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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// deno-lint-ignore-file ban-types
|
|
2
|
+
// deno-fmt-ignore-file
|
|
3
|
+
import { IsEnum } from '../../types/enum.mjs';
|
|
4
|
+
import { IsUnion } from '../../types/union.mjs';
|
|
5
|
+
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
6
|
+
import { EnumValuesToVariants } from '../enum/index.mjs';
|
|
7
|
+
import { EvaluateUnion, Flatten } from '../evaluate/index.mjs';
|
|
8
|
+
function ExcludeUnionLeft(types, right) {
|
|
9
|
+
return types.reduce((result, head) => {
|
|
10
|
+
return [...result, ...ExcludeTypeLeft(head, right)];
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
13
|
+
function ExcludeTypeLeft(left, right) {
|
|
14
|
+
const check = Extends({}, left, right);
|
|
15
|
+
const result = ExtendsResult.IsExtendsTrueLike(check) ? [] : [left];
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export function ExcludeOperation(left, right) {
|
|
19
|
+
const remaining = (IsEnum(left) ? ExcludeUnionLeft(EnumValuesToVariants(left.enum), right) :
|
|
20
|
+
IsUnion(left) ? ExcludeUnionLeft(Flatten(left.anyOf), right) :
|
|
21
|
+
ExcludeTypeLeft(left, right));
|
|
22
|
+
const result = EvaluateUnion(remaining);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
-
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
4
|
-
import { type TUnion } from '../../types/union.mjs';
|
|
5
|
-
import { type TExtends, ExtendsResult } from '../../extends/index.mjs';
|
|
6
|
-
import { type TEnumValuesToVariants } from '../enum/index.mjs';
|
|
7
|
-
import { type TEvaluateUnion, type TFlatten } from '../evaluate/index.mjs';
|
|
8
3
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
9
4
|
import { type TExtractDeferred } from '../../action/extract.mjs';
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
export type TExtractInstantiate<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema> = TCanInstantiate<Context, [Left, Right]> extends true ? TExtractImmediate<Context, State, Left, Right> : TExtractDeferred<Left, Right>;
|
|
5
|
+
import { type TExtractOperation } from './operation.mjs';
|
|
6
|
+
export type TExtractAction<Left extends TSchema, Right extends TSchema, Result extends TSchema = TCanInstantiate<[Left, Right]> extends true ? TExtractOperation<Left, Right> : TExtractDeferred<Left, Right>> = Result;
|
|
7
|
+
export declare function ExtractAction<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options: TSchemaOptions): TExtractAction<Left, Right>;
|
|
8
|
+
export type TExtractInstantiate<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema, InstantiatedLeft extends TSchema = TInstantiateType<Context, State, Left>, InstantiatedRight extends TSchema = TInstantiateType<Context, State, Right>> = TExtractAction<InstantiatedLeft, InstantiatedRight>;
|
|
15
9
|
export declare function ExtractInstantiate<Context extends TProperties, State extends TState, Left extends TSchema, Right extends TSchema>(context: Context, state: State, left: Left, right: Right, options: TSchemaOptions): TExtractInstantiate<Context, State, Left, Right>;
|
|
16
|
-
export {};
|
|
@@ -1,37 +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 { IsEnum } from '../../types/enum.mjs';
|
|
5
|
-
import { IsUnion } from '../../types/union.mjs';
|
|
6
|
-
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
7
|
-
import { EnumValuesToVariants } from '../enum/index.mjs';
|
|
8
|
-
import { EvaluateUnion, Flatten } from '../evaluate/index.mjs';
|
|
9
3
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
10
4
|
import { ExtractDeferred } from '../../action/extract.mjs';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function ExtractType(left, right) {
|
|
17
|
-
const check = Extends({}, left, right);
|
|
18
|
-
const result = ExtendsResult.IsExtendsTrueLike(check) ? [left] : [];
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
function ExtractAction(left, right) {
|
|
22
|
-
const remaining = (IsEnum(left) ? ExtractUnion(EnumValuesToVariants(left.enum), right) :
|
|
23
|
-
IsUnion(left) ? ExtractUnion(Flatten(left.anyOf), right) :
|
|
24
|
-
ExtractType(left, right));
|
|
25
|
-
const result = EvaluateUnion(remaining);
|
|
5
|
+
import { ExtractOperation } from './operation.mjs';
|
|
6
|
+
export function ExtractAction(left, right, options) {
|
|
7
|
+
const result = CanInstantiate([left, right])
|
|
8
|
+
? Memory.Update(ExtractOperation(left, right), {}, options)
|
|
9
|
+
: ExtractDeferred(left, right, options);
|
|
26
10
|
return result;
|
|
27
11
|
}
|
|
28
|
-
function
|
|
12
|
+
export function ExtractInstantiate(context, state, left, right, options) {
|
|
29
13
|
const instantiatedLeft = InstantiateType(context, state, left);
|
|
30
14
|
const instantiatedRight = InstantiateType(context, state, right);
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
export function ExtractInstantiate(context, state, left, right, options) {
|
|
34
|
-
return (CanInstantiate(context, [left, right])
|
|
35
|
-
? ExtractImmediate(context, state, left, right, options)
|
|
36
|
-
: ExtractDeferred(left, right, options));
|
|
15
|
+
return ExtractAction(instantiatedLeft, instantiatedRight, options);
|
|
37
16
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
3
|
+
import { type TUnion } from '../../types/union.mjs';
|
|
4
|
+
import { type TExtends, ExtendsResult } from '../../extends/index.mjs';
|
|
5
|
+
import { type TEnumValuesToVariants } from '../enum/index.mjs';
|
|
6
|
+
import { type TEvaluateUnion, type TFlatten } from '../evaluate/index.mjs';
|
|
7
|
+
type TExtractUnionLeft<Types extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Types extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtractUnionLeft<Tail, Right, [...Result, ...TExtractTypeLeft<Head, Right>]> : Result);
|
|
8
|
+
type TExtractTypeLeft<Left extends TSchema, Right extends TSchema, Check extends ExtendsResult.TResult = TExtends<{}, Left, Right>, Result extends TSchema[] = Check extends ExtendsResult.TExtendsTrueLike<infer _> ? [Left] : []> = Result;
|
|
9
|
+
export type TExtractOperation<Left extends TSchema, Right extends TSchema, Remaining extends TSchema[] = (Left extends TEnum<infer Values extends TEnumValue[]> ? TExtractUnionLeft<TEnumValuesToVariants<Values>, Right> : Left extends TUnion<infer Types extends TSchema[]> ? TExtractUnionLeft<TFlatten<Types>, Right> : TExtractTypeLeft<Left, Right>), Result extends TSchema = TEvaluateUnion<Remaining>> = Result;
|
|
10
|
+
export declare function ExtractOperation<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TExtractOperation<Left, Right>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// deno-lint-ignore-file ban-types
|
|
2
|
+
// deno-fmt-ignore-file
|
|
3
|
+
import { IsEnum } from '../../types/enum.mjs';
|
|
4
|
+
import { IsUnion } from '../../types/union.mjs';
|
|
5
|
+
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
6
|
+
import { EnumValuesToVariants } from '../enum/index.mjs';
|
|
7
|
+
import { EvaluateUnion, Flatten } from '../evaluate/index.mjs';
|
|
8
|
+
function ExtractUnionLeft(types, right) {
|
|
9
|
+
return types.reduce((result, head) => {
|
|
10
|
+
return [...result, ...ExtractTypeLeft(head, right)];
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
13
|
+
function ExtractTypeLeft(left, right) {
|
|
14
|
+
const check = Extends({}, left, right);
|
|
15
|
+
const result = ExtendsResult.IsExtendsTrueLike(check) ? [left] : [];
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export function ExtractOperation(left, right) {
|
|
19
|
+
const remaining = (IsEnum(left) ? ExtractUnionLeft(EnumValuesToVariants(left.enum), right) :
|
|
20
|
+
IsUnion(left) ? ExtractUnionLeft(Flatten(left.anyOf), right) :
|
|
21
|
+
ExtractTypeLeft(left, right));
|
|
22
|
+
const result = EvaluateUnion(remaining);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
@@ -23,7 +23,7 @@ export * from './parameters/index.mjs';
|
|
|
23
23
|
export * from './patterns/index.mjs';
|
|
24
24
|
export * from './partial/index.mjs';
|
|
25
25
|
export * from './pick/index.mjs';
|
|
26
|
-
export * from './readonly-
|
|
26
|
+
export * from './readonly-object/index.mjs';
|
|
27
27
|
export * from './record/index.mjs';
|
|
28
28
|
export * from './ref/index.mjs';
|
|
29
29
|
export * from './required/index.mjs';
|
|
@@ -29,7 +29,7 @@ export * from './parameters/index.mjs';
|
|
|
29
29
|
export * from './patterns/index.mjs';
|
|
30
30
|
export * from './partial/index.mjs';
|
|
31
31
|
export * from './pick/index.mjs';
|
|
32
|
-
export * from './readonly-
|
|
32
|
+
export * from './readonly-object/index.mjs';
|
|
33
33
|
export * from './record/index.mjs';
|
|
34
34
|
export * from './ref/index.mjs';
|
|
35
35
|
export * from './required/index.mjs';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TArray } from '../../types/array.mjs';
|
|
3
|
+
import { type TNever } from '../../types/never.mjs';
|
|
4
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
5
|
+
import { type TObject } from '../../types/object.mjs';
|
|
6
|
+
import { type TTuple } from '../../types/tuple.mjs';
|
|
7
|
+
import { type TFromArray } from './from-array.mjs';
|
|
8
|
+
import { type TFromObject } from './from-object.mjs';
|
|
9
|
+
import { type TFromTuple } from './from-tuple.mjs';
|
|
10
|
+
export type TFromType<Type extends TSchema, Indexer extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TFromArray<Type, Indexer> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<Properties, Indexer> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<Types, Indexer> : TNever);
|
|
11
|
+
export declare function FromType<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer): TFromType<Type, Indexer>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { IsArray } from '../../types/array.mjs';
|
|
3
|
+
import { Never } from '../../types/never.mjs';
|
|
4
|
+
import { IsObject } from '../../types/object.mjs';
|
|
5
|
+
import { IsTuple } from '../../types/tuple.mjs';
|
|
6
|
+
import { FromArray } from './from-array.mjs';
|
|
7
|
+
import { FromObject } from './from-object.mjs';
|
|
8
|
+
import { FromTuple } from './from-tuple.mjs';
|
|
9
|
+
export function FromType(type, indexer) {
|
|
10
|
+
return (IsArray(type) ? FromArray(type.items, indexer) :
|
|
11
|
+
IsObject(type) ? FromObject(type.properties, indexer) :
|
|
12
|
+
IsTuple(type) ? FromTuple(type.items, indexer) :
|
|
13
|
+
Never());
|
|
14
|
+
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
-
import { type TArray } from '../../types/array.mjs';
|
|
3
2
|
import { type TCyclic } from '../../types/cyclic.mjs';
|
|
4
3
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
5
|
-
import { type TNever } from '../../types/never.mjs';
|
|
6
4
|
import { type TProperties } from '../../types/properties.mjs';
|
|
7
|
-
import { type TObject } from '../../types/object.mjs';
|
|
8
|
-
import { type TTuple } from '../../types/tuple.mjs';
|
|
9
5
|
import { type TUnion } from '../../types/union.mjs';
|
|
10
|
-
import { type
|
|
11
|
-
import { type TFromObject } from './from-object.mjs';
|
|
12
|
-
import { type TFromTuple } from './from-tuple.mjs';
|
|
13
|
-
import { type TState, type TInstantiateType, TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
+
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
14
7
|
import { type TIndexDeferred } from '../../action/indexed.mjs';
|
|
15
8
|
import { type TCollapseToObject } from '../object/index.mjs';
|
|
9
|
+
import { type TFromType } from './from-type.mjs';
|
|
16
10
|
type TNormalizeType<Type extends TSchema, Result extends TSchema = (Type extends TCyclic | TIntersect | TUnion ? TCollapseToObject<Type> : Type)> = Result;
|
|
17
|
-
type TIndexAction<Type extends TSchema, Indexer extends TSchema,
|
|
18
|
-
|
|
19
|
-
export type TIndexInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema
|
|
11
|
+
export type TIndexAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType<TNormalizeType<Type>, Indexer> : TIndexDeferred<Type, Indexer>> = Result;
|
|
12
|
+
export declare function IndexAction<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options: TSchemaOptions): TIndexAction<Type, Indexer>;
|
|
13
|
+
export type TIndexInstantiate<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>> = TIndexAction<InstantiatedType, InstantiatedIndexer>;
|
|
20
14
|
export declare function IndexInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema>(context: Context, state: State, type: Type, indexer: Indexer, options: TSchemaOptions): TIndexInstantiate<Context, State, Type, Indexer>;
|
|
21
15
|
export {};
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
-
import { IsArray } from '../../types/array.mjs';
|
|
4
3
|
import { IsCyclic } from '../../types/cyclic.mjs';
|
|
5
4
|
import { IsIntersect } from '../../types/intersect.mjs';
|
|
6
|
-
import { Never } from '../../types/never.mjs';
|
|
7
|
-
import { IsObject } from '../../types/object.mjs';
|
|
8
|
-
import { IsTuple } from '../../types/tuple.mjs';
|
|
9
5
|
import { IsUnion } from '../../types/union.mjs';
|
|
10
|
-
import { FromArray } from './from-array.mjs';
|
|
11
|
-
import { FromObject } from './from-object.mjs';
|
|
12
|
-
import { FromTuple } from './from-tuple.mjs';
|
|
13
6
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
14
7
|
import { IndexDeferred } from '../../action/indexed.mjs';
|
|
15
8
|
import { CollapseToObject } from '../object/index.mjs';
|
|
9
|
+
import { FromType } from './from-type.mjs';
|
|
16
10
|
function NormalizeType(type) {
|
|
17
11
|
const result = (IsCyclic(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) :
|
|
18
12
|
type);
|
|
19
13
|
return result;
|
|
20
14
|
}
|
|
21
|
-
function IndexAction(type, indexer) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Never());
|
|
15
|
+
export function IndexAction(type, indexer, options) {
|
|
16
|
+
const result = CanInstantiate([type, indexer])
|
|
17
|
+
? Memory.Update(FromType(NormalizeType(type), indexer), {}, options)
|
|
18
|
+
: IndexDeferred(type, indexer, options);
|
|
19
|
+
return result;
|
|
27
20
|
}
|
|
28
|
-
function
|
|
21
|
+
export function IndexInstantiate(context, state, type, indexer, options) {
|
|
29
22
|
const instantiatedType = InstantiateType(context, state, type);
|
|
30
23
|
const instantiatedIndexer = InstantiateType(context, state, indexer);
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
export function IndexInstantiate(context, state, type, indexer, options) {
|
|
34
|
-
return (CanInstantiate(context, [type, indexer])
|
|
35
|
-
? IndexImmediate(context, state, type, indexer, options)
|
|
36
|
-
: IndexDeferred(type, indexer, options));
|
|
24
|
+
return IndexAction(instantiatedType, instantiatedIndexer, options);
|
|
37
25
|
}
|
|
@@ -4,9 +4,9 @@ import { type TConstructor } from '../../types/constructor.mjs';
|
|
|
4
4
|
import { type TNever } from '../../types/never.mjs';
|
|
5
5
|
import { type TInstanceTypeDeferred } from '../../action/instance-type.mjs';
|
|
6
6
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
7
|
-
type
|
|
8
|
-
export type
|
|
9
|
-
export declare function
|
|
10
|
-
export type TInstanceTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema
|
|
7
|
+
type TInstanceTypeOperation<Type extends TSchema> = (Type extends TConstructor ? Type['instanceType'] : TNever);
|
|
8
|
+
export type TInstanceTypeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TInstanceTypeOperation<Type> : TInstanceTypeDeferred<Type>> = Result;
|
|
9
|
+
export declare function InstanceTypeAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TInstanceTypeAction<Type>;
|
|
10
|
+
export type TInstanceTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TInstanceTypeAction<InstantiatedType>;
|
|
11
11
|
export declare function InstanceTypeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options?: TSchemaOptions): TInstanceTypeInstantiate<Context, State, Type>;
|
|
12
12
|
export {};
|
|
@@ -4,17 +4,18 @@ import { IsConstructor } from '../../types/constructor.mjs';
|
|
|
4
4
|
import { Never } from '../../types/never.mjs';
|
|
5
5
|
import { InstanceTypeDeferred } from '../../action/instance-type.mjs';
|
|
6
6
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
7
|
-
function
|
|
7
|
+
function InstanceTypeOperation(type) {
|
|
8
8
|
return (IsConstructor(type)
|
|
9
|
-
? type
|
|
9
|
+
? type['instanceType']
|
|
10
10
|
: Never());
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
export function InstanceTypeAction(type, options) {
|
|
13
|
+
const result = CanInstantiate([type])
|
|
14
|
+
? Memory.Update(InstanceTypeOperation(type), {}, options)
|
|
15
|
+
: InstanceTypeDeferred(type, options);
|
|
16
|
+
return result;
|
|
15
17
|
}
|
|
16
18
|
export function InstanceTypeInstantiate(context, state, type, options = {}) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: InstanceTypeDeferred(type, options));
|
|
19
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
20
|
+
return InstanceTypeAction(instantiatedType, options);
|
|
20
21
|
}
|
|
@@ -42,7 +42,7 @@ import { type TOptionsInstantiate } from './options/instantiate.mjs';
|
|
|
42
42
|
import { type TParametersInstantiate } from './parameters/instantiate.mjs';
|
|
43
43
|
import { type TPartialInstantiate } from './partial/instantiate.mjs';
|
|
44
44
|
import { type TPickInstantiate } from './pick/instantiate.mjs';
|
|
45
|
-
import { type
|
|
45
|
+
import { type TReadonlyObjectInstantiate } from './readonly-object/instantiate.mjs';
|
|
46
46
|
import { type TRecordInstantiate } from './record/instantiate.mjs';
|
|
47
47
|
import { type TRefInstantiate } from './ref/instantiate.mjs';
|
|
48
48
|
import { type TRequiredInstantiate } from './required/instantiate.mjs';
|
|
@@ -54,10 +54,8 @@ import { type TRestSpread } from './rest/index.mjs';
|
|
|
54
54
|
export interface TState {
|
|
55
55
|
callstack: string[];
|
|
56
56
|
}
|
|
57
|
-
type
|
|
58
|
-
|
|
59
|
-
export type TCanInstantiate<Context extends TProperties, Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCanInstantiateType<Context, Left> extends true ? TCanInstantiate<Context, Right> : false : true;
|
|
60
|
-
export declare function CanInstantiate<Context extends TProperties, Types extends TSchema[]>(context: Context, types: [...Types]): TCanInstantiate<Context, Types>;
|
|
57
|
+
export type TCanInstantiate<Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TRef ? false : TCanInstantiate<Right> : true;
|
|
58
|
+
export declare function CanInstantiate<Types extends TSchema[]>(types: [...Types]): TCanInstantiate<Types>;
|
|
61
59
|
type ModifierAction = 'add' | 'remove' | 'none';
|
|
62
60
|
type TModifierActions<Type extends TSchema, Readonly extends ModifierAction, Optional extends ModifierAction> = (Type extends TReadonlyRemoveAction<infer Type extends TSchema> ? TModifierActions<Type, 'remove', Optional> : Type extends TOptionalRemoveAction<infer Type extends TSchema> ? TModifierActions<Type, Readonly, 'remove'> : Type extends TReadonlyAddAction<infer Type extends TSchema> ? TModifierActions<Type, 'add', Optional> : Type extends TOptionalAddAction<infer Type extends TSchema> ? TModifierActions<Type, Readonly, 'add'> : [
|
|
63
61
|
Type,
|
|
@@ -137,7 +135,7 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
137
135
|
] extends ['Omit', [infer Type extends TSchema, infer Indexer extends TSchema]] ? TOmitInstantiate<Context, State, Type, Indexer> : [
|
|
138
136
|
Action,
|
|
139
137
|
Parameters
|
|
140
|
-
] extends ['
|
|
138
|
+
] extends ['ReadonlyObject', [infer Type extends TSchema]] ? TReadonlyObjectInstantiate<Context, State, Type> : [
|
|
141
139
|
Action,
|
|
142
140
|
Parameters
|
|
143
141
|
] extends ['Record', [infer Key extends TSchema, infer Value extends TSchema]] ? TRecordInstantiate<Context, State, Key, Value> : [
|
|
@@ -10,10 +10,10 @@ import { IsReadonly, ReadonlyAdd, ReadonlyRemove } from '../types/_readonly.mjs'
|
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
11
|
// Types
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
|
+
import { IsBase } from '../types/base.mjs';
|
|
13
14
|
import { IsSchema } from '../types/schema.mjs';
|
|
14
15
|
import { Array, IsArray, ArrayOptions } from '../types/array.mjs';
|
|
15
16
|
import { AsyncIterator, IsAsyncIterator, AsyncIteratorOptions } from '../types/async-iterator.mjs';
|
|
16
|
-
import { IsBase } from '../types/base.mjs';
|
|
17
17
|
import { Constructor, IsConstructor, ConstructorOptions } from '../types/constructor.mjs';
|
|
18
18
|
import { Deferred, IsDeferred } from '../types/deferred.mjs';
|
|
19
19
|
import { _Function_, IsFunction, FunctionOptions } from '../types/function.mjs';
|
|
@@ -21,7 +21,7 @@ import { IsCall } from '../types/call.mjs';
|
|
|
21
21
|
import { Intersect, IsIntersect, IntersectOptions } from '../types/intersect.mjs';
|
|
22
22
|
import { Iterator, IsIterator, IteratorOptions } from '../types/iterator.mjs';
|
|
23
23
|
import { Object, IsObject, ObjectOptions } from '../types/object.mjs';
|
|
24
|
-
import {
|
|
24
|
+
import { _Promise_, IsPromise, PromiseOptions } from '../types/promise.mjs';
|
|
25
25
|
import { RecordFromPattern, IsRecord, RecordPattern, RecordValue } from '../types/record.mjs';
|
|
26
26
|
import { Tuple, IsTuple, TupleOptions } from '../types/tuple.mjs';
|
|
27
27
|
import { Union, IsUnion, UnionOptions } from '../types/union.mjs';
|
|
@@ -56,7 +56,7 @@ import { OptionsInstantiate } from './options/instantiate.mjs';
|
|
|
56
56
|
import { ParametersInstantiate } from './parameters/instantiate.mjs';
|
|
57
57
|
import { PartialInstantiate } from './partial/instantiate.mjs';
|
|
58
58
|
import { PickInstantiate } from './pick/instantiate.mjs';
|
|
59
|
-
import {
|
|
59
|
+
import { ReadonlyObjectInstantiate } from './readonly-object/instantiate.mjs';
|
|
60
60
|
import { RecordInstantiate } from './record/instantiate.mjs';
|
|
61
61
|
import { RefInstantiate } from './ref/instantiate.mjs';
|
|
62
62
|
import { RequiredInstantiate } from './required/instantiate.mjs';
|
|
@@ -65,21 +65,12 @@ import { TemplateLiteralInstantiate } from './template-literal/instantiate.mjs';
|
|
|
65
65
|
import { UncapitalizeInstantiate } from './intrinsics/instantiate.mjs';
|
|
66
66
|
import { UppercaseInstantiate } from './intrinsics/instantiate.mjs';
|
|
67
67
|
import { RestSpread } from './rest/index.mjs';
|
|
68
|
-
function
|
|
69
|
-
return (ref in context);
|
|
70
|
-
}
|
|
71
|
-
function CanInstantiateType(context, type) {
|
|
72
|
-
return (IsIntersect(type) ? CanInstantiate(context, type.allOf) :
|
|
73
|
-
IsUnion(type) ? CanInstantiate(context, type.anyOf) :
|
|
74
|
-
IsRef(type) ? CanInstantiateRef(context, type.$ref) :
|
|
75
|
-
true);
|
|
76
|
-
}
|
|
77
|
-
export function CanInstantiate(context, types) {
|
|
68
|
+
export function CanInstantiate(types) {
|
|
78
69
|
const [left, ...right] = types;
|
|
79
70
|
return (IsSchema(left)
|
|
80
|
-
?
|
|
81
|
-
?
|
|
82
|
-
:
|
|
71
|
+
? IsRef(left)
|
|
72
|
+
? false
|
|
73
|
+
: CanInstantiate(right)
|
|
83
74
|
: true);
|
|
84
75
|
}
|
|
85
76
|
function ModifierActions(type, readonly, optional) {
|
|
@@ -133,7 +124,7 @@ function InstantiateDeferred(context, state, action, parameters, options) {
|
|
|
133
124
|
Guard.IsEqual(action, 'Parameters') ? ParametersInstantiate(context, state, parameters[0], options) :
|
|
134
125
|
Guard.IsEqual(action, 'Partial') ? PartialInstantiate(context, state, parameters[0], options) :
|
|
135
126
|
Guard.IsEqual(action, 'Omit') ? OmitInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
136
|
-
Guard.IsEqual(action, '
|
|
127
|
+
Guard.IsEqual(action, 'ReadonlyObject') ? ReadonlyObjectInstantiate(context, state, parameters[0], options) :
|
|
137
128
|
Guard.IsEqual(action, 'Record') ? RecordInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
138
129
|
Guard.IsEqual(action, 'Required') ? RequiredInstantiate(context, state, parameters[0], options) :
|
|
139
130
|
Guard.IsEqual(action, 'ReturnType') ? ReturnTypeInstantiate(context, state, parameters[0], options) :
|
|
@@ -156,7 +147,7 @@ export function InstantiateType(context, state, input) {
|
|
|
156
147
|
IsIntersect(type) ? Intersect(InstantiateTypes(context, state, type.allOf), IntersectOptions(type)) :
|
|
157
148
|
IsIterator(type) ? Iterator(InstantiateType(context, state, type.iteratorItems), IteratorOptions(type)) :
|
|
158
149
|
IsObject(type) ? Object(InstantiateProperties(context, state, type.properties), ObjectOptions(type)) :
|
|
159
|
-
IsPromise(type) ?
|
|
150
|
+
IsPromise(type) ? _Promise_(InstantiateType(context, state, type.item), PromiseOptions(type)) :
|
|
160
151
|
IsRecord(type) ? RecordFromPattern(RecordPattern(type), InstantiateType(context, state, RecordValue(type))) :
|
|
161
152
|
IsRest(type) ? Rest(InstantiateType(context, state, type.items)) :
|
|
162
153
|
IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) :
|
|
@@ -6,11 +6,13 @@ import { type TInterfaceDeferred } from '../../action/index.mjs';
|
|
|
6
6
|
import { type TState, type TCanInstantiate } from '../instantiate.mjs';
|
|
7
7
|
import { type TInstantiateProperties } from '../instantiate.mjs';
|
|
8
8
|
import { type TInstantiateTypes } from '../instantiate.mjs';
|
|
9
|
-
type
|
|
9
|
+
type TInterfaceOperation<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TEvaluateIntersect<[...Heritage, TObject<Properties>]>> = Result;
|
|
10
|
+
export type TInterfaceAction<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TCanInstantiate<Heritage> extends true ? TInterfaceOperation<Heritage, Properties> : TInterfaceDeferred<Heritage, Properties>> = Result;
|
|
11
|
+
export declare function InterfaceAction<Heritage extends TSchema[], Properties extends TProperties>(heritage: [...Heritage], properties: Properties, options: TSchemaOptions): TInterfaceAction<Heritage, Properties>;
|
|
12
|
+
export type TInterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, {
|
|
10
13
|
callstack: [];
|
|
11
|
-
}, Heritage>,
|
|
14
|
+
}, Heritage>, InstantiatedProperties extends TProperties = TInstantiateProperties<Context, {
|
|
12
15
|
callstack: [];
|
|
13
|
-
}, Properties
|
|
14
|
-
export type TInterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties> = TCanInstantiate<Context, Heritage> extends true ? TInterfaceImmediate<Context, State, Heritage, Properties> : TInterfaceDeferred<Heritage, Properties>;
|
|
16
|
+
}, Properties>> = TInterfaceAction<InstantiatedHeritage, InstantiatedProperties>;
|
|
15
17
|
export declare function InterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties>(context: Context, state: State, heritage: [...Heritage], properties: Properties, options: TSchemaOptions): TInterfaceInstantiate<Context, State, Heritage, Properties>;
|
|
16
18
|
export {};
|
|
@@ -6,14 +6,18 @@ import { InterfaceDeferred } from '../../action/index.mjs';
|
|
|
6
6
|
import { CanInstantiate } from '../instantiate.mjs';
|
|
7
7
|
import { InstantiateProperties } from '../instantiate.mjs';
|
|
8
8
|
import { InstantiateTypes } from '../instantiate.mjs';
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
function InterfaceOperation(heritage, properties) {
|
|
10
|
+
const result = EvaluateIntersect([...heritage, Object(properties)]);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
export function InterfaceAction(heritage, properties, options) {
|
|
14
|
+
const result = CanInstantiate(heritage)
|
|
15
|
+
? Memory.Update(InterfaceOperation(heritage, properties), {}, options)
|
|
16
|
+
: InterfaceDeferred(heritage, properties, options);
|
|
17
|
+
return result;
|
|
14
18
|
}
|
|
15
19
|
export function InterfaceInstantiate(context, state, heritage, properties, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
const instantiatedHeritage = InstantiateTypes(context, state, heritage);
|
|
21
|
+
const instantiatedProperties = InstantiateProperties(context, state, properties);
|
|
22
|
+
return InterfaceAction(instantiatedHeritage, instantiatedProperties, options);
|
|
19
23
|
}
|
|
@@ -19,16 +19,20 @@ interface TUncapitalizeMapping extends TMappingType {
|
|
|
19
19
|
interface TUppercaseMapping extends TMappingType {
|
|
20
20
|
output: Uppercase<this['input']>;
|
|
21
21
|
}
|
|
22
|
-
type
|
|
23
|
-
export
|
|
22
|
+
export type TCapitalizeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<TCapitalizeMapping, Type> : TCapitalizeDeferred<Type>> = Result;
|
|
23
|
+
export declare function CapitalizeAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TCapitalizeAction<Type>;
|
|
24
|
+
export type TLowercaseAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<TLowercaseMapping, Type> : TLowercaseDeferred<Type>> = Result;
|
|
25
|
+
export declare function LowercaseAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TLowercaseAction<Type>;
|
|
26
|
+
export type TUncapitalizeAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<TUncapitalizeMapping, Type> : TUncapitalizeDeferred<Type>> = Result;
|
|
27
|
+
export declare function UncapitalizeAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TUncapitalizeAction<Type>;
|
|
28
|
+
export type TUppercaseAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<TUppercaseMapping, Type> : TUppercaseDeferred<Type>> = Result;
|
|
29
|
+
export declare function UppercaseAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TUppercaseAction<Type>;
|
|
30
|
+
export type TCapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TCapitalizeAction<InstantiatedType>;
|
|
24
31
|
export declare function CapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TCapitalizeInstantiate<Context, State, Type>;
|
|
25
|
-
type
|
|
26
|
-
export type TLowercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TLowercaseImmediate<Context, State, Type> : TLowercaseDeferred<Type>;
|
|
32
|
+
export type TLowercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TLowercaseAction<InstantiatedType>;
|
|
27
33
|
export declare function LowercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TLowercaseInstantiate<Context, State, Type>;
|
|
28
|
-
type
|
|
29
|
-
export type TUncapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TUncapitalizeImmediate<Context, State, Type> : TUncapitalizeDeferred<Type>;
|
|
34
|
+
export type TUncapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TUncapitalizeAction<InstantiatedType>;
|
|
30
35
|
export declare function UncapitalizeInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TUncapitalizeInstantiate<Context, State, Type>;
|
|
31
|
-
type
|
|
32
|
-
export type TUppercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TUppercaseImmediate<Context, State, Type> : TUppercaseDeferred<Type>;
|
|
36
|
+
export type TUppercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TUppercaseAction<InstantiatedType>;
|
|
33
37
|
export declare function UppercaseInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TUppercaseInstantiate<Context, State, Type>;
|
|
34
38
|
export {};
|
|
@@ -10,39 +10,43 @@ const CapitalizeMapping = (input) => input[0].toUpperCase() + input.slice(1);
|
|
|
10
10
|
const LowercaseMapping = (input) => input.toLowerCase();
|
|
11
11
|
const UncapitalizeMapping = (input) => input[0].toLowerCase() + input.slice(1);
|
|
12
12
|
const UppercaseMapping = (input) => input.toUpperCase();
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
export function CapitalizeAction(type, options) {
|
|
14
|
+
const result = CanInstantiate([type])
|
|
15
|
+
? Memory.Update(FromType(CapitalizeMapping, type), {}, options)
|
|
16
|
+
: CapitalizeDeferred(type, options);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
export function LowercaseAction(type, options) {
|
|
20
|
+
const result = CanInstantiate([type])
|
|
21
|
+
? Memory.Update(FromType(LowercaseMapping, type), {}, options)
|
|
22
|
+
: LowercaseDeferred(type, options);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
export function UncapitalizeAction(type, options) {
|
|
26
|
+
const result = CanInstantiate([type])
|
|
27
|
+
? Memory.Update(FromType(UncapitalizeMapping, type), {}, options)
|
|
28
|
+
: UncapitalizeDeferred(type, options);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
export function UppercaseAction(type, options) {
|
|
32
|
+
const result = CanInstantiate([type])
|
|
33
|
+
? Memory.Update(FromType(UppercaseMapping, type), {}, options)
|
|
34
|
+
: UppercaseDeferred(type, options);
|
|
35
|
+
return result;
|
|
16
36
|
}
|
|
17
37
|
export function CapitalizeInstantiate(context, state, type, options) {
|
|
18
|
-
return (CanInstantiate(context, [type])
|
|
19
|
-
? CapitalizeImmediate(context, state, type, options)
|
|
20
|
-
: CapitalizeDeferred(type, options));
|
|
21
|
-
}
|
|
22
|
-
function LowercaseImmediate(context, state, type, options) {
|
|
23
38
|
const instantiatedType = InstantiateType(context, state, type);
|
|
24
|
-
return
|
|
39
|
+
return CapitalizeAction(instantiatedType, options);
|
|
25
40
|
}
|
|
26
41
|
export function LowercaseInstantiate(context, state, type, options) {
|
|
27
|
-
return (CanInstantiate(context, [type])
|
|
28
|
-
? LowercaseImmediate(context, state, type, options)
|
|
29
|
-
: LowercaseDeferred(type, options));
|
|
30
|
-
}
|
|
31
|
-
function UncapitalizeImmediate(context, state, type, options) {
|
|
32
42
|
const instantiatedType = InstantiateType(context, state, type);
|
|
33
|
-
return
|
|
43
|
+
return LowercaseAction(instantiatedType, options);
|
|
34
44
|
}
|
|
35
45
|
export function UncapitalizeInstantiate(context, state, type, options) {
|
|
36
|
-
return (CanInstantiate(context, [type])
|
|
37
|
-
? UncapitalizeImmediate(context, state, type, options)
|
|
38
|
-
: UncapitalizeDeferred(type, options));
|
|
39
|
-
}
|
|
40
|
-
function UppercaseImmediate(context, state, type, options) {
|
|
41
46
|
const instantiatedType = InstantiateType(context, state, type);
|
|
42
|
-
return
|
|
47
|
+
return UncapitalizeAction(instantiatedType, options);
|
|
43
48
|
}
|
|
44
49
|
export function UppercaseInstantiate(context, state, type, options) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
: UppercaseDeferred(type, options));
|
|
50
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
51
|
+
return UppercaseAction(instantiatedType, options);
|
|
48
52
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TAny } from '../../types/any.mjs';
|
|
4
|
+
import { type TArray } from '../../types/array.mjs';
|
|
5
|
+
import { type TNever } from '../../types/never.mjs';
|
|
6
|
+
import { type TObject } from '../../types/object.mjs';
|
|
7
|
+
import { type TRecord } from '../../types/record.mjs';
|
|
8
|
+
import { type TTuple } from '../../types/tuple.mjs';
|
|
9
|
+
import { type TFromAny } from './from-any.mjs';
|
|
10
|
+
import { type TFromArray } from './from-array.mjs';
|
|
11
|
+
import { type TFromObject } from './from-object.mjs';
|
|
12
|
+
import { type TFromRecord } from './from-record.mjs';
|
|
13
|
+
import { type TFromTuple } from './from-tuple.mjs';
|
|
14
|
+
export type TFromType<Type extends TSchema> = (Type extends TAny ? TFromAny : Type extends TArray<infer Type extends TSchema> ? TFromArray<Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<Properties> : Type extends TRecord ? TFromRecord<Type> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<Types> : TNever);
|
|
15
|
+
export declare function FromType<Type extends TSchema>(type: Type): TFromType<Type>;
|