@openclaw/imessage 2026.10.10 → 2026.11.5-beta.1
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/dist/.setup/{accounts-BH0coL46.mjs → accounts-C1Ypv3Wn.mjs} +6 -7
- package/dist/.setup/{actions-CW7XYYF4.mjs → actions-qOuKy8To.mjs} +360 -108
- package/dist/.setup/{actions.runtime-B2ZHQ3TJ.mjs → actions.runtime-Ccg9CARL.mjs} +10 -56
- package/dist/.setup/{api-6xi-NBrt.mjs → api-BXXuQQCS.mjs} +7 -7
- package/dist/.setup/{api-B0ih8Iof.mjs → api-DTbxSOPc.mjs} +8 -8
- package/dist/.setup/{approval-handler.runtime-BKmqba3L.mjs → approval-handler.runtime-B6vrFfZx.mjs} +112 -131
- package/dist/.setup/{approval-reactions-B9CJS0NT.mjs → approval-reactions-DBBsqbRC.mjs} +152 -72
- package/dist/.setup/{channel-6kcKpSRw.mjs → channel-CLaN4mQn.mjs} +142 -119
- package/dist/.setup/{channel.runtime-BW4A0m4h.mjs → channel.runtime-XJGx1MIH.mjs} +205 -363
- package/dist/.setup/chat-context-fTfJVqAi.mjs +77 -0
- package/dist/.setup/chat-lookup-xtPsOBkl.mjs +50 -0
- package/dist/.setup/client-D_BaG8sC.mjs +367 -0
- package/dist/.setup/{config-schema-DRkdRC21.mjs → config-schema-BjkQV5P5.mjs} +1 -2
- package/dist/.setup/{conversation-bindings-vZFn6sN2.mjs → conversation-bindings-8DjxoIYU.mjs} +9 -6
- package/dist/.setup/{media-contract-CoixpXRX.mjs → media-contract-BErFBKV9.mjs} +1 -1
- package/dist/.setup/{message-tool-api-CxSY_rh7.mjs → message-tool-api-DtZ1wKbT.mjs} +3 -6
- package/dist/.setup/{remote-file-CCgMYZ-u.mjs → remote-file-DpK3GQFD.mjs} +8 -22
- package/dist/.setup/{sanitize-outbound-C02fJrn6.mjs → sanitize-outbound-Dhjhz0a-.mjs} +23 -27
- package/dist/.setup/{send-D98hQFdv.mjs → send-DhEW0gfe.mjs} +150 -226
- package/dist/.setup/{setup-core-BWnW0czE.mjs → setup-core-B1_P_t4T.mjs} +2 -2
- package/dist/.setup/{setup-surface-aRZhAzzQ.mjs → setup-surface-CD28mXWK.mjs} +11 -25
- package/dist/.setup/{targets-CIx4BKqL.mjs → targets-C7CIWJ0k.mjs} +12 -3
- package/dist/.source-module-urls/929c518fa2986b0f85f66bceefead22868db0ab452dee914dc6a2bb86b2e60ad.json +1 -1
- package/dist/api.js +8 -8
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/media-contract-api.js +1 -1
- package/dist/message-tool-api.js +1 -1
- package/dist/runtime-api.js +1 -3
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/src/chat-db.worker.js +1 -1
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +0 -30
- package/package.json +6 -6
- package/dist/.setup/client-C3e7ZLqA.mjs +0 -739
- package/dist/.setup/question-reactions-DTj-VH3N.mjs +0 -67
- package/dist/.setup/reaction-context-Bw00FkmU.mjs +0 -105
- package/dist/.setup/runtime-BRQCPuAD.mjs +0 -7
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// deno-lint-ignore-file no-explicit-any
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
3
|
+
import { Settings } from '../settings/index.mjs';
|
|
4
|
+
import { Keys } from './keys.mjs';
|
|
5
|
+
// ------------------------------------------------------------------
|
|
6
|
+
// Freeze
|
|
7
|
+
// ------------------------------------------------------------------
|
|
8
|
+
function Freeze(value, seen) {
|
|
9
|
+
if (seen.has(value))
|
|
10
|
+
return;
|
|
11
|
+
seen.add(value);
|
|
12
|
+
for (const key of Keys(value)) {
|
|
13
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
14
|
+
if (!descriptor || !('value' in descriptor))
|
|
15
|
+
continue;
|
|
16
|
+
if (Guard.IsObject(descriptor.value))
|
|
17
|
+
Freeze(descriptor.value, seen);
|
|
18
|
+
}
|
|
19
|
+
Object.freeze(value);
|
|
20
|
+
}
|
|
21
|
+
// ------------------------------------------------------------------
|
|
22
|
+
// Finalize
|
|
23
|
+
// ------------------------------------------------------------------
|
|
24
|
+
/** Finalizes a type. Will recursively freeze if `immutableTypes` is true, otherwise no action. */
|
|
25
|
+
export function Finalize(value) {
|
|
26
|
+
if (!Settings.Get().immutableTypes)
|
|
27
|
+
return value;
|
|
28
|
+
Freeze(value, new WeakSet());
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Guard } from '../../guard/index.mjs';
|
|
2
|
+
// ------------------------------------------------------------------
|
|
3
|
+
// Keys (alternatively, Reflect.ownKeys(...))
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
/** Returns the own string and symbol keys of the given object. */
|
|
6
|
+
export function Keys(value) {
|
|
7
|
+
return [...Guard.Keys(value), ...Guard.Symbols(value)];
|
|
8
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
type ObjectLike = Record<PropertyKey, any>;
|
|
2
|
-
/**
|
|
3
|
-
* Updates a value with new properties while preserving property enumerability. Use this function to modify
|
|
4
|
-
* existing types without altering their configuration.
|
|
5
|
-
*/
|
|
2
|
+
/** Updates an existing type with additional hidden and enumerable properties while preserving property configuration. */
|
|
6
3
|
export declare function Update(current: ObjectLike, hidden: ObjectLike, enumerable: ObjectLike): ObjectLike;
|
|
7
4
|
export {};
|
|
@@ -1,27 +1,43 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-explicit-any
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
2
3
|
import { Settings } from '../settings/index.mjs';
|
|
3
4
|
import { Metrics } from './metrics.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
import { Finalize } from './finalize.mjs';
|
|
6
|
+
import { Keys } from './keys.mjs';
|
|
7
|
+
// ------------------------------------------------------------------
|
|
8
|
+
// WithCurrent
|
|
9
|
+
// ------------------------------------------------------------------
|
|
10
|
+
function WithCurrent(current, hiddenKeys, enumerableKeys, result) {
|
|
11
|
+
for (const key of Keys(current)) {
|
|
12
|
+
if (Guard.IsUnsafePropertyKey(key) || hiddenKeys.includes(key) || enumerableKeys.includes(key))
|
|
13
|
+
continue; // (ignore: prototype-pollution)
|
|
14
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key); // safe-name!
|
|
15
|
+
Object.defineProperty(result, key, descriptor);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// ------------------------------------------------------------------
|
|
19
|
+
// WithHidden
|
|
20
|
+
// ------------------------------------------------------------------
|
|
21
|
+
function WithHidden(hidden, keys, result) {
|
|
22
|
+
const enumerableKind = Settings.Get().enumerableKind;
|
|
23
|
+
for (const key of keys) {
|
|
24
|
+
if (Guard.IsUnsafePropertyKey(key))
|
|
25
|
+
continue; // (ignore: prototype-pollution)
|
|
16
26
|
Object.defineProperty(result, key, {
|
|
17
27
|
configurable: true,
|
|
18
28
|
writable: true,
|
|
19
|
-
enumerable:
|
|
29
|
+
enumerable: enumerableKind,
|
|
20
30
|
value: hidden[key]
|
|
21
31
|
});
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
}
|
|
34
|
+
// ------------------------------------------------------------------
|
|
35
|
+
// WithEnumerable
|
|
36
|
+
// ------------------------------------------------------------------
|
|
37
|
+
function WithEnumerable(enumerable, keys, result) {
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
if (Guard.IsUnsafePropertyKey(key))
|
|
40
|
+
continue; // (ignore: prototype-pollution)
|
|
25
41
|
Object.defineProperty(result, key, {
|
|
26
42
|
configurable: true,
|
|
27
43
|
enumerable: true,
|
|
@@ -29,5 +45,16 @@ export function Update(current, hidden, enumerable) {
|
|
|
29
45
|
value: enumerable[key]
|
|
30
46
|
});
|
|
31
47
|
}
|
|
32
|
-
|
|
48
|
+
}
|
|
49
|
+
// ------------------------------------------------------------------
|
|
50
|
+
// Update
|
|
51
|
+
// ------------------------------------------------------------------
|
|
52
|
+
/** Updates an existing type with additional hidden and enumerable properties while preserving property configuration. */
|
|
53
|
+
export function Update(current, hidden, enumerable) {
|
|
54
|
+
Metrics.update += 1;
|
|
55
|
+
const result = {}, hiddenKeys = Keys(hidden), enumerableKeys = Keys(enumerable);
|
|
56
|
+
WithCurrent(current, hiddenKeys, enumerableKeys, result);
|
|
57
|
+
WithHidden(hidden, hiddenKeys, result);
|
|
58
|
+
WithEnumerable(enumerable, enumerableKeys, result);
|
|
59
|
+
return Finalize(result);
|
|
33
60
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './instantiate.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './instantiate.mjs';
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
2
|
-
import { type TOptional } from '../../types/_optional.mjs';
|
|
3
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
4
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
5
3
|
import { type TObject } from '../../types/object.mjs';
|
|
6
4
|
import { type TNever } from '../../types/never.mjs';
|
|
7
5
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
8
|
-
import { type TAddReadonly } from '../../action/_add_readonly.mjs';
|
|
9
|
-
import { type TAddOptional } from '../../action/_add_optional.mjs';
|
|
10
|
-
import { type TRemoveReadonly } from '../../action/_remove_readonly.mjs';
|
|
11
|
-
import { type TRemoveOptional } from '../../action/_remove_optional.mjs';
|
|
12
6
|
import { type TTupleElementsToProperties } from '../tuple/to_object.mjs';
|
|
13
|
-
import { type
|
|
14
|
-
|
|
15
|
-
export type TCanComposite<Type extends TSchema> = (Type extends TObject<infer _ extends TProperties> ? true : Type extends TTuple<infer _ extends TSchema[]> ? true : false);
|
|
16
|
-
/** Returns true if the type is a valid operand to Composite. */
|
|
17
|
-
export declare function CanComposite<Type extends TSchema>(type: Type): TCanComposite<Type>;
|
|
18
|
-
type TIsReadonlyProperty<Left extends TSchema, Right extends TSchema> = (Left extends TReadonly<Left> ? Right extends TReadonly<Right> ? true : false : false);
|
|
19
|
-
type TIsOptionalProperty<Left extends TSchema, Right extends TSchema> = (Left extends TOptional<Left> ? Right extends TOptional<Right> ? true : false : false);
|
|
20
|
-
type TCompositeProperty<Left extends TSchema, Right extends TSchema, IsReadonly extends boolean = TIsReadonlyProperty<Left, Right>, IsOptional extends boolean = TIsOptionalProperty<Left, Right>, Evaluated extends TSchema = TEvaluateIntersect<[Left, Right]>, Property extends TSchema = TRemoveReadonly<TRemoveOptional<Evaluated>>> = ([
|
|
21
|
-
IsReadonly,
|
|
22
|
-
IsOptional
|
|
23
|
-
] extends [true, true] ? TAddReadonly<TAddOptional<Property>> : [
|
|
24
|
-
IsReadonly,
|
|
25
|
-
IsOptional
|
|
26
|
-
] extends [true, false] ? TAddReadonly<Property> : [
|
|
27
|
-
IsReadonly,
|
|
28
|
-
IsOptional
|
|
29
|
-
] extends [false, true] ? TAddOptional<Property> : Property);
|
|
30
|
-
type TCompositePropertyKey<Left extends TProperties, Right extends TProperties, Key extends PropertyKey, Result extends TSchema = (Key extends keyof Left ? Key extends keyof Right ? TCompositeProperty<Left[Key], Right[Key]> : Left[Key] : Key extends keyof Right ? Right[Key] : TNever)> = Result;
|
|
7
|
+
import { type TEvaluatePropertyIntersect } from './property.mjs';
|
|
8
|
+
type TCompositePropertyKey<Left extends TProperties, Right extends TProperties, Key extends PropertyKey, Result extends TSchema = (Key extends keyof Left ? Key extends keyof Right ? TEvaluatePropertyIntersect<Left[Key], Right[Key]> : Left[Key] : Key extends keyof Right ? Right[Key] : TNever)> = Result;
|
|
31
9
|
type TCompositeProperties<Left extends TProperties, Right extends TProperties, Keys extends PropertyKey = keyof (Left & Right), Result extends TProperties = {
|
|
32
10
|
[Key in Keys]: TCompositePropertyKey<Left, Right, Key>;
|
|
33
11
|
}> = Result;
|
|
@@ -1,41 +1,14 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
3
|
import { Guard } from '../../../guard/index.mjs';
|
|
4
|
-
import { IsReadonly } from '../../types/_readonly.mjs';
|
|
5
|
-
import { IsOptional } from '../../types/_optional.mjs';
|
|
6
4
|
import { Object, IsObject } from '../../types/object.mjs';
|
|
7
5
|
import { Never } from '../../types/never.mjs';
|
|
8
6
|
import { IsTuple } from '../../types/tuple.mjs';
|
|
9
|
-
import { AddReadonly } from '../../action/_add_readonly.mjs';
|
|
10
|
-
import { AddOptional } from '../../action/_add_optional.mjs';
|
|
11
|
-
import { RemoveReadonly } from '../../action/_remove_readonly.mjs';
|
|
12
|
-
import { RemoveOptional } from '../../action/_remove_optional.mjs';
|
|
13
7
|
import { TupleElementsToProperties } from '../tuple/to_object.mjs';
|
|
14
|
-
import {
|
|
15
|
-
/** Returns true if the type is a valid operand to Composite. */
|
|
16
|
-
export function CanComposite(type) {
|
|
17
|
-
return (IsObject(type) || IsTuple(type));
|
|
18
|
-
}
|
|
19
|
-
function IsReadonlyProperty(left, right) {
|
|
20
|
-
return (IsReadonly(left) ? IsReadonly(right) ? true : false : false);
|
|
21
|
-
}
|
|
22
|
-
function IsOptionalProperty(left, right) {
|
|
23
|
-
return (IsOptional(left) ? IsOptional(right) ? true : false : false);
|
|
24
|
-
}
|
|
25
|
-
function CompositeProperty(left, right) {
|
|
26
|
-
const isReadonly = IsReadonlyProperty(left, right);
|
|
27
|
-
const isOptional = IsOptionalProperty(left, right);
|
|
28
|
-
const evaluated = EvaluateIntersect([left, right]);
|
|
29
|
-
// Modifiers need to be discarded and re-applied
|
|
30
|
-
const property = RemoveReadonly(RemoveOptional(evaluated));
|
|
31
|
-
return (isReadonly && isOptional ? AddReadonly(AddOptional(property)) :
|
|
32
|
-
isReadonly && !isOptional ? AddReadonly(property) :
|
|
33
|
-
!isReadonly && isOptional ? AddOptional(property) :
|
|
34
|
-
property);
|
|
35
|
-
}
|
|
8
|
+
import { EvaluatePropertyIntersect } from './property.mjs';
|
|
36
9
|
function CompositePropertyKey(left, right, key) {
|
|
37
10
|
return (key in left
|
|
38
|
-
? key in right ?
|
|
11
|
+
? key in right ? EvaluatePropertyIntersect(left[key], right[key]) : left[key]
|
|
39
12
|
: key in right ? right[key] : Never());
|
|
40
13
|
}
|
|
41
14
|
function CompositeProperties(left, right) {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
3
|
+
import { type TObject } from '../../types/object.mjs';
|
|
2
4
|
import { type TAny } from '../../types/any.mjs';
|
|
3
5
|
import { type TNever } from '../../types/never.mjs';
|
|
6
|
+
import { type TTuple } from '../../types/tuple.mjs';
|
|
4
7
|
import { type TUnknown } from '../../types/unknown.mjs';
|
|
5
8
|
import { type TCompare, type TCompareResult, CompareResultLeftInside, CompareResultRightInside, CompareResultEqual } from './compare.mjs';
|
|
6
|
-
import { type TComposite
|
|
9
|
+
import { type TComposite } from './composite.mjs';
|
|
7
10
|
type TNarrowCompareRule<Left extends TSchema, Right extends TSchema, Result extends TCompareResult = TCompare<Left, Right>> = (Result extends typeof CompareResultLeftInside ? Left : Result extends typeof CompareResultRightInside ? Right : Result extends typeof CompareResultEqual ? Right : TNever);
|
|
11
|
+
type TCanComposite<Type extends TSchema> = (Type extends TObject<infer _ extends TProperties> ? true : Type extends TTuple<infer _ extends TSchema[]> ? true : false);
|
|
8
12
|
type TNarrowCompositeRule<Left extends TSchema, Right extends TSchema, CanCompositeLeft extends boolean = TCanComposite<Left>, CanCompositeRight extends boolean = TCanComposite<Right>> = ([
|
|
9
13
|
CanCompositeLeft,
|
|
10
14
|
CanCompositeRight
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
+
import { IsObject } from '../../types/object.mjs';
|
|
3
4
|
import { IsAny } from '../../types/any.mjs';
|
|
4
5
|
import { Never, IsNever } from '../../types/never.mjs';
|
|
6
|
+
import { IsTuple } from '../../types/tuple.mjs';
|
|
5
7
|
import { IsUnknown } from '../../types/unknown.mjs';
|
|
6
8
|
import { Compare, CompareResultLeftInside, CompareResultRightInside, CompareResultEqual } from './compare.mjs';
|
|
7
|
-
import { Composite
|
|
9
|
+
import { Composite } from './composite.mjs';
|
|
8
10
|
function NarrowCompareRule(left, right) {
|
|
9
11
|
const result = Compare(left, right);
|
|
10
12
|
return (Guard.IsEqual(result, CompareResultLeftInside) ? left :
|
|
@@ -12,6 +14,9 @@ function NarrowCompareRule(left, right) {
|
|
|
12
14
|
Guard.IsEqual(result, CompareResultEqual) ? right :
|
|
13
15
|
Never());
|
|
14
16
|
}
|
|
17
|
+
function CanComposite(type) {
|
|
18
|
+
return (IsObject(type) || IsTuple(type));
|
|
19
|
+
}
|
|
15
20
|
function NarrowCompositeRule(left, right) {
|
|
16
21
|
const canCompositeLeft = CanComposite(left);
|
|
17
22
|
const canCompositeRight = CanComposite(right);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TOptional } from '../../types/_optional.mjs';
|
|
3
|
+
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
4
|
+
import { type TAddOptionalAction } from '../optional/instantiate_add.mjs';
|
|
5
|
+
import { type TAddReadonlyAction } from '../readonly/instantiate_add.mjs';
|
|
6
|
+
import { type TRemoveOptionalAction } from '../optional/instantiate_remove.mjs';
|
|
7
|
+
import { type TRemoveReadonlyAction } from '../readonly/instantiate_remove.mjs';
|
|
8
|
+
import { type TEvaluateIntersect, type TEvaluateUnion } from './evaluate.mjs';
|
|
9
|
+
export type TEvaluatePropertyIntersect<Left extends TSchema, Right extends TSchema, IsReadonly extends boolean = Left extends TReadonly ? Right extends TReadonly ? true : false : false, IsOptional extends boolean = Left extends TOptional ? Right extends TOptional ? true : false : false, Evaluated extends TSchema = TEvaluateIntersect<[Left, Right]>, Property extends TSchema = TRemoveReadonlyAction<TRemoveOptionalAction<Evaluated>>> = ([
|
|
10
|
+
IsReadonly,
|
|
11
|
+
IsOptional
|
|
12
|
+
] extends [true, true] ? TAddReadonlyAction<TAddOptionalAction<Property>> : [
|
|
13
|
+
IsReadonly,
|
|
14
|
+
IsOptional
|
|
15
|
+
] extends [true, false] ? TAddReadonlyAction<Property> : [
|
|
16
|
+
IsReadonly,
|
|
17
|
+
IsOptional
|
|
18
|
+
] extends [false, true] ? TAddOptionalAction<Property> : Property);
|
|
19
|
+
export declare function EvaluatePropertyIntersect<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TEvaluatePropertyIntersect<Left, Right>;
|
|
20
|
+
export type TEvaluatePropertyUnion<Left extends TSchema, Right extends TSchema, IsReadonly extends boolean = Left extends TReadonly ? true : Right extends TReadonly ? true : false, IsOptional extends boolean = Left extends TOptional ? true : Right extends TOptional ? true : false, LeftProperty extends TSchema = TRemoveReadonlyAction<TRemoveOptionalAction<Left>>, RightProperty extends TSchema = TRemoveReadonlyAction<TRemoveOptionalAction<Right>>, Property extends TSchema = TEvaluateUnion<[LeftProperty, RightProperty]>> = ([
|
|
21
|
+
IsReadonly,
|
|
22
|
+
IsOptional
|
|
23
|
+
] extends [true, true] ? TAddReadonlyAction<TAddOptionalAction<Property>> : [
|
|
24
|
+
IsReadonly,
|
|
25
|
+
IsOptional
|
|
26
|
+
] extends [true, false] ? TAddReadonlyAction<Property> : [
|
|
27
|
+
IsReadonly,
|
|
28
|
+
IsOptional
|
|
29
|
+
] extends [false, true] ? TAddOptionalAction<Property> : Property);
|
|
30
|
+
export declare function EvaluatePropertyUnion<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TEvaluatePropertyUnion<Left, Right>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { IsOptional } from '../../types/_optional.mjs';
|
|
3
|
+
import { IsReadonly } from '../../types/_readonly.mjs';
|
|
4
|
+
import { AddOptionalAction } from '../optional/instantiate_add.mjs';
|
|
5
|
+
import { AddReadonlyAction } from '../readonly/instantiate_add.mjs';
|
|
6
|
+
import { RemoveOptionalAction } from '../optional/instantiate_remove.mjs';
|
|
7
|
+
import { RemoveReadonlyAction } from '../readonly/instantiate_remove.mjs';
|
|
8
|
+
import { EvaluateIntersect, EvaluateUnion } from './evaluate.mjs';
|
|
9
|
+
export function EvaluatePropertyIntersect(left, right) {
|
|
10
|
+
const isReadonly = IsReadonly(left) && IsReadonly(right);
|
|
11
|
+
const isOptional = IsOptional(left) && IsOptional(right);
|
|
12
|
+
const evaluated = EvaluateIntersect([left, right]);
|
|
13
|
+
const property = RemoveReadonlyAction(RemoveOptionalAction(evaluated, {}), {});
|
|
14
|
+
return (isReadonly && isOptional ? AddReadonlyAction(AddOptionalAction(property, {}), {}) :
|
|
15
|
+
isReadonly ? AddReadonlyAction(property, {}) :
|
|
16
|
+
isOptional ? AddOptionalAction(property, {}) :
|
|
17
|
+
property);
|
|
18
|
+
}
|
|
19
|
+
export function EvaluatePropertyUnion(left, right) {
|
|
20
|
+
const isReadonly = IsReadonly(left) || IsReadonly(right);
|
|
21
|
+
const isOptional = IsOptional(left) || IsOptional(right);
|
|
22
|
+
const leftProperty = RemoveReadonlyAction(RemoveOptionalAction(left, {}), {});
|
|
23
|
+
const rightProperty = RemoveReadonlyAction(RemoveOptionalAction(right, {}), {});
|
|
24
|
+
const property = EvaluateUnion([leftProperty, rightProperty]);
|
|
25
|
+
return (isReadonly && isOptional ? AddReadonlyAction(AddOptionalAction(property, {}), {}) :
|
|
26
|
+
isReadonly ? AddReadonlyAction(property, {}) :
|
|
27
|
+
isOptional ? AddOptionalAction(property, {}) :
|
|
28
|
+
property);
|
|
29
|
+
}
|
|
@@ -2,9 +2,7 @@ import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
|
2
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
3
3
|
import { type TImmutable } from '../../types/_immutable.mjs';
|
|
4
4
|
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
-
type
|
|
6
|
-
export type TAddImmutableAction<Type extends TSchema, Result extends TSchema = TAddImmutableOperation<Type>> = Result;
|
|
5
|
+
export type TAddImmutableAction<Type extends TSchema, Result extends TSchema = '~immutable' extends keyof Type ? Type : TImmutable<Type>> = Result;
|
|
7
6
|
export declare function AddImmutableAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TAddImmutableAction<Type>;
|
|
8
7
|
export type TAddImmutableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddImmutableAction<InstantiateType>;
|
|
9
8
|
export declare function AddImmutableInstantiate<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, type: Type, options: TSchemaOptions): TAddImmutableInstantiate<Context, State, Type>;
|
|
10
|
-
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
3
|
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
-
function AddImmutableOperation(type) {
|
|
5
|
-
return Memory.Update(type, { '~immutable': true }, {});
|
|
6
|
-
}
|
|
7
4
|
export function AddImmutableAction(type, options) {
|
|
8
|
-
const result = Memory.Update(
|
|
5
|
+
const result = Memory.Update(type, { '~immutable': true }, options);
|
|
9
6
|
return result;
|
|
10
7
|
}
|
|
11
8
|
export function AddImmutableInstantiate(context, state, type, options) {
|
|
@@ -2,13 +2,13 @@ import { Memory } from '../../../system/memory/index.mjs';
|
|
|
2
2
|
import { type TSchema } from '../../types/schema.mjs';
|
|
3
3
|
import { type TProperties } from '../../types/properties.mjs';
|
|
4
4
|
import { type TFromType } from './from_type.mjs';
|
|
5
|
-
import { type
|
|
5
|
+
import { type TEvaluatePropertyIntersect } from '../evaluate/property.mjs';
|
|
6
6
|
type TCollapseIntersectProperties<Left extends TProperties, Right extends TProperties, LeftKeys extends keyof Left = Exclude<keyof Left, keyof Right>, RightKeys extends keyof Right = Exclude<keyof Right, keyof Left>, SharedKeys extends keyof Left & keyof Right = Extract<keyof Left, keyof Right>, LeftProperties extends TProperties = {
|
|
7
7
|
[Key in LeftKeys]: Left[Key];
|
|
8
8
|
}, RightProperties extends TProperties = {
|
|
9
9
|
[Key in RightKeys]: Right[Key];
|
|
10
10
|
}, SharedProperties extends TProperties = {
|
|
11
|
-
[Key in SharedKeys]:
|
|
11
|
+
[Key in SharedKeys]: TEvaluatePropertyIntersect<Left[Key], Right[Key]>;
|
|
12
12
|
}, Unique extends TProperties = Memory.TAssign<LeftProperties, RightProperties>, Shared extends TProperties = Memory.TAssign<Unique, SharedProperties>> = Shared;
|
|
13
13
|
export type TFromIntersect<Types extends TSchema[], Result extends TProperties = {}> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromIntersect<Right, TCollapseIntersectProperties<Result, TFromType<Left>>> : {
|
|
14
14
|
[Key in keyof Result]: Result[Key];
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
4
4
|
import { Guard } from '../../../guard/index.mjs';
|
|
5
5
|
import { FromType } from './from_type.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { EvaluatePropertyIntersect } from '../evaluate/property.mjs';
|
|
7
7
|
function CollapseIntersectProperties(left, right) {
|
|
8
8
|
const leftKeys = Guard.Keys(left).filter((key) => !Guard.HasPropertyKey(right, key));
|
|
9
9
|
const rightKeys = Guard.Keys(right).filter((key) => !Guard.HasPropertyKey(left, key));
|
|
10
10
|
const sharedKeys = Guard.Keys(left).filter((key) => Guard.HasPropertyKey(right, key));
|
|
11
11
|
const leftProperties = leftKeys.reduce((result, key) => ({ ...result, [key]: left[key] }), {});
|
|
12
12
|
const rightProperties = rightKeys.reduce((result, key) => ({ ...result, [key]: right[key] }), {});
|
|
13
|
-
const sharedProperties = sharedKeys.reduce((result, key) => ({ ...result, [key]:
|
|
13
|
+
const sharedProperties = sharedKeys.reduce((result, key) => ({ ...result, [key]: EvaluatePropertyIntersect(left[key], right[key]) }), {});
|
|
14
14
|
const unique = Memory.Assign(leftProperties, rightProperties);
|
|
15
15
|
const shared = Memory.Assign(unique, sharedProperties);
|
|
16
16
|
return shared;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type TUnreachable } from '../../../system/unreachable/index.mjs';
|
|
2
2
|
import { type TSchema } from '../../types/schema.mjs';
|
|
3
3
|
import { type TProperties } from '../../types/properties.mjs';
|
|
4
|
-
import { type
|
|
4
|
+
import { type TEvaluatePropertyUnion } from '../evaluate/property.mjs';
|
|
5
5
|
import { type TFromType } from './from_type.mjs';
|
|
6
6
|
type TCollapseUnionProperties<Left extends TProperties, Right extends TProperties, SharedKeys extends PropertyKey = keyof Left & keyof Right, Result extends TProperties = {
|
|
7
|
-
[Key in SharedKeys]:
|
|
7
|
+
[Key in SharedKeys]: TEvaluatePropertyUnion<Left[Key], Right[Key]>;
|
|
8
8
|
}> = Result;
|
|
9
9
|
type TReduceVariants<Types extends TSchema[], Result extends TProperties> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReduceVariants<Right, TCollapseUnionProperties<Result, TFromType<Left>>> : Result);
|
|
10
10
|
export type TFromUnion<Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReduceVariants<Right, TFromType<Left>> : TUnreachable);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { Unreachable } from '../../../system/unreachable/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { EvaluatePropertyUnion } from '../evaluate/property.mjs';
|
|
5
5
|
import { FromType } from './from_type.mjs';
|
|
6
6
|
function CollapseUnionProperties(left, right) {
|
|
7
7
|
const sharedKeys = Guard.Keys(left).filter((key) => key in right);
|
|
8
8
|
const result = sharedKeys.reduce((result, key) => {
|
|
9
|
-
return { ...result, [key]:
|
|
9
|
+
return { ...result, [key]: EvaluatePropertyUnion(left[key], right[key]) };
|
|
10
10
|
}, {});
|
|
11
11
|
return result;
|
|
12
12
|
}
|
|
@@ -2,9 +2,7 @@ import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
|
2
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
3
3
|
import { type TOptional } from '../../types/_optional.mjs';
|
|
4
4
|
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
-
type
|
|
6
|
-
export type TAddOptionalAction<Type extends TSchema, Result extends TSchema = TAddOptionalOperation<Type>> = Result;
|
|
5
|
+
export type TAddOptionalAction<Type extends TSchema, Result extends TSchema = '~optional' extends keyof Type ? Type : TOptional<Type>> = Result;
|
|
7
6
|
export declare function AddOptionalAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TAddOptionalAction<Type>;
|
|
8
7
|
export type TAddOptionalInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddOptionalAction<InstantiateType>;
|
|
9
8
|
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 {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
3
|
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
-
function AddOptionalOperation(type) {
|
|
5
|
-
return Memory.Update(type, { '~optional': true }, {});
|
|
6
|
-
}
|
|
7
4
|
export function AddOptionalAction(type, options) {
|
|
8
|
-
const result = Memory.Update(
|
|
5
|
+
const result = Memory.Update(type, { '~optional': true }, options);
|
|
9
6
|
return result;
|
|
10
7
|
}
|
|
11
8
|
export function AddOptionalInstantiate(context, state, type, options) {
|
|
@@ -2,9 +2,7 @@ import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
|
2
2
|
import { type TProperties } from '../../types/properties.mjs';
|
|
3
3
|
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
4
4
|
import { type TState, type TInstantiateType } from '../instantiate.mjs';
|
|
5
|
-
type
|
|
6
|
-
export type TAddReadonlyAction<Type extends TSchema, Result extends TSchema = TAddReadonlyOperation<Type>> = Result;
|
|
5
|
+
export type TAddReadonlyAction<Type extends TSchema, Result extends TSchema = '~readonly' extends keyof Type ? Type : TReadonly<Type>> = Result;
|
|
7
6
|
export declare function AddReadonlyAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TAddReadonlyAction<Type>;
|
|
8
7
|
export type TAddReadonlyInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiateType extends TSchema = TInstantiateType<Context, State, Type>> = TAddReadonlyAction<InstantiateType>;
|
|
9
8
|
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 {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
3
|
import { InstantiateType } from '../instantiate.mjs';
|
|
4
|
-
function AddReadonlyOperation(type) {
|
|
5
|
-
return Memory.Update(type, { '~readonly': true }, {});
|
|
6
|
-
}
|
|
7
4
|
export function AddReadonlyAction(type, options) {
|
|
8
|
-
const result = Memory.Update(
|
|
5
|
+
const result = Memory.Update(type, { '~readonly': true }, options);
|
|
9
6
|
return result;
|
|
10
7
|
}
|
|
11
8
|
export function AddReadonlyInstantiate(context, state, type, options) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './expand_this.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './expand_this.mjs';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns a Clone of the given value. This function is similar to structuredClone()
|
|
3
|
-
* but also supports deep cloning
|
|
2
|
+
* Returns a deep Clone of the given value. This function is similar to `structuredClone()`,
|
|
3
|
+
* but also supports deep cloning `Map`, `Set`, and `TypeArray` instances. This function can also be used
|
|
4
|
+
* to clone TypeBox types while retaining their enumerable and non-enumerable properties.
|
|
4
5
|
*/
|
|
5
|
-
export declare function Clone<Value extends unknown>(value: Value): Value;
|
|
6
|
+
export declare function Clone<Value extends unknown = unknown>(value: Value): Value;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import {
|
|
3
|
-
// ------------------------------------------------------------------
|
|
4
|
-
// Clone
|
|
5
|
-
// ------------------------------------------------------------------
|
|
2
|
+
import { Deep } from '../../system/memory/deep.mjs';
|
|
6
3
|
/**
|
|
7
|
-
* Returns a Clone of the given value. This function is similar to structuredClone()
|
|
8
|
-
* but also supports deep cloning
|
|
4
|
+
* Returns a deep Clone of the given value. This function is similar to `structuredClone()`,
|
|
5
|
+
* but also supports deep cloning `Map`, `Set`, and `TypeArray` instances. This function can also be used
|
|
6
|
+
* to clone TypeBox types while retaining their enumerable and non-enumerable properties.
|
|
9
7
|
*/
|
|
10
8
|
export function Clone(value) {
|
|
11
|
-
return
|
|
9
|
+
return Deep(value);
|
|
12
10
|
}
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import Guard from '../../guard/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Memory } from '../../system/memory/index.mjs';
|
|
4
|
+
import { Array as _Array_, ArrayOptions, IsArray } from '../../type/index.mjs';
|
|
5
|
+
import { Intersect, IsIntersect } from '../../type/index.mjs';
|
|
5
6
|
import { IsObject, Object as _Object_ } from '../../type/index.mjs';
|
|
6
|
-
import { IsRecord, Record,
|
|
7
|
+
import { IsRecord, Record, RecordPattern, RecordValue } from '../../type/index.mjs';
|
|
8
|
+
import { String } from '../../type/index.mjs';
|
|
7
9
|
import { IsTuple, Tuple } from '../../type/index.mjs';
|
|
8
|
-
import {
|
|
10
|
+
import { IsUnion, Union } from '../../type/index.mjs';
|
|
9
11
|
import { Priority } from '../../type/index.mjs';
|
|
10
12
|
// ------------------------------------------------------------------
|
|
11
13
|
// Modifiers (Mutable)
|
|
12
14
|
//
|
|
13
15
|
// Prioritized types lose `~modifier` properties and additional constraints
|
|
14
16
|
// (e.g. additionalProperties) during the mapping phase and need to be
|
|
15
|
-
// reassigned afterward.
|
|
16
|
-
//
|
|
17
|
+
// reassigned afterward. We previously used a mutable assignment on this
|
|
18
|
+
// function, however `immutableTypes: true` caused errors. We use the
|
|
19
|
+
// Memory.Assign to ensure modifiers are retained and we preserve type
|
|
20
|
+
// configurations (review)
|
|
17
21
|
//
|
|
18
22
|
// ------------------------------------------------------------------
|
|
19
23
|
function Modifiers(type, next) {
|
|
20
|
-
|
|
21
|
-
if (Guard.HasPropertyKey(next, key))
|
|
22
|
-
continue;
|
|
23
|
-
next[key] = type[key];
|
|
24
|
-
}
|
|
25
|
-
return next;
|
|
24
|
+
return Memory.Assign(type, next);
|
|
26
25
|
}
|
|
27
26
|
// ------------------------------------------------------------------
|
|
28
27
|
// Properties
|
|
@@ -34,6 +33,18 @@ function FromProperties(properties) {
|
|
|
34
33
|
return result;
|
|
35
34
|
}
|
|
36
35
|
// ------------------------------------------------------------------
|
|
36
|
+
// FromRecordKey
|
|
37
|
+
//
|
|
38
|
+
// This is required because RecordKey(...) returns a canonical
|
|
39
|
+
// decoded type derived from the pattern. When the pattern is an
|
|
40
|
+
// unrecognized user-defined one, the result falls through to
|
|
41
|
+
// TString (^.*$) and the user-defined pattern is lost. This
|
|
42
|
+
// function ensures the exact pattern is retained.
|
|
43
|
+
// ------------------------------------------------------------------
|
|
44
|
+
function FromRecordKey(type) {
|
|
45
|
+
return String({ pattern: RecordPattern(type) });
|
|
46
|
+
}
|
|
47
|
+
// ------------------------------------------------------------------
|
|
37
48
|
// PriorityTypes
|
|
38
49
|
// ------------------------------------------------------------------
|
|
39
50
|
function FromPriorityTypes(types) {
|
|
@@ -43,7 +54,7 @@ function FromPriorityTypes(types) {
|
|
|
43
54
|
// Types
|
|
44
55
|
// ------------------------------------------------------------------
|
|
45
56
|
function FromTypes(types) {
|
|
46
|
-
return types.map(type => FromType(type));
|
|
57
|
+
return types.map((type) => FromType(type));
|
|
47
58
|
}
|
|
48
59
|
// ------------------------------------------------------------------
|
|
49
60
|
// Type
|
|
@@ -53,7 +64,7 @@ function FromType(type) {
|
|
|
53
64
|
IsIntersect(type) ? Intersect(FromTypes(type.allOf)) :
|
|
54
65
|
IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) :
|
|
55
66
|
IsObject(type) ? _Object_(FromProperties(type.properties)) :
|
|
56
|
-
IsRecord(type) ? Record(
|
|
67
|
+
IsRecord(type) ? Record(FromRecordKey(type), FromType(RecordValue(type))) :
|
|
57
68
|
IsTuple(type) ? Tuple(FromTypes(type.items)) :
|
|
58
69
|
type);
|
|
59
70
|
return Modifiers(type, next);
|