@sinclair/typebox 0.34.12 → 0.34.13
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/cjs/type/ref/ref.d.ts +19 -6
- package/build/cjs/type/type/json.d.ts +19 -6
- package/build/cjs/value/convert/convert.js +1 -1
- package/build/esm/type/ref/ref.d.mts +19 -6
- package/build/esm/type/type/json.d.mts +19 -6
- package/build/esm/value/convert/convert.mjs +1 -1
- package/package.json +1 -1
|
@@ -11,18 +11,31 @@ export type TRefUnsafe<Type extends TSchema> = TUnsafe<Static<Type>>;
|
|
|
11
11
|
/** `[Json]` Creates a Ref type.*/
|
|
12
12
|
export declare function Ref<Ref extends string>($ref: Ref, options?: SchemaOptions): TRef<Ref>;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated `[Json]` Creates a Ref type.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass
|
|
15
|
+
* a `string` value for the reference (and not a schema).
|
|
16
|
+
*
|
|
17
|
+
* To adhere to the 0.34.0 signature, Ref implementations should be updated to the following.
|
|
18
18
|
*
|
|
19
19
|
* ```typescript
|
|
20
|
+
* // pre-0.34.0
|
|
21
|
+
*
|
|
22
|
+
* const T = Type.String({ $id: 'T' })
|
|
23
|
+
*
|
|
20
24
|
* const R = Type.Ref(T)
|
|
21
25
|
* ```
|
|
22
|
-
* to
|
|
26
|
+
* should be changed to the following
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // post-0.34.0
|
|
30
|
+
*
|
|
31
|
+
* const T = Type.String({ $id: 'T' })
|
|
32
|
+
*
|
|
33
|
+
* const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T'))
|
|
34
|
+
* ```
|
|
35
|
+
* You can also create a generic function to replicate the pre-0.34.0 signature if required
|
|
23
36
|
*
|
|
24
37
|
* ```typescript
|
|
25
|
-
* const
|
|
38
|
+
* const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!))
|
|
26
39
|
* ```
|
|
27
40
|
*/
|
|
28
41
|
export declare function Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>;
|
|
@@ -151,18 +151,31 @@ export declare class JsonTypeBuilder {
|
|
|
151
151
|
/** `[Json]` Creates a Ref type.*/
|
|
152
152
|
Ref<Ref extends string>($ref: Ref, options?: SchemaOptions): TRef<Ref>;
|
|
153
153
|
/**
|
|
154
|
-
* @deprecated `[Json]` Creates a Ref type.
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
154
|
+
* @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass
|
|
155
|
+
* a `string` value for the reference (and not a schema).
|
|
156
|
+
*
|
|
157
|
+
* To adhere to the 0.34.0 signature, Ref implementations should be updated to the following.
|
|
158
158
|
*
|
|
159
159
|
* ```typescript
|
|
160
|
+
* // pre-0.34.0
|
|
161
|
+
*
|
|
162
|
+
* const T = Type.String({ $id: 'T' })
|
|
163
|
+
*
|
|
160
164
|
* const R = Type.Ref(T)
|
|
161
165
|
* ```
|
|
162
|
-
* to
|
|
166
|
+
* should be changed to the following
|
|
167
|
+
*
|
|
168
|
+
* ```typescript
|
|
169
|
+
* // post-0.34.0
|
|
170
|
+
*
|
|
171
|
+
* const T = Type.String({ $id: 'T' })
|
|
172
|
+
*
|
|
173
|
+
* const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T'))
|
|
174
|
+
* ```
|
|
175
|
+
* You can also create a generic function to replicate the pre-0.34.0 signature if required
|
|
163
176
|
*
|
|
164
177
|
* ```typescript
|
|
165
|
-
* const
|
|
178
|
+
* const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!))
|
|
166
179
|
* ```
|
|
167
180
|
*/
|
|
168
181
|
Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>;
|
|
@@ -70,7 +70,7 @@ function TryConvertBigInt(value) {
|
|
|
70
70
|
return IsStringNumeric(value) ? BigInt(truncateInteger(value)) : (0, index_5.IsNumber)(value) ? BigInt(Math.trunc(value)) : IsValueFalse(value) ? BigInt(0) : IsValueTrue(value) ? BigInt(1) : value;
|
|
71
71
|
}
|
|
72
72
|
function TryConvertString(value) {
|
|
73
|
-
return
|
|
73
|
+
return (0, index_5.IsSymbol)(value) && value.description !== undefined ? value.description.toString() : IsValueToString(value) ? value.toString() : value;
|
|
74
74
|
}
|
|
75
75
|
function TryConvertNumber(value) {
|
|
76
76
|
return IsStringNumeric(value) ? parseFloat(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|
|
@@ -11,18 +11,31 @@ export type TRefUnsafe<Type extends TSchema> = TUnsafe<Static<Type>>;
|
|
|
11
11
|
/** `[Json]` Creates a Ref type.*/
|
|
12
12
|
export declare function Ref<Ref extends string>($ref: Ref, options?: SchemaOptions): TRef<Ref>;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated `[Json]` Creates a Ref type.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass
|
|
15
|
+
* a `string` value for the reference (and not a schema).
|
|
16
|
+
*
|
|
17
|
+
* To adhere to the 0.34.0 signature, Ref implementations should be updated to the following.
|
|
18
18
|
*
|
|
19
19
|
* ```typescript
|
|
20
|
+
* // pre-0.34.0
|
|
21
|
+
*
|
|
22
|
+
* const T = Type.String({ $id: 'T' })
|
|
23
|
+
*
|
|
20
24
|
* const R = Type.Ref(T)
|
|
21
25
|
* ```
|
|
22
|
-
* to
|
|
26
|
+
* should be changed to the following
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // post-0.34.0
|
|
30
|
+
*
|
|
31
|
+
* const T = Type.String({ $id: 'T' })
|
|
32
|
+
*
|
|
33
|
+
* const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T'))
|
|
34
|
+
* ```
|
|
35
|
+
* You can also create a generic function to replicate the pre-0.34.0 signature if required
|
|
23
36
|
*
|
|
24
37
|
* ```typescript
|
|
25
|
-
* const
|
|
38
|
+
* const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!))
|
|
26
39
|
* ```
|
|
27
40
|
*/
|
|
28
41
|
export declare function Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>;
|
|
@@ -151,18 +151,31 @@ export declare class JsonTypeBuilder {
|
|
|
151
151
|
/** `[Json]` Creates a Ref type.*/
|
|
152
152
|
Ref<Ref extends string>($ref: Ref, options?: SchemaOptions): TRef<Ref>;
|
|
153
153
|
/**
|
|
154
|
-
* @deprecated `[Json]` Creates a Ref type.
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
154
|
+
* @deprecated `[Json]` Creates a Ref type. This signature was deprecated in 0.34.0 where Ref requires callers to pass
|
|
155
|
+
* a `string` value for the reference (and not a schema).
|
|
156
|
+
*
|
|
157
|
+
* To adhere to the 0.34.0 signature, Ref implementations should be updated to the following.
|
|
158
158
|
*
|
|
159
159
|
* ```typescript
|
|
160
|
+
* // pre-0.34.0
|
|
161
|
+
*
|
|
162
|
+
* const T = Type.String({ $id: 'T' })
|
|
163
|
+
*
|
|
160
164
|
* const R = Type.Ref(T)
|
|
161
165
|
* ```
|
|
162
|
-
* to
|
|
166
|
+
* should be changed to the following
|
|
167
|
+
*
|
|
168
|
+
* ```typescript
|
|
169
|
+
* // post-0.34.0
|
|
170
|
+
*
|
|
171
|
+
* const T = Type.String({ $id: 'T' })
|
|
172
|
+
*
|
|
173
|
+
* const R = Type.Unsafe<Static<typeof T>>(Type.Ref('T'))
|
|
174
|
+
* ```
|
|
175
|
+
* You can also create a generic function to replicate the pre-0.34.0 signature if required
|
|
163
176
|
*
|
|
164
177
|
* ```typescript
|
|
165
|
-
* const
|
|
178
|
+
* const LegacyRef = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T>>(Type.Ref(schema.$id!))
|
|
166
179
|
* ```
|
|
167
180
|
*/
|
|
168
181
|
Ref<Type extends TSchema>(type: Type, options?: SchemaOptions): TRefUnsafe<Type>;
|
|
@@ -66,7 +66,7 @@ function TryConvertBigInt(value) {
|
|
|
66
66
|
return IsStringNumeric(value) ? BigInt(truncateInteger(value)) : IsNumber(value) ? BigInt(Math.trunc(value)) : IsValueFalse(value) ? BigInt(0) : IsValueTrue(value) ? BigInt(1) : value;
|
|
67
67
|
}
|
|
68
68
|
function TryConvertString(value) {
|
|
69
|
-
return
|
|
69
|
+
return IsSymbol(value) && value.description !== undefined ? value.description.toString() : IsValueToString(value) ? value.toString() : value;
|
|
70
70
|
}
|
|
71
71
|
function TryConvertNumber(value) {
|
|
72
72
|
return IsStringNumeric(value) ? parseFloat(value) : IsValueTrue(value) ? 1 : IsValueFalse(value) ? 0 : value;
|