@sinclair/typebox 0.32.11 → 0.32.12
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.
- package/build/import/type/array/array.d.mts +5 -2
- package/build/import/type/array/array.mjs +1 -1
- package/build/import/type/record/record.d.mts +3 -1
- package/build/import/type/type/json.mjs +1 -1
- package/build/require/type/array/array.d.ts +5 -2
- package/build/require/type/array/array.js +1 -1
- package/build/require/type/record/record.d.ts +3 -1
- package/build/require/type/type/json.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Ensure } from '../helpers/index.mjs';
|
|
2
|
+
import type { SchemaOptions, TSchema } from '../schema/index.mjs';
|
|
2
3
|
import type { Static } from '../static/index.mjs';
|
|
3
4
|
import { Kind } from '../symbols/index.mjs';
|
|
4
5
|
export interface ArrayOptions extends SchemaOptions {
|
|
@@ -15,11 +16,13 @@ export interface ArrayOptions extends SchemaOptions {
|
|
|
15
16
|
/** A maximum number of contains schema matches */
|
|
16
17
|
maxContains?: number;
|
|
17
18
|
}
|
|
19
|
+
type ArrayStatic<T extends TSchema, P extends unknown[]> = Ensure<Static<T, P>[]>;
|
|
18
20
|
export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
19
21
|
[Kind]: 'Array';
|
|
20
|
-
static:
|
|
22
|
+
static: ArrayStatic<T, this['params']>;
|
|
21
23
|
type: 'array';
|
|
22
24
|
items: T;
|
|
23
25
|
}
|
|
24
26
|
/** `[Json]` Creates an Array type */
|
|
25
27
|
export declare function Array<T extends TSchema>(schema: T, options?: ArrayOptions): TArray<T>;
|
|
28
|
+
export {};
|
|
@@ -35,7 +35,9 @@ type TFromRegExpKey<_ extends TRegExp, T extends TSchema> = (Ensure<TRecord<TReg
|
|
|
35
35
|
type TFromStringKey<_ extends TString, T extends TSchema> = (Ensure<TRecord<TString, T>>);
|
|
36
36
|
type TFromIntegerKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
|
|
37
37
|
type TFromNumberKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
|
|
38
|
-
type RecordStatic<K extends TSchema, T extends TSchema, P extends unknown[]> = (Evaluate<
|
|
38
|
+
type RecordStatic<K extends TSchema, T extends TSchema, P extends unknown[]> = (Evaluate<{
|
|
39
|
+
[_ in Assert<Static<K>, PropertyKey>]: Static<T, P>;
|
|
40
|
+
}>);
|
|
39
41
|
export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
|
|
40
42
|
[Kind]: 'Record';
|
|
41
43
|
static: RecordStatic<K, T, this['params']>;
|
|
@@ -172,7 +172,7 @@ export class JsonTypeBuilder {
|
|
|
172
172
|
}
|
|
173
173
|
/** `[Json]` Creates a Record type */
|
|
174
174
|
Record(key, schema, options = {}) {
|
|
175
|
-
return Record(key, schema);
|
|
175
|
+
return Record(key, schema, options);
|
|
176
176
|
}
|
|
177
177
|
/** `[Json]` Creates a Recursive type */
|
|
178
178
|
Recursive(callback, options = {}) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Ensure } from '../helpers/index';
|
|
2
|
+
import type { SchemaOptions, TSchema } from '../schema/index';
|
|
2
3
|
import type { Static } from '../static/index';
|
|
3
4
|
import { Kind } from '../symbols/index';
|
|
4
5
|
export interface ArrayOptions extends SchemaOptions {
|
|
@@ -15,11 +16,13 @@ export interface ArrayOptions extends SchemaOptions {
|
|
|
15
16
|
/** A maximum number of contains schema matches */
|
|
16
17
|
maxContains?: number;
|
|
17
18
|
}
|
|
19
|
+
type ArrayStatic<T extends TSchema, P extends unknown[]> = Ensure<Static<T, P>[]>;
|
|
18
20
|
export interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
19
21
|
[Kind]: 'Array';
|
|
20
|
-
static:
|
|
22
|
+
static: ArrayStatic<T, this['params']>;
|
|
21
23
|
type: 'array';
|
|
22
24
|
items: T;
|
|
23
25
|
}
|
|
24
26
|
/** `[Json]` Creates an Array type */
|
|
25
27
|
export declare function Array<T extends TSchema>(schema: T, options?: ArrayOptions): TArray<T>;
|
|
28
|
+
export {};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Array = void 0;
|
|
5
|
-
const index_1 = require("../symbols/index");
|
|
6
5
|
const type_1 = require("../clone/type");
|
|
6
|
+
const index_1 = require("../symbols/index");
|
|
7
7
|
/** `[Json]` Creates an Array type */
|
|
8
8
|
function Array(schema, options = {}) {
|
|
9
9
|
return {
|
|
@@ -35,7 +35,9 @@ type TFromRegExpKey<_ extends TRegExp, T extends TSchema> = (Ensure<TRecord<TReg
|
|
|
35
35
|
type TFromStringKey<_ extends TString, T extends TSchema> = (Ensure<TRecord<TString, T>>);
|
|
36
36
|
type TFromIntegerKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
|
|
37
37
|
type TFromNumberKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
|
|
38
|
-
type RecordStatic<K extends TSchema, T extends TSchema, P extends unknown[]> = (Evaluate<
|
|
38
|
+
type RecordStatic<K extends TSchema, T extends TSchema, P extends unknown[]> = (Evaluate<{
|
|
39
|
+
[_ in Assert<Static<K>, PropertyKey>]: Static<T, P>;
|
|
40
|
+
}>);
|
|
39
41
|
export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
|
|
40
42
|
[Kind]: 'Record';
|
|
41
43
|
static: RecordStatic<K, T, this['params']>;
|
|
@@ -176,7 +176,7 @@ class JsonTypeBuilder {
|
|
|
176
176
|
}
|
|
177
177
|
/** `[Json]` Creates a Record type */
|
|
178
178
|
Record(key, schema, options = {}) {
|
|
179
|
-
return (0, index_29.Record)(key, schema);
|
|
179
|
+
return (0, index_29.Record)(key, schema, options);
|
|
180
180
|
}
|
|
181
181
|
/** `[Json]` Creates a Recursive type */
|
|
182
182
|
Recursive(callback, options = {}) {
|