MCPcopy Create free account
hub / github.com/effect-app/libs / encodeKeys

Function encodeKeys

repos/effect/packages/effect/src/Schema.ts:3494–3526  ·  view source on GitHub ↗
(mapping: M)

Source from the content-addressed store, hash-verified

3492 * after the transformation.
3493 */
3494 mapFields<To extends Struct.Fields>(
3495 f: (fields: Fields) => To,
3496 options?: {
3497 readonly unsafePreserveChecks?: boolean | undefined
3498 } | undefined
3499 ): Struct<Simplify<Readonly<To>>>
3500}
3501
3502function makeStruct<const Fields extends Struct.Fields>(ast: SchemaAST.Objects, fields: Fields): Struct<Fields> {
3503 return make(ast, {
3504 fields,
3505 mapFields<To extends Struct.Fields>(
3506 this: Struct<Fields>,
3507 f: (fields: Fields) => To,
3508 options?: {
3509 readonly unsafePreserveChecks?: boolean | undefined
3510 } | undefined
3511 ): Struct<To> {
3512 const fields = f(this.fields)
3513 return makeStruct(SchemaAST.struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields)
3514 }
3515 })
3516}
3517
3518/**
3519 * Defines a struct schema from a map of field schemas.
3520 *
3521 * **Details**
3522 *
3523 * Each field value is a schema. Use {@link optionalKey} or {@link optional} to
3524 * mark fields as optional, and {@link mutableKey} to mark them as mutable.
3525 *
3526 * The resulting schema's `Type` is a readonly object type with the fields'
3527 * decoded types. The `Encoded` form mirrors the field schemas' encoded types.
3528 *
3529 * **Example** (Defining a basic struct)

Callers

nothing calls this directly

Calls 9

formatPropertyKeyFunction · 0.90
toEncodedInterface · 0.85
canonicalPropertyKeyFunction · 0.85
StructFunction · 0.70
decodeToFunction · 0.70
addMethod · 0.65
pipeMethod · 0.65
transformMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…