viborm 0.1.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 (113) hide show
  1. package/README.md +529 -0
  2. package/dist/adapters.d.mts +2 -0
  3. package/dist/adapters.mjs +1 -0
  4. package/dist/bun-sql.d.mts +3 -0
  5. package/dist/bun-sql.mjs +2 -0
  6. package/dist/bun-sql.mjs.map +1 -0
  7. package/dist/bun-sqlite.d.mts +3 -0
  8. package/dist/bun-sqlite.mjs +2 -0
  9. package/dist/bun-sqlite.mjs.map +1 -0
  10. package/dist/cache/cloudflare-kv.d.mts +3 -0
  11. package/dist/cache/cloudflare-kv.mjs +2 -0
  12. package/dist/cache/cloudflare-kv.mjs.map +1 -0
  13. package/dist/cache/memory.d.mts +3 -0
  14. package/dist/cache/memory.mjs +2 -0
  15. package/dist/cache/memory.mjs.map +1 -0
  16. package/dist/cache.d.mts +4 -0
  17. package/dist/cache.mjs +1 -0
  18. package/dist/cli.d.mts +1 -0
  19. package/dist/cli.mjs +41 -0
  20. package/dist/cli.mjs.map +1 -0
  21. package/dist/client-CgdtiDGV.mjs +2 -0
  22. package/dist/client-CgdtiDGV.mjs.map +1 -0
  23. package/dist/client.d.mts +3 -0
  24. package/dist/client.mjs +1 -0
  25. package/dist/cloudflare-kv-DauXhtnT.d.mts +1110 -0
  26. package/dist/d1-http.d.mts +3 -0
  27. package/dist/d1-http.mjs +2 -0
  28. package/dist/d1-http.mjs.map +1 -0
  29. package/dist/d1.d.mts +3 -0
  30. package/dist/d1.mjs +2 -0
  31. package/dist/d1.mjs.map +1 -0
  32. package/dist/driver-B_vBzQ6A.mjs +2 -0
  33. package/dist/driver-B_vBzQ6A.mjs.map +1 -0
  34. package/dist/driver-Cj1EbciY.mjs +2 -0
  35. package/dist/driver-Cj1EbciY.mjs.map +1 -0
  36. package/dist/driver.d.mts +2 -0
  37. package/dist/driver.mjs +1 -0
  38. package/dist/errors-DvcqIdEo.mjs +2 -0
  39. package/dist/errors-DvcqIdEo.mjs.map +1 -0
  40. package/dist/helper-cDCDjRAD.d.mts +3020 -0
  41. package/dist/helpers-WNr9B-2U.mjs +2 -0
  42. package/dist/helpers-WNr9B-2U.mjs.map +1 -0
  43. package/dist/hydration-CFnwc7j6.mjs +2 -0
  44. package/dist/hydration-CFnwc7j6.mjs.map +1 -0
  45. package/dist/index-3sdVKfeG.d.mts +1447 -0
  46. package/dist/index-BGmpst1h.d.mts +2158 -0
  47. package/dist/index.d.mts +46 -0
  48. package/dist/index.mjs +2 -0
  49. package/dist/index.mjs.map +1 -0
  50. package/dist/instrumentation.d.mts +2 -0
  51. package/dist/instrumentation.mjs +1 -0
  52. package/dist/libsql.d.mts +3 -0
  53. package/dist/libsql.mjs +2 -0
  54. package/dist/libsql.mjs.map +1 -0
  55. package/dist/migrations.d.mts +1588 -0
  56. package/dist/migrations.mjs +11 -0
  57. package/dist/migrations.mjs.map +1 -0
  58. package/dist/mysql-adapter-0catKeCI.mjs +6 -0
  59. package/dist/mysql-adapter-0catKeCI.mjs.map +1 -0
  60. package/dist/mysql-utils-BPw9qhac.mjs +2 -0
  61. package/dist/mysql-utils-BPw9qhac.mjs.map +1 -0
  62. package/dist/mysql2.d.mts +3 -0
  63. package/dist/mysql2.mjs +2 -0
  64. package/dist/mysql2.mjs.map +1 -0
  65. package/dist/native-types-BwICkVjz.mjs +2 -0
  66. package/dist/native-types-BwICkVjz.mjs.map +1 -0
  67. package/dist/neon-http.d.mts +3 -0
  68. package/dist/neon-http.mjs +2 -0
  69. package/dist/neon-http.mjs.map +1 -0
  70. package/dist/pending-operation-CkzYTpi4.mjs +2 -0
  71. package/dist/pending-operation-CkzYTpi4.mjs.map +1 -0
  72. package/dist/pg.d.mts +3 -0
  73. package/dist/pg.mjs +2 -0
  74. package/dist/pg.mjs.map +1 -0
  75. package/dist/pglite.d.mts +3 -0
  76. package/dist/pglite.mjs +2 -0
  77. package/dist/pglite.mjs.map +1 -0
  78. package/dist/planetscale.d.mts +3 -0
  79. package/dist/planetscale.mjs +2 -0
  80. package/dist/planetscale.mjs.map +1 -0
  81. package/dist/postgres-adapter-Blzqj1bl.mjs +6 -0
  82. package/dist/postgres-adapter-Blzqj1bl.mjs.map +1 -0
  83. package/dist/postgres.d.mts +3 -0
  84. package/dist/postgres.mjs +2 -0
  85. package/dist/postgres.mjs.map +1 -0
  86. package/dist/push-qZreXYkb.mjs +252 -0
  87. package/dist/push-qZreXYkb.mjs.map +1 -0
  88. package/dist/result-parsing-FNQbuHvC.mjs +2 -0
  89. package/dist/result-parsing-FNQbuHvC.mjs.map +1 -0
  90. package/dist/schema-DeAJZocc.mjs +2 -0
  91. package/dist/schema-DeAJZocc.mjs.map +1 -0
  92. package/dist/schema.d.mts +293 -0
  93. package/dist/schema.mjs +2 -0
  94. package/dist/schema.mjs.map +1 -0
  95. package/dist/spans-CJt5UgbJ.mjs +2 -0
  96. package/dist/spans-CJt5UgbJ.mjs.map +1 -0
  97. package/dist/sqlite-adapter-5Em_-oGU.mjs +6 -0
  98. package/dist/sqlite-adapter-5Em_-oGU.mjs.map +1 -0
  99. package/dist/sqlite-utils-BW7elKTz.mjs +2 -0
  100. package/dist/sqlite-utils-BW7elKTz.mjs.map +1 -0
  101. package/dist/sqlite3.d.mts +3 -0
  102. package/dist/sqlite3.mjs +2 -0
  103. package/dist/sqlite3.mjs.map +1 -0
  104. package/dist/tracer-CGzIAsj8.mjs +2 -0
  105. package/dist/tracer-CGzIAsj8.mjs.map +1 -0
  106. package/dist/validation-RtU-wu4N.mjs +2 -0
  107. package/dist/validation-RtU-wu4N.mjs.map +1 -0
  108. package/dist/validation.d.mts +2 -0
  109. package/dist/validation.mjs +1 -0
  110. package/dist/validator-DpJsJcd7.mjs +3 -0
  111. package/dist/validator-DpJsJcd7.mjs.map +1 -0
  112. package/package.json +278 -0
  113. package/readme/README.md +69 -0
