schemair 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +420 -11
  2. package/dist/authoring/index.cjs +13 -350
  3. package/dist/authoring/index.d.cts +2 -90
  4. package/dist/authoring/index.d.ts +2 -90
  5. package/dist/authoring/index.js +2 -304
  6. package/dist/authoring-D3V0iyTe.js +362 -0
  7. package/dist/authoring-Dnrg5TXm.cjs +389 -0
  8. package/dist/chunk-BgLxgFZR.js +18 -0
  9. package/dist/definition/index.cjs +10 -2
  10. package/dist/definition/index.d.cts +3 -21
  11. package/dist/definition/index.d.ts +3 -21
  12. package/dist/definition/index.js +2 -2
  13. package/dist/definition-BLLBpLKv.cjs +1187 -0
  14. package/dist/definition-DmYnDmQO.js +1115 -0
  15. package/dist/index-4aMF0cTE.d.ts +368 -0
  16. package/dist/index-BqfGAU1K.d.ts +56 -0
  17. package/dist/{index-eK2Xgrwp.d.ts → index-CBbd4hXJ.d.ts} +13 -2
  18. package/dist/index-CIim1dG7.d.cts +92 -0
  19. package/dist/{index-TACcK_mi.d.cts → index-CNjYUKvu.d.cts} +13 -2
  20. package/dist/index-CQynt7ft.d.cts +420 -0
  21. package/dist/index-D3mfwaSO.d.cts +56 -0
  22. package/dist/index-DDMwVy2I.d.cts +368 -0
  23. package/dist/index-DM5DSLLL.d.ts +99 -0
  24. package/dist/index-DXWoNYFB.d.ts +92 -0
  25. package/dist/index-DhmHCGpT.d.cts +99 -0
  26. package/dist/index-bQy-C-1l.d.ts +418 -0
  27. package/dist/index.cjs +64 -52
  28. package/dist/index.d.cts +7 -7
  29. package/dist/index.d.ts +7 -7
  30. package/dist/index.js +7 -5
  31. package/dist/integrations/json-schema/index.cjs +328 -0
  32. package/dist/integrations/json-schema/index.d.cts +53 -0
  33. package/dist/integrations/json-schema/index.d.ts +53 -0
  34. package/dist/integrations/json-schema/index.js +324 -0
  35. package/dist/integrations/standard-schema/index.cjs +32 -0
  36. package/dist/integrations/standard-schema/index.d.cts +22 -0
  37. package/dist/integrations/standard-schema/index.d.ts +22 -0
  38. package/dist/integrations/standard-schema/index.js +32 -0
  39. package/dist/payload/index.cjs +1 -1
  40. package/dist/payload/index.d.cts +1 -55
  41. package/dist/payload/index.d.ts +1 -55
  42. package/dist/payload/index.js +1 -1
  43. package/dist/relations/index.cjs +3 -1
  44. package/dist/relations/index.d.cts +2 -2
  45. package/dist/relations/index.d.ts +2 -2
  46. package/dist/relations/index.js +2 -2
  47. package/dist/{relations-CMz_0nf4.cjs → relations-Cymx4iTc.cjs} +158 -5
  48. package/dist/{relations-By0bK3UK.js → relations-ysXDmi-Z.js} +147 -6
  49. package/dist/spec/index.cjs +9 -0
  50. package/dist/spec/index.d.cts +2 -2
  51. package/dist/spec/index.d.ts +2 -2
  52. package/dist/spec/index.js +3 -1
  53. package/dist/standard/index.cjs +810 -0
  54. package/dist/standard/index.d.cts +3 -0
  55. package/dist/standard/index.d.ts +3 -0
  56. package/dist/standard/index.js +777 -0
  57. package/dist/standard-DhKsxu9U.js +471 -0
  58. package/dist/standard-etPFZDJI.cjs +513 -0
  59. package/dist/type-interpreter/index.cjs +3 -3
  60. package/dist/type-interpreter/index.d.cts +2 -99
  61. package/dist/type-interpreter/index.d.ts +2 -99
  62. package/dist/type-interpreter/index.js +2 -2
  63. package/dist/{type-interpreter-Ck0VDhzn.js → type-interpreter-DnrId8aM.js} +5 -284
  64. package/dist/{type-interpreter-DAIBUqKf.cjs → type-interpreter-OLt2W2yd.cjs} +15 -294
  65. package/package.json +38 -3
  66. package/dist/definition-BXj3T94L.js +0 -467
  67. package/dist/definition-DSZZTz4e.cjs +0 -473
  68. package/dist/index-CEzHfht2.d.ts +0 -269
  69. package/dist/index-rzkFjgrt.d.cts +0 -269
