@duplojs/lang 0.0.1-beta.8 → 0.0.1-beta.9
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/chrono/createDate.cjs +1 -1
- package/dist/chrono/createDate.mjs +1 -1
- package/dist/common/constraint/cast/index.d.ts +3 -3
- package/dist/common/constraint/infer/string.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/isObject.d.ts +8 -0
- package/dist/dataStructure/common/codec/base.cjs +2 -2
- package/dist/dataStructure/common/codec/base.mjs +2 -2
- package/dist/dataStructure/common/error.cjs +4 -2
- package/dist/dataStructure/common/error.d.ts +4 -2
- package/dist/dataStructure/common/error.mjs +4 -2
- package/dist/dataStructure/common/errorInterpreter.cjs +6 -6
- package/dist/dataStructure/common/errorInterpreter.d.ts +7 -3
- package/dist/dataStructure/common/errorInterpreter.mjs +6 -6
- package/dist/dataStructure/constraint/defaults/allowedCharacters.d.ts +1 -3
- package/dist/dataStructure/helpers/index.d.ts +5 -2
- package/dist/dataStructure/helpers/isNullable.cjs +12 -0
- package/dist/dataStructure/helpers/isNullable.d.ts +2 -0
- package/dist/dataStructure/helpers/isNullable.mjs +12 -0
- package/dist/dataStructure/helpers/isOptional.cjs +12 -0
- package/dist/dataStructure/helpers/isOptional.d.ts +2 -0
- package/dist/dataStructure/helpers/isOptional.mjs +12 -0
- package/dist/dataStructure/helpers/unwrapLazy.cjs +9 -0
- package/dist/dataStructure/helpers/unwrapLazy.d.ts +2 -0
- package/dist/dataStructure/helpers/unwrapLazy.mjs +9 -0
- package/dist/dataStructure/index.cjs +11 -2
- package/dist/dataStructure/index.mjs +9 -3
- package/dist/dataStructure/structure/base.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/array.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/lazy.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/object.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/record.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/type.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/union.d.ts +1 -1
- package/dist/either/index.cjs +30 -8
- package/dist/either/index.d.ts +4 -0
- package/dist/either/index.mjs +23 -9
- package/dist/either/left/index.d.ts +3 -2
- package/dist/either/left/none.cjs +15 -0
- package/dist/either/left/none.d.ts +7 -0
- package/dist/either/left/none.mjs +14 -0
- package/dist/either/matchInformationOtherwise.d.ts +1 -1
- package/dist/either/rewriteInformation.cjs +22 -0
- package/dist/either/rewriteInformation.d.ts +14 -0
- package/dist/either/rewriteInformation.mjs +22 -0
- package/dist/either/right/asyncGroup.cjs +2 -2
- package/dist/either/right/asyncGroup.mjs +2 -2
- package/dist/either/right/group.cjs +1 -1
- package/dist/either/right/group.mjs +1 -1
- package/dist/either/right/index.d.ts +6 -5
- package/dist/either/right/some.cjs +15 -0
- package/dist/either/right/some.d.ts +7 -0
- package/dist/either/right/some.mjs +14 -0
- package/dist/either/toMaybe.cjs +12 -0
- package/dist/either/toMaybe.d.ts +5 -0
- package/dist/either/toMaybe.mjs +12 -0
- package/dist/either/types/mayBe.d.ts +3 -0
- package/dist/either/unwrapOr.cjs +14 -0
- package/dist/either/unwrapOr.d.ts +8 -0
- package/dist/either/unwrapOr.mjs +14 -0
- package/dist/either/unwrapOtherwise.cjs +14 -0
- package/dist/either/unwrapOtherwise.d.ts +8 -0
- package/dist/either/unwrapOtherwise.mjs +14 -0
- package/dist/generator/reduce.cjs +2 -1
- package/dist/generator/reduce.mjs +1 -1
- package/dist/invocation/index.cjs +8 -8
- package/dist/invocation/index.d.ts +1 -1
- package/dist/invocation/index.mjs +6 -6
- package/dist/invocation/reader.cjs +26 -0
- package/dist/invocation/reader.d.ts +28 -0
- package/dist/invocation/reader.mjs +25 -0
- package/dist/modeling/entity/base.cjs +19 -2
- package/dist/modeling/entity/base.d.ts +9 -2
- package/dist/modeling/entity/base.mjs +19 -3
- package/dist/modeling/entity/namespace.cjs +1 -1
- package/dist/modeling/entity/namespace.d.ts +1 -1
- package/dist/modeling/entity/namespace.mjs +1 -1
- package/dist/modeling/flag/base.cjs +1 -5
- package/dist/modeling/flag/base.d.ts +6 -7
- package/dist/modeling/flag/base.mjs +1 -5
- package/dist/modeling/index.cjs +6 -0
- package/dist/modeling/index.mjs +7 -4
- package/dist/modeling/newType/base.cjs +21 -3
- package/dist/modeling/newType/base.d.ts +9 -2
- package/dist/modeling/newType/base.mjs +19 -3
- package/dist/modeling/taggedObject/base.cjs +19 -2
- package/dist/modeling/taggedObject/base.d.ts +9 -2
- package/dist/modeling/taggedObject/base.mjs +19 -3
- package/dist/object/types/forbiddenUndefinedProps.d.ts +3 -0
- package/dist/object/types/index.d.ts +2 -1
- package/dist/object/types/split.d.ts +2 -2
- package/dist/pattern/matchWithNumber.d.ts +4 -4
- package/dist/pattern/matchWithNumberOtherwise.d.ts +4 -4
- package/dist/pattern/matchWithString.d.ts +4 -4
- package/dist/pattern/matchWithStringOtherwise.d.ts +4 -4
- package/dist/string/constraints/allowedCharacters.d.ts +3 -3
- package/dist/string/isComposedOf.cjs +0 -1
- package/dist/string/isComposedOf.d.ts +5 -8
- package/dist/string/isComposedOf.mjs +0 -1
- package/dist/string/types/IsAllowedString.d.ts +3 -0
- package/dist/string/types/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/invocation/useCase.cjs +0 -26
- package/dist/invocation/useCase.d.ts +0 -28
- package/dist/invocation/useCase.mjs +0 -25
|
@@ -3,8 +3,8 @@ const require_theDate = require("./theDate.cjs");
|
|
|
3
3
|
const require_isDate = require("./isDate.cjs");
|
|
4
4
|
const require_create = require("../either/left/create.cjs");
|
|
5
5
|
const require_is = require("../either/left/is.cjs");
|
|
6
|
-
const require_when = require("../either/left/when.cjs");
|
|
7
6
|
const require_create$1 = require("../either/right/create.cjs");
|
|
7
|
+
const require_when = require("../either/left/when.cjs");
|
|
8
8
|
const require_unwrap = require("../either/right/unwrap.cjs");
|
|
9
9
|
const require_safeCallback = require("../either/safeCallback.cjs");
|
|
10
10
|
const require_isSafeTimestamp = require("./isSafeTimestamp.cjs");
|
|
@@ -3,8 +3,8 @@ import { TheDate } from "./theDate.mjs";
|
|
|
3
3
|
import { isDate } from "./isDate.mjs";
|
|
4
4
|
import { left } from "../either/left/create.mjs";
|
|
5
5
|
import { isLeft } from "../either/left/is.mjs";
|
|
6
|
-
import { whenIsLeft } from "../either/left/when.mjs";
|
|
7
6
|
import { right } from "../either/right/create.mjs";
|
|
7
|
+
import { whenIsLeft } from "../either/left/when.mjs";
|
|
8
8
|
import { unwrapRight } from "../either/right/unwrap.mjs";
|
|
9
9
|
import { safeCallback } from "../either/safeCallback.mjs";
|
|
10
10
|
import { isSafeTimestamp } from "./isSafeTimestamp.mjs";
|
|
@@ -3,7 +3,7 @@ import { UnbundlesConstraint, BaseConstraint, RemoveConstraint } from '../types'
|
|
|
3
3
|
import { CastError, RemoveCastError } from './error';
|
|
4
4
|
import { ComputeCastConstraintNumberRule } from './number';
|
|
5
5
|
import { ComputeCastConstraintStringRule } from './string';
|
|
6
|
-
import {
|
|
6
|
+
import { IsExtends, BreakGenericLink, NeverCoalescing, UnionContain, IsEqual } from '../../types';
|
|
7
7
|
import type * as DArray from '../../../array';
|
|
8
8
|
import type * as DTuple from '../../../tuple';
|
|
9
9
|
import type * as DObject from '../../../object';
|
|
@@ -17,7 +17,7 @@ export interface ComputeCastConstraintRule<GenericValue extends unknown, Generic
|
|
|
17
17
|
array: GenericValue extends readonly unknown[] ? DObject.Values<ComputeCastConstraintArrayRule<GenericValue, GenericConstraint>> : never;
|
|
18
18
|
}
|
|
19
19
|
export type ComputeCastConstraint<GenericValue extends unknown, GenericExpectedValue extends unknown> = (GenericExpectedValue extends any ? [UnbundlesConstraint<GenericExpectedValue>] : never) extends infer InferredComputedExpectedValue extends [BaseConstraint] ? DArray.Unwrap<NeverCoalescing<Extract<GenericValue extends any ? (InferredComputedExpectedValue extends [infer InferredConstraint extends BaseConstraint] ? NeverCoalescing<Extract<InferredConstraint extends any ? [
|
|
20
|
-
NeverCoalescing<DObject.Values<ComputeCastConstraintRule<GenericValue, InferredConstraint>>, CastError<"None of the intended constraints is possible on the current value.", GenericValue, InferredConstraint>>
|
|
20
|
+
GenericValue extends InferredConstraint ? unknown : NeverCoalescing<DObject.Values<ComputeCastConstraintRule<GenericValue, InferredConstraint>>, CastError<"None of the intended constraints is possible on the current value.", GenericValue, InferredConstraint>>
|
|
21
21
|
] : never, [
|
|
22
22
|
CastError<any, any, any>
|
|
23
23
|
]>, [
|
|
@@ -25,7 +25,7 @@ export type ComputeCastConstraint<GenericValue extends unknown, GenericExpectedV
|
|
|
25
25
|
]> : never) extends infer InferredResult ? UnionContain<InferredResult, [unknown]> extends true ? [unknown] : InferredResult : never : never, [
|
|
26
26
|
CastError<any, any, any>
|
|
27
27
|
]>, unknown>> : never;
|
|
28
|
-
type ComputeTransformCastValue<GenericValue extends unknown> = GenericValue extends
|
|
28
|
+
type ComputeTransformCastValue<GenericValue extends unknown> = GenericValue extends readonly unknown[] ? DArray.ExtractLengthEqual<GenericValue, unknown> extends DArray.LengthEqual<infer InferredLength> ? DTuple.Create<GenericValue[number], InferredLength> : DArray.ExtractMinElements<GenericValue, unknown> extends DArray.MinElements<infer InferredMin> ? readonly [...DTuple.Create<GenericValue[number], InferredMin>, ...GenericValue] : RemoveConstraint<GenericValue> : RemoveConstraint<GenericValue>;
|
|
29
29
|
export type ComputeCastValue<GenericValue extends unknown, GenericExpectedValue extends unknown> = [
|
|
30
30
|
ComputeTransformCastValue<GenericValue>,
|
|
31
31
|
ComputeTransformCastValue<GenericExpectedValue>
|
|
@@ -5,6 +5,7 @@ export interface ComputeInferConstraintStringRule<GenericInput extends string, G
|
|
|
5
5
|
maxCharacters: DString.ComputeMaxCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.MaxCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MaxCharacters<${InferredResult["to"]}> because constraint MaxCharacters<${InferredResult["from"]}> from the value is more than.`> : never;
|
|
6
6
|
minCharacters: DString.ComputeMinCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.MinCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MinCharacters<${InferredResult["to"]}> because constraint MinCharacters<${InferredResult["from"]}> from the value is less than.`> : never;
|
|
7
7
|
lengthEqual: DString.ComputeLengthEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.LengthEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`> : never;
|
|
8
|
+
allowedCharacters: GenericOutput extends DString.AllowedCharacters ? keyof ReturnType<GenericOutput[DCommon.ConstraintSymbol][DString.AllowedCharactersConstraintName]> extends infer InferredCharactersRange extends DString.CharactersRange ? DString.IsAllowedString<GenericInput, DString.CharactersRangeStore[InferredCharactersRange]> extends true ? DString.AllowedCharacters<InferredCharactersRange> : DCommon.ComputedTypeError<`Impossible to cast on AllowedCharacters because value ${GenericInput} contains forbidden characters.`> : never : never;
|
|
8
9
|
number: DCommon.IsExtends<GenericOutput, DString.Number> extends true ? GenericInput extends DString.NumberInString ? DString.Number : DCommon.ComputedTypeError<`Impossible to cast on Number because value ${GenericInput} is not a number.`> : never;
|
|
9
10
|
path: DCommon.IsExtends<GenericOutput, DPath.Path> extends true ? DPath.IsLiteralPath<GenericInput> extends true ? DPath.Path : DCommon.ComputedTypeError<`Impossible to cast on Path because value ${GenericInput} is not path.`> : never;
|
|
10
11
|
absolutePath: DCommon.IsExtends<GenericOutput, DPath.Absolute> extends true ? DPath.IsLiteralAbsolutePath<GenericInput> extends true ? DPath.Absolute : DCommon.ComputedTypeError<`Impossible to cast on AbsolutePath because value ${GenericInput} is not absolute path.`> : never;
|
|
@@ -26,6 +26,7 @@ export type * from './forward';
|
|
|
26
26
|
export type * from './hasSomething';
|
|
27
27
|
export type * from './isEqual';
|
|
28
28
|
export type * from './isNever';
|
|
29
|
+
export type * from './isObject';
|
|
29
30
|
export type * from './isUnion';
|
|
30
31
|
export type * from './json';
|
|
31
32
|
export type * from './lastUnionElement';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { And } from './and';
|
|
2
|
+
import { IsExtends } from './IsExtends';
|
|
3
|
+
import { IsNever } from './isNever';
|
|
4
|
+
import { Not } from './not';
|
|
5
|
+
export type IsObject<GenericValue extends unknown> = And<[
|
|
6
|
+
IsExtends<GenericValue, object>,
|
|
7
|
+
Not<IsNever<keyof GenericValue>>
|
|
8
|
+
]>;
|
|
@@ -9,8 +9,8 @@ function createCodec(fundamentalType, predicateEncode, encode, decode) {
|
|
|
9
9
|
const self = {
|
|
10
10
|
fundamentalType,
|
|
11
11
|
predicateEncode: (data) => predicateEncode(data),
|
|
12
|
-
encode: (data, errorHandler) => require_callThen.callThen(encode(data, self, errorHandler), (encodedData) => encodedData === require_resultSymbol.ErrorSymbol ? require_resultSymbol.ErrorSymbol : require_callThen.callThen(predicateEncode(encodedData), (result) => result === false ? errorHandler?.().addEncodeIssue(self, encodedData) ?? require_resultSymbol.ErrorSymbol : encodedData)),
|
|
13
|
-
decode: (data, errorHandler) => require_callThen.callThen(predicateEncode(data), (result) => result === false ? errorHandler?.().addDecodeIssue(self, data) ?? require_resultSymbol.ErrorSymbol : decode(data, self, errorHandler)),
|
|
12
|
+
encode: (data, errorHandler) => require_callThen.callThen(encode(data, self, errorHandler), (encodedData) => encodedData === require_resultSymbol.ErrorSymbol ? errorHandler?.().addEncodeIssue(self, "encoding", data) ?? require_resultSymbol.ErrorSymbol : require_callThen.callThen(predicateEncode(encodedData), (result) => result === false ? errorHandler?.().addEncodeIssue(self, "predicate", encodedData) ?? require_resultSymbol.ErrorSymbol : encodedData)),
|
|
13
|
+
decode: (data, errorHandler) => require_callThen.callThen(predicateEncode(data), (result) => result === false ? errorHandler?.().addDecodeIssue(self, "predicate", data) ?? require_resultSymbol.ErrorSymbol : require_callThen.callThen(decode(data, self, errorHandler), (decodedData) => decodedData === require_resultSymbol.ErrorSymbol ? errorHandler?.().addDecodeIssue(self, "decoding", data) ?? require_resultSymbol.ErrorSymbol : decodedData)),
|
|
14
14
|
[codecKind.runTimeKey]: null
|
|
15
15
|
};
|
|
16
16
|
return self;
|
|
@@ -9,8 +9,8 @@ function createCodec(fundamentalType, predicateEncode, encode, decode) {
|
|
|
9
9
|
const self = {
|
|
10
10
|
fundamentalType,
|
|
11
11
|
predicateEncode: (data) => predicateEncode(data),
|
|
12
|
-
encode: (data, errorHandler) => callThen(encode(data, self, errorHandler), (encodedData) => encodedData === ErrorSymbol ? ErrorSymbol : callThen(predicateEncode(encodedData), (result) => result === false ? errorHandler?.().addEncodeIssue(self, encodedData) ?? ErrorSymbol : encodedData)),
|
|
13
|
-
decode: (data, errorHandler) => callThen(predicateEncode(data), (result) => result === false ? errorHandler?.().addDecodeIssue(self, data) ?? ErrorSymbol : decode(data, self, errorHandler)),
|
|
12
|
+
encode: (data, errorHandler) => callThen(encode(data, self, errorHandler), (encodedData) => encodedData === ErrorSymbol ? errorHandler?.().addEncodeIssue(self, "encoding", data) ?? ErrorSymbol : callThen(predicateEncode(encodedData), (result) => result === false ? errorHandler?.().addEncodeIssue(self, "predicate", encodedData) ?? ErrorSymbol : encodedData)),
|
|
13
|
+
decode: (data, errorHandler) => callThen(predicateEncode(data), (result) => result === false ? errorHandler?.().addDecodeIssue(self, "predicate", data) ?? ErrorSymbol : callThen(decode(data, self, errorHandler), (decodedData) => decodedData === ErrorSymbol ? errorHandler?.().addDecodeIssue(self, "decoding", data) ?? ErrorSymbol : decodedData)),
|
|
14
14
|
[codecKind.runTimeKey]: null
|
|
15
15
|
};
|
|
16
16
|
return self;
|
|
@@ -34,8 +34,9 @@ function createErrorHandler(defaultPath) {
|
|
|
34
34
|
[issueKind.runTimeKey]: null
|
|
35
35
|
});
|
|
36
36
|
},
|
|
37
|
-
addEncodeIssue: (source, data, message) => {
|
|
37
|
+
addEncodeIssue: (source, from, data, message) => {
|
|
38
38
|
issues.push({
|
|
39
|
+
from,
|
|
39
40
|
data,
|
|
40
41
|
path: currentPath.join("."),
|
|
41
42
|
message,
|
|
@@ -43,8 +44,9 @@ function createErrorHandler(defaultPath) {
|
|
|
43
44
|
[encodeIssueKind.runTimeKey]: null
|
|
44
45
|
});
|
|
45
46
|
},
|
|
46
|
-
addDecodeIssue: (source, data, message) => {
|
|
47
|
+
addDecodeIssue: (source, from, data, message) => {
|
|
47
48
|
issues.push({
|
|
49
|
+
from,
|
|
48
50
|
data,
|
|
49
51
|
path: currentPath.join("."),
|
|
50
52
|
message,
|
|
@@ -13,6 +13,7 @@ export interface Issue extends DKind.Kind<typeof issueKind> {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const encodeIssueKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/encode-issue", unknown>>;
|
|
15
15
|
export interface EncodeIssue extends DKind.Kind<typeof encodeIssueKind> {
|
|
16
|
+
readonly from: "encoding" | "predicate" | "external";
|
|
16
17
|
readonly path: string;
|
|
17
18
|
readonly data: unknown;
|
|
18
19
|
readonly message?: string;
|
|
@@ -20,6 +21,7 @@ export interface EncodeIssue extends DKind.Kind<typeof encodeIssueKind> {
|
|
|
20
21
|
}
|
|
21
22
|
export declare const decodeIssueKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/decode-issue", unknown>>;
|
|
22
23
|
export interface DecodeIssue extends DKind.Kind<typeof decodeIssueKind> {
|
|
24
|
+
readonly from: "decoding" | "predicate" | "external";
|
|
23
25
|
readonly path: string;
|
|
24
26
|
readonly data: unknown;
|
|
25
27
|
readonly message?: string;
|
|
@@ -37,8 +39,8 @@ export interface ErrorHandler {
|
|
|
37
39
|
readonly issues: readonly Issues[];
|
|
38
40
|
readonly currentPath: string[];
|
|
39
41
|
addIssue(source: ReturnType<Issue["getSource"]>, data: unknown, subSource?: ReturnType<Extract<Issue["getSubSource"], DCommon.AnyFunction>>): void;
|
|
40
|
-
addEncodeIssue(source: ReturnType<EncodeIssue["getSource"]>, data: unknown, message?: string): void;
|
|
41
|
-
addDecodeIssue(source: ReturnType<DecodeIssue["getSource"]>, data: unknown, message?: string): void;
|
|
42
|
+
addEncodeIssue(source: ReturnType<EncodeIssue["getSource"]>, from: EncodeIssue["from"], data: unknown, message?: string): void;
|
|
43
|
+
addDecodeIssue(source: ReturnType<DecodeIssue["getSource"]>, from: DecodeIssue["from"], data: unknown, message?: string): void;
|
|
42
44
|
importIssues(errorHandler: (GetErrorHandler | ErrorHandler)[]): void;
|
|
43
45
|
createPathStage(): PathStageErrorHandler;
|
|
44
46
|
createError(): Error;
|
|
@@ -34,8 +34,9 @@ function createErrorHandler(defaultPath) {
|
|
|
34
34
|
[issueKind.runTimeKey]: null
|
|
35
35
|
});
|
|
36
36
|
},
|
|
37
|
-
addEncodeIssue: (source, data, message) => {
|
|
37
|
+
addEncodeIssue: (source, from, data, message) => {
|
|
38
38
|
issues.push({
|
|
39
|
+
from,
|
|
39
40
|
data,
|
|
40
41
|
path: currentPath.join("."),
|
|
41
42
|
message,
|
|
@@ -43,8 +44,9 @@ function createErrorHandler(defaultPath) {
|
|
|
43
44
|
[encodeIssueKind.runTimeKey]: null
|
|
44
45
|
});
|
|
45
46
|
},
|
|
46
|
-
addDecodeIssue: (source, data, message) => {
|
|
47
|
+
addDecodeIssue: (source, from, data, message) => {
|
|
47
48
|
issues.push({
|
|
49
|
+
from,
|
|
48
50
|
data,
|
|
49
51
|
path: currentPath.join("."),
|
|
50
52
|
message,
|
|
@@ -9,8 +9,8 @@ const require_error = require("./error.cjs");
|
|
|
9
9
|
const kindNamespaceName = "DuplojsLangDataStructure";
|
|
10
10
|
function createErrorInterpreter(structureDictionary = {}, codecDictionary = []) {
|
|
11
11
|
const formattedStructureDictionary = require_pipe.pipe(structureDictionary, require_entries.entries, require_map.map(([key, value]) => require_entry.entry(`${require_base.keyKindPrefix}@${kindNamespaceName}/${key}`, value)));
|
|
12
|
-
const getInterpretedMessageStructure = (structure) => require_reduce.reduce(formattedStructureDictionary, require_reduce.reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure)) : next(void 0));
|
|
13
|
-
const getInterpretedMessageCodec = (codec) => require_reduce.reduce(codecDictionary, require_reduce.reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message) : next(void 0));
|
|
12
|
+
const getInterpretedMessageStructure = (structure, issue) => require_reduce.reduce(formattedStructureDictionary, require_reduce.reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure, issue)) : next(void 0));
|
|
13
|
+
const getInterpretedMessageCodec = (codec, issue) => require_reduce.reduce(codecDictionary, require_reduce.reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message(codec, issue)) : next(void 0));
|
|
14
14
|
return (error) => require_map.map(error.issues, (issue) => {
|
|
15
15
|
if (require_error.issueKind.has(issue)) {
|
|
16
16
|
const source = issue.getSource();
|
|
@@ -20,8 +20,8 @@ function createErrorInterpreter(structureDictionary = {}, codecDictionary = [])
|
|
|
20
20
|
interpretedMessage: {
|
|
21
21
|
source: source.definition.message,
|
|
22
22
|
subSource: subSource?.definition.message,
|
|
23
|
-
interpretedSource: getInterpretedMessageStructure(source),
|
|
24
|
-
interpretedSubSource: subSource && getInterpretedMessageStructure(subSource)
|
|
23
|
+
interpretedSource: getInterpretedMessageStructure(source, issue),
|
|
24
|
+
interpretedSubSource: subSource && getInterpretedMessageStructure(subSource, issue)
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
@@ -29,14 +29,14 @@ function createErrorInterpreter(structureDictionary = {}, codecDictionary = [])
|
|
|
29
29
|
...issue,
|
|
30
30
|
interpretedMessage: {
|
|
31
31
|
source: issue.message,
|
|
32
|
-
interpretedSource: getInterpretedMessageCodec(issue.getSource())
|
|
32
|
+
interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
return {
|
|
36
36
|
...issue,
|
|
37
37
|
interpretedMessage: {
|
|
38
38
|
source: issue.message,
|
|
39
|
-
interpretedSource: getInterpretedMessageCodec(issue.getSource())
|
|
39
|
+
interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
});
|
|
@@ -24,9 +24,13 @@ export interface InterpretedDecodedIssue extends DecodeIssue {
|
|
|
24
24
|
interpretedMessage: InterpretedMessage;
|
|
25
25
|
}
|
|
26
26
|
export type InterpretedIssues = (InterpretedIssue | InterpretedEncodedIssue | InterpretedDecodedIssue);
|
|
27
|
-
type
|
|
28
|
-
[DataStructure in (Types | Structures | Constraints) as RemoveNamespace<DKind.GetName<DataStructure>>]?: (structure: DataStructure) => string;
|
|
27
|
+
type StructureDictionaryParams = DCommon.SimplifyTopLevel<Omit<{
|
|
28
|
+
[DataStructure in (Types | Structures | Constraints) as RemoveNamespace<DKind.GetName<DataStructure>>]?: (structure: DataStructure, issue: Issue) => string;
|
|
29
29
|
}, RemoveNamespace<DKind.GetName<Type>> | RemoveNamespace<DKind.GetName<Structure>> | RemoveNamespace<DKind.GetName<Constraint>>>>;
|
|
30
|
-
|
|
30
|
+
type CodecDictionaryParams = [
|
|
31
|
+
Codec,
|
|
32
|
+
(codec: Codec, issue: EncodeIssue | DecodeIssue) => string
|
|
33
|
+
][];
|
|
34
|
+
export declare function createErrorInterpreter(structureDictionary?: StructureDictionaryParams, codecDictionary?: CodecDictionaryParams): (error: Error) => readonly InterpretedIssues[];
|
|
31
35
|
export type ErrorInterpreter = ReturnType<typeof createErrorInterpreter>;
|
|
32
36
|
export {};
|
|
@@ -9,8 +9,8 @@ import { encodeIssueKind, issueKind } from "./error.mjs";
|
|
|
9
9
|
const kindNamespaceName = "DuplojsLangDataStructure";
|
|
10
10
|
function createErrorInterpreter(structureDictionary = {}, codecDictionary = []) {
|
|
11
11
|
const formattedStructureDictionary = pipe(structureDictionary, entries, map(([key, value]) => entry(`${keyKindPrefix}@${kindNamespaceName}/${key}`, value)));
|
|
12
|
-
const getInterpretedMessageStructure = (structure) => reduce(formattedStructureDictionary, reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure)) : next(void 0));
|
|
13
|
-
const getInterpretedMessageCodec = (codec) => reduce(codecDictionary, reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message) : next(void 0));
|
|
12
|
+
const getInterpretedMessageStructure = (structure, issue) => reduce(formattedStructureDictionary, reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure, issue)) : next(void 0));
|
|
13
|
+
const getInterpretedMessageCodec = (codec, issue) => reduce(codecDictionary, reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message(codec, issue)) : next(void 0));
|
|
14
14
|
return (error) => map(error.issues, (issue) => {
|
|
15
15
|
if (issueKind.has(issue)) {
|
|
16
16
|
const source = issue.getSource();
|
|
@@ -20,8 +20,8 @@ function createErrorInterpreter(structureDictionary = {}, codecDictionary = [])
|
|
|
20
20
|
interpretedMessage: {
|
|
21
21
|
source: source.definition.message,
|
|
22
22
|
subSource: subSource?.definition.message,
|
|
23
|
-
interpretedSource: getInterpretedMessageStructure(source),
|
|
24
|
-
interpretedSubSource: subSource && getInterpretedMessageStructure(subSource)
|
|
23
|
+
interpretedSource: getInterpretedMessageStructure(source, issue),
|
|
24
|
+
interpretedSubSource: subSource && getInterpretedMessageStructure(subSource, issue)
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
@@ -29,14 +29,14 @@ function createErrorInterpreter(structureDictionary = {}, codecDictionary = [])
|
|
|
29
29
|
...issue,
|
|
30
30
|
interpretedMessage: {
|
|
31
31
|
source: issue.message,
|
|
32
|
-
interpretedSource: getInterpretedMessageCodec(issue.getSource())
|
|
32
|
+
interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
return {
|
|
36
36
|
...issue,
|
|
37
37
|
interpretedMessage: {
|
|
38
38
|
source: issue.message,
|
|
39
|
-
interpretedSource: getInterpretedMessageCodec(issue.getSource())
|
|
39
|
+
interpretedSource: getInterpretedMessageCodec(issue.getSource(), issue)
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
});
|
|
@@ -3,11 +3,9 @@ import type * as DCommon from '../../../common';
|
|
|
3
3
|
import type * as DKind from '../../../kind';
|
|
4
4
|
import * as DString from '../../../string';
|
|
5
5
|
export declare const allowedCharactersConstraintKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/allowed-characters-constraint", unknown>>;
|
|
6
|
-
type AllowedCharactersConstraintValue<GenericCharactersRange extends DString.CharactersRange> = string & DCommon.UnionToIntersection<GenericCharactersRange extends any ? DString.AllowedCharacters<GenericCharactersRange> : never>;
|
|
7
6
|
export interface AllowedCharactersConstraintDefinition<GenericCharactersRange extends DString.CharactersRange = DString.CharactersRange> extends ConstraintDefinition {
|
|
8
7
|
readonly charactersRange: DCommon.MaybeArray<GenericCharactersRange>;
|
|
9
8
|
}
|
|
10
|
-
export interface AllowedCharactersConstraint<GenericCharactersRange extends DString.CharactersRange = DString.CharactersRange> extends DCommon.Forward<Constraint<string,
|
|
9
|
+
export interface AllowedCharactersConstraint<GenericCharactersRange extends DString.CharactersRange = DString.CharactersRange> extends DCommon.Forward<Constraint<string, string & DString.AllowedCharacters<GenericCharactersRange>, AllowedCharactersConstraintDefinition<GenericCharactersRange>> & DKind.Kind<typeof allowedCharactersConstraintKind>> {
|
|
11
10
|
}
|
|
12
11
|
export declare const AllowedCharactersConstraint: <GenericCharactersRange extends DString.CharactersRange>(charactersRange: DCommon.MaybeArray<GenericCharactersRange>) => AllowedCharactersConstraint<GenericCharactersRange>;
|
|
13
|
-
export {};
|
|
@@ -14,6 +14,8 @@ export * from './greaterThan';
|
|
|
14
14
|
export * from './greaterThanOrEqual';
|
|
15
15
|
export * from './integer';
|
|
16
16
|
export * from './isNullStructure';
|
|
17
|
+
export * from './isNullable';
|
|
18
|
+
export * from './isOptional';
|
|
17
19
|
export * from './isUndefinedStructure';
|
|
18
20
|
export * from './lazy';
|
|
19
21
|
export * from './lessThan';
|
|
@@ -39,17 +41,18 @@ export * from './path';
|
|
|
39
41
|
export * from './positive';
|
|
40
42
|
export * from './record';
|
|
41
43
|
export * from './refine';
|
|
44
|
+
export * from './regex';
|
|
42
45
|
export * from './required';
|
|
43
46
|
export * from './safe';
|
|
44
47
|
export * from './segmentPath';
|
|
45
|
-
export * from './string';
|
|
46
48
|
export * from './strictNegative';
|
|
47
49
|
export * from './strictPositive';
|
|
50
|
+
export * from './string';
|
|
48
51
|
export * from './stringLengthEqual';
|
|
49
52
|
export * from './time';
|
|
50
53
|
export * from './trimmed';
|
|
51
54
|
export * from './undefined';
|
|
52
55
|
export * from './union';
|
|
56
|
+
export * from './unwrapLazy';
|
|
53
57
|
export * from './url';
|
|
54
58
|
export * from './uuid';
|
|
55
|
-
export * from './regex';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_identifier = require("../structure/identifier.cjs");
|
|
2
|
+
const require_lazy = require("../structure/defaults/lazy.cjs");
|
|
3
|
+
const require_union = require("../structure/defaults/union.cjs");
|
|
4
|
+
const require_isNullStructure = require("./isNullStructure.cjs");
|
|
5
|
+
//#region scripts/dataStructure/helpers/isNullable.ts
|
|
6
|
+
function isNullable(structure) {
|
|
7
|
+
if (require_identifier.structureIdentifier(structure, require_lazy.lazyStructureKind)) return isNullable(structure.definition.getter.value);
|
|
8
|
+
if (!require_identifier.structureIdentifier(structure, require_union.unionStructureKind)) return require_isNullStructure.isNullStructure(structure);
|
|
9
|
+
return structure.definition.values.value.some(require_isNullStructure.isNullStructure);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.isNullable = isNullable;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { structureIdentifier } from "../structure/identifier.mjs";
|
|
2
|
+
import { lazyStructureKind } from "../structure/defaults/lazy.mjs";
|
|
3
|
+
import { unionStructureKind } from "../structure/defaults/union.mjs";
|
|
4
|
+
import { isNullStructure } from "./isNullStructure.mjs";
|
|
5
|
+
//#region scripts/dataStructure/helpers/isNullable.ts
|
|
6
|
+
function isNullable(structure) {
|
|
7
|
+
if (structureIdentifier(structure, lazyStructureKind)) return isNullable(structure.definition.getter.value);
|
|
8
|
+
if (!structureIdentifier(structure, unionStructureKind)) return isNullStructure(structure);
|
|
9
|
+
return structure.definition.values.value.some(isNullStructure);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isNullable };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_identifier = require("../structure/identifier.cjs");
|
|
2
|
+
const require_lazy = require("../structure/defaults/lazy.cjs");
|
|
3
|
+
const require_union = require("../structure/defaults/union.cjs");
|
|
4
|
+
const require_isUndefinedStructure = require("./isUndefinedStructure.cjs");
|
|
5
|
+
//#region scripts/dataStructure/helpers/isOptional.ts
|
|
6
|
+
function isOptional(structure) {
|
|
7
|
+
if (require_identifier.structureIdentifier(structure, require_lazy.lazyStructureKind)) return isOptional(structure.definition.getter.value);
|
|
8
|
+
if (!require_identifier.structureIdentifier(structure, require_union.unionStructureKind)) return require_isUndefinedStructure.isUndefinedStructure(structure);
|
|
9
|
+
return structure.definition.values.value.some(require_isUndefinedStructure.isUndefinedStructure);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.isOptional = isOptional;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { structureIdentifier } from "../structure/identifier.mjs";
|
|
2
|
+
import { lazyStructureKind } from "../structure/defaults/lazy.mjs";
|
|
3
|
+
import { unionStructureKind } from "../structure/defaults/union.mjs";
|
|
4
|
+
import { isUndefinedStructure } from "./isUndefinedStructure.mjs";
|
|
5
|
+
//#region scripts/dataStructure/helpers/isOptional.ts
|
|
6
|
+
function isOptional(structure) {
|
|
7
|
+
if (structureIdentifier(structure, lazyStructureKind)) return isOptional(structure.definition.getter.value);
|
|
8
|
+
if (!structureIdentifier(structure, unionStructureKind)) return isUndefinedStructure(structure);
|
|
9
|
+
return structure.definition.values.value.some(isUndefinedStructure);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isOptional };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_identifier = require("../structure/identifier.cjs");
|
|
2
|
+
const require_lazy = require("../structure/defaults/lazy.cjs");
|
|
3
|
+
//#region scripts/dataStructure/helpers/unwrapLazy.ts
|
|
4
|
+
function unwrapLazy(structure) {
|
|
5
|
+
if (require_identifier.structureIdentifier(structure, require_lazy.lazyStructureKind)) return structure.definition.getter.value;
|
|
6
|
+
return structure;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.unwrapLazy = unwrapLazy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { structureIdentifier } from "../structure/identifier.mjs";
|
|
2
|
+
import { lazyStructureKind } from "../structure/defaults/lazy.mjs";
|
|
3
|
+
//#region scripts/dataStructure/helpers/unwrapLazy.ts
|
|
4
|
+
function unwrapLazy(structure) {
|
|
5
|
+
if (structureIdentifier(structure, lazyStructureKind)) return structure.definition.getter.value;
|
|
6
|
+
return structure;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { unwrapLazy };
|
|
@@ -91,7 +91,9 @@ const require_greaterThan$1 = require("./helpers/greaterThan.cjs");
|
|
|
91
91
|
const require_greaterThanOrEqual$1 = require("./helpers/greaterThanOrEqual.cjs");
|
|
92
92
|
const require_integer$1 = require("./helpers/integer.cjs");
|
|
93
93
|
const require_isNullStructure = require("./helpers/isNullStructure.cjs");
|
|
94
|
+
const require_isNullable = require("./helpers/isNullable.cjs");
|
|
94
95
|
const require_isUndefinedStructure = require("./helpers/isUndefinedStructure.cjs");
|
|
96
|
+
const require_isOptional = require("./helpers/isOptional.cjs");
|
|
95
97
|
const require_lazy$1 = require("./helpers/lazy.cjs");
|
|
96
98
|
const require_lessThan$1 = require("./helpers/lessThan.cjs");
|
|
97
99
|
const require_lessThanOrEqual$1 = require("./helpers/lessThanOrEqual.cjs");
|
|
@@ -118,18 +120,19 @@ const require_path$1 = require("./helpers/path.cjs");
|
|
|
118
120
|
const require_positive$1 = require("./helpers/positive.cjs");
|
|
119
121
|
const require_record$1 = require("./helpers/record.cjs");
|
|
120
122
|
const require_refine$1 = require("./helpers/refine.cjs");
|
|
123
|
+
const require_regex$1 = require("./helpers/regex.cjs");
|
|
121
124
|
const require_required = require("./helpers/required.cjs");
|
|
122
125
|
const require_safe$1 = require("./helpers/safe.cjs");
|
|
123
126
|
const require_segmentPath$1 = require("./helpers/segmentPath.cjs");
|
|
124
|
-
const require_string$3 = require("./helpers/string.cjs");
|
|
125
127
|
const require_strictNegative$1 = require("./helpers/strictNegative.cjs");
|
|
126
128
|
const require_strictPositive$1 = require("./helpers/strictPositive.cjs");
|
|
129
|
+
const require_string$3 = require("./helpers/string.cjs");
|
|
127
130
|
const require_stringLengthEqual$1 = require("./helpers/stringLengthEqual.cjs");
|
|
128
131
|
const require_time$2 = require("./helpers/time.cjs");
|
|
129
132
|
const require_trimmed$1 = require("./helpers/trimmed.cjs");
|
|
133
|
+
const require_unwrapLazy = require("./helpers/unwrapLazy.cjs");
|
|
130
134
|
const require_url$1 = require("./helpers/url.cjs");
|
|
131
135
|
const require_uuid$1 = require("./helpers/uuid.cjs");
|
|
132
|
-
const require_regex$1 = require("./helpers/regex.cjs");
|
|
133
136
|
//#region scripts/dataStructure/index.ts
|
|
134
137
|
var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
135
138
|
AbsolutePathConstraint: () => require_absolutePath.AbsolutePathConstraint,
|
|
@@ -252,6 +255,8 @@ var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
252
255
|
integer: () => require_integer$1.integer,
|
|
253
256
|
integerConstraintKind: () => require_integer.integerConstraintKind,
|
|
254
257
|
isNullStructure: () => require_isNullStructure.isNullStructure,
|
|
258
|
+
isNullable: () => require_isNullable.isNullable,
|
|
259
|
+
isOptional: () => require_isOptional.isOptional,
|
|
255
260
|
isUndefinedStructure: () => require_isUndefinedStructure.isUndefinedStructure,
|
|
256
261
|
issueKind: () => require_error.issueKind,
|
|
257
262
|
lazy: () => require_lazy$1.lazy,
|
|
@@ -334,6 +339,7 @@ var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
334
339
|
undefinedTypeKind: () => require_undefined$1.undefinedTypeKind,
|
|
335
340
|
union: () => require_union$1.union,
|
|
336
341
|
unionStructureKind: () => require_union.unionStructureKind,
|
|
342
|
+
unwrapLazy: () => require_unwrapLazy.unwrapLazy,
|
|
337
343
|
url: () => require_url$1.url,
|
|
338
344
|
urlConstraintKind: () => require_url.urlConstraintKind,
|
|
339
345
|
uuid: () => require_uuid$1.uuid,
|
|
@@ -466,6 +472,8 @@ exports.greaterThanOrEqualConstraintKind = require_greaterThanOrEqual.greaterTha
|
|
|
466
472
|
exports.integer = require_integer$1.integer;
|
|
467
473
|
exports.integerConstraintKind = require_integer.integerConstraintKind;
|
|
468
474
|
exports.isNullStructure = require_isNullStructure.isNullStructure;
|
|
475
|
+
exports.isNullable = require_isNullable.isNullable;
|
|
476
|
+
exports.isOptional = require_isOptional.isOptional;
|
|
469
477
|
exports.isUndefinedStructure = require_isUndefinedStructure.isUndefinedStructure;
|
|
470
478
|
exports.issueKind = require_error.issueKind;
|
|
471
479
|
exports.lazy = require_lazy$1.lazy;
|
|
@@ -548,6 +556,7 @@ exports.undefinedFundamentalTypeKind = require_undefined.undefinedFundamentalTyp
|
|
|
548
556
|
exports.undefinedTypeKind = require_undefined$1.undefinedTypeKind;
|
|
549
557
|
exports.union = require_union$1.union;
|
|
550
558
|
exports.unionStructureKind = require_union.unionStructureKind;
|
|
559
|
+
exports.unwrapLazy = require_unwrapLazy.unwrapLazy;
|
|
551
560
|
exports.url = require_url$1.url;
|
|
552
561
|
exports.urlConstraintKind = require_url.urlConstraintKind;
|
|
553
562
|
exports.uuid = require_uuid$1.uuid;
|
|
@@ -91,7 +91,9 @@ import { greaterThan } from "./helpers/greaterThan.mjs";
|
|
|
91
91
|
import { greaterThanOrEqual } from "./helpers/greaterThanOrEqual.mjs";
|
|
92
92
|
import { integer } from "./helpers/integer.mjs";
|
|
93
93
|
import { isNullStructure } from "./helpers/isNullStructure.mjs";
|
|
94
|
+
import { isNullable } from "./helpers/isNullable.mjs";
|
|
94
95
|
import { isUndefinedStructure } from "./helpers/isUndefinedStructure.mjs";
|
|
96
|
+
import { isOptional } from "./helpers/isOptional.mjs";
|
|
95
97
|
import { lazy } from "./helpers/lazy.mjs";
|
|
96
98
|
import { lessThan } from "./helpers/lessThan.mjs";
|
|
97
99
|
import { lessThanOrEqual } from "./helpers/lessThanOrEqual.mjs";
|
|
@@ -118,18 +120,19 @@ import { path } from "./helpers/path.mjs";
|
|
|
118
120
|
import { positive } from "./helpers/positive.mjs";
|
|
119
121
|
import { record } from "./helpers/record.mjs";
|
|
120
122
|
import { refine } from "./helpers/refine.mjs";
|
|
123
|
+
import { regex } from "./helpers/regex.mjs";
|
|
121
124
|
import { required } from "./helpers/required.mjs";
|
|
122
125
|
import { safe } from "./helpers/safe.mjs";
|
|
123
126
|
import { segmentPath } from "./helpers/segmentPath.mjs";
|
|
124
|
-
import { string } from "./helpers/string.mjs";
|
|
125
127
|
import { strictNegative } from "./helpers/strictNegative.mjs";
|
|
126
128
|
import { strictPositive } from "./helpers/strictPositive.mjs";
|
|
129
|
+
import { string } from "./helpers/string.mjs";
|
|
127
130
|
import { stringLengthEqual } from "./helpers/stringLengthEqual.mjs";
|
|
128
131
|
import { time } from "./helpers/time.mjs";
|
|
129
132
|
import { trimmed } from "./helpers/trimmed.mjs";
|
|
133
|
+
import { unwrapLazy } from "./helpers/unwrapLazy.mjs";
|
|
130
134
|
import { url } from "./helpers/url.mjs";
|
|
131
135
|
import { uuid } from "./helpers/uuid.mjs";
|
|
132
|
-
import { regex } from "./helpers/regex.mjs";
|
|
133
136
|
//#region scripts/dataStructure/index.ts
|
|
134
137
|
var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
135
138
|
AbsolutePathConstraint: () => AbsolutePathConstraint,
|
|
@@ -252,6 +255,8 @@ var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
|
252
255
|
integer: () => integer,
|
|
253
256
|
integerConstraintKind: () => integerConstraintKind,
|
|
254
257
|
isNullStructure: () => isNullStructure,
|
|
258
|
+
isNullable: () => isNullable,
|
|
259
|
+
isOptional: () => isOptional,
|
|
255
260
|
isUndefinedStructure: () => isUndefinedStructure,
|
|
256
261
|
issueKind: () => issueKind,
|
|
257
262
|
lazy: () => lazy,
|
|
@@ -334,10 +339,11 @@ var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
|
334
339
|
undefinedTypeKind: () => undefinedTypeKind,
|
|
335
340
|
union: () => union,
|
|
336
341
|
unionStructureKind: () => unionStructureKind,
|
|
342
|
+
unwrapLazy: () => unwrapLazy,
|
|
337
343
|
url: () => url,
|
|
338
344
|
urlConstraintKind: () => urlConstraintKind,
|
|
339
345
|
uuid: () => uuid,
|
|
340
346
|
uuidConstraintKind: () => uuidConstraintKind
|
|
341
347
|
});
|
|
342
348
|
//#endregion
|
|
343
|
-
export { AbsolutePathConstraint, AllowedCharactersConstraint, ArrayLengthEqualConstraint, ArrayStructure, BetweenThanConstraint, BetweenThanOrEqualConstraint, BigintLiteralType, BigintType, BooleanLiteralType, BooleanType, ConstraintBase, DateType, EmailConstraint, ErrorSymbol, EvenConstraint, GreaterThanConstraint, GreaterThanOrEqualConstraint, IntegerConstraint, LazyStructure, LessThanConstraint, LessThanOrEqualConstraint, MaxCharactersConstraint, MaxElementsConstraint, MinCharactersConstraint, MinElementsConstraint, MultipleOfConstraint, NegativeConstraint, NonEncodableStringStructure, NotEmptyConstraint, NotZeroConstraint, NullType, NumberInStringConstraint, NumberLiteralType, NumberType, ObjectStructure, OddConstraint, PathConstraint, PositiveConstraint, RecordStructure, RefineConstraint, RegexConstraint, SafeConstraint, SegmentPathConstraint, StrictNegativeConstraint, StrictPositiveConstraint, StringLengthEqualConstraint, StringLiteralType, StringType, StructureClass, SuccessSymbol, TheBigint, TheBoolean, TheDate, TheNull, TheNumber, TheString, TheTime, TheUndefined, TimeType, TrimmedConstraint, TypeStructure, UndefinedType, UnionStructure, UrlConstraint, UuidConstraint, absolutePath, absolutePathConstraintKind, allowedCharacters, allowedCharactersConstraintKind, array, arrayLengthEqual, arrayLengthEqualConstraintKind, arrayStructureKind, betweenThan, betweenThanConstraintKind, betweenThanOrEqual, betweenThanOrEqualConstraintKind, bigint, bigintFundamentalTypeKind, bigintLiteralTypeKind, bigintTypeKind, boolean, booleanFundamentalTypeKind, booleanLiteralTypeKind, booleanTypeKind, codecKind, codecsJson, codecsKind, codecsString, constraintIdentifier, constraintKind, createCodec, createCodecs, createConstraint, createErrorHandler, createErrorInterpreter, createFundamentalType, createGetErrorHandler, createKind, createStructure, createType, dataStructure_exports, date, dateFundamentalTypeKind, dateTypeKind, decodeIssueKind, email, emailConstraintKind, encodeIssueKind, even, evenConstraintKind, extend, fundamentalTypeIdentifier, fundamentalTypeKind, greaterThan, greaterThanConstraintKind, greaterThanOrEqual, greaterThanOrEqualConstraintKind, integer, integerConstraintKind, isNullStructure, isUndefinedStructure, issueKind, lazy, lazyStructureKind, lessThan, lessThanConstraintKind, lessThanOrEqual, lessThanOrEqualConstraintKind, literal, maxCharacters, maxCharactersConstraintKind, maxElements, maxElementsConstraintKind, minCharacters, minCharactersConstraintKind, minElements, minElementsConstraintKind, multipleOf, multipleOfConstraintKind, negative, negativeConstraintKind, nonEncodableStringStructureKind, notEmpty, notEmptyConstraintKind, notZero, notZeroConstraintKind, nullHelper as null, nullFundamentalTypeKind, nullTypeKind, nullable, number, numberFundamentalTypeKind, numberInString, numberInStringConstraintKind, numberLiteralTypeKind, numberTypeKind, object, objectStructureKind, odd, oddConstraintKind, optional, partial, path, pathConstraintKind, positive, positiveConstraintKind, record, recordStructureKind, refine, refineConstraintKind, regex, regexConstraintKind, required, safe, safeConstraintKind, segmentPath, segmentPathConstraintKind, strictNegative, strictNegativeConstraintKind, strictPositive, strictPositiveConstraintKind, string, stringFundamentalTypeKind, stringLengthEqual, stringLengthEqualConstraintKind, stringLiteralTypeKind, stringTypeKind, structureIdentifier, structureKind, time, timeFundamentalTypeKind, timeTypeKind, trimmed, trimmedConstraintKind, typeIdentifier, typeKind, typeStructureKind, undefinedHelper as undefined, undefinedFundamentalTypeKind, undefinedTypeKind, union, unionStructureKind, url, urlConstraintKind, uuid, uuidConstraintKind };
|
|
349
|
+
export { AbsolutePathConstraint, AllowedCharactersConstraint, ArrayLengthEqualConstraint, ArrayStructure, BetweenThanConstraint, BetweenThanOrEqualConstraint, BigintLiteralType, BigintType, BooleanLiteralType, BooleanType, ConstraintBase, DateType, EmailConstraint, ErrorSymbol, EvenConstraint, GreaterThanConstraint, GreaterThanOrEqualConstraint, IntegerConstraint, LazyStructure, LessThanConstraint, LessThanOrEqualConstraint, MaxCharactersConstraint, MaxElementsConstraint, MinCharactersConstraint, MinElementsConstraint, MultipleOfConstraint, NegativeConstraint, NonEncodableStringStructure, NotEmptyConstraint, NotZeroConstraint, NullType, NumberInStringConstraint, NumberLiteralType, NumberType, ObjectStructure, OddConstraint, PathConstraint, PositiveConstraint, RecordStructure, RefineConstraint, RegexConstraint, SafeConstraint, SegmentPathConstraint, StrictNegativeConstraint, StrictPositiveConstraint, StringLengthEqualConstraint, StringLiteralType, StringType, StructureClass, SuccessSymbol, TheBigint, TheBoolean, TheDate, TheNull, TheNumber, TheString, TheTime, TheUndefined, TimeType, TrimmedConstraint, TypeStructure, UndefinedType, UnionStructure, UrlConstraint, UuidConstraint, absolutePath, absolutePathConstraintKind, allowedCharacters, allowedCharactersConstraintKind, array, arrayLengthEqual, arrayLengthEqualConstraintKind, arrayStructureKind, betweenThan, betweenThanConstraintKind, betweenThanOrEqual, betweenThanOrEqualConstraintKind, bigint, bigintFundamentalTypeKind, bigintLiteralTypeKind, bigintTypeKind, boolean, booleanFundamentalTypeKind, booleanLiteralTypeKind, booleanTypeKind, codecKind, codecsJson, codecsKind, codecsString, constraintIdentifier, constraintKind, createCodec, createCodecs, createConstraint, createErrorHandler, createErrorInterpreter, createFundamentalType, createGetErrorHandler, createKind, createStructure, createType, dataStructure_exports, date, dateFundamentalTypeKind, dateTypeKind, decodeIssueKind, email, emailConstraintKind, encodeIssueKind, even, evenConstraintKind, extend, fundamentalTypeIdentifier, fundamentalTypeKind, greaterThan, greaterThanConstraintKind, greaterThanOrEqual, greaterThanOrEqualConstraintKind, integer, integerConstraintKind, isNullStructure, isNullable, isOptional, isUndefinedStructure, issueKind, lazy, lazyStructureKind, lessThan, lessThanConstraintKind, lessThanOrEqual, lessThanOrEqualConstraintKind, literal, maxCharacters, maxCharactersConstraintKind, maxElements, maxElementsConstraintKind, minCharacters, minCharactersConstraintKind, minElements, minElementsConstraintKind, multipleOf, multipleOfConstraintKind, negative, negativeConstraintKind, nonEncodableStringStructureKind, notEmpty, notEmptyConstraintKind, notZero, notZeroConstraintKind, nullHelper as null, nullFundamentalTypeKind, nullTypeKind, nullable, number, numberFundamentalTypeKind, numberInString, numberInStringConstraintKind, numberLiteralTypeKind, numberTypeKind, object, objectStructureKind, odd, oddConstraintKind, optional, partial, path, pathConstraintKind, positive, positiveConstraintKind, record, recordStructureKind, refine, refineConstraintKind, regex, regexConstraintKind, required, safe, safeConstraintKind, segmentPath, segmentPathConstraintKind, strictNegative, strictNegativeConstraintKind, strictPositive, strictPositiveConstraintKind, string, stringFundamentalTypeKind, stringLengthEqual, stringLengthEqualConstraintKind, stringLiteralTypeKind, stringTypeKind, structureIdentifier, structureKind, time, timeFundamentalTypeKind, timeTypeKind, trimmed, trimmedConstraintKind, typeIdentifier, typeKind, typeStructureKind, undefinedHelper as undefined, undefinedFundamentalTypeKind, undefinedTypeKind, union, unionStructureKind, unwrapLazy, url, urlConstraintKind, uuid, uuidConstraintKind };
|
|
@@ -14,7 +14,7 @@ export interface StructureDefinition<GenericConstraints extends readonly Constra
|
|
|
14
14
|
readonly message?: string;
|
|
15
15
|
readonly constraints: readonly [...GenericConstraints];
|
|
16
16
|
}
|
|
17
|
-
export interface Structure<GenericValue extends unknown = unknown, GenericDefinition extends StructureDefinition<readonly Constraint<GenericValue>[]> = StructureDefinition<readonly Constraint<GenericValue>[]>> extends DKind.Kind<typeof structureKind, (GenericValue & StructureConstraintsValue<GenericDefinition["constraints"][number]>)> {
|
|
17
|
+
export interface Structure<out GenericValue extends unknown = unknown, out GenericDefinition extends StructureDefinition<readonly Constraint<GenericValue>[]> = StructureDefinition<readonly Constraint<GenericValue>[]>> extends DKind.Kind<typeof structureKind, (GenericValue & StructureConstraintsValue<GenericDefinition["constraints"][number]>)> {
|
|
18
18
|
readonly definition: GenericDefinition;
|
|
19
19
|
addConstraint<const GenericNewConstraints extends DCommon.AnyTuple<Constraint<GenericValue>>>(...args: DCommon.FixDeepFunctionInfer<DCommon.AnyTuple<Constraint<GenericValue>>, GenericNewConstraints>): Structure<StructureValue<this>, StructureDefinition<readonly [...this["definition"]["constraints"], ...GenericNewConstraints]>>;
|
|
20
20
|
executeConstraints(data: unknown, errorHandler?: GetErrorHandler): DCommon.MaybePromise<SuccessSymbol | ErrorSymbol>;
|
|
@@ -13,6 +13,6 @@ export declare const arrayStructureKind: DKind.Handler<DKind.Definition<"@Duploj
|
|
|
13
13
|
export interface ArrayStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
14
14
|
readonly element: Structure;
|
|
15
15
|
}
|
|
16
|
-
export interface ArrayStructure<GenericValue extends readonly unknown[] = readonly unknown[], GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, ArrayStructureDefinition<GenericConstraints>> & DKind.Kind<typeof arrayStructureKind>> {
|
|
16
|
+
export interface ArrayStructure<out GenericValue extends readonly unknown[] = readonly unknown[], out GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, ArrayStructureDefinition<GenericConstraints>> & DKind.Kind<typeof arrayStructureKind>> {
|
|
17
17
|
}
|
|
18
18
|
export declare const ArrayStructure: <GenericElement extends Structure, const GenericConstraints extends readonly Constraint<readonly StructureValue<GenericElement>[]>[]>(element: GenericElement, constraints: GenericConstraints) => NoInfer<ArrayStructure<readonly StructureValue<GenericElement>[], readonly [...GenericConstraints]>>;
|
|
@@ -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.Forward<Structure<GenericValue, LazyStructureDefinition<GenericConstraints>> & DKind.Kind<typeof lazyStructureKind>> {
|
|
10
|
+
export interface LazyStructure<out GenericValue extends unknown = unknown, out 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]>>;
|
|
@@ -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.Forward<Structure<GenericValue, ObjectStructureDefinition<GenericConstraints>> & DKind.Kind<typeof objectStructureKind>> {
|
|
28
|
+
export interface ObjectStructure<out GenericValue extends Record<string, unknown> = Record<string, unknown>, out 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]>>;
|
|
@@ -14,6 +14,6 @@ export interface RecordStructureDefinition<GenericConstraints extends readonly C
|
|
|
14
14
|
readonly value: Structure;
|
|
15
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.Forward<Structure<GenericValue, RecordStructureDefinition<GenericConstraints>> & DKind.Kind<typeof recordStructureKind>> {
|
|
17
|
+
export interface RecordStructure<out GenericValue extends Record<string, unknown> = Record<string, unknown>, out 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]>>;
|