@@ -0,0 +1,1447 @@
1
+ import { StandardSchemaV1 } from "@standard-schema/spec";
2
+
3
+ //#region src/validation/inferred.d.ts
4
+
5
+ /**
6
+ * Branded key for type inference.
7
+ *
8
+ * KEY INSIGHT: ArkType uses a STRING, not a unique symbol.
9
+ * This is: export declare const inferred: " arkInferred";
10
+ *
11
+ * Using a string literal allows TypeScript's pattern matching
12
+ * to work correctly during circular reference resolution.
13
+ */
14
+ declare const inferred: " vibInferred";
15
+ type inferred = typeof inferred;
16
+ //#endregion
17
+ //#region src/validation/json-schema/types.d.ts
18
+ /**
19
+ * Standard JSON Schema types for VibORM.
20
+ * Implements the StandardJSONSchemaV1 specification.
21
+ * @see https://standardschema.dev/json-schema
22
+ */
23
+ /**
24
+ * Supported JSON Schema target versions.
25
+ * - draft-07: JSON Schema Draft 7 (widely used)
26
+ * - draft-2020-12: JSON Schema Draft 2020-12 (latest)
27
+ * - openapi-3.0: OpenAPI 3.0 compatible (superset of draft-04)
28
+ */
29
+ type JsonSchemaTarget = "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string);
30
+ /**
31
+ * Options for JSON Schema conversion methods.
32
+ */
33
+ interface JsonSchemaOptions {
34
+ /** Target JSON Schema version */
35
+ readonly target: JsonSchemaTarget;
36
+ /** Vendor-specific options */
37
+ readonly libraryOptions?: Record<string, unknown> | undefined;
38
+ }
39
+ /**
40
+ * JSON Schema object type.
41
+ * A flexible record that can hold any JSON Schema properties.
42
+ */
43
+ interface JsonSchema$1 {
44
+ $schema?: string;
45
+ $defs?: Record<string, JsonSchema$1>;
46
+ $ref?: string;
47
+ type?: string | string[];
48
+ const?: unknown;
49
+ enum?: unknown[];
50
+ properties?: Record<string, JsonSchema$1>;
51
+ required?: string[];
52
+ additionalProperties?: boolean | JsonSchema$1;
53
+ items?: JsonSchema$1 | JsonSchema$1[];
54
+ prefixItems?: JsonSchema$1[];
55
+ minItems?: number;
56
+ maxItems?: number;
57
+ anyOf?: JsonSchema$1[];
58
+ oneOf?: JsonSchema$1[];
59
+ allOf?: JsonSchema$1[];
60
+ nullable?: boolean;
61
+ format?: string;
62
+ contentEncoding?: string;
63
+ minimum?: number;
64
+ maximum?: number;
65
+ minLength?: number;
66
+ maxLength?: number;
67
+ pattern?: string;
68
+ default?: unknown;
69
+ description?: string;
70
+ title?: string;
71
+ [key: string]: unknown;
72
+ }
73
+ /**
74
+ * JSON Schema converter interface.
75
+ * Provides methods to convert to input/output JSON Schema.
76
+ */
77
+ interface JsonSchemaConverter {
78
+ /**
79
+ * Converts the input type to JSON Schema.
80
+ * @throws If conversion is not supported for the given target.
81
+ */
82
+ readonly input: (options: JsonSchemaOptions) => Record<string, unknown>;
83
+ /**
84
+ * Converts the output type to JSON Schema.
85
+ * @throws If conversion is not supported for the given target.
86
+ */
87
+ readonly output: (options: JsonSchemaOptions) => Record<string, unknown>;
88
+ }
89
+ //#endregion
90
+ //#region src/validation/types.d.ts
91
+ /**
92
+ * Prettify forces TypeScript to fully evaluate the type.
93
+ * Recursively prettifies nested objects for cleaner type display.
94
+ * Use sparingly - mapped types are expensive!
95
+ */
96
+ type Prettify<T> = T extends ((...args: any[]) => any) ? T : T extends object ? T extends Date ? T : { [K in keyof T]: Prettify<T[K]> } & {} : T;
97
+ /**
98
+ * Cast interface with OPTIONAL [inferred] - for pattern matching.
99
+ * Uses a tuple [Input, Output] to carry both types.
100
+ */
101
+ interface Cast<TInput = unknown, TOutput = TInput> {
102
+ [inferred]?: [TInput, TOutput];
103
+ }
104
+ /**
105
+ * Thunk returning a Cast - for lazy type resolution in circular references.
106
+ */
107
+ type ThunkCast<TInput = unknown, TOutput = TInput> = () => Cast<TInput, TOutput>;
108
+ /**
109
+ * Base schema interface implementing StandardSchemaV1 and StandardJSONSchemaV1.
110
+ * All VibORM schemas extend this interface.
111
+ */
112
+ interface VibSchema<TInput = unknown, TOutput = TInput> extends StandardSchemaV1<TInput, TOutput> {
113
+ /**
114
+ * Branded type carrier for pattern matching.
115
+ * The tuple [Input, Output] allows extracting both types.
116
+ */
117
+ [inferred]: [TInput, TOutput];
118
+ /**
119
+ * Schema type identifier for runtime checks.
120
+ */
121
+ readonly type: string;
122
+ /**
123
+ * Standard properties extended with JSON Schema converter.
124
+ */
125
+ readonly "~standard": StandardSchemaV1<TInput, TOutput>["~standard"] & {
126
+ /**
127
+ * JSON Schema converter methods.
128
+ * Implements StandardJSONSchemaV1 specification.
129
+ */
130
+ readonly jsonSchema: JsonSchemaConverter;
131
+ };
132
+ }
133
+ /**
134
+ * Options for scalar schemas (string, number, boolean, etc.)
135
+ * TSchemaOut allows the `schema` property to influence output type.
136
+ */
137
+ interface ScalarOptions<T, TOut = T, TSchemaOut = TOut> {
138
+ optional?: boolean;
139
+ nullable?: boolean;
140
+ array?: boolean;
141
+ default?: any | (() => any) | undefined;
142
+ /** Transform function applied AFTER schema validation */
143
+ transform?: ((value: TSchemaOut) => TOut) | undefined;
144
+ /** Additional StandardSchema for extra validation. Its output flows to transform. */
145
+ schema?: StandardSchemaV1<T, TSchemaOut> | undefined;
146
+ }
147
+ /**
148
+ * Extract output type from branded [inferred] property.
149
+ * Uses constrained infer for fewer type branches.
150
+ */
151
+ type InferOutput<Def> = Def extends {
152
+ [inferred]?: [any, infer O];
153
+ } ? O : Def extends (() => {
154
+ [inferred]?: [any, infer O];
155
+ }) ? O : unknown;
156
+ /**
157
+ * Extract input type from branded [inferred] property.
158
+ */
159
+ type InferInput<Def> = Def extends {
160
+ [inferred]?: [infer I, any];
161
+ } ? I : Def extends (() => {
162
+ [inferred]?: [infer I, any];
163
+ }) ? I : unknown;
164
+ /**
165
+ * Infer output shape from object field definitions.
166
+ * Prettify applied once at the end, not per-field.
167
+ */
168
+ type InferOutputShape<Defs> = { [K in keyof Defs]: InferOutput<Defs[K]> };
169
+ /**
170
+ * Infer input shape from object field definitions.
171
+ */
172
+ type InferInputShape<Defs> = { [K in keyof Defs]: InferInput<Defs[K]> };
173
+ /**
174
+ * Boolean key helper for option lookup.
175
+ */
176
+ type BoolKey<T, K$1 extends keyof T> = T[K$1] extends true ? "t" : "f";
177
+ /**
178
+ * Extract the effective input type considering schema.
179
+ * If a schema is provided, use its input type; otherwise use base type.
180
+ */
181
+ type EffectiveInput<T, Opts extends ScalarOptions<any, any, any>> = Opts["schema"] extends StandardSchemaV1<infer I, any> ? I : T;
182
+ /**
183
+ * Compute input type using lookup pattern (fewer conditionals).
184
+ */
185
+ type ComputeInput<T, Opts extends ScalarOptions<any, any, any> | undefined> = Opts extends ScalarOptions<any, any, any> ? ComputeInputLookup<EffectiveInput<T, Opts>, Opts>[`${BoolKey<Opts, "array">}${BoolKey<Opts, "nullable">}${BoolKey<Opts, "optional">}`] : T;
186
+ interface ComputeInputLookup<T, Opts extends ScalarOptions<any, any, any>> {
187
+ ttt: T[] | null | undefined;
188
+ ttf: Opts["default"] extends T | (() => T) ? T[] | null | undefined : T[] | null;
189
+ tft: T[] | undefined;
190
+ tff: Opts["default"] extends T | (() => T) ? T[] | undefined : T[];
191
+ ftt: T | null | undefined;
192
+ ftf: Opts["default"] extends T | (() => T) ? T | null | undefined : T | null;
193
+ fft: T | undefined;
194
+ fff: Opts["default"] extends T | (() => T) ? T | undefined : T;
195
+ }
196
+ /**
197
+ * Extract the effective output type considering schema and transform.
198
+ * Priority: transform > schema > base type
199
+ */
200
+ type EffectiveOutput<T, Opts extends ScalarOptions<any, any, any>> = Opts["transform"] extends ((v: any) => infer R) ? R : Opts["schema"] extends StandardSchemaV1<any, infer S> ? S : T;
201
+ /**
202
+ * Compute output type using lookup pattern.
203
+ */
204
+ type ComputeOutput<T, Opts extends ScalarOptions<any, any, any> | undefined> = Opts extends ScalarOptions<any, any, any> ? ComputeOutputLookup<EffectiveOutput<T, Opts>, Opts>[`${BoolKey<Opts, "array">}${BoolKey<Opts, "nullable">}`] : T;
205
+ interface ComputeOutputLookup<T, _Opts> {
206
+ tt: T[] | null;
207
+ tf: T[];
208
+ ft: T | null;
209
+ ff: T;
210
+ }
211
+ interface ValidationIssue {
212
+ readonly message: string;
213
+ readonly path?: readonly PropertyKey[];
214
+ }
215
+ interface ValidationSuccess<T> {
216
+ readonly value: T;
217
+ readonly issues?: undefined;
218
+ }
219
+ interface ValidationFailure {
220
+ readonly issues: readonly ValidationIssue[];
221
+ }
222
+ type ValidationResult<T> = ValidationSuccess<T> | ValidationFailure;
223
+ declare function isVibSchema(value: unknown): value is VibSchema;
224
+ //#endregion
225
+ //#region src/validation/helpers.d.ts
226
+ /**
227
+ * Create a failure result with a single issue.
228
+ */
229
+ declare function fail(message: string, path?: PropertyKey[]): ValidationResult<never>;
230
+ /**
231
+ * Create a success result.
232
+ */
233
+ declare function ok<T>(value: T): ValidationResult<T>;
234
+ type ValidatorFn<T> = (value: unknown) => ValidationResult<T>;
235
+ /**
236
+ * Build an optimized validator at schema creation time.
237
+ * Uses set theory approach for nullable/optional/array/default combinations.
238
+ *
239
+ * @param baseValidate - The base type validator
240
+ * @param options - Schema options
241
+ * @param typeName - Type name for error messages (unused but kept for API consistency)
242
+ */
243
+ declare function buildValidator<T, TOut, TSchemaOut = T>(baseValidate: ValidatorFn<T>, options: ScalarOptions<T, TOut, TSchemaOut> | undefined, _typeName: string): ValidatorFn<TOut>;
244
+ /**
245
+ * Get default value from options.
246
+ */
247
+ declare function getDefault<T>(options: ScalarOptions<T, any> | undefined): T | undefined;
248
+ /**
249
+ * Create a StandardSchema-compatible schema object.
250
+ */
251
+ declare function createSchema<TInput, TOutput>(type: string, validate: (value: unknown) => ValidationResult<TOutput>): VibSchema<TInput, TOutput>;
252
+ /**
253
+ * Validate a value against a StandardSchema.
254
+ */
255
+ declare function validateSchema<T>(schema: StandardSchemaV1<unknown, T>, value: unknown): ValidationResult<T>;
256
+ //#endregion
257
+ //#region src/validation/json-schema/converters.d.ts
258
+ /**
259
+ * Converts a VibORM schema to a complete JSON Schema document.
260
+ *
261
+ * @param schema - The VibORM schema to convert
262
+ * @param target - The target JSON Schema version
263
+ * @returns Complete JSON Schema with $schema and $defs if needed
264
+ */
265
+ declare function toJsonSchema(schema: VibSchema<unknown, unknown>, target?: JsonSchemaTarget): JsonSchema$1;
266
+ //#endregion
267
+ //#region src/validation/json-schema/factory.d.ts
268
+ /**
269
+ * Creates a JSON Schema converter for a VibORM schema.
270
+ * The converter provides `input` and `output` methods that generate
271
+ * JSON Schema representations of the schema's input and output types.
272
+ *
273
+ * @param schema - The VibORM schema to create a converter for
274
+ * @returns A JsonSchemaConverter with input and output methods
275
+ */
276
+ declare function createJsonSchemaConverter(schema: VibSchema<unknown, unknown>): JsonSchemaConverter;
277
+ //#endregion
278
+ //#region src/validation/schemas/array.d.ts
279
+ interface ArraySchema<TItem extends VibSchema<any, any>, TInput = InferInput<TItem>[], TOutput = InferOutput<TItem>[]> extends VibSchema<TInput, TOutput> {
280
+ readonly type: "array";
281
+ readonly item: TItem;
282
+ }
283
+ /**
284
+ * Create an array schema that validates each item.
285
+ *
286
+ * @example
287
+ * const tags = v.array(v.string());
288
+ * const scores = v.array(v.number());
289
+ */
290
+ declare function array<TItem extends VibSchema<any, any>>(item: TItem): ArraySchema<TItem>;
291
+ //#endregion
292
+ //#region src/validation/schemas/bigint.d.ts
293
+ interface BaseBigIntSchema<Opts extends ScalarOptions<bigint, any> | undefined = undefined> extends VibSchema<ComputeInput<bigint, Opts>, ComputeOutput<bigint, Opts>> {}
294
+ interface BigIntSchema<TInput = bigint, TOutput = bigint> extends VibSchema<TInput, TOutput> {
295
+ readonly type: "bigint";
296
+ }
297
+ /**
298
+ * Validate that a value is a bigint.
299
+ */
300
+ declare function validateBigInt(value: unknown): ValidationResult<bigint> | Readonly<{
301
+ issues: readonly Readonly<{
302
+ message: "Expected bigint";
303
+ }>[];
304
+ }>;
305
+ /**
306
+ * Create a bigint schema.
307
+ *
308
+ * @example
309
+ * const id = v.bigint();
310
+ * const optionalId = v.bigint({ optional: true });
311
+ */
312
+ declare function bigint<const Opts extends ScalarOptions<bigint, any> | undefined = undefined>(options?: Opts): BigIntSchema<ComputeInput<bigint, Opts>, ComputeOutput<bigint, Opts>>;
313
+ //#endregion
314
+ //#region src/validation/schemas/blob.d.ts
315
+ interface BaseBlobSchema<Opts extends ScalarOptions<Uint8Array, any> | undefined = undefined> extends VibSchema<ComputeInput<Uint8Array, Opts>, ComputeOutput<Uint8Array, Opts>> {}
316
+ interface BlobSchema<TInput = Uint8Array, TOutput = Uint8Array> extends VibSchema<TInput, TOutput> {
317
+ readonly type: "blob";
318
+ }
319
+ /**
320
+ * Validate that a value is a Uint8Array or Buffer.
321
+ */
322
+ declare function validateBlob(value: unknown): ValidationResult<Uint8Array<ArrayBufferLike>> | Readonly<{
323
+ issues: readonly Readonly<{
324
+ message: "Expected Uint8Array or Buffer";
325
+ }>[];
326
+ }>;
327
+ /**
328
+ * Create a blob schema for binary data (Uint8Array/Buffer).
329
+ *
330
+ * @example
331
+ * const avatar = v.blob();
332
+ * const optionalBlob = v.blob({ optional: true });
333
+ * const nullableBlob = v.blob({ nullable: true });
334
+ */
335
+ declare function blob<const Opts extends ScalarOptions<Uint8Array, any> | undefined = undefined>(options?: Opts): BlobSchema<ComputeInput<Uint8Array, Opts>, ComputeOutput<Uint8Array, Opts>>;
336
+ //#endregion
337
+ //#region src/validation/schemas/boolean.d.ts
338
+ interface BaseBooleanSchema<Opts extends ScalarOptions<boolean, any> | undefined = undefined> extends VibSchema<ComputeInput<boolean, Opts>, ComputeOutput<boolean, Opts>> {}
339
+ interface BooleanSchema<TInput = boolean, TOutput = boolean> extends VibSchema<TInput, TOutput> {
340
+ readonly type: "boolean";
341
+ }
342
+ /**
343
+ * Validate that a value is a boolean.
344
+ */
345
+ declare function validateBoolean(value: unknown): ValidationResult<boolean> | Readonly<{
346
+ issues: readonly Readonly<{
347
+ message: "Expected boolean";
348
+ }>[];
349
+ }>;
350
+ /**
351
+ * Create a boolean schema.
352
+ *
353
+ * @example
354
+ * const active = v.boolean();
355
+ * const optionalFlag = v.boolean({ optional: true });
356
+ */
357
+ declare function boolean<const Opts extends ScalarOptions<boolean, any> | undefined = undefined>(options?: Opts): BooleanSchema<ComputeInput<boolean, Opts>, ComputeOutput<boolean, Opts>>;
358
+ //#endregion
359
+ //#region src/validation/schemas/date.d.ts
360
+ interface BaseDateSchema<Opts extends ScalarOptions<Date, any> | undefined = undefined> extends VibSchema<ComputeInput<Date, Opts>, ComputeOutput<Date, Opts>> {}
361
+ interface DateSchema<TInput = Date, TOutput = Date> extends VibSchema<TInput, TOutput> {
362
+ readonly type: "date";
363
+ }
364
+ /**
365
+ * Validate that a value is a JavaScript Date object.
366
+ */
367
+ declare function validateDate(value: unknown): Readonly<{
368
+ issues: readonly Readonly<{
369
+ message: "Expected Date";
370
+ }>[];
371
+ }> | Readonly<{
372
+ issues: readonly Readonly<{
373
+ message: "Expected valid Date";
374
+ }>[];
375
+ }> | ValidationResult<Date>;
376
+ /**
377
+ * Create a date schema for JavaScript Date objects.
378
+ *
379
+ * @example
380
+ * const createdAt = v.date();
381
+ * const optionalDate = v.date({ optional: true });
382
+ */
383
+ declare function date<const Opts extends ScalarOptions<Date, any> | undefined = undefined>(options?: Opts): DateSchema<ComputeInput<Date, Opts>, ComputeOutput<Date, Opts>>;
384
+ //#endregion
385
+ //#region src/validation/schemas/enum.d.ts
386
+ type EnumValues<S extends VibSchema> = S extends EnumSchema<infer TValues, any, any> ? TValues : never;
387
+ type BaseEnumSchema<TValues extends string[], Opts extends ScalarOptions<TValues[number], any> | undefined = undefined> = EnumSchema<TValues, ComputeInput<TValues[number], Opts>, ComputeOutput<TValues[number], Opts>>;
388
+ interface EnumSchema<TValues extends string[], TInput = TValues[number], TOutput = TValues[number]> extends VibSchema<TInput, TOutput> {
389
+ readonly type: "enum";
390
+ readonly values: TValues;
391
+ }
392
+ /**
393
+ * Create an enum schema that validates a value is one of the allowed values.
394
+ *
395
+ * @param values - Array of allowed values (strings or numbers)
396
+ * @param options - Schema options
397
+ *
398
+ * @example
399
+ * const status = v.enum_(["active", "inactive", "pending"]);
400
+ * const level = v.enum_([1, 2, 3]);
401
+ * const mixed = v.enum_(["a", 1, "b", 2]);
402
+ */
403
+ declare function enum_<const TValues extends string[], const Opts extends ScalarOptions<TValues[number], any> | undefined = undefined>(values: TValues, options?: Opts): EnumSchema<TValues, ComputeInput<TValues[number], Opts>, ComputeOutput<TValues[number], Opts>>;
404
+ //#endregion
405
+ //#region src/validation/schemas/instance.d.ts
406
+ interface InstanceSchema<TClass extends abstract new (...args: any) => any, TInput = InstanceType<TClass>, TOutput = InstanceType<TClass>> extends VibSchema<TInput, TOutput> {
407
+ readonly type: "instance";
408
+ }
409
+ /**
410
+ * Create an instance schema for validating class instances.
411
+ *
412
+ * @example
413
+ * const buffer = v.instance(Uint8Array);
414
+ * const blob = v.union([v.instance(Uint8Array), v.instance(Buffer)]);
415
+ */
416
+ declare function instance<TClass extends abstract new (...args: any) => any, const Opts extends ScalarOptions<InstanceType<TClass>, any> | undefined = undefined>(classConstructor: TClass, options?: Opts): InstanceSchema<TClass, ComputeInput<InstanceType<TClass>, Opts>, ComputeOutput<InstanceType<TClass>, Opts>>;
417
+ //#endregion
418
+ //#region src/validation/schemas/iso.d.ts
419
+ interface BaseIsoTimestampSchema<Opts extends ScalarOptions<string, any> | undefined = undefined> extends VibSchema<ComputeInput<string | Date, Opts>, ComputeOutput<string, Opts>> {}
420
+ interface IsoTimestampSchema<TInput = string | Date, TOutput = string> extends VibSchema<TInput, TOutput> {
421
+ readonly type: "iso_timestamp";
422
+ }
423
+ /**
424
+ * Validate ISO timestamp format.
425
+ * Accepts Date objects and converts them to ISO strings.
426
+ */
427
+ declare function validateIsoTimestamp(value: unknown): Readonly<{
428
+ issues: readonly Readonly<{
429
+ message: "Invalid date in ISO timestamp";
430
+ }>[];
431
+ }> | ValidationResult<string> | Readonly<{
432
+ issues: readonly Readonly<{
433
+ message: "Expected string or Date";
434
+ }>[];
435
+ }> | Readonly<{
436
+ issues: readonly Readonly<{
437
+ message: "Expected ISO timestamp format (YYYY-MM-DDTHH:mm:ss.sssZ)";
438
+ }>[];
439
+ }>;
440
+ /**
441
+ * Create an ISO timestamp schema.
442
+ * Accepts strings in format: 2023-12-15T10:30:00.000Z or Date objects.
443
+ * Date objects are automatically converted to ISO strings.
444
+ *
445
+ * @example
446
+ * const timestamp = v.isoTimestamp();
447
+ * parse(timestamp, new Date()) // Returns ISO string
448
+ */
449
+ declare function isoTimestamp<const Opts extends ScalarOptions<string, any> | undefined = undefined>(options?: Opts): IsoTimestampSchema<ComputeInput<string | Date, Opts>, ComputeOutput<string, Opts>>;
450
+ interface BaseIsoDateSchema<Opts extends ScalarOptions<string, any> | undefined = undefined> extends VibSchema<ComputeInput<string | Date, Opts>, ComputeOutput<string, Opts>> {}
451
+ interface IsoDateSchema<TInput = string | Date, TOutput = string> extends VibSchema<TInput, TOutput> {
452
+ readonly type: "iso_date";
453
+ }
454
+ /**
455
+ * Validate ISO date format.
456
+ * Accepts Date objects and converts them to ISO date strings (YYYY-MM-DD).
457
+ */
458
+ declare function validateIsoDate(value: unknown): ValidationResult<string> | Readonly<{
459
+ issues: readonly Readonly<{
460
+ message: "Expected string or Date";
461
+ }>[];
462
+ }> | Readonly<{
463
+ issues: readonly Readonly<{
464
+ message: "Invalid date";
465
+ }>[];
466
+ }> | Readonly<{
467
+ issues: readonly Readonly<{
468
+ message: "Expected ISO date format (YYYY-MM-DD)";
469
+ }>[];
470
+ }>;
471
+ /**
472
+ * Create an ISO date schema.
473
+ * Accepts strings in format: 2023-12-15 or Date objects.
474
+ * Date objects are automatically converted to ISO date strings (YYYY-MM-DD).
475
+ *
476
+ * @example
477
+ * const birthDate = v.isoDate();
478
+ * parse(birthDate, new Date()) // Returns "2023-12-15"
479
+ */
480
+ declare function isoDate<const Opts extends ScalarOptions<string, any> | undefined = undefined>(options?: Opts): IsoDateSchema<ComputeInput<string | Date, Opts>, ComputeOutput<string, Opts>>;
481
+ interface BaseIsoTimeSchema<Opts extends ScalarOptions<string, any> | undefined = undefined> extends VibSchema<ComputeInput<string | Date, Opts>, ComputeOutput<string, Opts>> {}
482
+ interface IsoTimeSchema<TInput = string | Date, TOutput = string> extends VibSchema<TInput, TOutput> {
483
+ readonly type: "iso_time";
484
+ }
485
+ /**
486
+ * Validate ISO time format.
487
+ * Accepts Date objects and extracts the time portion (HH:mm:ss.sss).
488
+ */
489
+ declare function validateIsoTime(value: unknown): ValidationResult<string> | Readonly<{
490
+ issues: readonly Readonly<{
491
+ message: "Expected string or Date";
492
+ }>[];
493
+ }> | Readonly<{
494
+ issues: readonly Readonly<{
495
+ message: "Invalid time";
496
+ }>[];
497
+ }> | Readonly<{
498
+ issues: readonly Readonly<{
499
+ message: "Expected ISO time format (HH:mm:ss)";
500
+ }>[];
501
+ }>;
502
+ /**
503
+ * Create an ISO time schema.
504
+ * Accepts strings in format: 10:30:00 or Date objects.
505
+ * Date objects are automatically converted to time strings (HH:mm:ss.sss).
506
+ *
507
+ * @example
508
+ * const startTime = v.isoTime();
509
+ * parse(startTime, new Date()) // Returns "10:30:00.000"
510
+ */
511
+ declare function isoTime<const Opts extends ScalarOptions<string, any> | undefined = undefined>(options?: Opts): IsoTimeSchema<ComputeInput<string | Date, Opts>, ComputeOutput<string, Opts>>;
512
+ //#endregion
513
+ //#region src/validation/schemas/json.d.ts
514
+ /**
515
+ * JSON-compatible value type.
516
+ * Represents any value that can be safely serialized to JSON.
517
+ */
518
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
519
+ [key: string]: JsonValue;
520
+ };
521
+ interface BaseJsonSchema<Opts extends ScalarOptions<JsonValue, any> | undefined = undefined> extends VibSchema<ComputeInput<JsonValue, Opts>, ComputeOutput<JsonValue, Opts>> {}
522
+ interface JsonSchema<TInput = JsonValue, TOutput = JsonValue> extends VibSchema<TInput, TOutput> {
523
+ readonly type: "json";
524
+ }
525
+ /**
526
+ * Check if a value is JSON-compatible (can be serialized without loss).
527
+ * Rejects: undefined, functions, symbols, bigint, circular references.
528
+ */
529
+ declare function isJsonValue(value: unknown, seen?: WeakSet<object>): boolean;
530
+ /**
531
+ * Validate that a value is JSON-compatible.
532
+ */
533
+ declare function validateJson(value: unknown): ValidationResult<JsonValue> | Readonly<{
534
+ issues: readonly Readonly<{
535
+ message: "Expected JSON-compatible value";
536
+ }>[];
537
+ }>;
538
+ /**
539
+ * Create a JSON schema that validates any JSON-compatible value.
540
+ * Accepts: strings, numbers (finite), booleans, null, arrays, plain objects.
541
+ * Rejects: undefined, functions, symbols, bigint, circular references, class instances.
542
+ *
543
+ * @example
544
+ * const data = v.json();
545
+ * const optionalData = v.json({ optional: true });
546
+ * const nullableData = v.json({ nullable: true });
547
+ */
548
+ declare function json<const Opts extends ScalarOptions<JsonValue, any> | undefined = undefined>(options?: Opts): JsonSchema<ComputeInput<JsonValue, Opts>, ComputeOutput<JsonValue, Opts>>;
549
+ //#endregion
550
+ //#region src/validation/schemas/literal.d.ts
551
+ type LiteralValue = string | number | boolean | null | undefined | bigint;
552
+ interface LiteralSchema<T extends LiteralValue, TInput = T, TOutput = T> extends VibSchema<TInput, TOutput> {
553
+ readonly type: "literal";
554
+ readonly value: T;
555
+ }
556
+ /**
557
+ * Create a literal schema that matches an exact value.
558
+ *
559
+ * @example
560
+ * const admin = v.literal("admin");
561
+ * const zero = v.literal(0);
562
+ * const isTrue = v.literal(true);
563
+ */
564
+ declare function literal<const T extends LiteralValue, const Opts extends ScalarOptions<T, any> | undefined = undefined>(expected: T, options?: Opts): LiteralSchema<T, ComputeInput<T, Opts>, ComputeOutput<T, Opts>>;
565
+ //#endregion
566
+ //#region src/validation/schemas/nonArray.d.ts
567
+ /**
568
+ * Extract element type from array type.
569
+ */
570
+ type ElementOf<T> = T extends readonly (infer E)[] ? E : T;
571
+ /**
572
+ * Schema that validates a single element instead of an array.
573
+ * Useful for unwrapping array schemas.
574
+ */
575
+ interface NonArraySchema<TInput, TOutput> extends VibSchema<TInput, TOutput> {
576
+ readonly type: "nonArray";
577
+ }
578
+ /**
579
+ * Unwrap an array schema to validate single elements.
580
+ * If the wrapped schema expects an array, this validates a single element.
581
+ *
582
+ * @example
583
+ * const tags = v.string({ array: true });
584
+ * // tags validates: string[]
585
+ *
586
+ * const singleTag = v.nonArray(tags);
587
+ * // singleTag validates: string
588
+ *
589
+ * @example
590
+ * // Alias: element()
591
+ * const oneItem = v.element(v.number({ array: true }));
592
+ */
593
+ declare function nonArray<I$1, O$1>(schema: StandardSchemaV1<I$1[], O$1[]>): NonArraySchema<ElementOf<I$1>, ElementOf<O$1>>;
594
+ declare function nonArray<I$1, O$1>(schema: StandardSchemaV1<I$1, O$1>): NonArraySchema<ElementOf<I$1>, ElementOf<O$1>>;
595
+ /**
596
+ * Alias for nonArray.
597
+ * Extracts the element schema from an array schema.
598
+ */
599
+ declare const element: typeof nonArray;
600
+ //#endregion
601
+ //#region src/validation/schemas/nonNullable.d.ts
602
+ /**
603
+ * Schema that wraps another schema and excludes null from both input and output.
604
+ * Rejects null values at validation time.
605
+ */
606
+ interface NonNullableSchema<TInput, TOutput> extends VibSchema<TInput, TOutput> {
607
+ readonly type: "nonNullable";
608
+ }
609
+ /**
610
+ * Wrap a schema to exclude null from both input and output types.
611
+ * Fails validation if the value is null.
612
+ *
613
+ * @example
614
+ * const maybeNull = v.string({ nullable: true });
615
+ * const definitelyString = v.nonNullable(maybeNull);
616
+ * // Input: string, Output: string (null excluded from both)
617
+ *
618
+ * @example
619
+ * // Works with any StandardSchemaV1
620
+ * const externalSchema: StandardSchemaV1<unknown, string | null> = ...;
621
+ * const strict = v.nonNullable(externalSchema);
622
+ */
623
+ declare function nonNullable<I$1, O$1>(schema: StandardSchemaV1<I$1, O$1 | null> | StandardSchemaV1<I$1, O$1>): NonNullableSchema<NonNullable<I$1>, NonNullable<O$1>>;
624
+ //#endregion
625
+ //#region src/validation/schemas/nonOptional.d.ts
626
+ /**
627
+ * Schema that wraps another schema and ensures the value is defined.
628
+ * Rejects undefined values.
629
+ */
630
+ interface NonOptionalSchema<TInput, TOutput> extends VibSchema<TInput, TOutput> {
631
+ readonly type: "nonOptional";
632
+ }
633
+ /**
634
+ * Wrap a schema to ensure its input/output is not undefined.
635
+ * Fails validation if the value is undefined.
636
+ *
637
+ * @example
638
+ * const maybeUndefined = v.string({ optional: true });
639
+ * const required = v.nonOptional(maybeUndefined);
640
+ * // Input: string, Output: string (undefined rejected)
641
+ *
642
+ * @example
643
+ * // Alias: required()
644
+ * const requiredName = v.required(v.string({ optional: true }));
645
+ */
646
+ declare function nonOptional<I$1, O$1>(schema: StandardSchemaV1<I$1 | undefined, O$1 | undefined> | StandardSchemaV1<I$1, O$1 | undefined> | StandardSchemaV1<I$1 | undefined, O$1> | StandardSchemaV1<I$1, O$1>): NonOptionalSchema<Exclude<I$1, undefined>, Exclude<O$1, undefined>>;
647
+ /**
648
+ * Alias for nonOptional.
649
+ * Makes a schema required (rejects undefined).
650
+ */
651
+ declare const required: typeof nonOptional;
652
+ //#endregion
653
+ //#region src/validation/schemas/nullable.d.ts
654
+ interface NullableSchema<TWrapped extends VibSchema<any, any>, TInput = InferInput<TWrapped> | null, TOutput = InferOutput<TWrapped> | null> extends VibSchema<TInput, TOutput> {
655
+ readonly type: "nullable";
656
+ readonly wrapped: TWrapped;
657
+ }
658
+ /**
659
+ * Create a nullable schema that allows null values.
660
+ *
661
+ * @example
662
+ * const nullableName = v.nullable(v.string());
663
+ */
664
+ declare function nullable<TWrapped extends VibSchema<any, any>>(wrapped: TWrapped): NullableSchema<TWrapped>;
665
+ /**
666
+ * Conditionally wrap a schema in nullable based on a boolean flag.
667
+ * Useful for building schemas dynamically where nullability is determined at compile time.
668
+ *
669
+ * @example
670
+ * const schema = v.maybeNullable(v.string(), true); // NullableSchema<StringSchema>
671
+ * const schema2 = v.maybeNullable(v.string(), false); // StringSchema
672
+ */
673
+ declare function maybeNullable<TWrapped extends VibSchema<any, any>, TIsNullable extends boolean>(wrapped: TWrapped, isNullable: TIsNullable): TIsNullable extends true ? NullableSchema<TWrapped> : TWrapped;
674
+ //#endregion
675
+ //#region src/validation/schemas/number.d.ts
676
+ interface BaseNumberSchema<Opts extends ScalarOptions<number, any> | undefined = undefined> extends VibSchema<ComputeInput<number, Opts>, ComputeOutput<number, Opts>> {}
677
+ interface NumberSchema<TInput = number, TOutput = number> extends VibSchema<TInput, TOutput> {
678
+ readonly type: "number";
679
+ }
680
+ /**
681
+ * Validate that a value is a finite number (rejects NaN and Infinity).
682
+ */
683
+ declare function validateNumber(value: unknown): ValidationResult<number> | Readonly<{
684
+ issues: readonly Readonly<{
685
+ message: "Expected finite number";
686
+ }>[];
687
+ }>;
688
+ /**
689
+ * Create a number schema.
690
+ *
691
+ * @example
692
+ * const age = v.number();
693
+ * const optionalAge = v.number({ optional: true });
694
+ * const scores = v.number({ array: true });
695
+ */
696
+ declare function number<const Opts extends ScalarOptions<number, any> | undefined = undefined>(options?: Opts): NumberSchema<ComputeInput<number, Opts>, ComputeOutput<number, Opts>>;
697
+ interface BaseIntegerSchema<Opts extends ScalarOptions<number, any> | undefined = undefined> extends VibSchema<ComputeInput<number, Opts>, ComputeOutput<number, Opts>> {}
698
+ interface IntegerSchema<TInput = number, TOutput = number> extends VibSchema<TInput, TOutput> {
699
+ readonly type: "integer";
700
+ }
701
+ /**
702
+ * Validate that a value is an integer.
703
+ */
704
+ declare function validateInteger(value: unknown): ValidationResult<number> | Readonly<{
705
+ issues: readonly Readonly<{
706
+ message: "Expected integer";
707
+ }>[];
708
+ }>;
709
+ /**
710
+ * Create an integer schema.
711
+ *
712
+ * @example
713
+ * const count = v.integer();
714
+ */
715
+ declare function integer<const Opts extends ScalarOptions<number, any> | undefined = undefined>(options?: Opts): IntegerSchema<ComputeInput<number, Opts>, ComputeOutput<number, Opts>>;
716
+ //#endregion
717
+ //#region src/validation/schemas/object.d.ts
718
+ /**
719
+ * Object entries - a record of field names to schemas or thunks.
720
+ */
721
+ type ObjectEntries = Record<string, VibSchema<any, any> | ThunkCast<any, any>>;
722
+ /**
723
+ * Options for object schemas.
724
+ */
725
+ interface ObjectOptions<T = unknown, TKeys extends string = string> {
726
+ /** Make all fields optional (default: true) */
727
+ partial?: boolean;
728
+ /** Reject unknown keys (default: true) */
729
+ strict?: boolean;
730
+ /** Make the object itself optional (undefined allowed) */
731
+ optional?: boolean;
732
+ /** Make the object itself nullable (null allowed) */
733
+ nullable?: boolean;
734
+ /** Validate as array of objects */
735
+ array?: boolean;
736
+ /** Default value when undefined/null */
737
+ default?: T | (() => T);
738
+ /** Transform output */
739
+ transform?: (value: T) => T;
740
+ /** Object name for circular references in json schema*/
741
+ name?: string;
742
+ /** Object description for json schema*/
743
+ description?: string;
744
+ /** Require at least these specific keys (works with partial: true) */
745
+ atLeast?: TKeys[];
746
+ }
747
+ /**
748
+ * Compute input type based on partial option.
749
+ * Default is partial: true, so only non-partial when explicitly { partial: false }
750
+ * If atLeast is specified, those keys are required even when partial: true
751
+ */
752
+ type ComputeObjectInput<TEntries, TOpts> = TOpts extends {
753
+ partial: false;
754
+ } ? InferInputShape<TEntries> : TOpts extends {
755
+ atLeast: infer Keys extends readonly string[];
756
+ } ? RequireKeys<Partial<InferInputShape<TEntries>>, Keys[number]> : Partial<InferInputShape<TEntries>>;
757
+ /**
758
+ * Compute output type based on entries.
759
+ * Unlike input, output doesn't use Partial - each field's schema determines
760
+ * whether its output includes undefined (based on whether it has a default).
761
+ */
762
+ type ComputeObjectOutput<TEntries, _TOpts> = InferOutputShape<TEntries>;
763
+ /**
764
+ * Make specific keys required in an otherwise partial object.
765
+ * Uses a mapped type instead of Omit & Required<Pick> to reduce type depth.
766
+ */
767
+ type RequireKeys<T, K$1 extends string> = { [P in keyof T as P extends K$1 ? never : P]?: T[P] } & { [P in keyof T as P extends K$1 ? P : never]-?: T[P] };
768
+ /**
769
+ * Apply wrapper options (optional, nullable, array) to input type.
770
+ * Input accepts undefined when optional (even with default).
771
+ */
772
+ type ApplyObjectOptionsInput<TBase, TOpts> = TOpts extends {
773
+ array: true;
774
+ } ? TOpts extends {
775
+ optional: true;
776
+ } ? TOpts extends {
777
+ nullable: true;
778
+ } ? TBase[] | undefined | null : TBase[] | undefined : TOpts extends {
779
+ nullable: true;
780
+ } ? TBase[] | null : TBase[] : TOpts extends {
781
+ optional: true;
782
+ } ? TOpts extends {
783
+ nullable: true;
784
+ } ? TBase | undefined | null : TBase | undefined : TOpts extends {
785
+ nullable: true;
786
+ } ? TBase | null : TBase;
787
+ /**
788
+ * Apply wrapper options (optional, nullable, array) to output type.
789
+ * When a default is provided, undefined is not included in output
790
+ * (the default will always be applied).
791
+ */
792
+ type ApplyObjectOptionsOutput<TBase, TOpts> = TOpts extends {
793
+ array: true;
794
+ } ? TOpts extends {
795
+ optional: true;
796
+ } ? TOpts extends {
797
+ default: any;
798
+ } ? TOpts extends {
799
+ nullable: true;
800
+ } ? TBase[] | null : TBase[] : TOpts extends {
801
+ nullable: true;
802
+ } ? TBase[] | undefined | null : TBase[] | undefined : TOpts extends {
803
+ nullable: true;
804
+ } ? TBase[] | null : TBase[] : TOpts extends {
805
+ optional: true;
806
+ } ? TOpts extends {
807
+ default: any;
808
+ } ? TOpts extends {
809
+ nullable: true;
810
+ } ? TBase | null : TBase : TOpts extends {
811
+ nullable: true;
812
+ } ? TBase | undefined | null : TBase | undefined : TOpts extends {
813
+ nullable: true;
814
+ } ? TBase | null : TBase;
815
+ /**
816
+ * Object schema interface.
817
+ */
818
+ interface ObjectSchema<TEntries, TOpts extends ObjectOptions | undefined = undefined, TInput = ApplyObjectOptionsInput<ComputeObjectInput<TEntries, TOpts>, TOpts>, TOutput = ApplyObjectOptionsOutput<ComputeObjectOutput<TEntries, TOpts>, TOpts>> extends VibSchema<TInput, TOutput> {
819
+ readonly type: "object";
820
+ readonly entries: TEntries;
821
+ readonly options: TOpts;
822
+ readonly parse: VibSchema<TInput, TOutput>["~standard"]["validate"];
823
+ /** Extend this schema with additional entries */
824
+ extend<TNewEntries extends ObjectEntries, TNewTOpts extends ObjectOptions | undefined = undefined>(newEntries: TNewEntries, options?: TNewTOpts): ObjectSchema<TEntries & TNewEntries, TOpts & TNewTOpts>;
825
+ }
826
+ /**
827
+ * Create an object schema.
828
+ *
829
+ * IMPORTANT: No constraint on TEntries to allow circular reference resolution.
830
+ * The identity conditional (R extends infer _ ? _ : never) defers type evaluation.
831
+ *
832
+ * @param entries - Object field definitions
833
+ * @param options - Schema options
834
+ * - `strict` (default: true) - Reject unknown keys
835
+ * - `partial` (default: true) - Make all fields optional
836
+ * - `optional` - Allow undefined
837
+ * - `nullable` - Allow null
838
+ * - `array` - Validate as array of objects
839
+ * - `default` - Default value
840
+ * - `transform` - Transform output
841
+ *
842
+ * @example
843
+ * // Basic object (strict by default)
844
+ * const user = v.object({
845
+ * name: v.string(),
846
+ * age: v.number(),
847
+ * });
848
+ *
849
+ * // Circular references
850
+ * const node = v.object({
851
+ * value: v.string(),
852
+ * child: () => node, // Thunk
853
+ * });
854
+ */
855
+ declare function object<TEntries,
856
+ // NO constraint - critical for circular references
857
+ const TOpts extends ObjectOptions | undefined = undefined, R = ObjectSchema<TEntries, TOpts>>(entries: TEntries, options?: TOpts): R extends infer _ ? _ : never;
858
+ //#endregion
859
+ //#region src/validation/schemas/optional.d.ts
860
+ /**
861
+ * Schema or thunk that can be wrapped with optional.
862
+ */
863
+ type WrappableSchema = VibSchema<any, any> | ThunkCast<any, any> | (() => Cast<any, any>);
864
+ /**
865
+ * Unwrap a schema or thunk to get the underlying schema type.
866
+ */
867
+ type UnwrapSchema<T> = T extends VibSchema<any, any> ? T : T extends ThunkCast<infer I, infer O> ? VibSchema<I, O> : T extends (() => Cast<infer I, infer O>) ? VibSchema<I, O> : never;
868
+ interface OptionalSchema<TWrapped extends WrappableSchema, TDefault = undefined, TInput = InferInput<UnwrapSchema<TWrapped>> | undefined, TOutput = (TDefault extends undefined ? InferOutput<UnwrapSchema<TWrapped>> | undefined : InferOutput<UnwrapSchema<TWrapped>>)> extends VibSchema<TInput, TOutput> {
869
+ readonly type: "optional";
870
+ readonly wrapped: TWrapped;
871
+ readonly default: TDefault;
872
+ }
873
+ /**
874
+ * Create an optional schema that allows undefined values.
875
+ * Supports both direct schemas and thunks (for circular references).
876
+ * Optionally provide a default value for when undefined is received.
877
+ *
878
+ * @example
879
+ * const optionalName = v.optional(v.string());
880
+ * const nameWithDefault = v.optional(v.string(), "Unknown");
881
+ *
882
+ * // With thunks (circular references)
883
+ * const node = v.object({ child: v.optional(() => node) });
884
+ */
885
+ declare function optional<TWrapped extends WrappableSchema, TDefault extends InferOutput<UnwrapSchema<TWrapped>> | (() => InferOutput<UnwrapSchema<TWrapped>>) | undefined = undefined>(wrapped: TWrapped, defaultValue?: TDefault): OptionalSchema<TWrapped, TDefault>;
886
+ //#endregion
887
+ //#region src/validation/schemas/point.d.ts
888
+ /**
889
+ * Point type with x and y coordinates.
890
+ */
891
+ interface Point {
892
+ x: number;
893
+ y: number;
894
+ }
895
+ interface BasePointSchema<Opts extends ScalarOptions<Point, any> | undefined = undefined> extends VibSchema<ComputeInput<Point, Opts>, ComputeOutput<Point, Opts>> {}
896
+ interface PointSchema<TInput = Point, TOutput = Point> extends VibSchema<TInput, TOutput> {
897
+ readonly type: "point";
898
+ }
899
+ /**
900
+ * Validate that a value is a point with x and y coordinates.
901
+ */
902
+ declare function validatePoint(value: unknown): Readonly<{
903
+ issues: readonly Readonly<{
904
+ message: "Expected point object";
905
+ }>[];
906
+ }> | Readonly<{
907
+ issues: readonly Readonly<{
908
+ message: "Expected point with x and y properties";
909
+ }>[];
910
+ }> | Readonly<{
911
+ issues: readonly Readonly<{
912
+ message: "Expected x to be a number";
913
+ }>[];
914
+ }> | Readonly<{
915
+ issues: readonly Readonly<{
916
+ message: "Expected y to be a number";
917
+ }>[];
918
+ }> | ValidationResult<Point>;
919
+ /**
920
+ * Create a point schema for { x, y } coordinates.
921
+ *
922
+ * @example
923
+ * const location = v.point();
924
+ * const optionalPoint = v.point({ optional: true });
925
+ * const pointArray = v.point({ array: true });
926
+ */
927
+ declare function point<const Opts extends ScalarOptions<Point, any> | undefined = undefined>(options?: Opts): PointSchema<ComputeInput<Point, Opts>, ComputeOutput<Point, Opts>>;
928
+ //#endregion
929
+ //#region src/validation/schemas/string.d.ts
930
+ interface BaseStringSchema<Opts extends ScalarOptions<string, any> | undefined = undefined> extends VibSchema<ComputeInput<string, Opts>, ComputeOutput<string, Opts>> {}
931
+ interface StringSchema<TInput = string, TOutput = string> extends VibSchema<TInput, TOutput> {
932
+ readonly type: "string";
933
+ }
934
+ /**
935
+ * Validate that a value is a string.
936
+ */
937
+ declare function validateString(value: unknown): ValidationResult<string> | Readonly<{
938
+ issues: readonly Readonly<{
939
+ message: "Expected string";
940
+ }>[];
941
+ }>;
942
+ /**
943
+ * Create a string schema.
944
+ *
945
+ * @example
946
+ * const name = v.string();
947
+ * const optionalName = v.string({ optional: true });
948
+ * const tags = v.string({ array: true });
949
+ */
950
+ declare function string<const Opts extends ScalarOptions<string, any> | undefined = undefined>(options?: Opts): StringSchema<ComputeInput<string, Opts>, ComputeOutput<string, Opts>>;
951
+ //#endregion
952
+ //#region src/validation/schemas/union.d.ts
953
+ interface UnionSchema<TOptions extends readonly VibSchema<any, any>[], TInput = TOptions[number][" vibInferred"]["0"], TOutput = InferOutput<TOptions[number]>> extends VibSchema<TInput, TOutput> {
954
+ readonly type: "union";
955
+ readonly options: TOptions;
956
+ }
957
+ /**
958
+ * Create a union schema that validates against multiple options.
959
+ * Returns the result of the first matching schema.
960
+ *
961
+ * @example
962
+ * const stringOrNumber = v.union([v.string(), v.number()]);
963
+ */
964
+ declare function union<const TOptions extends readonly VibSchema<any, any>[]>(options: TOptions): UnionSchema<TOptions>;
965
+ //#endregion
966
+ //#region src/validation/schemas/vector.d.ts
967
+ interface BaseVectorSchema<Opts extends ScalarOptions<number[], any> | undefined = undefined> extends VibSchema<ComputeInput<number[], Opts>, ComputeOutput<number[], Opts>> {}
968
+ interface VectorSchema<TInput = number[], TOutput = number[]> extends VibSchema<TInput, TOutput> {
969
+ readonly type: "vector";
970
+ }
971
+ /**
972
+ * Validate that a value is a vector (array of numbers).
973
+ * Optionally check for specific dimensions.
974
+ */
975
+ declare function createVectorValidator(dimensions?: number): (value: unknown) => ValidationFailure | Readonly<{
976
+ issues: readonly Readonly<{
977
+ message: "Expected array of numbers";
978
+ }>[];
979
+ }> | Readonly<{
980
+ issues: readonly Readonly<{
981
+ message: `Expected vector of ${number} dimensions`;
982
+ }>[];
983
+ }> | ValidationSuccess<number[]>;
984
+ /**
985
+ * Create a vector schema for arrays of numbers (embeddings, coordinates, etc.)
986
+ *
987
+ * @param dimensions - Optional fixed number of dimensions
988
+ * @param options - Schema options
989
+ *
990
+ * @example
991
+ * const embedding = v.vector(); // Any length
992
+ * const embedding3d = v.vector(3); // Exactly 3 dimensions
993
+ * const optionalVector = v.vector(undefined, { optional: true });
994
+ */
995
+ declare function vector<const Opts extends ScalarOptions<number[], any> | undefined = undefined>(dimensions?: number, options?: Opts): VectorSchema<ComputeInput<number[], Opts>, ComputeOutput<number[], Opts>> & {
996
+ dimensions?: number;
997
+ };
998
+ //#endregion
999
+ //#region src/validation/schemas/from-object.d.ts
1000
+ /**
1001
+ * Gets the value at a dot path in an object type.
1002
+ * Supports nested paths like "create.name" or "create.friends".
1003
+ */
1004
+ type PathValue<T, P$1 extends string> = P$1 extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? T[Key] extends Record<string, any> ? PathValue<T[Key], Rest> : never : never : P$1 extends keyof T ? T[P$1] : never;
1005
+ /**
1006
+ * Recursively extracts all dot paths that lead to VibSchema or ThunkCast instances.
1007
+ * Returns a union of all valid paths (e.g., "create" | "create.name").
1008
+ * Limited to 5 levels of nesting to avoid infinite recursion.
1009
+ */
1010
+ type PathsToSchemas<T extends string, Prefix extends string = "", Depth extends readonly unknown[] = []> = Depth["length"] extends 5 ? never : T extends VibSchema<any, any> ? Prefix : T extends ThunkCast<any, any> ? Prefix : T extends (() => Cast<any, any>) ? Prefix : T extends Record<string, any> ? { [K in keyof T]: K extends string ? PathsToSchemas<T[K], Prefix extends "" ? K : `${Prefix}.${K}`, [...Depth, unknown]> : never }[keyof T] : never;
1011
+ /**
1012
+ * Normalize a schema entry to VibSchema.
1013
+ * Handles both direct VibSchema and ThunkCast (unwrapping the thunk's return type).
1014
+ */
1015
+ type NormalizeSchemaEntry<T> = T extends VibSchema<infer I, infer O> ? VibSchema<I, O> : T extends ThunkCast<infer I, infer O> ? VibSchema<I, O> : T extends (() => Cast<infer I, infer O>) ? VibSchema<I, O> : never;
1016
+ /**
1017
+ * Gets the schema type at a specific path for a specific key.
1018
+ * Handles both VibSchema and ThunkCast entries.
1019
+ */
1020
+ type SchemaAtPath<TObject extends Record<string, any>, TPath extends string, K$1 extends keyof TObject> = NormalizeSchemaEntry<PathValue<TObject[K$1], TPath>>;
1021
+ /**
1022
+ * Extracts all valid paths that lead to schemas from all keys in the object.
1023
+ */
1024
+ type AllPathsToSchemas<TObject extends Record<string, any>> = { [K in keyof TObject]: K extends string ? PathsToSchemas<TObject[K]> : never }[keyof TObject];
1025
+ /**
1026
+ * Options for fromObject schemas (same as ObjectOptions).
1027
+ */
1028
+ type FromObjectOptions<T = unknown> = ObjectOptions<T>;
1029
+ /**
1030
+ * Compute the entries type from an object and path.
1031
+ */
1032
+ type ComputeEntries<TObject extends Record<string, any>, TPath extends string> = { [K in keyof TObject]: SchemaAtPath<TObject, TPath, K> };
1033
+ /**
1034
+ * FromObject schema type (alias for ObjectSchema with computed entries).
1035
+ */
1036
+ type FromObjectSchema<TEntries, TOpts extends FromObjectOptions | undefined = undefined, TInput = unknown, TOutput = unknown> = ObjectSchema<TEntries, TOpts>;
1037
+ /**
1038
+ * Creates an object schema by extracting schemas from a record using a dot path.
1039
+ * This is a convenient way to build an object schema from a record with proper type inference.
1040
+ *
1041
+ * @param sourceObject - Source object containing nested schemas
1042
+ * @param path - Dot path to extract schemas (e.g., "create", "filter.where")
1043
+ * @param options - Schema options (same as object schema)
1044
+ *
1045
+ * @example
1046
+ * // Given a record of models with nested schemas:
1047
+ * const models = {
1048
+ * user: { create: v.string(), update: v.string() },
1049
+ * post: { create: v.number(), update: v.number() },
1050
+ * };
1051
+ *
1052
+ * // Extract all "create" schemas into a single object schema:
1053
+ * const createSchema = fromObject(models, "create");
1054
+ * // Validates: { user: string, post: number }
1055
+ *
1056
+ * // With options:
1057
+ * const optionalSchema = fromObject(models, "create", { optional: true });
1058
+ * // Validates: { user: string, post: number } | undefined
1059
+ *
1060
+ * @example
1061
+ * // Nested paths work too:
1062
+ * const nestedModels = {
1063
+ * user: { schemas: { create: v.string() } },
1064
+ * post: { schemas: { create: v.number() } },
1065
+ * };
1066
+ * const nestedSchema = fromObject(nestedModels, "schemas.create");
1067
+ * // Validates: { user: string, post: number }
1068
+ */
1069
+ declare function fromObject<TObject extends Record<string, any>, TPath extends string, const TOpts extends FromObjectOptions | undefined = undefined>(sourceObject: TObject, path: TPath, options?: TOpts): ObjectSchema<ComputeEntries<TObject, TPath>, TOpts>;
1070
+ //#endregion
1071
+ //#region src/validation/schemas/pipe.d.ts
1072
+ /**
1073
+ * Transform action interface.
1074
+ */
1075
+ interface TransformAction<TIn, TOut> {
1076
+ readonly type: "transform";
1077
+ readonly transform: (value: TIn) => TOut;
1078
+ }
1079
+ /**
1080
+ * Create a transform action for use with pipe.
1081
+ *
1082
+ * @example
1083
+ * const upperCase = v.pipe(v.string(), v.transform(s => s.toUpperCase()));
1084
+ */
1085
+ declare function transform<TIn, TOut>(fn: (value: TIn) => TOut): TransformAction<TIn, TOut>;
1086
+ /**
1087
+ * Pipe action types.
1088
+ */
1089
+ type PipeAction<TIn, TOut> = TransformAction<TIn, TOut>;
1090
+ /**
1091
+ * Pipe schema interface.
1092
+ */
1093
+ interface PipeSchema<TSchema extends VibSchema<any, any>, TActions extends readonly PipeAction<any, any>[], TInput = InferInput<TSchema>, TOutput = (TActions extends readonly [...any[], PipeAction<any, infer TLast>] ? TLast : InferOutput<TSchema>)> extends VibSchema<TInput, TOutput> {
1094
+ readonly type: "pipe";
1095
+ readonly schema: TSchema;
1096
+ readonly actions: TActions;
1097
+ }
1098
+ /**
1099
+ * Infer the final output type from a chain of actions.
1100
+ */
1101
+ type InferPipeOutput<TSchema extends VibSchema<any, any>, TActions extends readonly PipeAction<any, any>[]> = TActions extends readonly [] ? InferOutput<TSchema> : TActions extends readonly [PipeAction<any, infer TOut>] ? TOut : TActions extends readonly [PipeAction<any, infer TMid>, ...infer TRest] ? TRest extends readonly PipeAction<any, any>[] ? InferPipeOutput<VibSchema<TMid, TMid>, TRest> : TMid : InferOutput<TSchema>;
1102
+ /**
1103
+ * Create a pipe schema that chains a base schema with transform actions.
1104
+ *
1105
+ * @example
1106
+ * const trimmedString = v.pipe(v.string(), v.transform(s => s.trim()));
1107
+ * const isoDate = v.pipe(v.date(), v.transform(d => d.toISOString()));
1108
+ */
1109
+ declare function pipe<TSchema extends VibSchema<any, any>, const TActions extends readonly PipeAction<any, any>[]>(schema: TSchema, ...actions: TActions): PipeSchema<TSchema, TActions, InferInput<TSchema>, InferPipeOutput<TSchema, TActions>>;
1110
+ //#endregion
1111
+ //#region src/validation/schemas/record.d.ts
1112
+ interface RecordSchema<TKey extends VibSchema<string, string>, TValue extends VibSchema<any, any>, TInput = Record<InferInput<TKey>, InferInput<TValue>>, TOutput = Record<InferOutput<TKey>, InferOutput<TValue>>> extends VibSchema<TInput, TOutput> {
1113
+ readonly type: "record";
1114
+ readonly key: TKey;
1115
+ readonly value: TValue;
1116
+ }
1117
+ /**
1118
+ * Create a record schema that validates keys and values.
1119
+ *
1120
+ * @example
1121
+ * const stringRecord = v.record(v.string(), v.number());
1122
+ * // Validates: { foo: 1, bar: 2 }
1123
+ */
1124
+ declare function record<TKey extends VibSchema<string, string>, TValue extends VibSchema<any, any>>(key: TKey, value: TValue): RecordSchema<TKey, TValue>;
1125
+ /**
1126
+ * Schema entry type - VibSchema or ThunkCast for circular references.
1127
+ */
1128
+ type SchemaEntry = VibSchema<any, any> | ThunkCast<any, any> | (() => Cast<any, any>);
1129
+ /**
1130
+ * Normalize a schema entry to VibSchema for type extraction.
1131
+ */
1132
+ type NormalizeEntry<T> = T extends VibSchema<infer I, infer O> ? VibSchema<I, O> : T extends ThunkCast<infer I, infer O> ? VibSchema<I, O> : T extends (() => Cast<infer I, infer O>) ? VibSchema<I, O> : never;
1133
+ /**
1134
+ * Compute entries from a tuple of keys and a schema.
1135
+ */
1136
+ type ComputeEntriesFromKeys<TKeys extends readonly string[], TSchema extends SchemaEntry> = { [K in TKeys[number]]: NormalizeEntry<TSchema> };
1137
+ /**
1138
+ * Options for fromKeys (same as ObjectOptions).
1139
+ */
1140
+ type FromKeysOptions<T = unknown> = ObjectOptions<T>;
1141
+ /**
1142
+ * Creates an object schema from an array of keys, all mapping to the same schema.
1143
+ * This is a convenient wrapper around `object()` for creating uniform schemas.
1144
+ *
1145
+ * @param keys - Array of key names (use `as const` for type inference)
1146
+ * @param schema - Schema to use for all keys (can be a thunk for circular refs)
1147
+ * @param options - Schema options (same as object schema)
1148
+ *
1149
+ * @example
1150
+ * // All keys have the same string schema
1151
+ * const schema = v.fromKeys(["name", "email", "bio"] as const, v.string());
1152
+ * // → ObjectSchema<{ name: string, email: string, bio: string }>
1153
+ *
1154
+ * @example
1155
+ * // With options
1156
+ * const optionalSchema = v.fromKeys(
1157
+ * ["user", "post"] as const,
1158
+ * v.number(),
1159
+ * { partial: false }
1160
+ * );
1161
+ * // → ObjectSchema<{ user: number, post: number }> (all required)
1162
+ *
1163
+ * @example
1164
+ * // With thunks for circular references
1165
+ * const nodeSchema: VibSchema<any, any> = v.object({ value: v.string() });
1166
+ * const schema = v.fromKeys(
1167
+ * ["left", "right"] as const,
1168
+ * () => nodeSchema,
1169
+ * { optional: true }
1170
+ * );
1171
+ */
1172
+ declare function fromKeys<const TKeys extends readonly string[], TSchema extends SchemaEntry, const TOpts extends FromKeysOptions | undefined = undefined>(keys: TKeys, schema: TSchema, options?: TOpts): ObjectSchema<ComputeEntriesFromKeys<TKeys, TSchema>, TOpts>;
1173
+ //#endregion
1174
+ //#region src/validation/schemas/transform.d.ts
1175
+ /**
1176
+ * Schema that wraps another schema and transforms its output.
1177
+ */
1178
+ interface TransformSchema<TInput, TOutput> extends VibSchema<TInput, TOutput> {
1179
+ readonly type: "transform";
1180
+ }
1181
+ /**
1182
+ * Wrap a schema with a transform function.
1183
+ * Validates with the wrapped schema, then applies the transform to the output.
1184
+ *
1185
+ * @param schema - The base schema to validate with
1186
+ * @param fn - Transform function: (validatedValue) => newValue
1187
+ *
1188
+ * @example
1189
+ * // String to uppercase
1190
+ * const upper = v.coerce(v.string(), s => s.toUpperCase());
1191
+ *
1192
+ * @example
1193
+ * // Parse string to number
1194
+ * const parseNum = v.coerce(v.string(), s => parseInt(s, 10));
1195
+ * type Out = InferOutput<typeof parseNum>; // number
1196
+ *
1197
+ * @example
1198
+ * // Date to ISO string
1199
+ * const isoDate = v.coerce(v.date(), d => d.toISOString());
1200
+ * type Out = InferOutput<typeof isoDate>; // string
1201
+ *
1202
+ * @example
1203
+ * // Extract property from object
1204
+ * const getName = v.coerce(
1205
+ * v.object({ name: v.string(), age: v.number() }),
1206
+ * obj => obj.name
1207
+ * );
1208
+ * type Out = InferOutput<typeof getName>; // string
1209
+ */
1210
+ declare function coerce<S extends VibSchema<any, any>, TOut>(schema: S, fn: (value: S[" vibInferred"]["1"]) => TOut): TransformSchema<InferInput<S>, TOut> & {
1211
+ wrapped: S;
1212
+ };
1213
+ /**
1214
+ * Alias for coerce - transform wrapper.
1215
+ */
1216
+ declare const map: typeof coerce;
1217
+ //#endregion
1218
+ //#region src/validation/V.d.ts
1219
+ /**
1220
+ * V Namespace - Type-level schema constructors for explicit type annotations.
1221
+ *
1222
+ * These mirror the runtime v.* functions but produce types directly without
1223
+ * needing to serialize the full schema structure in .d.ts files.
1224
+ *
1225
+ * @example
1226
+ * ```typescript
1227
+ * // In a .d.ts file:
1228
+ * import type { V } from "@validation";
1229
+ *
1230
+ * export type UserSchema = V.Object<{
1231
+ * id: V.String;
1232
+ * name: V.String<{ optional: true }>;
1233
+ * age: V.Number;
1234
+ * }>;
1235
+ * ```
1236
+ */
1237
+ declare namespace V {
1238
+ /**
1239
+ * Type-level string schema.
1240
+ * @example V.String - Required string
1241
+ * @example V.String<{ optional: true }> - Optional string
1242
+ * @example V.String<{ nullable: true }> - Nullable string
1243
+ * @example V.String<{ array: true }> - Array of strings
1244
+ */
1245
+ type String<Opts extends ScalarOptions<string, any> | undefined = undefined> = StringSchema<ComputeInput<string, Opts>, ComputeOutput<string, Opts>>;
1246
+ /**
1247
+ * Type-level number schema.
1248
+ * @example V.Number - Required number
1249
+ * @example V.Number<{ optional: true }> - Optional number
1250
+ */
1251
+ type Number<Opts extends ScalarOptions<number, any> | undefined = undefined> = NumberSchema<ComputeInput<number, Opts>, ComputeOutput<number, Opts>>;
1252
+ /**
1253
+ * Type-level integer schema.
1254
+ */
1255
+ type Integer<Opts extends ScalarOptions<number, any> | undefined = undefined> = IntegerSchema<ComputeInput<number, Opts>, ComputeOutput<number, Opts>>;
1256
+ /**
1257
+ * Type-level boolean schema.
1258
+ */
1259
+ type Boolean<Opts extends ScalarOptions<boolean, any> | undefined = undefined> = BooleanSchema<ComputeInput<boolean, Opts>, ComputeOutput<boolean, Opts>>;
1260
+ /**
1261
+ * Type-level bigint schema.
1262
+ */
1263
+ type BigInt<Opts extends ScalarOptions<bigint, any> | undefined = undefined> = BigIntSchema<ComputeInput<bigint, Opts>, ComputeOutput<bigint, Opts>>;
1264
+ /**
1265
+ * Type-level Date schema (JavaScript Date object).
1266
+ */
1267
+ type Date<Opts extends ScalarOptions<globalThis.Date, any> | undefined = undefined> = DateSchema<ComputeInput<globalThis.Date, Opts>, ComputeOutput<globalThis.Date, Opts>>;
1268
+ /**
1269
+ * Type-level ISO timestamp schema (accepts string | Date, outputs string).
1270
+ */
1271
+ type IsoTimestamp<Opts extends ScalarOptions<string, any> | undefined = undefined> = IsoTimestampSchema<ComputeInput<string | globalThis.Date, Opts>, ComputeOutput<string, Opts>>;
1272
+ /**
1273
+ * Type-level ISO date schema (accepts string | Date, outputs string YYYY-MM-DD).
1274
+ */
1275
+ type IsoDate<Opts extends ScalarOptions<string, any> | undefined = undefined> = IsoDateSchema<ComputeInput<string | globalThis.Date, Opts>, ComputeOutput<string, Opts>>;
1276
+ /**
1277
+ * Type-level ISO time schema (accepts string | Date, outputs string HH:MM:SS).
1278
+ */
1279
+ type IsoTime<Opts extends ScalarOptions<string, any> | undefined = undefined> = IsoTimeSchema<ComputeInput<string | globalThis.Date, Opts>, ComputeOutput<string, Opts>>;
1280
+ /**
1281
+ * Type-level JSON schema.
1282
+ */
1283
+ type Json<Opts extends ScalarOptions<JsonValue, any> | undefined = undefined> = JsonSchema<ComputeInput<JsonValue, Opts>, ComputeOutput<JsonValue, Opts>>;
1284
+ /**
1285
+ * Type-level blob schema (Uint8Array or Buffer-like).
1286
+ */
1287
+ type Blob<Opts extends ScalarOptions<Uint8Array, any> | undefined = undefined> = BlobSchema<ComputeInput<Uint8Array, Opts>, ComputeOutput<Uint8Array, Opts>>;
1288
+ /**
1289
+ * Type-level vector schema (number array for embeddings).
1290
+ */
1291
+ type Vector<Opts extends ScalarOptions<number[], any> | undefined = undefined> = VectorSchema<ComputeInput<number[], Opts>, ComputeOutput<number[], Opts>>;
1292
+ /**
1293
+ * Type-level point schema (geographic coordinates).
1294
+ */
1295
+ type Point<Opts extends ScalarOptions<{
1296
+ x: number;
1297
+ y: number;
1298
+ }, any> | undefined = undefined> = PointSchema<ComputeInput<{
1299
+ x: number;
1300
+ y: number;
1301
+ }, Opts>, ComputeOutput<{
1302
+ x: number;
1303
+ y: number;
1304
+ }, Opts>>;
1305
+ /**
1306
+ * Type-level object schema.
1307
+ * @example V.Object<{ name: V.String; age: V.Number }>
1308
+ * @example V.Object<{ name: V.String }, { partial: false }> - All required
1309
+ */
1310
+ type Object<TEntries, TOpts extends ObjectOptions | undefined = undefined> = ObjectSchema<TEntries, TOpts>;
1311
+ /**
1312
+ * Type-level from object schema.
1313
+ * @example V.FromObject<{ name: V.String }, "name"> - Object with name field
1314
+ */
1315
+ type FromObject<TObject extends Record<string, any>, TPath extends string, TOpts extends ObjectOptions | undefined = undefined> = ObjectSchema<ComputeEntries<TObject, TPath>, TOpts>;
1316
+ type FromKeys<TKeys extends string[], TSchema extends VibSchema<any, any>, TOpts extends ObjectOptions | undefined = undefined> = ObjectSchema<ComputeEntriesFromKeys<TKeys, TSchema>, TOpts>;
1317
+ /**
1318
+ * Type-level array schema.
1319
+ * @example V.Array<V.String> - Array of strings
1320
+ */
1321
+ type Array<TItem extends VibSchema<any, any>> = ArraySchema<TItem>;
1322
+ /**
1323
+ * Type-level union schema.
1324
+ * @example V.Union<[V.String, V.Number]>
1325
+ */
1326
+ type Union<TOptions extends readonly VibSchema<any, any>[]> = UnionSchema<TOptions>;
1327
+ /**
1328
+ * Type-level enum schema.
1329
+ * @example V.Enum<["active", "inactive", "pending"]>
1330
+ */
1331
+ type Enum<TValues extends string[], Opts extends ScalarOptions<TValues[number], any> | undefined = undefined> = EnumSchema<TValues, ComputeInput<TValues[number], Opts>, ComputeOutput<TValues[number], Opts>>;
1332
+ /**
1333
+ * Type-level literal schema.
1334
+ * @example V.Literal<"active">
1335
+ */
1336
+ type Literal<TValue extends LiteralValue> = LiteralSchema<TValue>;
1337
+ /**
1338
+ * Type-level record schema (dictionary with uniform value type).
1339
+ * @example V.Record<V.String, V.Number>
1340
+ */
1341
+ type VRecord<TKey extends VibSchema<any, string>, TValue extends VibSchema<any, any>> = RecordSchema<TKey, TValue>;
1342
+ /**
1343
+ * Type-level optional schema.
1344
+ * @example V.Optional<V.String> - string | undefined
1345
+ */
1346
+ type Optional<TWrapped extends WrappableSchema, TDefault = undefined> = OptionalSchema<TWrapped, TDefault>;
1347
+ /**
1348
+ * Type-level nullable schema.
1349
+ * @example V.Nullable<V.String> - string | null
1350
+ */
1351
+ type Nullable<TWrapped extends VibSchema<any, any>> = NullableSchema<TWrapped>;
1352
+ type MaybeNullable<TWrapped extends VibSchema<any, any>, TIsNullable extends boolean> = TIsNullable extends true ? NullableSchema<TWrapped> : TWrapped;
1353
+ /**
1354
+ * Type-level transform schema.
1355
+ * @example V.Transform<string, number> - transforms string input to number output
1356
+ */
1357
+ type Transform<TInput, TOutput> = TransformSchema<TInput, TOutput>;
1358
+ /**
1359
+ * Type-level pipe schema for chaining validations.
1360
+ * @example V.Pipe<V.String, [TrimAction, LowercaseAction]>
1361
+ */
1362
+ type Pipe<TSchema extends VibSchema<any, any>, TActions extends readonly PipeAction<any, any>[]> = PipeSchema<TSchema, TActions>;
1363
+ type Coerce<TWrapped extends VibSchema<any, any>, TOutput> = TransformSchema<InferInput<TWrapped>, TOutput> & {
1364
+ wrapped: TWrapped;
1365
+ };
1366
+ type ShorthandFilter<TWrapped extends VibSchema<any, any>> = Coerce<TWrapped, {
1367
+ equals: TWrapped[" vibInferred"]["1"];
1368
+ }>;
1369
+ type ShorthandUpdate<TWrapped extends VibSchema<any, any>> = Coerce<TWrapped, {
1370
+ set: TWrapped[" vibInferred"]["1"];
1371
+ }>;
1372
+ type ShorthandArray<TWrapped extends VibSchema<any, any>> = Coerce<TWrapped, [TWrapped[" vibInferred"]["1"]]>;
1373
+ type SingleOrArray<TWrapped extends VibSchema<any, any>> = V.Union<readonly [V.Coerce<TWrapped, [TWrapped[" vibInferred"]["1"]]>, V.Array<TWrapped>]>;
1374
+ /**
1375
+ * Extract input type from a V.* type or VibSchema.
1376
+ */
1377
+ type Input<T> = InferInput<T>;
1378
+ /**
1379
+ * Extract output type from a V.* type or VibSchema.
1380
+ */
1381
+ type Output<T> = InferOutput<T>;
1382
+ /**
1383
+ * Any VibSchema - useful for generic constraints.
1384
+ */
1385
+ type Schema<TInput = unknown, TOutput = TInput> = VibSchema<TInput, TOutput>;
1386
+ }
1387
+ //#endregion
1388
+ //#region src/validation/index.d.ts
1389
+ /**
1390
+ * VibORM validation namespace.
1391
+ *
1392
+ * @example
1393
+ * import { v } from "viborm/validation";
1394
+ *
1395
+ * const user = v.object({
1396
+ * name: v.string(),
1397
+ * age: v.number({ optional: true }),
1398
+ * email: v.string(),
1399
+ * createdAt: v.date(),
1400
+ * });
1401
+ *
1402
+ * // Circular references use thunks
1403
+ * const node = v.object({
1404
+ * value: v.string(),
1405
+ * parent: () => node, // Thunk for self-reference
1406
+ * });
1407
+ */
1408
+ declare const v: {
1409
+ readonly string: typeof string;
1410
+ readonly number: typeof number;
1411
+ readonly integer: typeof integer;
1412
+ readonly boolean: typeof boolean;
1413
+ readonly bigint: typeof bigint;
1414
+ readonly literal: typeof literal;
1415
+ readonly enum: typeof enum_;
1416
+ readonly json: typeof json;
1417
+ readonly date: typeof date;
1418
+ readonly isoTimestamp: typeof isoTimestamp;
1419
+ readonly isoDate: typeof isoDate;
1420
+ readonly isoTime: typeof isoTime;
1421
+ readonly instance: typeof instance;
1422
+ readonly blob: typeof blob;
1423
+ readonly vector: typeof vector;
1424
+ readonly point: typeof point;
1425
+ readonly array: typeof array;
1426
+ readonly nullable: typeof nullable;
1427
+ readonly maybeNullable: typeof maybeNullable;
1428
+ readonly optional: typeof optional;
1429
+ readonly nonNullable: typeof nonNullable;
1430
+ readonly nonOptional: typeof nonOptional;
1431
+ readonly required: typeof nonOptional;
1432
+ readonly nonArray: typeof nonArray;
1433
+ readonly element: typeof nonArray;
1434
+ readonly object: typeof object;
1435
+ readonly fromObject: typeof fromObject;
1436
+ readonly union: typeof union;
1437
+ readonly pipe: typeof pipe;
1438
+ readonly transformAction: typeof transform;
1439
+ readonly record: typeof record;
1440
+ readonly fromKeys: typeof fromKeys;
1441
+ readonly coerce: typeof coerce;
1442
+ readonly map: typeof coerce;
1443
+ };
1444
+ declare const parse: <const S extends VibSchema>(schema: S, value: unknown) => Awaited<ReturnType<(typeof schema)["~standard"]["validate"]>>;
1445
+ //#endregion
1446
+ export { nonOptional as $, buildValidator as $t, BasePointSchema as A, EnumSchema as At, object as B, validateBoolean as Bt, vector as C, JsonSchemaOptions as Cn, isoTimestamp as Ct, StringSchema as D, InstanceSchema as Dt, BaseStringSchema as E, validateIsoTimestamp as Et, OptionalSchema as F, date as Ft, integer as G, BaseBigIntSchema as Gt, BaseNumberSchema as H, BlobSchema as Ht, optional as I, validateDate as It, validateNumber as J, validateBigInt as Jt, number as K, BigIntSchema as Kt, ObjectEntries as L, BaseBooleanSchema as Lt, PointSchema as M, enum_ as Mt, point as N, BaseDateSchema as Nt, string as O, instance as Ot, validatePoint as P, DateSchema as Pt, NonOptionalSchema as Q, toJsonSchema as Qt, ObjectOptions as R, BooleanSchema as Rt, createVectorValidator as S, JsonSchemaConverter as Sn, isoTime as St, union as T, inferred as Tn, validateIsoTime as Tt, IntegerSchema as U, blob as Ut, type BaseIntegerSchema as V, BaseBlobSchema as Vt, NumberSchema as W, validateBlob as Wt, maybeNullable as X, array as Xt, NullableSchema as Y, ArraySchema as Yt, nullable as Z, createJsonSchemaConverter as Zt, FromObjectOptions as _, ValidationResult as _n, BaseIsoTimestampSchema as _t, coerce as a, Cast as an, nonArray as at, BaseVectorSchema as b, isVibSchema as bn, IsoTimestampSchema as bt, RecordSchema as c, InferInput as cn, literal as ct, PipeAction as d, InferOutputShape as dn, JsonValue as dt, createSchema as en, required as et, PipeSchema as f, Prettify as fn, isJsonValue as ft, AllPathsToSchemas as g, ValidationIssue as gn, BaseIsoTimeSchema as gt, transform as h, ValidationFailure as hn, BaseIsoDateSchema as ht, TransformSchema as i, validateSchema as in, element as it, Point as j, EnumValues as jt, validateString as k, BaseEnumSchema as kt, fromKeys as l, InferInputShape as ln, BaseJsonSchema as lt, pipe as m, ThunkCast as mn, validateJson as mt, v as n, getDefault as nn, nonNullable as nt, map as o, ComputeInput as on, LiteralSchema as ot, TransformAction as p, ScalarOptions as pn, json as pt, validateInteger as q, bigint as qt, V as r, ok as rn, NonArraySchema as rt, FromKeysOptions as s, ComputeOutput as sn, LiteralValue as st, parse as t, fail as tn, NonNullableSchema as tt, record as u, InferOutput as un, JsonSchema as ut, FromObjectSchema as v, ValidationSuccess as vn, IsoDateSchema as vt, UnionSchema as w, JsonSchemaTarget as wn, validateIsoDate as wt, VectorSchema as x, JsonSchema$1 as xn, isoDate as xt, fromObject as y, VibSchema as yn, IsoTimeSchema as yt, ObjectSchema as z, boolean as zt };
1447
+ //# sourceMappingURL=index-3sdVKfeG.d.mts.map