@@ -0,0 +1,420 @@
1
+ import { G as OperationChannelDefinition, H as SchemaVariantSelector, L as SchemaTypeTerm, _t as SchemaStringNode, a as StandardSemanticDefinition, at as SchemaConstraint, bt as SchemaTupleNode, ct as SchemaNode, dt as SchemaNumberNode, ft as SchemaPrimitiveNode, gt as SchemaSelfRefNode, ht as SchemaRefNode, i as StandardConstraintDefinition, it as SchemaBooleanNode, lt as SchemaNullNode, mt as SchemaRecordNode, ot as SchemaLiteralNode, p as SchemaFieldSelector, pt as SchemaRecordField, q as OperationDefinition, rt as SchemaArrayNode, st as SchemaLiteralUnionNode, tt as LiteralValue, ut as SchemaNullableNode, vt as SchemaTaggedUnionNode, y as SchemaTypeExpr, yt as SchemaTaggedUnionVariant } from "./index-DDMwVy2I.cjs";
2
+ import { f as SyncConstraintProvider, h as SyncSemanticProvider, m as SyncPayloadValidationContext } from "./index-D3mfwaSO.cjs";
3
+ import { o as RelationContext } from "./index-CNjYUKvu.cjs";
4
+
5
+ //#region rolldown:runtime
6
+ //#endregion
7
+ //#region src/standard/runtime.d.ts
8
+ type StandardSemanticResolution = 'standard' | 'extension' | 'unresolved';
9
+ interface ClassifiedSemanticPath {
10
+ path: string[];
11
+ key: string;
12
+ resolution: StandardSemanticResolution;
13
+ definition?: StandardSemanticDefinition;
14
+ }
15
+ interface StandardVocabularyRegistry {
16
+ semanticDefinitions: Readonly<Record<string, StandardSemanticDefinition>>;
17
+ constraintDefinitions: Readonly<Record<string, StandardConstraintDefinition>>;
18
+ }
19
+ declare function pathKey(path: readonly string[]): string;
20
+ declare const STANDARD_SEMANTIC_DEFINITION_MAP: Record<string, StandardSemanticDefinition>;
21
+ declare const STANDARD_CONSTRAINT_DEFINITION_MAP: Record<string, StandardConstraintDefinition>;
22
+ declare const standardVocabularyRegistry: StandardVocabularyRegistry;
23
+ declare function isStandardSemanticNamespace(path: readonly string[] | undefined): boolean;
24
+ declare function isExtensionSemanticPath(path: readonly string[] | undefined): boolean;
25
+ declare function classifySemanticPath(path: readonly string[] | undefined): ClassifiedSemanticPath | undefined;
26
+ //#endregion
27
+ //#region src/standard/exact-rational.d.ts
28
+ interface ExactRational {
29
+ readonly numerator: bigint;
30
+ readonly denominator: bigint;
31
+ }
32
+ type ExactRationalFailureReason = 'invalid_number' | 'division_by_zero' | 'max_bits_exceeded';
33
+ type ExactRationalResult<T> = {
34
+ readonly ok: true;
35
+ readonly value: T;
36
+ } | {
37
+ readonly ok: false;
38
+ readonly reason: ExactRationalFailureReason;
39
+ };
40
+ declare const DEFAULT_EXACT_RATIONAL_MAX_BITS = 4096;
41
+ declare function exactRationalFromFiniteNumber(value: number, maxBits?: number): ExactRationalResult<ExactRational>;
42
+ declare function exactRationalIsIntegerMultiple(value: ExactRational, divisor: ExactRational, maxBits?: number): ExactRationalResult<boolean>;
43
+ declare function greatestCommonDivisorRationals(values: readonly ExactRational[], maxBits?: number): ExactRationalResult<ExactRational>;
44
+ declare function leastCommonMultipleRationals(values: readonly ExactRational[], maxBits?: number): ExactRationalResult<ExactRational>;
45
+ declare function formatExactRational(value: ExactRational): string;
46
+ //#endregion
47
+ //#region src/standard/constraint-profile.d.ts
48
+ type StandardConstraintOwner = SchemaStringNode | SchemaNumberNode | SchemaArrayNode | SchemaRecordNode;
49
+ interface StandardConstraintBound {
50
+ readonly value: number;
51
+ readonly inclusive: boolean;
52
+ }
53
+ interface StandardConstraintInterval {
54
+ readonly domain: 'continuous' | 'integer';
55
+ readonly lower?: StandardConstraintBound;
56
+ readonly upper?: StandardConstraintBound;
57
+ }
58
+ type StandardConstraintSatisfiability = 'satisfiable' | 'empty' | 'unknown';
59
+ interface StandardConstraintProfile {
60
+ readonly interval?: StandardConstraintInterval;
61
+ readonly multipleOf: readonly ExactRational[];
62
+ readonly uniqueItems?: boolean;
63
+ readonly patterns: readonly string[];
64
+ readonly unhandled: readonly SchemaConstraint[];
65
+ readonly invalid: readonly SchemaConstraint[];
66
+ readonly budgetExceeded: boolean;
67
+ readonly satisfiability: StandardConstraintSatisfiability;
68
+ }
69
+ interface BuildStandardConstraintProfileOptions {
70
+ readonly maxRationalBits?: number;
71
+ }
72
+ declare function isStandardConstraintOwner(node: SchemaNode): node is StandardConstraintOwner;
73
+ declare function buildStandardConstraintProfile(node: StandardConstraintOwner, options?: BuildStandardConstraintProfileOptions): StandardConstraintProfile;
74
+ //#endregion
75
+ //#region src/standard/payload.d.ts
76
+ declare const standardSemanticProvider: SyncSemanticProvider;
77
+ declare function standardConstraintTarget(node: SchemaNode): string;
78
+ declare const standardConstraintProvider: SyncConstraintProvider;
79
+ declare const standardSemanticRegistry: Readonly<Record<string, SyncSemanticProvider>>;
80
+ declare const standardConstraintRegistry: Readonly<Record<string, SyncConstraintProvider>>;
81
+ /** Opt in explicitly; core validation never silently installs vocabulary policy. */
82
+ declare const standardPayloadContext: SyncPayloadValidationContext;
83
+ //#endregion
84
+ //#region src/standard/operations.d.ts
85
+ type StandardSchemaOperationResult = {
86
+ status: 'resolved';
87
+ schema: SchemaNode;
88
+ } | {
89
+ status: 'emptySet';
90
+ } | {
91
+ status: 'unknown' | 'unsupported';
92
+ message: string;
93
+ };
94
+ declare function standardSchemaSatisfiability(node: SchemaNode): 'inhabited' | 'emptySet' | 'unknown';
95
+ declare function refineStandardSchema(node: SchemaNode, addConstraints: readonly SchemaConstraint[]): StandardSchemaOperationResult;
96
+ declare function intersectStandardSchemas(left: SchemaNode, right: SchemaNode): StandardSchemaOperationResult;
97
+ //#endregion
98
+ //#region src/standard/relations.d.ts
99
+ interface StandardProviderContext {
100
+ readonly semanticIdentityPolicy?: 'ignore' | 'hierarchical' | 'exact';
101
+ }
102
+ /** Accepted-set policy; unknown implication is never treated as compatibility. */
103
+ declare function createStandardRelationContext(options?: StandardProviderContext): RelationContext;
104
+ declare const standardRelationContext: RelationContext;
105
+ declare const standardVocabularyProvider: Readonly<{
106
+ payload: SyncPayloadValidationContext;
107
+ relation: RelationContext;
108
+ refine: typeof refineStandardSchema;
109
+ intersect: typeof intersectStandardSchemas;
110
+ satisfiability: typeof standardSchemaSatisfiability;
111
+ }>;
112
+ //#endregion
113
+ //#region src/authoring/infer.d.ts
114
+ /** Project a statically known SchemaNode into its TypeScript payload carrier. */
115
+ type Infer<Schema$1, Registry = never> = InferNode<Schema$1, Schema$1, Registry>;
116
+ /** Reasons a statically authored schema cannot be projected precisely. */
117
+ type InferFailureReason = 'unsupported-schema' | 'unresolved-ref' | 'dynamic-ref-path' | 'cyclic-ref' | 'ambiguous-ref' | 'unsupported-additional-fields' | 'depth-limit';
118
+ type InferResult<Schema$1, Registry = never> = Reasons<Schema$1, Schema$1, Registry> extends infer Reason ? [Reason] extends [never] ? {
119
+ readonly ok: true;
120
+ readonly type: Infer<Schema$1, Registry>;
121
+ } : {
122
+ readonly ok: false;
123
+ readonly reason: Reason;
124
+ } : never;
125
+ interface StaticSchemaRegistryEntry {
126
+ readonly refPath: readonly string[];
127
+ readonly name: string;
128
+ readonly schema: SchemaNode;
129
+ }
130
+ type StaticSchemaRegistry = readonly StaticSchemaRegistryEntry[];
131
+ type SamePath<Left, Right> = Left extends readonly [infer LH extends string, ...infer LT] ? Right extends readonly [infer RH extends string, ...infer RT] ? [LH, RH] extends [RH, LH] ? SamePath<LT, RT> : false : false : Left extends readonly [] ? Right extends readonly [] ? true : false : false;
132
+ type Matches<Registry, Path$1, Found extends readonly unknown[] = []> = Registry extends readonly [infer Head, ...infer Tail] ? Head extends {
133
+ readonly refPath: infer P;
134
+ readonly schema: infer S;
135
+ } ? Matches<Tail, Path$1, SamePath<P, Path$1> extends true ? [...Found, S] : Found> : Matches<Tail, Path$1, Found> : Found;
136
+ type ResolvedRegistryTarget<Registry, Path$1 extends readonly string[]> = [Registry] extends [never] ? never : number extends Path$1['length'] ? never : string extends Path$1[number] ? never : Registry extends readonly unknown[] ? number extends Registry['length'] ? never : Matches<Registry, Path$1> extends readonly [infer Target] ? Target : never : never;
137
+ type SeenReference<Seen extends readonly (readonly string[])[], Path$1 extends readonly string[]> = Seen[number] extends infer Previous ? Previous extends readonly string[] ? SamePath<Previous, Path$1> extends true ? true : never : never : never;
138
+ /** Project a statically registered reference into its TypeScript payload type. */
139
+ type InferRef<Registry, Path$1 extends readonly string[]> = string extends Path$1[number] ? unknown : [ResolvedRegistryTarget<Registry, Path$1>] extends [never] ? unknown : InferNode<ResolvedRegistryTarget<Registry, Path$1>, ResolvedRegistryTarget<Registry, Path$1>, Registry, [Path$1]>;
140
+ type InferNode<Schema$1, Root, Registry, Seen extends readonly (readonly string[])[] = []> = IsAny<Schema$1> extends true ? unknown : [Schema$1] extends [never] ? unknown : SchemaNode extends Schema$1 ? unknown : Schema$1 extends {
141
+ readonly kind: 'primitive';
142
+ readonly name: infer Name;
143
+ } ? Name extends 'string' ? string : Name extends 'number' ? number : Name extends 'boolean' ? boolean : Name extends 'null' ? null : unknown : Schema$1 extends {
144
+ readonly kind: 'literal';
145
+ readonly literal: infer Value;
146
+ } ? Value extends LiteralValue ? Value : unknown : Schema$1 extends {
147
+ readonly kind: 'literalUnion';
148
+ readonly values: infer Values extends readonly unknown[];
149
+ } ? Values[number] extends LiteralValue ? Values[number] : unknown : Schema$1 extends {
150
+ readonly kind: 'nullable';
151
+ readonly value: infer Value;
152
+ } ? InferNode<Value, Root, Registry, Seen> | null : Schema$1 extends {
153
+ readonly kind: 'array';
154
+ readonly elementSchema: infer Element;
155
+ } ? InferNode<Element, Root, Registry, Seen>[] : Schema$1 extends {
156
+ readonly kind: 'tuple';
157
+ readonly elementSchemas: infer Elements extends readonly unknown[];
158
+ } ? number extends Elements['length'] ? unknown : { -readonly [Index in keyof Elements]: InferNode<Elements[Index], Root, Registry, Seen> } : Schema$1 extends {
159
+ readonly kind: 'record';
160
+ readonly fields: infer Fields extends readonly unknown[];
161
+ } ? InferRecord<Fields, Schema$1, Root, Registry, Seen> : Schema$1 extends {
162
+ readonly kind: 'taggedUnion';
163
+ readonly variants: infer Variants extends readonly unknown[];
164
+ } ? InferVariants<Variants, Root, Registry, Seen> : Schema$1 extends {
165
+ readonly kind: 'selfRef';
166
+ } ? ProductiveRoot<Root> extends true ? InferNode<Root, Root, Registry, Seen> : unknown : Schema$1 extends {
167
+ readonly kind: 'ref';
168
+ readonly refPath: infer Path extends readonly string[];
169
+ } ? true extends SeenReference<Seen, Path> ? unknown : [ResolvedRegistryTarget<Registry, Path>] extends [never] ? unknown : InferNode<ResolvedRegistryTarget<Registry, Path>, Root, Registry, [...Seen, Path]> : Schema$1 extends SchemaNode ? unknown : unknown;
170
+ type IsAny<T> = 0 extends (1 & T) ? true : false;
171
+ type ProductiveRoot<Root> = Root extends {
172
+ readonly kind: 'record' | 'array' | 'tuple' | 'taggedUnion';
173
+ } ? true : false;
174
+ type Reasons<S$1, Root, R, Seen extends readonly (readonly string[])[] = [], Depth extends readonly unknown[] = []> = IsAny<S$1> extends true ? 'unsupported-schema' : [S$1] extends [never] ? 'unsupported-schema' : SchemaNode extends S$1 ? 'unsupported-schema' : Depth['length'] extends 32 ? 'depth-limit' : S$1 extends {
175
+ readonly kind: 'primitive';
176
+ readonly name: 'string' | 'number' | 'boolean' | 'null';
177
+ } ? never : S$1 extends {
178
+ readonly kind: 'literal';
179
+ readonly literal: LiteralValue;
180
+ } ? never : S$1 extends {
181
+ readonly kind: 'literalUnion';
182
+ readonly values: readonly LiteralValue[];
183
+ } ? never : S$1 extends {
184
+ readonly kind: 'nullable';
185
+ readonly value: infer V;
186
+ } ? Reasons<V, Root, R, Seen, [...Depth, 0]> : S$1 extends {
187
+ readonly kind: 'array';
188
+ readonly elementSchema: infer V;
189
+ } ? Reasons<V, Root, R, Seen, [...Depth, 0]> : S$1 extends {
190
+ readonly kind: 'tuple';
191
+ readonly elementSchemas: infer E extends readonly unknown[];
192
+ } ? number extends E['length'] ? 'unsupported-schema' : Children<E[number], Root, R, Seen, [...Depth, 0]> : S$1 extends {
193
+ readonly kind: 'record';
194
+ readonly fields: infer F extends readonly unknown[];
195
+ } ? number extends F['length'] ? 'unsupported-schema' : FieldReasons<F[number], Root, R, Seen, [...Depth, 0]> | AdditionalReasons<S$1, F, Root, R, Seen, [...Depth, 0]> : S$1 extends {
196
+ readonly kind: 'taggedUnion';
197
+ readonly variants: infer V extends readonly unknown[];
198
+ } ? number extends V['length'] ? 'unsupported-schema' : VariantReasons<V[number], Root, R, Seen, [...Depth, 0]> : S$1 extends {
199
+ readonly kind: 'selfRef';
200
+ } ? ProductiveRoot<Root> extends true ? never : 'unsupported-schema' : S$1 extends {
201
+ readonly kind: 'ref';
202
+ readonly refPath: infer P extends readonly string[];
203
+ } ? number extends P['length'] ? 'dynamic-ref-path' : string extends P[number] ? 'dynamic-ref-path' : true extends SeenReference<Seen, P> ? 'cyclic-ref' : [R] extends [never] ? 'unresolved-ref' : R extends readonly unknown[] ? number extends R['length'] ? 'unresolved-ref' : Matches<R, P> extends readonly [] ? 'unresolved-ref' : Matches<R, P> extends readonly [infer Target] ? Reasons<Target, Root, R, [...Seen, P], [...Depth, 0]> : 'ambiguous-ref' : 'unresolved-ref' : 'unsupported-schema';
204
+ type Children<S$1, Root, R, Seen extends readonly (readonly string[])[], D extends readonly unknown[]> = S$1 extends unknown ? Reasons<S$1, Root, R, Seen, D> : never;
205
+ type FieldReasons<F$1, Root, R, Seen extends readonly (readonly string[])[], D extends readonly unknown[]> = F$1 extends {
206
+ readonly key: infer K extends string;
207
+ readonly schema: infer S;
208
+ } ? string extends K ? 'unsupported-schema' : Reasons<S, Root, R, Seen, D> : 'unsupported-schema';
209
+ type VariantReasons<V$1, Root, R, Seen extends readonly (readonly string[])[], D extends readonly unknown[]> = V$1 extends {
210
+ readonly schema: infer S;
211
+ } ? Reasons<S, Root, R, Seen, D> : 'unsupported-schema';
212
+ type AdditionalReasons<S$1, F$1 extends readonly unknown[], Root, R, Seen extends readonly (readonly string[])[], D extends readonly unknown[]> = 'additionalFields' extends keyof S$1 ? S$1 extends {
213
+ readonly additionalFields?: infer A;
214
+ } ? Exclude<A, undefined> extends true ? never : F$1 extends readonly [] ? Reasons<Exclude<A, undefined>, Root, R, Seen, D> : 'unsupported-additional-fields' : never : never;
215
+ type InferRecord<Fields$1 extends readonly unknown[], Schema$1, Root, Registry, Seen extends readonly (readonly string[])[]> = number extends Fields$1['length'] ? unknown : string extends (Fields$1[number] extends {
216
+ readonly key: infer K;
217
+ } ? K : never) ? unknown : Schema$1 extends {
218
+ readonly additionalFields: infer Additional;
219
+ } ? Additional extends true ? InferDeclaredFields<Fields$1, Root, Registry, Seen> & Record<string, unknown> : Additional extends SchemaNode ? Fields$1 extends readonly [] ? Record<string, InferNode<Additional, Root, Registry, Seen>> : unknown : InferDeclaredFields<Fields$1, Root, Registry, Seen> : InferDeclaredFields<Fields$1, Root, Registry, Seen>;
220
+ type InferDeclaredFields<Fields$1 extends readonly unknown[], Root, Registry, Seen extends readonly (readonly string[])[]> = { [Field in Fields$1[number] as Field extends {
221
+ readonly key: infer Key extends string;
222
+ } ? Field extends {
223
+ readonly required: true;
224
+ } ? Key : never : never]-?: Field extends {
225
+ readonly schema: infer FieldSchema;
226
+ } ? InferNode<FieldSchema, Root, Registry, Seen> : unknown } & { [Field in Fields$1[number] as Field extends {
227
+ readonly key: infer Key extends string;
228
+ } ? Field extends {
229
+ readonly required: true;
230
+ } ? never : Key : never]?: Field extends {
231
+ readonly schema: infer FieldSchema;
232
+ } ? InferNode<FieldSchema, Root, Registry, Seen> : unknown };
233
+ type InferVariants<Variants$1 extends readonly unknown[], Root, Registry, Seen extends readonly (readonly string[])[]> = Variants$1[number] extends infer Variant ? number extends Variants$1['length'] ? unknown : Variant extends {
234
+ readonly schema: infer VariantSchema;
235
+ } ? InferNode<VariantSchema, Root, Registry, Seen> : unknown : never;
236
+ declare namespace schema_d_exports {
237
+ export { ArrayOptions, FieldOptions, PrimitiveMetadata, RecordOptions, StaticSchemaRegistry, StaticSchemaRegistryEntry, VariantOptions, array, boolean, defineSchemaRegistry, field, literal, literalUnion, nullValue, nullable, number, optionalField, primitive, record, ref, requiredField, selfRef, string, taggedUnion, tuple, variant };
238
+ }
239
+ interface PrimitiveMetadata {
240
+ semanticPath?: string[];
241
+ constraints?: SchemaConstraint[];
242
+ }
243
+ interface RecordOptions {
244
+ additionalFields?: true | SchemaNode;
245
+ constraints?: SchemaConstraint[];
246
+ }
247
+ interface ArrayOptions {
248
+ constraints?: SchemaConstraint[];
249
+ }
250
+ interface FieldOptions {
251
+ required?: boolean;
252
+ description?: string;
253
+ }
254
+ interface VariantOptions {
255
+ description?: string;
256
+ }
257
+ type FieldResult<Key extends string, Node extends SchemaNode, Options> = Omit<SchemaRecordField, 'key' | 'schema' | 'required'> & {
258
+ key: Key;
259
+ schema: Node;
260
+ } & (Options extends {
261
+ required: true;
262
+ } ? {
263
+ required: true;
264
+ } : {});
265
+ type DiscriminatorLiteral<Schema$1, Key extends string> = Schema$1 extends {
266
+ readonly fields: infer Fields extends readonly unknown[];
267
+ } ? Fields[number] extends infer Field ? Field extends {
268
+ readonly key: Key;
269
+ readonly required: true;
270
+ readonly schema: {
271
+ readonly kind: 'literal';
272
+ readonly literal: infer Value;
273
+ };
274
+ } ? Value : never : never : never;
275
+ type ValidTaggedVariants<Discriminator extends string, Variants$1 extends readonly SchemaTaggedUnionVariant[]> = Variants$1[number] extends infer Variant ? Variant extends {
276
+ readonly key: infer Key extends string;
277
+ readonly schema: infer Schema;
278
+ } ? DiscriminatorLiteral<Schema, Discriminator> extends Key ? Variant : never : never : never;
279
+ /** Construct a primitive SchemaNode. This does not validate metadata. */
280
+ declare function primitive<const Name$1 extends 'string' | 'number'>(name: Name$1, metadata?: PrimitiveMetadata): Extract<SchemaPrimitiveNode, {
281
+ name: Name$1;
282
+ }>;
283
+ declare function primitive<const Name$1 extends 'boolean' | 'null'>(name: Name$1): Extract<SchemaPrimitiveNode, {
284
+ name: Name$1;
285
+ }>;
286
+ declare const string: (metadata?: PrimitiveMetadata) => SchemaStringNode;
287
+ declare const number: (metadata?: PrimitiveMetadata) => SchemaNumberNode;
288
+ declare const boolean: () => SchemaBooleanNode;
289
+ declare const nullValue: () => SchemaNullNode;
290
+ declare function literal<const Value$1 extends LiteralValue>(value: Value$1): Omit<SchemaLiteralNode, 'literal'> & {
291
+ literal: Value$1;
292
+ };
293
+ declare function field<const Key extends string, const Node extends SchemaNode, const Options extends FieldOptions | undefined = undefined>(key: Key, schema: Node, options?: Options): FieldResult<Key, Node, Options>;
294
+ declare function requiredField<const Key extends string, const Node extends SchemaNode>(key: Key, schema: Node, description?: string): Omit<SchemaRecordField, 'key' | 'schema' | 'required'> & {
295
+ key: Key;
296
+ schema: Node;
297
+ required: true;
298
+ };
299
+ declare function optionalField<const Key extends string, const Node extends SchemaNode>(key: Key, schema: Node, description?: string): Omit<SchemaRecordField, 'key' | 'schema' | 'required'> & {
300
+ key: Key;
301
+ schema: Node;
302
+ };
303
+ declare function record<const Fields$1 extends readonly SchemaRecordField[]>(fields: Fields$1): {
304
+ kind: 'record';
305
+ fields: [...Fields$1];
306
+ };
307
+ declare function record<const Fields$1 extends readonly SchemaRecordField[], const Options extends RecordOptions>(fields: Fields$1, options: Options): {
308
+ kind: 'record';
309
+ fields: [...Fields$1];
310
+ } & Options;
311
+ declare function array<const Element$1 extends SchemaNode>(elementSchema: Element$1, options?: ArrayOptions): Omit<SchemaArrayNode, 'elementSchema'> & {
312
+ elementSchema: Element$1;
313
+ };
314
+ declare function tuple<const Elements$1 extends SchemaNode[]>(elementSchemas: Elements$1): Omit<SchemaTupleNode, 'elementSchemas'> & {
315
+ elementSchemas: Elements$1;
316
+ };
317
+ declare function literalUnion<const Values$1 extends [LiteralValue, LiteralValue, ...LiteralValue[]]>(values: Values$1): Omit<SchemaLiteralUnionNode, 'values'> & {
318
+ values: Values$1;
319
+ };
320
+ declare function nullable<const Value$1 extends SchemaNode>(value: Value$1): Omit<SchemaNullableNode, 'value'> & {
321
+ value: Value$1;
322
+ };
323
+ declare function variant<const Key extends string, const Schema$1 extends SchemaRecordNode>(key: Key, schema: Schema$1, options?: VariantOptions): Omit<SchemaTaggedUnionVariant, 'key' | 'schema'> & {
324
+ key: Key;
325
+ schema: Schema$1;
326
+ };
327
+ declare function taggedUnion<const Discriminator extends string, const Variants$1 extends SchemaTaggedUnionVariant[]>(discriminator: Discriminator, variants: Variants$1 & (Variants$1[number] extends ValidTaggedVariants<Discriminator, Variants$1> ? unknown : never)): Omit<SchemaTaggedUnionNode, 'discriminator' | 'variants'> & {
328
+ discriminator: Discriminator;
329
+ variants: Variants$1;
330
+ };
331
+ declare function ref<const Path$1 extends string[]>(refPath: Path$1): Omit<SchemaRefNode, 'refPath'> & {
332
+ refPath: Path$1;
333
+ };
334
+ declare function selfRef(): SchemaSelfRefNode;
335
+ /** Preserve a statically authored registry as ordinary declaration data. */
336
+ declare function defineSchemaRegistry<const Entries extends readonly {
337
+ readonly refPath: readonly string[];
338
+ readonly name: string;
339
+ readonly schema: SchemaNode;
340
+ }[]>(entries: Entries): Entries;
341
+ declare namespace expression_d_exports {
342
+ export { absent, allFields, arrayOf, elementAt, elementOf, excludeVariants, extractVariants, fieldOf, fieldsOf, intersect, keyOf, maybeAbsent, mergeRecords, never, nullableOf, omitFields, opaqueHostType, partialFields, pickFields, recordOf, refine, requiredFields, selectKeys, taggedUnionOf, tupleOf, typeVar, unknown, valueOf };
343
+ }
344
+ declare function typeVar(name: string, upperBound?: SchemaTypeTerm): SchemaTypeExpr;
345
+ declare function opaqueHostType(hostPath: string[]): SchemaTypeExpr;
346
+ declare function absent(): SchemaTypeExpr;
347
+ declare function never(): SchemaTypeExpr;
348
+ declare function unknown(): SchemaTypeExpr;
349
+ declare function maybeAbsent(value: SchemaTypeTerm): SchemaTypeExpr;
350
+ declare function arrayOf(element: SchemaTypeTerm, constraints?: SchemaConstraint[]): SchemaTypeExpr;
351
+ declare function tupleOf(elements: SchemaTypeTerm[]): SchemaTypeExpr;
352
+ declare function recordOf(fields: {
353
+ key: string;
354
+ value: SchemaTypeTerm;
355
+ required?: boolean;
356
+ description?: string;
357
+ }[], options?: {
358
+ additionalFields?: true | SchemaTypeTerm;
359
+ constraints?: SchemaConstraint[];
360
+ }): SchemaTypeExpr;
361
+ declare function nullableOf(value: SchemaTypeTerm): SchemaTypeExpr;
362
+ declare function taggedUnionOf(discriminator: string, variants: {
363
+ key: string;
364
+ value: SchemaTypeTerm;
365
+ description?: string;
366
+ }[]): SchemaTypeExpr;
367
+ declare function elementOf(source: SchemaTypeTerm): SchemaTypeExpr;
368
+ declare function valueOf(source: SchemaTypeTerm): SchemaTypeExpr;
369
+ declare function elementAt(source: SchemaTypeTerm, index: number): SchemaTypeExpr;
370
+ declare function fieldOf(source: SchemaTypeTerm, key: string): SchemaTypeExpr;
371
+ declare function keyOf(source: SchemaTypeTerm): SchemaTypeExpr;
372
+ declare function allFields(): SchemaFieldSelector;
373
+ declare function selectKeys(keys: string[], onMissing?: 'error' | 'ignore'): SchemaFieldSelector;
374
+ declare function fieldsOf(source: SchemaTypeTerm, fields: SchemaFieldSelector): SchemaTypeExpr;
375
+ declare function pickFields(source: SchemaTypeTerm, fields: SchemaFieldSelector): SchemaTypeExpr;
376
+ declare function omitFields(source: SchemaTypeTerm, fields: SchemaFieldSelector): SchemaTypeExpr;
377
+ declare function partialFields(source: SchemaTypeTerm, fields: SchemaFieldSelector): SchemaTypeExpr;
378
+ declare function requiredFields(source: SchemaTypeTerm, fields: SchemaFieldSelector): SchemaTypeExpr;
379
+ declare function mergeRecords(sources: SchemaTypeTerm[], conflict: 'leftWins' | 'rightWins' | 'error'): SchemaTypeExpr;
380
+ declare function intersect(sources: SchemaTypeTerm[]): SchemaTypeExpr;
381
+ declare function refine(source: SchemaTypeTerm, fields: {
382
+ key: string;
383
+ require?: true;
384
+ intersectWith?: SchemaTypeTerm;
385
+ addConstraints?: SchemaConstraint[];
386
+ }[]): SchemaTypeExpr;
387
+ declare function excludeVariants(source: SchemaTypeTerm, variants: SchemaVariantSelector): SchemaTypeExpr;
388
+ declare function extractVariants(source: SchemaTypeTerm, variants: SchemaVariantSelector): SchemaTypeExpr;
389
+ //#endregion
390
+ //#region src/authoring/operation-infer.d.ts
391
+ type Property<T, K extends PropertyKey> = K extends keyof T ? T[K] : undefined;
392
+ /** Map a portable payload to a host-selected TypeScript carrier. */
393
+ type InferOperationPayload<Payload, Registry = never, Binary = unknown> = [Payload] extends [never] ? undefined : Payload extends {
394
+ readonly kind: 'structured';
395
+ readonly schema: infer Schema;
396
+ } ? Infer<Schema, Registry> : Payload extends {
397
+ readonly kind: 'binary';
398
+ } ? Binary : undefined;
399
+ type InferOperationInput<Operation, Registry = never, Binary = unknown> = InferOperationPayload<Property<Operation, 'input'>, Registry, Binary>;
400
+ type InferOperationOutput<Operation, Registry = never, Binary = unknown> = InferOperationPayload<Property<Operation, 'output'>, Registry, Binary>;
401
+ type InferErrorData<Data, Registry> = Data extends undefined ? undefined : Infer<Data, Registry>;
402
+ type InferError<Error, Registry> = InferErrorData<Property<Error, 'data'>, Registry>;
403
+ type InferOperationErrors<Operation, Registry = never> = InferErrors<Property<Operation, 'errors'>, Registry>;
404
+ type InferErrors<Errors, Registry> = Errors extends undefined ? undefined : Errors extends object ? { [Code in keyof Errors]: InferError<Errors[Code], Registry> } : unknown;
405
+ type InferChannel<Channel, Registry, Binary> = Channel extends OperationChannelDefinition ? {
406
+ readonly data: InferOperationPayload<Property<Channel, 'data'>, Registry, Binary>;
407
+ readonly errors: InferOperationErrors<Channel, Registry>;
408
+ } : never;
409
+ type InferOperationEmits<Operation, Registry = never, Binary = unknown> = InferEmits<Property<Operation, 'emits'>, Registry, Binary>;
410
+ type InferEmits<Emits, Registry, Binary> = Emits extends undefined ? undefined : Emits extends Record<string, OperationChannelDefinition> ? { [Name in keyof Emits]: InferChannel<Emits[Name], Registry, Binary> } : unknown;
411
+ /** Convenience projection of all operation channels. */
412
+ type InferOperation<Operation extends OperationDefinition, Registry = never, Binary = unknown> = {
413
+ readonly input: InferOperationInput<Operation, Registry, Binary>;
414
+ readonly output: InferOperationOutput<Operation, Registry, Binary>;
415
+ readonly errors: InferOperationErrors<Operation, Registry>;
416
+ readonly emits: InferOperationEmits<Operation, Registry, Binary>;
417
+ };
418
+ type OperationRegistry = StaticSchemaRegistry;
419
+ //#endregion
420
+ export { isExtensionSemanticPath as $, BuildStandardConstraintProfileOptions as A, ExactRationalFailureReason as B, standardSchemaSatisfiability as C, standardPayloadContext as D, standardConstraintTarget as E, StandardConstraintSatisfiability as F, greatestCommonDivisorRationals as G, exactRationalFromFiniteNumber as H, buildStandardConstraintProfile as I, STANDARD_CONSTRAINT_DEFINITION_MAP as J, leastCommonMultipleRationals as K, isStandardConstraintOwner as L, StandardConstraintInterval as M, StandardConstraintOwner as N, standardSemanticProvider as O, StandardConstraintProfile as P, classifySemanticPath as Q, DEFAULT_EXACT_RATIONAL_MAX_BITS as R, refineStandardSchema as S, standardConstraintRegistry as T, exactRationalIsIntegerMultiple as U, ExactRationalResult as V, formatExactRational as W, StandardSemanticResolution as X, STANDARD_SEMANTIC_DEFINITION_MAP as Y, StandardVocabularyRegistry as Z, createStandardRelationContext as _, InferOperationOutput as a, StandardSchemaOperationResult as b, expression_d_exports as c, InferFailureReason as d, isStandardSemanticNamespace as et, InferRef as f, StandardProviderContext as g, StaticSchemaRegistryEntry as h, InferOperationInput as i, StandardConstraintBound as j, standardSemanticRegistry as k, schema_d_exports as l, StaticSchemaRegistry as m, InferOperationEmits as n, standardVocabularyRegistry as nt, InferOperationPayload as o, InferResult as p, ClassifiedSemanticPath as q, InferOperationErrors as r, OperationRegistry as s, InferOperation as t, pathKey as tt, Infer as u, standardRelationContext as v, standardConstraintProvider as w, intersectStandardSchemas as x, standardVocabularyProvider as y, ExactRational as z };
@@ -0,0 +1,56 @@
1
+ import { ct as SchemaNode } from "./index-DDMwVy2I.cjs";
2
+
3
+ //#region src/payload/validator.d.ts
4
+ type PayloadPath = readonly (string | number)[];
5
+ interface PayloadValidationDiagnostic {
6
+ readonly code: string;
7
+ readonly path: PayloadPath;
8
+ readonly message: string;
9
+ }
10
+ type PayloadValidationResult = {
11
+ readonly status: 'accepted';
12
+ readonly issues: readonly [];
13
+ } | {
14
+ readonly status: 'rejected' | 'unknown';
15
+ readonly issues: readonly PayloadValidationDiagnostic[];
16
+ };
17
+ type PayloadProviderDecision = boolean | {
18
+ readonly status: 'accepted' | 'rejected' | 'unknown' | 'unsupported';
19
+ readonly message?: string;
20
+ };
21
+ interface PayloadProviderContext {
22
+ readonly path: PayloadPath;
23
+ readonly schema: SchemaNode;
24
+ readonly rootSchema: SchemaNode;
25
+ }
26
+ interface PayloadResolutionContext extends PayloadProviderContext {
27
+ readonly refPath: readonly string[];
28
+ }
29
+ type PayloadResolution = SchemaNode | {
30
+ readonly status: 'resolved';
31
+ readonly schema: SchemaNode;
32
+ } | {
33
+ readonly status: 'unknown' | 'unsupported';
34
+ readonly message?: string;
35
+ } | undefined;
36
+ type SemanticProvider = (semanticPath: readonly string[], value: unknown, context: PayloadProviderContext) => PayloadProviderDecision | Promise<PayloadProviderDecision | undefined> | undefined;
37
+ type ConstraintProvider = (constraintPath: readonly string[], args: unknown, value: unknown, context: PayloadProviderContext) => PayloadProviderDecision | Promise<PayloadProviderDecision | undefined> | undefined;
38
+ type SyncSemanticProvider = (semanticPath: readonly string[], value: unknown, context: PayloadProviderContext) => PayloadProviderDecision | undefined;
39
+ type SyncConstraintProvider = (constraintPath: readonly string[], args: unknown, value: unknown, context: PayloadProviderContext) => PayloadProviderDecision | undefined;
40
+ type SyncPayloadResolution = PayloadResolution;
41
+ interface SyncPayloadValidationContext {
42
+ readonly resolveRef?: (refPath: readonly string[], context: PayloadResolutionContext) => SyncPayloadResolution;
43
+ readonly semanticProvider?: SyncSemanticProvider;
44
+ readonly constraintProvider?: SyncConstraintProvider;
45
+ }
46
+ interface PayloadValidationContext {
47
+ readonly resolveRef?: (refPath: readonly string[], context: PayloadResolutionContext) => PayloadResolution | Promise<PayloadResolution>;
48
+ readonly semanticProvider?: SemanticProvider;
49
+ readonly constraintProvider?: ConstraintProvider;
50
+ }
51
+ /** Context accepted by the asynchronous payload validation entry point. */
52
+ type AsyncPayloadValidationContext = PayloadValidationContext;
53
+ declare function validatePayload(value: unknown, schema: SchemaNode, context?: SyncPayloadValidationContext): PayloadValidationResult;
54
+ declare function validatePayloadAsync(value: unknown, schema: SchemaNode, context?: AsyncPayloadValidationContext): Promise<PayloadValidationResult>;
55
+ //#endregion
56
+ export { validatePayloadAsync as _, PayloadProviderDecision as a, PayloadValidationContext as c, SemanticProvider as d, SyncConstraintProvider as f, validatePayload as g, SyncSemanticProvider as h, PayloadProviderContext as i, PayloadValidationDiagnostic as l, SyncPayloadValidationContext as m, ConstraintProvider as n, PayloadResolution as o, SyncPayloadResolution as p, PayloadPath as r, PayloadResolutionContext as s, AsyncPayloadValidationContext as t, PayloadValidationResult as u };