ccusage 11.0.2 → 12.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.
@@ -1,1737 +0,0 @@
1
- //#region node_modules/type-fest/source/observable-like.d.ts
2
- declare global {
3
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
4
- interface SymbolConstructor {
5
- readonly observable: symbol;
6
- }
7
- }
8
-
9
- /**
10
- @remarks
11
- The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
12
- As well, some guidance on making an `Observable` to not include `closed` property.
13
- @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
14
- @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
15
- @see https://github.com/benlesh/symbol-observable#making-an-object-observable
16
-
17
- @category Observable
18
- */
19
-
20
- //#endregion
21
- //#region node_modules/type-fest/source/tuple-to-union.d.ts
22
- /**
23
- Convert a tuple/array into a union type of its elements.
24
-
25
- This can be useful when you have a fixed set of allowed values and want a type defining only the allowed values, but do not want to repeat yourself.
26
-
27
- @example
28
- ```
29
- import type {TupleToUnion} from 'type-fest';
30
-
31
- const destinations = ['a', 'b', 'c'] as const;
32
-
33
- type Destination = TupleToUnion<typeof destinations>;
34
- //=> 'a' | 'b' | 'c'
35
-
36
- function verifyDestination(destination: unknown): destination is Destination {
37
- return destinations.includes(destination as any);
38
- }
39
-
40
- type RequestBody = {
41
- deliverTo: Destination;
42
- };
43
-
44
- function verifyRequestBody(body: unknown): body is RequestBody {
45
- const deliverTo = (body as any).deliverTo;
46
- return typeof body === 'object' && body !== null && verifyDestination(deliverTo);
47
- }
48
- ```
49
-
50
- Alternatively, you may use `typeof destinations[number]`. If `destinations` is a tuple, there is no difference. However if `destinations` is a string, the resulting type will the union of the characters in the string. Other types of `destinations` may result in a compile error. In comparison, TupleToUnion will return `never` if a tuple is not provided.
51
-
52
- @example
53
- ```
54
- const destinations = ['a', 'b', 'c'] as const;
55
-
56
- type Destination = typeof destinations[number];
57
- //=> 'a' | 'b' | 'c'
58
-
59
- const erroringType = new Set(['a', 'b', 'c']);
60
-
61
- type ErroringType = typeof erroringType[number];
62
- //=> Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)
63
-
64
- const numberBool: { [n: number]: boolean } = { 1: true };
65
-
66
- type NumberBool = typeof numberBool[number];
67
- //=> boolean
68
- ```
69
-
70
- @category Array
71
- */
72
- type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;
73
- //#endregion
74
- //#region node_modules/valibot/dist/index.d.ts
75
-
76
- /**
77
- * Fallback type.
78
- */
79
- type Fallback<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>>> = MaybeReadonly<InferOutput<TSchema>> | ((dataset?: OutputDataset<InferOutput<TSchema>, InferIssue<TSchema>>, config?: Config<InferIssue<TSchema>>) => MaybeReadonly<InferOutput<TSchema>>);
80
- /**
81
- * Schema with fallback type.
82
- */
83
- type SchemaWithFallback<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TFallback extends Fallback<TSchema>> = TSchema & {
84
- /**
85
- * The fallback value.
86
- */
87
- readonly fallback: TFallback;
88
- };
89
- /**
90
- * Returns a fallback value as output if the input does not match the schema.
91
- *
92
- * @param schema The schema to catch.
93
- * @param fallback The fallback value.
94
- *
95
- * @returns The passed schema.
96
- */
97
-
98
- /**
99
- * Fallback async type.
100
- */
101
- type FallbackAsync<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = MaybeReadonly<InferOutput<TSchema>> | ((dataset?: OutputDataset<InferOutput<TSchema>, InferIssue<TSchema>>, config?: Config<InferIssue<TSchema>>) => MaybePromise<MaybeReadonly<InferOutput<TSchema>>>);
102
- /**
103
- * Schema with fallback async type.
104
- */
105
- type SchemaWithFallbackAsync<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TFallback extends FallbackAsync<TSchema>> = Omit<TSchema, 'async' | '~standard' | '~run'> & {
106
- /**
107
- * The fallback value.
108
- */
109
- readonly fallback: TFallback;
110
- /**
111
- * Whether it's async.
112
- */
113
- readonly async: true;
114
- /**
115
- * The Standard Schema properties.
116
- *
117
- * @internal
118
- */
119
- readonly '~standard': StandardProps<InferInput<TSchema>, InferOutput<TSchema>>;
120
- /**
121
- * Parses unknown input values.
122
- *
123
- * @param dataset The input dataset.
124
- * @param config The configuration.
125
- *
126
- * @returns The output dataset.
127
- *
128
- * @internal
129
- */
130
- readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<InferOutput<TSchema>, InferIssue<TSchema>>>;
131
- };
132
- /**
133
- * Returns a fallback value as output if the input does not match the schema.
134
- *
135
- * @param schema The schema to catch.
136
- * @param fallback The fallback value.
137
- *
138
- * @returns The passed schema.
139
- */
140
-
141
- /**
142
- * Schema with pipe type.
143
- */
144
- type SchemaWithPipe<TPipe extends readonly [BaseSchema<unknown, unknown, BaseIssue<unknown>>, ...PipeItem<any, unknown, BaseIssue<unknown>>[]]> = Omit<FirstTupleItem<TPipe>, 'pipe' | '~standard' | '~run' | '~types'> & {
145
- /**
146
- * The pipe items.
147
- */
148
- readonly pipe: TPipe;
149
- /**
150
- * The Standard Schema properties.
151
- *
152
- * @internal
153
- */
154
- readonly '~standard': StandardProps<InferInput<FirstTupleItem<TPipe>>, InferOutput<LastTupleItem<TPipe>>>;
155
- /**
156
- * Parses unknown input values.
157
- *
158
- * @param dataset The input dataset.
159
- * @param config The configuration.
160
- *
161
- * @returns The output dataset.
162
- *
163
- * @internal
164
- */
165
- readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => OutputDataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>;
166
- /**
167
- * The input, output and issue type.
168
- *
169
- * @internal
170
- */
171
- readonly '~types'?: {
172
- readonly input: InferInput<FirstTupleItem<TPipe>>;
173
- readonly output: InferOutput<LastTupleItem<TPipe>>;
174
- readonly issue: InferIssue<TPipe[number]>;
175
- } | undefined;
176
- };
177
- /**
178
- * Adds a pipeline to a schema, that can validate and transform its input.
179
- *
180
- * @param schema The root schema.
181
- * @param item1 The first pipe item.
182
- *
183
- * @returns A schema with a pipeline.
184
- */
185
-
186
- /**
187
- * Schema with pipe async type.
188
- */
189
- type SchemaWithPipeAsync<TPipe extends readonly [(BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>), ...(PipeItem<any, unknown, BaseIssue<unknown>> | PipeItemAsync<any, unknown, BaseIssue<unknown>>)[]]> = Omit<FirstTupleItem<TPipe>, 'async' | 'pipe' | '~standard' | '~run' | '~types'> & {
190
- /**
191
- * The pipe items.
192
- */
193
- readonly pipe: TPipe;
194
- /**
195
- * Whether it's async.
196
- */
197
- readonly async: true;
198
- /**
199
- * The Standard Schema properties.
200
- *
201
- * @internal
202
- */
203
- readonly '~standard': StandardProps<InferInput<FirstTupleItem<TPipe>>, InferOutput<LastTupleItem<TPipe>>>;
204
- /**
205
- * Parses unknown input values.
206
- *
207
- * @param dataset The input dataset.
208
- * @param config The configuration.
209
- *
210
- * @returns The output dataset.
211
- *
212
- * @internal
213
- */
214
- readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<InferOutput<LastTupleItem<TPipe>>, InferIssue<TPipe[number]>>>;
215
- /**
216
- * The input, output and issue type.
217
- *
218
- * @internal
219
- */
220
- readonly '~types'?: {
221
- readonly input: InferInput<FirstTupleItem<TPipe>>;
222
- readonly output: InferOutput<LastTupleItem<TPipe>>;
223
- readonly issue: InferIssue<TPipe[number]>;
224
- } | undefined;
225
- };
226
- /**
227
- * Adds a pipeline to a schema, that can validate and transform its input.
228
- *
229
- * @param schema The root schema.
230
- * @param item1 The first pipe item.
231
- *
232
- * @returns A schema with a pipeline.
233
- */
234
-
235
- /**
236
- * Base metadata interface.
237
- */
238
- interface BaseMetadata<TInput> {
239
- /**
240
- * The object kind.
241
- */
242
- readonly kind: 'metadata';
243
- /**
244
- * The metadata type.
245
- */
246
- readonly type: string;
247
- /**
248
- * The metadata reference.
249
- */
250
- readonly reference: (...args: any[]) => BaseMetadata<any>;
251
- /**
252
- * The input, output and issue type.
253
- *
254
- * @internal
255
- */
256
- readonly '~types'?: {
257
- readonly input: TInput;
258
- readonly output: TInput;
259
- readonly issue: never;
260
- } | undefined;
261
- }
262
- /**
263
- * Generic metadata type.
264
- */
265
-
266
- /**
267
- * Unknown dataset interface.
268
- */
269
- interface UnknownDataset {
270
- /**
271
- * Whether is's typed.
272
- */
273
- typed?: false;
274
- /**
275
- * The dataset value.
276
- */
277
- value: unknown;
278
- /**
279
- * The dataset issues.
280
- */
281
- issues?: undefined;
282
- }
283
- /**
284
- * Success dataset interface.
285
- */
286
- interface SuccessDataset<TValue> {
287
- /**
288
- * Whether is's typed.
289
- */
290
- typed: true;
291
- /**
292
- * The dataset value.
293
- */
294
- value: TValue;
295
- /**
296
- * The dataset issues.
297
- */
298
- issues?: undefined;
299
- }
300
- /**
301
- * Partial dataset interface.
302
- */
303
- interface PartialDataset<TValue, TIssue extends BaseIssue<unknown>> {
304
- /**
305
- * Whether is's typed.
306
- */
307
- typed: true;
308
- /**
309
- * The dataset value.
310
- */
311
- value: TValue;
312
- /**
313
- * The dataset issues.
314
- */
315
- issues: [TIssue, ...TIssue[]];
316
- }
317
- /**
318
- * Failure dataset interface.
319
- */
320
- interface FailureDataset<TIssue extends BaseIssue<unknown>> {
321
- /**
322
- * Whether is's typed.
323
- */
324
- typed: false;
325
- /**
326
- * The dataset value.
327
- */
328
- value: unknown;
329
- /**
330
- * The dataset issues.
331
- */
332
- issues: [TIssue, ...TIssue[]];
333
- }
334
- /**
335
- * Output dataset type.
336
- */
337
- type OutputDataset<TValue, TIssue extends BaseIssue<unknown>> = SuccessDataset<TValue> | PartialDataset<TValue, TIssue> | FailureDataset<TIssue>;
338
-
339
- /**
340
- * The Standard Schema properties interface.
341
- */
342
- interface StandardProps<TInput, TOutput> {
343
- /**
344
- * The version number of the standard.
345
- */
346
- readonly version: 1;
347
- /**
348
- * The vendor name of the schema library.
349
- */
350
- readonly vendor: 'valibot';
351
- /**
352
- * Validates unknown input values.
353
- */
354
- readonly validate: (value: unknown) => StandardResult<TOutput> | Promise<StandardResult<TOutput>>;
355
- /**
356
- * Inferred types associated with the schema.
357
- */
358
- readonly types?: StandardTypes<TInput, TOutput> | undefined;
359
- }
360
- /**
361
- * The result interface of the validate function.
362
- */
363
- type StandardResult<TOutput> = StandardSuccessResult<TOutput> | StandardFailureResult;
364
- /**
365
- * The result interface if validation succeeds.
366
- */
367
- interface StandardSuccessResult<TOutput> {
368
- /**
369
- * The typed output value.
370
- */
371
- readonly value: TOutput;
372
- /**
373
- * The non-existent issues.
374
- */
375
- readonly issues?: undefined;
376
- }
377
- /**
378
- * The result interface if validation fails.
379
- */
380
- interface StandardFailureResult {
381
- /**
382
- * The issues of failed validation.
383
- */
384
- readonly issues: readonly StandardIssue[];
385
- }
386
- /**
387
- * The issue interface of the failure output.
388
- */
389
- interface StandardIssue {
390
- /**
391
- * The error message of the issue.
392
- */
393
- readonly message: string;
394
- /**
395
- * The path of the issue, if any.
396
- */
397
- readonly path?: readonly (PropertyKey | StandardPathItem)[] | undefined;
398
- }
399
- /**
400
- * The path item interface of the issue.
401
- */
402
- interface StandardPathItem {
403
- /**
404
- * The key of the path item.
405
- */
406
- readonly key: PropertyKey;
407
- }
408
- /**
409
- * The Standard Schema types interface.
410
- */
411
- interface StandardTypes<TInput, TOutput> {
412
- /**
413
- * The input type of the schema.
414
- */
415
- readonly input: TInput;
416
- /**
417
- * The output type of the schema.
418
- */
419
- readonly output: TOutput;
420
- }
421
-
422
- /**
423
- * Base schema interface.
424
- */
425
- interface BaseSchema<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
426
- /**
427
- * The object kind.
428
- */
429
- readonly kind: 'schema';
430
- /**
431
- * The schema type.
432
- */
433
- readonly type: string;
434
- /**
435
- * The schema reference.
436
- */
437
- readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>>;
438
- /**
439
- * The expected property.
440
- */
441
- readonly expects: string;
442
- /**
443
- * Whether it's async.
444
- */
445
- readonly async: false;
446
- /**
447
- * The Standard Schema properties.
448
- *
449
- * @internal
450
- */
451
- readonly '~standard': StandardProps<TInput, TOutput>;
452
- /**
453
- * Parses unknown input values.
454
- *
455
- * @param dataset The input dataset.
456
- * @param config The configuration.
457
- *
458
- * @returns The output dataset.
459
- *
460
- * @internal
461
- */
462
- readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, TIssue>;
463
- /**
464
- * The input, output and issue type.
465
- *
466
- * @internal
467
- */
468
- readonly '~types'?: {
469
- readonly input: TInput;
470
- readonly output: TOutput;
471
- readonly issue: TIssue;
472
- } | undefined;
473
- }
474
- /**
475
- * Base schema async interface.
476
- */
477
- interface BaseSchemaAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseSchema<TInput, TOutput, TIssue>, 'reference' | 'async' | '~run'> {
478
- /**
479
- * The schema reference.
480
- */
481
- readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
482
- /**
483
- * Whether it's async.
484
- */
485
- readonly async: true;
486
- /**
487
- * Parses unknown input values.
488
- *
489
- * @param dataset The input dataset.
490
- * @param config The configuration.
491
- *
492
- * @returns The output dataset.
493
- *
494
- * @internal
495
- */
496
- readonly '~run': (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, TIssue>>;
497
- }
498
- /**
499
- * Generic schema type.
500
- */
501
-
502
- /**
503
- * Base transformation interface.
504
- */
505
- interface BaseTransformation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
506
- /**
507
- * The object kind.
508
- */
509
- readonly kind: 'transformation';
510
- /**
511
- * The transformation type.
512
- */
513
- readonly type: string;
514
- /**
515
- * The transformation reference.
516
- */
517
- readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>>;
518
- /**
519
- * Whether it's async.
520
- */
521
- readonly async: false;
522
- /**
523
- * Transforms known input values.
524
- *
525
- * @param dataset The input dataset.
526
- * @param config The configuration.
527
- *
528
- * @returns The output dataset.
529
- *
530
- * @internal
531
- */
532
- readonly '~run': (dataset: SuccessDataset<TInput>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, BaseIssue<unknown> | TIssue>;
533
- /**
534
- * The input, output and issue type.
535
- *
536
- * @internal
537
- */
538
- readonly '~types'?: {
539
- readonly input: TInput;
540
- readonly output: TOutput;
541
- readonly issue: TIssue;
542
- } | undefined;
543
- }
544
- /**
545
- * Base transformation async interface.
546
- */
547
- interface BaseTransformationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseTransformation<TInput, TOutput, TIssue>, 'reference' | 'async' | '~run'> {
548
- /**
549
- * The transformation reference.
550
- */
551
- readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>> | BaseTransformationAsync<any, any, BaseIssue<unknown>>;
552
- /**
553
- * Whether it's async.
554
- */
555
- readonly async: true;
556
- /**
557
- * Transforms known input values.
558
- *
559
- * @param dataset The input dataset.
560
- * @param config The configuration.
561
- *
562
- * @returns The output dataset.
563
- *
564
- * @internal
565
- */
566
- readonly '~run': (dataset: SuccessDataset<TInput>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, BaseIssue<unknown> | TIssue>>;
567
- }
568
- /**
569
- * Generic transformation type.
570
- */
571
-
572
- /**
573
- * Base validation interface.
574
- */
575
- interface BaseValidation<TInput, TOutput, TIssue extends BaseIssue<unknown>> {
576
- /**
577
- * The object kind.
578
- */
579
- readonly kind: 'validation';
580
- /**
581
- * The validation type.
582
- */
583
- readonly type: string;
584
- /**
585
- * The validation reference.
586
- */
587
- readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>>;
588
- /**
589
- * The expected property.
590
- */
591
- readonly expects: string | null;
592
- /**
593
- * Whether it's async.
594
- */
595
- readonly async: false;
596
- /**
597
- * Validates known input values.
598
- *
599
- * @param dataset The input dataset.
600
- * @param config The configuration.
601
- *
602
- * @returns The output dataset.
603
- *
604
- * @internal
605
- */
606
- readonly '~run': (dataset: OutputDataset<TInput, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput, BaseIssue<unknown> | TIssue>;
607
- /**
608
- * The input, output and issue type.
609
- *
610
- * @internal
611
- */
612
- readonly '~types'?: {
613
- readonly input: TInput;
614
- readonly output: TOutput;
615
- readonly issue: TIssue;
616
- } | undefined;
617
- }
618
- /**
619
- * Base validation async interface.
620
- */
621
- interface BaseValidationAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> extends Omit<BaseValidation<TInput, TOutput, TIssue>, 'reference' | 'async' | '~run'> {
622
- /**
623
- * The validation reference.
624
- */
625
- readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>> | BaseValidationAsync<any, any, BaseIssue<unknown>>;
626
- /**
627
- * Whether it's async.
628
- */
629
- readonly async: true;
630
- /**
631
- * Validates known input values.
632
- *
633
- * @param dataset The input dataset.
634
- * @param config The configuration.
635
- *
636
- * @returns The output dataset.
637
- *
638
- * @internal
639
- */
640
- readonly '~run': (dataset: OutputDataset<TInput, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput, BaseIssue<unknown> | TIssue>>;
641
- }
642
- /**
643
- * Generic validation type.
644
- */
645
-
646
- /**
647
- * Infer input type.
648
- */
649
- type InferInput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['input'];
650
- /**
651
- * Infer output type.
652
- */
653
- type InferOutput<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['output'];
654
- /**
655
- * Infer issue type.
656
- */
657
- type InferIssue<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem['~types']>['issue'];
658
-
659
- /**
660
- * Checks if a type is `any`.
661
- */
662
-
663
- /**
664
- * Constructs a type that is maybe readonly.
665
- */
666
- type MaybeReadonly<TValue> = TValue | Readonly<TValue>;
667
- /**
668
- * Constructs a type that is maybe a promise.
669
- */
670
- type MaybePromise<TValue> = TValue | Promise<TValue>;
671
- /**
672
- * Prettifies a type for better readability.
673
- *
674
- * Hint: This type has no effect and is only used so that TypeScript displays
675
- * the final type in the preview instead of the utility types used.
676
- */
677
- type Prettify<TObject> = { [TKey in keyof TObject]: TObject[TKey] } & {};
678
- /**
679
- * Marks specific keys as optional.
680
- */
681
- type MarkOptional<TObject, TKeys extends keyof TObject> = { [TKey in keyof TObject]?: unknown } & Omit<TObject, TKeys> & Partial<Pick<TObject, TKeys>>;
682
- /**
683
- * Merges two objects. Overlapping entries from the second object overwrite
684
- * properties from the first object.
685
- */
686
-
687
- /**
688
- * Extracts first tuple item.
689
- */
690
- type FirstTupleItem<TTuple extends readonly [unknown, ...unknown[]]> = TTuple[0];
691
- /**
692
- * Extracts last tuple item.
693
- */
694
- type LastTupleItem<TTuple extends readonly [unknown, ...unknown[]]> = TTuple[TTuple extends readonly [unknown, ...infer TRest] ? TRest['length'] : never];
695
- /**
696
- * Converts union to intersection type.
697
- */
698
-
699
- /**
700
- * Error message type.
701
- */
702
- type ErrorMessage<TIssue extends BaseIssue<unknown>> = ((issue: TIssue) => string) | string;
703
- /**
704
- * Default type.
705
- */
706
- type Default<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybeReadonly<InferInput<TWrapped> | TInput>) | undefined;
707
- /**
708
- * Default async type.
709
- */
710
- type DefaultAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TInput extends null | undefined> = MaybeReadonly<InferInput<TWrapped> | TInput> | ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<MaybeReadonly<InferInput<TWrapped> | TInput>>) | undefined;
711
- /**
712
- * Default value type.
713
- */
714
- type DefaultValue<TDefault extends Default<BaseSchema<unknown, unknown, BaseIssue<unknown>>, null | undefined> | DefaultAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, null | undefined>> = TDefault extends DefaultAsync<infer TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, infer TInput> ? TDefault extends ((dataset?: UnknownDataset, config?: Config<InferIssue<TWrapped>>) => MaybePromise<InferInput<TWrapped> | TInput>) ? Awaited<ReturnType<TDefault>> : TDefault : never;
715
-
716
- /**
717
- * Optional entry schema type.
718
- */
719
- type OptionalEntrySchema = ExactOptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchema<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown>;
720
- /**
721
- * Optional entry schema async type.
722
- */
723
- type OptionalEntrySchemaAsync = ExactOptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | NullishSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalSchemaAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown>;
724
- /**
725
- * Object entries interface.
726
- */
727
- interface ObjectEntries {
728
- [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | SchemaWithFallback<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalEntrySchema;
729
- }
730
- /**
731
- * Object entries async interface.
732
- */
733
- interface ObjectEntriesAsync {
734
- [key: string]: BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | SchemaWithFallback<BaseSchema<unknown, unknown, BaseIssue<unknown>>, unknown> | SchemaWithFallbackAsync<BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, unknown> | OptionalEntrySchema | OptionalEntrySchemaAsync;
735
- }
736
- /**
737
- * Object keys type.
738
- */
739
-
740
- /**
741
- * Infer entries input type.
742
- */
743
- type InferEntriesInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = { -readonly [TKey in keyof TEntries]: InferInput<TEntries[TKey]> };
744
- /**
745
- * Infer entries output type.
746
- */
747
- type InferEntriesOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = { -readonly [TKey in keyof TEntries]: InferOutput<TEntries[TKey]> };
748
- /**
749
- * Optional input keys type.
750
- */
751
- type OptionalInputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = { [TKey in keyof TEntries]: TEntries[TKey] extends OptionalEntrySchema | OptionalEntrySchemaAsync ? TKey : never }[keyof TEntries];
752
- /**
753
- * Optional output keys type.
754
- */
755
- type OptionalOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = { [TKey in keyof TEntries]: TEntries[TKey] extends OptionalEntrySchema | OptionalEntrySchemaAsync ? undefined extends TEntries[TKey]['default'] ? TKey : never : never }[keyof TEntries];
756
- /**
757
- * Input with question marks type.
758
- */
759
- type InputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesInput<TEntries>> = MarkOptional<TObject, OptionalInputKeys<TEntries>>;
760
- /**
761
- * Output with question marks type.
762
- */
763
- type OutputWithQuestionMarks<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends InferEntriesOutput<TEntries>> = MarkOptional<TObject, OptionalOutputKeys<TEntries>>;
764
- /**
765
- * Readonly output keys type.
766
- */
767
- type ReadonlyOutputKeys<TEntries extends ObjectEntries | ObjectEntriesAsync> = { [TKey in keyof TEntries]: TEntries[TKey] extends SchemaWithPipe<infer TPipe> | SchemaWithPipeAsync<infer TPipe> ? ReadonlyAction<any> extends TPipe[number] ? TKey : never : never }[keyof TEntries];
768
- /**
769
- * Output with readonly type.
770
- */
771
- type OutputWithReadonly<TEntries extends ObjectEntries | ObjectEntriesAsync, TObject extends OutputWithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>> = Readonly<TObject> & Pick<TObject, Exclude<keyof TObject, ReadonlyOutputKeys<TEntries>>>;
772
- /**
773
- * Infer object input type.
774
- */
775
- type InferObjectInput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<InputWithQuestionMarks<TEntries, InferEntriesInput<TEntries>>>;
776
- /**
777
- * Infer object output type.
778
- */
779
- type InferObjectOutput<TEntries extends ObjectEntries | ObjectEntriesAsync> = Prettify<OutputWithReadonly<TEntries, OutputWithQuestionMarks<TEntries, InferEntriesOutput<TEntries>>>>;
780
- /**
781
- * Infer object issue type.
782
- */
783
- type InferObjectIssue<TEntries extends ObjectEntries | ObjectEntriesAsync> = InferIssue<TEntries[keyof TEntries]>;
784
-
785
- /**
786
- * Tuple items type.
787
- */
788
-
789
- /**
790
- * Array path item interface.
791
- */
792
- interface ArrayPathItem {
793
- /**
794
- * The path item type.
795
- */
796
- readonly type: 'array';
797
- /**
798
- * The path item origin.
799
- */
800
- readonly origin: 'value';
801
- /**
802
- * The path item input.
803
- */
804
- readonly input: MaybeReadonly<unknown[]>;
805
- /**
806
- * The path item key.
807
- */
808
- readonly key: number;
809
- /**
810
- * The path item value.
811
- */
812
- readonly value: unknown;
813
- }
814
- /**
815
- * Map path item interface.
816
- */
817
- interface MapPathItem {
818
- /**
819
- * The path item type.
820
- */
821
- readonly type: 'map';
822
- /**
823
- * The path item origin.
824
- */
825
- readonly origin: 'key' | 'value';
826
- /**
827
- * The path item input.
828
- */
829
- readonly input: Map<unknown, unknown>;
830
- /**
831
- * The path item key.
832
- */
833
- readonly key: unknown;
834
- /**
835
- * The path item value.
836
- */
837
- readonly value: unknown;
838
- }
839
- /**
840
- * Object path item interface.
841
- */
842
- interface ObjectPathItem {
843
- /**
844
- * The path item type.
845
- */
846
- readonly type: 'object';
847
- /**
848
- * The path item origin.
849
- */
850
- readonly origin: 'key' | 'value';
851
- /**
852
- * The path item input.
853
- */
854
- readonly input: Record<string, unknown>;
855
- /**
856
- * The path item key.
857
- */
858
- readonly key: string;
859
- /**
860
- * The path item value.
861
- */
862
- readonly value: unknown;
863
- }
864
- /**
865
- * Set path item interface.
866
- */
867
- interface SetPathItem {
868
- /**
869
- * The path item type.
870
- */
871
- readonly type: 'set';
872
- /**
873
- * The path item origin.
874
- */
875
- readonly origin: 'value';
876
- /**
877
- * The path item input.
878
- */
879
- readonly input: Set<unknown>;
880
- /**
881
- * The path item key.
882
- */
883
- readonly key: null;
884
- /**
885
- * The path item key.
886
- */
887
- readonly value: unknown;
888
- }
889
- /**
890
- * Unknown path item interface.
891
- */
892
- interface UnknownPathItem {
893
- /**
894
- * The path item type.
895
- */
896
- readonly type: 'unknown';
897
- /**
898
- * The path item origin.
899
- */
900
- readonly origin: 'key' | 'value';
901
- /**
902
- * The path item input.
903
- */
904
- readonly input: unknown;
905
- /**
906
- * The path item key.
907
- */
908
- readonly key: unknown;
909
- /**
910
- * The path item value.
911
- */
912
- readonly value: unknown;
913
- }
914
- /**
915
- * Issue path item type.
916
- */
917
- type IssuePathItem = ArrayPathItem | MapPathItem | ObjectPathItem | SetPathItem | UnknownPathItem;
918
- /**
919
- * Base issue interface.
920
- */
921
- interface BaseIssue<TInput> extends Config<BaseIssue<TInput>> {
922
- /**
923
- * The issue kind.
924
- */
925
- readonly kind: 'schema' | 'validation' | 'transformation';
926
- /**
927
- * The issue type.
928
- */
929
- readonly type: string;
930
- /**
931
- * The raw input data.
932
- */
933
- readonly input: TInput;
934
- /**
935
- * The expected property.
936
- */
937
- readonly expected: string | null;
938
- /**
939
- * The received property.
940
- */
941
- readonly received: string;
942
- /**
943
- * The error message.
944
- */
945
- readonly message: string;
946
- /**
947
- * The input requirement.
948
- */
949
- readonly requirement?: unknown | undefined;
950
- /**
951
- * The issue path.
952
- */
953
- readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined;
954
- /**
955
- * The sub issues.
956
- */
957
- readonly issues?: [BaseIssue<TInput>, ...BaseIssue<TInput>[]] | undefined;
958
- }
959
- /**
960
- * Generic issue type.
961
- */
962
-
963
- /**
964
- * Config interface.
965
- */
966
- interface Config<TIssue extends BaseIssue<unknown>> {
967
- /**
968
- * The selected language.
969
- */
970
- readonly lang?: string | undefined;
971
- /**
972
- * The error message.
973
- */
974
- readonly message?: ErrorMessage<TIssue> | undefined;
975
- /**
976
- * Whether it should be aborted early.
977
- */
978
- readonly abortEarly?: boolean | undefined;
979
- /**
980
- * Whether a pipe should be aborted early.
981
- */
982
- readonly abortPipeEarly?: boolean | undefined;
983
- }
984
-
985
- /**
986
- * Pipe action type.
987
- */
988
- type PipeAction<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidation<TInput, TOutput, TIssue> | BaseTransformation<TInput, TOutput, TIssue> | BaseMetadata<TInput>;
989
- /**
990
- * Pipe action async type.
991
- */
992
- type PipeActionAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseValidationAsync<TInput, TOutput, TIssue> | BaseTransformationAsync<TInput, TOutput, TIssue>;
993
- /**
994
- * Pipe item type.
995
- */
996
- type PipeItem<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue> | PipeAction<TInput, TOutput, TIssue>;
997
- /**
998
- * Pipe item async type.
999
- */
1000
- type PipeItemAsync<TInput, TOutput, TIssue extends BaseIssue<unknown>> = BaseSchemaAsync<TInput, TOutput, TIssue> | PipeActionAsync<TInput, TOutput, TIssue>;
1001
- /**
1002
- * Schema without pipe type.
1003
- */
1004
-
1005
- /**
1006
- * Array issue interface.
1007
- */
1008
- interface ArrayIssue extends BaseIssue<unknown> {
1009
- /**
1010
- * The issue kind.
1011
- */
1012
- readonly kind: 'schema';
1013
- /**
1014
- * The issue type.
1015
- */
1016
- readonly type: 'array';
1017
- /**
1018
- * The expected property.
1019
- */
1020
- readonly expected: 'Array';
1021
- }
1022
-
1023
- /**
1024
- * Array schema interface.
1025
- */
1026
- interface ArraySchema<TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<ArrayIssue> | undefined> extends BaseSchema<InferInput<TItem>[], InferOutput<TItem>[], ArrayIssue | InferIssue<TItem>> {
1027
- /**
1028
- * The schema type.
1029
- */
1030
- readonly type: 'array';
1031
- /**
1032
- * The schema reference.
1033
- */
1034
- readonly reference: typeof array;
1035
- /**
1036
- * The expected property.
1037
- */
1038
- readonly expects: 'Array';
1039
- /**
1040
- * The array item schema.
1041
- */
1042
- readonly item: TItem;
1043
- /**
1044
- * The error message.
1045
- */
1046
- readonly message: TMessage;
1047
- }
1048
- /**
1049
- * Creates an array schema.
1050
- *
1051
- * @param item The item schema.
1052
- *
1053
- * @returns An array schema.
1054
- */
1055
- declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(item: TItem): ArraySchema<TItem, undefined>;
1056
- /**
1057
- * Creates an array schema.
1058
- *
1059
- * @param item The item schema.
1060
- * @param message The error message.
1061
- *
1062
- * @returns An array schema.
1063
- */
1064
- declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<ArrayIssue> | undefined>(item: TItem, message: TMessage): ArraySchema<TItem, TMessage>;
1065
-
1066
- /**
1067
- * Array schema interface.
1068
- */
1069
-
1070
- /**
1071
- * Exact optional schema interface.
1072
- */
1073
- interface ExactOptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, never>> extends BaseSchema<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
1074
- /**
1075
- * The schema type.
1076
- */
1077
- readonly type: 'exact_optional';
1078
- /**
1079
- * The schema reference.
1080
- */
1081
- readonly reference: typeof exactOptional;
1082
- /**
1083
- * The expected property.
1084
- */
1085
- readonly expects: TWrapped['expects'];
1086
- /**
1087
- * The wrapped schema.
1088
- */
1089
- readonly wrapped: TWrapped;
1090
- /**
1091
- * The default value.
1092
- */
1093
- readonly default: TDefault;
1094
- }
1095
- /**
1096
- * Creates an exact optional schema.
1097
- *
1098
- * @param wrapped The wrapped schema.
1099
- *
1100
- * @returns An exact optional schema.
1101
- */
1102
- declare function exactOptional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): ExactOptionalSchema<TWrapped, undefined>;
1103
- /**
1104
- * Creates an exact optional schema.
1105
- *
1106
- * @param wrapped The wrapped schema.
1107
- * @param default_ The default value.
1108
- *
1109
- * @returns An exact optional schema.
1110
- */
1111
- declare function exactOptional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, never>>(wrapped: TWrapped, default_: TDefault): ExactOptionalSchema<TWrapped, TDefault>;
1112
-
1113
- /**
1114
- * Exact optional schema async interface.
1115
- */
1116
- interface ExactOptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, never>> extends BaseSchemaAsync<InferInput<TWrapped>, InferOutput<TWrapped>, InferIssue<TWrapped>> {
1117
- /**
1118
- * The schema type.
1119
- */
1120
- readonly type: 'exact_optional';
1121
- /**
1122
- * The schema reference.
1123
- */
1124
- readonly reference: typeof exactOptional | typeof exactOptionalAsync;
1125
- /**
1126
- * The expected property.
1127
- */
1128
- readonly expects: TWrapped['expects'];
1129
- /**
1130
- * The wrapped schema.
1131
- */
1132
- readonly wrapped: TWrapped;
1133
- /**
1134
- * The default value.
1135
- */
1136
- readonly default: TDefault;
1137
- }
1138
- /**
1139
- * Creates an exact optional schema.
1140
- *
1141
- * @param wrapped The wrapped schema.
1142
- *
1143
- * @returns An exact optional schema.
1144
- */
1145
- declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): ExactOptionalSchemaAsync<TWrapped, undefined>;
1146
- /**
1147
- * Creates an exact optional schema.
1148
- *
1149
- * @param wrapped The wrapped schema.
1150
- * @param default_ The default value.
1151
- *
1152
- * @returns An exact optional schema.
1153
- */
1154
- declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, never>>(wrapped: TWrapped, default_: TDefault): ExactOptionalSchemaAsync<TWrapped, TDefault>;
1155
-
1156
- /**
1157
- * File issue interface.
1158
- */
1159
-
1160
- /**
1161
- * Infer nullish output type.
1162
- */
1163
- type InferNullishOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> = undefined extends TDefault ? InferOutput<TWrapped> | null | undefined : InferOutput<TWrapped> | Extract<DefaultValue<TDefault>, null | undefined>;
1164
-
1165
- /**
1166
- * Nullish schema interface.
1167
- */
1168
- interface NullishSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, null | undefined>> extends BaseSchema<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
1169
- /**
1170
- * The schema type.
1171
- */
1172
- readonly type: 'nullish';
1173
- /**
1174
- * The schema reference.
1175
- */
1176
- readonly reference: typeof nullish;
1177
- /**
1178
- * The expected property.
1179
- */
1180
- readonly expects: `(${TWrapped['expects']} | null | undefined)`;
1181
- /**
1182
- * The wrapped schema.
1183
- */
1184
- readonly wrapped: TWrapped;
1185
- /**
1186
- * The default value.
1187
- */
1188
- readonly default: TDefault;
1189
- }
1190
- /**
1191
- * Creates a nullish schema.
1192
- *
1193
- * @param wrapped The wrapped schema.
1194
- *
1195
- * @returns A nullish schema.
1196
- */
1197
- declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchema<TWrapped, undefined>;
1198
- /**
1199
- * Creates a nullish schema.
1200
- *
1201
- * @param wrapped The wrapped schema.
1202
- * @param default_ The default value.
1203
- *
1204
- * @returns A nullish schema.
1205
- */
1206
- declare function nullish<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchema<TWrapped, TDefault>;
1207
-
1208
- /**
1209
- * Nullish schema async interface.
1210
- */
1211
- interface NullishSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, null | undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | null | undefined, InferNullishOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
1212
- /**
1213
- * The schema type.
1214
- */
1215
- readonly type: 'nullish';
1216
- /**
1217
- * The schema reference.
1218
- */
1219
- readonly reference: typeof nullish | typeof nullishAsync;
1220
- /**
1221
- * The expected property.
1222
- */
1223
- readonly expects: `(${TWrapped['expects']} | null | undefined)`;
1224
- /**
1225
- * The wrapped schema.
1226
- */
1227
- readonly wrapped: TWrapped;
1228
- /**
1229
- * The default value.
1230
- */
1231
- readonly default: TDefault;
1232
- }
1233
- /**
1234
- * Creates a nullish schema.
1235
- *
1236
- * @param wrapped The wrapped schema.
1237
- *
1238
- * @returns A nullish schema.
1239
- */
1240
- declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): NullishSchemaAsync<TWrapped, undefined>;
1241
- /**
1242
- * Creates a nullish schema.
1243
- *
1244
- * @param wrapped The wrapped schema.
1245
- * @param default_ The default value.
1246
- *
1247
- * @returns A nullish schema.
1248
- */
1249
- declare function nullishAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, null | undefined>>(wrapped: TWrapped, default_: TDefault): NullishSchemaAsync<TWrapped, TDefault>;
1250
-
1251
- /**
1252
- * Number issue interface.
1253
- */
1254
- interface NumberIssue extends BaseIssue<unknown> {
1255
- /**
1256
- * The issue kind.
1257
- */
1258
- readonly kind: 'schema';
1259
- /**
1260
- * The issue type.
1261
- */
1262
- readonly type: 'number';
1263
- /**
1264
- * The expected property.
1265
- */
1266
- readonly expected: 'number';
1267
- }
1268
- /**
1269
- * Number schema interface.
1270
- */
1271
- interface NumberSchema<TMessage extends ErrorMessage<NumberIssue> | undefined> extends BaseSchema<number, number, NumberIssue> {
1272
- /**
1273
- * The schema type.
1274
- */
1275
- readonly type: 'number';
1276
- /**
1277
- * The schema reference.
1278
- */
1279
- readonly reference: typeof number;
1280
- /**
1281
- * The expected property.
1282
- */
1283
- readonly expects: 'number';
1284
- /**
1285
- * The error message.
1286
- */
1287
- readonly message: TMessage;
1288
- }
1289
- /**
1290
- * Creates a number schema.
1291
- *
1292
- * @returns A number schema.
1293
- */
1294
- declare function number(): NumberSchema<undefined>;
1295
- /**
1296
- * Creates a number schema.
1297
- *
1298
- * @param message The error message.
1299
- *
1300
- * @returns A number schema.
1301
- */
1302
- declare function number<const TMessage extends ErrorMessage<NumberIssue> | undefined>(message: TMessage): NumberSchema<TMessage>;
1303
-
1304
- /**
1305
- * Object issue interface.
1306
- */
1307
- interface ObjectIssue extends BaseIssue<unknown> {
1308
- /**
1309
- * The issue kind.
1310
- */
1311
- readonly kind: 'schema';
1312
- /**
1313
- * The issue type.
1314
- */
1315
- readonly type: 'object';
1316
- /**
1317
- * The expected property.
1318
- */
1319
- readonly expected: 'Object' | `"${string}"`;
1320
- }
1321
-
1322
- /**
1323
- * Object schema interface.
1324
- */
1325
- interface ObjectSchema<TEntries extends ObjectEntries, TMessage extends ErrorMessage<ObjectIssue> | undefined> extends BaseSchema<InferObjectInput<TEntries>, InferObjectOutput<TEntries>, ObjectIssue | InferObjectIssue<TEntries>> {
1326
- /**
1327
- * The schema type.
1328
- */
1329
- readonly type: 'object';
1330
- /**
1331
- * The schema reference.
1332
- */
1333
- readonly reference: typeof object;
1334
- /**
1335
- * The expected property.
1336
- */
1337
- readonly expects: 'Object';
1338
- /**
1339
- * The entries schema.
1340
- */
1341
- readonly entries: TEntries;
1342
- /**
1343
- * The error message.
1344
- */
1345
- readonly message: TMessage;
1346
- }
1347
- /**
1348
- * Creates an object schema.
1349
- *
1350
- * Hint: This schema removes unknown entries. The output will only include the
1351
- * entries you specify. To include unknown entries, use `looseObject`. To
1352
- * return an issue for unknown entries, use `strictObject`. To include and
1353
- * validate unknown entries, use `objectWithRest`.
1354
- *
1355
- * @param entries The entries schema.
1356
- *
1357
- * @returns An object schema.
1358
- */
1359
- declare function object<const TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries, undefined>;
1360
- /**
1361
- * Creates an object schema.
1362
- *
1363
- * Hint: This schema removes unknown entries. The output will only include the
1364
- * entries you specify. To include unknown entries, use `looseObject`. To
1365
- * return an issue for unknown entries, use `strictObject`. To include and
1366
- * validate unknown entries, use `objectWithRest`.
1367
- *
1368
- * @param entries The entries schema.
1369
- * @param message The error message.
1370
- *
1371
- * @returns An object schema.
1372
- */
1373
- declare function object<const TEntries extends ObjectEntries, const TMessage extends ErrorMessage<ObjectIssue> | undefined>(entries: TEntries, message: TMessage): ObjectSchema<TEntries, TMessage>;
1374
-
1375
- /**
1376
- * Object schema async interface.
1377
- */
1378
-
1379
- /**
1380
- * Infer optional output type.
1381
- */
1382
- type InferOptionalOutput<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> = undefined extends TDefault ? InferOutput<TWrapped> | undefined : InferOutput<TWrapped> | Extract<DefaultValue<TDefault>, undefined>;
1383
-
1384
- /**
1385
- * Optional schema interface.
1386
- */
1387
- interface OptionalSchema<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TDefault extends Default<TWrapped, undefined>> extends BaseSchema<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
1388
- /**
1389
- * The schema type.
1390
- */
1391
- readonly type: 'optional';
1392
- /**
1393
- * The schema reference.
1394
- */
1395
- readonly reference: typeof optional;
1396
- /**
1397
- * The expected property.
1398
- */
1399
- readonly expects: `(${TWrapped['expects']} | undefined)`;
1400
- /**
1401
- * The wrapped schema.
1402
- */
1403
- readonly wrapped: TWrapped;
1404
- /**
1405
- * The default value.
1406
- */
1407
- readonly default: TDefault;
1408
- }
1409
- /**
1410
- * Creates an optional schema.
1411
- *
1412
- * @param wrapped The wrapped schema.
1413
- *
1414
- * @returns An optional schema.
1415
- */
1416
- declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchema<TWrapped, undefined>;
1417
- /**
1418
- * Creates an optional schema.
1419
- *
1420
- * @param wrapped The wrapped schema.
1421
- * @param default_ The default value.
1422
- *
1423
- * @returns An optional schema.
1424
- */
1425
- declare function optional<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TDefault extends Default<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchema<TWrapped, TDefault>;
1426
-
1427
- /**
1428
- * Optional schema async interface.
1429
- */
1430
- interface OptionalSchemaAsync<TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TDefault extends DefaultAsync<TWrapped, undefined>> extends BaseSchemaAsync<InferInput<TWrapped> | undefined, InferOptionalOutput<TWrapped, TDefault>, InferIssue<TWrapped>> {
1431
- /**
1432
- * The schema type.
1433
- */
1434
- readonly type: 'optional';
1435
- /**
1436
- * The schema reference.
1437
- */
1438
- readonly reference: typeof optional | typeof optionalAsync;
1439
- /**
1440
- * The expected property.
1441
- */
1442
- readonly expects: `(${TWrapped['expects']} | undefined)`;
1443
- /**
1444
- * The wrapped schema.
1445
- */
1446
- readonly wrapped: TWrapped;
1447
- /**
1448
- * The default value.
1449
- */
1450
- readonly default: TDefault;
1451
- }
1452
- /**
1453
- * Creates an optional schema.
1454
- *
1455
- * @param wrapped The wrapped schema.
1456
- *
1457
- * @returns An optional schema.
1458
- */
1459
- declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(wrapped: TWrapped): OptionalSchemaAsync<TWrapped, undefined>;
1460
- /**
1461
- * Creates an optional schema.
1462
- *
1463
- * @param wrapped The wrapped schema.
1464
- * @param default_ The default value.
1465
- *
1466
- * @returns An optional schema.
1467
- */
1468
- declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, const TDefault extends DefaultAsync<TWrapped, undefined>>(wrapped: TWrapped, default_: TDefault): OptionalSchemaAsync<TWrapped, TDefault>;
1469
-
1470
- /**
1471
- * Picklist options type.
1472
- */
1473
-
1474
- /**
1475
- * String issue interface.
1476
- */
1477
- interface StringIssue extends BaseIssue<unknown> {
1478
- /**
1479
- * The issue kind.
1480
- */
1481
- readonly kind: 'schema';
1482
- /**
1483
- * The issue type.
1484
- */
1485
- readonly type: 'string';
1486
- /**
1487
- * The expected property.
1488
- */
1489
- readonly expected: 'string';
1490
- }
1491
- /**
1492
- * String schema interface.
1493
- */
1494
- interface StringSchema<TMessage extends ErrorMessage<StringIssue> | undefined> extends BaseSchema<string, string, StringIssue> {
1495
- /**
1496
- * The schema type.
1497
- */
1498
- readonly type: 'string';
1499
- /**
1500
- * The schema reference.
1501
- */
1502
- readonly reference: typeof string;
1503
- /**
1504
- * The expected property.
1505
- */
1506
- readonly expects: 'string';
1507
- /**
1508
- * The error message.
1509
- */
1510
- readonly message: TMessage;
1511
- }
1512
- /**
1513
- * Creates a string schema.
1514
- *
1515
- * @returns A string schema.
1516
- */
1517
- declare function string(): StringSchema<undefined>;
1518
- /**
1519
- * Creates a string schema.
1520
- *
1521
- * @param message The error message.
1522
- *
1523
- * @returns A string schema.
1524
- */
1525
- declare function string<const TMessage extends ErrorMessage<StringIssue> | undefined>(message: TMessage): StringSchema<TMessage>;
1526
-
1527
- /**
1528
- * Symbol issue interface.
1529
- */
1530
-
1531
- /**
1532
- * Readonly output type.
1533
- */
1534
- type ReadonlyOutput<TInput> = TInput extends Map<infer TKey, infer TValue> ? ReadonlyMap<TKey, TValue> : TInput extends Set<infer TValue> ? ReadonlySet<TValue> : Readonly<TInput>;
1535
- /**
1536
- * Readonly action interface.
1537
- */
1538
- interface ReadonlyAction<TInput> extends BaseTransformation<TInput, ReadonlyOutput<TInput>, never> {
1539
- /**
1540
- * The action type.
1541
- */
1542
- readonly type: 'readonly';
1543
- /**
1544
- * The action reference.
1545
- */
1546
- readonly reference: typeof readonly;
1547
- }
1548
- /**
1549
- * Creates a readonly transformation action.
1550
- *
1551
- * @returns A readonly action.
1552
- */
1553
- declare function readonly<TInput>(): ReadonlyAction<TInput>;
1554
-
1555
- /**
1556
- * Array action type.
1557
- */
1558
-
1559
- /**
1560
- * Regex issue interface.
1561
- */
1562
- interface RegexIssue<TInput extends string> extends BaseIssue<TInput> {
1563
- /**
1564
- * The issue kind.
1565
- */
1566
- readonly kind: 'validation';
1567
- /**
1568
- * The issue type.
1569
- */
1570
- readonly type: 'regex';
1571
- /**
1572
- * The expected input.
1573
- */
1574
- readonly expected: string;
1575
- /**
1576
- * The received input.
1577
- */
1578
- readonly received: `"${string}"`;
1579
- /**
1580
- * The regex pattern.
1581
- */
1582
- readonly requirement: RegExp;
1583
- }
1584
- /**
1585
- * Regex action interface.
1586
- */
1587
- interface RegexAction<TInput extends string, TMessage extends ErrorMessage<RegexIssue<TInput>> | undefined> extends BaseValidation<TInput, TInput, RegexIssue<TInput>> {
1588
- /**
1589
- * The action type.
1590
- */
1591
- readonly type: 'regex';
1592
- /**
1593
- * The action reference.
1594
- */
1595
- readonly reference: typeof regex;
1596
- /**
1597
- * The expected property.
1598
- */
1599
- readonly expects: string;
1600
- /**
1601
- * The regex pattern.
1602
- */
1603
- readonly requirement: RegExp;
1604
- /**
1605
- * The error message.
1606
- */
1607
- readonly message: TMessage;
1608
- }
1609
- /**
1610
- * Creates a [regex](https://en.wikipedia.org/wiki/Regular_expression) validation action.
1611
- *
1612
- * Hint: Be careful with the global flag `g` in your regex pattern, as it can lead to unexpected results. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test#using_test_on_a_regex_with_the_global_flag) for more information.
1613
- *
1614
- * @param requirement The regex pattern.
1615
- *
1616
- * @returns A regex action.
1617
- */
1618
- declare function regex<TInput extends string>(requirement: RegExp): RegexAction<TInput, undefined>;
1619
- /**
1620
- * Creates a [regex](https://en.wikipedia.org/wiki/Regular_expression) validation action.
1621
- *
1622
- * Hint: Be careful with the global flag `g` in your regex pattern, as it can lead to unexpected results. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test#using_test_on_a_regex_with_the_global_flag) for more information.
1623
- *
1624
- * @param requirement The regex pattern.
1625
- * @param message The error message.
1626
- *
1627
- * @returns A regex action.
1628
- */
1629
- declare function regex<TInput extends string, const TMessage extends ErrorMessage<RegexIssue<TInput>> | undefined>(requirement: RegExp, message: TMessage): RegexAction<TInput, TMessage>;
1630
-
1631
- /**
1632
- * Returns action type.
1633
- */
1634
- //#endregion
1635
- //#region src/types.internal.d.ts
1636
- /**
1637
- * Available cost calculation modes
1638
- * - auto: Use pre-calculated costs when available, otherwise calculate from tokens
1639
- * - calculate: Always calculate costs from token counts using model pricing
1640
- * - display: Always use pre-calculated costs, show 0 for missing costs
1641
- */
1642
- declare const CostModes: readonly ["auto", "calculate", "display"];
1643
- /**
1644
- * Union type for cost calculation modes
1645
- */
1646
- type CostMode = TupleToUnion<typeof CostModes>;
1647
- /**
1648
- * Available sort orders for data presentation
1649
- */
1650
- declare const SortOrders: readonly ["desc", "asc"];
1651
- /**
1652
- * Union type for sort order options
1653
- */
1654
- type SortOrder = TupleToUnion<typeof SortOrders>;
1655
- /**
1656
- * Valibot schema for model pricing information from LiteLLM
1657
- */
1658
- declare const modelPricingSchema: ObjectSchema<{
1659
- readonly input_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
1660
- readonly output_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
1661
- readonly cache_creation_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
1662
- readonly cache_read_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
1663
- }, undefined>;
1664
- /**
1665
- * Type definition for model pricing information
1666
- */
1667
- type ModelPricing = InferOutput<typeof modelPricingSchema>;
1668
- //#endregion
1669
- //#region src/pricing-fetcher.d.ts
1670
- /**
1671
- * Fetches and caches model pricing information from LiteLLM
1672
- * Implements Disposable pattern for automatic resource cleanup
1673
- */
1674
- declare class PricingFetcher implements Disposable {
1675
- private cachedPricing;
1676
- private readonly offline;
1677
- /**
1678
- * Creates a new PricingFetcher instance
1679
- * @param offline - Whether to use pre-fetched pricing data instead of fetching from API
1680
- */
1681
- constructor(offline?: boolean);
1682
- /**
1683
- * Implements Disposable interface for automatic cleanup
1684
- */
1685
- [Symbol.dispose](): void;
1686
- /**
1687
- * Clears the cached pricing data
1688
- */
1689
- clearCache(): void;
1690
- private ensurePricingLoaded;
1691
- /**
1692
- * Fetches all available model pricing data
1693
- * @returns Map of model names to pricing information
1694
- */
1695
- fetchModelPricing(): Promise<Map<string, ModelPricing>>;
1696
- /**
1697
- * Gets pricing information for a specific model with fallback matching
1698
- * Tries exact match first, then provider prefixes, then partial matches
1699
- * @param modelName - Name of the model to get pricing for
1700
- * @returns Model pricing information or null if not found
1701
- */
1702
- getModelPricing(modelName: string): Promise<ModelPricing | null>;
1703
- /**
1704
- * Calculates the cost for given token usage and model
1705
- * @param tokens - Token usage breakdown
1706
- * @param tokens.input_tokens - Number of input tokens
1707
- * @param tokens.output_tokens - Number of output tokens
1708
- * @param tokens.cache_creation_input_tokens - Number of cache creation tokens
1709
- * @param tokens.cache_read_input_tokens - Number of cache read tokens
1710
- * @param modelName - Name of the model used
1711
- * @returns Total cost in USD
1712
- */
1713
- calculateCostFromTokens(tokens: {
1714
- input_tokens: number;
1715
- output_tokens: number;
1716
- cache_creation_input_tokens?: number;
1717
- cache_read_input_tokens?: number;
1718
- }, modelName: string): Promise<number>;
1719
- /**
1720
- * Calculates cost from token usage and pricing information
1721
- * @param tokens - Token usage breakdown
1722
- * @param tokens.input_tokens - Number of input tokens
1723
- * @param tokens.output_tokens - Number of output tokens
1724
- * @param tokens.cache_creation_input_tokens - Number of cache creation tokens
1725
- * @param tokens.cache_read_input_tokens - Number of cache read tokens
1726
- * @param pricing - Model pricing rates
1727
- * @returns Total cost in USD
1728
- */
1729
- calculateCostFromPricing(tokens: {
1730
- input_tokens: number;
1731
- output_tokens: number;
1732
- cache_creation_input_tokens?: number;
1733
- cache_read_input_tokens?: number;
1734
- }, pricing: ModelPricing): number;
1735
- }
1736
- //#endregion
1737
- export { ArraySchema, CostMode, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, SortOrder, StringSchema };