diff --git a/packages/effect/dtslint/SchemaClass.ts b/packages/effect/dtslint/SchemaClass.ts index 6ad1e25526f..1198c34d4f0 100644 --- a/packages/effect/dtslint/SchemaClass.ts +++ b/packages/effect/dtslint/SchemaClass.ts @@ -6,7 +6,7 @@ import * as S from "effect/Schema" // --------------------------------------------- type HasFields = S.Struct | { - readonly [S.refineTypeId]: HasFields + readonly [S.RefineSchemaId]: HasFields } declare const checkForConflicts: ( diff --git a/packages/effect/src/Arbitrary.ts b/packages/effect/src/Arbitrary.ts index 11ebfa36217..1e32ad4887c 100644 --- a/packages/effect/src/Arbitrary.ts +++ b/packages/effect/src/Arbitrary.ts @@ -21,41 +21,30 @@ export interface LazyArbitrary { } /** - * @category hooks - * @since 3.10.0 - */ -export const ArbitraryHookId: unique symbol = Symbol.for("effect/Schema/ArbitraryHookId") - -/** - * @category hooks - * @since 3.10.0 - */ -export type ArbitraryHookId = typeof ArbitraryHookId - -/** - * @category hooks + * @category annotations * @since 3.10.0 */ -export interface GenerationContext { +export interface ArbitraryGenerationContext { readonly depthIdentifier?: string readonly maxDepth: number } /** - * @category hooks + * @category annotations * @since 3.10.0 */ -export type ArbitraryAnnotation = ( - ...args: [...ReadonlyArray>, GenerationContext] +export type ArbitraryAnnotation = readonly []> = ( + ...arbitraries: [ + ...{ readonly [K in keyof TypeParameters]: LazyArbitrary }, + ctx: ArbitraryGenerationContext + ] ) => LazyArbitrary /** * @category annotations * @since 3.10.0 */ -export const arbitrary = - (annotation: ArbitraryAnnotation) => (self: Schema.Schema): Schema.Schema => - self.annotations({ [ArbitraryHookId]: annotation }) +export const ArbitraryAnnotationId: unique symbol = Symbol.for("effect/annotation/Arbitrary") /** * Returns a LazyArbitrary for the `A` type of the provided schema. @@ -74,7 +63,7 @@ export const makeLazy = (schema: Schema.Schema): LazyArbitrary */ export const make = (schema: Schema.Schema): FastCheck.Arbitrary => makeLazy(schema)(FastCheck) -const getHook = AST.getAnnotation>(ArbitraryHookId) +const getAnnotation = AST.getAnnotation>(ArbitraryAnnotationId) const getRefinementFromArbitrary = ( ast: AST.Refinement, @@ -121,7 +110,7 @@ const getSuspendedArray = ( ) } -interface Context extends GenerationContext { +interface Context extends ArbitraryGenerationContext { readonly constraints?: Constraints } @@ -130,15 +119,15 @@ const go = ( ctx: Context, path: ReadonlyArray ): LazyArbitrary => { - const hook = getHook(ast) - if (Option.isSome(hook)) { + const annotation = getAnnotation(ast) + if (Option.isSome(annotation)) { switch (ast._tag) { case "Declaration": - return hook.value(...ast.typeParameters.map((p) => go(p, ctx, path)), ctx) + return annotation.value(...ast.typeParameters.map((p) => go(p, ctx, path)), ctx) case "Refinement": - return hook.value(getRefinementFromArbitrary(ast, ctx, path), ctx) + return annotation.value(getRefinementFromArbitrary(ast, ctx, path), ctx) default: - return hook.value(ctx) + return annotation.value(ctx) } } switch (ast._tag) { @@ -442,40 +431,40 @@ export type Constraints = /** @internal */ export const getConstraints = (ast: AST.Refinement): Constraints | undefined => { - const TypeAnnotationId = ast.annotations[AST.TypeAnnotationId] + const TypeAnnotationId = ast.annotations[AST.SchemaIdAnnotationId] const jsonSchema: any = ast.annotations[AST.JSONSchemaAnnotationId] switch (TypeAnnotationId) { // int - case filters_.IntTypeId: + case filters_.IntSchemaId: return new IntegerConstraints({}) // number - case filters_.GreaterThanTypeId: - case filters_.GreaterThanOrEqualToTypeId: - case filters_.LessThanTypeId: - case filters_.LessThanOrEqualToTypeId: - case filters_.BetweenTypeId: + case filters_.GreaterThanSchemaId: + case filters_.GreaterThanOrEqualToSchemaId: + case filters_.LessThanSchemaId: + case filters_.LessThanOrEqualToSchemaId: + case filters_.BetweenSchemaId: return new NumberConstraints({ min: jsonSchema.exclusiveMinimum ?? jsonSchema.minimum, max: jsonSchema.exclusiveMaximum ?? jsonSchema.maximum }) // bigint - case filters_.GreaterThanBigintTypeId: - case filters_.GreaterThanOrEqualToBigIntTypeId: - case filters_.LessThanBigIntTypeId: - case filters_.LessThanOrEqualToBigIntTypeId: - case filters_.BetweenBigintTypeId: { + case filters_.GreaterThanBigintSchemaId: + case filters_.GreaterThanOrEqualToBigIntSchemaId: + case filters_.LessThanBigIntSchemaId: + case filters_.LessThanOrEqualToBigIntSchemaId: + case filters_.BetweenBigintSchemaId: { const constraints: any = ast.annotations[TypeAnnotationId] return new BigIntConstraints(constraints) } // string - case filters_.MinLengthTypeId: - case filters_.MaxLengthTypeId: - case filters_.LengthTypeId: + case filters_.MinLengthSchemaId: + case filters_.MaxLengthSchemaId: + case filters_.LengthSchemaId: return new StringConstraints(jsonSchema) // array - case filters_.MinItemsTypeId: - case filters_.MaxItemsTypeId: - case filters_.ItemsCountTypeId: + case filters_.MinItemsSchemaId: + case filters_.MaxItemsSchemaId: + case filters_.ItemsCountSchemaId: return new ArrayConstraints({ minLength: jsonSchema.minItems, maxLength: jsonSchema.maxItems diff --git a/packages/effect/src/JSONSchema.ts b/packages/effect/src/JSONSchema.ts index fd87635b726..a6e138db81b 100644 --- a/packages/effect/src/JSONSchema.ts +++ b/packages/effect/src/JSONSchema.ts @@ -3,7 +3,6 @@ */ import * as errors_ from "./internal/schema/errors.js" -import * as filters_ from "./internal/schema/filters.js" import * as Option from "./Option.js" import * as Predicate from "./Predicate.js" import * as Record from "./Record.js" @@ -319,7 +318,7 @@ const getRefinementInnerTransformation = (ast: AST.Refinement): AST.AST | undefi } const isParseJsonTransformation = (ast: AST.AST): boolean => - ast.annotations[AST.TypeAnnotationId] === filters_.ParseJsonTypeId + ast.annotations[AST.SchemaIdAnnotationId] === AST.ParseJsonSchemaId function merge(a: JsonSchemaAnnotations, b: JsonSchema7): JsonSchema7 function merge(a: JsonSchema7, b: JsonSchemaAnnotations): JsonSchema7 diff --git a/packages/effect/src/Pretty.ts b/packages/effect/src/Pretty.ts index 8da7db6e31c..ca9ba85a84e 100644 --- a/packages/effect/src/Pretty.ts +++ b/packages/effect/src/Pretty.ts @@ -18,24 +18,18 @@ export interface Pretty { } /** - * @category hooks - * @since 3.10.0 - */ -export const PrettyHookId: unique symbol = Symbol.for("effect/Schema/PrettyHookId") - -/** - * @category hooks + * @category annotations * @since 3.10.0 */ -export type PrettyHookId = typeof PrettyHookId +export type PrettyAnnotation = readonly []> = ( + ...pretties: { readonly [K in keyof TypeParameters]: Pretty } +) => Pretty /** * @category annotations * @since 3.10.0 */ -export const pretty = - (handler: (...args: ReadonlyArray>) => Pretty) => - (self: Schema.Schema): Schema.Schema => self.annotations({ [PrettyHookId]: handler }) +export const PrettyAnnotationId: unique symbol = Symbol.for("effect/annotation/Pretty") /** * @category prettify @@ -43,12 +37,10 @@ export const pretty = */ export const make = (schema: Schema.Schema): (a: A) => string => compile(schema.ast, []) -const getHook = AST.getAnnotation<(...args: ReadonlyArray>) => Pretty>( - PrettyHookId -) +const getAnnotation = AST.getAnnotation>(PrettyAnnotationId) const getMatcher = (defaultPretty: Pretty) => (ast: AST.AST): Pretty => - Option.match(getHook(ast), { + Option.match(getAnnotation(ast), { onNone: () => defaultPretty, onSome: (handler) => handler() }) @@ -64,9 +56,9 @@ const formatUnknown = getMatcher(util_.formatUnknown) */ export const match: AST.Match> = { "Declaration": (ast, go, path) => { - const hook = getHook(ast) - if (Option.isSome(hook)) { - return hook.value(...ast.typeParameters.map((tp) => go(tp, path))) + const annotation = getAnnotation(ast) + if (Option.isSome(annotation)) { + return annotation.value(...ast.typeParameters.map((tp) => go(tp, path))) } throw new Error(errors_.getPrettyMissingAnnotationErrorMessage(path, ast)) }, @@ -92,7 +84,7 @@ export const match: AST.Match> = { "BigIntKeyword": getMatcher((a) => `${String(a)}n`), "Enums": stringify, "TupleType": (ast, go, path) => { - const hook = getHook(ast) + const hook = getAnnotation(ast) if (Option.isSome(hook)) { return hook.value() } @@ -134,7 +126,7 @@ export const match: AST.Match> = { } }, "TypeLiteral": (ast, go, path) => { - const hook = getHook(ast) + const hook = getAnnotation(ast) if (Option.isSome(hook)) { return hook.value() } @@ -179,7 +171,7 @@ export const match: AST.Match> = { } }, "Union": (ast, go, path) => { - const hook = getHook(ast) + const hook = getAnnotation(ast) if (Option.isSome(hook)) { return hook.value() } @@ -193,7 +185,7 @@ export const match: AST.Match> = { } }, "Suspend": (ast, go, path) => { - return Option.match(getHook(ast), { + return Option.match(getAnnotation(ast), { onNone: () => { const get = util_.memoizeThunk(() => go(ast.f(), path)) return (a) => get()(a) @@ -202,13 +194,13 @@ export const match: AST.Match> = { }) }, "Refinement": (ast, go, path) => { - return Option.match(getHook(ast), { + return Option.match(getAnnotation(ast), { onNone: () => go(ast.from, path), onSome: (handler) => handler() }) }, "Transformation": (ast, go, path) => { - return Option.match(getHook(ast), { + return Option.match(getAnnotation(ast), { onNone: () => go(ast.to, path), onSome: (handler) => handler() }) diff --git a/packages/effect/src/Schema.ts b/packages/effect/src/Schema.ts index 2cf49aa73f7..9c1daeda282 100644 --- a/packages/effect/src/Schema.ts +++ b/packages/effect/src/Schema.ts @@ -3,7 +3,7 @@ */ import * as arbitrary_ from "./Arbitrary.js" -import type { GenerationContext, LazyArbitrary } from "./Arbitrary.js" +import type { ArbitraryGenerationContext, LazyArbitrary } from "./Arbitrary.js" import * as array_ from "./Array.js" import * as bigDecimal_ from "./BigDecimal.js" import * as bigInt_ from "./BigInt.js" @@ -69,7 +69,7 @@ export type SimplifyMutable = { * @since 3.10.0 * @category symbol */ -export const TypeId: unique symbol = Symbol.for("effect/Schema/Schema") +export const TypeId: unique symbol = Symbol.for("effect/Schema") /** * @since 3.10.0 @@ -135,52 +135,42 @@ interface AllAnnotations> extends Annotations.Schema, PropertySignature.Annotations {} +const builtInAnnotations = { + schemaId: AST.SchemaIdAnnotationId, + message: AST.MessageAnnotationId, + missingMessage: AST.MissingMessageAnnotationId, + identifier: AST.IdentifierAnnotationId, + title: AST.TitleAnnotationId, + description: AST.DescriptionAnnotationId, + examples: AST.ExamplesAnnotationId, + default: AST.DefaultAnnotationId, + documentation: AST.DocumentationAnnotationId, + jsonSchema: AST.JSONSchemaAnnotationId, + arbitrary: arbitrary_.ArbitraryAnnotationId, + pretty: pretty_.PrettyAnnotationId, + equivalence: equivalence_.EquivalenceAnnotationId, + concurrency: AST.ConcurrencyAnnotationId, + batching: AST.BatchingAnnotationId, + parseIssueTitle: AST.ParseIssueTitleAnnotationId, + parseOptions: AST.ParseOptionsAnnotationId, + decodingFallback: AST.DecodingFallbackAnnotationId +} + const toASTAnnotations = >( annotations?: AllAnnotations ): AST.Annotations => { if (!annotations) { return {} } - const out: Types.Mutable = {} - - // symbols are reserved for custom annotations - const custom = Object.getOwnPropertySymbols(annotations) - for (const sym of custom) { - out[sym] = annotations[sym] - } + const out: Types.Mutable = { ...annotations } - // string keys are reserved as /schema namespace - if (annotations.typeId !== undefined) { - const typeId = annotations.typeId - if (typeof typeId === "object") { - out[AST.TypeAnnotationId] = typeId.id - out[typeId.id] = typeId.annotation - } else { - out[AST.TypeAnnotationId] = typeId - } - } - const move = (from: keyof typeof annotations, to: symbol) => { - if (annotations[from] !== undefined) { - out[to] = annotations[from] + for (const key in builtInAnnotations) { + if (key in annotations) { + const id = builtInAnnotations[key as keyof typeof builtInAnnotations] + out[id] = annotations[key as keyof typeof annotations] + delete out[key] } } - move("message", AST.MessageAnnotationId) - move("missingMessage", AST.MissingMessageAnnotationId) - move("identifier", AST.IdentifierAnnotationId) - move("title", AST.TitleAnnotationId) - move("description", AST.DescriptionAnnotationId) - move("examples", AST.ExamplesAnnotationId) - move("default", AST.DefaultAnnotationId) - move("documentation", AST.DocumentationAnnotationId) - move("jsonSchema", AST.JSONSchemaAnnotationId) - move("arbitrary", arbitrary_.ArbitraryHookId) - move("pretty", pretty_.PrettyHookId) - move("equivalence", equivalence_.EquivalenceHookId) - move("concurrency", AST.ConcurrencyAnnotationId) - move("batching", AST.BatchingAnnotationId) - move("parseIssueTitle", AST.ParseIssueTitleAnnotationId) - move("parseOptions", AST.ParseOptionsAnnotationId) - move("decodingFallback", AST.DecodingFallbackAnnotationId) return out } @@ -951,10 +941,10 @@ export const declare: { } as any /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const BrandTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Brand") +export const BrandSchemaId: unique symbol = Symbol.for("effect/SchemaId/Brand") /** * @category constructors @@ -974,15 +964,19 @@ export const fromBrand = , A extends Brand.Unbr option_.some(new ParseResult.Type(ast, a, either.left.map((v) => v.message).join(", "))) : option_.none() }, - toASTAnnotations({ typeId: { id: BrandTypeId, annotation: { constructor } }, ...annotations }) + toASTAnnotations({ + schemaId: BrandSchemaId, + [BrandSchemaId]: { constructor }, + ...annotations + }) ) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const InstanceOfTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/InstanceOf") +export const InstanceOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/InstanceOf") /** * @category api interface @@ -1004,7 +998,8 @@ export const instanceOf = any>( title: constructor.name, description: `an instance of ${constructor.name}`, pretty: (): pretty_.Pretty> => String, - typeId: { id: InstanceOfTypeId, annotation: { constructor } }, + schemaId: InstanceOfSchemaId, + [InstanceOfSchemaId]: { constructor }, ...annotations } ) @@ -1669,7 +1664,7 @@ const mergeSignatureAnnotations = ( * @since 3.10.0 * @category symbol */ -export const PropertySignatureTypeId: unique symbol = Symbol.for("effect/Schema/PropertySignature") +export const PropertySignatureTypeId: unique symbol = Symbol.for("effect/PropertySignature") /** * @since 3.10.0 @@ -3309,13 +3304,13 @@ export const suspend = (f: () => Schema): suspend => * @since 3.10.0 * @category symbol */ -export const refineTypeId: unique symbol = Symbol.for("effect/Schema/refine") +export const RefineSchemaId: unique symbol = Symbol.for("effect/SchemaId/Refine") /** * @since 3.10.0 * @category symbol */ -export type refineTypeId = typeof refineTypeId +export type RefineSchemaId = typeof RefineSchemaId /** * @category api interface @@ -3324,7 +3319,7 @@ export type refineTypeId = typeof refineTypeId export interface refine extends AnnotableClass, A, Schema.Encoded, Schema.Context> { - readonly [refineTypeId]: From + readonly [RefineSchemaId]: From // required for `type HasFields = ...` readonly from: From readonly filter: ( a: Schema.Type, @@ -3348,7 +3343,7 @@ const makeRefineClass = ( return makeRefineClass(this.from, this.filter, mergeSchemaAnnotations(this.ast, annotations)) } - static [refineTypeId] = from + static [RefineSchemaId] = from static from = from @@ -3872,20 +3867,11 @@ export declare namespace Annotations { export interface Schema = readonly []> extends Doc { readonly identifier?: AST.IdentifierAnnotation readonly message?: AST.MessageAnnotation - readonly typeId?: AST.TypeAnnotation | { id: AST.TypeAnnotation; annotation: unknown } + readonly schemaId?: AST.SchemaIdAnnotation readonly jsonSchema?: AST.JSONSchemaAnnotation - readonly arbitrary?: ( - ...arbitraries: [ - ...{ readonly [K in keyof TypeParameters]: LazyArbitrary }, - ctx: GenerationContext - ] - ) => LazyArbitrary - readonly pretty?: ( - ...pretties: { readonly [K in keyof TypeParameters]: pretty_.Pretty } - ) => pretty_.Pretty - readonly equivalence?: ( - ...equivalences: { readonly [K in keyof TypeParameters]: Equivalence.Equivalence } - ) => Equivalence.Equivalence + readonly arbitrary?: arbitrary_.ArbitraryAnnotation + readonly pretty?: pretty_.PrettyAnnotation + readonly equivalence?: equivalence_.EquivalenceAnnotation readonly concurrency?: AST.ConcurrencyAnnotation readonly batching?: AST.BatchingAnnotation readonly parseIssueTitle?: AST.ParseIssueTitleAnnotation @@ -3962,10 +3948,10 @@ export const rename: { ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const TrimmedTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Trimmed") +export const TrimmedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Trimmed") /** * Verifies that a string contains no leading or trailing whitespaces. @@ -3980,7 +3966,7 @@ export const trimmed = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a === a.trim(), { - typeId: TrimmedTypeId, + schemaId: TrimmedSchemaId, description: "a string with no leading or trailing whitespace", jsonSchema: { pattern: "^\\S[\\s\\S]*\\S$|^\\S$|^$" }, ...annotations @@ -3988,16 +3974,16 @@ export const trimmed = ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const MaxLengthTypeId: unique symbol = filters_.MaxLengthTypeId +export const MaxLengthSchemaId: unique symbol = filters_.MaxLengthSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type MaxLengthTypeId = typeof MaxLengthTypeId +export type MaxLengthSchemaId = typeof MaxLengthSchemaId /** * @category string filters @@ -4012,7 +3998,7 @@ export const maxLength = ( filter( (a) => a.length <= maxLength, { - typeId: MaxLengthTypeId, + schemaId: MaxLengthSchemaId, description: `a string at most ${maxLength} character(s) long`, jsonSchema: { maxLength }, ...annotations @@ -4021,16 +4007,16 @@ export const maxLength = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const MinLengthTypeId: unique symbol = filters_.MinLengthTypeId +export const MinLengthSchemaId: unique symbol = filters_.MinLengthSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type MinLengthTypeId = typeof MinLengthTypeId +export type MinLengthSchemaId = typeof MinLengthSchemaId /** * @category string filters @@ -4045,7 +4031,7 @@ export const minLength = ( filter( (a) => a.length >= minLength, { - typeId: MinLengthTypeId, + schemaId: MinLengthSchemaId, description: `a string at least ${minLength} character(s) long`, jsonSchema: { minLength }, ...annotations @@ -4054,10 +4040,10 @@ export const minLength = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const PatternTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Pattern") +export const PatternSchemaId: unique symbol = Symbol.for("effect/SchemaId/Pattern") /** * @category string filters @@ -4077,7 +4063,8 @@ export const pattern = ( return regex.test(a) }, { - typeId: { id: PatternTypeId, annotation: { regex } }, + schemaId: PatternSchemaId, + [PatternSchemaId]: { regex }, description: `a string matching the pattern ${pattern}`, jsonSchema: { pattern }, arbitrary: () => (fc) => fc.stringMatching(regex) as any, @@ -4088,10 +4075,10 @@ export const pattern = ( } /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const StartsWithTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/StartsWith") +export const StartsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/StartsWith") /** * @category string filters @@ -4106,7 +4093,8 @@ export const startsWith = ( filter( (a) => a.startsWith(startsWith), { - typeId: { id: StartsWithTypeId, annotation: { startsWith } }, + schemaId: StartsWithSchemaId, + [StartsWithSchemaId]: { startsWith }, description: `a string starting with ${JSON.stringify(startsWith)}`, jsonSchema: { pattern: `^${startsWith}` }, ...annotations @@ -4115,10 +4103,10 @@ export const startsWith = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const EndsWithTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/EndsWith") +export const EndsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/EndsWith") /** * @category string filters @@ -4133,7 +4121,8 @@ export const endsWith = ( filter( (a) => a.endsWith(endsWith), { - typeId: { id: EndsWithTypeId, annotation: { endsWith } }, + schemaId: EndsWithSchemaId, + [EndsWithSchemaId]: { endsWith }, description: `a string ending with ${JSON.stringify(endsWith)}`, jsonSchema: { pattern: `^.*${endsWith}$` }, ...annotations @@ -4142,10 +4131,10 @@ export const endsWith = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const IncludesTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Includes") +export const IncludesSchemaId: unique symbol = Symbol.for("effect/SchemaId/Includes") /** * @category string filters @@ -4160,7 +4149,8 @@ export const includes = ( filter( (a) => a.includes(searchString), { - typeId: { id: IncludesTypeId, annotation: { includes: searchString } }, + schemaId: IncludesSchemaId, + [IncludesSchemaId]: { includes: searchString }, description: `a string including ${JSON.stringify(searchString)}`, jsonSchema: { pattern: `.*${searchString}.*` }, ...annotations @@ -4169,10 +4159,10 @@ export const includes = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LowercasedTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Lowercased") +export const LowercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Lowercased") /** * Verifies that a string is lowercased. @@ -4184,7 +4174,7 @@ export const lowercased = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a === a.toLowerCase(), { - typeId: LowercasedTypeId, + schemaId: LowercasedSchemaId, description: "a lowercase string", ...annotations }) @@ -4199,10 +4189,10 @@ export class Lowercased extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const CapitalizedTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Capitalized") +export const CapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Capitalized") /** * Verifies that a string is capitalized. @@ -4214,7 +4204,7 @@ export const capitalized = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a[0]?.toUpperCase() === a[0], { - typeId: CapitalizedTypeId, + schemaId: CapitalizedSchemaId, description: "a capitalized string", ...annotations }) @@ -4229,10 +4219,10 @@ export class Capitalized extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const UncapitalizedTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Uncapitalized") +export const UncapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uncapitalized") /** * Verifies that a string is uncapitalized. @@ -4244,7 +4234,7 @@ export const uncapitalized = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a[0]?.toLowerCase() === a[0], { - typeId: UncapitalizedTypeId, + schemaId: UncapitalizedSchemaId, description: "a uncapitalized string", ...annotations }) @@ -4259,10 +4249,10 @@ export class Uncapitalized extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const UppercasedTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Uppercased") +export const UppercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uppercased") /** * Verifies that a string is uppercased. @@ -4274,7 +4264,7 @@ export const uppercased = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a === a.toUpperCase(), { - typeId: UppercasedTypeId, + schemaId: UppercasedSchemaId, description: "an uppercase string", ...annotations }) @@ -4289,16 +4279,16 @@ export class Uppercased extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LengthTypeId: unique symbol = filters_.LengthTypeId +export const LengthSchemaId: unique symbol = filters_.LengthSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type LengthTypeId = typeof LengthTypeId +export type LengthSchemaId = typeof LengthSchemaId /** * @category string filters @@ -4314,7 +4304,7 @@ export const length = ( if (minLength !== maxLength) { return self.pipe( filter((a) => a.length >= minLength && a.length <= maxLength, { - typeId: LengthTypeId, + schemaId: LengthSchemaId, description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`, jsonSchema: { minLength, maxLength }, ...annotations @@ -4323,7 +4313,7 @@ export const length = ( } return self.pipe( filter((a) => a.length === minLength, { - typeId: LengthTypeId, + schemaId: LengthSchemaId, description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`, jsonSchema: { minLength, maxLength: minLength }, ...annotations @@ -4482,7 +4472,7 @@ const getParseJsonTransformation = (options?: ParseJsonOptions) => catch: (e: any) => new ParseResult.Type(ast, u, e.message) }) } - ).annotations({ typeId: filters_.ParseJsonTypeId }) + ).annotations({ schemaId: AST.ParseJsonSchemaId }) /** * The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying @@ -4504,10 +4494,10 @@ const getParseJsonTransformation = (options?: ParseJsonOptions) => export const parseJson: { (schema: Schema, options?: ParseJsonOptions): SchemaClass (options?: ParseJsonOptions): SchemaClass -} = (schema?: Schema | ParseJsonOptions, o?: ParseJsonOptions) => - isSchema(schema) - ? compose(parseJson(o), schema) as any - : getParseJsonTransformation(schema as ParseJsonOptions | undefined) +} = (schemaOrOptions?: Schema | ParseJsonOptions, o?: ParseJsonOptions) => + isSchema(schemaOrOptions) + ? compose(parseJson(o), schemaOrOptions) as any + : getParseJsonTransformation(schemaOrOptions as ParseJsonOptions | undefined) /** * @category string constructors @@ -4518,10 +4508,10 @@ export class NonEmptyString extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const UUIDTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/UUID") +export const UUIDSchemaId: unique symbol = Symbol.for("effect/SchemaId/UUID") const uuidRegexp = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i @@ -4535,7 +4525,7 @@ const uuidRegexp = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4} */ export class UUID extends String$.pipe( pattern(uuidRegexp, { - typeId: UUIDTypeId, + schemaId: UUIDSchemaId, identifier: "UUID", title: "UUID", description: "a Universally Unique Identifier", @@ -4544,10 +4534,10 @@ export class UUID extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const ULIDTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/ULID") +export const ULIDSchemaId: unique symbol = Symbol.for("effect/SchemaId/ULID") const ulidRegexp = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i @@ -4562,7 +4552,7 @@ const ulidRegexp = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i */ export class ULID extends String$.pipe( pattern(ulidRegexp, { - typeId: ULIDTypeId, + schemaId: ULIDSchemaId, identifier: "ULID", title: "ULID", description: "a Universally Unique Lexicographically Sortable Identifier", @@ -4571,10 +4561,10 @@ export class ULID extends String$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const FiniteTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/Finite") +export const FiniteSchemaId: unique symbol = Symbol.for("effect/SchemaId/Finite") /** * Ensures that the provided value is a finite number. @@ -4588,23 +4578,23 @@ export const finite = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => Number.isFinite(a), { - typeId: FiniteTypeId, + schemaId: FiniteSchemaId, description: "a finite number", ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanTypeId: unique symbol = filters_.GreaterThanTypeId +export const GreaterThanSchemaId: unique symbol = filters_.GreaterThanSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type GreaterThanTypeId = typeof GreaterThanTypeId +export type GreaterThanSchemaId = typeof GreaterThanSchemaId /** * This filter checks whether the provided number is greater than the specified minimum. @@ -4619,7 +4609,7 @@ export const greaterThan = ( (self: Schema): filter> => self.pipe( filter((a) => a > min, { - typeId: GreaterThanTypeId, + schemaId: GreaterThanSchemaId, description: min === 0 ? "a positive number" : `a number greater than ${min}`, jsonSchema: { exclusiveMinimum: min }, ...annotations @@ -4627,16 +4617,16 @@ export const greaterThan = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanOrEqualToTypeId: unique symbol = filters_.GreaterThanOrEqualToTypeId +export const GreaterThanOrEqualToSchemaId: unique symbol = filters_.GreaterThanOrEqualToSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type GreaterThanOrEqualToTypeId = typeof GreaterThanOrEqualToTypeId +export type GreaterThanOrEqualToSchemaId = typeof GreaterThanOrEqualToSchemaId /** * This filter checks whether the provided number is greater than or equal to the specified minimum. @@ -4651,7 +4641,7 @@ export const greaterThanOrEqualTo = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min, { - typeId: GreaterThanOrEqualToTypeId, + schemaId: GreaterThanOrEqualToSchemaId, description: min === 0 ? "a non-negative number" : `a number greater than or equal to ${min}`, jsonSchema: { minimum: min }, ...annotations @@ -4659,10 +4649,10 @@ export const greaterThanOrEqualTo = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const MultipleOfTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/MultipleOf") +export const MultipleOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/MultipleOf") /** * @category number filters @@ -4675,7 +4665,7 @@ export const multipleOf = ( (self: Schema): filter> => self.pipe( filter((a) => number_.remainder(a, divisor) === 0, { - typeId: MultipleOfTypeId, + schemaId: MultipleOfSchemaId, description: `a number divisible by ${divisor}`, jsonSchema: { multipleOf: Math.abs(divisor) }, // spec requires positive divisor ...annotations @@ -4683,16 +4673,16 @@ export const multipleOf = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const IntTypeId: unique symbol = filters_.IntTypeId +export const IntSchemaId: unique symbol = filters_.IntSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type IntTypeId = typeof IntTypeId +export type IntSchemaId = typeof IntSchemaId /** * @category number filters @@ -4702,7 +4692,7 @@ export const int = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => Number.isSafeInteger(a), { - typeId: IntTypeId, + schemaId: IntSchemaId, title: "integer", description: "an integer", jsonSchema: { type: "integer" }, @@ -4711,16 +4701,16 @@ export const int = ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanTypeId: unique symbol = filters_.LessThanTypeId +export const LessThanSchemaId: unique symbol = filters_.LessThanSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type LessThanTypeId = typeof LessThanTypeId +export type LessThanSchemaId = typeof LessThanSchemaId /** * This filter checks whether the provided number is less than the specified maximum. @@ -4733,7 +4723,7 @@ export const lessThan = (self: Schema): filter> => self.pipe( filter((a) => a < max, { - typeId: LessThanTypeId, + schemaId: LessThanSchemaId, description: max === 0 ? "a negative number" : `a number less than ${max}`, jsonSchema: { exclusiveMaximum: max }, ...annotations @@ -4741,16 +4731,16 @@ export const lessThan = ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanOrEqualToTypeId: unique symbol = filters_.LessThanOrEqualToTypeId +export const LessThanOrEqualToSchemaId: unique symbol = filters_.LessThanOrEqualToSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type LessThanOrEqualToTypeId = typeof LessThanOrEqualToTypeId +export type LessThanOrEqualToSchemaId = typeof LessThanOrEqualToSchemaId /** * This schema checks whether the provided number is less than or equal to the specified maximum. @@ -4765,7 +4755,7 @@ export const lessThanOrEqualTo = ( (self: Schema): filter> => self.pipe( filter((a) => a <= max, { - typeId: LessThanOrEqualToTypeId, + schemaId: LessThanOrEqualToSchemaId, description: max === 0 ? "a non-positive number" : `a number less than or equal to ${max}`, jsonSchema: { maximum: max }, ...annotations @@ -4773,16 +4763,16 @@ export const lessThanOrEqualTo = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const BetweenTypeId: unique symbol = filters_.BetweenTypeId +export const BetweenSchemaId: unique symbol = filters_.BetweenSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type BetweenTypeId = typeof BetweenTypeId +export type BetweenSchemaId = typeof BetweenSchemaId /** * This filter checks whether the provided number falls within the specified minimum and maximum values. @@ -4798,7 +4788,7 @@ export const between = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min && a <= max, { - typeId: BetweenTypeId, + schemaId: BetweenSchemaId, description: `a number between ${min} and ${max}`, jsonSchema: { maximum: max, minimum: min }, ...annotations @@ -4806,10 +4796,10 @@ export const between = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const NonNaNTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/NonNaN") +export const NonNaNSchemaId: unique symbol = Symbol.for("effect/SchemaId/NonNaN") /** * @category number filters @@ -4819,7 +4809,7 @@ export const nonNaN = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => !Number.isNaN(a), { - typeId: NonNaNTypeId, + schemaId: NonNaNSchemaId, description: "a number excluding NaN", ...annotations }) @@ -4960,10 +4950,10 @@ export class NonNegative extends Number$.pipe( ) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const JsonNumberTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/JsonNumber") +export const JsonNumberSchemaId: unique symbol = Symbol.for("effect/SchemaId/JsonNumber") /** * The `JsonNumber` is a schema for representing JSON numbers. It ensures that the provided value is a valid @@ -4985,7 +4975,7 @@ export const JsonNumberTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/ */ export class JsonNumber extends Number$.pipe( filter((n) => !Number.isNaN(n) && Number.isFinite(n), { - typeId: JsonNumberTypeId, + schemaId: JsonNumberSchemaId, identifier: "JsonNumber", title: "JSON-compatible number", description: "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity", @@ -5021,16 +5011,16 @@ export { } /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanBigIntTypeId: unique symbol = filters_.GreaterThanBigintTypeId +export const GreaterThanBigIntSchemaId: unique symbol = filters_.GreaterThanBigintSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type GreaterThanBigIntTypeId = typeof GreaterThanBigIntTypeId +export type GreaterThanBigIntSchemaId = typeof GreaterThanBigIntSchemaId /** * @category bigint filters @@ -5043,23 +5033,24 @@ export const greaterThanBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a > min, { - typeId: { id: GreaterThanBigIntTypeId, annotation: { min } }, + schemaId: GreaterThanBigIntSchemaId, + [GreaterThanBigIntSchemaId]: { min }, description: min === 0n ? "a positive bigint" : `a bigint greater than ${min}n`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanOrEqualToBigIntTypeId: unique symbol = filters_.GreaterThanOrEqualToBigIntTypeId +export const GreaterThanOrEqualToBigIntSchemaId: unique symbol = filters_.GreaterThanOrEqualToBigIntSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type GreaterThanOrEqualToBigIntTypeId = typeof GreaterThanOrEqualToBigIntTypeId +export type GreaterThanOrEqualToBigIntSchemaId = typeof GreaterThanOrEqualToBigIntSchemaId /** * @category bigint filters @@ -5072,7 +5063,8 @@ export const greaterThanOrEqualToBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min, { - typeId: { id: GreaterThanOrEqualToBigIntTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToBigIntSchemaId, + [GreaterThanOrEqualToBigIntSchemaId]: { min }, description: min === 0n ? "a non-negative bigint" : `a bigint greater than or equal to ${min}n`, @@ -5081,16 +5073,16 @@ export const greaterThanOrEqualToBigInt = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanBigIntTypeId: unique symbol = filters_.LessThanBigIntTypeId +export const LessThanBigIntSchemaId: unique symbol = filters_.LessThanBigIntSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type LessThanBigIntTypeId = typeof LessThanBigIntTypeId +export type LessThanBigIntSchemaId = typeof LessThanBigIntSchemaId /** * @category bigint filters @@ -5103,23 +5095,24 @@ export const lessThanBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a < max, { - typeId: { id: LessThanBigIntTypeId, annotation: { max } }, + schemaId: LessThanBigIntSchemaId, + [LessThanBigIntSchemaId]: { max }, description: max === 0n ? "a negative bigint" : `a bigint less than ${max}n`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanOrEqualToBigIntTypeId: unique symbol = filters_.LessThanOrEqualToBigIntTypeId +export const LessThanOrEqualToBigIntSchemaId: unique symbol = filters_.LessThanOrEqualToBigIntSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type LessThanOrEqualToBigIntTypeId = typeof LessThanOrEqualToBigIntTypeId +export type LessThanOrEqualToBigIntSchemaId = typeof LessThanOrEqualToBigIntSchemaId /** * @category bigint filters @@ -5132,23 +5125,24 @@ export const lessThanOrEqualToBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a <= max, { - typeId: { id: LessThanOrEqualToBigIntTypeId, annotation: { max } }, + schemaId: LessThanOrEqualToBigIntSchemaId, + [LessThanOrEqualToBigIntSchemaId]: { max }, description: max === 0n ? "a non-positive bigint" : `a bigint less than or equal to ${max}n`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const BetweenBigIntTypeId: unique symbol = filters_.BetweenBigintTypeId +export const BetweenBigIntSchemaId: unique symbol = filters_.BetweenBigintSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type BetweenBigIntTypeId = typeof BetweenBigIntTypeId +export type BetweenBigIntSchemaId = typeof BetweenBigIntSchemaId /** * @category bigint filters @@ -5162,7 +5156,8 @@ export const betweenBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min && a <= max, { - typeId: { id: BetweenBigIntTypeId, annotation: { max, min } }, + schemaId: BetweenBigIntSchemaId, + [BetweenBigIntSchemaId]: { max, min }, description: `a bigint between ${min}n and ${max}n`, ...annotations }) @@ -5519,10 +5514,10 @@ export const clampDuration = ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanDurationTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/LessThanDuration") +export const LessThanDurationSchemaId: unique symbol = Symbol.for("effect/SchemaId/LessThanDuration") /** * @category Duration filters @@ -5535,18 +5530,19 @@ export const lessThanDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.lessThan(a, max), { - typeId: { id: LessThanDurationTypeId, annotation: { max } }, + schemaId: LessThanDurationSchemaId, + [LessThanDurationSchemaId]: { max }, description: `a Duration less than ${duration_.decode(max)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanOrEqualToDurationTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/LessThanOrEqualToDuration" +export const LessThanOrEqualToDurationSchemaId: unique symbol = Symbol.for( + "effect/schema/LessThanOrEqualToDuration" ) /** @@ -5560,17 +5556,18 @@ export const lessThanOrEqualToDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.lessThanOrEqualTo(a, max), { - typeId: { id: LessThanDurationTypeId, annotation: { max } }, + schemaId: LessThanDurationSchemaId, + [LessThanDurationSchemaId]: { max }, description: `a Duration less than or equal to ${duration_.decode(max)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanDurationTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/GreaterThanDuration") +export const GreaterThanDurationSchemaId: unique symbol = Symbol.for("effect/SchemaId/GreaterThanDuration") /** * @category Duration filters @@ -5583,18 +5580,19 @@ export const greaterThanDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.greaterThan(a, min), { - typeId: { id: GreaterThanDurationTypeId, annotation: { min } }, + schemaId: GreaterThanDurationSchemaId, + [GreaterThanDurationSchemaId]: { min }, description: `a Duration greater than ${duration_.decode(min)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanOrEqualToDurationTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/GreaterThanOrEqualToDuration" +export const GreaterThanOrEqualToDurationSchemaId: unique symbol = Symbol.for( + "effect/schema/GreaterThanOrEqualToDuration" ) /** @@ -5608,17 +5606,18 @@ export const greaterThanOrEqualToDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.greaterThanOrEqualTo(a, min), { - typeId: { id: GreaterThanOrEqualToDurationTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToDurationSchemaId, + [GreaterThanOrEqualToDurationSchemaId]: { min }, description: `a Duration greater than or equal to ${duration_.decode(min)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const BetweenDurationTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/BetweenDuration") +export const BetweenDurationSchemaId: unique symbol = Symbol.for("effect/SchemaId/BetweenDuration") /** * @category Duration filters @@ -5632,7 +5631,8 @@ export const betweenDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.between(a, { minimum, maximum }), { - typeId: { id: BetweenDurationTypeId, annotation: { maximum, minimum } }, + schemaId: BetweenDurationSchemaId, + [BetweenDurationSchemaId]: { maximum, minimum }, description: `a Duration between ${duration_.decode(minimum)} and ${duration_.decode(maximum)}`, ...annotations }) @@ -5786,16 +5786,16 @@ export const StringFromHex: Schema = makeEncodingTransformation( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const MinItemsTypeId: unique symbol = filters_.MinItemsTypeId +export const MinItemsSchemaId: unique symbol = filters_.MinItemsSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type MinItemsTypeId = typeof MinItemsTypeId +export type MinItemsSchemaId = typeof MinItemsSchemaId /** * @category ReadonlyArray filters @@ -5816,7 +5816,7 @@ export const minItems = ( filter( (a) => a.length >= minItems, { - typeId: MinItemsTypeId, + schemaId: MinItemsSchemaId, description: `an array of at least ${minItems} items`, jsonSchema: { minItems }, [AST.StableFilterAnnotationId]: true, @@ -5827,16 +5827,16 @@ export const minItems = ( } /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const MaxItemsTypeId: unique symbol = filters_.MaxItemsTypeId +export const MaxItemsSchemaId: unique symbol = filters_.MaxItemsSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type MaxItemsTypeId = typeof MaxItemsTypeId +export type MaxItemsSchemaId = typeof MaxItemsSchemaId /** * @category ReadonlyArray filters @@ -5849,7 +5849,7 @@ export const maxItems = ( (self: Schema, I, R>): filter, I, R>> => self.pipe( filter((a) => a.length <= n, { - typeId: MaxItemsTypeId, + schemaId: MaxItemsSchemaId, description: `an array of at most ${n} items`, jsonSchema: { maxItems: n }, [AST.StableFilterAnnotationId]: true, @@ -5858,16 +5858,16 @@ export const maxItems = ( ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const ItemsCountTypeId: unique symbol = filters_.ItemsCountTypeId +export const ItemsCountSchemaId: unique symbol = filters_.ItemsCountSchemaId /** - * @category type id + * @category schema id * @since 3.10.0 */ -export type ItemsCountTypeId = typeof ItemsCountTypeId +export type ItemsCountSchemaId = typeof ItemsCountSchemaId /** * @category ReadonlyArray filters @@ -5880,7 +5880,7 @@ export const itemsCount = ( (self: Schema, I, R>): filter, I, R>> => self.pipe( filter((a) => a.length === n, { - typeId: ItemsCountTypeId, + schemaId: ItemsCountSchemaId, description: `an array of exactly ${n} item(s)`, jsonSchema: { minItems: n, maxItems: n }, [AST.StableFilterAnnotationId]: true, @@ -5940,10 +5940,10 @@ export const headOrElse: { ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const ValidDateTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/ValidDate") +export const ValidDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/ValidDate") /** * Defines a filter that specifically rejects invalid dates, such as `new @@ -5958,17 +5958,17 @@ export const validDate = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => !Number.isNaN(a.getTime()), { - typeId: ValidDateTypeId, + schemaId: ValidDateSchemaId, description: "a valid Date", ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanDateTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/LessThanDate") +export const LessThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/LessThanDate") /** * @category Date filters @@ -5981,18 +5981,19 @@ export const lessThanDate = ( (self: Schema): filter> => self.pipe( filter((a) => a < max, { - typeId: { id: LessThanDateTypeId, annotation: { max } }, + schemaId: LessThanDateSchemaId, + [LessThanDateSchemaId]: { max }, description: `a date before ${util_.formatDate(max)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanOrEqualToDateTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/LessThanOrEqualToDate" +export const LessThanOrEqualToDateSchemaId: unique symbol = Symbol.for( + "effect/schema/LessThanOrEqualToDate" ) /** @@ -6006,17 +6007,18 @@ export const lessThanOrEqualToDate = ( (self: Schema): filter> => self.pipe( filter((a) => a <= max, { - typeId: { id: LessThanDateTypeId, annotation: { max } }, + schemaId: LessThanDateSchemaId, + [LessThanDateSchemaId]: { max }, description: `a date before or equal to ${util_.formatDate(max)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanDateTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/GreaterThanDate") +export const GreaterThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/GreaterThanDate") /** * @category Date filters @@ -6029,18 +6031,19 @@ export const greaterThanDate = ( (self: Schema): filter> => self.pipe( filter((a) => a > min, { - typeId: { id: GreaterThanDateTypeId, annotation: { min } }, + schemaId: GreaterThanDateSchemaId, + [GreaterThanDateSchemaId]: { min }, description: `a date after ${util_.formatDate(min)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanOrEqualToDateTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/GreaterThanOrEqualToDate" +export const GreaterThanOrEqualToDateSchemaId: unique symbol = Symbol.for( + "effect/schema/GreaterThanOrEqualToDate" ) /** @@ -6054,17 +6057,18 @@ export const greaterThanOrEqualToDate = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min, { - typeId: { id: GreaterThanOrEqualToDateTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToDateSchemaId, + [GreaterThanOrEqualToDateSchemaId]: { min }, description: `a date after or equal to ${util_.formatDate(min)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const BetweenDateTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/BetweenDate") +export const BetweenDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/BetweenDate") /** * @category Date filters @@ -6078,7 +6082,8 @@ export const betweenDate = ( (self: Schema): filter> => self.pipe( filter((a) => a <= maximum && a >= minimum, { - typeId: { id: BetweenDateTypeId, annotation: { maximum, minimum } }, + schemaId: BetweenDateSchemaId, + [BetweenDateSchemaId]: { maximum, minimum }, description: `a date between ${util_.formatDate(minimum)} and ${util_.formatDate(maximum)}`, ...annotations }) @@ -6406,7 +6411,7 @@ const optionDecode = (input: OptionEncoded): option_.Option => input._tag === "None" ? option_.none() : option_.some(input.value) const optionArbitrary = - (value: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => + (value: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => fc.oneof( ctx, fc.record({ _tag: fc.constant("None" as const) }), @@ -6829,7 +6834,7 @@ export const EitherFromUnion = ({ le const mapArbitrary = ( key: LazyArbitrary, value: LazyArbitrary, - ctx: GenerationContext + ctx: ArbitraryGenerationContext ): LazyArbitrary> => { return (fc) => { const items = fc.array(fc.tuple(key(fc), value(fc))) @@ -7033,10 +7038,11 @@ export const MapFromRecord = ({ key, value }: { } ) -const setArbitrary = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => new Set(as)) -} +const setArbitrary = + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => new Set(as)) + } const readonlySetPretty = (item: pretty_.Pretty): pretty_.Pretty> => (set) => `new Set([${Array.from(set.values()).map((a) => item(a)).join(", ")}])` @@ -7223,10 +7229,10 @@ export class BigDecimalFromNumber extends transformOrFail( ).annotations({ identifier: "BigDecimalFromNumber" }) {} /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanBigDecimalTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/GreaterThanBigDecimal") +export const GreaterThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/SchemaId/GreaterThanBigDecimal") /** * @category BigDecimal filters @@ -7239,18 +7245,19 @@ export const greaterThanBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.greaterThan(a, min), { - typeId: { id: GreaterThanBigDecimalTypeId, annotation: { min } }, + schemaId: GreaterThanBigDecimalSchemaId, + [GreaterThanBigDecimalSchemaId]: { min }, description: `a BigDecimal greater than ${bigDecimal_.format(min)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const GreaterThanOrEqualToBigDecimalTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/GreaterThanOrEqualToBigDecimal" +export const GreaterThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/GreaterThanOrEqualToBigDecimal" ) /** @@ -7264,17 +7271,18 @@ export const greaterThanOrEqualToBigDecimal = (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.greaterThanOrEqualTo(a, min), { - typeId: { id: GreaterThanOrEqualToBigDecimalTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToBigDecimalSchemaId, + [GreaterThanOrEqualToBigDecimalSchemaId]: { min }, description: `a BigDecimal greater than or equal to ${bigDecimal_.format(min)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanBigDecimalTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/LessThanBigDecimal") +export const LessThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/SchemaId/LessThanBigDecimal") /** * @category BigDecimal filters @@ -7287,18 +7295,19 @@ export const lessThanBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.lessThan(a, max), { - typeId: { id: LessThanBigDecimalTypeId, annotation: { max } }, + schemaId: LessThanBigDecimalSchemaId, + [LessThanBigDecimalSchemaId]: { max }, description: `a BigDecimal less than ${bigDecimal_.format(max)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const LessThanOrEqualToBigDecimalTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/LessThanOrEqualToBigDecimal" +export const LessThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/LessThanOrEqualToBigDecimal" ) /** @@ -7312,18 +7321,19 @@ export const lessThanOrEqualToBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.lessThanOrEqualTo(a, max), { - typeId: { id: LessThanOrEqualToBigDecimalTypeId, annotation: { max } }, + schemaId: LessThanOrEqualToBigDecimalSchemaId, + [LessThanOrEqualToBigDecimalSchemaId]: { max }, description: `a BigDecimal less than or equal to ${bigDecimal_.format(max)}`, ...annotations }) ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const PositiveBigDecimalTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/PositiveBigDecimal" +export const PositiveBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/PositiveBigDecimal" ) /** @@ -7336,7 +7346,7 @@ export const positiveBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.isPositive(a), { - typeId: { id: PositiveBigDecimalTypeId, annotation: {} }, + schemaId: PositiveBigDecimalSchemaId, description: `a positive BigDecimal`, ...annotations }) @@ -7354,11 +7364,11 @@ export const PositiveBigDecimalFromSelf: filter> ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const NonNegativeBigDecimalTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/NonNegativeBigDecimal" +export const NonNegativeBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/NonNegativeBigDecimal" ) /** @@ -7371,7 +7381,7 @@ export const nonNegativeBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => a.value >= 0n, { - typeId: { id: NonNegativeBigDecimalTypeId, annotation: {} }, + schemaId: NonNegativeBigDecimalSchemaId, description: `a non-negative BigDecimal`, ...annotations }) @@ -7389,11 +7399,11 @@ export const NonNegativeBigDecimalFromSelf: filter( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.isNegative(a), { - typeId: { id: NegativeBigDecimalTypeId, annotation: {} }, + schemaId: NegativeBigDecimalSchemaId, description: `a negative BigDecimal`, ...annotations }) @@ -7424,11 +7434,11 @@ export const NegativeBigDecimalFromSelf: filter> ) /** - * @category type id + * @category schema id * @since 3.10.0 */ -export const NonPositiveBigDecimalTypeId: unique symbol = Symbol.for( - "effect/Schema/TypeId/NonPositiveBigDecimal" +export const NonPositiveBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/NonPositiveBigDecimal" ) /** @@ -7441,7 +7451,7 @@ export const nonPositiveBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => a.value <= 0n, { - typeId: { id: NonPositiveBigDecimalTypeId, annotation: {} }, + schemaId: NonPositiveBigDecimalSchemaId, description: `a non-positive BigDecimal`, ...annotations }) @@ -7459,10 +7469,10 @@ export const NonPositiveBigDecimalFromSelf: filter( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.between(a, { minimum, maximum }), { - typeId: { id: BetweenBigDecimalTypeId, annotation: { maximum, minimum } }, + schemaId: BetweenBigDecimalSchemaId, + [BetweenBigDecimalSchemaId]: { maximum, minimum }, description: `a BigDecimal between ${bigDecimal_.format(minimum)} and ${bigDecimal_.format(maximum)}`, ...annotations }) @@ -7497,10 +7508,11 @@ export const clampBigDecimal = { strict: false, decode: (self) => bigDecimal_.clamp(self, { minimum, maximum }), encode: identity } ) -const chunkArbitrary = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(chunk_.fromIterable) -} +const chunkArbitrary = + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(chunk_.fromIterable) + } const chunkPretty = (item: pretty_.Pretty): pretty_.Pretty> => (c) => `Chunk(${chunk_.toReadonlyArray(c).map(item).join(", ")})` @@ -7819,7 +7831,7 @@ export interface Class = Struct | { - readonly [refineTypeId]: HasFields + readonly [RefineSchemaId]: HasFields } const isField = (u: unknown) => isSchema(u) || isPropertySignature(u) @@ -7828,7 +7840,7 @@ const isFields = (fields: object): fields is Field util_.ownKeys(fields).every((key) => isField((fields as any)[key])) const getFields = (hasFields: HasFields): Fields => - "fields" in hasFields ? hasFields.fields : getFields(hasFields[refineTypeId]) + "fields" in hasFields ? hasFields.fields : getFields(hasFields[RefineSchemaId]) const getSchemaFromFieldsOr = (fieldsOr: Fields | HasFields): Schema.Any => isFields(fieldsOr) ? Struct(fieldsOr) : isSchema(fieldsOr) ? fieldsOr : Struct(getFields(fieldsOr)) @@ -8867,7 +8879,7 @@ export const Exit = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { const items = fc.array(item(fc)) return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map( hashSet_.fromIterable @@ -8956,7 +8968,7 @@ export const HashSet = (value: Value): HashSet const hashMapArbitrary = ( key: LazyArbitrary, value: LazyArbitrary, - ctx: GenerationContext + ctx: ArbitraryGenerationContext ): LazyArbitrary> => (fc) => { const items = fc.array(fc.tuple(key(fc), value(fc))) @@ -9058,10 +9070,11 @@ export const HashMap = ({ key, value ) } -const listArbitrary = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(list_.fromIterable) -} +const listArbitrary = + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(list_.fromIterable) + } const listPretty = (item: pretty_.Pretty): pretty_.Pretty> => (set) => `List(${Array.from(set).map((a) => item(a)).join(", ")})` @@ -9142,14 +9155,17 @@ export const List = (value: Value): List => { ) } -const sortedSetArbitrary = - (item: LazyArbitrary, ord: Order.Order, ctx: GenerationContext): LazyArbitrary> => - (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => - sortedSet_.fromIterable(as, ord) - ) - } +const sortedSetArbitrary = ( + item: LazyArbitrary, + ord: Order.Order, + ctx: ArbitraryGenerationContext +): LazyArbitrary> => +(fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => + sortedSet_.fromIterable(as, ord) + ) +} const sortedSetPretty = (item: pretty_.Pretty): pretty_.Pretty> => (set) => `new SortedSet([${Array.from(sortedSet_.values(set)).map((a) => item(a)).join(", ")}])` diff --git a/packages/effect/src/SchemaAST.ts b/packages/effect/src/SchemaAST.ts index 51a4baf01d3..31b6d17c974 100644 --- a/packages/effect/src/SchemaAST.ts +++ b/packages/effect/src/SchemaAST.ts @@ -60,19 +60,19 @@ export type BrandAnnotation = Arr.NonEmptyReadonlyArray * @category annotations * @since 3.10.0 */ -export const BrandAnnotationId = Symbol.for("effect/Schema/annotation/Brand") +export const BrandAnnotationId: unique symbol = Symbol.for("effect/annotation/Brand") /** * @category annotations * @since 3.10.0 */ -export type TypeAnnotation = symbol +export type SchemaIdAnnotation = string | symbol /** * @category annotations * @since 3.10.0 */ -export const TypeAnnotationId = Symbol.for("effect/Schema/annotation/Type") +export const SchemaIdAnnotationId: unique symbol = Symbol.for("effect/annotation/SchemaId") /** * @category annotations @@ -87,7 +87,7 @@ export type MessageAnnotation = (issue: ParseIssue) => string | Effect | * @category annotations * @since 3.10.0 */ -export const MessageAnnotationId = Symbol.for("effect/Schema/annotation/Message") +export const MessageAnnotationId: unique symbol = Symbol.for("effect/annotation/Message") /** * @category annotations @@ -99,7 +99,7 @@ export type MissingMessageAnnotation = () => string | Effect * @category annotations * @since 3.10.0 */ -export const MissingMessageAnnotationId = Symbol.for("effect/Schema/annotation/MissingMessage") +export const MissingMessageAnnotationId: unique symbol = Symbol.for("effect/annotation/MissingMessage") /** * @category annotations @@ -111,7 +111,7 @@ export type IdentifierAnnotation = string * @category annotations * @since 3.10.0 */ -export const IdentifierAnnotationId = Symbol.for("effect/Schema/annotation/Identifier") +export const IdentifierAnnotationId: unique symbol = Symbol.for("effect/annotation/Identifier") /** * @category annotations @@ -123,7 +123,7 @@ export type TitleAnnotation = string * @category annotations * @since 3.10.0 */ -export const TitleAnnotationId = Symbol.for("effect/Schema/annotation/Title") +export const TitleAnnotationId: unique symbol = Symbol.for("effect/annotation/Title") /** * @category annotations @@ -135,7 +135,7 @@ export type DescriptionAnnotation = string * @category annotations * @since 3.10.0 */ -export const DescriptionAnnotationId = Symbol.for("effect/Schema/annotation/Description") +export const DescriptionAnnotationId: unique symbol = Symbol.for("effect/annotation/Description") /** * @category annotations @@ -147,7 +147,7 @@ export type ExamplesAnnotation = Arr.NonEmptyReadonlyArray * @category annotations * @since 3.10.0 */ -export const ExamplesAnnotationId = Symbol.for("effect/Schema/annotation/Examples") +export const ExamplesAnnotationId: unique symbol = Symbol.for("effect/annotation/Examples") /** * @category annotations @@ -159,7 +159,7 @@ export type DefaultAnnotation = A * @category annotations * @since 3.10.0 */ -export const DefaultAnnotationId = Symbol.for("effect/Schema/annotation/Default") +export const DefaultAnnotationId: unique symbol = Symbol.for("effect/annotation/Default") /** * @category annotations @@ -171,7 +171,7 @@ export type JSONSchemaAnnotation = object * @category annotations * @since 3.10.0 */ -export const JSONSchemaAnnotationId = Symbol.for("effect/Schema/annotation/JSONSchema") +export const JSONSchemaAnnotationId: unique symbol = Symbol.for("effect/annotation/JSONSchema") /** * @category annotations @@ -183,7 +183,7 @@ export type DocumentationAnnotation = string * @category annotations * @since 3.10.0 */ -export const DocumentationAnnotationId = Symbol.for("effect/Schema/annotation/Documentation") +export const DocumentationAnnotationId: unique symbol = Symbol.for("effect/annotation/Documentation") /** * @category annotations @@ -195,7 +195,7 @@ export type ConcurrencyAnnotation = Concurrency | undefined * @category annotations * @since 3.10.0 */ -export const ConcurrencyAnnotationId = Symbol.for("effect/Schema/annotation/Concurrency") +export const ConcurrencyAnnotationId: unique symbol = Symbol.for("effect/annotation/Concurrency") /** * @category annotations @@ -207,7 +207,7 @@ export type BatchingAnnotation = boolean | "inherit" | undefined * @category annotations * @since 3.10.0 */ -export const BatchingAnnotationId = Symbol.for("effect/Schema/annotation/Batching") +export const BatchingAnnotationId: unique symbol = Symbol.for("effect/annotation/Batching") /** * @category annotations @@ -219,13 +219,13 @@ export type ParseIssueTitleAnnotation = (issue: ParseIssue) => string | undefine * @category annotations * @since 3.10.0 */ -export const ParseIssueTitleAnnotationId = Symbol.for("effect/Schema/annotation/ParseIssueTitle") +export const ParseIssueTitleAnnotationId: unique symbol = Symbol.for("effect/annotation/ParseIssueTitle") /** * @category annotations * @since 3.10.0 */ -export const ParseOptionsAnnotationId = Symbol.for("effect/Schema/annotation/ParseOptions") +export const ParseOptionsAnnotationId: unique symbol = Symbol.for("effect/annotation/ParseOptions") /** * @category annotations @@ -237,27 +237,22 @@ export type DecodingFallbackAnnotation = (issue: ParseIssue) => Effect(SurrogateAnnotationId) const getStableFilterAnnotation = getAnnotation(StableFilterAnnotationId) @@ -400,11 +399,35 @@ const getStableFilterAnnotation = getAnnotation(StableFi export const hasStableFilter = (annotated: Annotated) => Option.exists(getStableFilterAnnotation(annotated), (b) => b === true) -const JSONIdentifierAnnotationId = Symbol.for("effect/Schema/annotation/JSONIdentifier") +/** + * @category annotations + * @since 3.10.0 + */ +export const JSONIdentifierAnnotationId: unique symbol = Symbol.for("effect/annotation/JSONIdentifier") -/** @internal */ +/** + * @category annotations + * @since 3.10.0 + */ export const getJSONIdentifierAnnotation = getAnnotation(JSONIdentifierAnnotationId) +/** + * @category annotations + * @since 3.10.0 + */ +export const getJSONIdentifier = (annotated: Annotated) => + Option.orElse(getJSONIdentifierAnnotation(annotated), () => getIdentifierAnnotation(annotated)) + +// ------------------------------------------------------------------------------------- +// schema ids +// ------------------------------------------------------------------------------------- + +/** + * @category schema id + * @since 3.10.0 + */ +export const ParseJsonSchemaId: unique symbol = Symbol.for("effect/schema/ParseJson") + /** * @category model * @since 3.10.0 @@ -2485,10 +2508,6 @@ export const blackListAnnotations = return out } -/** @internal */ -export const getJSONIdentifier = (annotated: Annotated) => - Option.orElse(getJSONIdentifierAnnotation(annotated), () => getIdentifierAnnotation(annotated)) - // To generate a JSON Schema from a recursive schema, an `identifier` annotation // is required. So, when we calculate the encodedAST, we need to preserve the // annotation in the form of an internal custom annotation that acts as a diff --git a/packages/effect/src/SchemaEquivalence.ts b/packages/effect/src/SchemaEquivalence.ts index e29b4349e73..4e8ed744725 100644 --- a/packages/effect/src/SchemaEquivalence.ts +++ b/packages/effect/src/SchemaEquivalence.ts @@ -14,24 +14,18 @@ import type * as Schema from "./Schema.js" import * as AST from "./SchemaAST.js" /** - * @category hooks - * @since 3.10.0 - */ -export const EquivalenceHookId: unique symbol = Symbol.for("effect/Schema/EquivalenceHookId") - -/** - * @category hooks + * @category annotations * @since 3.10.0 */ -export type EquivalenceHookId = typeof EquivalenceHookId +export type EquivalenceAnnotation = readonly []> = ( + ...equivalences: { readonly [K in keyof TypeParameters]: Equivalence.Equivalence } +) => Equivalence.Equivalence /** * @category annotations * @since 3.10.0 */ -export const equivalence = - (handler: (...args: ReadonlyArray>) => Equivalence.Equivalence) => - (self: Schema.Schema): Schema.Schema => self.annotations({ [EquivalenceHookId]: handler }) +export const EquivalenceAnnotationId: unique symbol = Symbol.for("effect/annotation/Equivalence") /** * @category Equivalence @@ -39,14 +33,10 @@ export const equivalence = */ export const make = (schema: Schema.Schema): Equivalence.Equivalence => go(schema.ast, []) -const getHook = AST.getAnnotation< - (...args: ReadonlyArray>) => Equivalence.Equivalence ->( - EquivalenceHookId -) +const getAnnotation = AST.getAnnotation>(EquivalenceAnnotationId) const go = (ast: AST.AST, path: ReadonlyArray): Equivalence.Equivalence => { - const hook = getHook(ast) + const hook = getAnnotation(ast) if (Option.isSome(hook)) { switch (ast._tag) { case "Declaration": diff --git a/packages/effect/src/internal/schema/filters.ts b/packages/effect/src/internal/schema/filters.ts index 470997f9b70..710373d7b40 100644 --- a/packages/effect/src/internal/schema/filters.ts +++ b/packages/effect/src/internal/schema/filters.ts @@ -1,89 +1,86 @@ import type * as Schema from "../../Schema.js" /** @internal */ -export const GreaterThanTypeId: Schema.GreaterThanTypeId = Symbol.for( - "effect/Schema/TypeId/GreaterThan" -) as Schema.GreaterThanTypeId +export const GreaterThanSchemaId: Schema.GreaterThanSchemaId = Symbol.for( + "effect/schema/GreaterThan" +) as Schema.GreaterThanSchemaId /** @internal */ -export const GreaterThanOrEqualToTypeId: Schema.GreaterThanOrEqualToTypeId = Symbol.for( - "effect/Schema/TypeId/GreaterThanOrEqualTo" -) as Schema.GreaterThanOrEqualToTypeId +export const GreaterThanOrEqualToSchemaId: Schema.GreaterThanOrEqualToSchemaId = Symbol.for( + "effect/schema/GreaterThanOrEqualTo" +) as Schema.GreaterThanOrEqualToSchemaId /** @internal */ -export const LessThanTypeId: Schema.LessThanTypeId = Symbol.for( - "effect/Schema/TypeId/LessThan" -) as Schema.LessThanTypeId +export const LessThanSchemaId: Schema.LessThanSchemaId = Symbol.for( + "effect/schema/LessThan" +) as Schema.LessThanSchemaId /** @internal */ -export const LessThanOrEqualToTypeId: Schema.LessThanOrEqualToTypeId = Symbol.for( - "effect/Schema/TypeId/LessThanOrEqualTo" -) as Schema.LessThanOrEqualToTypeId +export const LessThanOrEqualToSchemaId: Schema.LessThanOrEqualToSchemaId = Symbol.for( + "effect/schema/LessThanOrEqualTo" +) as Schema.LessThanOrEqualToSchemaId /** @internal */ -export const IntTypeId: Schema.IntTypeId = Symbol.for( - "effect/Schema/TypeId/Int" -) as Schema.IntTypeId +export const IntSchemaId: Schema.IntSchemaId = Symbol.for( + "effect/schema/Int" +) as Schema.IntSchemaId /** @internal */ -export const BetweenTypeId: Schema.BetweenTypeId = Symbol.for( - "effect/Schema/TypeId/Between" -) as Schema.BetweenTypeId +export const BetweenSchemaId: Schema.BetweenSchemaId = Symbol.for( + "effect/schema/Between" +) as Schema.BetweenSchemaId /** @internal */ -export const GreaterThanBigintTypeId: Schema.GreaterThanBigIntTypeId = Symbol.for( - "effect/Schema/TypeId/GreaterThanBigint" -) as Schema.GreaterThanBigIntTypeId +export const GreaterThanBigintSchemaId: Schema.GreaterThanBigIntSchemaId = Symbol.for( + "effect/schema/GreaterThanBigint" +) as Schema.GreaterThanBigIntSchemaId /** @internal */ -export const GreaterThanOrEqualToBigIntTypeId: Schema.GreaterThanOrEqualToBigIntTypeId = Symbol.for( - "effect/Schema/TypeId/GreaterThanOrEqualToBigint" -) as Schema.GreaterThanOrEqualToBigIntTypeId +export const GreaterThanOrEqualToBigIntSchemaId: Schema.GreaterThanOrEqualToBigIntSchemaId = Symbol.for( + "effect/schema/GreaterThanOrEqualToBigint" +) as Schema.GreaterThanOrEqualToBigIntSchemaId /** @internal */ -export const LessThanBigIntTypeId: Schema.LessThanBigIntTypeId = Symbol.for( - "effect/Schema/TypeId/LessThanBigint" -) as Schema.LessThanBigIntTypeId +export const LessThanBigIntSchemaId: Schema.LessThanBigIntSchemaId = Symbol.for( + "effect/schema/LessThanBigint" +) as Schema.LessThanBigIntSchemaId /** @internal */ -export const LessThanOrEqualToBigIntTypeId: Schema.LessThanOrEqualToBigIntTypeId = Symbol.for( - "effect/Schema/TypeId/LessThanOrEqualToBigint" -) as Schema.LessThanOrEqualToBigIntTypeId +export const LessThanOrEqualToBigIntSchemaId: Schema.LessThanOrEqualToBigIntSchemaId = Symbol.for( + "effect/schema/LessThanOrEqualToBigint" +) as Schema.LessThanOrEqualToBigIntSchemaId /** @internal */ -export const BetweenBigintTypeId: Schema.BetweenBigIntTypeId = Symbol.for( - "effect/Schema/TypeId/BetweenBigint" -) as Schema.BetweenBigIntTypeId +export const BetweenBigintSchemaId: Schema.BetweenBigIntSchemaId = Symbol.for( + "effect/schema/BetweenBigint" +) as Schema.BetweenBigIntSchemaId /** @internal */ -export const MinLengthTypeId: Schema.MinLengthTypeId = Symbol.for( - "effect/Schema/TypeId/MinLength" -) as Schema.MinLengthTypeId +export const MinLengthSchemaId: Schema.MinLengthSchemaId = Symbol.for( + "effect/schema/MinLength" +) as Schema.MinLengthSchemaId /** @internal */ -export const MaxLengthTypeId: Schema.MaxLengthTypeId = Symbol.for( - "effect/Schema/TypeId/MaxLength" -) as Schema.MaxLengthTypeId +export const MaxLengthSchemaId: Schema.MaxLengthSchemaId = Symbol.for( + "effect/schema/MaxLength" +) as Schema.MaxLengthSchemaId /** @internal */ -export const LengthTypeId: Schema.LengthTypeId = Symbol.for( - "effect/Schema/TypeId/Length" -) as Schema.LengthTypeId +export const LengthSchemaId: Schema.LengthSchemaId = Symbol.for( + "effect/schema/Length" +) as Schema.LengthSchemaId /** @internal */ -export const MinItemsTypeId: Schema.MinItemsTypeId = Symbol.for( - "effect/Schema/TypeId/MinItems" -) as Schema.MinItemsTypeId +export const MinItemsSchemaId: Schema.MinItemsSchemaId = Symbol.for( + "effect/schema/MinItems" +) as Schema.MinItemsSchemaId /** @internal */ -export const MaxItemsTypeId: Schema.MaxItemsTypeId = Symbol.for( - "effect/Schema/TypeId/MaxItems" -) as Schema.MaxItemsTypeId +export const MaxItemsSchemaId: Schema.MaxItemsSchemaId = Symbol.for( + "effect/schema/MaxItems" +) as Schema.MaxItemsSchemaId /** @internal */ -export const ItemsCountTypeId: Schema.ItemsCountTypeId = Symbol.for( - "effect/Schema/TypeId/ItemsCount" -) as Schema.ItemsCountTypeId - -/** @internal */ -export const ParseJsonTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/ParseJson") +export const ItemsCountSchemaId: Schema.ItemsCountSchemaId = Symbol.for( + "effect/schema/ItemsCount" +) as Schema.ItemsCountSchemaId diff --git a/packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts b/packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts index a1037e52f93..1c4f7c4ef59 100644 --- a/packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts +++ b/packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts @@ -256,7 +256,7 @@ details: Generating an Arbitrary for this schema requires at least one enum`) const schema = S.Struct({ a: S.String, as: S.Array( - S.suspend((): S.Schema => schema).pipe(Arbitrary.arbitrary(() => () => arb)) + S.suspend((): S.Schema => schema).annotations({ arbitrary: () => () => arb }) ) }) expectValidArbitrary(schema) @@ -620,7 +620,7 @@ details: Generating an Arbitrary for this schema requires at least one enum`) describe("should handle annotations", () => { const expectHook = (source: S.Schema) => { - const schema = source.pipe(Arbitrary.arbitrary(() => (fc) => fc.constant("custom arbitrary") as any)) + const schema = source.annotations({ arbitrary: () => (fc) => fc.constant("custom arbitrary") as any }) const arb = Arbitrary.makeLazy(schema)(fc) expect(fc.sample(arb, 1)[0]).toEqual("custom arbitrary") } diff --git a/packages/effect/test/Schema/Pretty.test.ts b/packages/effect/test/Schema/Pretty.test.ts index a4cbff8f7ec..1a250583391 100644 --- a/packages/effect/test/Schema/Pretty.test.ts +++ b/packages/effect/test/Schema/Pretty.test.ts @@ -434,7 +434,7 @@ schema (Declaration): `) describe("should handle annotations", () => { const expectHook = (source: S.Schema) => { - const schema = source.pipe(Pretty.pretty(() => () => "custom pretty")) + const schema = source.annotations({ pretty: () => () => "custom pretty" }) const pretty = Pretty.make(schema) expect(pretty(null as any)).toEqual("custom pretty") } diff --git a/packages/effect/test/Schema/Schema/annotations.test.ts b/packages/effect/test/Schema/Schema/annotations.test.ts index 6fafe96159f..29de6d2d774 100644 --- a/packages/effect/test/Schema/Schema/annotations.test.ts +++ b/packages/effect/test/Schema/Schema/annotations.test.ts @@ -142,3 +142,16 @@ describe(".annotations()", () => { expect(Pretty.make(AFromSelf)(new A("value"))).toEqual(`new A("value")`) }) }) + +declare module "effect/Schema" { + namespace Annotations { + interface Schema extends Doc { + formName?: string + } + } +} + +it("should support custom annotations", () => { + const schema = S.String.annotations({ formName: "a" }) + expect(schema.ast.annotations["formName"]).toEqual("a") +}) diff --git a/packages/effect/test/Schema/Schema/brand.test.ts b/packages/effect/test/Schema/Schema/brand.test.ts index 3bca1e05724..541fabeee81 100644 --- a/packages/effect/test/Schema/Schema/brand.test.ts +++ b/packages/effect/test/Schema/Schema/brand.test.ts @@ -61,7 +61,7 @@ describe("brand", () => { ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: S.IntTypeId, + [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: ["A"], [AST.TitleAnnotationId]: `integer & Brand<"A">`, [AST.DescriptionAnnotationId]: "an A brand", @@ -79,7 +79,7 @@ describe("brand", () => { ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: S.IntTypeId, + [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: ["A", "B"], [AST.TitleAnnotationId]: `integer & Brand<"A"> & Brand<"B">`, [AST.DescriptionAnnotationId]: "a B brand", @@ -98,7 +98,7 @@ describe("brand", () => { }) ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: S.IntTypeId, + [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: [A, B], [AST.TitleAnnotationId]: "integer & Brand & Brand", [AST.DescriptionAnnotationId]: "a B brand", diff --git a/packages/effect/test/Schema/Schema/exports.test.ts b/packages/effect/test/Schema/Schema/exports.test.ts index d5e0e606106..c982f96eda4 100644 --- a/packages/effect/test/Schema/Schema/exports.test.ts +++ b/packages/effect/test/Schema/Schema/exports.test.ts @@ -22,30 +22,30 @@ it("exports", () => { expect(S.validateOption).exist expect(S.validateEither).exist - expect(S.GreaterThanBigIntTypeId).exist - expect(S.GreaterThanOrEqualToBigIntTypeId).exist - expect(S.LessThanBigIntTypeId).exist - expect(S.LessThanOrEqualToBigIntTypeId).exist - expect(S.BetweenBigIntTypeId).exist - expect(S.BrandTypeId).exist - expect(S.FiniteTypeId).exist - expect(S.GreaterThanTypeId).exist - expect(S.GreaterThanOrEqualToTypeId).exist - expect(S.MultipleOfTypeId).exist - expect(S.IntTypeId).exist - expect(S.LessThanTypeId).exist - expect(S.LessThanOrEqualToTypeId).exist - expect(S.BetweenTypeId).exist - expect(S.NonNaNTypeId).exist - expect(S.InstanceOfTypeId).exist - expect(S.MinItemsTypeId).exist - expect(S.MaxItemsTypeId).exist - expect(S.ItemsCountTypeId).exist - expect(S.TrimmedTypeId).exist - expect(S.PatternTypeId).exist - expect(S.StartsWithTypeId).exist - expect(S.EndsWithTypeId).exist - expect(S.IncludesTypeId).exist - expect(S.UUIDTypeId).exist - expect(S.ULIDTypeId).exist + expect(S.GreaterThanBigIntSchemaId).exist + expect(S.GreaterThanOrEqualToBigIntSchemaId).exist + expect(S.LessThanBigIntSchemaId).exist + expect(S.LessThanOrEqualToBigIntSchemaId).exist + expect(S.BetweenBigIntSchemaId).exist + expect(S.BrandSchemaId).exist + expect(S.FiniteSchemaId).exist + expect(S.GreaterThanSchemaId).exist + expect(S.GreaterThanOrEqualToSchemaId).exist + expect(S.MultipleOfSchemaId).exist + expect(S.IntSchemaId).exist + expect(S.LessThanSchemaId).exist + expect(S.LessThanOrEqualToSchemaId).exist + expect(S.BetweenSchemaId).exist + expect(S.NonNaNSchemaId).exist + expect(S.InstanceOfSchemaId).exist + expect(S.MinItemsSchemaId).exist + expect(S.MaxItemsSchemaId).exist + expect(S.ItemsCountSchemaId).exist + expect(S.TrimmedSchemaId).exist + expect(S.PatternSchemaId).exist + expect(S.StartsWithSchemaId).exist + expect(S.EndsWithSchemaId).exist + expect(S.IncludesSchemaId).exist + expect(S.UUIDSchemaId).exist + expect(S.ULIDSchemaId).exist }) diff --git a/packages/effect/test/Schema/Schema/filter.test.ts b/packages/effect/test/Schema/Schema/filter.test.ts index bc712972504..5d3e627e8e8 100644 --- a/packages/effect/test/Schema/Schema/filter.test.ts +++ b/packages/effect/test/Schema/Schema/filter.test.ts @@ -8,7 +8,7 @@ describe("filter", () => { it("annotation options", () => { const schema = S.String.pipe( S.filter((s): s is string => s.length === 1, { - typeId: Symbol.for("Char"), + schemaId: Symbol.for("Char"), description: "description", documentation: "documentation", examples: ["examples"], @@ -18,7 +18,7 @@ describe("filter", () => { }) ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: Symbol.for("Char"), + [AST.SchemaIdAnnotationId]: Symbol.for("Char"), [AST.DescriptionAnnotationId]: "description", [AST.DocumentationAnnotationId]: "documentation", [AST.ExamplesAnnotationId]: [ diff --git a/packages/effect/test/Schema/Schema/instanceOf.test.ts b/packages/effect/test/Schema/Schema/instanceOf.test.ts index 3ca32739a32..5de4eb4a0db 100644 --- a/packages/effect/test/Schema/Schema/instanceOf.test.ts +++ b/packages/effect/test/Schema/Schema/instanceOf.test.ts @@ -17,7 +17,7 @@ describe("instanceOf", () => { it("annotations", () => { const schema = S.instanceOf(Set, { description: "my description" }) expect(schema.ast.annotations[AST.DescriptionAnnotationId]).toEqual("my description") - expect(schema.ast.annotations[S.InstanceOfTypeId]).toEqual({ constructor: Set }) + expect(schema.ast.annotations[S.InstanceOfSchemaId]).toEqual({ constructor: Set }) }) it("decoding", async () => { diff --git a/packages/effect/test/Schema/SchemaAST/annotations.test.ts b/packages/effect/test/Schema/SchemaAST/annotations.test.ts index b1c71a3fe9a..6506f24bbef 100644 --- a/packages/effect/test/Schema/SchemaAST/annotations.test.ts +++ b/packages/effect/test/Schema/SchemaAST/annotations.test.ts @@ -2,7 +2,7 @@ import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("annotations", () => { - it("should ad annotations", () => { + it("should add annotations", () => { const symA = Symbol.for("a") const ast = AST.annotations(AST.stringKeyword, { [symA]: "A" }) expect(ast instanceof AST.StringKeyword).toBe(true) diff --git a/packages/effect/test/Schema/SchemaEquivalence.test.ts b/packages/effect/test/Schema/SchemaEquivalence.test.ts index e5b2b0c0a93..c372e21e769 100644 --- a/packages/effect/test/Schema/SchemaEquivalence.test.ts +++ b/packages/effect/test/Schema/SchemaEquivalence.test.ts @@ -711,7 +711,7 @@ schema (NeverKeyword): never`) describe("should handle annotations", () => { const expectHook = (source: S.Schema) => { - const schema = source.pipe(E.equivalence(() => () => true)) + const schema = source.annotations({ equivalence: () => () => true }) const eq = E.make(schema) expect(eq("a" as any, "b" as any)).toEqual(true) } diff --git a/packages/platform/src/OpenApiJsonSchema.ts b/packages/platform/src/OpenApiJsonSchema.ts index 4151a69e204..8a7e2487a52 100644 --- a/packages/platform/src/OpenApiJsonSchema.ts +++ b/packages/platform/src/OpenApiJsonSchema.ts @@ -312,7 +312,8 @@ const getRefinementInnerTransformation = (ast: AST.Refinement): AST.AST | undefi } } -const isParseJsonTransformation = (ast: AST.AST): boolean => ast.annotations[AST.TypeAnnotationId] === ParseJsonTypeId +const isParseJsonTransformation = (ast: AST.AST): boolean => + ast.annotations[AST.SchemaIdAnnotationId] === AST.ParseJsonSchemaId const isOverrideAnnotation = (jsonSchema: JsonSchema): boolean => { return ("type" in jsonSchema) || ("oneOf" in jsonSchema) || ("anyOf" in jsonSchema) || ("const" in jsonSchema) || @@ -352,7 +353,7 @@ const go = ( } return handler } - const surrogate = getSurrogateAnnotation(ast) + const surrogate = AST.getSurrogateAnnotation(ast) if (Option.isSome(surrogate)) { return { ...(ast._tag === "Transformation" ? getJsonSchemaAnnotations(ast.to) : {}), @@ -361,7 +362,7 @@ const go = ( } } if (handleIdentifier && !AST.isTransformation(ast) && !AST.isRefinement(ast)) { - const identifier = getJSONIdentifier(ast) + const identifier = AST.getJSONIdentifier(ast) if (Option.isSome(identifier)) { const id = identifier.value const out = { $ref: get$ref(id) } @@ -603,7 +604,7 @@ const go = ( } } case "Suspend": { - const identifier = Option.orElse(getJSONIdentifier(ast), () => getJSONIdentifier(ast.f())) + const identifier = Option.orElse(AST.getJSONIdentifier(ast), () => AST.getJSONIdentifier(ast.f())) if (Option.isNone(identifier)) { throw new Error(getJSONSchemaMissingIdentifierAnnotationErrorMessage(path, ast)) } @@ -703,12 +704,3 @@ const formatPath = (path: ParseResult.Path): string => const isNonEmpty = (x: ParseResult.SingleOrNonEmpty): x is Arr.NonEmptyReadonlyArray => Array.isArray(x) const formatPropertyKey = (name: PropertyKey): string => typeof name === "string" ? JSON.stringify(name) : String(name) - -const ParseJsonTypeId: unique symbol = Symbol.for("effect/Schema/TypeId/ParseJson") -const SurrogateAnnotationId = Symbol.for("effect/Schema/annotation/Surrogate") -const JSONIdentifierAnnotationId = Symbol.for("effect/Schema/annotation/JSONIdentifier") - -const getSurrogateAnnotation = AST.getAnnotation(SurrogateAnnotationId) -const getJSONIdentifierAnnotation = AST.getAnnotation(JSONIdentifierAnnotationId) -const getJSONIdentifier = (annotated: AST.Annotated) => - Option.orElse(getJSONIdentifierAnnotation(annotated), () => AST.getIdentifierAnnotation(annotated))