typebox 1.2.3 → 1.2.5
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/type/action/_add_immutable.d.mts +11 -0
- package/build/type/action/_add_immutable.mjs +11 -0
- package/build/type/action/_add_optional.d.mts +11 -0
- package/build/type/action/_add_optional.mjs +11 -0
- package/build/type/action/_add_readonly.d.mts +11 -0
- package/build/type/action/_add_readonly.mjs +11 -0
- package/build/type/action/_remove_immutable.d.mts +11 -0
- package/build/type/action/_remove_immutable.mjs +11 -0
- package/build/type/action/_remove_optional.d.mts +11 -0
- package/build/type/action/_remove_optional.mjs +11 -0
- package/build/type/action/_remove_readonly.d.mts +11 -0
- package/build/type/action/_remove_readonly.mjs +11 -0
- package/build/type/action/index.d.mts +6 -2
- package/build/type/action/index.mjs +6 -2
- package/build/type/action/module.d.mts +8 -7
- package/build/type/action/module.mjs +7 -6
- package/build/type/engine/evaluate/composite.d.mts +10 -6
- package/build/type/engine/evaluate/composite.mjs +10 -6
- package/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/build/type/engine/instantiate.d.mts +33 -16
- package/build/type/engine/instantiate.mjs +61 -61
- package/build/type/engine/module/instantiate.d.mts +7 -7
- package/build/type/engine/module/instantiate.mjs +16 -15
- package/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/build/type/engine/partial/from_object.d.mts +2 -2
- package/build/type/engine/partial/from_object.mjs +2 -2
- package/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/build/type/engine/required/from_object.d.mts +2 -2
- package/build/type/engine/required/from_object.mjs +2 -2
- package/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/build/type/script/mapping.d.mts +42 -42
- package/build/type/script/mapping.mjs +46 -46
- package/build/type/types/_immutable.d.mts +2 -9
- package/build/type/types/_immutable.mjs +2 -10
- package/build/type/types/_optional.d.mts +2 -9
- package/build/type/types/_optional.mjs +2 -11
- package/build/type/types/_readonly.d.mts +2 -9
- package/build/type/types/_readonly.mjs +2 -10
- package/build/type/types/deferred.d.mts +1 -0
- package/build/type/types/deferred.mjs +1 -1
- package/package.json +1 -1
- package/build/type/action/_optional.d.mts +0 -19
- package/build/type/action/_optional.mjs +0 -40
- package/build/type/action/_readonly.d.mts +0 -19
- package/build/type/action/_readonly.mjs +0 -40
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
3
|
import { Guard } from '../../guard/index.mjs';
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
|
-
// Modifiers
|
|
6
|
-
// ------------------------------------------------------------------
|
|
7
|
-
import { IsImmutable, Immutable } from '../types/_immutable.mjs';
|
|
8
|
-
import { IsOptional, OptionalAdd, OptionalRemove } from '../types/_optional.mjs';
|
|
9
|
-
import { IsReadonly, ReadonlyAdd, ReadonlyRemove } from '../types/_readonly.mjs';
|
|
10
|
-
// ------------------------------------------------------------------
|
|
11
5
|
// Types
|
|
12
6
|
// ------------------------------------------------------------------
|
|
13
7
|
import { IsBase } from '../types/base.mjs';
|
|
@@ -28,10 +22,17 @@ import { Union, IsUnion, UnionOptions } from '../types/union.mjs';
|
|
|
28
22
|
import { IsRef } from '../types/ref.mjs';
|
|
29
23
|
import { Rest, IsRest } from '../types/rest.mjs';
|
|
30
24
|
// ------------------------------------------------------------------
|
|
31
|
-
// Modifier
|
|
25
|
+
// Modifier Instantiate
|
|
32
26
|
// ------------------------------------------------------------------
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
27
|
+
import { AddImmutableInstantiate } from './immutable/instantiate_add.mjs';
|
|
28
|
+
import { RemoveImmutableInstantiate } from './immutable/instantiate_remove.mjs';
|
|
29
|
+
import { AddReadonlyInstantiate } from './readonly/instantiate_add.mjs';
|
|
30
|
+
import { RemoveReadonlyInstantiate } from './readonly/instantiate_remove.mjs';
|
|
31
|
+
import { AddOptionalInstantiate } from './optional/instantiate_add.mjs';
|
|
32
|
+
import { RemoveOptionalInstantiate } from './optional/instantiate_remove.mjs';
|
|
33
|
+
import { Optional, IsOptional } from '../types/_optional.mjs';
|
|
34
|
+
import { Immutable, IsImmutable } from '../types/_immutable.mjs';
|
|
35
|
+
import { Readonly, IsReadonly } from '../types/_readonly.mjs';
|
|
35
36
|
// ------------------------------------------------------------------
|
|
36
37
|
// Instantiate
|
|
37
38
|
// ------------------------------------------------------------------
|
|
@@ -73,23 +74,6 @@ export function CanInstantiate(types) {
|
|
|
73
74
|
? false
|
|
74
75
|
: CanInstantiate(right), () => true);
|
|
75
76
|
}
|
|
76
|
-
function ModifierActions(type, readonly, optional) {
|
|
77
|
-
return (IsReadonlyRemoveAction(type) ? ModifierActions(type.type, 'remove', optional) :
|
|
78
|
-
IsOptionalRemoveAction(type) ? ModifierActions(type.type, readonly, 'remove') :
|
|
79
|
-
IsReadonlyAddAction(type) ? ModifierActions(type.type, 'add', optional) :
|
|
80
|
-
IsOptionalAddAction(type) ? ModifierActions(type.type, readonly, 'add') :
|
|
81
|
-
[type, readonly, optional]);
|
|
82
|
-
}
|
|
83
|
-
function ApplyReadonly(action, type) {
|
|
84
|
-
return (Guard.IsEqual(action, 'remove') ? ReadonlyRemove(type) :
|
|
85
|
-
Guard.IsEqual(action, 'add') ? ReadonlyAdd(type) :
|
|
86
|
-
type);
|
|
87
|
-
}
|
|
88
|
-
function ApplyOptional(action, type) {
|
|
89
|
-
return (Guard.IsEqual(action, 'remove') ? OptionalRemove(type) :
|
|
90
|
-
Guard.IsEqual(action, 'add') ? OptionalAdd(type) :
|
|
91
|
-
type);
|
|
92
|
-
}
|
|
93
77
|
export function InstantiateProperties(context, state, properties) {
|
|
94
78
|
return Guard.Keys(properties).reduce((result, key) => {
|
|
95
79
|
return { ...result, [key]: InstantiateType(context, state, properties[key]) };
|
|
@@ -104,40 +88,47 @@ export function InstantiateTypes(context, state, types) {
|
|
|
104
88
|
return types.map(type => InstantiateType(context, state, type));
|
|
105
89
|
}
|
|
106
90
|
function InstantiateDeferred(context, state, action, parameters, options) {
|
|
107
|
-
return (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
91
|
+
return (
|
|
92
|
+
// Modifier Actions
|
|
93
|
+
Guard.IsEqual(action, 'AddImmutable') ? AddImmutableInstantiate(context, state, parameters[0], options) :
|
|
94
|
+
Guard.IsEqual(action, 'RemoveImmutable') ? RemoveImmutableInstantiate(context, state, parameters[0], options) :
|
|
95
|
+
Guard.IsEqual(action, 'AddReadonly') ? AddReadonlyInstantiate(context, state, parameters[0], options) :
|
|
96
|
+
Guard.IsEqual(action, 'RemoveReadonly') ? RemoveReadonlyInstantiate(context, state, parameters[0], options) :
|
|
97
|
+
Guard.IsEqual(action, 'AddOptional') ? AddOptionalInstantiate(context, state, parameters[0], options) :
|
|
98
|
+
Guard.IsEqual(action, 'RemoveOptional') ? RemoveOptionalInstantiate(context, state, parameters[0], options) :
|
|
99
|
+
// Actions
|
|
100
|
+
Guard.IsEqual(action, 'Awaited') ? AwaitedInstantiate(context, state, parameters[0], options) :
|
|
101
|
+
Guard.IsEqual(action, 'Capitalize') ? CapitalizeInstantiate(context, state, parameters[0], options) :
|
|
102
|
+
Guard.IsEqual(action, 'Conditional') ? ConditionalInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) :
|
|
103
|
+
Guard.IsEqual(action, 'ConstructorParameters') ? ConstructorParametersInstantiate(context, state, parameters[0], options) :
|
|
104
|
+
Guard.IsEqual(action, 'Evaluate') ? EvaluateInstantiate(context, state, parameters[0], options) :
|
|
105
|
+
Guard.IsEqual(action, 'Exclude') ? ExcludeInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
106
|
+
Guard.IsEqual(action, 'Extract') ? ExtractInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
107
|
+
Guard.IsEqual(action, 'Index') ? IndexInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
108
|
+
Guard.IsEqual(action, 'InstanceType') ? InstanceTypeInstantiate(context, state, parameters[0], options) :
|
|
109
|
+
Guard.IsEqual(action, 'Interface') ? InterfaceInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
110
|
+
Guard.IsEqual(action, 'KeyOf') ? KeyOfInstantiate(context, state, parameters[0], options) :
|
|
111
|
+
Guard.IsEqual(action, 'Lowercase') ? LowercaseInstantiate(context, state, parameters[0], options) :
|
|
112
|
+
Guard.IsEqual(action, 'Mapped') ? MappedInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) :
|
|
113
|
+
Guard.IsEqual(action, 'Module') ? ModuleInstantiate(context, state, parameters[0], options) :
|
|
114
|
+
Guard.IsEqual(action, 'NonNullable') ? NonNullableInstantiate(context, state, parameters[0], options) :
|
|
115
|
+
Guard.IsEqual(action, 'Pick') ? PickInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
116
|
+
Guard.IsEqual(action, 'Parameters') ? ParametersInstantiate(context, state, parameters[0], options) :
|
|
117
|
+
Guard.IsEqual(action, 'Partial') ? PartialInstantiate(context, state, parameters[0], options) :
|
|
118
|
+
Guard.IsEqual(action, 'Omit') ? OmitInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
119
|
+
Guard.IsEqual(action, 'ReadonlyObject') ? ReadonlyObjectInstantiate(context, state, parameters[0], options) :
|
|
120
|
+
Guard.IsEqual(action, 'Record') ? RecordInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
121
|
+
Guard.IsEqual(action, 'Required') ? RequiredInstantiate(context, state, parameters[0], options) :
|
|
122
|
+
Guard.IsEqual(action, 'ReturnType') ? ReturnTypeInstantiate(context, state, parameters[0], options) :
|
|
123
|
+
Guard.IsEqual(action, 'TemplateLiteral') ? TemplateLiteralInstantiate(context, state, parameters[0], options) :
|
|
124
|
+
Guard.IsEqual(action, 'Uncapitalize') ? UncapitalizeInstantiate(context, state, parameters[0], options) :
|
|
125
|
+
Guard.IsEqual(action, 'Uppercase') ? UppercaseInstantiate(context, state, parameters[0], options) :
|
|
126
|
+
Guard.IsEqual(action, 'With') ? WithInstantiate(context, state, parameters[0], parameters[1]) :
|
|
127
|
+
Deferred(action, parameters, options));
|
|
135
128
|
}
|
|
136
|
-
export function
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
const type = IsBase(modifiers[0]) ? modifiers[0].Clone() : modifiers[0];
|
|
140
|
-
const instantiated = (IsRef(type) ? RefInstantiate(context, state, type, type.$ref) :
|
|
129
|
+
export function InstantiateImmediate(context, state, type) {
|
|
130
|
+
type = (IsBase(type) ? type.Clone() : type);
|
|
131
|
+
const result = (IsRef(type) ? RefInstantiate(context, state, type, type.$ref) :
|
|
141
132
|
IsArray(type) ? _Array_(InstantiateType(context, state, type.items), ArrayOptions(type)) :
|
|
142
133
|
IsAsyncIterator(type) ? AsyncIterator(InstantiateType(context, state, type.iteratorItems), AsyncIteratorOptions(type)) :
|
|
143
134
|
IsCall(type) ? CallInstantiate(context, state, type.target, type.arguments) :
|
|
@@ -154,8 +145,17 @@ export function InstantiateType(context, state, input) {
|
|
|
154
145
|
IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) :
|
|
155
146
|
IsUnion(type) ? Union(InstantiateTypes(context, state, type.anyOf), UnionOptions(type)) :
|
|
156
147
|
type);
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
function WithModifiers(type, instantiatedType) {
|
|
151
|
+
const withImmutable = IsImmutable(type) ? Immutable(instantiatedType) : instantiatedType;
|
|
152
|
+
const withReadonly = IsReadonly(type) ? Readonly(withImmutable) : withImmutable;
|
|
153
|
+
const withOptional = IsOptional(type) ? Optional(withReadonly) : withReadonly;
|
|
154
|
+
return withOptional;
|
|
155
|
+
}
|
|
156
|
+
export function InstantiateType(context, state, type) {
|
|
157
|
+
const instantiatedType = InstantiateImmediate(context, state, type);
|
|
158
|
+
const withModifiers = IsDeferred(type) ? instantiatedType : WithModifiers(type, instantiatedType);
|
|
159
159
|
return withModifiers;
|
|
160
160
|
}
|
|
161
161
|
/** Instantiates computed schematics using the given context and type. */
|
|
@@ -5,15 +5,15 @@ import { type TState } from '../instantiate.mjs';
|
|
|
5
5
|
import { type TCyclicCandidates } from '../cyclic/candidates.mjs';
|
|
6
6
|
import { type TInstantiateCyclic } from '../cyclic/instantiate.mjs';
|
|
7
7
|
import { type TInstantiateType } from '../instantiate.mjs';
|
|
8
|
-
type TInstantiateCyclics<Context extends TProperties, CyclicKeys extends string[], Result extends TProperties = {
|
|
9
|
-
[Key in Extract<keyof
|
|
8
|
+
type TInstantiateCyclics<Context extends TProperties, Declarations extends TProperties, CyclicKeys extends string[], DeclarationContext extends TProperties = Memory.TAssign<Context, Declarations>, Result extends TProperties = {
|
|
9
|
+
[Key in Extract<keyof Declarations, CyclicKeys[number]>]: TInstantiateCyclic<DeclarationContext, Key, Declarations[Key]>;
|
|
10
10
|
}> = Result;
|
|
11
|
-
type TInstantiateNonCyclics<Context extends TProperties, CyclicKeys extends string[], Result extends TProperties = {
|
|
12
|
-
[Key in Exclude<keyof
|
|
11
|
+
type TInstantiateNonCyclics<Context extends TProperties, Declarations extends TProperties, CyclicKeys extends string[], DeclarationContext extends TProperties = Memory.TAssign<Context, Declarations>, Result extends TProperties = {
|
|
12
|
+
[Key in Exclude<keyof Declarations, CyclicKeys[number]>]: TInstantiateType<DeclarationContext, TState<[], []>, Declarations[Key]>;
|
|
13
13
|
}> = Result;
|
|
14
|
-
type TInstantiateModule<Context extends TProperties, CyclicCandidates extends string[] = TCyclicCandidates<
|
|
14
|
+
type TInstantiateModule<Context extends TProperties, Declarations extends TProperties, CyclicCandidates extends string[] = TCyclicCandidates<Declarations>, InstantiatedCyclics extends TProperties = TInstantiateCyclics<Context, Declarations, CyclicCandidates>, InstantiatedNonCyclics extends TProperties = TInstantiateNonCyclics<Context, Declarations, CyclicCandidates>, InstantiatedModule extends TProperties = InstantiatedCyclics & InstantiatedNonCyclics> = {
|
|
15
15
|
[Key in keyof InstantiatedModule]: InstantiatedModule[Key];
|
|
16
16
|
} & {};
|
|
17
|
-
export type TModuleInstantiate<Context extends TProperties, _State extends TState,
|
|
18
|
-
export declare function ModuleInstantiate<Context extends TProperties, State extends TState,
|
|
17
|
+
export type TModuleInstantiate<Context extends TProperties, _State extends TState, Declarations extends TProperties, InstantiatedModule extends TProperties = TInstantiateModule<Context, Declarations>> = InstantiatedModule;
|
|
18
|
+
export declare function ModuleInstantiate<Context extends TProperties, State extends TState, Declarations extends TProperties>(context: Context, _state: State, declarations: Declarations, options: TSchemaOptions): TModuleInstantiate<Context, State, Declarations>;
|
|
19
19
|
export {};
|
|
@@ -9,27 +9,28 @@ import { State } from '../instantiate.mjs';
|
|
|
9
9
|
import { CyclicCandidates } from '../cyclic/candidates.mjs';
|
|
10
10
|
import { InstantiateCyclic } from '../cyclic/instantiate.mjs';
|
|
11
11
|
import { InstantiateType } from '../instantiate.mjs';
|
|
12
|
-
function InstantiateCyclics(context, cyclicKeys) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function InstantiateCyclics(context, declarations, cyclicKeys) {
|
|
13
|
+
const declarationContext = Memory.Assign(context, declarations);
|
|
14
|
+
const declarationKeys = Guard.Keys(declarations).filter(key => cyclicKeys.includes(key));
|
|
15
|
+
return declarationKeys.reduce((result, key) => {
|
|
16
|
+
return { ...result, [key]: InstantiateCyclic(declarationContext, key, declarations[key]) };
|
|
16
17
|
}, {});
|
|
17
18
|
}
|
|
18
|
-
function InstantiateNonCyclics(context, cyclicKeys) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
function InstantiateNonCyclics(context, declarations, cyclicKeys) {
|
|
20
|
+
const declarationContext = Memory.Assign(context, declarations);
|
|
21
|
+
const declarationKeys = Guard.Keys(declarations).filter(key => !cyclicKeys.includes(key));
|
|
22
|
+
return declarationKeys.reduce((result, key) => {
|
|
23
|
+
return { ...result, [key]: InstantiateType(declarationContext, State([], []), declarations[key]) };
|
|
22
24
|
}, {});
|
|
23
25
|
}
|
|
24
|
-
function InstantiateModule(context, options) {
|
|
25
|
-
const cyclicCandidates = CyclicCandidates(
|
|
26
|
-
const instantiatedCyclics = InstantiateCyclics(context, cyclicCandidates);
|
|
27
|
-
const instantiatedNonCyclics = InstantiateNonCyclics(context, cyclicCandidates);
|
|
26
|
+
function InstantiateModule(context, declarations, options) {
|
|
27
|
+
const cyclicCandidates = CyclicCandidates(declarations);
|
|
28
|
+
const instantiatedCyclics = InstantiateCyclics(context, declarations, cyclicCandidates);
|
|
29
|
+
const instantiatedNonCyclics = InstantiateNonCyclics(context, declarations, cyclicCandidates);
|
|
28
30
|
const instantiatedModule = { ...instantiatedCyclics, ...instantiatedNonCyclics };
|
|
29
31
|
return Memory.Update(instantiatedModule, {}, options);
|
|
30
32
|
}
|
|
31
|
-
export function ModuleInstantiate(context, _state,
|
|
32
|
-
const
|
|
33
|
-
const instantiatedModule = InstantiateModule(moduleContext, options);
|
|
33
|
+
export function ModuleInstantiate(context, _state, declarations, options) {
|
|
34
|
+
const instantiatedModule = InstantiateModule(context, declarations, options);
|
|
34
35
|
return instantiatedModule;
|
|
35
36
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TOptional } from '../../types/_optional.mjs';
|
|
4
|
+
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
+
type TAddOptionalOperation<Type extends TSchema, Result extends TSchema = `~optional` extends keyof Type ? Type : TOptional<Type>> = Result;
|
|
6
|
+
export type TAddOptionalAction<Type extends TSchema, Result extends TSchema = TAddOptionalOperation<Type>> = Result;
|
|
7
|
+
export declare function AddOptionalAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TAddOptionalAction<Type>;
|
|
8
|
+
export type TAddOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddOptionalAction<InstantiateType>;
|
|
9
|
+
export declare function AddOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TAddOptionalInstantiate<Context, State, Type>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
+
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
+
function AddOptionalOperation(type) {
|
|
5
|
+
return Memory.Update(type, { '~optional': true }, {});
|
|
6
|
+
}
|
|
7
|
+
export function AddOptionalAction(type, options) {
|
|
8
|
+
const result = Memory.Update(AddOptionalOperation(type), {}, options);
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
export function AddOptionalInstantiate(context, state, type, options) {
|
|
12
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
13
|
+
return AddOptionalAction(instantiatedType, options);
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TOptional } from '../../types/_optional.mjs';
|
|
4
|
+
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
+
type TRemoveOptionalOperation<Type extends TSchema, Result extends TSchema = Type extends TOptional<infer Type extends TSchema> ? Type : Type> = Result;
|
|
6
|
+
export type TRemoveOptionalAction<Type extends TSchema, Result extends TSchema = TRemoveOptionalOperation<Type>> = Result;
|
|
7
|
+
export declare function RemoveOptionalAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TRemoveOptionalAction<Type>;
|
|
8
|
+
export type TRemoveOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TRemoveOptionalAction<InstantiateType>;
|
|
9
|
+
export declare function RemoveOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TRemoveOptionalInstantiate<Context, State, Type>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
+
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
+
function RemoveOptionalOperation(type) {
|
|
5
|
+
return Memory.Discard(type, ['~optional']);
|
|
6
|
+
}
|
|
7
|
+
export function RemoveOptionalAction(type, options) {
|
|
8
|
+
const result = Memory.Update(RemoveOptionalOperation(type), {}, options);
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
export function RemoveOptionalInstantiate(context, state, type, options) {
|
|
12
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
13
|
+
return RemoveOptionalAction(instantiatedType, options);
|
|
14
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TObject } from '../../types/object.mjs';
|
|
3
|
-
import { type
|
|
3
|
+
import { type TAddOptional } from '../../action/_add_optional.mjs';
|
|
4
4
|
import { type TProperties } from '../../types/properties.mjs';
|
|
5
5
|
export type TFromObject<Properties extends TProperties, Mapped extends TProperties = {
|
|
6
|
-
[Key in keyof Properties]:
|
|
6
|
+
[Key in keyof Properties]: TAddOptional<Properties[Key]>;
|
|
7
7
|
}, Result extends TSchema = TObject<Mapped>> = Result;
|
|
8
8
|
export declare function FromObject<Properties extends TProperties>(properties: Properties): TFromObject<Properties>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { Object } from '../../types/object.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { AddOptional } from '../../action/_add_optional.mjs';
|
|
5
5
|
export function FromObject(properties) {
|
|
6
6
|
const mapped = Guard.Keys(properties).reduce((result, left) => {
|
|
7
|
-
return { ...result, [left]:
|
|
7
|
+
return { ...result, [left]: AddOptional(properties[left]) };
|
|
8
8
|
}, {});
|
|
9
9
|
const result = Object(mapped);
|
|
10
10
|
return result;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
4
|
+
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
+
type TAddReadonlyOperation<Type extends TSchema, Result extends TSchema = `~readonly` extends keyof Type ? Type : TReadonly<Type>> = Result;
|
|
6
|
+
export type TAddReadonlyAction<Type extends TSchema, Result extends TSchema = TAddReadonlyOperation<Type>> = Result;
|
|
7
|
+
export declare function AddReadonlyAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TAddReadonlyAction<Type>;
|
|
8
|
+
export type TAddReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddReadonlyAction<InstantiateType>;
|
|
9
|
+
export declare function AddReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TAddReadonlyInstantiate<Context, State, Type>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
+
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
+
function AddReadonlyOperation(type) {
|
|
5
|
+
return Memory.Update(type, { '~readonly': true }, {});
|
|
6
|
+
}
|
|
7
|
+
export function AddReadonlyAction(type, options) {
|
|
8
|
+
const result = Memory.Update(AddReadonlyOperation(type), {}, options);
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
export function AddReadonlyInstantiate(context, state, type, options) {
|
|
12
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
13
|
+
return AddReadonlyAction(instantiatedType, options);
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
4
|
+
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
+
type TRemoveReadonlyOperation<Type extends TSchema, Result extends TSchema = Type extends TReadonly<infer Type extends TSchema> ? Type : Type> = Result;
|
|
6
|
+
export type TRemoveReadonlyAction<Type extends TSchema, Result extends TSchema = TRemoveReadonlyOperation<Type>> = Result;
|
|
7
|
+
export declare function RemoveReadonlyAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TRemoveReadonlyAction<Type>;
|
|
8
|
+
export type TRemoveReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TRemoveReadonlyAction<InstantiateType>;
|
|
9
|
+
export declare function RemoveReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TRemoveReadonlyInstantiate<Context, State, Type>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
|
+
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
+
function RemoveReadonlyOperation(type) {
|
|
5
|
+
return Memory.Discard(type, ['~readonly']);
|
|
6
|
+
}
|
|
7
|
+
export function RemoveReadonlyAction(type, options) {
|
|
8
|
+
const result = Memory.Update(RemoveReadonlyOperation(type), {}, options);
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
export function RemoveReadonlyInstantiate(context, state, type, options) {
|
|
12
|
+
const instantiatedType = InstantiateType(context, state, type);
|
|
13
|
+
return RemoveReadonlyAction(instantiatedType, options);
|
|
14
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TArray } from '../../types/array.mjs';
|
|
3
|
-
import { type
|
|
4
|
-
export type TFromArray<Type extends TSchema, Result extends TSchema =
|
|
3
|
+
import { type TAddImmutable } from '../../action/_add_immutable.mjs';
|
|
4
|
+
export type TFromArray<Type extends TSchema, Result extends TSchema = TAddImmutable<TArray<Type>>> = Result;
|
|
5
5
|
export declare function FromArray<Type extends TSchema>(type: Type): TFromArray<Type>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Array } from '../../types/array.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { AddImmutable } from '../../action/_add_immutable.mjs';
|
|
4
4
|
export function FromArray(type) {
|
|
5
|
-
const result =
|
|
5
|
+
const result = AddImmutable(Array(type));
|
|
6
6
|
return result;
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TObject } from '../../types/object.mjs';
|
|
3
|
-
import { type
|
|
3
|
+
import { type TAddReadonly } from '../../action/_add_readonly.mjs';
|
|
4
4
|
import { type TProperties } from '../../types/properties.mjs';
|
|
5
5
|
export type TFromObject<Properties extends TProperties, Mapped extends TProperties = {
|
|
6
|
-
[Key in keyof Properties]:
|
|
6
|
+
[Key in keyof Properties]: TAddReadonly<Properties[Key]>;
|
|
7
7
|
}, Result extends TSchema = TObject<Mapped>> = Result;
|
|
8
8
|
export declare function FromObject<Properties extends TProperties>(properties: Properties): TFromObject<Properties>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { Object } from '../../types/object.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { AddReadonly } from '../../action/_add_readonly.mjs';
|
|
5
5
|
export function FromObject(properties) {
|
|
6
6
|
const mapped = Guard.Keys(properties).reduce((result, left) => {
|
|
7
|
-
return { ...result, [left]:
|
|
7
|
+
return { ...result, [left]: AddReadonly(properties[left]) };
|
|
8
8
|
}, {});
|
|
9
9
|
const result = Object(mapped);
|
|
10
10
|
return result;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
3
|
-
import { type
|
|
4
|
-
export type TFromTuple<Types extends TSchema[], Result extends TSchema =
|
|
3
|
+
import { type TAddImmutable } from '../../action/_add_immutable.mjs';
|
|
4
|
+
export type TFromTuple<Types extends TSchema[], Result extends TSchema = TAddImmutable<TTuple<Types>>> = Result;
|
|
5
5
|
export declare function FromTuple<Types extends TSchema[]>(types: [...Types]): TFromTuple<Types>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Tuple } from '../../types/tuple.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { AddImmutable } from '../../action/_add_immutable.mjs';
|
|
4
4
|
export function FromTuple(types) {
|
|
5
|
-
const result =
|
|
5
|
+
const result = AddImmutable(Tuple(types));
|
|
6
6
|
return result;
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TObject } from '../../types/object.mjs';
|
|
3
|
-
import { type
|
|
3
|
+
import { type TRemoveOptional } from '../../action/_remove_optional.mjs';
|
|
4
4
|
import { type TProperties } from '../../types/properties.mjs';
|
|
5
5
|
export type TFromObject<Properties extends TProperties, Mapped extends TProperties = {
|
|
6
|
-
[Key in keyof Properties]:
|
|
6
|
+
[Key in keyof Properties]: TRemoveOptional<Properties[Key]>;
|
|
7
7
|
}, Result extends TSchema = TObject<Mapped>> = Result;
|
|
8
8
|
export declare function FromObject<Properties extends TProperties>(properties: Properties): TFromObject<Properties>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { Object } from '../../types/object.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { RemoveOptional } from '../../action/_remove_optional.mjs';
|
|
5
5
|
export function FromObject(properties) {
|
|
6
6
|
const mapped = Guard.Keys(properties).reduce((result, left) => {
|
|
7
|
-
return { ...result, [left]:
|
|
7
|
+
return { ...result, [left]: RemoveOptional(properties[left]) };
|
|
8
8
|
}, {});
|
|
9
9
|
const result = Object(mapped);
|
|
10
10
|
return result;
|