typebox 1.1.27 → 1.1.29
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/schema/engine/_refine.mjs +4 -4
- package/build/schema/types/_refine.d.mts +2 -2
- package/build/schema/types/_refine.mjs +4 -4
- package/build/type/action/awaited.d.mts +2 -2
- package/build/type/action/awaited.mjs +2 -3
- package/build/type/action/capitalize.d.mts +2 -2
- package/build/type/action/capitalize.mjs +2 -3
- package/build/type/action/conditional.d.mts +4 -2
- package/build/type/action/conditional.mjs +2 -2
- package/build/type/action/constructor-parameters.d.mts +2 -2
- package/build/type/action/constructor-parameters.mjs +2 -3
- package/build/type/action/evaluate.d.mts +2 -2
- package/build/type/action/evaluate.mjs +2 -3
- package/build/type/action/exclude.d.mts +2 -2
- package/build/type/action/exclude.mjs +2 -3
- package/build/type/action/extract.d.mts +2 -2
- package/build/type/action/extract.mjs +2 -3
- package/build/type/action/index.d.mts +1 -1
- package/build/type/action/index.mjs +1 -1
- package/build/type/action/indexed.d.mts +2 -2
- package/build/type/action/indexed.mjs +2 -3
- package/build/type/action/instance-type.d.mts +2 -2
- package/build/type/action/instance-type.mjs +2 -3
- package/build/type/action/interface.d.mts +2 -2
- package/build/type/action/interface.mjs +5 -3
- package/build/type/action/keyof.d.mts +2 -2
- package/build/type/action/keyof.mjs +2 -3
- package/build/type/action/lowercase.d.mts +2 -2
- package/build/type/action/lowercase.mjs +2 -3
- package/build/type/action/mapped.d.mts +4 -2
- package/build/type/action/mapped.mjs +2 -2
- package/build/type/action/non-nullable.d.mts +2 -2
- package/build/type/action/non-nullable.mjs +2 -3
- package/build/type/action/omit.d.mts +2 -2
- package/build/type/action/omit.mjs +2 -3
- package/build/type/action/options.d.mts +4 -5
- package/build/type/action/options.mjs +3 -4
- package/build/type/action/parameters.d.mts +2 -2
- package/build/type/action/parameters.mjs +2 -3
- package/build/type/action/partial.d.mts +3 -3
- package/build/type/action/partial.mjs +2 -3
- package/build/type/action/pick.d.mts +2 -2
- package/build/type/action/pick.mjs +2 -3
- package/build/type/action/readonly-object.d.mts +16 -0
- package/build/type/action/readonly-object.mjs +16 -0
- package/build/type/action/required.d.mts +2 -2
- package/build/type/action/required.mjs +2 -3
- package/build/type/action/return-type.d.mts +2 -2
- package/build/type/action/return-type.mjs +2 -3
- package/build/type/action/uncapitalize.d.mts +2 -2
- package/build/type/action/uncapitalize.mjs +2 -3
- package/build/type/action/uppercase.d.mts +2 -2
- package/build/type/action/uppercase.mjs +2 -3
- package/build/type/engine/awaited/instantiate.d.mts +4 -3
- package/build/type/engine/awaited/instantiate.mjs +9 -8
- package/build/type/engine/conditional/instantiate.d.mts +4 -2
- package/build/type/engine/conditional/instantiate.mjs +13 -9
- package/build/type/engine/constructor-parameters/instantiate.d.mts +6 -5
- package/build/type/engine/constructor-parameters/instantiate.mjs +13 -11
- package/build/type/engine/evaluate/instantiate.d.mts +3 -3
- package/build/type/engine/evaluate/instantiate.mjs +5 -10
- package/build/type/engine/exclude/instantiate.d.mts +4 -11
- package/build/type/engine/exclude/instantiate.mjs +7 -28
- package/build/type/engine/exclude/operation.d.mts +11 -0
- package/build/type/engine/exclude/operation.mjs +24 -0
- package/build/type/engine/extract/instantiate.d.mts +4 -11
- package/build/type/engine/extract/instantiate.mjs +7 -28
- package/build/type/engine/extract/operation.d.mts +11 -0
- package/build/type/engine/extract/operation.mjs +24 -0
- package/build/type/engine/index.d.mts +1 -1
- package/build/type/engine/index.mjs +1 -1
- package/build/type/engine/indexed/from-object.d.mts +7 -2
- package/build/type/engine/indexed/from-object.mjs +24 -5
- package/build/type/engine/indexed/from-type.d.mts +11 -0
- package/build/type/engine/indexed/from-type.mjs +14 -0
- package/build/type/engine/indexed/instantiate.d.mts +5 -11
- package/build/type/engine/indexed/instantiate.mjs +8 -20
- package/build/type/engine/instance-type/instantiate.d.mts +4 -4
- package/build/type/engine/instance-type/instantiate.mjs +9 -8
- package/build/type/engine/instantiate.d.mts +4 -6
- package/build/type/engine/instantiate.mjs +9 -18
- package/build/type/engine/interface/instantiate.d.mts +6 -4
- package/build/type/engine/interface/instantiate.mjs +12 -8
- package/build/type/engine/intrinsics/instantiate.d.mts +12 -8
- package/build/type/engine/intrinsics/instantiate.mjs +28 -24
- package/build/type/engine/keyof/from-type.d.mts +15 -0
- package/build/type/engine/keyof/from-type.mjs +23 -0
- package/build/type/engine/keyof/instantiate.d.mts +4 -16
- package/build/type/engine/keyof/instantiate.mjs +8 -28
- package/build/type/engine/mapped/instantiate.d.mts +4 -19
- package/build/type/engine/mapped/instantiate.mjs +7 -42
- package/build/type/engine/mapped/mapped-operation.d.mts +22 -0
- package/build/type/engine/mapped/mapped-operation.mjs +42 -0
- package/build/type/engine/mapped/mapped-variants.d.mts +3 -2
- package/build/type/engine/mapped/mapped-variants.mjs +7 -2
- package/build/type/engine/non-nullable/instantiate.d.mts +5 -6
- package/build/type/engine/non-nullable/instantiate.mjs +10 -10
- package/build/type/engine/omit/from-type.d.mts +12 -0
- package/build/type/engine/omit/from-type.mjs +18 -0
- package/build/type/engine/omit/instantiate.d.mts +4 -11
- package/build/type/engine/omit/instantiate.mjs +7 -22
- package/build/type/engine/options/instantiate.d.mts +4 -4
- package/build/type/engine/options/instantiate.mjs +8 -7
- package/build/type/engine/parameters/instantiate.d.mts +6 -5
- package/build/type/engine/parameters/instantiate.mjs +13 -11
- package/build/type/engine/partial/instantiate.d.mts +3 -3
- package/build/type/engine/partial/instantiate.mjs +7 -6
- package/build/type/engine/pick/from-type.d.mts +13 -0
- package/build/type/engine/pick/from-type.mjs +20 -0
- package/build/type/engine/pick/instantiate.d.mts +4 -12
- package/build/type/engine/pick/instantiate.mjs +7 -23
- package/build/type/engine/readonly-object/instantiate.d.mts +9 -0
- package/build/type/engine/readonly-object/instantiate.mjs +15 -0
- package/build/type/engine/record/instantiate.d.mts +3 -3
- package/build/type/engine/record/instantiate.mjs +8 -7
- package/build/type/engine/required/instantiate.d.mts +3 -3
- package/build/type/engine/required/instantiate.mjs +7 -6
- package/build/type/engine/return-type/instantiate.d.mts +5 -4
- package/build/type/engine/return-type/instantiate.mjs +12 -9
- package/build/type/engine/template-literal/encode.d.mts +4 -2
- package/build/type/engine/template-literal/encode.mjs +10 -3
- package/build/type/engine/template-literal/instantiate.d.mts +3 -3
- package/build/type/engine/template-literal/instantiate.mjs +7 -6
- package/build/type/extends/extends.d.mts +4 -2
- package/build/type/extends/extends.mjs +9 -7
- package/build/type/script/mapping.d.mts +1 -1
- package/build/type/script/mapping.mjs +1 -1
- package/build/type/types/_refine.d.mts +13 -6
- package/build/type/types/_refine.mjs +21 -4
- package/build/type/types/promise.d.mts +2 -1
- package/build/type/types/promise.mjs +2 -1
- package/build/type/types/properties.d.mts +2 -1
- package/build/type/types/record.d.mts +3 -5
- package/build/type/types/record.mjs +2 -6
- package/build/type/types/template-literal.d.mts +5 -3
- package/build/type/types/template-literal.mjs +10 -4
- package/build/type/types/unsafe.d.mts +1 -2
- package/build/type/types/unsafe.mjs +5 -3
- package/build/typebox.d.mts +4 -4
- package/build/typebox.mjs +2 -2
- package/build/value/mutate/mutate.d.mts +2 -0
- package/build/value/mutate/mutate.mjs +2 -0
- package/package.json +1 -1
- package/build/type/action/readonly-type.d.mts +0 -11
- package/build/type/action/readonly-type.mjs +0 -12
- package/build/type/engine/readonly-type/instantiate.d.mts +0 -9
- package/build/type/engine/readonly-type/instantiate.mjs +0 -14
- /package/build/type/engine/{readonly-type → readonly-object}/from-array.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-array.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-cyclic.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-cyclic.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-intersect.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-intersect.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-object.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-object.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-tuple.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-tuple.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-type.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-type.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-union.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/from-union.mjs +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/index.d.mts +0 -0
- /package/build/type/engine/{readonly-type → readonly-object}/index.mjs +0 -0
|
@@ -9,7 +9,8 @@ export interface TPromise<Type extends TSchema = TSchema> extends TSchema {
|
|
|
9
9
|
item: Type;
|
|
10
10
|
}
|
|
11
11
|
/** Creates a Promise type. */
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function _Promise_<Type extends TSchema>(item: Type, options?: TSchemaOptions): TPromise<Type>;
|
|
13
|
+
export { _Promise_ as Promise };
|
|
13
14
|
/** Returns true if the given type is TPromise. */
|
|
14
15
|
export declare function IsPromise(value: unknown): value is TPromise;
|
|
15
16
|
/** Extracts options from a TPromise. */
|
|
@@ -5,9 +5,10 @@ import { IsKind } from './schema.mjs';
|
|
|
5
5
|
// Factory
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
/** Creates a Promise type. */
|
|
8
|
-
export function
|
|
8
|
+
export function _Promise_(item, options) {
|
|
9
9
|
return Memory.Create({ ['~kind']: 'Promise' }, { type: 'promise', item }, options);
|
|
10
10
|
}
|
|
11
|
+
export { _Promise_ as Promise };
|
|
11
12
|
// ------------------------------------------------------------------
|
|
12
13
|
// Guard
|
|
13
14
|
// ------------------------------------------------------------------
|
|
@@ -30,8 +30,9 @@ export type TRequiredArray<Properties extends TProperties, RequiredProperties ex
|
|
|
30
30
|
}, RequiredKeys extends string[] = TUnionToTuple<Extract<keyof RequiredProperties, string>>, Result extends string[] | undefined = RequiredKeys extends [] ? undefined : RequiredKeys> = Result;
|
|
31
31
|
/** Creates a RequiredArray derived from the given TProperties value. */
|
|
32
32
|
export declare function RequiredArray<Properties extends TProperties>(properties: Properties): TRequiredArray<Properties>;
|
|
33
|
+
type TKeyToString<Key extends number | string> = `${Key}`;
|
|
33
34
|
/** Extracts a tuple of keys from a TProperties value. */
|
|
34
|
-
export type TPropertyKeys<Properties extends TProperties,
|
|
35
|
+
export type TPropertyKeys<Properties extends TProperties, ExtractKey extends number | string = Extract<keyof Properties, number | string>, StringKey extends string = TKeyToString<ExtractKey>, Result extends string[] = TUnionToTuple<StringKey>> = Result;
|
|
35
36
|
/** Extracts a tuple of keys from a TProperties value. */
|
|
36
37
|
export declare function PropertyKeys<Properties extends TProperties>(properties: Properties): TPropertyKeys<Properties>;
|
|
37
38
|
type TPropertyValuesReduce<Properties extends TProperties, Keys extends string[], Result extends TSchema[] = []> = Keys extends [infer Left extends string, ...infer Right extends string[]] ? Left extends keyof Properties ? TPropertyValuesReduce<Properties, Right, [...Result, Properties[Left]]> : TPropertyValuesReduce<Properties, Right, Result> : Result;
|
|
@@ -5,9 +5,9 @@ import { type TInteger } from './integer.mjs';
|
|
|
5
5
|
import { type TNumber } from './number.mjs';
|
|
6
6
|
import { type TString } from './string.mjs';
|
|
7
7
|
import { type TDeferred } from './deferred.mjs';
|
|
8
|
-
import { type TInstantiate } from '../engine/instantiate.mjs';
|
|
9
8
|
import { type TTemplateLiteralStatic } from '../engine/template-literal/index.mjs';
|
|
10
9
|
import { type TTemplateLiteralDecodeUnsafe } from '../engine/template-literal/decode.mjs';
|
|
10
|
+
import { type TRecordAction } from '../engine/record/instantiate.mjs';
|
|
11
11
|
type StaticPropertyKey<Key extends string, Result extends PropertyKey = (Key extends TStringKey ? string : Key extends TIntegerKey ? number : Key extends TNumberKey ? number : Key extends `^${string}$` ? TTemplateLiteralStatic<Key> : string)> = Result;
|
|
12
12
|
export type StaticRecord<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Key extends string, Value extends TSchema, StaticKey extends PropertyKey = StaticPropertyKey<Key>, StaticValue extends unknown = StaticType<Stack, Direction, Context, This, Value>, Result extends Record<PropertyKey, unknown> = Record<StaticKey, StaticValue>> = Result;
|
|
13
13
|
export type TStringKey = typeof StringKey;
|
|
@@ -24,13 +24,11 @@ export interface TRecord<Key extends string = string, Value extends TSchema = TS
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
/** Represents a deferred Record action. */
|
|
27
|
-
export type TRecordDeferred<Key extends TSchema, Value extends TSchema> = (TDeferred<'Record', [Key, Value]>);
|
|
27
|
+
export type TRecordDeferred<Key extends TSchema = TSchema, Value extends TSchema = TSchema> = (TDeferred<'Record', [Key, Value]>);
|
|
28
28
|
/** Represents a deferred Record action. */
|
|
29
29
|
export declare function RecordDeferred<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions): TRecordDeferred<Key, Value>;
|
|
30
|
-
export type TRecordConstruct<Key extends TSchema, Value extends TSchema> = (TInstantiate<{}, TRecordDeferred<Key, Value>>);
|
|
31
|
-
export declare function RecordConstruct<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions): TRecordConstruct<Key, Value>;
|
|
32
30
|
/** Creates a Record type. */
|
|
33
|
-
export declare function Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions):
|
|
31
|
+
export declare function Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions): TRecordAction<Key, Value>;
|
|
34
32
|
/** Creates a Record type from regular expression pattern. */
|
|
35
33
|
export declare function RecordFromPattern<Pattern extends string, Value extends TSchema>(key: Pattern, value: Value): TRecord<Pattern, Value>;
|
|
36
34
|
/** Returns the raw string pattern used for the Record key */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// deno-lint-ignore-file ban-types
|
|
2
1
|
// deno-fmt-ignore-file
|
|
3
2
|
import { Memory } from '../../system/memory/index.mjs';
|
|
4
3
|
import { Guard } from '../../guard/index.mjs';
|
|
@@ -7,9 +6,9 @@ import { Integer, IntegerPattern } from './integer.mjs';
|
|
|
7
6
|
import { Number, NumberPattern } from './number.mjs';
|
|
8
7
|
import { String, StringPattern } from './string.mjs';
|
|
9
8
|
import { Deferred } from './deferred.mjs';
|
|
10
|
-
import { Instantiate } from '../engine/instantiate.mjs';
|
|
11
9
|
import { TemplateLiteralDecodeUnsafe } from '../engine/template-literal/decode.mjs';
|
|
12
10
|
import { CreateRecord } from '../engine/record/record-create.mjs';
|
|
11
|
+
import { RecordAction } from '../engine/record/instantiate.mjs';
|
|
13
12
|
export const IntegerKey = `^${IntegerPattern}$`;
|
|
14
13
|
export const NumberKey = `^${NumberPattern}$`;
|
|
15
14
|
export const StringKey = `^${StringPattern}$`;
|
|
@@ -17,15 +16,12 @@ export const StringKey = `^${StringPattern}$`;
|
|
|
17
16
|
export function RecordDeferred(key, value, options = {}) {
|
|
18
17
|
return Deferred('Record', [key, value], options);
|
|
19
18
|
}
|
|
20
|
-
export function RecordConstruct(key, value, options = {}) {
|
|
21
|
-
return Instantiate({}, RecordDeferred(key, value, options));
|
|
22
|
-
}
|
|
23
19
|
// -------------------------------------------------------------------
|
|
24
20
|
// Factory
|
|
25
21
|
// -------------------------------------------------------------------
|
|
26
22
|
/** Creates a Record type. */
|
|
27
23
|
export function Record(key, value, options = {}) {
|
|
28
|
-
return
|
|
24
|
+
return RecordAction(key, value, options);
|
|
29
25
|
}
|
|
30
26
|
// -------------------------------------------------------------------
|
|
31
27
|
// FromPattern
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from './schema.mjs';
|
|
2
2
|
import { type TDeferred } from './deferred.mjs';
|
|
3
3
|
import { type TParseTemplateIntoTypes } from '../engine/patterns/template.mjs';
|
|
4
|
-
import { type TInstantiate } from '../engine/instantiate.mjs';
|
|
5
4
|
import { type TTemplateLiteralStatic } from '../engine/template-literal/static.mjs';
|
|
5
|
+
import { type TTemplateLiteralAction } from '../engine/template-literal/instantiate.mjs';
|
|
6
6
|
export type StaticTemplateLiteral<Pattern extends string> = (TTemplateLiteralStatic<Pattern>);
|
|
7
7
|
/** Represents a TemplateLiteral type. */
|
|
8
8
|
export interface TTemplateLiteral<Pattern extends string = string> extends TSchema {
|
|
@@ -11,10 +11,12 @@ export interface TTemplateLiteral<Pattern extends string = string> extends TSche
|
|
|
11
11
|
pattern: Pattern;
|
|
12
12
|
}
|
|
13
13
|
/** Creates a deferred TemplateLiteral action. */
|
|
14
|
-
export type TTemplateLiteralDeferred<Types extends TSchema[]> = (TDeferred<'TemplateLiteral', [Types]>);
|
|
14
|
+
export type TTemplateLiteralDeferred<Types extends TSchema[] = TSchema[]> = (TDeferred<'TemplateLiteral', [Types]>);
|
|
15
15
|
/** Creates a deferred TemplateLiteral action. */
|
|
16
16
|
export declare function TemplateLiteralDeferred<Types extends TSchema[]>(types: [...Types], options?: TSchemaOptions): TTemplateLiteralDeferred<Types>;
|
|
17
|
-
|
|
17
|
+
/** Returns true if this value is a deferred Interface action. */
|
|
18
|
+
export declare function IsTemplateLiteralDeferred(value: unknown): value is TTemplateLiteralDeferred;
|
|
19
|
+
export type TTemplateLiteralFromTypes<Types extends TSchema[], Result extends TSchema = TTemplateLiteralAction<Types>> = Result;
|
|
18
20
|
export declare function TemplateLiteralFromTypes<Types extends TSchema[]>(types: [...Types]): TTemplateLiteralFromTypes<Types>;
|
|
19
21
|
export type TTemplateLiteralFromString<Template extends string, Types extends TSchema[] = TParseTemplateIntoTypes<Template>, Result extends TSchema = TTemplateLiteralFromTypes<Types>> = Result;
|
|
20
22
|
export declare function TemplateLiteralFromString<Template extends string>(template: Template): TTemplateLiteralFromString<Template>;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
|
+
import { Memory } from '../../system/system.mjs';
|
|
3
4
|
import { Guard } from '../../guard/index.mjs';
|
|
4
|
-
import { IsKind } from './schema.mjs';
|
|
5
|
+
import { IsSchema, IsKind } from './schema.mjs';
|
|
5
6
|
import { Deferred } from './deferred.mjs';
|
|
6
7
|
import { ParseTemplateIntoTypes } from '../engine/patterns/template.mjs';
|
|
7
|
-
import {
|
|
8
|
-
import { Memory } from '../../system/system.mjs';
|
|
8
|
+
import { TemplateLiteralAction } from '../engine/template-literal/instantiate.mjs';
|
|
9
9
|
/** Creates a deferred TemplateLiteral action. */
|
|
10
10
|
export function TemplateLiteralDeferred(types, options = {}) {
|
|
11
11
|
return Deferred('TemplateLiteral', [types], options);
|
|
12
12
|
}
|
|
13
|
+
/** Returns true if this value is a deferred Interface action. */
|
|
14
|
+
export function IsTemplateLiteralDeferred(value) {
|
|
15
|
+
return IsSchema(value)
|
|
16
|
+
&& Guard.HasPropertyKey(value, 'action')
|
|
17
|
+
&& Guard.IsEqual(value.action, 'TemplateLiteral');
|
|
18
|
+
}
|
|
13
19
|
export function TemplateLiteralFromTypes(types) {
|
|
14
|
-
return
|
|
20
|
+
return TemplateLiteralAction(types, {});
|
|
15
21
|
}
|
|
16
22
|
export function TemplateLiteralFromString(template) {
|
|
17
23
|
const types = ParseTemplateIntoTypes(template);
|
|
@@ -2,8 +2,7 @@ import { type TSchema } from './schema.mjs';
|
|
|
2
2
|
export type StaticUnsafe<Type extends unknown> = Type;
|
|
3
3
|
/** Represents an Unsafe type. */
|
|
4
4
|
export interface TUnsafe<Type extends unknown = unknown> extends TSchema {
|
|
5
|
-
'~
|
|
6
|
-
'~hint': Type;
|
|
5
|
+
'~unsafe': Type;
|
|
7
6
|
}
|
|
8
7
|
/** Creates a Unsafe type. */
|
|
9
8
|
export declare function Unsafe<Type extends unknown>(schema: TSchema): TUnsafe<Type>;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
|
+
import { Guard } from '../../guard/index.mjs';
|
|
3
4
|
import { Memory } from '../../system/memory/index.mjs';
|
|
4
|
-
import { IsKind } from './schema.mjs';
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
6
|
// Factory
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
/** Creates a Unsafe type. */
|
|
9
9
|
export function Unsafe(schema) {
|
|
10
|
-
return Memory.
|
|
10
|
+
return Memory.Update(schema, { ['~unsafe']: null }, {});
|
|
11
11
|
}
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
13
|
// Guard
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
15
|
/** Returns true if the given value is TUnsafe. */
|
|
16
16
|
export function IsUnsafe(value) {
|
|
17
|
-
return
|
|
17
|
+
return Guard.IsObjectNotArray(value)
|
|
18
|
+
&& Guard.HasPropertyKey(value, '~unsafe')
|
|
19
|
+
&& Guard.IsNull(value['~unsafe']);
|
|
18
20
|
}
|
package/build/typebox.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Instantiate, type TInstantiate } from './type/engine/instantiate.mjs';
|
|
2
2
|
export { Extends, ExtendsResult, type TExtends } from './type/extends/index.mjs';
|
|
3
3
|
export { Script, type TScript } from './type/script/index.mjs';
|
|
4
|
-
export { Awaited, type
|
|
4
|
+
export { Awaited, type TAwaited, type TAwaitedDeferred } from './type/action/awaited.mjs';
|
|
5
5
|
export { Capitalize, type TCapitalize, type TCapitalizeDeferred } from './type/action/capitalize.mjs';
|
|
6
6
|
export { Conditional, type TConditional, type TConditionalDeferred } from './type/action/conditional.mjs';
|
|
7
7
|
export { ConstructorParameters, type TConstructorParameters, type TConstructorParametersDeferred } from './type/action/constructor-parameters.mjs';
|
|
@@ -21,7 +21,7 @@ export { Options, type TOptions } from './type/action/options.mjs';
|
|
|
21
21
|
export { Parameters, type TParameters, type TParametersDeferred } from './type/action/parameters.mjs';
|
|
22
22
|
export { Partial, type TPartial, type TPartialDeferred } from './type/action/partial.mjs';
|
|
23
23
|
export { Pick, type TPick, type TPickDeferred } from './type/action/pick.mjs';
|
|
24
|
-
export { ReadonlyType, type
|
|
24
|
+
export { ReadonlyObject, ReadonlyType, type TReadonlyObject, type TReadonlyObjectDeferred } from './type/action/readonly-object.mjs';
|
|
25
25
|
export { Required, type TRequired, type TRequiredDeferred } from './type/action/required.mjs';
|
|
26
26
|
export { ReturnType, type TReturnType, type TReturnTypeDeferred } from './type/action/return-type.mjs';
|
|
27
27
|
export { type TUncapitalize, type TUncapitalizeDeferred, Uncapitalize } from './type/action/uncapitalize.mjs';
|
|
@@ -30,7 +30,7 @@ export { Codec, Decode, DecodeBuilder, Encode, EncodeBuilder, IsCodec, type TCod
|
|
|
30
30
|
export { Immutable, IsImmutable, type TImmutable } from './type/types/_immutable.mjs';
|
|
31
31
|
export { IsOptional, Optional, type TOptional } from './type/types/_optional.mjs';
|
|
32
32
|
export { IsReadonly, Readonly, type TReadonly } from './type/types/_readonly.mjs';
|
|
33
|
-
export { IsRefine, Refine, type TRefine, type
|
|
33
|
+
export { IsRefine, Refine, type TRefine, type TRefineCheckCallback, type TRefineErrorCallback, type TRefinement } from './type/types/_refine.mjs';
|
|
34
34
|
export { Any, IsAny, type TAny } from './type/types/any.mjs';
|
|
35
35
|
export { Array, IsArray, type TArray } from './type/types/array.mjs';
|
|
36
36
|
export { AsyncIterator, IsAsyncIterator, type TAsyncIterator } from './type/types/async-iterator.mjs';
|
|
@@ -56,7 +56,7 @@ export { IsObject, Object, type TObject } from './type/types/object.mjs';
|
|
|
56
56
|
export { IsParameter, Parameter, type TParameter } from './type/types/parameter.mjs';
|
|
57
57
|
export { IsPromise, Promise, type TPromise } from './type/types/promise.mjs';
|
|
58
58
|
export { type TProperties, type TRequiredArray } from './type/types/properties.mjs';
|
|
59
|
-
export { IsRecord, Record, RecordKey, RecordPattern
|
|
59
|
+
export { IsRecord, Record, RecordKey, RecordPattern, RecordValue, type TRecord, type TRecordKey, type TRecordPattern, type TRecordValue } from './type/types/record.mjs';
|
|
60
60
|
export { IsRef, Ref, type TRef } from './type/types/ref.mjs';
|
|
61
61
|
export { IsRest, Rest, type TRest } from './type/types/rest.mjs';
|
|
62
62
|
export { IsKind, IsSchema, type TArrayOptions, type TFormat, type TIntersectOptions, type TNumberOptions, type TObjectOptions, type TSchema, type TSchemaOptions, type TStringOptions, type TTupleOptions } from './type/types/schema.mjs';
|
package/build/typebox.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export { Options } from './type/action/options.mjs';
|
|
|
33
33
|
export { Parameters } from './type/action/parameters.mjs';
|
|
34
34
|
export { Partial } from './type/action/partial.mjs';
|
|
35
35
|
export { Pick } from './type/action/pick.mjs';
|
|
36
|
-
export { ReadonlyType } from './type/action/readonly-
|
|
36
|
+
export { ReadonlyObject, ReadonlyType } from './type/action/readonly-object.mjs';
|
|
37
37
|
export { Required } from './type/action/required.mjs';
|
|
38
38
|
export { ReturnType } from './type/action/return-type.mjs';
|
|
39
39
|
export { Uncapitalize } from './type/action/uncapitalize.mjs';
|
|
@@ -73,7 +73,7 @@ export { IsNumber, Number } from './type/types/number.mjs';
|
|
|
73
73
|
export { IsObject, Object } from './type/types/object.mjs';
|
|
74
74
|
export { IsParameter, Parameter } from './type/types/parameter.mjs';
|
|
75
75
|
export { IsPromise, Promise } from './type/types/promise.mjs';
|
|
76
|
-
export { IsRecord, Record, RecordKey, RecordPattern
|
|
76
|
+
export { IsRecord, Record, RecordKey, RecordPattern, RecordValue } from './type/types/record.mjs';
|
|
77
77
|
export { IsRef, Ref } from './type/types/ref.mjs';
|
|
78
78
|
export { IsRest, Rest } from './type/types/rest.mjs';
|
|
79
79
|
export { IsKind, IsSchema } from './type/types/schema.mjs';
|
|
@@ -5,5 +5,7 @@ export type TMutable = {
|
|
|
5
5
|
* Performs a deep structural assignment, applying values from next to current while retaining internal references. This function
|
|
6
6
|
* is written for use in infrastructure that interprets reference changes as a signal to perform some action (i.e. React redraw), this
|
|
7
7
|
* function can mitigate this by applying mutable updates deep within a value, ensuring parent references are retained.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated This function is being removed in the next version but will be retained as a reference under examples.
|
|
8
10
|
*/
|
|
9
11
|
export declare function Mutate(current: TMutable, next: TMutable): void;
|
|
@@ -29,6 +29,8 @@ function IsMismatchedValue(left, right) {
|
|
|
29
29
|
* Performs a deep structural assignment, applying values from next to current while retaining internal references. This function
|
|
30
30
|
* is written for use in infrastructure that interprets reference changes as a signal to perform some action (i.e. React redraw), this
|
|
31
31
|
* function can mitigate this by applying mutable updates deep within a value, ensuring parent references are retained.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated This function is being removed in the next version but will be retained as a reference under examples.
|
|
32
34
|
*/
|
|
33
35
|
export function Mutate(current, next) {
|
|
34
36
|
if (IsNonMutableValue(current) || IsNonMutableValue(next))
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type TSchema, type TSchemaOptions } from '../types/schema.mjs';
|
|
2
|
-
import { type TDeferred } from '../types/deferred.mjs';
|
|
3
|
-
import { type TInstantiate } from '../engine/instantiate.mjs';
|
|
4
|
-
/** Creates a deferred ReadonlyType action. */
|
|
5
|
-
export type TReadonlyTypeDeferred<Type extends TSchema> = (TDeferred<'ReadonlyType', [Type]>);
|
|
6
|
-
/** Creates a deferred ReadonlyType action. */
|
|
7
|
-
export declare function ReadonlyTypeDeferred<Type extends TSchema>(type: Type, options?: TSchemaOptions): TDeferred<"ReadonlyType", [Type]>;
|
|
8
|
-
/** This type is an alias for the TypeScript `Readonly<T>` utility type. */
|
|
9
|
-
export type TReadonlyType<Type extends TSchema> = (TInstantiate<{}, TReadonlyTypeDeferred<Type>>);
|
|
10
|
-
/** This type is an alias for the TypeScript `Readonly<T>` utility type. */
|
|
11
|
-
export declare function ReadonlyType<Type extends TSchema>(type: Type, options?: TSchemaOptions): TReadonlyType<Type>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// deno-lint-ignore-file ban-types
|
|
2
|
-
// deno-fmt-ignore-file
|
|
3
|
-
import { Deferred } from '../types/deferred.mjs';
|
|
4
|
-
import { Instantiate } from '../engine/instantiate.mjs';
|
|
5
|
-
/** Creates a deferred ReadonlyType action. */
|
|
6
|
-
export function ReadonlyTypeDeferred(type, options = {}) {
|
|
7
|
-
return Deferred('ReadonlyType', [type], options);
|
|
8
|
-
}
|
|
9
|
-
/** This type is an alias for the TypeScript `Readonly<T>` utility type. */
|
|
10
|
-
export function ReadonlyType(type, options = {}) {
|
|
11
|
-
return Instantiate({}, ReadonlyTypeDeferred(type, options));
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
-
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
-
import { type TReadonlyTypeDeferred } from '../../action/readonly-type.mjs';
|
|
4
|
-
import { type TFromType } from './from-type.mjs';
|
|
5
|
-
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
type TReadonlyTypeImmediate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TFromType<InstantiatedType>;
|
|
7
|
-
export type TReadonlyTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TReadonlyTypeImmediate<Context, State, Type> : TReadonlyTypeDeferred<Type>;
|
|
8
|
-
export declare function ReadonlyTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TReadonlyTypeInstantiate<Context, State, Type>;
|
|
9
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// deno-fmt-ignore-file
|
|
2
|
-
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
-
import { ReadonlyTypeDeferred } from '../../action/readonly-type.mjs';
|
|
4
|
-
import { FromType } from './from-type.mjs';
|
|
5
|
-
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
function ReadonlyTypeImmediate(context, state, type, options) {
|
|
7
|
-
const instantiatedType = InstantiateType(context, state, type);
|
|
8
|
-
return Memory.Update(FromType(instantiatedType), {}, options);
|
|
9
|
-
}
|
|
10
|
-
export function ReadonlyTypeInstantiate(context, state, type, options) {
|
|
11
|
-
return (CanInstantiate(context, [type])
|
|
12
|
-
? ReadonlyTypeImmediate(context, state, type, options)
|
|
13
|
-
: ReadonlyTypeDeferred(type, options));
|
|
14
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|