@cleverbrush/schema 1.1.11 → 3.0.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 (98) hide show
  1. package/README.md +1721 -104
  2. package/dist/builders/AnySchemaBuilder.d.ts +54 -14
  3. package/dist/builders/AnySchemaBuilder.js +2 -112
  4. package/dist/builders/AnySchemaBuilder.js.map +1 -0
  5. package/dist/builders/ArraySchemaBuilder.d.ts +126 -23
  6. package/dist/builders/ArraySchemaBuilder.js +2 -284
  7. package/dist/builders/ArraySchemaBuilder.js.map +1 -0
  8. package/dist/builders/BooleanSchemaBuilder.d.ts +109 -19
  9. package/dist/builders/BooleanSchemaBuilder.js +2 -150
  10. package/dist/builders/BooleanSchemaBuilder.js.map +1 -0
  11. package/dist/builders/DateSchemaBuilder.d.ts +154 -34
  12. package/dist/builders/DateSchemaBuilder.js +2 -433
  13. package/dist/builders/DateSchemaBuilder.js.map +1 -0
  14. package/dist/builders/ExternSchemaBuilder.d.ts +202 -0
  15. package/dist/builders/ExternSchemaBuilder.js +2 -0
  16. package/dist/builders/ExternSchemaBuilder.js.map +1 -0
  17. package/dist/builders/FunctionSchemaBuilder.d.ts +205 -18
  18. package/dist/builders/FunctionSchemaBuilder.js +2 -113
  19. package/dist/builders/FunctionSchemaBuilder.js.map +1 -0
  20. package/dist/builders/GenericSchemaBuilder.d.ts +294 -0
  21. package/dist/builders/LazySchemaBuilder.d.ts +169 -0
  22. package/dist/builders/NullSchemaBuilder.d.ts +162 -0
  23. package/dist/builders/NumberSchemaBuilder.d.ts +159 -31
  24. package/dist/builders/NumberSchemaBuilder.js +2 -386
  25. package/dist/builders/NumberSchemaBuilder.js.map +1 -0
  26. package/dist/builders/ObjectSchemaBuilder.d.ts +486 -61
  27. package/dist/builders/ObjectSchemaBuilder.js +2 -589
  28. package/dist/builders/ObjectSchemaBuilder.js.map +1 -0
  29. package/dist/builders/ParseStringSchemaBuilder.d.ts +204 -0
  30. package/dist/builders/ParseStringSchemaBuilder.js +2 -0
  31. package/dist/builders/ParseStringSchemaBuilder.js.map +1 -0
  32. package/dist/builders/PromiseSchemaBuilder.d.ts +213 -0
  33. package/dist/builders/PromiseSchemaBuilder.js +2 -0
  34. package/dist/builders/PromiseSchemaBuilder.js.map +1 -0
  35. package/dist/builders/PropertyValidationResult.d.ts +68 -0
  36. package/dist/builders/RecordSchemaBuilder.d.ts +343 -0
  37. package/dist/builders/RecordSchemaBuilder.js +2 -0
  38. package/dist/builders/RecordSchemaBuilder.js.map +1 -0
  39. package/dist/builders/SchemaBuilder.d.ts +907 -30
  40. package/dist/builders/StringSchemaBuilder.d.ts +154 -37
  41. package/dist/builders/StringSchemaBuilder.js +2 -414
  42. package/dist/builders/StringSchemaBuilder.js.map +1 -0
  43. package/dist/builders/TupleSchemaBuilder.d.ts +250 -0
  44. package/dist/builders/TupleSchemaBuilder.js +2 -0
  45. package/dist/builders/TupleSchemaBuilder.js.map +1 -0
  46. package/dist/builders/UnionSchemaBuilder.d.ts +141 -39
  47. package/dist/builders/UnionSchemaBuilder.js +2 -216
  48. package/dist/builders/UnionSchemaBuilder.js.map +1 -0
  49. package/dist/chunk-3JMDGYDT.js +2 -0
  50. package/dist/chunk-3JMDGYDT.js.map +1 -0
  51. package/dist/chunk-BUEVZ3KA.js +2 -0
  52. package/dist/chunk-BUEVZ3KA.js.map +1 -0
  53. package/dist/chunk-CFIJQ4GP.js +2 -0
  54. package/dist/chunk-CFIJQ4GP.js.map +1 -0
  55. package/dist/chunk-DY7J6RNN.js +2 -0
  56. package/dist/chunk-DY7J6RNN.js.map +1 -0
  57. package/dist/chunk-EIVZX4ZO.js +2 -0
  58. package/dist/chunk-EIVZX4ZO.js.map +1 -0
  59. package/dist/chunk-GXPV6UQK.js +2 -0
  60. package/dist/chunk-GXPV6UQK.js.map +1 -0
  61. package/dist/chunk-HN774HD7.js +2 -0
  62. package/dist/chunk-HN774HD7.js.map +1 -0
  63. package/dist/chunk-K6Z47OQY.js +2 -0
  64. package/dist/chunk-K6Z47OQY.js.map +1 -0
  65. package/dist/chunk-NUW3VXZV.js +2 -0
  66. package/dist/chunk-NUW3VXZV.js.map +1 -0
  67. package/dist/chunk-PHE4LIAN.js +2 -0
  68. package/dist/chunk-PHE4LIAN.js.map +1 -0
  69. package/dist/chunk-QARCEYGO.js +2 -0
  70. package/dist/chunk-QARCEYGO.js.map +1 -0
  71. package/dist/chunk-WDMJBGBD.js +2 -0
  72. package/dist/chunk-WDMJBGBD.js.map +1 -0
  73. package/dist/chunk-WQDYWDOE.js +2 -0
  74. package/dist/chunk-WQDYWDOE.js.map +1 -0
  75. package/dist/chunk-YQZHDMRF.js +2 -0
  76. package/dist/chunk-YQZHDMRF.js.map +1 -0
  77. package/dist/chunk-ZC6YBKCP.js +2 -0
  78. package/dist/chunk-ZC6YBKCP.js.map +1 -0
  79. package/dist/chunk-ZFI27R3L.js +2 -0
  80. package/dist/chunk-ZFI27R3L.js.map +1 -0
  81. package/dist/core.d.ts +28 -0
  82. package/dist/core.js +2 -0
  83. package/dist/core.js.map +1 -0
  84. package/dist/extension.d.ts +421 -0
  85. package/dist/extensions/array.d.ts +112 -0
  86. package/dist/extensions/enum.d.ts +190 -0
  87. package/dist/extensions/index.d.ts +112 -0
  88. package/dist/extensions/nullable.d.ts +26 -0
  89. package/dist/extensions/number.d.ts +228 -0
  90. package/dist/extensions/string.d.ts +332 -0
  91. package/dist/extensions/util.d.ts +45 -0
  92. package/dist/index.d.ts +10 -20
  93. package/dist/index.js +2 -19
  94. package/dist/index.js.map +1 -0
  95. package/dist/utils/transaction.d.ts +27 -4
  96. package/package.json +83 -7
  97. package/dist/builders/SchemaBuilder.js +0 -275
  98. package/dist/utils/transaction.js +0 -178
