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,23 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { IsAny } from '../../types/any.mjs';
|
|
3
|
+
import { IsArray } from '../../types/array.mjs';
|
|
4
|
+
import { Never } from '../../types/never.mjs';
|
|
5
|
+
import { IsObject } from '../../types/object.mjs';
|
|
6
|
+
import { IsRecord } from '../../types/record.mjs';
|
|
7
|
+
import { IsTuple } from '../../types/tuple.mjs';
|
|
8
|
+
// ------------------------------------------------------------------
|
|
9
|
+
// Computed
|
|
10
|
+
// ------------------------------------------------------------------
|
|
11
|
+
import { FromAny } from './from-any.mjs';
|
|
12
|
+
import { FromArray } from './from-array.mjs';
|
|
13
|
+
import { FromObject } from './from-object.mjs';
|
|
14
|
+
import { FromRecord } from './from-record.mjs';
|
|
15
|
+
import { FromTuple } from './from-tuple.mjs';
|
|
16
|
+
export function FromType(type) {
|
|
17
|
+
return (IsAny(type) ? FromAny() :
|
|
18
|
+
IsArray(type) ? FromArray(type.items) :
|
|
19
|
+
IsObject(type) ? FromObject(type.properties) :
|
|
20
|
+
IsRecord(type) ? FromRecord(type) :
|
|
21
|
+
IsTuple(type) ? FromTuple(type.items) :
|
|
22
|
+
Never());
|
|
23
|
+
}
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
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
3
|
import { type TCyclic } from '../../types/cyclic.mjs';
|
|
6
4
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
7
|
-
import { type TNever } from '../../types/never.mjs';
|
|
8
|
-
import { type TObject } from '../../types/object.mjs';
|
|
9
|
-
import { type TRecord } from '../../types/record.mjs';
|
|
10
|
-
import { type TTuple } from '../../types/tuple.mjs';
|
|
11
5
|
import { type TUnion } from '../../types/union.mjs';
|
|
12
6
|
import { type TKeyOfDeferred } from '../../action/keyof.mjs';
|
|
13
7
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
14
8
|
import { type TCollapseToObject } from '../object/index.mjs';
|
|
15
|
-
import { type
|
|
16
|
-
import { type TFromArray } from './from-array.mjs';
|
|
17
|
-
import { type TFromObject } from './from-object.mjs';
|
|
18
|
-
import { type TFromRecord } from './from-record.mjs';
|
|
19
|
-
import { type TFromTuple } from './from-tuple.mjs';
|
|
9
|
+
import { type TFromType } from './from-type.mjs';
|
|
20
10
|
type TNormalizeType<Type extends TSchema, Result extends TSchema = (Type extends TCyclic | TIntersect | TUnion ? TCollapseToObject<Type> : Type)> = Result;
|
|
21
|
-
export type TKeyOfAction<Type extends TSchema,
|
|
22
|
-
export declare function KeyOfAction<Type extends TSchema>(type: Type): TKeyOfAction<Type>;
|
|
23
|
-
export type
|
|
24
|
-
export declare function KeyOfImmediate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TKeyOfImmediate<Context, State, Type>;
|
|
25
|
-
export type TKeyOfInstantiate<Context extends TProperties, State extends TState, Type extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TKeyOfImmediate<Context, State, Type> : TKeyOfDeferred<Type>;
|
|
11
|
+
export type TKeyOfAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<TNormalizeType<Type>> : TKeyOfDeferred<Type>> = Result;
|
|
12
|
+
export declare function KeyOfAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TKeyOfAction<Type>;
|
|
13
|
+
export type TKeyOfInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TKeyOfAction<InstantiatedType>;
|
|
26
14
|
export declare function KeyOfInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TKeyOfInstantiate<Context, State, Type>;
|
|
27
15
|
export {};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
-
import { IsAny } from '../../types/any.mjs';
|
|
4
|
-
import { IsArray } from '../../types/array.mjs';
|
|
5
3
|
import { IsCyclic } from '../../types/cyclic.mjs';
|
|
6
4
|
import { IsIntersect } from '../../types/intersect.mjs';
|
|
7
|
-
import { Never } from '../../types/never.mjs';
|
|
8
|
-
import { IsObject } from '../../types/object.mjs';
|
|
9
|
-
import { IsRecord } from '../../types/record.mjs';
|
|
10
|
-
import { IsTuple } from '../../types/tuple.mjs';
|
|
11
5
|
import { IsUnion } from '../../types/union.mjs';
|
|
12
6
|
import { KeyOfDeferred } from '../../action/keyof.mjs';
|
|
13
7
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
@@ -15,31 +9,17 @@ import { CollapseToObject } from '../object/index.mjs';
|
|
|
15
9
|
// ------------------------------------------------------------------
|
|
16
10
|
// Computed
|
|
17
11
|
// ------------------------------------------------------------------
|
|
18
|
-
import {
|
|
19
|
-
import { FromArray } from './from-array.mjs';
|
|
20
|
-
import { FromObject } from './from-object.mjs';
|
|
21
|
-
import { FromRecord } from './from-record.mjs';
|
|
22
|
-
import { FromTuple } from './from-tuple.mjs';
|
|
12
|
+
import { FromType } from './from-type.mjs';
|
|
23
13
|
function NormalizeType(type) {
|
|
24
|
-
const result = (IsCyclic(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) :
|
|
25
|
-
type);
|
|
14
|
+
const result = (IsCyclic(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) : type);
|
|
26
15
|
return result;
|
|
27
16
|
}
|
|
28
|
-
export function KeyOfAction(type) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
IsObject(normal) ? FromObject(normal.properties) :
|
|
33
|
-
IsRecord(normal) ? FromRecord(normal) :
|
|
34
|
-
IsTuple(normal) ? FromTuple(normal.items) :
|
|
35
|
-
Never());
|
|
36
|
-
}
|
|
37
|
-
export function KeyOfImmediate(context, state, type, options) {
|
|
38
|
-
const instantiatedType = InstantiateType(context, state, type);
|
|
39
|
-
return Memory.Update(KeyOfAction(instantiatedType), {}, options);
|
|
17
|
+
export function KeyOfAction(type, options) {
|
|
18
|
+
return (CanInstantiate([type])
|
|
19
|
+
? Memory.Update(FromType(NormalizeType(type)), {}, options)
|
|
20
|
+
: KeyOfDeferred(type, options));
|
|
40
21
|
}
|
|
41
22
|
export function KeyOfInstantiate(context, state, type, options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
: KeyOfDeferred(type, options));
|
|
23
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
24
|
+
return KeyOfAction(instantiatedType, options);
|
|
45
25
|
}
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import { Memory } from '../../../system/memory/index.mjs';
|
|
2
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
3
|
-
import { type TLiteral } from '../../types/literal.mjs';
|
|
4
|
-
import { type TObject } from '../../types/object.mjs';
|
|
5
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
6
3
|
import { type TIdentifier } from '../../types/identifier.mjs';
|
|
7
|
-
import { type TTemplateLiteral } from '../../types/template-literal.mjs';
|
|
8
4
|
import { type TMappedDeferred } from '../../action/mapped.mjs';
|
|
9
|
-
import { type TTemplateLiteralDecode } from '../template-literal/decode.mjs';
|
|
10
5
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
11
|
-
import { type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type
|
|
15
|
-
[_ in Identifier['name']]: Variant;
|
|
16
|
-
}>, InstantiatedAs extends TSchema = TInstantiateType<VariantContext, State, As>, CanonicalAs extends TSchema = TCanonicalAs<InstantiatedAs>, InstantiatedProperty extends TSchema = TInstantiateType<VariantContext, State, Property>, Result extends TProperties = CanonicalAs extends TLiteral<string | number> ? {
|
|
17
|
-
[_ in CanonicalAs['const']]: InstantiatedProperty;
|
|
18
|
-
} : {}> = Result;
|
|
19
|
-
type TMappedProperties<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Variants extends TSchema[], As extends TSchema, Property extends TSchema, Result extends TProperties[] = []> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TMappedProperties<Context, State, Identifier, Right, As, Property, [...Result, TMappedVariant<Context, State, Identifier, Left, As, Property>]> : Result);
|
|
20
|
-
type TReduceProperties<Properties extends TProperties[], Result extends TSchema[] = []> = (Properties extends [infer Left extends TProperties, ...infer Right extends TProperties[]] ? TReduceProperties<Right, [...Result, TObject<Left>]> : Result);
|
|
21
|
-
type TMappedAction<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, Variants extends TSchema[] = TMappedVariants<Type>, MappedProperties extends TProperties[] = TMappedProperties<Context, State, Identifier, Variants, As, Property>, MappedObjects extends TSchema[] = TReduceProperties<MappedProperties>, Result extends TSchema = TEvaluateIntersect<MappedObjects>> = Result;
|
|
22
|
-
type TMappedImmediate<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TMappedAction<Context, State, Identifier, InstantiatedType, As, Property>;
|
|
23
|
-
export type TMappedInstantiate<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TMappedImmediate<Context, State, Identifier, Type, As, Property> : TMappedDeferred<Identifier, Type, As, Property>;
|
|
6
|
+
import { type TMappedOperation } from './mapped-operation.mjs';
|
|
7
|
+
export type TMappedAction<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TMappedOperation<Context, State, Identifier, Type, As, Property> : TMappedDeferred<Identifier, Type, As, Property>> = Result;
|
|
8
|
+
export declare function MappedAction<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema>(context: Context, state: State, identifier: Identifier, type: Type, as: As, property: Property, options: TSchemaOptions): TMappedAction<Context, State, Identifier, Type, As, Property>;
|
|
9
|
+
export type TMappedInstantiate<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, InstaniatedType extends TSchema = TInstantiateType<Context, State, Type>> = TMappedAction<Context, State, Identifier, InstaniatedType, As, Property>;
|
|
24
10
|
export declare function MappedInstantiate<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema>(context: Context, state: State, identifier: Identifier, type: Type, as: As, property: Property, options: TSchemaOptions): TMappedInstantiate<Context, State, Identifier, Type, As, Property>;
|
|
25
|
-
export {};
|
|
@@ -1,50 +1,15 @@
|
|
|
1
|
-
// deno-lint-ignore-file ban-types
|
|
2
1
|
// deno-fmt-ignore-file
|
|
3
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
4
|
-
import { IsLiteralNumber, IsLiteralString } from '../../types/literal.mjs';
|
|
5
|
-
import { Object } from '../../types/object.mjs';
|
|
6
|
-
import { IsTemplateLiteral } from '../../types/template-literal.mjs';
|
|
7
3
|
import { MappedDeferred } from '../../action/mapped.mjs';
|
|
8
|
-
import { TemplateLiteralDecode } from '../template-literal/decode.mjs';
|
|
9
4
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { MappedOperation } from './mapped-operation.mjs';
|
|
6
|
+
export function MappedAction(context, state, identifier, type, as, property, options) {
|
|
7
|
+
const result = CanInstantiate([type])
|
|
8
|
+
? Memory.Update(MappedOperation(context, state, identifier, type, as, property), {}, options)
|
|
9
|
+
: MappedDeferred(identifier, type, as, property, options);
|
|
14
10
|
return result;
|
|
15
11
|
}
|
|
16
|
-
function MappedVariant(context, state, identifier, variant, as, property) {
|
|
17
|
-
const variantContext = Memory.Assign(context, { [identifier['name']]: variant });
|
|
18
|
-
const instantiatedAs = InstantiateType(variantContext, state, as);
|
|
19
|
-
const canonicalAs = CanonicalAs(instantiatedAs);
|
|
20
|
-
const instantiatedProperty = InstantiateType(variantContext, state, property);
|
|
21
|
-
return (IsLiteralNumber(canonicalAs) || IsLiteralString(canonicalAs)
|
|
22
|
-
? { [canonicalAs.const]: instantiatedProperty }
|
|
23
|
-
: {});
|
|
24
|
-
}
|
|
25
|
-
function MappedProperties(context, state, identifier, variants, as, property) {
|
|
26
|
-
return variants.reduce((result, left) => {
|
|
27
|
-
return [...result, MappedVariant(context, state, identifier, left, as, property)];
|
|
28
|
-
}, []);
|
|
29
|
-
}
|
|
30
|
-
function MappedObjects(properties) {
|
|
31
|
-
return properties.reduce((result, left) => {
|
|
32
|
-
return [...result, Object(left)];
|
|
33
|
-
}, []);
|
|
34
|
-
}
|
|
35
|
-
function MappedAction(context, state, identifier, type, as, property) {
|
|
36
|
-
const variants = MappedVariants(type);
|
|
37
|
-
const mappedProperties = MappedProperties(context, state, identifier, variants, as, property);
|
|
38
|
-
const mappedObjects = MappedObjects(mappedProperties);
|
|
39
|
-
const result = EvaluateIntersect(mappedObjects);
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
function MappedImmediate(context, state, identifier, type, as, property, options) {
|
|
43
|
-
const instantiatedType = InstantiateType(context, state, type);
|
|
44
|
-
return Memory.Update(MappedAction(context, state, identifier, instantiatedType, as, property), {}, options);
|
|
45
|
-
}
|
|
46
12
|
export function MappedInstantiate(context, state, identifier, type, as, property, options) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: MappedDeferred(identifier, type, as, property, options));
|
|
13
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
14
|
+
return MappedAction(context, state, identifier, instantiatedType, as, property, options);
|
|
50
15
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
2
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
3
|
+
import { type TLiteral } from '../../types/literal.mjs';
|
|
4
|
+
import { type TObject } from '../../types/object.mjs';
|
|
5
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
6
|
+
import { type TIdentifier } from '../../types/identifier.mjs';
|
|
7
|
+
import { type TTemplateLiteral } from '../../types/template-literal.mjs';
|
|
8
|
+
import { type TTemplateLiteralDecode } from '../template-literal/decode.mjs';
|
|
9
|
+
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
10
|
+
import { type TEvaluateIntersect } from '../evaluate/index.mjs';
|
|
11
|
+
import { type TMappedVariants } from './mapped-variants.mjs';
|
|
12
|
+
type TCanonicalAs<InstantiatedAs extends TSchema, Result extends TSchema = InstantiatedAs extends TTemplateLiteral<infer Pattern extends string> ? TTemplateLiteralDecode<Pattern> : InstantiatedAs> = Result;
|
|
13
|
+
type TMappedVariant<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Variant extends TSchema, As extends TSchema, Property extends TSchema, VariantContext extends TProperties = Memory.TAssign<Context, {
|
|
14
|
+
[_ in Identifier['name']]: Variant;
|
|
15
|
+
}>, InstantiatedAs extends TSchema = TInstantiateType<VariantContext, State, As>, CanonicalAs extends TSchema = TCanonicalAs<InstantiatedAs>, InstantiatedProperty extends TSchema = TInstantiateType<VariantContext, State, Property>, Result extends TProperties = CanonicalAs extends TLiteral<string | number> ? {
|
|
16
|
+
[_ in CanonicalAs['const']]: InstantiatedProperty;
|
|
17
|
+
} : {}> = Result;
|
|
18
|
+
type TMappedProperties<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Variants extends TSchema[], As extends TSchema, Property extends TSchema, Result extends TProperties[] = []> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TMappedProperties<Context, State, Identifier, Right, As, Property, [...Result, TMappedVariant<Context, State, Identifier, Left, As, Property>]> : Result);
|
|
19
|
+
type TReduceProperties<Properties extends TProperties[], Result extends TSchema[] = []> = (Properties extends [infer Left extends TProperties, ...infer Right extends TProperties[]] ? TReduceProperties<Right, [...Result, TObject<Left>]> : Result);
|
|
20
|
+
export type TMappedOperation<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema, Variants extends TSchema[] = TMappedVariants<Type>, MappedProperties extends TProperties[] = TMappedProperties<Context, State, Identifier, Variants, As, Property>, MappedObjects extends TSchema[] = TReduceProperties<MappedProperties>, Result extends TSchema = TEvaluateIntersect<MappedObjects>> = Result;
|
|
21
|
+
export declare function MappedOperation<Context extends TProperties, State extends TState, Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema>(context: Context, state: State, identifier: Identifier, type: Type, as: As, property: Property): TMappedOperation<Context, State, Identifier, Type, As, Property>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// deno-lint-ignore-file ban-types
|
|
2
|
+
// deno-fmt-ignore-file
|
|
3
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
4
|
+
import { IsLiteralNumber, IsLiteralString } from '../../types/literal.mjs';
|
|
5
|
+
import { Object } from '../../types/object.mjs';
|
|
6
|
+
import { IsTemplateLiteral } from '../../types/template-literal.mjs';
|
|
7
|
+
import { TemplateLiteralDecode } from '../template-literal/decode.mjs';
|
|
8
|
+
import { InstantiateType } from '../instantiate.mjs';
|
|
9
|
+
import { EvaluateIntersect } from '../evaluate/index.mjs';
|
|
10
|
+
import { MappedVariants } from './mapped-variants.mjs';
|
|
11
|
+
function CanonicalAs(instantiatedAs) {
|
|
12
|
+
const result = IsTemplateLiteral(instantiatedAs)
|
|
13
|
+
? TemplateLiteralDecode(instantiatedAs.pattern)
|
|
14
|
+
: instantiatedAs;
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function MappedVariant(context, state, identifier, variant, as, property) {
|
|
18
|
+
const variantContext = Memory.Assign(context, { [identifier['name']]: variant });
|
|
19
|
+
const instantiatedAs = InstantiateType(variantContext, state, as);
|
|
20
|
+
const canonicalAs = CanonicalAs(instantiatedAs);
|
|
21
|
+
const instantiatedProperty = InstantiateType(variantContext, state, property);
|
|
22
|
+
return (IsLiteralNumber(canonicalAs) || IsLiteralString(canonicalAs)
|
|
23
|
+
? { [canonicalAs.const]: instantiatedProperty }
|
|
24
|
+
: {});
|
|
25
|
+
}
|
|
26
|
+
function MappedProperties(context, state, identifier, variants, as, property) {
|
|
27
|
+
return variants.reduce((result, left) => {
|
|
28
|
+
return [...result, MappedVariant(context, state, identifier, left, as, property)];
|
|
29
|
+
}, []);
|
|
30
|
+
}
|
|
31
|
+
function MappedObjects(properties) {
|
|
32
|
+
return properties.reduce((result, left) => {
|
|
33
|
+
return [...result, Object(left)];
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
export function MappedOperation(context, state, identifier, type, as, property) {
|
|
37
|
+
const variants = MappedVariants(type);
|
|
38
|
+
const mappedProperties = MappedProperties(context, state, identifier, variants, as, property);
|
|
39
|
+
const mappedObjects = MappedObjects(mappedProperties);
|
|
40
|
+
const result = EvaluateIntersect(mappedObjects);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
@@ -3,13 +3,12 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TNull } from '../../types/null.mjs';
|
|
4
4
|
import { type TUndefined } from '../../types/undefined.mjs';
|
|
5
5
|
import { type TUnion } from '../../types/union.mjs';
|
|
6
|
-
import { type
|
|
6
|
+
import { type TExcludeAction } from '../exclude/instantiate.mjs';
|
|
7
7
|
import { type TNonNullableDeferred } from '../../action/non-nullable.mjs';
|
|
8
8
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
export type TNonNullableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema> = TCanInstantiate<Context, [Type]> extends true ? TNonNullableImmediate<Context, State, Type> : TNonNullableDeferred<Type>;
|
|
9
|
+
type TNonNullableOperation<Type extends TSchema, Excluded extends TSchema = TUnion<[TNull, TUndefined]>> = TExcludeAction<Type, Excluded>;
|
|
10
|
+
export type TNonNullableAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TNonNullableOperation<Type> : TNonNullableDeferred<Type>> = Result;
|
|
11
|
+
export declare function NonNullableAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TNonNullableAction<Type>;
|
|
12
|
+
export type TNonNullableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TNonNullableAction<InstantiatedType>;
|
|
14
13
|
export declare function NonNullableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TNonNullableInstantiate<Context, State, Type>;
|
|
15
14
|
export {};
|
|
@@ -1,22 +1,22 @@
|
|
|
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 { Null } from '../../types/null.mjs';
|
|
5
4
|
import { Undefined } from '../../types/undefined.mjs';
|
|
6
5
|
import { Union } from '../../types/union.mjs';
|
|
7
|
-
import {
|
|
6
|
+
import { ExcludeAction } from '../exclude/instantiate.mjs';
|
|
8
7
|
import { NonNullableDeferred } from '../../action/non-nullable.mjs';
|
|
9
8
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
10
|
-
function
|
|
9
|
+
function NonNullableOperation(type) {
|
|
11
10
|
const excluded = Union([Null(), Undefined()]);
|
|
12
|
-
return
|
|
11
|
+
return ExcludeAction(type, excluded, {});
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
|
|
13
|
+
export function NonNullableAction(type, options) {
|
|
14
|
+
const result = CanInstantiate([type])
|
|
15
|
+
? Memory.Update(NonNullableOperation(type), {}, options)
|
|
16
|
+
: NonNullableDeferred(type, options);
|
|
17
|
+
return result;
|
|
17
18
|
}
|
|
18
19
|
export function NonNullableInstantiate(context, state, type, options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: NonNullableDeferred(type, options));
|
|
20
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
21
|
+
return NonNullableAction(instantiatedType, options);
|
|
22
22
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TObject } from '../../types/object.mjs';
|
|
4
|
+
import { type TToIndexableKeys } from '../indexable/to-indexable-keys.mjs';
|
|
5
|
+
import { type TToIndexable } from '../indexable/to-indexable.mjs';
|
|
6
|
+
type TNormalKeys<Keys extends string[], UnionKeys extends string = Keys[number], Result extends string | number = (UnionKeys extends `${infer Value extends number}` ? UnionKeys | Value : UnionKeys)> = Result;
|
|
7
|
+
type TFromKeys<Properties extends TProperties, Keys extends string[], Omitted extends TProperties = Omit<Properties, TNormalKeys<Keys>>, Result extends TProperties = {
|
|
8
|
+
[Key in keyof Omitted]: Omitted[Key];
|
|
9
|
+
}> = Result;
|
|
10
|
+
export type TFromType<Type extends TSchema, Indexer extends TSchema, Indexable extends TProperties = TToIndexable<Type>, IndexableKeys extends string[] = TToIndexableKeys<Indexer>, Omitted extends TProperties = TFromKeys<Indexable, IndexableKeys>, Result extends TSchema = TObject<Omitted>> = Result;
|
|
11
|
+
export declare function FromType<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer): TFromType<Type, Indexer>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
+
import { Object } from '../../types/object.mjs';
|
|
4
|
+
import { ToIndexableKeys } from '../indexable/to-indexable-keys.mjs';
|
|
5
|
+
import { ToIndexable } from '../indexable/to-indexable.mjs';
|
|
6
|
+
function FromKeys(properties, keys) {
|
|
7
|
+
const result = Guard.Keys(properties).reduce((result, key) => {
|
|
8
|
+
return keys.includes(key) ? result : { ...result, [key]: properties[key] };
|
|
9
|
+
}, {});
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
export function FromType(type, indexer) {
|
|
13
|
+
const indexable = ToIndexable(type);
|
|
14
|
+
const indexableKeys = ToIndexableKeys(indexer);
|
|
15
|
+
const omitted = FromKeys(indexable, indexableKeys);
|
|
16
|
+
const result = Object(omitted);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
@@ -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 TObject } from '../../types/object.mjs';
|
|
4
|
-
import { type TToIndexableKeys } from '../indexable/to-indexable-keys.mjs';
|
|
5
|
-
import { type TToIndexable } from '../indexable/to-indexable.mjs';
|
|
6
3
|
import { type TOmitDeferred } from '../../action/omit.mjs';
|
|
7
4
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type TOmitAction<Type extends TSchema, Indexer extends TSchema, Indexable extends TProperties = TToIndexable<Type>, IndexableKeys extends string[] = TToIndexableKeys<Indexer>, Omitted extends TProperties = TFromKeys<Indexable, IndexableKeys>, Result extends TSchema = TObject<Omitted>> = Result;
|
|
13
|
-
type TOmitImmediate<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>, Result extends TSchema = TOmitAction<InstantiatedType, InstantiatedIndexer>> = Result;
|
|
14
|
-
export type TOmitInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema> = TCanInstantiate<Context, [Type, Indexer]> extends true ? TOmitImmediate<Context, State, Type, Indexer> : TOmitDeferred<Type, Indexer>;
|
|
5
|
+
import { type TFromType } from './from-type.mjs';
|
|
6
|
+
export type TOmitAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType<Type, Indexer> : TOmitDeferred<Type, Indexer>> = Result;
|
|
7
|
+
export declare function OmitAction<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options: TSchemaOptions): TOmitAction<Type, Indexer>;
|
|
8
|
+
export type TOmitInstantiate<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>> = TOmitAction<InstantiatedType, InstantiatedIndexer>;
|
|
15
9
|
export declare function OmitInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema>(context: Context, state: State, type: Type, indexer: Indexer, options: TSchemaOptions): TOmitInstantiate<Context, State, Type, Indexer>;
|
|
16
|
-
export {};
|
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
-
import { Guard } from '../../../guard/index.mjs';
|
|
4
|
-
import { Object } from '../../types/object.mjs';
|
|
5
|
-
import { ToIndexableKeys } from '../indexable/to-indexable-keys.mjs';
|
|
6
|
-
import { ToIndexable } from '../indexable/to-indexable.mjs';
|
|
7
3
|
import { OmitDeferred } from '../../action/omit.mjs';
|
|
8
4
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import { FromType } from './from-type.mjs';
|
|
6
|
+
export function OmitAction(type, indexer, options) {
|
|
7
|
+
const result = CanInstantiate([type, indexer])
|
|
8
|
+
? Memory.Update(FromType(type, indexer), {}, options)
|
|
9
|
+
: OmitDeferred(type, indexer, options);
|
|
13
10
|
return result;
|
|
14
11
|
}
|
|
15
|
-
function
|
|
16
|
-
const indexable = ToIndexable(type);
|
|
17
|
-
const indexableKeys = ToIndexableKeys(indexer);
|
|
18
|
-
const omitted = FromKeys(indexable, indexableKeys);
|
|
19
|
-
const result = Object(omitted);
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
function OmitImmediate(context, state, type, indexer, options) {
|
|
12
|
+
export function OmitInstantiate(context, state, type, indexer, options) {
|
|
23
13
|
const instantiatedType = InstantiateType(context, state, type);
|
|
24
14
|
const instantiatedIndexer = InstantiateType(context, state, indexer);
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
export function OmitInstantiate(context, state, type, indexer, options) {
|
|
28
|
-
return (CanInstantiate(context, [type, indexer])
|
|
29
|
-
? OmitImmediate(context, state, type, indexer, options)
|
|
30
|
-
: OmitDeferred(type, indexer, options));
|
|
15
|
+
return OmitAction(instantiatedType, instantiatedIndexer, options);
|
|
31
16
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type TProperties } from '../../types/properties.mjs';
|
|
2
2
|
import { type TSchema } from '../../types/schema.mjs';
|
|
3
|
-
import { type TState, type TInstantiateType, TCanInstantiate } from '../instantiate.mjs';
|
|
3
|
+
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
4
4
|
import { type TOptionsDeferred, type TOptions } from '../../action/options.mjs';
|
|
5
|
-
type
|
|
6
|
-
export
|
|
5
|
+
export type TOptionsAction<Type extends TSchema, Options extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TOptions<Type, Options> : TOptionsDeferred<Type, Options>> = Result;
|
|
6
|
+
export declare function OptionsAction<Type extends TSchema, Options extends TSchema>(type: Type, options: Options): TOptionsAction<Type, Options>;
|
|
7
|
+
export type TOptionsInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Options extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TOptionsAction<InstantiatedType, Options>;
|
|
7
8
|
export declare function OptionsInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Options extends TSchema>(context: Context, state: State, type: Type, options: Options): TOptionsInstantiate<Context, State, Type, Options>;
|
|
8
|
-
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
4
4
|
import { OptionsDeferred } from '../../action/options.mjs';
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
export function OptionsAction(type, options) {
|
|
6
|
+
const result = CanInstantiate([type])
|
|
7
|
+
? Memory.Update(type, {}, options)
|
|
8
|
+
: OptionsDeferred(type, options);
|
|
9
|
+
return result;
|
|
8
10
|
}
|
|
9
11
|
export function OptionsInstantiate(context, state, type, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
: OptionsDeferred(type, options));
|
|
12
|
+
const instaniatedType = InstantiateType(context, state, type);
|
|
13
|
+
return OptionsAction(instaniatedType, options);
|
|
13
14
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
3
3
|
import { type TFunction } from '../../types/function.mjs';
|
|
4
|
-
import { type TNever } from '../../types/never.mjs';
|
|
5
4
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
6
5
|
import { type TParametersDeferred } from '../../action/parameters.mjs';
|
|
7
6
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
8
|
-
|
|
7
|
+
import { type TInstantiateElements } from '../instantiate.mjs';
|
|
8
|
+
type TParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TFunction ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, {
|
|
9
9
|
callstack: [];
|
|
10
|
-
}, TTuple<
|
|
11
|
-
type
|
|
12
|
-
export
|
|
10
|
+
}, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
11
|
+
export type TParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TParametersOperation<Type> : TParametersDeferred<Type>> = Result;
|
|
12
|
+
export declare function ParametersAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TParametersAction<Type>;
|
|
13
|
+
export type TParametersInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TParametersAction<InstantiatedType>;
|
|
13
14
|
export declare function ParametersInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TParametersInstantiate<Context, State, Type>;
|
|
14
15
|
export {};
|
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
4
4
|
import { IsFunction } from '../../types/function.mjs';
|
|
5
|
-
import { Never } from '../../types/never.mjs';
|
|
6
5
|
import { Tuple } from '../../types/tuple.mjs';
|
|
7
6
|
import { ParametersDeferred } from '../../action/parameters.mjs';
|
|
8
7
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { InstantiateElements } from '../instantiate.mjs';
|
|
9
|
+
function ParametersOperation(type) {
|
|
10
|
+
const parameters = IsFunction(type) ? type['parameters'] : [];
|
|
11
|
+
const instantiatedParameters = InstantiateElements({}, { callstack: [] }, parameters);
|
|
12
|
+
const result = Tuple(instantiatedParameters);
|
|
13
|
+
return result;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
export function ParametersAction(type, options) {
|
|
16
|
+
const result = CanInstantiate([type])
|
|
17
|
+
? Memory.Update(ParametersOperation(type), {}, options)
|
|
18
|
+
: ParametersDeferred(type, options);
|
|
19
|
+
return result;
|
|
17
20
|
}
|
|
18
21
|
export function ParametersInstantiate(context, state, type, options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: ParametersDeferred(type, options));
|
|
22
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
23
|
+
return ParametersAction(instantiatedType, options);
|
|
22
24
|
}
|
|
@@ -3,7 +3,7 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TPartialDeferred } from '../../action/partial.mjs';
|
|
4
4
|
import { type TFromType } from './from-type.mjs';
|
|
5
5
|
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
type
|
|
7
|
-
export
|
|
6
|
+
export type TPartialAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TFromType<Type> : TPartialDeferred<Type>> = Result;
|
|
7
|
+
export declare function PartialAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TPartialAction<Type>;
|
|
8
|
+
export type TPartialInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TPartialAction<InstantiatedType>;
|
|
8
9
|
export declare function PartialInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TPartialInstantiate<Context, State, Type>;
|
|
9
|
-
export {};
|
|
@@ -3,12 +3,13 @@ import { Memory } from '../../../system/memory/index.mjs';
|
|
|
3
3
|
import { PartialDeferred } from '../../action/partial.mjs';
|
|
4
4
|
import { FromType } from './from-type.mjs';
|
|
5
5
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
export function PartialAction(type, options) {
|
|
7
|
+
const result = CanInstantiate([type])
|
|
8
|
+
? Memory.Update(FromType(type), {}, options)
|
|
9
|
+
: PartialDeferred(type, options);
|
|
10
|
+
return result;
|
|
9
11
|
}
|
|
10
12
|
export function PartialInstantiate(context, state, type, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
: PartialDeferred(type, options));
|
|
13
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
14
|
+
return PartialAction(instantiatedType, options);
|
|
14
15
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
2
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
3
|
+
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
|
+
type TComparable<Indexable extends TProperties> = (keyof Indexable extends string | number ? `${keyof Indexable}` : never);
|
|
8
|
+
type TFromKeys<Indexable extends TProperties, Keys extends string[], Result extends TProperties = {}> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? Left extends TComparable<Indexable> ? TFromKeys<Indexable, Right, Memory.TAssign<Result, {
|
|
9
|
+
[_ in Left]: Indexable[Left];
|
|
10
|
+
}>> : TFromKeys<Indexable, Right, Result> : Result);
|
|
11
|
+
export type TFromType<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;
|
|
12
|
+
export declare function FromType<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer): TFromType<Type, Indexer>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// deno-lint-ignore-file ban-types
|
|
2
|
+
// deno-fmt-ignore-file
|
|
3
|
+
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
|
+
function FromKeys(properties, keys) {
|
|
9
|
+
const result = Guard.Keys(properties).reduce((result, key) => {
|
|
10
|
+
return keys.includes(key) ? Memory.Assign(result, { [key]: properties[key] }) : result;
|
|
11
|
+
}, {});
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
export function FromType(type, indexer) {
|
|
15
|
+
const indexable = ToIndexable(type);
|
|
16
|
+
const keys = ToIndexableKeys(indexer);
|
|
17
|
+
const applied = FromKeys(indexable, keys);
|
|
18
|
+
const result = Object(applied);
|
|
19
|
+
return result;
|
|
20
|
+
}
|