@liase/cli 1.0.1 → 1.0.2
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/lib/zod.d.ts +7 -6
- package/dist/lib/zod.d.ts.map +1 -1
- package/dist/lib/zod.js +31 -31
- package/package.json +8 -8
package/dist/lib/zod.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
type Primitive = string | number | boolean | null | undefined | bigint | symbol;
|
|
2
3
|
type SimpleSchema = ({
|
|
3
4
|
type: "string";
|
|
4
5
|
default?: string;
|
|
5
|
-
checks?:
|
|
6
|
+
checks?: unknown[];
|
|
6
7
|
} | {
|
|
7
8
|
type: "number";
|
|
8
9
|
default?: number;
|
|
9
|
-
checks?:
|
|
10
|
+
checks?: unknown[];
|
|
10
11
|
} | {
|
|
11
12
|
type: "boolean";
|
|
12
13
|
default?: boolean;
|
|
13
14
|
} | {
|
|
14
15
|
type: "date";
|
|
15
16
|
default?: Date | string;
|
|
16
|
-
checks?:
|
|
17
|
+
checks?: unknown[];
|
|
17
18
|
} | {
|
|
18
19
|
type: "object";
|
|
19
20
|
children: {
|
|
@@ -40,11 +41,11 @@ type SimpleSchema = ({
|
|
|
40
41
|
} | {
|
|
41
42
|
type: "other" | "undefined";
|
|
42
43
|
default?: unknown;
|
|
43
|
-
zodTypeName:
|
|
44
|
+
zodTypeName: string;
|
|
44
45
|
}) & {
|
|
45
46
|
optional?: boolean;
|
|
46
47
|
description?: string;
|
|
47
48
|
};
|
|
48
|
-
export declare function zodSchemaToSimpleSchema(zodSchema:
|
|
49
|
+
export declare function zodSchemaToSimpleSchema(zodSchema: z.ZodType): SimpleSchema;
|
|
49
50
|
export {};
|
|
50
51
|
//# sourceMappingURL=zod.d.ts.map
|
package/dist/lib/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/lib/zod.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/lib/zod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhF,KAAK,YAAY,GAAG,CAChB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAC;IAC1C,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACtC,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB,GACD;IACE,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IAC9D,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB,GACD;IACE,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CACJ,GAAG;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAyEF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,GAAG,YAAY,CAuL1E"}
|
package/dist/lib/zod.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function isZodType(
|
|
2
|
+
// biome-ignore lint/suspicious/noExplicitAny: Must accept any Zod type including future/external versions
|
|
3
|
+
zodSchema, type) {
|
|
3
4
|
return zodSchema?.constructor?.name === type;
|
|
4
5
|
}
|
|
5
6
|
export function zodSchemaToSimpleSchema(zodSchema) {
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: _def is internal Zod API that varies between versions
|
|
8
|
+
const def = zodSchema._def;
|
|
6
9
|
let simpleSchema;
|
|
7
|
-
const zodTypeName = zodSchema.
|
|
8
|
-
const description = zodSchema.
|
|
10
|
+
const zodTypeName = zodSchema.constructor.name;
|
|
11
|
+
const description = zodSchema.description;
|
|
9
12
|
const defaultProps = {
|
|
10
13
|
...(description ? { description } : {}),
|
|
11
14
|
};
|
|
@@ -17,13 +20,13 @@ export function zodSchemaToSimpleSchema(zodSchema) {
|
|
|
17
20
|
type: "object",
|
|
18
21
|
children: {},
|
|
19
22
|
};
|
|
20
|
-
for (const [name, zodType] of Object.entries(
|
|
23
|
+
for (const [name, zodType] of Object.entries(def.shape)) {
|
|
21
24
|
simpleSchema.children[name] = zodSchemaToSimpleSchema(zodType);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
else if (isZodType(zodSchema, "ZodIntersection")) {
|
|
25
|
-
const left = zodSchemaToSimpleSchema(
|
|
26
|
-
const right = zodSchemaToSimpleSchema(
|
|
28
|
+
const left = zodSchemaToSimpleSchema(def.left);
|
|
29
|
+
const right = zodSchemaToSimpleSchema(def.right);
|
|
27
30
|
simpleSchema = {
|
|
28
31
|
...defaultProps,
|
|
29
32
|
type: "object",
|
|
@@ -34,19 +37,19 @@ export function zodSchemaToSimpleSchema(zodSchema) {
|
|
|
34
37
|
simpleSchema = {
|
|
35
38
|
...defaultProps,
|
|
36
39
|
type: "array",
|
|
37
|
-
children: zodSchemaToSimpleSchema(
|
|
40
|
+
children: zodSchemaToSimpleSchema(def.element),
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
else if (isZodType(zodSchema, "ZodSet")) {
|
|
41
44
|
simpleSchema = {
|
|
42
45
|
...defaultProps,
|
|
43
46
|
type: "array",
|
|
44
|
-
children: zodSchemaToSimpleSchema(
|
|
47
|
+
children: zodSchemaToSimpleSchema(def.valueType),
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
50
|
else if (isZodType(zodSchema, "ZodUnion") ||
|
|
48
51
|
isZodType(zodSchema, "ZodDiscriminatedUnion")) {
|
|
49
|
-
const zodTypesInUnion =
|
|
52
|
+
const zodTypesInUnion = def.options;
|
|
50
53
|
const simpleSchemaTypesInUnion = zodTypesInUnion.map(zodSchemaToSimpleSchema);
|
|
51
54
|
simpleSchema = { ...defaultProps, type: simpleSchemaTypesInUnion };
|
|
52
55
|
const unionIncludesUndefined = simpleSchemaTypesInUnion.some((schema) => schema.type === "other" && schema.zodTypeName === "ZodUndefined");
|
|
@@ -57,34 +60,34 @@ export function zodSchemaToSimpleSchema(zodSchema) {
|
|
|
57
60
|
else if (isZodType(zodSchema, "ZodOptional")) {
|
|
58
61
|
simpleSchema = {
|
|
59
62
|
...defaultProps,
|
|
60
|
-
...zodSchemaToSimpleSchema(
|
|
63
|
+
...zodSchemaToSimpleSchema(def.innerType),
|
|
61
64
|
optional: true,
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
else if (isZodType(zodSchema, "ZodString")) {
|
|
65
68
|
simpleSchema = { ...defaultProps, type: "string" };
|
|
66
|
-
if (
|
|
67
|
-
simpleSchema.checks =
|
|
69
|
+
if (def.checks.length)
|
|
70
|
+
simpleSchema.checks = def.checks;
|
|
68
71
|
}
|
|
69
72
|
else if (isZodType(zodSchema, "ZodNumber") ||
|
|
70
73
|
isZodType(zodSchema, "ZodBigInt")) {
|
|
71
74
|
simpleSchema = { ...defaultProps, type: "number" };
|
|
72
|
-
if (
|
|
73
|
-
simpleSchema.checks =
|
|
75
|
+
if (def.checks.length)
|
|
76
|
+
simpleSchema.checks = def.checks;
|
|
74
77
|
}
|
|
75
78
|
else if (isZodType(zodSchema, "ZodBoolean")) {
|
|
76
79
|
simpleSchema = { ...defaultProps, type: "boolean" };
|
|
77
80
|
}
|
|
78
81
|
else if (isZodType(zodSchema, "ZodDate")) {
|
|
79
82
|
simpleSchema = { ...defaultProps, type: "date" };
|
|
80
|
-
if (
|
|
81
|
-
simpleSchema.checks =
|
|
83
|
+
if (def.checks.length)
|
|
84
|
+
simpleSchema.checks = def.checks;
|
|
82
85
|
}
|
|
83
86
|
else if (isZodType(zodSchema, "ZodNull")) {
|
|
84
87
|
simpleSchema = { ...defaultProps, type: "null" };
|
|
85
88
|
}
|
|
86
89
|
else if (isZodType(zodSchema, "ZodLiteral")) {
|
|
87
|
-
const value =
|
|
90
|
+
const value = def.values[0];
|
|
88
91
|
let valueType;
|
|
89
92
|
if (typeof value === "string") {
|
|
90
93
|
valueType = "string";
|
|
@@ -109,21 +112,21 @@ export function zodSchemaToSimpleSchema(zodSchema) {
|
|
|
109
112
|
};
|
|
110
113
|
}
|
|
111
114
|
else if (isZodType(zodSchema, "ZodEnum")) {
|
|
112
|
-
const enumValues =
|
|
115
|
+
const enumValues = Object.keys(def.entries);
|
|
113
116
|
simpleSchema = {
|
|
114
117
|
...defaultProps,
|
|
115
118
|
type: enumValues.map((enumValue) => ({
|
|
116
119
|
type: "literal",
|
|
117
120
|
value: enumValue,
|
|
118
121
|
valueType: "string",
|
|
119
|
-
zodTypeName:
|
|
122
|
+
zodTypeName: "ZodLiteral",
|
|
120
123
|
})),
|
|
121
124
|
};
|
|
122
125
|
}
|
|
123
126
|
else if (isZodType(zodSchema, "ZodEffects")) {
|
|
124
127
|
simpleSchema = {
|
|
125
128
|
...defaultProps,
|
|
126
|
-
...zodSchemaToSimpleSchema(
|
|
129
|
+
...zodSchemaToSimpleSchema(def.schema),
|
|
127
130
|
};
|
|
128
131
|
}
|
|
129
132
|
else if (isZodType(zodSchema, "ZodNativeEnum")) {
|
|
@@ -132,35 +135,32 @@ export function zodSchemaToSimpleSchema(zodSchema) {
|
|
|
132
135
|
else if (isZodType(zodSchema, "ZodNullable")) {
|
|
133
136
|
simpleSchema = {
|
|
134
137
|
...defaultProps,
|
|
135
|
-
type: [
|
|
136
|
-
zodSchemaToSimpleSchema(zodSchema._def.innerType),
|
|
137
|
-
{ type: "null" },
|
|
138
|
-
],
|
|
138
|
+
type: [zodSchemaToSimpleSchema(def.innerType), { type: "null" }],
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
else if (isZodType(zodSchema, "ZodDefault")) {
|
|
142
142
|
simpleSchema = {
|
|
143
143
|
...defaultProps,
|
|
144
|
-
...zodSchemaToSimpleSchema(
|
|
145
|
-
default:
|
|
144
|
+
...zodSchemaToSimpleSchema(def.innerType),
|
|
145
|
+
default: def.defaultValue,
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
else if (isZodType(zodSchema, "ZodCatch")) {
|
|
149
149
|
simpleSchema = {
|
|
150
150
|
...defaultProps,
|
|
151
|
-
...zodSchemaToSimpleSchema(
|
|
151
|
+
...zodSchemaToSimpleSchema(def.innerType),
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
else if (isZodType(zodSchema, "ZodBranded")) {
|
|
155
155
|
simpleSchema = {
|
|
156
156
|
...defaultProps,
|
|
157
|
-
...zodSchemaToSimpleSchema(
|
|
157
|
+
...zodSchemaToSimpleSchema(def.innerType ?? def.type),
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
else if (isZodType(zodSchema, "ZodPipeline")) {
|
|
161
161
|
simpleSchema = {
|
|
162
162
|
...defaultProps,
|
|
163
|
-
...zodSchemaToSimpleSchema(
|
|
163
|
+
...zodSchemaToSimpleSchema(def.in),
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
else if (isZodType(zodSchema, "ZodAny") ||
|
|
@@ -185,7 +185,7 @@ export function zodSchemaToSimpleSchema(zodSchema) {
|
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
else {
|
|
188
|
-
zodSchema; // Ensure we have a case for every type
|
|
188
|
+
zodSchema; // Ensure we have a case for every Zod type
|
|
189
189
|
simpleSchema = {
|
|
190
190
|
...defaultProps,
|
|
191
191
|
type: "other",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liase/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,21 +30,21 @@
|
|
|
30
30
|
"homepage": "https://github.com/callumgare/liase#readme",
|
|
31
31
|
"description": "",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@loopback/http-caching-proxy": "^
|
|
33
|
+
"@loopback/http-caching-proxy": "^6.0.14",
|
|
34
34
|
"@refactorjs/http-proxy": "^0.2.14",
|
|
35
|
-
"@types/mime-types": "^
|
|
35
|
+
"@types/mime-types": "^3.0.1",
|
|
36
36
|
"ansi-to-html": "^0.7.2",
|
|
37
|
-
"commander": "^
|
|
38
|
-
"mime-types": "^
|
|
39
|
-
"open": "^
|
|
40
|
-
"zod": "^
|
|
37
|
+
"commander": "^14.0.3",
|
|
38
|
+
"mime-types": "^3.0.2",
|
|
39
|
+
"open": "^11.0.0",
|
|
40
|
+
"zod": "^4.4.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@tsconfig/node21": "^21.0.3",
|
|
44
44
|
"semantic-release": "^25.0.3",
|
|
45
45
|
"semantic-release-monorepo": "^8.0.2",
|
|
46
46
|
"tsx": "^4.19.2",
|
|
47
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^6.0.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@liase/core": "*"
|