@miroir-framework/jzod-ts 0.8.2 → 0.8.3
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/index.cjs +14 -4
- package/dist/index.js +15 -5
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -53,14 +53,20 @@ module.exports = __toCommonJS(index_exports);
|
|
|
53
53
|
// src/JzodToTs.ts
|
|
54
54
|
var import_zod_to_ts = require("zod-to-ts");
|
|
55
55
|
var import_jzod = require("@miroir-framework/jzod");
|
|
56
|
+
var typeScriptLazyReferenceConverter = (innerReference, relativeReference) => (0, import_zod_to_ts.withGetType)(innerReference, (ts) => {
|
|
57
|
+
const actualTypeName = relativeReference ? relativeReference.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
|
58
|
+
return ts.factory.createTypeReferenceNode(
|
|
59
|
+
ts.factory.createIdentifier(actualTypeName ?? "RELATIVEPATH_NOT_DEFINED"),
|
|
60
|
+
void 0
|
|
61
|
+
);
|
|
62
|
+
});
|
|
56
63
|
function jzodToZodTextAndZodSchemaForTsGeneration(element, context = {}) {
|
|
57
64
|
const contextFunction = () => context;
|
|
58
65
|
const elementZodSchemaAndDescription = (0, import_jzod.jzodToZodTextAndZodSchema)(
|
|
59
66
|
element,
|
|
60
67
|
contextFunction,
|
|
61
68
|
contextFunction,
|
|
62
|
-
{
|
|
63
|
-
// typeScriptGeneration
|
|
69
|
+
{ typeScriptLazyConverter: typeScriptLazyReferenceConverter }
|
|
64
70
|
);
|
|
65
71
|
return elementZodSchemaAndDescription;
|
|
66
72
|
}
|
|
@@ -135,10 +141,14 @@ function jzodToZodTextAndTsTypeAliases(element, context = {}, typeName) {
|
|
|
135
141
|
}
|
|
136
142
|
function jzodToTsCode(typeName, jzodElement2, context = {}, exportPrefix = true, headerForZodImports = true, typeAnotationForSchema = [], extendedTsTypesText = "") {
|
|
137
143
|
console.log(
|
|
138
|
-
"###################################
|
|
144
|
+
"################################### jzodToTsCodeeeeeeee typeName",
|
|
139
145
|
typeName,
|
|
140
146
|
"jzodElement",
|
|
141
|
-
jzodElement2 && jzodElement2.context ? JSON.stringify(
|
|
147
|
+
jzodElement2 && jzodElement2.context ? JSON.stringify(
|
|
148
|
+
Object.entries(jzodElement2.context).map(([key, value]) => [key, !value]).map(([key, value]) => key + ": " + value),
|
|
149
|
+
null,
|
|
150
|
+
2
|
|
151
|
+
) : void 0
|
|
142
152
|
);
|
|
143
153
|
const schemaName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toLowerCase() + c) : "";
|
|
144
154
|
const actualTypeName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
package/dist/index.js
CHANGED
|
@@ -6,18 +6,24 @@ const __dirname = dirname(__filename)
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// src/JzodToTs.ts
|
|
9
|
-
import { createTypeAlias, printNode, zodToTs } from "zod-to-ts";
|
|
9
|
+
import { createTypeAlias, printNode, withGetType, zodToTs } from "zod-to-ts";
|
|
10
10
|
import {
|
|
11
11
|
jzodToZodTextAndZodSchema
|
|
12
12
|
} from "@miroir-framework/jzod";
|
|
13
|
+
var typeScriptLazyReferenceConverter = (innerReference, relativeReference) => withGetType(innerReference, (ts) => {
|
|
14
|
+
const actualTypeName = relativeReference ? relativeReference.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
|
15
|
+
return ts.factory.createTypeReferenceNode(
|
|
16
|
+
ts.factory.createIdentifier(actualTypeName ?? "RELATIVEPATH_NOT_DEFINED"),
|
|
17
|
+
void 0
|
|
18
|
+
);
|
|
19
|
+
});
|
|
13
20
|
function jzodToZodTextAndZodSchemaForTsGeneration(element, context = {}) {
|
|
14
21
|
const contextFunction = () => context;
|
|
15
22
|
const elementZodSchemaAndDescription = jzodToZodTextAndZodSchema(
|
|
16
23
|
element,
|
|
17
24
|
contextFunction,
|
|
18
25
|
contextFunction,
|
|
19
|
-
{
|
|
20
|
-
// typeScriptGeneration
|
|
26
|
+
{ typeScriptLazyConverter: typeScriptLazyReferenceConverter }
|
|
21
27
|
);
|
|
22
28
|
return elementZodSchemaAndDescription;
|
|
23
29
|
}
|
|
@@ -92,10 +98,14 @@ function jzodToZodTextAndTsTypeAliases(element, context = {}, typeName) {
|
|
|
92
98
|
}
|
|
93
99
|
function jzodToTsCode(typeName, jzodElement2, context = {}, exportPrefix = true, headerForZodImports = true, typeAnotationForSchema = [], extendedTsTypesText = "") {
|
|
94
100
|
console.log(
|
|
95
|
-
"###################################
|
|
101
|
+
"################################### jzodToTsCodeeeeeeee typeName",
|
|
96
102
|
typeName,
|
|
97
103
|
"jzodElement",
|
|
98
|
-
jzodElement2 && jzodElement2.context ? JSON.stringify(
|
|
104
|
+
jzodElement2 && jzodElement2.context ? JSON.stringify(
|
|
105
|
+
Object.entries(jzodElement2.context).map(([key, value]) => [key, !value]).map(([key, value]) => key + ": " + value),
|
|
106
|
+
null,
|
|
107
|
+
2
|
|
108
|
+
) : void 0
|
|
99
109
|
);
|
|
100
110
|
const schemaName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toLowerCase() + c) : "";
|
|
101
111
|
const actualTypeName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miroir-framework/jzod-ts",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"description": "The Typescript-related functionalities of Jzod.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
"test": "cross-env NODE_ENV=test vitest run --poolOptions.threads.singleThread --passWithNoTests -t"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@miroir-framework/jzod": "0.8.
|
|
39
|
+
"@miroir-framework/jzod": "0.8.3",
|
|
40
40
|
"zod": "^3.24.2",
|
|
41
41
|
"zod-to-ts": "^1.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.6.0",
|
|
44
45
|
"path": "^0.12.7",
|
|
45
46
|
"tsconfig-paths": "^4.1.2",
|
|
46
47
|
"tsup": "^8.4.0",
|