@duplojs/lang 0.0.1-beta.2 → 0.0.1-beta.4
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/common/constraint/index.d.ts +1 -0
- package/dist/common/constraint/remove.cjs +6 -0
- package/dist/common/constraint/remove.d.ts +2 -0
- package/dist/common/constraint/remove.mjs +6 -0
- package/dist/common/index.cjs +3 -0
- package/dist/common/index.mjs +3 -1
- package/dist/common/types/forward.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/dataStructure/common/codec.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/allowedCharacters.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/arrayLengthEqual.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/betweenThan.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/betweenThanOrEqual.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/email.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/even.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/greaterThan.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/greaterThanOrEqual.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/index.d.ts +1 -0
- package/dist/dataStructure/constraint/defaults/integer.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/lessThan.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/lessThanOrEqual.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/maxCharacters.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/maxElements.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/minCharacters.cjs +3 -3
- package/dist/dataStructure/constraint/defaults/minCharacters.d.ts +2 -2
- package/dist/dataStructure/constraint/defaults/minCharacters.mjs +3 -3
- package/dist/dataStructure/constraint/defaults/minElements.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/multipleOf.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/negative.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/notEmpty.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/notZero.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/odd.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/positive.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/refine.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/regex.cjs +13 -0
- package/dist/dataStructure/constraint/defaults/regex.d.ts +10 -0
- package/dist/dataStructure/constraint/defaults/regex.mjs +12 -0
- package/dist/dataStructure/constraint/defaults/safe.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/strictNegative.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/strictPositive.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/stringLengthEqual.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/trimmed.d.ts +1 -1
- package/dist/dataStructure/constraint/defaults/url.cjs +2 -2
- package/dist/dataStructure/constraint/defaults/url.d.ts +2 -3
- package/dist/dataStructure/constraint/defaults/url.mjs +2 -2
- package/dist/dataStructure/constraint/defaults/uuid.cjs +1 -3
- package/dist/dataStructure/constraint/defaults/uuid.d.ts +1 -3
- package/dist/dataStructure/constraint/defaults/uuid.mjs +3 -4
- package/dist/dataStructure/constraint/identifier.d.ts +3 -4
- package/dist/dataStructure/constraint/types/constraints.d.ts +18 -15
- package/dist/dataStructure/fundamentalType/defaults/bigint.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/boolean.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/date.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/null.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/number.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/string.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/time.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/defaults/undefined.d.ts +1 -1
- package/dist/dataStructure/fundamentalType/identifier.d.ts +3 -4
- package/dist/dataStructure/helpers/index.d.ts +1 -0
- package/dist/dataStructure/helpers/nullable.cjs +5 -2
- package/dist/dataStructure/helpers/nullable.mjs +5 -2
- package/dist/dataStructure/helpers/optional.cjs +5 -2
- package/dist/dataStructure/helpers/optional.mjs +5 -2
- package/dist/dataStructure/helpers/partial.cjs +5 -2
- package/dist/dataStructure/helpers/partial.mjs +5 -2
- package/dist/dataStructure/helpers/regex.cjs +7 -0
- package/dist/dataStructure/helpers/regex.d.ts +2 -0
- package/dist/dataStructure/helpers/regex.mjs +7 -0
- package/dist/dataStructure/helpers/required.cjs +6 -3
- package/dist/dataStructure/helpers/required.d.ts +2 -1
- package/dist/dataStructure/helpers/required.mjs +6 -3
- package/dist/dataStructure/helpers/url.cjs +2 -2
- package/dist/dataStructure/helpers/url.d.ts +1 -2
- package/dist/dataStructure/helpers/url.mjs +2 -2
- package/dist/dataStructure/index.cjs +12 -6
- package/dist/dataStructure/index.mjs +11 -7
- package/dist/dataStructure/structure/defaults/array.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/lazy.cjs +6 -1
- package/dist/dataStructure/structure/defaults/lazy.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/lazy.mjs +6 -1
- package/dist/dataStructure/structure/defaults/nonEncodableString.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/object.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/record.cjs +7 -7
- package/dist/dataStructure/structure/defaults/record.d.ts +2 -2
- package/dist/dataStructure/structure/defaults/record.mjs +7 -7
- package/dist/dataStructure/structure/defaults/type.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/union.cjs +11 -5
- package/dist/dataStructure/structure/defaults/union.d.ts +2 -2
- package/dist/dataStructure/structure/defaults/union.mjs +11 -5
- package/dist/dataStructure/structure/identifier.d.ts +3 -4
- package/dist/dataStructure/type/defaults/bigint.d.ts +1 -1
- package/dist/dataStructure/type/defaults/bigintLiteral.d.ts +1 -1
- package/dist/dataStructure/type/defaults/boolean.d.ts +1 -1
- package/dist/dataStructure/type/defaults/booleanLiteral.d.ts +1 -1
- package/dist/dataStructure/type/defaults/date.d.ts +1 -1
- package/dist/dataStructure/type/defaults/null.d.ts +1 -1
- package/dist/dataStructure/type/defaults/number.d.ts +1 -1
- package/dist/dataStructure/type/defaults/numberLiteral.d.ts +1 -1
- package/dist/dataStructure/type/defaults/string.d.ts +1 -1
- package/dist/dataStructure/type/defaults/stringLiteral.d.ts +1 -1
- package/dist/dataStructure/type/defaults/time.d.ts +1 -1
- package/dist/dataStructure/type/defaults/undefined.d.ts +1 -1
- package/dist/dataStructure/type/identifier.d.ts +3 -4
- package/dist/index.cjs +2 -0
- package/dist/index.mjs +2 -1
- package/dist/invocation/flow/base.d.ts +1 -1
- package/dist/invocation/flow/controller/defaults/aborter.cjs +4 -1
- package/dist/invocation/flow/controller/defaults/aborter.d.ts +6 -3
- package/dist/invocation/flow/controller/defaults/aborter.mjs +4 -1
- package/dist/invocation/flow/controller/defaults/debounce.d.ts +1 -1
- package/dist/invocation/flow/controller/defaults/filter.d.ts +1 -1
- package/dist/invocation/flow/controller/defaults/retry.d.ts +1 -1
- package/dist/invocation/flow/controller/defaults/throttling.d.ts +1 -1
- package/dist/invocation/flow/controller/defaults/timeout.d.ts +1 -1
- package/dist/kind/createIdentifier.d.ts +8 -4
- package/dist/modeling/entity/base.d.ts +3 -4
- package/dist/modeling/newType/base.d.ts +1 -1
- package/dist/modeling/taggedObject/base.d.ts +3 -4
- package/dist/string/isUrl.cjs +2 -11
- package/dist/string/isUrl.d.ts +1 -5
- package/dist/string/isUrl.mjs +2 -11
- package/package.json +1 -1
|
@@ -3,10 +3,15 @@ const require_memo = require("../../../common/memo.cjs");
|
|
|
3
3
|
const require_kind = require("../../kind.cjs");
|
|
4
4
|
const require_resultSymbol = require("../../common/resultSymbol.cjs");
|
|
5
5
|
const require_base = require("../base.cjs");
|
|
6
|
+
const require_identifier = require("../identifier.cjs");
|
|
6
7
|
//#region scripts/dataStructure/structure/defaults/lazy.ts
|
|
7
8
|
const lazyStructureKind = require_kind.createKind("lazy-structure");
|
|
8
9
|
const LazyStructure = require_base.createStructure(lazyStructureKind, ({ init }) => (getStructure, constraints) => init({
|
|
9
|
-
getter: require_memo.memo(
|
|
10
|
+
getter: require_memo.memo(() => {
|
|
11
|
+
const dataStructure = getStructure();
|
|
12
|
+
if (require_identifier.structureIdentifier(dataStructure, lazyStructureKind)) return dataStructure.definition.getter.value;
|
|
13
|
+
return dataStructure;
|
|
14
|
+
}),
|
|
10
15
|
constraints
|
|
11
16
|
}, {
|
|
12
17
|
executeCheck: (self, data, errorHandler) => self.definition.getter.value.executeCheck(data, errorHandler),
|
|
@@ -7,6 +7,6 @@ export declare const lazyStructureKind: DKind.Handler<DKind.Definition<"@Duplojs
|
|
|
7
7
|
export interface LazyStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
8
8
|
readonly getter: DCommon.Memoized<Structure>;
|
|
9
9
|
}
|
|
10
|
-
export interface LazyStructure<GenericValue extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.
|
|
10
|
+
export interface LazyStructure<GenericValue extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, LazyStructureDefinition<GenericConstraints>> & DKind.Kind<typeof lazyStructureKind>> {
|
|
11
11
|
}
|
|
12
12
|
export declare const LazyStructure: <GenericStructure extends Structure, const GenericConstraints extends readonly Constraint<StructureValue<GenericStructure>>[]>(getStructure: () => GenericStructure, constraints: GenericConstraints) => NoInfer<LazyStructure<StructureValue<GenericStructure>, readonly [...GenericConstraints]>>;
|
|
@@ -3,10 +3,15 @@ import { memo } from "../../../common/memo.mjs";
|
|
|
3
3
|
import { createKind } from "../../kind.mjs";
|
|
4
4
|
import { ErrorSymbol } from "../../common/resultSymbol.mjs";
|
|
5
5
|
import { createStructure } from "../base.mjs";
|
|
6
|
+
import { structureIdentifier } from "../identifier.mjs";
|
|
6
7
|
//#region scripts/dataStructure/structure/defaults/lazy.ts
|
|
7
8
|
const lazyStructureKind = createKind("lazy-structure");
|
|
8
9
|
const LazyStructure = createStructure(lazyStructureKind, ({ init }) => (getStructure, constraints) => init({
|
|
9
|
-
getter: memo(
|
|
10
|
+
getter: memo(() => {
|
|
11
|
+
const dataStructure = getStructure();
|
|
12
|
+
if (structureIdentifier(dataStructure, lazyStructureKind)) return dataStructure.definition.getter.value;
|
|
13
|
+
return dataStructure;
|
|
14
|
+
}),
|
|
10
15
|
constraints
|
|
11
16
|
}, {
|
|
12
17
|
executeCheck: (self, data, errorHandler) => self.definition.getter.value.executeCheck(data, errorHandler),
|
|
@@ -5,6 +5,6 @@ export declare const nonEncodableStringStructureKind: DKind.Handler<DKind.Defini
|
|
|
5
5
|
export interface NonEncodableStringStructureDefinition extends StructureDefinition<readonly []> {
|
|
6
6
|
readonly value: string;
|
|
7
7
|
}
|
|
8
|
-
export interface NonEncodableStringStructure extends DCommon.
|
|
8
|
+
export interface NonEncodableStringStructure extends DCommon.Forward<Structure<String, NonEncodableStringStructureDefinition> & DKind.Kind<typeof nonEncodableStringStructureKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const NonEncodableStringStructure: (value: string) => NoInfer<NonEncodableStringStructure>;
|
|
@@ -25,6 +25,6 @@ export interface ObjectStructureDefinition<GenericConstraints extends readonly C
|
|
|
25
25
|
readonly shape: DCommon.Memoized<readonly EntryShapeObjectStructure[]>;
|
|
26
26
|
readonly keys: readonly string[];
|
|
27
27
|
}
|
|
28
|
-
export interface ObjectStructure<GenericValue extends Record<string, unknown> = Record<string, unknown>, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.
|
|
28
|
+
export interface ObjectStructure<GenericValue extends Record<string, unknown> = Record<string, unknown>, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, ObjectStructureDefinition<GenericConstraints>> & DKind.Kind<typeof objectStructureKind>> {
|
|
29
29
|
}
|
|
30
30
|
export declare const ObjectStructure: <GenericShape extends ShapeObjectStructure, const GenericConstraints extends readonly Constraint<ShapeObjectStructureValue<GenericShape>>[]>(shape: GenericShape, constraints: GenericConstraints) => NoInfer<ObjectStructure<ShapeObjectStructureValue<GenericShape>, readonly [...GenericConstraints]>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_callThen = require("../../../common/callThen.cjs");
|
|
2
2
|
const require_isType = require("../../../common/isType.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_memo = require("../../../common/memo.cjs");
|
|
4
4
|
const require_kind = require("../../kind.cjs");
|
|
5
5
|
const require_resultSymbol = require("../../common/resultSymbol.cjs");
|
|
6
6
|
const require_base = require("../base.cjs");
|
|
@@ -16,10 +16,10 @@ const RecordStructure = require_base.createStructure(recordStructureKind, ({ ini
|
|
|
16
16
|
key,
|
|
17
17
|
value,
|
|
18
18
|
constraints,
|
|
19
|
-
requiredKeys:
|
|
19
|
+
requiredKeys: require_memo.memo(() => {
|
|
20
20
|
if (require_identifier.structureIdentifier(key, require_union.unionStructureKind)) {
|
|
21
|
-
if (key.definition.values.some((value) => require_identifier.structureIdentifier(value, require_type.typeStructureKind) && require_identifier$1.typeIdentifier(value.definition.type, require_string.stringTypeKind))) return null;
|
|
22
|
-
return key.definition.values.map((value) => require_identifier.structureIdentifier(value, require_type.typeStructureKind) && require_identifier$1.typeIdentifier(value.definition.type, require_stringLiteral.stringLiteralTypeKind) ? value.definition.type.definition.value : null).filter(require_isType.isType("string"));
|
|
21
|
+
if (key.definition.values.value.some((value) => require_identifier.structureIdentifier(value, require_type.typeStructureKind) && require_identifier$1.typeIdentifier(value.definition.type, require_string.stringTypeKind))) return null;
|
|
22
|
+
return key.definition.values.value.map((value) => require_identifier.structureIdentifier(value, require_type.typeStructureKind) && require_identifier$1.typeIdentifier(value.definition.type, require_stringLiteral.stringLiteralTypeKind) ? value.definition.type.definition.value : null).filter(require_isType.isType("string"));
|
|
23
23
|
}
|
|
24
24
|
if (require_identifier.structureIdentifier(key, require_type.typeStructureKind) && require_identifier$1.typeIdentifier(key.definition.type, require_stringLiteral.stringLiteralTypeKind)) return [key.definition.type.definition.value];
|
|
25
25
|
return null;
|
|
@@ -28,7 +28,7 @@ const RecordStructure = require_base.createStructure(recordStructureKind, ({ ini
|
|
|
28
28
|
executeCheck: (self, data, errorHandler) => {
|
|
29
29
|
if (typeof data !== "object" || data === null || data.constructor !== void 0 && data.constructor.name !== "Object" || Object.getOwnPropertySymbols(data).length !== 0) return errorHandler?.().addIssue(self, data) ?? require_resultSymbol.ErrorSymbol;
|
|
30
30
|
const keyData = Object.keys(data);
|
|
31
|
-
const requiredKeys = self.definition.requiredKeys;
|
|
31
|
+
const requiredKeys = self.definition.requiredKeys.value;
|
|
32
32
|
if (requiredKeys && keyData.some((value) => !requiredKeys.includes(value))) return errorHandler?.().addIssue(self, data) ?? require_resultSymbol.ErrorSymbol;
|
|
33
33
|
const pathStage = errorHandler?.().createPathStage();
|
|
34
34
|
const result = (requiredKeys ?? keyData).reduce((accumulator, key) => require_callThen.callThen(accumulator, (awaitedAccumulator) => pathStage?.setCurrentPath(`{record key: ${key}}`) ?? require_callThen.callThen(self.definition.key.executeCheck(key, errorHandler), (resultKey) => pathStage?.setCurrentPath(`{record value: ${key}}`) ?? require_callThen.callThen(self.definition.value.executeCheck(data[key], errorHandler), (resultValue) => resultValue === require_resultSymbol.ErrorSymbol || resultKey === require_resultSymbol.ErrorSymbol || awaitedAccumulator === require_resultSymbol.ErrorSymbol ? require_resultSymbol.ErrorSymbol : require_resultSymbol.SuccessSymbol))), require_resultSymbol.SuccessSymbol);
|
|
@@ -40,7 +40,7 @@ const RecordStructure = require_base.createStructure(recordStructureKind, ({ ini
|
|
|
40
40
|
executeEncode: (self, codecContext, data, errorHandler) => {
|
|
41
41
|
if (typeof data !== "object" || data === null || data.constructor !== void 0 && data.constructor.name !== "Object" || Object.getOwnPropertySymbols(data).length !== 0) return errorHandler?.().addIssue(self, data) ?? require_resultSymbol.ErrorSymbol;
|
|
42
42
|
const keyData = Object.keys(data);
|
|
43
|
-
const requiredKeys = self.definition.requiredKeys;
|
|
43
|
+
const requiredKeys = self.definition.requiredKeys.value;
|
|
44
44
|
if (requiredKeys && keyData.some((value) => !requiredKeys.includes(value))) return errorHandler?.().addIssue(self, data) ?? require_resultSymbol.ErrorSymbol;
|
|
45
45
|
const pathStage = errorHandler?.().createPathStage();
|
|
46
46
|
const encodedData = (requiredKeys ?? keyData).reduce((accumulator, key) => require_callThen.callThen(accumulator, (awaitedAccumulator) => pathStage?.setCurrentPath(`{record key: ${key}}`) ?? require_callThen.callThen(self.definition.key.executeCheck(key, errorHandler), (keyResult) => pathStage?.setCurrentPath(`{record value: ${key}}`) ?? require_callThen.callThen(self.definition.value.executeEncode(codecContext, data[key], errorHandler), (encodedValue) => {
|
|
@@ -53,7 +53,7 @@ const RecordStructure = require_base.createStructure(recordStructureKind, ({ ini
|
|
|
53
53
|
executeDecode: (self, codecContext, data, errorHandler) => {
|
|
54
54
|
if (typeof data !== "object" || data === null || data.constructor !== void 0 && data.constructor.name !== "Object" || Object.getOwnPropertySymbols(data).length !== 0) return errorHandler?.().addIssue(self, data) ?? require_resultSymbol.ErrorSymbol;
|
|
55
55
|
const keyData = Object.keys(data);
|
|
56
|
-
const requiredKeys = self.definition.requiredKeys;
|
|
56
|
+
const requiredKeys = self.definition.requiredKeys.value;
|
|
57
57
|
if (requiredKeys && keyData.some((value) => !requiredKeys.includes(value))) return errorHandler?.().addIssue(self, data) ?? require_resultSymbol.ErrorSymbol;
|
|
58
58
|
const pathStage = errorHandler?.().createPathStage();
|
|
59
59
|
const decodedData = (requiredKeys ?? keyData).reduce((accumulator, key) => require_callThen.callThen(accumulator, (awaitedAccumulator) => pathStage?.setCurrentPath(`{record key: ${key}}`) ?? require_callThen.callThen(self.definition.key.executeCheck(key, errorHandler), (keyResult) => pathStage?.setCurrentPath(`{record value: ${key}}`) ?? require_callThen.callThen(self.definition.value.executeDecode(codecContext, data[key], errorHandler), (decodedValue) => {
|
|
@@ -12,8 +12,8 @@ export declare const recordStructureKind: DKind.Handler<DKind.Definition<"@Duplo
|
|
|
12
12
|
export interface RecordStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
13
13
|
readonly key: UnionStructure<string> | TypeStructure<string>;
|
|
14
14
|
readonly value: Structure;
|
|
15
|
-
readonly requiredKeys: string[] | null
|
|
15
|
+
readonly requiredKeys: DCommon.Memoized<string[] | null>;
|
|
16
16
|
}
|
|
17
|
-
export interface RecordStructure<GenericValue extends Record<string, unknown> = Record<string, unknown>, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.
|
|
17
|
+
export interface RecordStructure<GenericValue extends Record<string, unknown> = Record<string, unknown>, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, RecordStructureDefinition<GenericConstraints>> & DKind.Kind<typeof recordStructureKind>> {
|
|
18
18
|
}
|
|
19
19
|
export declare const RecordStructure: <GenericKey extends (UnionStructure<string> | TypeStructure<string>), GenericValueStructure extends Structure, const GenericConstraints extends readonly Constraint<RecordStructureValue<GenericKey, GenericValueStructure>>[]>(key: GenericKey, value: GenericValueStructure, constraints: GenericConstraints) => NoInfer<RecordStructure<RecordStructureValue<GenericKey, GenericValueStructure>, readonly [...GenericConstraints]>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { callThen } from "../../../common/callThen.mjs";
|
|
2
2
|
import { isType } from "../../../common/isType.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { memo } from "../../../common/memo.mjs";
|
|
4
4
|
import { createKind } from "../../kind.mjs";
|
|
5
5
|
import { ErrorSymbol, SuccessSymbol } from "../../common/resultSymbol.mjs";
|
|
6
6
|
import { createStructure } from "../base.mjs";
|
|
@@ -16,10 +16,10 @@ const RecordStructure = createStructure(recordStructureKind, ({ init }) => (key,
|
|
|
16
16
|
key,
|
|
17
17
|
value,
|
|
18
18
|
constraints,
|
|
19
|
-
requiredKeys:
|
|
19
|
+
requiredKeys: memo(() => {
|
|
20
20
|
if (structureIdentifier(key, unionStructureKind)) {
|
|
21
|
-
if (key.definition.values.some((value) => structureIdentifier(value, typeStructureKind) && typeIdentifier(value.definition.type, stringTypeKind))) return null;
|
|
22
|
-
return key.definition.values.map((value) => structureIdentifier(value, typeStructureKind) && typeIdentifier(value.definition.type, stringLiteralTypeKind) ? value.definition.type.definition.value : null).filter(isType("string"));
|
|
21
|
+
if (key.definition.values.value.some((value) => structureIdentifier(value, typeStructureKind) && typeIdentifier(value.definition.type, stringTypeKind))) return null;
|
|
22
|
+
return key.definition.values.value.map((value) => structureIdentifier(value, typeStructureKind) && typeIdentifier(value.definition.type, stringLiteralTypeKind) ? value.definition.type.definition.value : null).filter(isType("string"));
|
|
23
23
|
}
|
|
24
24
|
if (structureIdentifier(key, typeStructureKind) && typeIdentifier(key.definition.type, stringLiteralTypeKind)) return [key.definition.type.definition.value];
|
|
25
25
|
return null;
|
|
@@ -28,7 +28,7 @@ const RecordStructure = createStructure(recordStructureKind, ({ init }) => (key,
|
|
|
28
28
|
executeCheck: (self, data, errorHandler) => {
|
|
29
29
|
if (typeof data !== "object" || data === null || data.constructor !== void 0 && data.constructor.name !== "Object" || Object.getOwnPropertySymbols(data).length !== 0) return errorHandler?.().addIssue(self, data) ?? ErrorSymbol;
|
|
30
30
|
const keyData = Object.keys(data);
|
|
31
|
-
const requiredKeys = self.definition.requiredKeys;
|
|
31
|
+
const requiredKeys = self.definition.requiredKeys.value;
|
|
32
32
|
if (requiredKeys && keyData.some((value) => !requiredKeys.includes(value))) return errorHandler?.().addIssue(self, data) ?? ErrorSymbol;
|
|
33
33
|
const pathStage = errorHandler?.().createPathStage();
|
|
34
34
|
const result = (requiredKeys ?? keyData).reduce((accumulator, key) => callThen(accumulator, (awaitedAccumulator) => pathStage?.setCurrentPath(`{record key: ${key}}`) ?? callThen(self.definition.key.executeCheck(key, errorHandler), (resultKey) => pathStage?.setCurrentPath(`{record value: ${key}}`) ?? callThen(self.definition.value.executeCheck(data[key], errorHandler), (resultValue) => resultValue === ErrorSymbol || resultKey === ErrorSymbol || awaitedAccumulator === ErrorSymbol ? ErrorSymbol : SuccessSymbol))), SuccessSymbol);
|
|
@@ -40,7 +40,7 @@ const RecordStructure = createStructure(recordStructureKind, ({ init }) => (key,
|
|
|
40
40
|
executeEncode: (self, codecContext, data, errorHandler) => {
|
|
41
41
|
if (typeof data !== "object" || data === null || data.constructor !== void 0 && data.constructor.name !== "Object" || Object.getOwnPropertySymbols(data).length !== 0) return errorHandler?.().addIssue(self, data) ?? ErrorSymbol;
|
|
42
42
|
const keyData = Object.keys(data);
|
|
43
|
-
const requiredKeys = self.definition.requiredKeys;
|
|
43
|
+
const requiredKeys = self.definition.requiredKeys.value;
|
|
44
44
|
if (requiredKeys && keyData.some((value) => !requiredKeys.includes(value))) return errorHandler?.().addIssue(self, data) ?? ErrorSymbol;
|
|
45
45
|
const pathStage = errorHandler?.().createPathStage();
|
|
46
46
|
const encodedData = (requiredKeys ?? keyData).reduce((accumulator, key) => callThen(accumulator, (awaitedAccumulator) => pathStage?.setCurrentPath(`{record key: ${key}}`) ?? callThen(self.definition.key.executeCheck(key, errorHandler), (keyResult) => pathStage?.setCurrentPath(`{record value: ${key}}`) ?? callThen(self.definition.value.executeEncode(codecContext, data[key], errorHandler), (encodedValue) => {
|
|
@@ -53,7 +53,7 @@ const RecordStructure = createStructure(recordStructureKind, ({ init }) => (key,
|
|
|
53
53
|
executeDecode: (self, codecContext, data, errorHandler) => {
|
|
54
54
|
if (typeof data !== "object" || data === null || data.constructor !== void 0 && data.constructor.name !== "Object" || Object.getOwnPropertySymbols(data).length !== 0) return errorHandler?.().addIssue(self, data) ?? ErrorSymbol;
|
|
55
55
|
const keyData = Object.keys(data);
|
|
56
|
-
const requiredKeys = self.definition.requiredKeys;
|
|
56
|
+
const requiredKeys = self.definition.requiredKeys.value;
|
|
57
57
|
if (requiredKeys && keyData.some((value) => !requiredKeys.includes(value))) return errorHandler?.().addIssue(self, data) ?? ErrorSymbol;
|
|
58
58
|
const pathStage = errorHandler?.().createPathStage();
|
|
59
59
|
const decodedData = (requiredKeys ?? keyData).reduce((accumulator, key) => callThen(accumulator, (awaitedAccumulator) => pathStage?.setCurrentPath(`{record key: ${key}}`) ?? callThen(self.definition.key.executeCheck(key, errorHandler), (keyResult) => pathStage?.setCurrentPath(`{record value: ${key}}`) ?? callThen(self.definition.value.executeDecode(codecContext, data[key], errorHandler), (decodedValue) => {
|
|
@@ -7,6 +7,6 @@ export declare const typeStructureKind: DKind.Handler<DKind.Definition<"@Duplojs
|
|
|
7
7
|
export interface TypeStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
8
8
|
readonly type: Type;
|
|
9
9
|
}
|
|
10
|
-
export interface TypeStructure<GenericType extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericType>[] = readonly Constraint<GenericType>[]> extends DCommon.
|
|
10
|
+
export interface TypeStructure<GenericType extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericType>[] = readonly Constraint<GenericType>[]> extends DCommon.Forward<Structure<GenericType, TypeStructureDefinition<GenericConstraints>> & DKind.Kind<typeof typeStructureKind>> {
|
|
11
11
|
}
|
|
12
12
|
export declare const TypeStructure: <GenericType extends Type, const GenericConstraints extends readonly Constraint<TypeValue<GenericType>>[]>(type: GenericType, constraints: GenericConstraints) => NoInfer<TypeStructure<TypeValue<GenericType>, readonly [...GenericConstraints]>>;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
const require_callThen = require("../../../common/callThen.cjs");
|
|
2
|
+
const require_memo = require("../../../common/memo.cjs");
|
|
2
3
|
const require_kind = require("../../kind.cjs");
|
|
3
4
|
const require_resultSymbol = require("../../common/resultSymbol.cjs");
|
|
4
5
|
const require_error = require("../../common/error.cjs");
|
|
5
6
|
const require_base = require("../base.cjs");
|
|
6
7
|
const require_identifier = require("../identifier.cjs");
|
|
8
|
+
const require_lazy = require("./lazy.cjs");
|
|
7
9
|
//#region scripts/dataStructure/structure/defaults/union.ts
|
|
8
10
|
const unionStructureKind = require_kind.createKind("union-structure");
|
|
9
11
|
const UnionStructure = require_base.createStructure(unionStructureKind, ({ init }) => (values, constraints) => init({
|
|
10
|
-
values:
|
|
12
|
+
values: require_memo.memo(() => values.flatMap((value) => (function flatUnion(structure) {
|
|
13
|
+
if (require_identifier.structureIdentifier(structure, unionStructureKind)) return structure.definition.values.value.flatMap(flatUnion);
|
|
14
|
+
if (require_identifier.structureIdentifier(structure, require_lazy.lazyStructureKind)) return flatUnion(structure.definition.getter.value);
|
|
15
|
+
return structure;
|
|
16
|
+
})(value))),
|
|
11
17
|
constraints
|
|
12
18
|
}, {
|
|
13
19
|
executeCheck: (self, data, errorHandler) => {
|
|
14
20
|
const errorHandlers = errorHandler ? [] : void 0;
|
|
15
|
-
const result = self.definition.values.reduce((accumulator, value, index) => require_callThen.callThen(accumulator, (awaitedAccumulator) => {
|
|
21
|
+
const result = self.definition.values.value.reduce((accumulator, value, index) => require_callThen.callThen(accumulator, (awaitedAccumulator) => {
|
|
16
22
|
if (awaitedAccumulator === require_resultSymbol.SuccessSymbol) return awaitedAccumulator;
|
|
17
23
|
const subErrorHandler = errorHandler === void 0 ? void 0 : require_error.createGetErrorHandler(errorHandler().currentPath);
|
|
18
24
|
if (errorHandlers && subErrorHandler) {
|
|
@@ -32,7 +38,7 @@ const UnionStructure = require_base.createStructure(unionStructureKind, ({ init
|
|
|
32
38
|
},
|
|
33
39
|
executeEncode: (self, codec, data, errorHandler) => {
|
|
34
40
|
const errorHandlers = errorHandler ? [] : void 0;
|
|
35
|
-
const encodedData = self.definition.values.reduce((accumulator, value, index) => require_callThen.callThen(accumulator, (awaitedAccumulator) => {
|
|
41
|
+
const encodedData = self.definition.values.value.reduce((accumulator, value, index) => require_callThen.callThen(accumulator, (awaitedAccumulator) => {
|
|
36
42
|
if (awaitedAccumulator !== require_resultSymbol.ErrorSymbol) return awaitedAccumulator;
|
|
37
43
|
const subErrorHandler = errorHandler === void 0 ? void 0 : require_error.createGetErrorHandler(errorHandler().currentPath);
|
|
38
44
|
if (errorHandlers && subErrorHandler) {
|
|
@@ -52,7 +58,7 @@ const UnionStructure = require_base.createStructure(unionStructureKind, ({ init
|
|
|
52
58
|
},
|
|
53
59
|
executeDecode: (self, codec, data, errorHandler) => {
|
|
54
60
|
const errorHandlers = errorHandler ? [] : void 0;
|
|
55
|
-
const decodedData = self.definition.values.reduce((accumulator, value, index) => require_callThen.callThen(accumulator, (awaitedAccumulator) => {
|
|
61
|
+
const decodedData = self.definition.values.value.reduce((accumulator, value, index) => require_callThen.callThen(accumulator, (awaitedAccumulator) => {
|
|
56
62
|
if (awaitedAccumulator !== require_resultSymbol.ErrorSymbol) return awaitedAccumulator;
|
|
57
63
|
const subErrorHandler = errorHandler === void 0 ? void 0 : require_error.createGetErrorHandler(errorHandler().currentPath);
|
|
58
64
|
if (errorHandlers && subErrorHandler) {
|
|
@@ -70,7 +76,7 @@ const UnionStructure = require_base.createStructure(unionStructureKind, ({ init
|
|
|
70
76
|
return require_callThen.callThen(self.executeConstraints(awaitedDecodedData, errorHandler), (result) => result === require_resultSymbol.ErrorSymbol ? require_resultSymbol.ErrorSymbol : awaitedDecodedData);
|
|
71
77
|
});
|
|
72
78
|
},
|
|
73
|
-
isAsynchronous: (self) => self.definition.values.some((value) => value.isAsynchronous())
|
|
79
|
+
isAsynchronous: (self) => self.definition.values.value.some((value) => value.isAsynchronous())
|
|
74
80
|
}));
|
|
75
81
|
//#endregion
|
|
76
82
|
exports.UnionStructure = UnionStructure;
|
|
@@ -5,8 +5,8 @@ import type * as DKind from '../../../kind';
|
|
|
5
5
|
import * as DCommon from '../../../common';
|
|
6
6
|
export declare const unionStructureKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/union-structure", unknown>>;
|
|
7
7
|
export interface UnionStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
8
|
-
readonly values: DCommon.AnyTuple<Structure
|
|
8
|
+
readonly values: DCommon.Memoized<DCommon.AnyTuple<Structure>>;
|
|
9
9
|
}
|
|
10
|
-
export interface UnionStructure<GenericValue extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.
|
|
10
|
+
export interface UnionStructure<GenericValue extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, UnionStructureDefinition<GenericConstraints>> & DKind.Kind<typeof unionStructureKind>> {
|
|
11
11
|
}
|
|
12
12
|
export declare const UnionStructure: <GenericValues extends DCommon.AnyTuple<Structure>, const GenericConstraints extends readonly Constraint<StructureValue<GenericValues[number]>>[]>(values: GenericValues, constraints: GenericConstraints) => NoInfer<UnionStructure<StructureValue<GenericValues[number]>, readonly [...GenericConstraints]>>;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { callThen } from "../../../common/callThen.mjs";
|
|
2
|
+
import { memo } from "../../../common/memo.mjs";
|
|
2
3
|
import { createKind } from "../../kind.mjs";
|
|
3
4
|
import { ErrorSymbol, SuccessSymbol } from "../../common/resultSymbol.mjs";
|
|
4
5
|
import { createGetErrorHandler } from "../../common/error.mjs";
|
|
5
6
|
import { createStructure } from "../base.mjs";
|
|
6
7
|
import { structureIdentifier } from "../identifier.mjs";
|
|
8
|
+
import { lazyStructureKind } from "./lazy.mjs";
|
|
7
9
|
//#region scripts/dataStructure/structure/defaults/union.ts
|
|
8
10
|
const unionStructureKind = createKind("union-structure");
|
|
9
11
|
const UnionStructure = createStructure(unionStructureKind, ({ init }) => (values, constraints) => init({
|
|
10
|
-
values: values.flatMap((value) =>
|
|
12
|
+
values: memo(() => values.flatMap((value) => (function flatUnion(structure) {
|
|
13
|
+
if (structureIdentifier(structure, unionStructureKind)) return structure.definition.values.value.flatMap(flatUnion);
|
|
14
|
+
if (structureIdentifier(structure, lazyStructureKind)) return flatUnion(structure.definition.getter.value);
|
|
15
|
+
return structure;
|
|
16
|
+
})(value))),
|
|
11
17
|
constraints
|
|
12
18
|
}, {
|
|
13
19
|
executeCheck: (self, data, errorHandler) => {
|
|
14
20
|
const errorHandlers = errorHandler ? [] : void 0;
|
|
15
|
-
const result = self.definition.values.reduce((accumulator, value, index) => callThen(accumulator, (awaitedAccumulator) => {
|
|
21
|
+
const result = self.definition.values.value.reduce((accumulator, value, index) => callThen(accumulator, (awaitedAccumulator) => {
|
|
16
22
|
if (awaitedAccumulator === SuccessSymbol) return awaitedAccumulator;
|
|
17
23
|
const subErrorHandler = errorHandler === void 0 ? void 0 : createGetErrorHandler(errorHandler().currentPath);
|
|
18
24
|
if (errorHandlers && subErrorHandler) {
|
|
@@ -32,7 +38,7 @@ const UnionStructure = createStructure(unionStructureKind, ({ init }) => (values
|
|
|
32
38
|
},
|
|
33
39
|
executeEncode: (self, codec, data, errorHandler) => {
|
|
34
40
|
const errorHandlers = errorHandler ? [] : void 0;
|
|
35
|
-
const encodedData = self.definition.values.reduce((accumulator, value, index) => callThen(accumulator, (awaitedAccumulator) => {
|
|
41
|
+
const encodedData = self.definition.values.value.reduce((accumulator, value, index) => callThen(accumulator, (awaitedAccumulator) => {
|
|
36
42
|
if (awaitedAccumulator !== ErrorSymbol) return awaitedAccumulator;
|
|
37
43
|
const subErrorHandler = errorHandler === void 0 ? void 0 : createGetErrorHandler(errorHandler().currentPath);
|
|
38
44
|
if (errorHandlers && subErrorHandler) {
|
|
@@ -52,7 +58,7 @@ const UnionStructure = createStructure(unionStructureKind, ({ init }) => (values
|
|
|
52
58
|
},
|
|
53
59
|
executeDecode: (self, codec, data, errorHandler) => {
|
|
54
60
|
const errorHandlers = errorHandler ? [] : void 0;
|
|
55
|
-
const decodedData = self.definition.values.reduce((accumulator, value, index) => callThen(accumulator, (awaitedAccumulator) => {
|
|
61
|
+
const decodedData = self.definition.values.value.reduce((accumulator, value, index) => callThen(accumulator, (awaitedAccumulator) => {
|
|
56
62
|
if (awaitedAccumulator !== ErrorSymbol) return awaitedAccumulator;
|
|
57
63
|
const subErrorHandler = errorHandler === void 0 ? void 0 : createGetErrorHandler(errorHandler().currentPath);
|
|
58
64
|
if (errorHandlers && subErrorHandler) {
|
|
@@ -70,7 +76,7 @@ const UnionStructure = createStructure(unionStructureKind, ({ init }) => (values
|
|
|
70
76
|
return callThen(self.executeConstraints(awaitedDecodedData, errorHandler), (result) => result === ErrorSymbol ? ErrorSymbol : awaitedDecodedData);
|
|
71
77
|
});
|
|
72
78
|
},
|
|
73
|
-
isAsynchronous: (self) => self.definition.values.some((value) => value.isAsynchronous())
|
|
79
|
+
isAsynchronous: (self) => self.definition.values.value.some((value) => value.isAsynchronous())
|
|
74
80
|
}));
|
|
75
81
|
//#endregion
|
|
76
82
|
export { UnionStructure, unionStructureKind };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Structure } from './base';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
2
|
+
import { Structures } from './types';
|
|
3
|
+
import * as DKind from '../../kind';
|
|
4
|
+
export declare const structureIdentifier: DKind.KindIdentifier<Structure<unknown, import('..').StructureDefinition<readonly import('..').Constraint<unknown, unknown, import('..').ConstraintDefinition>[]>>, Structures>;
|
|
@@ -5,6 +5,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
5
5
|
export declare const bigintTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/bigint-type", unknown>>;
|
|
6
6
|
export interface BigintTypeDefinition extends TypeDefinition {
|
|
7
7
|
}
|
|
8
|
-
export interface BigintType extends DCommon.
|
|
8
|
+
export interface BigintType extends DCommon.Forward<Type<FundamentalType.TheBigint, bigint, BigintTypeDefinition> & DKind.Kind<typeof bigintTypeKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const BigintType: () => BigintType;
|
|
@@ -6,6 +6,6 @@ export declare const bigintLiteralTypeKind: DKind.Handler<DKind.Definition<"@Dup
|
|
|
6
6
|
export interface BigintLiteralTypeDefinition extends TypeDefinition {
|
|
7
7
|
value: bigint;
|
|
8
8
|
}
|
|
9
|
-
export interface BigintLiteralType<GenericValue extends bigint = bigint> extends DCommon.
|
|
9
|
+
export interface BigintLiteralType<GenericValue extends bigint = bigint> extends DCommon.Forward<Type<FundamentalType.TheBigint, GenericValue, BigintLiteralTypeDefinition> & DKind.Kind<typeof bigintLiteralTypeKind>> {
|
|
10
10
|
}
|
|
11
11
|
export declare const BigintLiteralType: <const GenericBigint extends bigint>(value: GenericBigint) => BigintLiteralType<GenericBigint>;
|
|
@@ -5,6 +5,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
5
5
|
export declare const booleanTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/boolean-type", unknown>>;
|
|
6
6
|
export interface BooleanTypeDefinition extends TypeDefinition {
|
|
7
7
|
}
|
|
8
|
-
export interface BooleanType extends DCommon.
|
|
8
|
+
export interface BooleanType extends DCommon.Forward<Type<FundamentalType.TheBoolean, boolean, BooleanTypeDefinition> & DKind.Kind<typeof booleanTypeKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const BooleanType: () => BooleanType;
|
|
@@ -6,6 +6,6 @@ export declare const booleanLiteralTypeKind: DKind.Handler<DKind.Definition<"@Du
|
|
|
6
6
|
export interface BooleanLiteralTypeDefinition extends TypeDefinition {
|
|
7
7
|
value: boolean;
|
|
8
8
|
}
|
|
9
|
-
export interface BooleanLiteralType<GenericValue extends boolean = boolean> extends DCommon.
|
|
9
|
+
export interface BooleanLiteralType<GenericValue extends boolean = boolean> extends DCommon.Forward<Type<FundamentalType.TheBoolean, GenericValue, BooleanLiteralTypeDefinition> & DKind.Kind<typeof booleanLiteralTypeKind>> {
|
|
10
10
|
}
|
|
11
11
|
export declare const BooleanLiteralType: <const GenericBoolean extends boolean>(value: GenericBoolean) => BooleanLiteralType<GenericBoolean>;
|
|
@@ -6,6 +6,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
6
6
|
export declare const dateTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/date-type", unknown>>;
|
|
7
7
|
export interface DateTypeDefinition extends TypeDefinition {
|
|
8
8
|
}
|
|
9
|
-
export interface DateType extends DCommon.
|
|
9
|
+
export interface DateType extends DCommon.Forward<Type<FundamentalType.TheDate, DChrono.TheDate, DateTypeDefinition> & DKind.Kind<typeof dateTypeKind>> {
|
|
10
10
|
}
|
|
11
11
|
export declare const DateType: () => DateType;
|
|
@@ -5,6 +5,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
5
5
|
export declare const nullTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/null-type", unknown>>;
|
|
6
6
|
export interface NullTypeDefinition extends TypeDefinition {
|
|
7
7
|
}
|
|
8
|
-
export interface NullType extends DCommon.
|
|
8
|
+
export interface NullType extends DCommon.Forward<Type<FundamentalType.TheNull, null, NullTypeDefinition> & DKind.Kind<typeof nullTypeKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const NullType: () => NullType;
|
|
@@ -5,6 +5,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
5
5
|
export declare const numberTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/number-type", unknown>>;
|
|
6
6
|
export interface NumberTypeDefinition extends TypeDefinition {
|
|
7
7
|
}
|
|
8
|
-
export interface NumberType extends DCommon.
|
|
8
|
+
export interface NumberType extends DCommon.Forward<Type<FundamentalType.TheNumber, number, NumberTypeDefinition> & DKind.Kind<typeof numberTypeKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const NumberType: () => NumberType;
|
|
@@ -6,6 +6,6 @@ export declare const numberLiteralTypeKind: DKind.Handler<DKind.Definition<"@Dup
|
|
|
6
6
|
export interface NumberLiteralTypeDefinition extends TypeDefinition {
|
|
7
7
|
value: number;
|
|
8
8
|
}
|
|
9
|
-
export interface NumberLiteralType<GenericValue extends number = number> extends DCommon.
|
|
9
|
+
export interface NumberLiteralType<GenericValue extends number = number> extends DCommon.Forward<Type<FundamentalType.TheNumber, GenericValue, NumberLiteralTypeDefinition> & DKind.Kind<typeof numberLiteralTypeKind>> {
|
|
10
10
|
}
|
|
11
11
|
export declare const NumberLiteralType: <const GenericNumber extends number>(value: GenericNumber) => NumberLiteralType<GenericNumber>;
|
|
@@ -5,6 +5,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
5
5
|
export declare const stringTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/string-type", unknown>>;
|
|
6
6
|
export interface StringTypeDefinition extends TypeDefinition {
|
|
7
7
|
}
|
|
8
|
-
export interface StringType extends DCommon.
|
|
8
|
+
export interface StringType extends DCommon.Forward<Type<FundamentalType.TheString, string, StringTypeDefinition> & DKind.Kind<typeof stringTypeKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const StringType: () => StringType;
|
|
@@ -6,6 +6,6 @@ export declare const stringLiteralTypeKind: DKind.Handler<DKind.Definition<"@Dup
|
|
|
6
6
|
export interface StringLiteralTypeDefinition extends TypeDefinition {
|
|
7
7
|
value: string;
|
|
8
8
|
}
|
|
9
|
-
export interface StringLiteralType<GenericValue extends string = string> extends DCommon.
|
|
9
|
+
export interface StringLiteralType<GenericValue extends string = string> extends DCommon.Forward<Type<FundamentalType.TheString, GenericValue, StringLiteralTypeDefinition> & DKind.Kind<typeof stringLiteralTypeKind>> {
|
|
10
10
|
}
|
|
11
11
|
export declare const StringLiteralType: <const GenericString extends string>(value: GenericString) => StringLiteralType<GenericString>;
|
|
@@ -6,6 +6,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
6
6
|
export declare const timeTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/time-type", unknown>>;
|
|
7
7
|
export interface TimeTypeDefinition extends TypeDefinition {
|
|
8
8
|
}
|
|
9
|
-
export interface TimeType extends DCommon.
|
|
9
|
+
export interface TimeType extends DCommon.Forward<Type<FundamentalType.TheTime, DChrono.TheTime, TimeTypeDefinition> & DKind.Kind<typeof timeTypeKind>> {
|
|
10
10
|
}
|
|
11
11
|
export declare const TimeType: () => TimeType;
|
|
@@ -5,6 +5,6 @@ import * as FundamentalType from "../../fundamentalType";
|
|
|
5
5
|
export declare const undefinedTypeKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/undefined-type", unknown>>;
|
|
6
6
|
export interface UndefinedTypeDefinition extends TypeDefinition {
|
|
7
7
|
}
|
|
8
|
-
export interface UndefinedType extends DCommon.
|
|
8
|
+
export interface UndefinedType extends DCommon.Forward<Type<FundamentalType.TheUndefined, undefined, UndefinedTypeDefinition> & DKind.Kind<typeof undefinedTypeKind>> {
|
|
9
9
|
}
|
|
10
10
|
export declare const UndefinedType: () => UndefinedType;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Type } from './base';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
2
|
+
import { Types } from './types';
|
|
3
|
+
import * as DKind from '../../kind';
|
|
4
|
+
export declare const typeIdentifier: DKind.KindIdentifier<Type<import('..').FundamentalType<unknown>, unknown, import('..').TypeDefinition>, Types>;
|
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ const require_callThen = require("./common/callThen.cjs");
|
|
|
15
15
|
const require_index$1 = require("./object/index.cjs");
|
|
16
16
|
const require_clone = require("./common/clone.cjs");
|
|
17
17
|
const require_index$2 = require("./common/constraint/cast/index.cjs");
|
|
18
|
+
const require_remove = require("./common/constraint/remove.cjs");
|
|
18
19
|
const require_detachObjectMethod = require("./common/detachObjectMethod.cjs");
|
|
19
20
|
const require_enum = require("./common/enum.cjs");
|
|
20
21
|
const require_equal = require("./common/equal.cjs");
|
|
@@ -286,6 +287,7 @@ exports.preparePipe = require_preparePipe.preparePipe;
|
|
|
286
287
|
exports.promiseAll = require_promiseAll.promiseAll;
|
|
287
288
|
exports.promiseObject = require_promiseObject.promiseObject;
|
|
288
289
|
exports.queueKind = require_queue.queueKind;
|
|
290
|
+
exports.removeConstraint = require_remove.removeConstraint;
|
|
289
291
|
exports.shameOnYou = require_index$2.shameOnYou;
|
|
290
292
|
exports.simpleClone = require_simpleClone.simpleClone;
|
|
291
293
|
exports.stringToBytes = require_stringToBytes.stringToBytes;
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { callThen } from "./common/callThen.mjs";
|
|
|
14
14
|
import { object_exports } from "./object/index.mjs";
|
|
15
15
|
import { clone } from "./common/clone.mjs";
|
|
16
16
|
import { cast, shameOnYou } from "./common/constraint/cast/index.mjs";
|
|
17
|
+
import { removeConstraint } from "./common/constraint/remove.mjs";
|
|
17
18
|
import { detachObjectMethod } from "./common/detachObjectMethod.mjs";
|
|
18
19
|
import { createEnum } from "./common/enum.mjs";
|
|
19
20
|
import { equal } from "./common/equal.mjs";
|
|
@@ -67,4 +68,4 @@ import { pattern_exports } from "./pattern/index.mjs";
|
|
|
67
68
|
import { invocation_exports } from "./invocation/index.mjs";
|
|
68
69
|
import { path_exports } from "./path/index.mjs";
|
|
69
70
|
import { printer_exports } from "./printer/index.mjs";
|
|
70
|
-
export { array_exports as A, AssertsError, chrono_exports as C, array_exports as DArray, chrono_exports as DChrono, common_exports as DCommon, dataStructure_exports as DDataStructure, either_exports as DEither, generator_exports as DGenerator, invocation_exports as DInvocation, kind_exports as DKind, modeling_exports as DModeling, number_exports as DNumber, object_exports as DObject, path_exports as DPath, pattern_exports as DPattern, printer_exports as DPrinter, dataStructure_exports as DS, string_exports as DString, tuple_exports as DTuple, either_exports as E, generator_exports as G, invocation_exports as I, InvalidBytesInStringError, InvalidMillisecondInStringError, modeling_exports as M, MissingBuilderMethodsError, number_exports as N, object_exports as O, pattern_exports as P, string_exports as S, tuple_exports as T, TheFormData, and, asserts, asyncInnerPipe, asyncLoop, asyncPipe, bindPrototypeMethods, builderKind, callThen, cast, clone, createAsyncRetry, createBuilder, createEnum, createExternalPromise, createFormData, createGlobalStore, createInterpolation, createKind, createQueue, createTransformer, detachObjectMethod, equal, escapeRegExp, falsy, forward, forwardAsserts, forwardLog, innerPipe, instanceOf, isType, justExec, justReturn, loop, memo, memoObject, memoPromise, mimeType, or, pipe, pipeCall, prepareAsyncPipe, preparePipe, promiseAll, promiseObject, queueKind, shameOnYou, simpleClone, stringToBytes, stringToMillisecond, timeout, toCurriedPredicate, toJSON, toNative, toRegExp, transformer, truthy, useAsyncRetry, when, whenElse, whenNot };
|
|
71
|
+
export { array_exports as A, AssertsError, chrono_exports as C, array_exports as DArray, chrono_exports as DChrono, common_exports as DCommon, dataStructure_exports as DDataStructure, either_exports as DEither, generator_exports as DGenerator, invocation_exports as DInvocation, kind_exports as DKind, modeling_exports as DModeling, number_exports as DNumber, object_exports as DObject, path_exports as DPath, pattern_exports as DPattern, printer_exports as DPrinter, dataStructure_exports as DS, string_exports as DString, tuple_exports as DTuple, either_exports as E, generator_exports as G, invocation_exports as I, InvalidBytesInStringError, InvalidMillisecondInStringError, modeling_exports as M, MissingBuilderMethodsError, number_exports as N, object_exports as O, pattern_exports as P, string_exports as S, tuple_exports as T, TheFormData, and, asserts, asyncInnerPipe, asyncLoop, asyncPipe, bindPrototypeMethods, builderKind, callThen, cast, clone, createAsyncRetry, createBuilder, createEnum, createExternalPromise, createFormData, createGlobalStore, createInterpolation, createKind, createQueue, createTransformer, detachObjectMethod, equal, escapeRegExp, falsy, forward, forwardAsserts, forwardLog, innerPipe, instanceOf, isType, justExec, justReturn, loop, memo, memoObject, memoPromise, mimeType, or, pipe, pipeCall, prepareAsyncPipe, preparePipe, promiseAll, promiseObject, queueKind, removeConstraint, shameOnYou, simpleClone, stringToBytes, stringToMillisecond, timeout, toCurriedPredicate, toJSON, toNative, toRegExp, transformer, truthy, useAsyncRetry, when, whenElse, whenNot };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlowControllerExit, FlowControllerResult, flowControllerExitKind, FlowControllerPreviousFunctionResult, UnwrapFlowControllerResult } from './controller';
|
|
2
|
-
import { DKind } from '../../index.ts';
|
|
3
2
|
import * as DCommon from '../../common';
|
|
3
|
+
import type * as DKind from '../../kind';
|
|
4
4
|
type ComputeLastUsableValue<GenericAccumulator extends DCommon.AnyTuple> = GenericAccumulator extends [
|
|
5
5
|
...infer InferredRest,
|
|
6
6
|
infer InferredLast
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_parentClass = require("../../../../kind/parentClass.cjs");
|
|
2
2
|
const require_create = require("../../../../either/left/create.cjs");
|
|
3
|
+
const require_stringToMillisecond = require("../../../../common/stringToMillisecond.cjs");
|
|
3
4
|
const require_kind = require("../../../kind.cjs");
|
|
4
5
|
const require_base = require("../base.cjs");
|
|
5
6
|
//#region scripts/invocation/flow/controller/defaults/aborter.ts
|
|
@@ -11,14 +12,16 @@ var AbortErrorFlowController = class extends require_parentClass.parentClass(req
|
|
|
11
12
|
this.abortController = abortController;
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
|
-
const aborter = require_base.createFlowController(flowControllerAborterKind, ({ init, exitFlow }) => (theFunction) => {
|
|
15
|
+
const aborter = require_base.createFlowController(flowControllerAborterKind, ({ init, exitFlow }) => (theFunction, params) => {
|
|
15
16
|
let aborter = void 0;
|
|
17
|
+
const formattedTimeout = params?.timeout === void 0 ? void 0 : require_stringToMillisecond.stringToMillisecond(params.timeout);
|
|
16
18
|
return init(async (previousFunction) => {
|
|
17
19
|
const result = previousFunction();
|
|
18
20
|
if (require_base.flowControllerExitKind.has(result)) return result;
|
|
19
21
|
aborter?.abort(new AbortErrorFlowController(aborter));
|
|
20
22
|
const currentAborter = new AbortController();
|
|
21
23
|
aborter = currentAborter;
|
|
24
|
+
if (formattedTimeout !== void 0) setTimeout(() => void currentAborter.abort(new AbortErrorFlowController(currentAborter)), formattedTimeout);
|
|
22
25
|
try {
|
|
23
26
|
const abortResult = await theFunction(result, currentAborter);
|
|
24
27
|
if (currentAborter.signal.aborted === true) return exitFlow(require_create.left("signal-aborted", currentAborter.signal.reason));
|