typebox 1.1.26 → 1.1.28
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/static/properties.d.mts +27 -6
- package/build/schema/static/required.d.mts +1 -11
- package/build/schema/static/schema.d.mts +3 -2
- package/build/schema/static/static.d.mts +2 -2
- package/build/schema/static/~canonical.d.mts +7 -0
- 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-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/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/script/mapping.d.mts +1 -1
- package/build/type/script/mapping.mjs +1 -1
- package/build/type/types/promise.d.mts +2 -1
- package/build/type/types/promise.mjs +2 -1
- package/build/type/types/record.d.mts +5 -5
- package/build/type/types/record.mjs +11 -6
- package/build/type/types/template-literal.d.mts +5 -3
- package/build/type/types/template-literal.mjs +10 -4
- package/build/typebox.d.mts +3 -3
- package/build/typebox.mjs +2 -2
- package/package.json +1 -1
- package/readme.md +1 -1
- package/build/schema/static/~non-readonly.d.mts +0 -7
- package/build/schema/static/~readonly.d.mts +0 -6
- package/build/schema/static/~readonly.mjs +0 -2
- 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/schema/static/{~non-readonly.mjs → ~canonical.mjs} +0 -0
- /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
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { Memory } from '../../../system/memory/index.mjs';
|
|
2
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
3
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
4
|
-
import { type TObject } from '../../types/object.mjs';
|
|
5
|
-
import { type TToIndexableKeys } from '../indexable/to-indexable-keys.mjs';
|
|
6
|
-
import { type TToIndexable } from '../indexable/to-indexable.mjs';
|
|
7
3
|
import { type TPickDeferred } from '../../action/pick.mjs';
|
|
8
4
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type TPickAction<Type extends TSchema, Indexer extends TSchema, Indexable extends TProperties = TToIndexable<Type>, Keys extends string[] = TToIndexableKeys<Indexer>, Applied extends TProperties = TFromKeys<Indexable, Keys>, Result extends TSchema = TObject<Applied>> = Result;
|
|
14
|
-
type TPickImmediate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TPickAction<InstantiatedType, InstantiatedIndexer>;
|
|
15
|
-
export type TPickInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema> = TCanInstantiate<Context, [Type, Indexer]> extends true ? TPickImmediate<Context, State, Type, Indexer> : TPickDeferred<Type, Indexer>;
|
|
5
|
+
import { type TFromType } from './from-type.mjs';
|
|
6
|
+
export type TPickAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType<Type, Indexer> : TPickDeferred<Type, Indexer>> = Result;
|
|
7
|
+
export declare function PickAction<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options: TSchemaOptions): TPickAction<Type, Indexer>;
|
|
8
|
+
export type TPickInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TPickAction<InstantiatedType, InstantiatedIndexer>;
|
|
16
9
|
export declare function PickInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema>(context: Context, state: State, type: Type, indexer: Indexer, options: TSchemaOptions): TPickInstantiate<Context, State, Type, Indexer>;
|
|
17
|
-
export {};
|
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
// deno-lint-ignore-file ban-types
|
|
2
1
|
// deno-fmt-ignore-file
|
|
3
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
4
|
-
import { Guard } from '../../../guard/index.mjs';
|
|
5
|
-
import { Object } from '../../types/object.mjs';
|
|
6
|
-
import { ToIndexableKeys } from '../indexable/to-indexable-keys.mjs';
|
|
7
|
-
import { ToIndexable } from '../indexable/to-indexable.mjs';
|
|
8
3
|
import { PickDeferred } from '../../action/pick.mjs';
|
|
9
4
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { FromType } from './from-type.mjs';
|
|
6
|
+
export function PickAction(type, indexer, options) {
|
|
7
|
+
const result = CanInstantiate([type, indexer])
|
|
8
|
+
? Memory.Update(FromType(type, indexer), {}, options)
|
|
9
|
+
: PickDeferred(type, indexer, options);
|
|
14
10
|
return result;
|
|
15
11
|
}
|
|
16
|
-
function
|
|
17
|
-
const indexable = ToIndexable(type);
|
|
18
|
-
const keys = ToIndexableKeys(indexer);
|
|
19
|
-
const applied = FromKeys(indexable, keys);
|
|
20
|
-
const result = Object(applied);
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
function PickImmediate(context, state, type, indexer, options) {
|
|
12
|
+
export function PickInstantiate(context, state, type, indexer, options) {
|
|
24
13
|
const instantiatedType = InstantiateType(context, state, type);
|
|
25
14
|
const instantiatedIndexer = InstantiateType(context, state, indexer);
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
export function PickInstantiate(context, state, type, indexer, options) {
|
|
29
|
-
return (CanInstantiate(context, [type, indexer])
|
|
30
|
-
? PickImmediate(context, state, type, indexer, options)
|
|
31
|
-
: PickDeferred(type, indexer, options));
|
|
15
|
+
return PickAction(instantiatedType, instantiatedIndexer, options);
|
|
32
16
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TReadonlyObjectDeferred } from '../../action/readonly-object.mjs';
|
|
4
|
+
import { type TFromType } from './from-type.mjs';
|
|
5
|
+
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
+
export type TReadonlyObjectAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<Type> : TReadonlyObjectDeferred<Type>> = Result;
|
|
7
|
+
export declare function ReadonlyObjectAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TReadonlyObjectAction<Type>;
|
|
8
|
+
export type TReadonlyObjectInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TReadonlyObjectAction<InstantiateType>;
|
|
9
|
+
export declare function ReadonlyObjectInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TReadonlyObjectInstantiate<Context, State, Type>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
+
import { ReadonlyObjectDeferred } from '../../action/readonly-object.mjs';
|
|
4
|
+
import { FromType } from './from-type.mjs';
|
|
5
|
+
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
6
|
+
export function ReadonlyObjectAction(type, options) {
|
|
7
|
+
const result = CanInstantiate([type])
|
|
8
|
+
? Memory.Update(FromType(type), {}, options)
|
|
9
|
+
: ReadonlyObjectDeferred(type);
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
export function ReadonlyObjectInstantiate(context, state, type, options) {
|
|
13
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
14
|
+
return ReadonlyObjectAction(instantiatedType, options);
|
|
15
|
+
}
|
|
@@ -3,7 +3,7 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TRecordDeferred } from '../../types/record.mjs';
|
|
4
4
|
import { type TFromKey } from './from-key.mjs';
|
|
5
5
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
type
|
|
7
|
-
export
|
|
6
|
+
export type TRecordAction<Key extends TSchema, Value extends TSchema, Result extends TSchema = TCanInstantiate<[Key]> extends true ? TFromKey<Key, Value> : TRecordDeferred<Key, Value>> = Result;
|
|
7
|
+
export declare function RecordAction<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options: TSchemaOptions): TRecordAction<Key, Value>;
|
|
8
|
+
export type TRecordInstantiate<Context extends TProperties, State extends TState, Key extends TSchema, Value extends TSchema, InstantiatedKey extends TSchema = TInstantiateType<Context, State, Key>, InstantiatedValue extends TSchema = TInstantiateType<Context, State, Value>> = TRecordAction<InstantiatedKey, InstantiatedValue>;
|
|
8
9
|
export declare function RecordInstantiate<Context extends TProperties, State extends TState, Key extends TSchema, Value extends TSchema>(context: Context, state: State, key: Key, value: Value, options: TSchemaOptions): TRecordInstantiate<Context, State, Key, Value>;
|
|
9
|
-
export {};
|
|
@@ -4,13 +4,14 @@ import { Memory } from '../../../system/memory/index.mjs';
|
|
|
4
4
|
import { RecordDeferred } from '../../types/record.mjs';
|
|
5
5
|
import { FromKey } from './from-key.mjs';
|
|
6
6
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export function RecordAction(key, value, options) {
|
|
8
|
+
const result = CanInstantiate([key])
|
|
9
|
+
? Memory.Update(FromKey(key, value), {}, options)
|
|
10
|
+
: RecordDeferred(key, value, options);
|
|
11
|
+
return result;
|
|
11
12
|
}
|
|
12
13
|
export function RecordInstantiate(context, state, key, value, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const instantiatedKey = InstantiateType(context, state, key);
|
|
15
|
+
const instantiatedValue = InstantiateType(context, state, value);
|
|
16
|
+
return RecordAction(instantiatedKey, instantiatedValue, options);
|
|
16
17
|
}
|
|
@@ -3,7 +3,7 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TFromType } from './from-type.mjs';
|
|
4
4
|
import { type TRequiredDeferred } from '../../action/required.mjs';
|
|
5
5
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
type
|
|
7
|
-
export
|
|
6
|
+
export type TRequiredAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<Type> : TRequiredDeferred<Type>> = Result;
|
|
7
|
+
export declare function RequiredAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TRequiredAction<Type>;
|
|
8
|
+
export type TRequiredInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TRequiredAction<InstantiatedType>;
|
|
8
9
|
export declare function RequiredInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TRequiredInstantiate<Context, State, Type>;
|
|
9
|
-
export {};
|
|
@@ -3,12 +3,13 @@ import { Memory } from '../../../system/memory/index.mjs';
|
|
|
3
3
|
import { FromType } from './from-type.mjs';
|
|
4
4
|
import { RequiredDeferred } from '../../action/required.mjs';
|
|
5
5
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
export function RequiredAction(type, options) {
|
|
7
|
+
const result = CanInstantiate([type])
|
|
8
|
+
? Memory.Update(FromType(type), {}, options)
|
|
9
|
+
: RequiredDeferred(type, options);
|
|
10
|
+
return result;
|
|
9
11
|
}
|
|
10
12
|
export function RequiredInstantiate(context, state, type, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
: RequiredDeferred(type, options));
|
|
13
|
+
const instaniatedType = InstantiateType(context, state, type);
|
|
14
|
+
return RequiredAction(instaniatedType, options);
|
|
14
15
|
}
|
|
@@ -4,8 +4,9 @@ import { type TFunction } from '../../types/function.mjs';
|
|
|
4
4
|
import { type TNever } from '../../types/never.mjs';
|
|
5
5
|
import { type TReturnTypeDeferred } from '../../action/return-type.mjs';
|
|
6
6
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
export
|
|
10
|
-
export
|
|
7
|
+
type TReturnTypeOperation<Type extends TSchema> = (Type extends TFunction ? Type['returnType'] : TNever);
|
|
8
|
+
export type TReturnTypeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TReturnTypeOperation<Type> : TReturnTypeDeferred<Type>> = Result;
|
|
9
|
+
export declare function ReturnTypeAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TReturnTypeAction<Type>;
|
|
10
|
+
export type TReturnTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TReturnTypeAction<InstantiatedType>;
|
|
11
|
+
export declare function ReturnTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options?: TSchemaOptions): TReturnTypeInstantiate<Context, State, Type>;
|
|
11
12
|
export {};
|
|
@@ -4,15 +4,18 @@ import { IsFunction } from '../../types/function.mjs';
|
|
|
4
4
|
import { Never } from '../../types/never.mjs';
|
|
5
5
|
import { ReturnTypeDeferred } from '../../action/return-type.mjs';
|
|
6
6
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
7
|
-
function
|
|
8
|
-
return (IsFunction(type)
|
|
7
|
+
function ReturnTypeOperation(type) {
|
|
8
|
+
return (IsFunction(type)
|
|
9
|
+
? type['returnType']
|
|
10
|
+
: Never());
|
|
9
11
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
export function ReturnTypeAction(type, options) {
|
|
13
|
+
const result = CanInstantiate([type])
|
|
14
|
+
? Memory.Update(ReturnTypeOperation(type), {}, options)
|
|
15
|
+
: ReturnTypeDeferred(type, options);
|
|
16
|
+
return result;
|
|
13
17
|
}
|
|
14
|
-
export function ReturnTypeInstantiate(context, state, type, options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: ReturnTypeDeferred(type, options));
|
|
18
|
+
export function ReturnTypeInstantiate(context, state, type, options = {}) {
|
|
19
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
20
|
+
return ReturnTypeAction(instantiatedType, options);
|
|
18
21
|
}
|
|
@@ -2,7 +2,7 @@ import { type TSchema } from '../../types/schema.mjs';
|
|
|
2
2
|
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
3
3
|
import { type TLiteral, type TLiteralValue } from '../../types/literal.mjs';
|
|
4
4
|
import { type TUnion } from '../../types/union.mjs';
|
|
5
|
-
import { type TTemplateLiteral } from '../../types/template-literal.mjs';
|
|
5
|
+
import { type TTemplateLiteral, TTemplateLiteralDeferred } from '../../types/template-literal.mjs';
|
|
6
6
|
import { type TBigInt, BigIntPattern } from '../../types/bigint.mjs';
|
|
7
7
|
import { type TString, StringPattern } from '../../types/string.mjs';
|
|
8
8
|
import { type TNumber, NumberPattern } from '../../types/number.mjs';
|
|
@@ -10,6 +10,7 @@ import { type TInteger, IntegerPattern } from '../../types/integer.mjs';
|
|
|
10
10
|
import { type TBoolean } from '../../types/boolean.mjs';
|
|
11
11
|
import { NeverPattern } from '../../types/never.mjs';
|
|
12
12
|
import { type TEnumValuesToVariants } from '../enum/enum-to-union.mjs';
|
|
13
|
+
import { type TTemplateLiteralAction } from './instantiate.mjs';
|
|
13
14
|
type TJoinString<Input extends string[], Result extends string = ''> = (Input extends [infer Left extends string, ...infer Right extends string[]] ? Result extends '' ? TJoinString<Right, Left> : TJoinString<Right, `${Result}|${Left}`> : Result);
|
|
14
15
|
type TUnwrapTemplateLiteralPattern<Pattern extends string> = (Pattern extends `^${infer Pattern extends string}$` ? Pattern : never);
|
|
15
16
|
type TEncodeLiteral<Value extends TLiteralValue, Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${Value}`>);
|
|
@@ -19,9 +20,10 @@ type TEncodeNumber<Right extends TSchema[], Pattern extends string> = (TEncodeTy
|
|
|
19
20
|
type TEncodeBoolean<Right extends TSchema[], Pattern extends string> = (TEncodeType<TUnion<[TLiteral<'false'>, TLiteral<'true'>]>, Right, Pattern>);
|
|
20
21
|
type TEncodeString<Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${typeof StringPattern}`>);
|
|
21
22
|
type TEncodeTemplateLiteral<TemplatePattern extends string, Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${TUnwrapTemplateLiteralPattern<TemplatePattern>}`>);
|
|
23
|
+
type TEncodeTemplateLiteralDeferred<Types extends TSchema[], Right extends TSchema[], Pattern extends string, TemplateLiteral extends TSchema = TTemplateLiteralAction<Types>, Result extends TSchema = TEncodeType<TemplateLiteral, Right, Pattern>> = Result;
|
|
22
24
|
type TEncodeEnum<Types extends TEnumValue[], Right extends TSchema[], Pattern extends string, Variants extends TSchema[] = TEnumValuesToVariants<Types>> = TEncodeUnion<Variants, Right, Pattern>;
|
|
23
25
|
type TEncodeUnion<Types extends TSchema[], Right extends TSchema[], Pattern extends string, Result extends string[] = []> = Types extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TEncodeUnion<Tail, Right, Pattern, [...Result, TEncodeType<Head, [], ''>]> : TEncodeTypes<Right, `${Pattern}(${TJoinString<Result>})`>;
|
|
24
|
-
type TEncodeType<Type extends TSchema, Right extends TSchema[], Pattern extends string> = (Type extends TEnum<infer Values extends TEnumValue[]> ? TEncodeEnum<Values, Right, Pattern> : Type extends TInteger ? TEncodeInteger<Right, Pattern> : Type extends TLiteral<infer Value extends TLiteralValue> ? TEncodeLiteral<Value, Right, Pattern> : Type extends TBigInt ? TEncodeBigInt<Right, Pattern> : Type extends TBoolean ? TEncodeBoolean<Right, Pattern> : Type extends TNumber ? TEncodeNumber<Right, Pattern> : Type extends TString ? TEncodeString<Right, Pattern> : Type extends TTemplateLiteral<infer TemplatePattern extends string> ? TEncodeTemplateLiteral<TemplatePattern, Right, Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TEncodeUnion<Types, Right, Pattern> : typeof NeverPattern);
|
|
26
|
+
type TEncodeType<Type extends TSchema, Right extends TSchema[], Pattern extends string> = (Type extends TEnum<infer Values extends TEnumValue[]> ? TEncodeEnum<Values, Right, Pattern> : Type extends TInteger ? TEncodeInteger<Right, Pattern> : Type extends TLiteral<infer Value extends TLiteralValue> ? TEncodeLiteral<Value, Right, Pattern> : Type extends TBigInt ? TEncodeBigInt<Right, Pattern> : Type extends TBoolean ? TEncodeBoolean<Right, Pattern> : Type extends TNumber ? TEncodeNumber<Right, Pattern> : Type extends TString ? TEncodeString<Right, Pattern> : Type extends TTemplateLiteral<infer TemplatePattern extends string> ? TEncodeTemplateLiteral<TemplatePattern, Right, Pattern> : Type extends TTemplateLiteralDeferred<infer Types extends TSchema[]> ? TEncodeTemplateLiteralDeferred<Types, Right, Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TEncodeUnion<Types, Right, Pattern> : typeof NeverPattern);
|
|
25
27
|
type TEncodeTypes<Types extends TSchema[], Pattern extends string> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TEncodeType<Left, Right, Pattern> : Pattern);
|
|
26
28
|
type TEncodePattern<Types extends TSchema[], Encoded extends string = TEncodeTypes<Types, ''>, Result extends string = `^${Encoded}$`> = Result;
|
|
27
29
|
/** Encodes a TemplateLiteral type sequence into a TemplateLiteral */
|
|
@@ -3,7 +3,7 @@ import { IsSchema } from '../../types/schema.mjs';
|
|
|
3
3
|
import { IsEnum } from '../../types/enum.mjs';
|
|
4
4
|
import { Literal, IsLiteral } from '../../types/literal.mjs';
|
|
5
5
|
import { Union, IsUnion } from '../../types/union.mjs';
|
|
6
|
-
import { IsTemplateLiteral } from '../../types/template-literal.mjs';
|
|
6
|
+
import { IsTemplateLiteral, IsTemplateLiteralDeferred } from '../../types/template-literal.mjs';
|
|
7
7
|
import { IsBigInt, BigIntPattern } from '../../types/bigint.mjs';
|
|
8
8
|
import { IsString, StringPattern } from '../../types/string.mjs';
|
|
9
9
|
import { IsNumber, NumberPattern } from '../../types/number.mjs';
|
|
@@ -12,6 +12,7 @@ import { IsBoolean } from '../../types/boolean.mjs';
|
|
|
12
12
|
import { NeverPattern } from '../../types/never.mjs';
|
|
13
13
|
import { TemplateLiteralCreate } from './create.mjs';
|
|
14
14
|
import { EnumValuesToVariants } from '../enum/enum-to-union.mjs';
|
|
15
|
+
import { TemplateLiteralAction } from './instantiate.mjs';
|
|
15
16
|
function JoinString(input) {
|
|
16
17
|
return input.join('|');
|
|
17
18
|
}
|
|
@@ -39,6 +40,11 @@ function EncodeString(right, pattern) {
|
|
|
39
40
|
function EncodeTemplateLiteral(templatePattern, right, pattern) {
|
|
40
41
|
return EncodeTypes(right, `${pattern}${UnwrapTemplateLiteralPattern(templatePattern)}`);
|
|
41
42
|
}
|
|
43
|
+
function EncodeTemplateLiteralDeferred(types, right, pattern) {
|
|
44
|
+
const templateLiteral = TemplateLiteralAction(types, {});
|
|
45
|
+
const result = EncodeType(templateLiteral, right, pattern);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
42
48
|
function EncodeEnum(types, right, pattern) {
|
|
43
49
|
const variants = EnumValuesToVariants(types);
|
|
44
50
|
return EncodeUnion(variants, right, pattern);
|
|
@@ -58,8 +64,9 @@ function EncodeType(type, right, pattern) {
|
|
|
58
64
|
IsNumber(type) ? EncodeNumber(right, pattern) :
|
|
59
65
|
IsString(type) ? EncodeString(right, pattern) :
|
|
60
66
|
IsTemplateLiteral(type) ? EncodeTemplateLiteral(type.pattern, right, pattern) :
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
IsTemplateLiteralDeferred(type) ? EncodeTemplateLiteralDeferred(type.parameters[0], right, pattern) :
|
|
68
|
+
IsUnion(type) ? EncodeUnion(type.anyOf, right, pattern) :
|
|
69
|
+
NeverPattern);
|
|
63
70
|
}
|
|
64
71
|
function EncodeTypes(types, pattern) {
|
|
65
72
|
const [left, ...right] = types;
|
|
@@ -3,7 +3,7 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TTemplateLiteralDeferred } from '../../types/template-literal.mjs';
|
|
4
4
|
import { type TTemplateLiteralEncode } from './encode.mjs';
|
|
5
5
|
import { type TState, type TInstantiateTypes, type TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
type
|
|
7
|
-
export
|
|
6
|
+
export type TTemplateLiteralAction<Types extends TSchema[], Result extends TSchema = TCanInstantiate<Types> extends true ? TTemplateLiteralEncode<Types> : TTemplateLiteralDeferred<Types>> = Result;
|
|
7
|
+
export declare function TemplateLiteralAction<Types extends TSchema[]>(types: [...Types], options: TSchemaOptions): TTemplateLiteralAction<Types>;
|
|
8
|
+
export type TTemplateLiteralInstantiate<Context extends TProperties, State extends TState, Types extends TSchema[], InstantiatedTypes extends TSchema[] = TInstantiateTypes<Context, State, Types>> = TTemplateLiteralAction<InstantiatedTypes>;
|
|
8
9
|
export declare function TemplateLiteralInstantiate<Context extends TProperties, State extends TState, Types extends TSchema[]>(context: Context, state: State, types: [...Types], options: TSchemaOptions): TTemplateLiteralInstantiate<Context, State, Types>;
|
|
9
|
-
export {};
|
|
@@ -3,12 +3,13 @@ import { Memory } from '../../../system/memory/index.mjs';
|
|
|
3
3
|
import { TemplateLiteralDeferred } from '../../types/template-literal.mjs';
|
|
4
4
|
import { TemplateLiteralEncode } from './encode.mjs';
|
|
5
5
|
import { InstantiateTypes, CanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
export function TemplateLiteralAction(types, options) {
|
|
7
|
+
const result = CanInstantiate(types)
|
|
8
|
+
? Memory.Update(TemplateLiteralEncode(types), {}, options)
|
|
9
|
+
: TemplateLiteralDeferred(types, options);
|
|
10
|
+
return result;
|
|
9
11
|
}
|
|
10
12
|
export function TemplateLiteralInstantiate(context, state, types, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
: TemplateLiteralDeferred(types, options));
|
|
13
|
+
const instantiatedTypes = InstantiateTypes(context, state, types);
|
|
14
|
+
return TemplateLiteralAction(instantiatedTypes, options);
|
|
14
15
|
}
|
|
@@ -64,7 +64,7 @@ type TIntrinsicOrCall<Target extends string, Parameters extends T.TSchema[]> = (
|
|
|
64
64
|
] extends ['Pick', [infer Type extends T.TSchema, infer Indexer extends T.TSchema]] ? C.TPickDeferred<Type, Indexer> : [
|
|
65
65
|
Target,
|
|
66
66
|
Parameters
|
|
67
|
-
] extends ['Readonly', [infer Type extends T.TSchema]] ? C.
|
|
67
|
+
] extends ['Readonly', [infer Type extends T.TSchema]] ? C.TReadonlyObjectDeferred<Type> : [
|
|
68
68
|
Target,
|
|
69
69
|
Parameters
|
|
70
70
|
] extends ['Record', [infer Key extends T.TSchema, infer Value extends T.TSchema]] ? T.TRecordDeferred<Key, Value> : [
|
|
@@ -27,7 +27,7 @@ function IntrinsicOrCall(ref, parameters) {
|
|
|
27
27
|
Guard.IsEqual(ref, 'Parameters') ? C.ParametersDeferred(parameters[0]) :
|
|
28
28
|
Guard.IsEqual(ref, 'Partial') ? C.PartialDeferred(parameters[0]) :
|
|
29
29
|
Guard.IsEqual(ref, 'Pick') ? C.PickDeferred(parameters[0], parameters[1]) :
|
|
30
|
-
Guard.IsEqual(ref, 'Readonly') ? C.
|
|
30
|
+
Guard.IsEqual(ref, 'Readonly') ? C.ReadonlyObjectDeferred(parameters[0]) :
|
|
31
31
|
Guard.IsEqual(ref, 'KeyOf') ? C.KeyOfDeferred(parameters[0]) :
|
|
32
32
|
Guard.IsEqual(ref, 'Record') ? T.RecordDeferred(parameters[0], parameters[1]) :
|
|
33
33
|
Guard.IsEqual(ref, 'Required') ? C.RequiredDeferred(parameters[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
|
// ------------------------------------------------------------------
|
|
@@ -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,13 @@ 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
|
-
|
|
31
|
-
export declare function
|
|
30
|
+
/** Returns true if this value is a deferred Interface action. */
|
|
31
|
+
export declare function IsRecordDeferred(value: unknown): value is TRecordDeferred;
|
|
32
32
|
/** Creates a Record type. */
|
|
33
|
-
export declare function Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions):
|
|
33
|
+
export declare function Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value, options?: TObjectOptions): TRecordAction<Key, Value>;
|
|
34
34
|
/** Creates a Record type from regular expression pattern. */
|
|
35
35
|
export declare function RecordFromPattern<Pattern extends string, Value extends TSchema>(key: Pattern, value: Value): TRecord<Pattern, Value>;
|
|
36
36
|
/** Returns the raw string pattern used for the Record key */
|
|
@@ -1,15 +1,14 @@
|
|
|
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';
|
|
5
|
-
import { IsKind } from './schema.mjs';
|
|
4
|
+
import { IsKind, IsSchema } from './schema.mjs';
|
|
6
5
|
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,21 @@ export const StringKey = `^${StringPattern}$`;
|
|
|
17
16
|
export function RecordDeferred(key, value, options = {}) {
|
|
18
17
|
return Deferred('Record', [key, value], options);
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// ------------------------------------------------------------------
|
|
20
|
+
// Guard
|
|
21
|
+
// ------------------------------------------------------------------
|
|
22
|
+
/** Returns true if this value is a deferred Interface action. */
|
|
23
|
+
export function IsRecordDeferred(value) {
|
|
24
|
+
return IsSchema(value)
|
|
25
|
+
&& Guard.HasPropertyKey(value, 'action')
|
|
26
|
+
&& Guard.IsEqual(value.action, 'Record');
|
|
22
27
|
}
|
|
23
28
|
// -------------------------------------------------------------------
|
|
24
29
|
// Factory
|
|
25
30
|
// -------------------------------------------------------------------
|
|
26
31
|
/** Creates a Record type. */
|
|
27
32
|
export function Record(key, value, options = {}) {
|
|
28
|
-
return
|
|
33
|
+
return RecordAction(key, value, options);
|
|
29
34
|
}
|
|
30
35
|
// -------------------------------------------------------------------
|
|
31
36
|
// 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);
|
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';
|
|
@@ -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';
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -196,7 +196,7 @@ type UserUpdate = Type.Static<typeof UserUpdate> // type UserUpdate = {
|
|
|
196
196
|
|
|
197
197
|
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/schema/overview) | [Example 1](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQokscAKuWrnyES-ajXZs6dOAFo58hYqXKVqteo0zJ0gMIEwwADZptszeYuWr8tmyQQAdg3gBVBmihwAvImZYAdHrgRmgAFHwU-gDylABWaEgwoQDebHBwwAAmAFy8-P4IMFDADgDmoQCUADRpcA6YIGi5EWgFRSXl1bUsRs35hcVlKbjQWDC5RD2GRHAAvhVs8wum1qtr61pScAAKmFDuKxtHx6q29k7wAK7unj5uHv67+2HJ6W-vH5-vW+fOcNceXKpdJZCYANgArDgAIyYABMlAAzEgACyZCFoME4ADsmAAHJQAJxIAAMmWhRCqX2pcC2IJycGcg1KNXS9UaEwBUEpNN5fO+0jZDSajPaZVZcCmnJuAAFMgRMCV-PYQDN+by6ZKsL1RczFhV1YajR8trNvHB-JagA) | [Example 2](https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQbddcAtH-wMFDhI0WPESenbgGECYYABs003pPUbNW-hyQQAdg3gBVBmihwAvImZYAdHPBK0ACgDebOHDIUAXMQhKACs0JBgiABpPODB8ClhgNAZ-Dy8vYAATFO9yNH8iIyhgfQBzIjgAXyi0uH1MEDy4Nxy-YkLissrqtJYlbJ9Ggpgi0sjcaCwYfN7FcoroquioNABHAFdgZay4AG1oryJMsf3iOobjmqIZ9i8AXTYKgEoOLjVtd4+P1QAFTCgzVSfIHAyS6AxGOBrMwWaymcx2X7-VzNGqotHouCvPSGeBQ8wpaKZfIANgArDgAIyYABMlAAzEgACwZUloYk4ADsmAAHJQAJxIAAMGQpYwx6Ne6W27VK3TOgzxUDF4pVqq8ktq9UaMpK3Rm+UVAAEMgRMMU7HoQOU1SqNfq4DqHo8bS7XajXhUrHA7D6gA) | [Specification](https://sinclairzx81.github.io/typebox/#/docs/schema/1_spec)
|
|
198
198
|
|
|
199
|
-
TypeBox
|
|
199
|
+
TypeBox includes a high-performance JSON Schema compiler with support for drafts 3 through to 2020-12. The compiler is designed to be a lightweight industry-grade alternative to Ajv and offers improved compilation and validation performance. The compiler also offers automatic fallback to dynamic checking in JIT-restricted environments such as Cloudflare Workers.
|
|
200
200
|
|
|
201
201
|
### Example
|
|
202
202
|
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
type XFromTuple<Value extends readonly unknown[]> = (Value extends [infer Left, ...infer Right extends unknown[]] ? [XNonReadonly<Left>, ...XFromTuple<Right>] : []);
|
|
2
|
-
type XFromArray<Value extends unknown, Result extends unknown[] = XNonReadonly<Value>[]> = Result;
|
|
3
|
-
type XFromObject<Value extends object, Result extends Record<PropertyKey, unknown> = {
|
|
4
|
-
-readonly [K in keyof Value]: XNonReadonly<Value[K]>;
|
|
5
|
-
}> = Result;
|
|
6
|
-
export type XNonReadonly<Value extends unknown> = (Value extends readonly [...infer Schemas extends unknown[]] ? XFromTuple<Schemas> : Value extends readonly (infer Schema)[] ? XFromArray<Schema> : Value extends object ? XFromObject<Value> : Value);
|
|
7
|
-
export {};
|