Hyperlinkv0.8.0-beta.28

SchemaRepresentation

SchemaRepresentation.$Annotationsconsteffect/SchemaRepresentation.ts:797
Schema.decodeTo<
  Schema.$Record<Schema.String, Schema.Unknown>,
  Schema.$Record<
    Schema.String,
    Schema.Codec<PrimitiveTree, PrimitiveTree, never, never>
  >,
  never,
  never
>

Schema for serializing public Schema.Annotations.Annotations values. It filters out internal annotation keys and non-primitive values during encoding.

When to use

Use to serialize schema annotations in representation schemas while retaining only primitive-tree metadata.

Details

Decoding is passthrough. Encoding removes internal annotation keys and values that are not accepted by $PrimitiveTree.

export const $Annotations = Schema.Record(Schema.String, Schema.Unknown).pipe(
  Schema.encodeTo(Schema.Record(Schema.String, $PrimitiveTree), {
    decode: SchemaGetter.passthrough(),
    encode: SchemaGetter.transformOptional(Option.flatMap((r) => {
      const out: Record<string, typeof $PrimitiveTree["Type"]> = {}
      for (const [k, v] of Object.entries(r)) {
        if (!toJsonAnnotationsBlacklist.has(k) && isPrimitiveTree(v)) {
          out[k] = v
        }
      }
      return Rec.isEmptyRecord(out) ? Option.none() : Option.some(out)
    }))
  })
).annotate({ identifier: "Annotations" })
Referenced by 23 symbols