@duplojs/data-parser-tools 0.2.7 → 0.2.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/toJsonSchema/transformer/defaults/record.cjs +3 -3
- package/dist/toJsonSchema/transformer/defaults/record.mjs +4 -4
- package/dist/toJsonSchema/transformer/defaults/templateLiteral.cjs +1 -1
- package/dist/toJsonSchema/transformer/defaults/templateLiteral.mjs +2 -2
- package/dist/toJsonSchema/transformer/transformer.cjs +6 -2
- package/dist/toJsonSchema/transformer/transformer.mjs +7 -3
- package/dist/toTypescript/index.cjs +2 -0
- package/dist/toTypescript/index.mjs +1 -0
- package/dist/toTypescript/render.cjs +1 -1
- package/dist/toTypescript/render.mjs +2 -2
- package/dist/toTypescript/transformer/defaults/index.cjs +1 -0
- package/dist/toTypescript/transformer/defaults/index.d.ts +1 -0
- package/dist/toTypescript/transformer/defaults/index.mjs +1 -1
- package/dist/toTypescript/transformer/defaults/literal.cjs +1 -1
- package/dist/toTypescript/transformer/defaults/literal.mjs +1 -1
- package/dist/toTypescript/transformer/defaults/nullable.cjs +1 -1
- package/dist/toTypescript/transformer/defaults/nullable.mjs +1 -1
- package/dist/toTypescript/transformer/transformer.cjs +6 -2
- package/dist/toTypescript/transformer/transformer.mjs +7 -3
- package/dist/utils/getRecursiveDataParser.cjs +11 -1
- package/dist/utils/getRecursiveDataParser.mjs +11 -1
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var utils = require('@duplojs/utils');
|
|
4
4
|
var create = require('../create.cjs');
|
|
5
5
|
|
|
6
|
-
const recordTransformer = create.createTransformer(utils.DP.recordKind.has, ({ definition: { key, value,
|
|
6
|
+
const recordTransformer = create.createTransformer(utils.DP.recordKind.has, ({ definition: { key, value, baseData } }, { transformer, success, }) => {
|
|
7
7
|
const keyResult = transformer(key);
|
|
8
8
|
if (utils.E.isLeft(keyResult)) {
|
|
9
9
|
return keyResult;
|
|
@@ -14,7 +14,8 @@ const recordTransformer = create.createTransformer(utils.DP.recordKind.has, ({ d
|
|
|
14
14
|
}
|
|
15
15
|
const keySchema = utils.unwrap(keyResult).schema;
|
|
16
16
|
const valueSchema = utils.unwrap(valueResult).schema;
|
|
17
|
-
|
|
17
|
+
const requireKey = utils.O.keys(baseData);
|
|
18
|
+
if (utils.A.minElements(requireKey, 1)) {
|
|
18
19
|
const properties = utils.A.reduce(requireKey, utils.A.reduceFrom({}), ({ element, lastValue, nextWithObject }) => nextWithObject(lastValue, { [element]: valueSchema }));
|
|
19
20
|
return success({
|
|
20
21
|
type: "object",
|
|
@@ -23,7 +24,6 @@ const recordTransformer = create.createTransformer(utils.DP.recordKind.has, ({ d
|
|
|
23
24
|
additionalProperties: false,
|
|
24
25
|
propertyNames: { enum: requireKey },
|
|
25
26
|
minProperties: requireKey.length,
|
|
26
|
-
maxProperties: requireKey.length,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
return success({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DP, E, unwrap, A } from '@duplojs/utils';
|
|
1
|
+
import { DP, E, unwrap, O, A } from '@duplojs/utils';
|
|
2
2
|
import { createTransformer } from '../create.mjs';
|
|
3
3
|
|
|
4
|
-
const recordTransformer = createTransformer(DP.recordKind.has, ({ definition: { key, value,
|
|
4
|
+
const recordTransformer = createTransformer(DP.recordKind.has, ({ definition: { key, value, baseData } }, { transformer, success, }) => {
|
|
5
5
|
const keyResult = transformer(key);
|
|
6
6
|
if (E.isLeft(keyResult)) {
|
|
7
7
|
return keyResult;
|
|
@@ -12,7 +12,8 @@ const recordTransformer = createTransformer(DP.recordKind.has, ({ definition: {
|
|
|
12
12
|
}
|
|
13
13
|
const keySchema = unwrap(keyResult).schema;
|
|
14
14
|
const valueSchema = unwrap(valueResult).schema;
|
|
15
|
-
|
|
15
|
+
const requireKey = O.keys(baseData);
|
|
16
|
+
if (A.minElements(requireKey, 1)) {
|
|
16
17
|
const properties = A.reduce(requireKey, A.reduceFrom({}), ({ element, lastValue, nextWithObject }) => nextWithObject(lastValue, { [element]: valueSchema }));
|
|
17
18
|
return success({
|
|
18
19
|
type: "object",
|
|
@@ -21,7 +22,6 @@ const recordTransformer = createTransformer(DP.recordKind.has, ({ definition: {
|
|
|
21
22
|
additionalProperties: false,
|
|
22
23
|
propertyNames: { enum: requireKey },
|
|
23
24
|
minProperties: requireKey.length,
|
|
24
|
-
maxProperties: requireKey.length,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
return success({
|
|
@@ -5,7 +5,7 @@ var create = require('../create.cjs');
|
|
|
5
5
|
|
|
6
6
|
const templateLiteralTransformer = create.createTransformer(utils.DP.templateLiteralKind.has, (schema, { success, transformer, }) => {
|
|
7
7
|
const result = utils.DP.findRecordRequiredKeyOnTemplateLiteralPart(schema.definition.template);
|
|
8
|
-
if (result) {
|
|
8
|
+
if (utils.A.minElements(result, 1)) {
|
|
9
9
|
return transformer(utils.DP.literal(result));
|
|
10
10
|
}
|
|
11
11
|
return success({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DP } from '@duplojs/utils';
|
|
1
|
+
import { DP, A } from '@duplojs/utils';
|
|
2
2
|
import { createTransformer } from '../create.mjs';
|
|
3
3
|
|
|
4
4
|
const templateLiteralTransformer = createTransformer(DP.templateLiteralKind.has, (schema, { success, transformer, }) => {
|
|
5
5
|
const result = DP.findRecordRequiredKeyOnTemplateLiteralPart(schema.definition.template);
|
|
6
|
-
if (result) {
|
|
6
|
+
if (A.minElements(result, 1)) {
|
|
7
7
|
return transformer(DP.literal(result));
|
|
8
8
|
}
|
|
9
9
|
return success({
|
|
@@ -36,14 +36,18 @@ function transformer(schema, params) {
|
|
|
36
36
|
isOptional: currentDeclaration.isOptional,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
const currentIdentifier = utils.
|
|
39
|
+
const currentIdentifier = utils.justExec(() => {
|
|
40
|
+
if (!utils.A.includes(params.recursiveDataParsers, currentSchema)
|
|
41
|
+
&& !currentSchema.definition.identifier) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
40
44
|
const identifier = currentSchema.definition.identifier ?? `RecursiveType${params.context.size}`;
|
|
41
45
|
params.context.set(currentSchema, {
|
|
42
46
|
name: identifier,
|
|
43
47
|
isOptional: false,
|
|
44
48
|
});
|
|
45
49
|
return identifier;
|
|
46
|
-
}
|
|
50
|
+
});
|
|
47
51
|
const functionParams = {
|
|
48
52
|
success(result, isOptional = false) {
|
|
49
53
|
return utils.E.right("buildSuccess", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, E,
|
|
1
|
+
import { A, E, justExec, unwrap } from '@duplojs/utils';
|
|
2
2
|
|
|
3
3
|
function buildRef(name, version) {
|
|
4
4
|
if (version === "openApi3"
|
|
@@ -34,14 +34,18 @@ function transformer(schema, params) {
|
|
|
34
34
|
isOptional: currentDeclaration.isOptional,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
const currentIdentifier =
|
|
37
|
+
const currentIdentifier = justExec(() => {
|
|
38
|
+
if (!A.includes(params.recursiveDataParsers, currentSchema)
|
|
39
|
+
&& !currentSchema.definition.identifier) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
38
42
|
const identifier = currentSchema.definition.identifier ?? `RecursiveType${params.context.size}`;
|
|
39
43
|
params.context.set(currentSchema, {
|
|
40
44
|
name: identifier,
|
|
41
45
|
isOptional: false,
|
|
42
46
|
});
|
|
43
47
|
return identifier;
|
|
44
|
-
}
|
|
48
|
+
});
|
|
45
49
|
const functionParams = {
|
|
46
50
|
success(result, isOptional = false) {
|
|
47
51
|
return E.right("buildSuccess", {
|
|
@@ -29,6 +29,7 @@ var union = require('./transformer/defaults/union.cjs');
|
|
|
29
29
|
var unknown = require('./transformer/defaults/unknown.cjs');
|
|
30
30
|
var date = require('./transformer/defaults/date.cjs');
|
|
31
31
|
var time = require('./transformer/defaults/time.cjs');
|
|
32
|
+
var file = require('./transformer/defaults/file.cjs');
|
|
32
33
|
var includesUndefinedTypeNode = require('./transformer/includesUndefinedTypeNode.cjs');
|
|
33
34
|
|
|
34
35
|
|
|
@@ -61,4 +62,5 @@ exports.unionTransformer = union.unionTransformer;
|
|
|
61
62
|
exports.unknownTransformer = unknown.unknownTransformer;
|
|
62
63
|
exports.dateTransformer = date.dateTransformer;
|
|
63
64
|
exports.timeTransformer = time.timeTransformer;
|
|
65
|
+
exports.fileTransformer = file.fileTransformer;
|
|
64
66
|
exports.includesUndefinedTypeNode = includesUndefinedTypeNode.includesUndefinedTypeNode;
|
|
@@ -27,4 +27,5 @@ export { unionTransformer } from './transformer/defaults/union.mjs';
|
|
|
27
27
|
export { unknownTransformer } from './transformer/defaults/unknown.mjs';
|
|
28
28
|
export { dateTransformer } from './transformer/defaults/date.mjs';
|
|
29
29
|
export { timeTransformer } from './transformer/defaults/time.mjs';
|
|
30
|
+
export { fileTransformer } from './transformer/defaults/file.mjs';
|
|
30
31
|
export { includesUndefinedTypeNode } from './transformer/includesUndefinedTypeNode.mjs';
|
|
@@ -43,7 +43,7 @@ function render(schema, params) {
|
|
|
43
43
|
return utils.pipe([
|
|
44
44
|
...importTypesTransformer.importTypesTransformer(importType),
|
|
45
45
|
...context.values(),
|
|
46
|
-
], utils.
|
|
46
|
+
], utils.A.map((value) => printer.printNode(typescript.EmitHint.Unspecified, value, sourceFile)), utils.A.join("\n\n"), utils.S.trim);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
exports.DataParserToTypescriptRenderError = DataParserToTypescriptRenderError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { kindHeritage, E, DP, unwrap, pipe,
|
|
1
|
+
import { kindHeritage, E, DP, unwrap, pipe, A, S } from '@duplojs/utils';
|
|
2
2
|
import './transformer/index.mjs';
|
|
3
3
|
import { factory, SyntaxKind, createSourceFile, ScriptTarget, ScriptKind, createPrinter, EmitHint } from 'typescript';
|
|
4
4
|
import { createToTypescriptKind } from './kind.mjs';
|
|
@@ -41,7 +41,7 @@ function render(schema, params) {
|
|
|
41
41
|
return pipe([
|
|
42
42
|
...importTypesTransformer(importType),
|
|
43
43
|
...context.values(),
|
|
44
|
-
],
|
|
44
|
+
], A.map((value) => printer.printNode(EmitHint.Unspecified, value, sourceFile)), A.join("\n\n"), S.trim);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export { DataParserToTypescriptRenderError, render };
|
|
@@ -72,4 +72,5 @@ exports.unionTransformer = union.unionTransformer;
|
|
|
72
72
|
exports.unknownTransformer = unknown.unknownTransformer;
|
|
73
73
|
exports.dateTransformer = date.dateTransformer;
|
|
74
74
|
exports.timeTransformer = time.timeTransformer;
|
|
75
|
+
exports.fileTransformer = file.fileTransformer;
|
|
75
76
|
exports.defaultTransformers = defaultTransformers;
|
|
@@ -20,4 +20,5 @@ export * from "./union";
|
|
|
20
20
|
export * from "./unknown";
|
|
21
21
|
export * from "./date";
|
|
22
22
|
export * from "./time";
|
|
23
|
+
export * from "./file";
|
|
23
24
|
export declare const defaultTransformers: readonly [(schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither, (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("..").TransformerParams) => import("..").MaybeTransformerEither];
|
|
@@ -48,4 +48,4 @@ const defaultTransformers = [
|
|
|
48
48
|
fileTransformer,
|
|
49
49
|
];
|
|
50
50
|
|
|
51
|
-
export { arrayTransformer, bigIntTransformer, booleanTransformer, dateTransformer, defaultTransformers, emptyTransformer, lazyTransformer, literalTransformer, nilTransformer, nullableTransformer, numberTransformer, objectTransformer, optionalTransformer, pipeTransformer, recordTransformer, recoverTransformer, stringTransformer, templateLiteralTransformer, timeTransformer, transformTransformer, tupleTransformer, unionTransformer, unknownTransformer };
|
|
51
|
+
export { arrayTransformer, bigIntTransformer, booleanTransformer, dateTransformer, defaultTransformers, emptyTransformer, fileTransformer, lazyTransformer, literalTransformer, nilTransformer, nullableTransformer, numberTransformer, objectTransformer, optionalTransformer, pipeTransformer, recordTransformer, recoverTransformer, stringTransformer, templateLiteralTransformer, timeTransformer, transformTransformer, tupleTransformer, unionTransformer, unknownTransformer };
|
|
@@ -11,6 +11,6 @@ const literalTransformer = create.createTransformer(utils.DP.literalKind.has, (s
|
|
|
11
11
|
.when(utils.isType("bigint"), (value) => typescript.factory.createLiteralTypeNode(typescript.factory.createBigIntLiteral(`${value}n`)))
|
|
12
12
|
.when(utils.isType("undefined"), () => typescript.factory.createKeywordTypeNode(typescript.SyntaxKind.UndefinedKeyword))
|
|
13
13
|
.when(utils.isType("null"), () => typescript.factory.createLiteralTypeNode(typescript.factory.createNull()))
|
|
14
|
-
.exhaustive()), typescript.factory.createUnionTypeNode, success));
|
|
14
|
+
.exhaustive()), utils.P.when(utils.A.lengthEqual(1), utils.A.at(0)), utils.P.otherwise(typescript.factory.createUnionTypeNode), success));
|
|
15
15
|
|
|
16
16
|
exports.literalTransformer = literalTransformer;
|
|
@@ -9,6 +9,6 @@ const literalTransformer = createTransformer(DP.literalKind.has, (schema, { succ
|
|
|
9
9
|
.when(isType("bigint"), (value) => factory.createLiteralTypeNode(factory.createBigIntLiteral(`${value}n`)))
|
|
10
10
|
.when(isType("undefined"), () => factory.createKeywordTypeNode(SyntaxKind.UndefinedKeyword))
|
|
11
11
|
.when(isType("null"), () => factory.createLiteralTypeNode(factory.createNull()))
|
|
12
|
-
.exhaustive()), factory.createUnionTypeNode, success));
|
|
12
|
+
.exhaustive()), P.when(A.lengthEqual(1), A.at(0)), P.otherwise(factory.createUnionTypeNode), success));
|
|
13
13
|
|
|
14
14
|
export { literalTransformer };
|
|
@@ -16,7 +16,7 @@ const nullableTransformer = create.createTransformer(utils.DP.nullableKind.has,
|
|
|
16
16
|
}, (value) => utils.P.match(value)
|
|
17
17
|
.with(utils.P.union({ mode: "in" }, {
|
|
18
18
|
mode: "out",
|
|
19
|
-
coalescingValue:
|
|
19
|
+
coalescingValue: null,
|
|
20
20
|
}), () => utils.pipe(typescript.factory.createNull(), typescript.factory.createLiteralTypeNode, (value) => typescript.factory.createUnionTypeNode([
|
|
21
21
|
innerType,
|
|
22
22
|
value,
|
|
@@ -14,7 +14,7 @@ const nullableTransformer = createTransformer(DP.nullableKind.has, (schema, { tr
|
|
|
14
14
|
}, (value) => P.match(value)
|
|
15
15
|
.with(P.union({ mode: "in" }, {
|
|
16
16
|
mode: "out",
|
|
17
|
-
coalescingValue:
|
|
17
|
+
coalescingValue: null,
|
|
18
18
|
}), () => pipe(factory.createNull(), factory.createLiteralTypeNode, (value) => factory.createUnionTypeNode([
|
|
19
19
|
innerType,
|
|
20
20
|
value,
|
|
@@ -25,11 +25,15 @@ function transformer(schema, params) {
|
|
|
25
25
|
if (currentDeclaration) {
|
|
26
26
|
return utils.E.right("buildSuccess", typescript.factory.createTypeReferenceNode(currentDeclaration.name));
|
|
27
27
|
}
|
|
28
|
-
const currentIdentifier = utils.
|
|
28
|
+
const currentIdentifier = utils.justExec(() => {
|
|
29
|
+
if (!utils.A.includes(params.recursiveDataParsers, currentSchema)
|
|
30
|
+
&& !currentSchema.definition.identifier) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
29
33
|
const identifier = currentSchema.definition.identifier ?? `RecursiveType${params.context.size}`;
|
|
30
34
|
params.context.set(currentSchema, typescript.factory.createTypeAliasDeclaration([typescript.factory.createToken(typescript.SyntaxKind.ExportKeyword)], typescript.factory.createIdentifier(identifier), undefined, typescript.factory.createTypeReferenceNode(identifier)));
|
|
31
35
|
return identifier;
|
|
32
|
-
}
|
|
36
|
+
});
|
|
33
37
|
const functionParams = {
|
|
34
38
|
success(result) {
|
|
35
39
|
return utils.E.right("buildSuccess", result);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, E,
|
|
1
|
+
import { A, E, justExec, unwrap } from '@duplojs/utils';
|
|
2
2
|
import { factory, SyntaxKind } from 'typescript';
|
|
3
3
|
|
|
4
4
|
function transformer(schema, params) {
|
|
@@ -23,11 +23,15 @@ function transformer(schema, params) {
|
|
|
23
23
|
if (currentDeclaration) {
|
|
24
24
|
return E.right("buildSuccess", factory.createTypeReferenceNode(currentDeclaration.name));
|
|
25
25
|
}
|
|
26
|
-
const currentIdentifier =
|
|
26
|
+
const currentIdentifier = justExec(() => {
|
|
27
|
+
if (!A.includes(params.recursiveDataParsers, currentSchema)
|
|
28
|
+
&& !currentSchema.definition.identifier) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
27
31
|
const identifier = currentSchema.definition.identifier ?? `RecursiveType${params.context.size}`;
|
|
28
32
|
params.context.set(currentSchema, factory.createTypeAliasDeclaration([factory.createToken(SyntaxKind.ExportKeyword)], factory.createIdentifier(identifier), undefined, factory.createTypeReferenceNode(identifier)));
|
|
29
33
|
return identifier;
|
|
30
|
-
}
|
|
34
|
+
});
|
|
31
35
|
const functionParams = {
|
|
32
36
|
success(result) {
|
|
33
37
|
return E.right("buildSuccess", result);
|
|
@@ -26,7 +26,17 @@ function getRecursiveDataParser(schema) {
|
|
|
26
26
|
utils.DP.recoverKind,
|
|
27
27
|
utils.DP.transformKind,
|
|
28
28
|
]), (dataParser) => void countDataParser(dataParser.definition.inner))
|
|
29
|
-
.when(utils.DP.lazyKind.has, (dataParser) =>
|
|
29
|
+
.when(utils.DP.lazyKind.has, (dataParser) => {
|
|
30
|
+
const count = (countMap.get(dataParser) ?? 0) + 1;
|
|
31
|
+
countMap.set(dataParser, count);
|
|
32
|
+
if (count > 1) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
countDataParser(dataParser.definition.getter.value);
|
|
36
|
+
if (countMap.get(dataParser) === 1) {
|
|
37
|
+
countMap.delete(dataParser);
|
|
38
|
+
}
|
|
39
|
+
})
|
|
30
40
|
.when(utils.DP.pipeKind.has, (dataParser) => {
|
|
31
41
|
countDataParser(dataParser.definition.input);
|
|
32
42
|
countDataParser(dataParser.definition.output);
|
|
@@ -24,7 +24,17 @@ function getRecursiveDataParser(schema) {
|
|
|
24
24
|
DP.recoverKind,
|
|
25
25
|
DP.transformKind,
|
|
26
26
|
]), (dataParser) => void countDataParser(dataParser.definition.inner))
|
|
27
|
-
.when(DP.lazyKind.has, (dataParser) =>
|
|
27
|
+
.when(DP.lazyKind.has, (dataParser) => {
|
|
28
|
+
const count = (countMap.get(dataParser) ?? 0) + 1;
|
|
29
|
+
countMap.set(dataParser, count);
|
|
30
|
+
if (count > 1) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
countDataParser(dataParser.definition.getter.value);
|
|
34
|
+
if (countMap.get(dataParser) === 1) {
|
|
35
|
+
countMap.delete(dataParser);
|
|
36
|
+
}
|
|
37
|
+
})
|
|
28
38
|
.when(DP.pipeKind.has, (dataParser) => {
|
|
29
39
|
countDataParser(dataParser.definition.input);
|
|
30
40
|
countDataParser(dataParser.definition.output);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/data-parser-tools",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "duplojs",
|
|
6
6
|
"contributors": [
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vitest": "3.2.4"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@duplojs/utils": ">=1.5.
|
|
74
|
+
"@duplojs/utils": ">=1.5.12 <2.0.0",
|
|
75
75
|
"@duplojs/server-utils": ">=0.1.4 < 1.0.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|