@@ -1,433 +1,2 @@
1
- import { transaction } from '../utils/transaction.js';
2
- import { SchemaBuilder } from './SchemaBuilder.js';
3
- const parseFromJsonPreprocessor = (value) => {
4
- if (typeof value === 'undefined')
5
- return value;
6
- if (typeof value === 'string') {
7
- const time = Date.parse(value);
8
- if (Number.isNaN(time))
9
- return value;
10
- return new Date(time);
11
- }
12
- return value;
13
- };
14
- const parseFromEpochPreprocessor = (value) => {
15
- if (typeof value === 'undefined')
16
- return value;
17
- if (typeof value === 'number') {
18
- const time = new Date(value);
19
- if (Number.isNaN(time.getTime()))
20
- return value;
21
- return time;
22
- }
23
- return value;
24
- };
25
- /**
26
- * Allows to create Date schema. It can be required or optional.
27
- * It can be restricted to be: equal to a certain value, in future, in past, in a certain range.
28
- * Supports parsing from JSON string and UNIX epoch (using preprocessors).
29
- *
30
- * **NOTE** this class is exported only to give opportunity to extend it
31
- * by inheriting. It is not recommended to create an instance of this class
32
- * directly. Use {@link date | date()} function instead.
33
- *
34
- * @example ```ts
35
- * const date = new Date(2020, 0, 2);
36
- * const schema = date().min(new Date(2020, 0, 1));
37
- * const result = await schema.validate(date);
38
- * // result.valid === true
39
- * // result.object === date
40
- * ```
41
- *
42
- * @example ```ts
43
- * const schema = date();
44
- * const result = await schema.validate('2020-01-01');
45
- * // result.valid === false
46
- * // result.errors[0].message === 'is expected to be a date'
47
- * ```
48
- *
49
- * @example ```ts
50
- * const schema = date().parseFromJson();
51
- * const result = await schema.validate('2020-01-01T00:00:00.000Z');
52
- * // result.valid === true
53
- * // result.object is equal to corresponding Date object
54
- * ```
55
- *
56
- * @example ```ts
57
- * const schema = date().parseFromEpoch();
58
- * const result = await schema.validate(1577836800000);
59
- * // result.valid === true
60
- * // result.object is equal to corresponding Date object
61
- * ```
62
- *
63
- * @see {@link date}
64
- */
65
- export class DateSchemaBuilder extends SchemaBuilder {
66
- #min;
67
- #max;
68
- #equalsTo;
69
- #ensureIsInFuture = false;
70
- #ensureIsInPast = false;
71
- #parseFromJson = false;
72
- #parseFromEpoch = false;
73
- static create(props) {
74
- return new DateSchemaBuilder({
75
- type: 'date',
76
- ...props
77
- });
78
- }
79
- constructor(props) {
80
- super(props);
81
- if (props.min instanceof Date) {
82
- this.#min = props.min;
83
- }
84
- if (props.max instanceof Date) {
85
- this.#max = props.max;
86
- }
87
- if (typeof props.ensureIsInFuture === 'boolean') {
88
- this.#ensureIsInFuture = props.ensureIsInFuture;
89
- }
90
- if (typeof props.ensureIsInPast === 'boolean') {
91
- this.#ensureIsInPast = props.ensureIsInPast;
92
- }
93
- if (typeof props.parseFromJson === 'boolean') {
94
- this.#parseFromJson = props.parseFromJson;
95
- }
96
- if (typeof props.parseFromEpoch === 'boolean') {
97
- this.#parseFromEpoch = props.parseFromEpoch;
98
- }
99
- if (props.equalsTo instanceof Date ||
100
- typeof props.equalsTo === 'undefined') {
101
- this.#equalsTo = props.equalsTo;
102
- }
103
- }
104
- introspect() {
105
- return {
106
- ...super.introspect(),
107
- /**
108
- * Min valid value (if defined).
109
- */
110
- min: this.#min,
111
- /**
112
- * Max valid value (if defined).
113
- */
114
- max: this.#max,
115
- /**
116
- * Make sure that date is in future. `false` by default.
117
- */
118
- ensureIsInFuture: this.#ensureIsInFuture,
119
- /**
120
- * Make sure that date is in past. `false` by default.
121
- */
122
- ensureIsInPast: this.#ensureIsInPast,
123
- /**
124
- * If set, restrict date to be equal to a certain value.
125
- */
126
- equalsTo: this.#equalsTo,
127
- /**
128
- * If set, schema will try to parse date from the UNIX epoch (number).
129
- * `false` by default.
130
- */
131
- parseFromEpoch: this.#parseFromEpoch,
132
- /**
133
- * If set, schema will try to parse date from JSON string.
134
- * `false` by default.
135
- */
136
- parseFromJson: this.#parseFromJson,
137
- /**
138
- * Array of preprocessor functions
139
- */
140
- preprocessors: this.preprocessors,
141
- /**
142
- * Array of validator functions
143
- */
144
- validators: this.validators
145
- };
146
- }
147
- /**
148
- * @hidden
149
- */
150
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
151
- hasType(notUsed) {
152
- return this.createFromProps({
153
- ...this.introspect()
154
- });
155
- }
156
- /**
157
- * @hidden
158
- */
159
- clearHasType() {
160
- return this.createFromProps({
161
- ...this.introspect()
162
- });
163
- }
164
- /**
165
- * Performs validion of Date schema over `object`.
166
- * @param context Optional `ValidationContext` settings.
167
- */
168
- async validate(object, context) {
169
- const superResult = await super.preValidate(object, context);
170
- const { valid, context: prevalidationContext, errors } = superResult;
171
- const { path } = prevalidationContext;
172
- if (!valid) {
173
- return {
174
- valid,
175
- errors
176
- };
177
- }
178
- let { transaction: preValidationTransaction } = superResult;
179
- let { object: { validatedObject: objToValidate } } = preValidationTransaction;
180
- if ((typeof objToValidate === 'undefined' || objToValidate === null) &&
181
- this.isRequired === false) {
182
- return {
183
- valid: true,
184
- object: objToValidate
185
- };
186
- }
187
- if (this.#parseFromJson) {
188
- preValidationTransaction = transaction({
189
- validatedObject: parseFromJsonPreprocessor(objToValidate)
190
- });
191
- objToValidate = preValidationTransaction.object.validatedObject;
192
- }
193
- if (this.#parseFromEpoch) {
194
- preValidationTransaction = transaction({
195
- validatedObject: parseFromEpochPreprocessor(objToValidate)
196
- });
197
- objToValidate = preValidationTransaction.object.validatedObject;
198
- }
199
- if (!(objToValidate instanceof Date))
200
- return {
201
- valid: false,
202
- errors: [
203
- {
204
- message: `expected instance of Date, but saw ${typeof objToValidate}`,
205
- path: path
206
- }
207
- ]
208
- };
209
- if (typeof this.#equalsTo !== 'undefined' &&
210
- objToValidate.getTime() !== this.#equalsTo.getTime()) {
211
- return {
212
- valid: false,
213
- errors: [
214
- {
215
- message: `is expected to be equal to ${this.#equalsTo}`,
216
- path: path
217
- }
218
- ]
219
- };
220
- }
221
- if (this.#ensureIsInFuture && objToValidate <= new Date()) {
222
- return {
223
- valid: false,
224
- errors: [
225
- {
226
- message: 'is expected to be in future',
227
- path: path
228
- }
229
- ]
230
- };
231
- }
232
- if (this.#ensureIsInPast && objToValidate >= new Date()) {
233
- return {
234
- valid: false,
235
- errors: [
236
- {
237
- message: 'is expected to be in past',
238
- path: path
239
- }
240
- ]
241
- };
242
- }
243
- if (typeof this.#min !== 'undefined') {
244
- if (objToValidate < this.#min)
245
- return {
246
- valid: false,
247
- errors: [
248
- {
249
- message: `expected to be at least ${this.#min}`,
250
- path: path
251
- }
252
- ]
253
- };
254
- }
255
- if (typeof this.#max !== 'undefined') {
256
- if (objToValidate > this.#max)
257
- return {
258
- valid: false,
259
- errors: [
260
- {
261
- message: `expected to be no more than or equal to ${this.#max}`,
262
- path: path
263
- }
264
- ]
265
- };
266
- }
267
- return {
268
- valid: true,
269
- object: preValidationTransaction.commit()
270
- .validatedObject
271
- };
272
- }
273
- /**
274
- * @hidden
275
- */
276
- createFromProps(props) {
277
- return DateSchemaBuilder.create(props);
278
- }
279
- /**
280
- * Restricts Date to be equal to `value`.
281
- */
282
- equals(value) {
283
- if (!(value instanceof Date))
284
- throw new Error('Date expected');
285
- return this.createFromProps({
286
- ...this.introspect(),
287
- equalsTo: value
288
- });
289
- }
290
- /**
291
- * Clears `equals()` call.
292
- */
293
- clearEquals() {
294
- return this.createFromProps({
295
- ...this.introspect(),
296
- equalsTo: undefined
297
- });
298
- }
299
- /**
300
- * @hidden
301
- */
302
- required() {
303
- return super.required();
304
- }
305
- /**
306
- * @hidden
307
- */
308
- optional() {
309
- return super.optional();
310
- }
311
- /**
312
- * Accept only dates in the future.
313
- */
314
- isInFuture() {
315
- return this.createFromProps({
316
- ...this.introspect(),
317
- ensureIsInFuture: true
318
- });
319
- }
320
- /**
321
- * Cancel `isInFuture()` call.
322
- */
323
- clearIsInFuture() {
324
- return this.createFromProps({
325
- ...this.introspect(),
326
- ensureIsInFuture: false
327
- });
328
- }
329
- /**
330
- * Accept only dates in the past.
331
- */
332
- isInPast() {
333
- return this.createFromProps({
334
- ...this.introspect(),
335
- ensureIsInPast: true
336
- });
337
- }
338
- /**
339
- * Cancel `isInPast()` call.
340
- */
341
- clearIsInPast() {
342
- return this.createFromProps({
343
- ...this.introspect(),
344
- ensureIsInPast: false
345
- });
346
- }
347
- /**
348
- * Set minimal valid Date value for schema.
349
- */
350
- min(minValue) {
351
- if (!(minValue instanceof Date))
352
- throw new Error('minValue must be a Date');
353
- return this.createFromProps({
354
- ...this.introspect(),
355
- min: minValue
356
- });
357
- }
358
- /**
359
- * Clear `min()` call.
360
- */
361
- clearMin() {
362
- const schema = this.introspect();
363
- delete schema.min;
364
- return this.createFromProps({
365
- ...schema
366
- });
367
- }
368
- /**
369
- * Set maximal valid Date value for schema.
370
- */
371
- max(maxValue) {
372
- if (!(maxValue instanceof Date))
373
- throw new Error('maxValue must be a Date');
374
- return this.createFromProps({
375
- ...this.introspect(),
376
- max: maxValue
377
- });
378
- }
379
- /**
380
- * Clear `max()` call.
381
- */
382
- clearMax() {
383
- const schema = this.introspect();
384
- delete schema.max;
385
- return this.createFromProps({
386
- ...schema
387
- });
388
- }
389
- /**
390
- * Accepts JSON string as a valid Date.
391
- * String must be in ISO format and will be parsed using `JSON.parse()`.
392
- */
393
- acceptJsonString() {
394
- return this.createFromProps({
395
- ...this.introspect(),
396
- parseFromJson: true
397
- });
398
- }
399
- /**
400
- * Cancel `acceptJsonString()` call.
401
- */
402
- doNotAcceptJsonString() {
403
- return this.createFromProps({
404
- ...this.introspect(),
405
- parseFromJson: false
406
- });
407
- }
408
- /**
409
- * Accepts epoch number as a valid Date.
410
- * Epoch number will be parsed using `new Date(epoch)`.
411
- */
412
- acceptEpoch() {
413
- return this.createFromProps({
414
- ...this.introspect(),
415
- parseFromEpoch: true
416
- });
417
- }
418
- /**
419
- * Cancel `acceptEpoch()` call.
420
- */
421
- doNotAcceptEpoch() {
422
- return this.createFromProps({
423
- ...this.introspect(),
424
- parseFromEpoch: false
425
- });
426
- }
427
- }
428
- /**
429
- * Creates a Date schema.
430
- */
431
- export const date = () => DateSchemaBuilder.create({
432
- isRequired: true
433
- });
1
+ import{a,b}from"../chunk-EIVZX4ZO.js";import"../chunk-3JMDGYDT.js";export{a as DateSchemaBuilder,b as date};
2
+ //# sourceMappingURL=DateSchemaBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,202 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import { type BRAND, SchemaBuilder, SYMBOL_HAS_PROPERTIES, type ValidationContext, type ValidationErrorMessageProvider, type ValidationResult } from './SchemaBuilder.js';
3
+ type ExternSchemaBuilderCreateProps<R extends boolean = true> = Partial<ReturnType<ExternSchemaBuilder<any, R>['introspect']>> & {
4
+ standardSchema: StandardSchemaV1;
5
+ };
6
+ /**
7
+ * Schema builder that wraps an external
8
+ * [Standard Schema v1](https://standardschema.dev/) compatible schema
9
+ * (e.g. Zod, Valibot, ArkType) into a `@cleverbrush/schema` builder.
10
+ *
11
+ * This enables cross-library schema composition — you can use a Zod schema
12
+ * as a property inside a `@cleverbrush/schema` object schema, and the
13
+ * inferred TypeScript type will be correct.
14
+ *
15
+ * Validation is delegated entirely to the external schema's
16
+ * `['~standard'].validate()` method. Standard Schema issues are mapped to
17
+ * `@cleverbrush/schema` `ValidationError` objects, with any issue paths
18
+ * formatted as dotted prefixes (e.g. `"address.city: must be a string"`).
19
+ *
20
+ * When used inside an `object()` schema, the property descriptor tree is
21
+ * built dynamically (via Proxy) from the external schema's output type,
22
+ * so `getErrorsFor(t => t.order.id)` works without any additional
23
+ * configuration.
24
+ *
25
+ * **NOTE** this class is exported only to give opportunity to extend it
26
+ * by inheriting. It is not recommended to create an instance of this class
27
+ * directly. Use the {@link extern | extern()} factory function instead.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { z } from 'zod';
32
+ * import { object, date, extern, InferType } from '@cleverbrush/schema';
33
+ *
34
+ * const zodUser = z.object({ first: z.string(), last: z.string() });
35
+ *
36
+ * const order = object({
37
+ * user: extern(zodUser),
38
+ * date: date(),
39
+ * });
40
+ *
41
+ * type Order = InferType<typeof order>;
42
+ * // { user: { first: string; last: string }; date: Date }
43
+ * ```
44
+ *
45
+ * @see {@link extern}
46
+ */
47
+ export declare class ExternSchemaBuilder<TStandardSchema extends StandardSchemaV1 = StandardSchemaV1, TRequired extends boolean = true, TNullable extends boolean = false, TExplicitType = undefined, THasDefault extends boolean = false, TExtensions = {}, TResult = TExplicitType extends undefined ? StandardSchemaV1.InferOutput<TStandardSchema> : TExplicitType> extends SchemaBuilder<TResult, TRequired, TNullable, THasDefault, TExtensions> {
48
+ #private;
49
+ /**
50
+ * Always `true` for extern schemas — enables Proxy-based property
51
+ * descriptor trees and nested error propagation in
52
+ * `ObjectSchemaBuilder`.
53
+ */
54
+ readonly [SYMBOL_HAS_PROPERTIES] = true;
55
+ /**
56
+ * @hidden
57
+ */
58
+ static create(props: ExternSchemaBuilderCreateProps<any>): ExternSchemaBuilder<StandardSchemaV1<unknown, unknown>, true, false, undefined, false, {}, unknown>;
59
+ protected constructor(props: ExternSchemaBuilderCreateProps<TRequired>);
60
+ /**
61
+ * Returns the wrapped Standard Schema instance.
62
+ */
63
+ get standardSchema(): TStandardSchema;
64
+ /**
65
+ * @inheritdoc
66
+ */
67
+ hasType<T>(_notUsed?: T): ExternSchemaBuilder<TStandardSchema, true, TNullable, T, THasDefault, TExtensions> & TExtensions;
68
+ /**
69
+ * @inheritdoc
70
+ */
71
+ clearHasType(): ExternSchemaBuilder<TStandardSchema, TRequired, TNullable, undefined, THasDefault, TExtensions> & TExtensions;
72
+ /** {@inheritDoc SchemaBuilder.validate} */
73
+ validate(object: TResult, context?: ValidationContext): ValidationResult<TResult>;
74
+ /** {@inheritDoc SchemaBuilder.validateAsync} */
75
+ validateAsync(object: TResult, context?: ValidationContext): Promise<ValidationResult<TResult>>;
76
+ /**
77
+ * Performs synchronous validation by delegating to the external
78
+ * Standard Schema's `validate()` method.
79
+ *
80
+ * If the external schema returns a `Promise` (async validation),
81
+ * this method throws — use {@link validateAsync} instead.
82
+ */
83
+ protected _validate(object: TResult, context?: ValidationContext): ValidationResult<TResult>;
84
+ /**
85
+ * Performs async validation by delegating to the external
86
+ * Standard Schema's `validate()` method. Supports external schemas
87
+ * that return a `Promise` from their `validate()`.
88
+ */
89
+ protected _validateAsync(object: TResult, context?: ValidationContext): Promise<ValidationResult<TResult>>;
90
+ protected createFromProps<TReq extends boolean>(props: ExternSchemaBuilderCreateProps<TReq>): this;
91
+ /**
92
+ * Returns a snapshot of the builder's internal state.
93
+ * Includes the wrapped `standardSchema` reference.
94
+ */
95
+ introspect(): {
96
+ standardSchema: TStandardSchema;
97
+ type: string;
98
+ isRequired: boolean;
99
+ isNullable: boolean;
100
+ isReadonly: boolean;
101
+ preprocessors: readonly import("./SchemaBuilder.js").PreprocessorEntry<TResult>[];
102
+ validators: readonly import("./SchemaBuilder.js").ValidatorEntry<TResult>[];
103
+ requiredValidationErrorMessageProvider: ValidationErrorMessageProvider<SchemaBuilder<any, any, any, any, any>>;
104
+ extensions: {
105
+ [x: string]: unknown;
106
+ };
107
+ hasDefault: boolean;
108
+ defaultValue: TResult | (() => TResult) | undefined;
109
+ description: string | undefined;
110
+ schemaName: string | undefined;
111
+ hasCatch: boolean;
112
+ catchValue: TResult | (() => TResult) | undefined;
113
+ example: unknown;
114
+ };
115
+ /**
116
+ * @hidden
117
+ */
118
+ required(errorMessage?: ValidationErrorMessageProvider): ExternSchemaBuilder<TStandardSchema, true, TNullable, TExplicitType, THasDefault, TExtensions> & TExtensions;
119
+ /**
120
+ * @hidden
121
+ */
122
+ optional(): ExternSchemaBuilder<TStandardSchema, false, TNullable, TExplicitType, THasDefault, TExtensions> & TExtensions;
123
+ /**
124
+ * @hidden
125
+ */
126
+ default(value: TResult | (() => TResult)): ExternSchemaBuilder<TStandardSchema, true, TNullable, TExplicitType, true, TExtensions> & TExtensions;
127
+ /**
128
+ * @hidden
129
+ */
130
+ clearDefault(): ExternSchemaBuilder<TStandardSchema, TRequired, TNullable, TExplicitType, false, TExtensions> & TExtensions;
131
+ /**
132
+ * @hidden
133
+ */
134
+ brand<TBrand extends string | symbol>(_name?: TBrand): ExternSchemaBuilder<TStandardSchema, TRequired, TNullable, TResult & {
135
+ readonly [K in BRAND]: TBrand;
136
+ }, THasDefault, TExtensions> & TExtensions;
137
+ /**
138
+ * Marks the inferred type as `Readonly<T>`. Sets the `isReadonly`
139
+ * introspection flag for tooling consistency.
140
+ *
141
+ * @see {@link SchemaBuilder.readonly}
142
+ */
143
+ readonly(): ExternSchemaBuilder<TStandardSchema, TRequired, TNullable, Readonly<TResult>, THasDefault, TExtensions> & TExtensions;
144
+ /**
145
+ * @hidden
146
+ */
147
+ nullable(): ExternSchemaBuilder<TStandardSchema, TRequired, true, TExplicitType, THasDefault, TExtensions> & TExtensions;
148
+ /**
149
+ * @hidden
150
+ */
151
+ notNullable(): ExternSchemaBuilder<TStandardSchema, TRequired, false, TExplicitType, THasDefault, TExtensions> & TExtensions;
152
+ }
153
+ /**
154
+ * Wraps an external [Standard Schema v1](https://standardschema.dev/)
155
+ * compatible schema into a `@cleverbrush/schema` builder.
156
+ *
157
+ * This enables cross-library schema composition — use schemas from Zod,
158
+ * Valibot, ArkType, or any Standard Schema v1 compliant library as
159
+ * properties inside `@cleverbrush/schema` object schemas with full type
160
+ * inference.
161
+ *
162
+ * @param standardSchema - A Standard Schema v1 compliant schema instance
163
+ * (any object that exposes a `['~standard']` property with `version: 1`
164
+ * and a `validate` function).
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * import { z } from 'zod';
169
+ * import { object, date, extern, InferType } from '@cleverbrush/schema';
170
+ *
171
+ * const zodUser = z.object({ first: z.string(), last: z.string() });
172
+ *
173
+ * const order = object({
174
+ * user: extern(zodUser),
175
+ * date: date(),
176
+ * });
177
+ *
178
+ * type Order = InferType<typeof order>;
179
+ * // { user: { first: string; last: string }; date: Date }
180
+ *
181
+ * order.validate({
182
+ * user: { first: 'Alice', last: 'Smith' },
183
+ * date: new Date(),
184
+ * }); // { valid: true, object: { user: …, date: … } }
185
+ * ```
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * // Optional external schema
190
+ * const schema = extern(zodUser).optional();
191
+ * schema.validate(undefined); // valid
192
+ * ```
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * // Inside an array
197
+ * import { array, extern } from '@cleverbrush/schema';
198
+ * const users = array(extern(zodUser));
199
+ * ```
200
+ */
201
+ export declare const extern: <T extends StandardSchemaV1>(standardSchema: T) => ExternSchemaBuilder<T, true>;
202
+ export {};
@@ -0,0 +1,2 @@
1
+ import{a,b}from"../chunk-PHE4LIAN.js";import"../chunk-3JMDGYDT.js";export{a as ExternSchemaBuilder,b as extern};
2
+ //# sourceMappingURL=ExternSchemaBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}