@duplojs/utils 1.1.10 → 1.1.11
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/types/index.d.ts +1 -0
- package/dist/common/types/removeFromUnion.d.ts +2 -0
- package/dist/common/types/unionContain.d.ts +1 -1
- package/dist/dataParser/base.cjs +3 -3
- package/dist/dataParser/base.d.ts +3 -3
- package/dist/dataParser/base.mjs +3 -3
- package/dist/dataParser/baseExtended.cjs +3 -3
- package/dist/dataParser/baseExtended.d.ts +5 -5
- package/dist/dataParser/baseExtended.mjs +3 -3
- package/dist/dataParser/error.cjs +9 -9
- package/dist/dataParser/error.d.ts +10 -9
- package/dist/dataParser/error.mjs +7 -7
- package/dist/dataParser/extended/array.d.ts +3 -2
- package/dist/dataParser/extended/lazy.d.ts +3 -2
- package/dist/dataParser/extended/nullable.d.ts +3 -2
- package/dist/dataParser/extended/optional.d.ts +3 -2
- package/dist/dataParser/extended/pipe.d.ts +3 -2
- package/dist/dataParser/extended/record.d.ts +3 -2
- package/dist/dataParser/extended/transform.d.ts +3 -3
- package/dist/dataParser/identifier.cjs +32 -0
- package/dist/dataParser/identifier.d.ts +9 -0
- package/dist/dataParser/identifier.mjs +30 -0
- package/dist/dataParser/index.cjs +26 -24
- package/dist/dataParser/index.d.ts +1 -0
- package/dist/dataParser/index.mjs +23 -22
- package/dist/dataParser/parsers/array/index.cjs +3 -3
- package/dist/dataParser/parsers/array/index.d.ts +5 -5
- package/dist/dataParser/parsers/array/index.mjs +3 -3
- package/dist/dataParser/parsers/bigint/index.cjs +3 -3
- package/dist/dataParser/parsers/bigint/index.d.ts +2 -2
- package/dist/dataParser/parsers/bigint/index.mjs +3 -3
- package/dist/dataParser/parsers/boolean.cjs +3 -3
- package/dist/dataParser/parsers/boolean.d.ts +2 -2
- package/dist/dataParser/parsers/boolean.mjs +3 -3
- package/dist/dataParser/parsers/empty.cjs +3 -3
- package/dist/dataParser/parsers/empty.d.ts +2 -2
- package/dist/dataParser/parsers/empty.mjs +3 -3
- package/dist/dataParser/parsers/lazy.cjs +3 -3
- package/dist/dataParser/parsers/lazy.d.ts +5 -5
- package/dist/dataParser/parsers/lazy.mjs +3 -3
- package/dist/dataParser/parsers/literal.cjs +3 -3
- package/dist/dataParser/parsers/literal.d.ts +2 -2
- package/dist/dataParser/parsers/literal.mjs +3 -3
- package/dist/dataParser/parsers/nil.cjs +3 -3
- package/dist/dataParser/parsers/nil.d.ts +2 -2
- package/dist/dataParser/parsers/nil.mjs +3 -3
- package/dist/dataParser/parsers/nullable.cjs +3 -3
- package/dist/dataParser/parsers/nullable.d.ts +5 -5
- package/dist/dataParser/parsers/nullable.mjs +3 -3
- package/dist/dataParser/parsers/number/index.cjs +3 -3
- package/dist/dataParser/parsers/number/index.d.ts +2 -2
- package/dist/dataParser/parsers/number/index.mjs +3 -3
- package/dist/dataParser/parsers/object.cjs +3 -3
- package/dist/dataParser/parsers/object.d.ts +5 -5
- package/dist/dataParser/parsers/object.mjs +3 -3
- package/dist/dataParser/parsers/optional.cjs +3 -3
- package/dist/dataParser/parsers/optional.d.ts +5 -5
- package/dist/dataParser/parsers/optional.mjs +3 -3
- package/dist/dataParser/parsers/pipe.cjs +3 -3
- package/dist/dataParser/parsers/pipe.d.ts +6 -6
- package/dist/dataParser/parsers/pipe.mjs +3 -3
- package/dist/dataParser/parsers/record.cjs +3 -3
- package/dist/dataParser/parsers/record.d.ts +7 -7
- package/dist/dataParser/parsers/record.mjs +3 -3
- package/dist/dataParser/parsers/string/index.cjs +3 -3
- package/dist/dataParser/parsers/string/index.d.ts +2 -2
- package/dist/dataParser/parsers/string/index.mjs +3 -3
- package/dist/dataParser/parsers/templateLiteral.cjs +4 -4
- package/dist/dataParser/parsers/templateLiteral.d.ts +2 -2
- package/dist/dataParser/parsers/templateLiteral.mjs +11 -11
- package/dist/dataParser/parsers/transform.cjs +3 -3
- package/dist/dataParser/parsers/transform.d.ts +5 -5
- package/dist/dataParser/parsers/transform.mjs +3 -3
- package/dist/dataParser/parsers/tuple.cjs +3 -3
- package/dist/dataParser/parsers/tuple.d.ts +11 -11
- package/dist/dataParser/parsers/tuple.mjs +3 -3
- package/dist/dataParser/parsers/union.cjs +3 -3
- package/dist/dataParser/parsers/union.d.ts +4 -4
- package/dist/dataParser/parsers/union.mjs +3 -3
- package/dist/dataParser/parsers/unknown.cjs +3 -3
- package/dist/dataParser/parsers/unknown.d.ts +2 -2
- package/dist/dataParser/parsers/unknown.mjs +3 -3
- package/dist/dataParser/types/checkers.d.ts +5 -1
- package/dist/dataParser/types/dataParsers.d.ts +9 -1
- package/dist/number/index.cjs +4 -0
- package/dist/number/index.d.ts +2 -0
- package/dist/number/index.mjs +2 -0
- package/dist/number/sqrt.cjs +7 -0
- package/dist/number/sqrt.d.ts +1 -0
- package/dist/number/sqrt.mjs +5 -0
- package/dist/number/toFixed.cjs +12 -0
- package/dist/number/toFixed.d.ts +2 -0
- package/dist/number/toFixed.mjs +10 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type IsEqual } from "./isEqual";
|
|
2
|
-
export type UnionContain<GenericUnion extends unknown, GenericValue extends unknown> = IsEqual<(GenericUnion extends any ? IsEqual<GenericUnion, GenericValue> : never) | false, boolean>;
|
|
2
|
+
export type UnionContain<GenericUnion extends unknown, GenericValue extends unknown> = IsEqual<GenericValue extends any ? IsEqual<(GenericUnion extends any ? IsEqual<GenericUnion, GenericValue> : never) | false, boolean> : never, true>;
|
package/dist/dataParser/base.cjs
CHANGED
|
@@ -10,9 +10,9 @@ var kind = require('./kind.cjs');
|
|
|
10
10
|
|
|
11
11
|
const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
12
12
|
const SymbolDataParserError = Symbol.for(SymbolDataParserErrorLabel);
|
|
13
|
-
const
|
|
13
|
+
const checkerKind = kind.createDataParserKind("checker");
|
|
14
14
|
function dataParserCheckerInit(kind, params, exec) {
|
|
15
|
-
return kind.setTo(
|
|
15
|
+
return kind.setTo(checkerKind.setTo({
|
|
16
16
|
...params,
|
|
17
17
|
exec,
|
|
18
18
|
}));
|
|
@@ -112,7 +112,7 @@ function dataParserInit(kind, params, exec) {
|
|
|
112
112
|
|
|
113
113
|
exports.SymbolDataParserError = SymbolDataParserError;
|
|
114
114
|
exports.SymbolDataParserErrorLabel = SymbolDataParserErrorLabel;
|
|
115
|
+
exports.checkerKind = checkerKind;
|
|
115
116
|
exports.dataParserCheckerInit = dataParserCheckerInit;
|
|
116
|
-
exports.dataParserCheckerKind = dataParserCheckerKind;
|
|
117
117
|
exports.dataParserInit = dataParserInit;
|
|
118
118
|
exports.dataParserKind = dataParserKind;
|
|
@@ -4,15 +4,15 @@ import * as DEither from "../either";
|
|
|
4
4
|
export declare const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
5
5
|
export declare const SymbolDataParserError: unique symbol;
|
|
6
6
|
export type SymbolDataParserError = typeof SymbolDataParserError;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const checkerKind: KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/checker", unknown>>;
|
|
8
8
|
export interface DataParserCheckerDefinition {
|
|
9
9
|
readonly errorMessage?: string;
|
|
10
10
|
}
|
|
11
|
-
export interface DataParserChecker<GenericDefinition extends DataParserCheckerDefinition = DataParserCheckerDefinition, GenericInput extends AnyValue = AnyValue> extends Kind<typeof
|
|
11
|
+
export interface DataParserChecker<GenericDefinition extends DataParserCheckerDefinition = DataParserCheckerDefinition, GenericInput extends AnyValue = AnyValue> extends Kind<typeof checkerKind.definition, GenericInput> {
|
|
12
12
|
readonly definition: GenericDefinition;
|
|
13
13
|
exec(data: GenericInput, self: this): GenericInput | SymbolDataParserErrorIssue;
|
|
14
14
|
}
|
|
15
|
-
export declare function dataParserCheckerInit<GenericDataParserChecker extends DataParserChecker>(kind: Exclude<GetKindHandler<GenericDataParserChecker>, typeof
|
|
15
|
+
export declare function dataParserCheckerInit<GenericDataParserChecker extends DataParserChecker>(kind: Exclude<GetKindHandler<GenericDataParserChecker>, typeof checkerKind>, params: NoInfer<Omit<RemoveKind<GenericDataParserChecker>, "exec">>, exec: (...args: Parameters<GenericDataParserChecker["exec"]>) => GetKindValue<typeof checkerKind, GenericDataParserChecker> | SymbolDataParserErrorIssue): GenericDataParserChecker;
|
|
16
16
|
export declare const dataParserKind: KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
17
17
|
input: unknown;
|
|
18
18
|
output: unknown;
|
package/dist/dataParser/base.mjs
CHANGED
|
@@ -8,9 +8,9 @@ import { createDataParserKind } from './kind.mjs';
|
|
|
8
8
|
|
|
9
9
|
const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
10
10
|
const SymbolDataParserError = Symbol.for(SymbolDataParserErrorLabel);
|
|
11
|
-
const
|
|
11
|
+
const checkerKind = createDataParserKind("checker");
|
|
12
12
|
function dataParserCheckerInit(kind, params, exec) {
|
|
13
|
-
return kind.setTo(
|
|
13
|
+
return kind.setTo(checkerKind.setTo({
|
|
14
14
|
...params,
|
|
15
15
|
exec,
|
|
16
16
|
}));
|
|
@@ -108,4 +108,4 @@ function dataParserInit(kind, params, exec) {
|
|
|
108
108
|
return dataParser;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
export { SymbolDataParserError, SymbolDataParserErrorLabel,
|
|
111
|
+
export { SymbolDataParserError, SymbolDataParserErrorLabel, checkerKind, dataParserCheckerInit, dataParserInit, dataParserKind };
|
|
@@ -16,9 +16,9 @@ var nullable = require('./extended/nullable.cjs');
|
|
|
16
16
|
var optional = require('./extended/optional.cjs');
|
|
17
17
|
var pipe$1 = require('./extended/pipe.cjs');
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const extendedKind = kind.createDataParserKind("extended");
|
|
20
20
|
function dataParserExtendedInit(dataParser, rest) {
|
|
21
|
-
const self =
|
|
21
|
+
const self = extendedKind.setTo({
|
|
22
22
|
...dataParser,
|
|
23
23
|
...pipe.pipe(rest, entries.entries, map.map(([key, value]) => entry.entry(key, typeof value === "function"
|
|
24
24
|
? (...args) => value(self, ...args)
|
|
@@ -54,4 +54,4 @@ function dataParserExtendedInit(dataParser, rest) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
exports.dataParserExtendedInit = dataParserExtendedInit;
|
|
57
|
-
exports.
|
|
57
|
+
exports.extendedKind = extendedKind;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Kind, type NeverCoalescing, type AnyFunction, type SimplifyTopLevel, type AnyValue } from "../common";
|
|
2
|
-
import { type
|
|
2
|
+
import { type MergeDefinition } from "./types";
|
|
3
3
|
import { type Output, type DataParser } from "./base";
|
|
4
4
|
import type * as dataParsers from "./parsers";
|
|
5
5
|
import * as dataParsersExtended from "./extended";
|
|
6
6
|
import { type DataParserError } from "./error";
|
|
7
|
-
export declare const
|
|
8
|
-
type _DataParserExtended = (DataParser & Kind<typeof
|
|
7
|
+
export declare const extendedKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>>;
|
|
8
|
+
type _DataParserExtended = (DataParser & Kind<typeof extendedKind.definition>);
|
|
9
9
|
export interface DataParserExtended extends _DataParserExtended {
|
|
10
10
|
array<GenericThis extends this = this, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionArray, "element">> = never>(definition?: GenericDefinition): dataParsersExtended.DataParserArrayExtended<MergeDefinition<dataParsers.DataParserDefinitionArray, NeverCoalescing<GenericDefinition, {}> & {
|
|
11
11
|
element: GenericThis;
|
|
@@ -25,7 +25,7 @@ export interface DataParserExtended extends _DataParserExtended {
|
|
|
25
25
|
}>>
|
|
26
26
|
];
|
|
27
27
|
}>>;
|
|
28
|
-
pipe<GenericThis extends this = this, GenericOutput extends
|
|
28
|
+
pipe<GenericThis extends this = this, GenericOutput extends DataParser = DataParser, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionPipe, "input" | "output">> = never>(output: GenericOutput, definition?: GenericDefinition): dataParsersExtended.DataParserPipeExtended<MergeDefinition<dataParsers.DataParserDefinitionPipe, NeverCoalescing<GenericDefinition, {}> & {
|
|
29
29
|
input: GenericThis;
|
|
30
30
|
output: GenericOutput;
|
|
31
31
|
}>>;
|
|
@@ -35,7 +35,7 @@ export interface DataParserExtended extends _DataParserExtended {
|
|
|
35
35
|
optional<GenericThis extends this = this, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionOptional, "inner">> = never>(definition?: GenericDefinition): dataParsersExtended.DataParserOptionalExtended<MergeDefinition<dataParsers.DataParserDefinitionOptional, NeverCoalescing<GenericDefinition, {}> & {
|
|
36
36
|
inner: GenericThis;
|
|
37
37
|
}>>;
|
|
38
|
-
or<GenericThis extends this = this, GenericDataParser extends
|
|
38
|
+
or<GenericThis extends this = this, GenericDataParser extends DataParser = DataParser, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionUnion, "options">> = never>(option: GenericDataParser, definition?: GenericDefinition): dataParsersExtended.DataParserUnionExtended<MergeDefinition<dataParsers.DataParserDefinitionUnion, NeverCoalescing<GenericDefinition, {}> & {
|
|
39
39
|
options: [GenericThis, GenericDataParser];
|
|
40
40
|
}>>;
|
|
41
41
|
}
|
|
@@ -14,9 +14,9 @@ import { nullable } from './extended/nullable.mjs';
|
|
|
14
14
|
import { optional } from './extended/optional.mjs';
|
|
15
15
|
import { pipe as pipe$1 } from './extended/pipe.mjs';
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const extendedKind = createDataParserKind("extended");
|
|
18
18
|
function dataParserExtendedInit(dataParser, rest) {
|
|
19
|
-
const self =
|
|
19
|
+
const self = extendedKind.setTo({
|
|
20
20
|
...dataParser,
|
|
21
21
|
...pipe(rest, entries, map(([key, value]) => entry(key, typeof value === "function"
|
|
22
22
|
? (...args) => value(self, ...args)
|
|
@@ -51,4 +51,4 @@ function dataParserExtendedInit(dataParser, rest) {
|
|
|
51
51
|
return self;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export { dataParserExtendedInit,
|
|
54
|
+
export { dataParserExtendedInit, extendedKind };
|
|
@@ -4,19 +4,19 @@ var kind = require('./kind.cjs');
|
|
|
4
4
|
|
|
5
5
|
const SymbolDataParserErrorIssueLabel = "SymbolDataParserErrorIssue";
|
|
6
6
|
const SymbolDataParserErrorIssue = Symbol.for(SymbolDataParserErrorIssueLabel);
|
|
7
|
-
const
|
|
7
|
+
const errorIssueKind = kind.createDataParserKind("error-issue");
|
|
8
8
|
const SymbolDataParserErrorPromiseIssueLabel = "SymbolDataParserErrorPromiseIssue";
|
|
9
9
|
const SymbolDataParserErrorPromiseIssue = Symbol.for(SymbolDataParserErrorPromiseIssueLabel);
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const errorPromiseIssueKind = kind.createDataParserKind("error-issue-promise");
|
|
11
|
+
const errorKind = kind.createDataParserKind("error");
|
|
12
12
|
function createError() {
|
|
13
|
-
return
|
|
13
|
+
return errorKind.setTo({
|
|
14
14
|
issues: [],
|
|
15
15
|
currentPath: [],
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
function addIssue(error, source, data) {
|
|
19
|
-
error.issues.push(
|
|
19
|
+
error.issues.push(errorIssueKind.setTo({
|
|
20
20
|
source,
|
|
21
21
|
path: error.currentPath.join("."),
|
|
22
22
|
data,
|
|
@@ -24,7 +24,7 @@ function addIssue(error, source, data) {
|
|
|
24
24
|
return error;
|
|
25
25
|
}
|
|
26
26
|
function addPromiseIssue(error, source, data) {
|
|
27
|
-
error.issues.push(
|
|
27
|
+
error.issues.push(errorPromiseIssueKind.setTo({
|
|
28
28
|
source,
|
|
29
29
|
path: error.currentPath.join("."),
|
|
30
30
|
data,
|
|
@@ -47,8 +47,8 @@ exports.SymbolDataParserErrorPromiseIssueLabel = SymbolDataParserErrorPromiseIss
|
|
|
47
47
|
exports.addIssue = addIssue;
|
|
48
48
|
exports.addPromiseIssue = addPromiseIssue;
|
|
49
49
|
exports.createError = createError;
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
50
|
+
exports.errorIssueKind = errorIssueKind;
|
|
51
|
+
exports.errorKind = errorKind;
|
|
52
|
+
exports.errorPromiseIssueKind = errorPromiseIssueKind;
|
|
53
53
|
exports.popErrorPath = popErrorPath;
|
|
54
54
|
exports.setErrorPath = setErrorPath;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { type Kind } from "../common";
|
|
2
|
-
import { type DataParsers, type Checkers } from "./types";
|
|
3
2
|
import { type DataParserTransform } from "./parsers";
|
|
3
|
+
import { type DataParser } from "./base";
|
|
4
|
+
import { type DataParserCheckers } from "./types";
|
|
4
5
|
export declare const SymbolDataParserErrorIssueLabel = "SymbolDataParserErrorIssue";
|
|
5
6
|
export declare const SymbolDataParserErrorIssue: unique symbol;
|
|
6
7
|
export type SymbolDataParserErrorIssue = typeof SymbolDataParserErrorIssue;
|
|
7
|
-
export declare const
|
|
8
|
-
export interface DataParserErrorIssue extends Kind<typeof
|
|
9
|
-
readonly source:
|
|
8
|
+
export declare const errorIssueKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/error-issue", unknown>>;
|
|
9
|
+
export interface DataParserErrorIssue extends Kind<typeof errorIssueKind.definition> {
|
|
10
|
+
readonly source: DataParser | DataParserCheckers;
|
|
10
11
|
readonly path: string;
|
|
11
12
|
readonly data: unknown;
|
|
12
13
|
}
|
|
13
14
|
export declare const SymbolDataParserErrorPromiseIssueLabel = "SymbolDataParserErrorPromiseIssue";
|
|
14
15
|
export declare const SymbolDataParserErrorPromiseIssue: unique symbol;
|
|
15
16
|
export type SymbolDataParserErrorPromiseIssue = typeof SymbolDataParserErrorPromiseIssue;
|
|
16
|
-
export declare const
|
|
17
|
-
export interface DataParserErrorPromiseIssue extends Kind<typeof
|
|
17
|
+
export declare const errorPromiseIssueKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/error-issue-promise", unknown>>;
|
|
18
|
+
export interface DataParserErrorPromiseIssue extends Kind<typeof errorPromiseIssueKind.definition> {
|
|
18
19
|
readonly source: DataParserTransform;
|
|
19
20
|
readonly path: string;
|
|
20
21
|
readonly data: unknown;
|
|
21
22
|
}
|
|
22
|
-
export declare const
|
|
23
|
-
export interface DataParserError extends Kind<typeof
|
|
23
|
+
export declare const errorKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/error", unknown>>;
|
|
24
|
+
export interface DataParserError extends Kind<typeof errorKind.definition> {
|
|
24
25
|
readonly issues: (DataParserErrorIssue | DataParserErrorPromiseIssue)[];
|
|
25
26
|
readonly currentPath: string[];
|
|
26
27
|
}
|
|
27
28
|
export declare function createError(): DataParserError;
|
|
28
|
-
export declare function addIssue(error: DataParserError, source:
|
|
29
|
+
export declare function addIssue(error: DataParserError, source: DataParser | DataParserCheckers, data: unknown): DataParserError;
|
|
29
30
|
export declare function addPromiseIssue(error: DataParserError, source: DataParserTransform, data: unknown): DataParserError;
|
|
30
31
|
export declare function setErrorPath(error: DataParserError, value: string, index: number): DataParserError;
|
|
31
32
|
export declare function popErrorPath(error: DataParserError): DataParserError;
|
|
@@ -2,19 +2,19 @@ import { createDataParserKind } from './kind.mjs';
|
|
|
2
2
|
|
|
3
3
|
const SymbolDataParserErrorIssueLabel = "SymbolDataParserErrorIssue";
|
|
4
4
|
const SymbolDataParserErrorIssue = Symbol.for(SymbolDataParserErrorIssueLabel);
|
|
5
|
-
const
|
|
5
|
+
const errorIssueKind = createDataParserKind("error-issue");
|
|
6
6
|
const SymbolDataParserErrorPromiseIssueLabel = "SymbolDataParserErrorPromiseIssue";
|
|
7
7
|
const SymbolDataParserErrorPromiseIssue = Symbol.for(SymbolDataParserErrorPromiseIssueLabel);
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const errorPromiseIssueKind = createDataParserKind("error-issue-promise");
|
|
9
|
+
const errorKind = createDataParserKind("error");
|
|
10
10
|
function createError() {
|
|
11
|
-
return
|
|
11
|
+
return errorKind.setTo({
|
|
12
12
|
issues: [],
|
|
13
13
|
currentPath: [],
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
function addIssue(error, source, data) {
|
|
17
|
-
error.issues.push(
|
|
17
|
+
error.issues.push(errorIssueKind.setTo({
|
|
18
18
|
source,
|
|
19
19
|
path: error.currentPath.join("."),
|
|
20
20
|
data,
|
|
@@ -22,7 +22,7 @@ function addIssue(error, source, data) {
|
|
|
22
22
|
return error;
|
|
23
23
|
}
|
|
24
24
|
function addPromiseIssue(error, source, data) {
|
|
25
|
-
error.issues.push(
|
|
25
|
+
error.issues.push(errorPromiseIssueKind.setTo({
|
|
26
26
|
source,
|
|
27
27
|
path: error.currentPath.join("."),
|
|
28
28
|
data,
|
|
@@ -38,4 +38,4 @@ function popErrorPath(error) {
|
|
|
38
38
|
return error;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export { SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel, SymbolDataParserErrorPromiseIssue, SymbolDataParserErrorPromiseIssueLabel, addIssue, addPromiseIssue, createError,
|
|
41
|
+
export { SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel, SymbolDataParserErrorPromiseIssue, SymbolDataParserErrorPromiseIssueLabel, addIssue, addPromiseIssue, createError, errorIssueKind, errorKind, errorPromiseIssueKind, popErrorPath, setErrorPath };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type AddCheckersToDefinition, type
|
|
3
|
+
import { type AddCheckersToDefinition, type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
+
import { type DataParser } from "../base";
|
|
5
6
|
type _DataParserArrayExtended<GenericDefinition extends dataParsers.DataParserDefinitionArray> = (dataParsers.DataParserArray<GenericDefinition> & DataParserExtended);
|
|
6
7
|
export interface DataParserArrayExtended<GenericDefinition extends dataParsers.DataParserDefinitionArray = dataParsers.DataParserDefinitionArray> extends _DataParserArrayExtended<GenericDefinition> {
|
|
7
8
|
addChecker<GenericChecker extends readonly [
|
|
@@ -15,7 +16,7 @@ export interface DataParserArrayExtended<GenericDefinition extends dataParsers.D
|
|
|
15
16
|
dataParsers.DataParserCheckerArrayMax
|
|
16
17
|
]>>;
|
|
17
18
|
}
|
|
18
|
-
export declare function array<GenericElement extends
|
|
19
|
+
export declare function array<GenericElement extends DataParser, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionArray, "element">> = never>(element: GenericElement, definition?: GenericDefinition): DataParserArrayExtended<MergeDefinition<dataParsers.DataParserDefinitionArray, NeverCoalescing<GenericDefinition, {}> & {
|
|
19
20
|
element: GenericElement;
|
|
20
21
|
}>>;
|
|
21
22
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type
|
|
3
|
+
import { type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
+
import { type DataParser } from "../base";
|
|
5
6
|
type _DataParserLazyExtended<GenericDefinition extends dataParsers.DataParserDefinitionLazy> = (dataParsers.DataParserLazy<GenericDefinition> & DataParserExtended);
|
|
6
7
|
export interface DataParserLazyExtended<GenericDefinition extends dataParsers.DataParserDefinitionLazy = dataParsers.DataParserDefinitionLazy> extends _DataParserLazyExtended<GenericDefinition> {
|
|
7
8
|
}
|
|
8
|
-
export declare function lazy<GenericDataParser extends
|
|
9
|
+
export declare function lazy<GenericDataParser extends DataParser, const GenericDefinition extends Partial<dataParsers.DataParserDefinitionLazy> = never>(getter: () => GenericDataParser, definition?: GenericDefinition): DataParserLazyExtended<MergeDefinition<dataParsers.DataParserDefinitionLazy, NeverCoalescing<GenericDefinition, {}> & {
|
|
9
10
|
getter(): GenericDataParser;
|
|
10
11
|
}>>;
|
|
11
12
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type
|
|
3
|
+
import { type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
+
import { type DataParser } from "../base";
|
|
5
6
|
type _DataParserNullableExtended<GenericDefinition extends dataParsers.DataParserDefinitionNullable> = (dataParsers.DataParserNullable<GenericDefinition> & DataParserExtended);
|
|
6
7
|
export interface DataParserNullableExtended<GenericDefinition extends dataParsers.DataParserDefinitionNullable = dataParsers.DataParserDefinitionNullable> extends _DataParserNullableExtended<GenericDefinition> {
|
|
7
8
|
}
|
|
8
|
-
export declare function nullable<GenericDataParser extends
|
|
9
|
+
export declare function nullable<GenericDataParser extends DataParser, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionNullable, "inner">> = never>(inner: GenericDataParser, definition?: GenericDefinition): DataParserNullableExtended<MergeDefinition<dataParsers.DataParserDefinitionNullable, NeverCoalescing<GenericDefinition, {}> & {
|
|
9
10
|
inner: GenericDataParser;
|
|
10
11
|
}>>;
|
|
11
12
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type
|
|
3
|
+
import { type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
+
import { type DataParser } from "../base";
|
|
5
6
|
type _DataParserOptionalExtended<GenericDefinition extends dataParsers.DataParserDefinitionOptional> = (dataParsers.DataParserOptional<GenericDefinition> & DataParserExtended);
|
|
6
7
|
export interface DataParserOptionalExtended<GenericDefinition extends dataParsers.DataParserDefinitionOptional = dataParsers.DataParserDefinitionOptional> extends _DataParserOptionalExtended<GenericDefinition> {
|
|
7
8
|
}
|
|
8
|
-
export declare function optional<GenericDataParser extends
|
|
9
|
+
export declare function optional<GenericDataParser extends DataParser, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionOptional, "inner">> = never>(inner: GenericDataParser, definition?: GenericDefinition): DataParserOptionalExtended<MergeDefinition<dataParsers.DataParserDefinitionOptional, NeverCoalescing<GenericDefinition, {}> & {
|
|
9
10
|
inner: GenericDataParser;
|
|
10
11
|
}>>;
|
|
11
12
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type
|
|
3
|
+
import { type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
+
import { type DataParser } from "../base";
|
|
5
6
|
type _DataParserPipeExtended<GenericDefinition extends dataParsers.DataParserDefinitionPipe> = (dataParsers.DataParserPipe<GenericDefinition> & DataParserExtended);
|
|
6
7
|
export interface DataParserPipeExtended<GenericDefinition extends dataParsers.DataParserDefinitionPipe = dataParsers.DataParserDefinitionPipe> extends _DataParserPipeExtended<GenericDefinition> {
|
|
7
8
|
}
|
|
8
|
-
export declare function pipe<GenericInput extends
|
|
9
|
+
export declare function pipe<GenericInput extends DataParser, GenericOutput extends DataParser, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionPipe, "input" | "output">> = never>(input: GenericInput, output: GenericOutput, definition?: GenericDefinition): DataParserPipeExtended<MergeDefinition<dataParsers.DataParserDefinitionPipe, NeverCoalescing<GenericDefinition, {}> & {
|
|
9
10
|
input: GenericInput;
|
|
10
11
|
output: GenericOutput;
|
|
11
12
|
}>>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type
|
|
3
|
+
import { type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
+
import { type DataParser } from "../base";
|
|
5
6
|
type _DataParserRecordExtended<GenericDefinition extends dataParsers.DataParserDefinitionRecord> = (dataParsers.DataParserRecord<GenericDefinition> & DataParserExtended);
|
|
6
7
|
export interface DataParserRecordExtended<GenericDefinition extends dataParsers.DataParserDefinitionRecord = dataParsers.DataParserDefinitionRecord> extends _DataParserRecordExtended<GenericDefinition> {
|
|
7
8
|
}
|
|
8
|
-
export declare function record<GenericDataParserKey extends dataParsers.DataParserRecordKey, GenericDataParserValue extends
|
|
9
|
+
export declare function record<GenericDataParserKey extends dataParsers.DataParserRecordKey, GenericDataParserValue extends DataParser, const GenericDefinition extends Partial<dataParsers.DataParserDefinitionRecord> = never>(key: GenericDataParserKey, value: GenericDataParserValue, definition?: GenericDefinition): DataParserRecordExtended<MergeDefinition<dataParsers.DataParserDefinitionRecord, NeverCoalescing<GenericDefinition, {}> & {
|
|
9
10
|
key: GenericDataParserKey;
|
|
10
11
|
value: GenericDataParserValue;
|
|
11
12
|
}>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type NeverCoalescing } from "../../common";
|
|
2
2
|
import { type DataParserExtended } from "../baseExtended";
|
|
3
|
-
import { type
|
|
3
|
+
import { type MergeDefinition } from "../types";
|
|
4
4
|
import * as dataParsers from "../parsers";
|
|
5
|
-
import { type Output } from "../base";
|
|
5
|
+
import { type DataParser, type Output } from "../base";
|
|
6
6
|
import { type DataParserError } from "../error";
|
|
7
7
|
type _DataParserTransformExtended<GenericDefinition extends dataParsers.DataParserDefinitionTransform> = (dataParsers.DataParserTransform<GenericDefinition> & DataParserExtended);
|
|
8
8
|
export interface DataParserTransformExtended<GenericDefinition extends dataParsers.DataParserDefinitionTransform = dataParsers.DataParserDefinitionTransform> extends _DataParserTransformExtended<GenericDefinition> {
|
|
9
9
|
}
|
|
10
|
-
export declare function transform<GenericDataParser extends
|
|
10
|
+
export declare function transform<GenericDataParser extends DataParser, GenericOutput extends unknown, const GenericDefinition extends Partial<Omit<dataParsers.DataParserDefinitionTransform, "inner" | "theFunction">> = never>(inner: GenericDataParser, theFunction: (input: Output<GenericDataParser>, error: DataParserError) => GenericOutput, definition?: GenericDefinition): DataParserTransformExtended<MergeDefinition<dataParsers.DataParserDefinitionTransform, NeverCoalescing<GenericDefinition, {}> & {
|
|
11
11
|
inner: GenericDataParser;
|
|
12
12
|
theFunction(input: Output<GenericDataParser>): GenericOutput;
|
|
13
13
|
}>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var coalescing = require('../array/coalescing.cjs');
|
|
4
|
+
require('../common/globalStore.cjs');
|
|
5
|
+
require('../common/builder.cjs');
|
|
6
|
+
var error = require('../either/left/error.cjs');
|
|
7
|
+
var success = require('../either/right/success.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Due to the recursive typing of `DataParsers`, it can’t be used without
|
|
11
|
+
* causing an infinity error. You therefore have to go through the parent
|
|
12
|
+
* type `DataParser`, which makes type discrimination impossible. That’s
|
|
13
|
+
* why the `identifier` function was created. The function ensures that,
|
|
14
|
+
* starting from the parent type and the kinds associated with the data
|
|
15
|
+
* parsers, the correct type can be retrieved.
|
|
16
|
+
*/
|
|
17
|
+
function identifier(...args) {
|
|
18
|
+
if (args.length === 1) {
|
|
19
|
+
const [kind] = args;
|
|
20
|
+
return (input) => identifier(input, kind);
|
|
21
|
+
}
|
|
22
|
+
const [input, kind] = args;
|
|
23
|
+
const formattedKind = coalescing.coalescing(kind);
|
|
24
|
+
for (const kind of formattedKind) {
|
|
25
|
+
if (!kind.has(input)) {
|
|
26
|
+
return error.error(input);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return success.success(input);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.identifier = identifier;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type KindHandler, type UnionToIntersection, type GetKindHandler, type Kind, type UnionContain } from "../common";
|
|
2
|
+
import { type DataParser } from "./base";
|
|
3
|
+
import { type DataParsers, type DataParsersExtended } from "./types";
|
|
4
|
+
import * as DEither from "../either";
|
|
5
|
+
type AllDataParsers = (DataParsers | DataParsersExtended);
|
|
6
|
+
type KindHandlers = AllDataParsers extends infer InferredDataParser ? InferredDataParser extends DataParser ? GetKindHandler<InferredDataParser> : never : never;
|
|
7
|
+
export declare function identifier<GenericKindHandler extends KindHandlers, GenericInput extends DataParser, GenericDataParserResult extends Extract<AllDataParsers, UnionToIntersection<GenericKindHandler extends KindHandler ? Kind<GenericKindHandler["definition"]> : never>>>(kind: GenericKindHandler | GenericKindHandler[]): (input: GenericInput) => ((GenericInput extends any ? UnionContain<GetKindHandler<GenericInput>, GenericKindHandler> extends true ? DEither.EitherSuccess<GenericInput> : DEither.EitherError<GenericInput> : never) | DEither.EitherSuccess<GenericDataParserResult>);
|
|
8
|
+
export declare function identifier<GenericKindHandler extends KindHandlers, GenericInput extends DataParser, GenericDataParserResult extends Extract<AllDataParsers, UnionToIntersection<GenericKindHandler extends KindHandler ? Kind<GenericKindHandler["definition"]> : never>>>(input: GenericInput, kind: GenericKindHandler | GenericKindHandler[]): ((GenericInput extends any ? UnionContain<GetKindHandler<GenericInput>, GenericKindHandler> extends true ? DEither.EitherSuccess<GenericInput> : DEither.EitherError<GenericInput> : never) | DEither.EitherSuccess<GenericDataParserResult>);
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { coalescing } from '../array/coalescing.mjs';
|
|
2
|
+
import '../common/globalStore.mjs';
|
|
3
|
+
import '../common/builder.mjs';
|
|
4
|
+
import { error } from '../either/left/error.mjs';
|
|
5
|
+
import { success } from '../either/right/success.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Due to the recursive typing of `DataParsers`, it can’t be used without
|
|
9
|
+
* causing an infinity error. You therefore have to go through the parent
|
|
10
|
+
* type `DataParser`, which makes type discrimination impossible. That’s
|
|
11
|
+
* why the `identifier` function was created. The function ensures that,
|
|
12
|
+
* starting from the parent type and the kinds associated with the data
|
|
13
|
+
* parsers, the correct type can be retrieved.
|
|
14
|
+
*/
|
|
15
|
+
function identifier(...args) {
|
|
16
|
+
if (args.length === 1) {
|
|
17
|
+
const [kind] = args;
|
|
18
|
+
return (input) => identifier(input, kind);
|
|
19
|
+
}
|
|
20
|
+
const [input, kind] = args;
|
|
21
|
+
const formattedKind = coalescing(kind);
|
|
22
|
+
for (const kind of formattedKind) {
|
|
23
|
+
if (!kind.has(input)) {
|
|
24
|
+
return error(input);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return success(input);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { identifier };
|
|
@@ -24,6 +24,7 @@ var lazy = require('./parsers/lazy.cjs');
|
|
|
24
24
|
var unknown = require('./parsers/unknown.cjs');
|
|
25
25
|
var record = require('./parsers/record.cjs');
|
|
26
26
|
var index = require('./extended/index.cjs');
|
|
27
|
+
var identifier = require('./identifier.cjs');
|
|
27
28
|
var url = require('./parsers/string/checkers/url.cjs');
|
|
28
29
|
var email = require('./parsers/string/checkers/email.cjs');
|
|
29
30
|
var max = require('./parsers/string/checkers/max.cjs');
|
|
@@ -41,12 +42,12 @@ var max$3 = require('./parsers/bigint/checkers/max.cjs');
|
|
|
41
42
|
|
|
42
43
|
exports.SymbolDataParserError = base.SymbolDataParserError;
|
|
43
44
|
exports.SymbolDataParserErrorLabel = base.SymbolDataParserErrorLabel;
|
|
45
|
+
exports.checkerKind = base.checkerKind;
|
|
44
46
|
exports.dataParserCheckerInit = base.dataParserCheckerInit;
|
|
45
|
-
exports.dataParserCheckerKind = base.dataParserCheckerKind;
|
|
46
47
|
exports.dataParserInit = base.dataParserInit;
|
|
47
48
|
exports.dataParserKind = base.dataParserKind;
|
|
48
49
|
exports.dataParserExtendedInit = baseExtended.dataParserExtendedInit;
|
|
49
|
-
exports.
|
|
50
|
+
exports.extendedKind = baseExtended.extendedKind;
|
|
50
51
|
exports.SymbolDataParserErrorIssue = error.SymbolDataParserErrorIssue;
|
|
51
52
|
exports.SymbolDataParserErrorIssueLabel = error.SymbolDataParserErrorIssueLabel;
|
|
52
53
|
exports.SymbolDataParserErrorPromiseIssue = error.SymbolDataParserErrorPromiseIssue;
|
|
@@ -54,51 +55,52 @@ exports.SymbolDataParserErrorPromiseIssueLabel = error.SymbolDataParserErrorProm
|
|
|
54
55
|
exports.addIssue = error.addIssue;
|
|
55
56
|
exports.addPromiseIssue = error.addPromiseIssue;
|
|
56
57
|
exports.createError = error.createError;
|
|
57
|
-
exports.
|
|
58
|
-
exports.
|
|
59
|
-
exports.
|
|
58
|
+
exports.errorIssueKind = error.errorIssueKind;
|
|
59
|
+
exports.errorKind = error.errorKind;
|
|
60
|
+
exports.errorPromiseIssueKind = error.errorPromiseIssueKind;
|
|
60
61
|
exports.popErrorPath = error.popErrorPath;
|
|
61
62
|
exports.setErrorPath = error.setErrorPath;
|
|
62
63
|
exports.coerce = index$1;
|
|
63
|
-
exports.dataParserStringKind = index$2.dataParserStringKind;
|
|
64
64
|
exports.string = index$2.string;
|
|
65
|
-
exports.
|
|
65
|
+
exports.stringKind = index$2.stringKind;
|
|
66
66
|
exports.object = object.object;
|
|
67
|
-
exports.
|
|
67
|
+
exports.objectKind = object.objectKind;
|
|
68
68
|
exports.number = index$3.number;
|
|
69
|
-
exports.
|
|
69
|
+
exports.numberKind = index$3.numberKind;
|
|
70
70
|
exports.literal = literal.literal;
|
|
71
|
-
exports.
|
|
71
|
+
exports.literalKind = literal.literalKind;
|
|
72
72
|
exports.union = union.union;
|
|
73
|
+
exports.unionKind = union.unionKind;
|
|
73
74
|
exports.array = index$4.array;
|
|
74
|
-
exports.
|
|
75
|
+
exports.arrayKind = index$4.arrayKind;
|
|
76
|
+
exports.bigIntKind = index$5.bigIntKind;
|
|
75
77
|
exports.bigint = index$5.bigint;
|
|
76
|
-
exports.dataParserBigIntKind = index$5.dataParserBigIntKind;
|
|
77
|
-
exports.dataParserTupleKind = tuple.dataParserTupleKind;
|
|
78
78
|
exports.tuple = tuple.tuple;
|
|
79
|
-
exports.
|
|
79
|
+
exports.tupleKind = tuple.tupleKind;
|
|
80
80
|
exports.transform = transform.transform;
|
|
81
|
-
exports.
|
|
81
|
+
exports.transformKind = transform.transformKind;
|
|
82
82
|
exports.nil = nil.nil;
|
|
83
|
+
exports.nilKind = nil.nilKind;
|
|
83
84
|
exports.boolean = boolean.boolean;
|
|
84
|
-
exports.
|
|
85
|
-
exports.dataParserEmptyKind = empty.dataParserEmptyKind;
|
|
85
|
+
exports.booleanKind = boolean.booleanKind;
|
|
86
86
|
exports.empty = empty.empty;
|
|
87
|
-
exports.
|
|
87
|
+
exports.emptyKind = empty.emptyKind;
|
|
88
88
|
exports.templateLiteral = templateLiteral.templateLiteral;
|
|
89
|
-
exports.
|
|
89
|
+
exports.templateLiteralKind = templateLiteral.templateLiteralKind;
|
|
90
90
|
exports.pipe = pipe.pipe;
|
|
91
|
-
exports.
|
|
91
|
+
exports.pipeKind = pipe.pipeKind;
|
|
92
92
|
exports.optional = optional.optional;
|
|
93
|
-
exports.
|
|
93
|
+
exports.optionalKind = optional.optionalKind;
|
|
94
94
|
exports.nullable = nullable.nullable;
|
|
95
|
-
exports.
|
|
95
|
+
exports.nullableKind = nullable.nullableKind;
|
|
96
96
|
exports.lazy = lazy.lazy;
|
|
97
|
-
exports.
|
|
97
|
+
exports.lazyKind = lazy.lazyKind;
|
|
98
98
|
exports.unknown = unknown.unknown;
|
|
99
|
-
exports.
|
|
99
|
+
exports.unknownKind = unknown.unknownKind;
|
|
100
100
|
exports.record = record.record;
|
|
101
|
+
exports.recordKind = record.recordKind;
|
|
101
102
|
exports.extended = index;
|
|
103
|
+
exports.identifier = identifier.identifier;
|
|
102
104
|
exports.checkerUrl = url.checkerUrl;
|
|
103
105
|
exports.dataParserCheckerUrlKind = url.dataParserCheckerUrlKind;
|
|
104
106
|
exports.url = url.url;
|