@mxpicture/zod-meta 0.1.7 → 0.1.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/package.json +6 -3
- package/dist/cjs/Meta.js +0 -13
- package/dist/cjs/common.js +0 -243
- package/dist/cjs/index.js +0 -42
- package/dist/cjs/lib.js +0 -19
- package/dist/cjs/package.js +0 -21
- package/dist/cjs/types.js +0 -43
- package/dist/esm/Meta.js +0 -13
- package/dist/esm/common.js +0 -243
- package/dist/esm/index.js +0 -42
- package/dist/esm/lib.js +0 -19
- package/dist/esm/package.js +0 -21
- package/dist/esm/types.js +0 -43
- package/dist/types/Meta.d.ts +0 -7
- package/dist/types/common.d.ts +0 -14
- package/dist/types/index.d.ts +0 -3
- package/dist/types/lib.d.ts +0 -3
- package/dist/types/package.d.ts +0 -1
- package/dist/types/types.d.ts +0 -140
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/zod-meta",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Zod Metadata Extraction, publishing both CommonJS and ESM builds",
|
|
5
5
|
"author": "MXPicture",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"dist/"
|
|
29
29
|
],
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": "
|
|
31
|
+
"node": ">=22"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"commit": "git-cz",
|
|
35
|
-
"
|
|
35
|
+
"postinstall": "husky install",
|
|
36
36
|
"clean": "rm -rf dist .tsbuildinfo",
|
|
37
37
|
"build:types": "tsc -p tsconfig.types.json",
|
|
38
38
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"path": "./node_modules/cz-conventional-changelog"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
49
52
|
"dependencies": {
|
|
50
53
|
"zod": "^4.3.5"
|
|
51
54
|
},
|
package/dist/cjs/Meta.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Meta = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
5
|
-
class Meta {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
this.props = props;
|
|
8
|
-
}
|
|
9
|
-
items() {
|
|
10
|
-
return (0, common_1.metaItems)(this.props);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.Meta = Meta;
|
package/dist/cjs/common.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.metaItems = exports.castEnum = exports.castOptional = exports.castRecord = exports.castObject = exports.castArray = exports.castDate = exports.castInt = exports.castNumber = exports.castString = exports.castBool = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
const castType = (type, prop) => (prop._zod.def.type === type ? prop : undefined);
|
|
6
|
-
const castBool = (p) => castType(types_1.MetaType.boolean, p);
|
|
7
|
-
exports.castBool = castBool;
|
|
8
|
-
const castString = (p) => castType(types_1.MetaType.string, p);
|
|
9
|
-
exports.castString = castString;
|
|
10
|
-
const castNumber = (p) => castType(types_1.MetaType.number, p);
|
|
11
|
-
exports.castNumber = castNumber;
|
|
12
|
-
const castInt = (p) => castType(types_1.MetaType.int, p);
|
|
13
|
-
exports.castInt = castInt;
|
|
14
|
-
const castDate = (p) => castType(types_1.MetaType.date, p);
|
|
15
|
-
exports.castDate = castDate;
|
|
16
|
-
const castArray = (p) => castType(types_1.MetaType.array, p);
|
|
17
|
-
exports.castArray = castArray;
|
|
18
|
-
const castObject = (p) => castType(types_1.MetaType.object, p);
|
|
19
|
-
exports.castObject = castObject;
|
|
20
|
-
const castRecord = (p) => castType(types_1.MetaType.record, p);
|
|
21
|
-
exports.castRecord = castRecord;
|
|
22
|
-
const castOptional = (p) => castType(types_1.MetaInternalType.optional, p);
|
|
23
|
-
exports.castOptional = castOptional;
|
|
24
|
-
const castEnum = (p) => castType(types_1.MetaType.enum, p);
|
|
25
|
-
exports.castEnum = castEnum;
|
|
26
|
-
const metaFunctions = {
|
|
27
|
-
boolean: (name, _prop, optional) => {
|
|
28
|
-
const prop = (0, exports.castBool)(_prop);
|
|
29
|
-
if (!prop)
|
|
30
|
-
return;
|
|
31
|
-
const meta = prop.meta();
|
|
32
|
-
return {
|
|
33
|
-
boolean: {
|
|
34
|
-
name,
|
|
35
|
-
title: meta?.title,
|
|
36
|
-
description: meta?.description,
|
|
37
|
-
type: types_1.MetaType.boolean,
|
|
38
|
-
optional,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
string: (name, _prop, optional) => {
|
|
43
|
-
const prop = (0, exports.castString)(_prop);
|
|
44
|
-
if (!prop)
|
|
45
|
-
return;
|
|
46
|
-
const meta = prop.meta();
|
|
47
|
-
const checks = metaChecks(prop._zod.def);
|
|
48
|
-
return {
|
|
49
|
-
string: {
|
|
50
|
-
name,
|
|
51
|
-
title: meta?.title,
|
|
52
|
-
description: meta?.description,
|
|
53
|
-
type: types_1.MetaType.string,
|
|
54
|
-
minLength: checks.min_length?.minimum,
|
|
55
|
-
maxLength: checks.max_length?.maximum,
|
|
56
|
-
exactLength: checks.length_equals?.length,
|
|
57
|
-
regex: checks.regex?.pattern?.toString() ??
|
|
58
|
-
checks.string_format?.pattern?.toString(),
|
|
59
|
-
format: checks.regex?.format ?? checks.string_format?.format,
|
|
60
|
-
optional,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
number: (name, _prop, optional) => {
|
|
65
|
-
const prop = (0, exports.castNumber)(_prop);
|
|
66
|
-
if (!prop)
|
|
67
|
-
return;
|
|
68
|
-
const meta = prop.meta();
|
|
69
|
-
const checks = metaChecks(prop._zod.def);
|
|
70
|
-
return {
|
|
71
|
-
number: {
|
|
72
|
-
name,
|
|
73
|
-
title: meta?.title,
|
|
74
|
-
description: meta?.description,
|
|
75
|
-
type: types_1.MetaType.number,
|
|
76
|
-
minValue: checks.greater_than?.value,
|
|
77
|
-
minInclusive: checks.greater_than?.inclusive,
|
|
78
|
-
maxValue: checks.less_than?.value,
|
|
79
|
-
maxInclusive: checks.less_than?.inclusive,
|
|
80
|
-
multipleOf: checks.multiple_of?.value,
|
|
81
|
-
format: checks.number_format?.format,
|
|
82
|
-
optional,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
int: (name, _prop, optional) => {
|
|
87
|
-
const prop = (0, exports.castInt)(_prop);
|
|
88
|
-
if (!prop)
|
|
89
|
-
return;
|
|
90
|
-
const meta = prop.meta();
|
|
91
|
-
const checks = metaChecks(prop._zod.def);
|
|
92
|
-
return {
|
|
93
|
-
int: {
|
|
94
|
-
name,
|
|
95
|
-
title: meta?.title,
|
|
96
|
-
description: meta?.description,
|
|
97
|
-
type: types_1.MetaType.int,
|
|
98
|
-
minValue: checks.greater_than?.value,
|
|
99
|
-
minInclusive: checks.greater_than?.inclusive,
|
|
100
|
-
maxValue: checks.less_than?.value,
|
|
101
|
-
maxInclusive: checks.less_than?.inclusive,
|
|
102
|
-
multipleOf: checks.multiple_of?.value,
|
|
103
|
-
format: checks.number_format?.format,
|
|
104
|
-
optional,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
date: (name, _prop, optional) => {
|
|
109
|
-
const prop = (0, exports.castDate)(_prop);
|
|
110
|
-
if (!prop)
|
|
111
|
-
return;
|
|
112
|
-
const meta = prop.meta();
|
|
113
|
-
return {
|
|
114
|
-
date: {
|
|
115
|
-
name,
|
|
116
|
-
title: meta?.title,
|
|
117
|
-
description: meta?.description,
|
|
118
|
-
type: types_1.MetaType.date,
|
|
119
|
-
optional,
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
array: (name, _prop, optional) => {
|
|
124
|
-
const prop = (0, exports.castArray)(_prop);
|
|
125
|
-
if (!prop)
|
|
126
|
-
return;
|
|
127
|
-
const meta = prop.meta();
|
|
128
|
-
const inner = prop.unwrap();
|
|
129
|
-
const checks = metaChecks(prop._zod.def);
|
|
130
|
-
return {
|
|
131
|
-
array: {
|
|
132
|
-
name,
|
|
133
|
-
title: meta?.title,
|
|
134
|
-
description: meta?.description,
|
|
135
|
-
type: types_1.MetaType.array,
|
|
136
|
-
item: metaItem(`${name}[]`, inner),
|
|
137
|
-
minLength: checks.min_length?.minimum,
|
|
138
|
-
maxLength: checks.max_length?.maximum,
|
|
139
|
-
exactLength: checks.length_equals?.length,
|
|
140
|
-
optional,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
record: (name, _prop, optional) => {
|
|
145
|
-
const prop = (0, exports.castRecord)(_prop);
|
|
146
|
-
if (!prop)
|
|
147
|
-
return;
|
|
148
|
-
const meta = prop.meta();
|
|
149
|
-
return {
|
|
150
|
-
record: {
|
|
151
|
-
name,
|
|
152
|
-
title: meta?.title,
|
|
153
|
-
description: meta?.description,
|
|
154
|
-
type: types_1.MetaType.record,
|
|
155
|
-
keyType: metaItem("keyType", prop.def.keyType),
|
|
156
|
-
valueType: metaItem("valueType", prop.def.valueType),
|
|
157
|
-
optional,
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
object: (name, _prop, optional) => {
|
|
162
|
-
const prop = (0, exports.castObject)(_prop);
|
|
163
|
-
if (!prop)
|
|
164
|
-
return;
|
|
165
|
-
const meta = prop.meta();
|
|
166
|
-
return {
|
|
167
|
-
object: {
|
|
168
|
-
name,
|
|
169
|
-
title: meta?.title,
|
|
170
|
-
description: meta?.description,
|
|
171
|
-
type: types_1.MetaType.object,
|
|
172
|
-
properties: (0, exports.metaItems)(prop.def.shape),
|
|
173
|
-
optional,
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
enum: (name, _prop, optional) => {
|
|
178
|
-
const prop = (0, exports.castEnum)(_prop);
|
|
179
|
-
if (!prop)
|
|
180
|
-
return;
|
|
181
|
-
const meta = prop.meta();
|
|
182
|
-
const entries = Object.entries(prop.def.entries).map(([key, value]) => {
|
|
183
|
-
const titles = Array.isArray(meta?.enumEntryTitles)
|
|
184
|
-
? meta.enumEntryTitles
|
|
185
|
-
: [];
|
|
186
|
-
return {
|
|
187
|
-
key,
|
|
188
|
-
value,
|
|
189
|
-
title: titles.find((t) => t.value === value)?.title,
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
return {
|
|
193
|
-
enum: {
|
|
194
|
-
name,
|
|
195
|
-
title: meta?.title,
|
|
196
|
-
description: meta?.description,
|
|
197
|
-
type: types_1.MetaType.enum,
|
|
198
|
-
entries,
|
|
199
|
-
optional,
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
optional: (name, _prop) => {
|
|
204
|
-
const prop = (0, exports.castOptional)(_prop);
|
|
205
|
-
if (!prop)
|
|
206
|
-
return;
|
|
207
|
-
const inner = prop.unwrap();
|
|
208
|
-
return metaItem(name, inner, true);
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
const metaCheck = (def) => {
|
|
212
|
-
const checks = {};
|
|
213
|
-
const found = types_1.MetaCheckTypeList.find((i) => i.value === def.check);
|
|
214
|
-
if (!found)
|
|
215
|
-
throw new Error(`Check type ${def.check} not supported`);
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
-
checks[found.value] = def;
|
|
218
|
-
return checks;
|
|
219
|
-
};
|
|
220
|
-
const metaChecks = (type) => {
|
|
221
|
-
let results = {};
|
|
222
|
-
const checks = type.def?.checks ??
|
|
223
|
-
type.checks ??
|
|
224
|
-
[];
|
|
225
|
-
for (const check of checks)
|
|
226
|
-
results = { ...results, ...metaCheck(check._zod.def) };
|
|
227
|
-
return results;
|
|
228
|
-
};
|
|
229
|
-
const metaItem = (name, prop, optional) => {
|
|
230
|
-
for (const f of Object.values(metaFunctions)) {
|
|
231
|
-
const item = f(name, prop, optional);
|
|
232
|
-
if (item)
|
|
233
|
-
return item;
|
|
234
|
-
}
|
|
235
|
-
throw new Error(`Property ${name} (${prop._zod.def.type}) failed`);
|
|
236
|
-
};
|
|
237
|
-
const metaItems = (props) => {
|
|
238
|
-
const items = [];
|
|
239
|
-
for (const [name, prop] of Object.entries(props))
|
|
240
|
-
items.push(metaItem(name, prop));
|
|
241
|
-
return items;
|
|
242
|
-
};
|
|
243
|
-
exports.metaItems = metaItems;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
__exportStar(require("./lib"), exports);
|
|
40
|
-
// A default export can help some consumers using require()
|
|
41
|
-
const _all = __importStar(require("./lib"));
|
|
42
|
-
exports.default = _all;
|
package/dist/cjs/lib.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Meta"), exports);
|
|
18
|
-
__exportStar(require("./common"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
package/dist/cjs/package.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
3
|
-
/// <reference path="./types/zod.d.ts" />
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
// Re-export your public types/exports so this file becomes the root .d.ts for the package.
|
|
20
|
-
// Adjust the relative path if your source layout differs.
|
|
21
|
-
__exportStar(require("./lib"), exports);
|
package/dist/cjs/types.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetaCheckTypeList = exports.MetaCheckType = exports.MetaInternalType = exports.MetaTypeList = exports.MetaType = void 0;
|
|
4
|
-
var MetaType;
|
|
5
|
-
(function (MetaType) {
|
|
6
|
-
MetaType["string"] = "string";
|
|
7
|
-
MetaType["number"] = "number";
|
|
8
|
-
MetaType["int"] = "int";
|
|
9
|
-
MetaType["date"] = "date";
|
|
10
|
-
MetaType["boolean"] = "boolean";
|
|
11
|
-
MetaType["array"] = "array";
|
|
12
|
-
MetaType["record"] = "record";
|
|
13
|
-
MetaType["object"] = "object";
|
|
14
|
-
MetaType["enum"] = "enum";
|
|
15
|
-
})(MetaType || (exports.MetaType = MetaType = {}));
|
|
16
|
-
exports.MetaTypeList = Object.entries(MetaType).map(([key, value]) => ({
|
|
17
|
-
key,
|
|
18
|
-
value,
|
|
19
|
-
}));
|
|
20
|
-
var MetaInternalType;
|
|
21
|
-
(function (MetaInternalType) {
|
|
22
|
-
MetaInternalType["optional"] = "optional";
|
|
23
|
-
})(MetaInternalType || (exports.MetaInternalType = MetaInternalType = {}));
|
|
24
|
-
var MetaCheckType;
|
|
25
|
-
(function (MetaCheckType) {
|
|
26
|
-
MetaCheckType["less_than"] = "less_than";
|
|
27
|
-
MetaCheckType["greater_than"] = "greater_than";
|
|
28
|
-
MetaCheckType["multiple_of"] = "multiple_of";
|
|
29
|
-
MetaCheckType["number_format"] = "number_format";
|
|
30
|
-
MetaCheckType["bigint_format"] = "bigint_format";
|
|
31
|
-
MetaCheckType["min_size"] = "min_size";
|
|
32
|
-
MetaCheckType["max_size"] = "max_size";
|
|
33
|
-
MetaCheckType["size_equals"] = "size_equals";
|
|
34
|
-
MetaCheckType["min_length"] = "min_length";
|
|
35
|
-
MetaCheckType["max_length"] = "max_length";
|
|
36
|
-
MetaCheckType["length_equals"] = "length_equals";
|
|
37
|
-
MetaCheckType["string_format"] = "string_format";
|
|
38
|
-
MetaCheckType["regex"] = "regex";
|
|
39
|
-
})(MetaCheckType || (exports.MetaCheckType = MetaCheckType = {}));
|
|
40
|
-
exports.MetaCheckTypeList = Object.entries(MetaCheckType).map(([key, value]) => ({
|
|
41
|
-
key,
|
|
42
|
-
value,
|
|
43
|
-
}));
|
package/dist/esm/Meta.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Meta = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
5
|
-
class Meta {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
this.props = props;
|
|
8
|
-
}
|
|
9
|
-
items() {
|
|
10
|
-
return (0, common_1.metaItems)(this.props);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.Meta = Meta;
|
package/dist/esm/common.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.metaItems = exports.castEnum = exports.castOptional = exports.castRecord = exports.castObject = exports.castArray = exports.castDate = exports.castInt = exports.castNumber = exports.castString = exports.castBool = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
const castType = (type, prop) => (prop._zod.def.type === type ? prop : undefined);
|
|
6
|
-
const castBool = (p) => castType(types_1.MetaType.boolean, p);
|
|
7
|
-
exports.castBool = castBool;
|
|
8
|
-
const castString = (p) => castType(types_1.MetaType.string, p);
|
|
9
|
-
exports.castString = castString;
|
|
10
|
-
const castNumber = (p) => castType(types_1.MetaType.number, p);
|
|
11
|
-
exports.castNumber = castNumber;
|
|
12
|
-
const castInt = (p) => castType(types_1.MetaType.int, p);
|
|
13
|
-
exports.castInt = castInt;
|
|
14
|
-
const castDate = (p) => castType(types_1.MetaType.date, p);
|
|
15
|
-
exports.castDate = castDate;
|
|
16
|
-
const castArray = (p) => castType(types_1.MetaType.array, p);
|
|
17
|
-
exports.castArray = castArray;
|
|
18
|
-
const castObject = (p) => castType(types_1.MetaType.object, p);
|
|
19
|
-
exports.castObject = castObject;
|
|
20
|
-
const castRecord = (p) => castType(types_1.MetaType.record, p);
|
|
21
|
-
exports.castRecord = castRecord;
|
|
22
|
-
const castOptional = (p) => castType(types_1.MetaInternalType.optional, p);
|
|
23
|
-
exports.castOptional = castOptional;
|
|
24
|
-
const castEnum = (p) => castType(types_1.MetaType.enum, p);
|
|
25
|
-
exports.castEnum = castEnum;
|
|
26
|
-
const metaFunctions = {
|
|
27
|
-
boolean: (name, _prop, optional) => {
|
|
28
|
-
const prop = (0, exports.castBool)(_prop);
|
|
29
|
-
if (!prop)
|
|
30
|
-
return;
|
|
31
|
-
const meta = prop.meta();
|
|
32
|
-
return {
|
|
33
|
-
boolean: {
|
|
34
|
-
name,
|
|
35
|
-
title: meta?.title,
|
|
36
|
-
description: meta?.description,
|
|
37
|
-
type: types_1.MetaType.boolean,
|
|
38
|
-
optional,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
string: (name, _prop, optional) => {
|
|
43
|
-
const prop = (0, exports.castString)(_prop);
|
|
44
|
-
if (!prop)
|
|
45
|
-
return;
|
|
46
|
-
const meta = prop.meta();
|
|
47
|
-
const checks = metaChecks(prop._zod.def);
|
|
48
|
-
return {
|
|
49
|
-
string: {
|
|
50
|
-
name,
|
|
51
|
-
title: meta?.title,
|
|
52
|
-
description: meta?.description,
|
|
53
|
-
type: types_1.MetaType.string,
|
|
54
|
-
minLength: checks.min_length?.minimum,
|
|
55
|
-
maxLength: checks.max_length?.maximum,
|
|
56
|
-
exactLength: checks.length_equals?.length,
|
|
57
|
-
regex: checks.regex?.pattern?.toString() ??
|
|
58
|
-
checks.string_format?.pattern?.toString(),
|
|
59
|
-
format: checks.regex?.format ?? checks.string_format?.format,
|
|
60
|
-
optional,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
number: (name, _prop, optional) => {
|
|
65
|
-
const prop = (0, exports.castNumber)(_prop);
|
|
66
|
-
if (!prop)
|
|
67
|
-
return;
|
|
68
|
-
const meta = prop.meta();
|
|
69
|
-
const checks = metaChecks(prop._zod.def);
|
|
70
|
-
return {
|
|
71
|
-
number: {
|
|
72
|
-
name,
|
|
73
|
-
title: meta?.title,
|
|
74
|
-
description: meta?.description,
|
|
75
|
-
type: types_1.MetaType.number,
|
|
76
|
-
minValue: checks.greater_than?.value,
|
|
77
|
-
minInclusive: checks.greater_than?.inclusive,
|
|
78
|
-
maxValue: checks.less_than?.value,
|
|
79
|
-
maxInclusive: checks.less_than?.inclusive,
|
|
80
|
-
multipleOf: checks.multiple_of?.value,
|
|
81
|
-
format: checks.number_format?.format,
|
|
82
|
-
optional,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
int: (name, _prop, optional) => {
|
|
87
|
-
const prop = (0, exports.castInt)(_prop);
|
|
88
|
-
if (!prop)
|
|
89
|
-
return;
|
|
90
|
-
const meta = prop.meta();
|
|
91
|
-
const checks = metaChecks(prop._zod.def);
|
|
92
|
-
return {
|
|
93
|
-
int: {
|
|
94
|
-
name,
|
|
95
|
-
title: meta?.title,
|
|
96
|
-
description: meta?.description,
|
|
97
|
-
type: types_1.MetaType.int,
|
|
98
|
-
minValue: checks.greater_than?.value,
|
|
99
|
-
minInclusive: checks.greater_than?.inclusive,
|
|
100
|
-
maxValue: checks.less_than?.value,
|
|
101
|
-
maxInclusive: checks.less_than?.inclusive,
|
|
102
|
-
multipleOf: checks.multiple_of?.value,
|
|
103
|
-
format: checks.number_format?.format,
|
|
104
|
-
optional,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
date: (name, _prop, optional) => {
|
|
109
|
-
const prop = (0, exports.castDate)(_prop);
|
|
110
|
-
if (!prop)
|
|
111
|
-
return;
|
|
112
|
-
const meta = prop.meta();
|
|
113
|
-
return {
|
|
114
|
-
date: {
|
|
115
|
-
name,
|
|
116
|
-
title: meta?.title,
|
|
117
|
-
description: meta?.description,
|
|
118
|
-
type: types_1.MetaType.date,
|
|
119
|
-
optional,
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
array: (name, _prop, optional) => {
|
|
124
|
-
const prop = (0, exports.castArray)(_prop);
|
|
125
|
-
if (!prop)
|
|
126
|
-
return;
|
|
127
|
-
const meta = prop.meta();
|
|
128
|
-
const inner = prop.unwrap();
|
|
129
|
-
const checks = metaChecks(prop._zod.def);
|
|
130
|
-
return {
|
|
131
|
-
array: {
|
|
132
|
-
name,
|
|
133
|
-
title: meta?.title,
|
|
134
|
-
description: meta?.description,
|
|
135
|
-
type: types_1.MetaType.array,
|
|
136
|
-
item: metaItem(`${name}[]`, inner),
|
|
137
|
-
minLength: checks.min_length?.minimum,
|
|
138
|
-
maxLength: checks.max_length?.maximum,
|
|
139
|
-
exactLength: checks.length_equals?.length,
|
|
140
|
-
optional,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
record: (name, _prop, optional) => {
|
|
145
|
-
const prop = (0, exports.castRecord)(_prop);
|
|
146
|
-
if (!prop)
|
|
147
|
-
return;
|
|
148
|
-
const meta = prop.meta();
|
|
149
|
-
return {
|
|
150
|
-
record: {
|
|
151
|
-
name,
|
|
152
|
-
title: meta?.title,
|
|
153
|
-
description: meta?.description,
|
|
154
|
-
type: types_1.MetaType.record,
|
|
155
|
-
keyType: metaItem("keyType", prop.def.keyType),
|
|
156
|
-
valueType: metaItem("valueType", prop.def.valueType),
|
|
157
|
-
optional,
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
object: (name, _prop, optional) => {
|
|
162
|
-
const prop = (0, exports.castObject)(_prop);
|
|
163
|
-
if (!prop)
|
|
164
|
-
return;
|
|
165
|
-
const meta = prop.meta();
|
|
166
|
-
return {
|
|
167
|
-
object: {
|
|
168
|
-
name,
|
|
169
|
-
title: meta?.title,
|
|
170
|
-
description: meta?.description,
|
|
171
|
-
type: types_1.MetaType.object,
|
|
172
|
-
properties: (0, exports.metaItems)(prop.def.shape),
|
|
173
|
-
optional,
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
enum: (name, _prop, optional) => {
|
|
178
|
-
const prop = (0, exports.castEnum)(_prop);
|
|
179
|
-
if (!prop)
|
|
180
|
-
return;
|
|
181
|
-
const meta = prop.meta();
|
|
182
|
-
const entries = Object.entries(prop.def.entries).map(([key, value]) => {
|
|
183
|
-
const titles = Array.isArray(meta?.enumEntryTitles)
|
|
184
|
-
? meta.enumEntryTitles
|
|
185
|
-
: [];
|
|
186
|
-
return {
|
|
187
|
-
key,
|
|
188
|
-
value,
|
|
189
|
-
title: titles.find((t) => t.value === value)?.title,
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
return {
|
|
193
|
-
enum: {
|
|
194
|
-
name,
|
|
195
|
-
title: meta?.title,
|
|
196
|
-
description: meta?.description,
|
|
197
|
-
type: types_1.MetaType.enum,
|
|
198
|
-
entries,
|
|
199
|
-
optional,
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
optional: (name, _prop) => {
|
|
204
|
-
const prop = (0, exports.castOptional)(_prop);
|
|
205
|
-
if (!prop)
|
|
206
|
-
return;
|
|
207
|
-
const inner = prop.unwrap();
|
|
208
|
-
return metaItem(name, inner, true);
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
const metaCheck = (def) => {
|
|
212
|
-
const checks = {};
|
|
213
|
-
const found = types_1.MetaCheckTypeList.find((i) => i.value === def.check);
|
|
214
|
-
if (!found)
|
|
215
|
-
throw new Error(`Check type ${def.check} not supported`);
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
-
checks[found.value] = def;
|
|
218
|
-
return checks;
|
|
219
|
-
};
|
|
220
|
-
const metaChecks = (type) => {
|
|
221
|
-
let results = {};
|
|
222
|
-
const checks = type.def?.checks ??
|
|
223
|
-
type.checks ??
|
|
224
|
-
[];
|
|
225
|
-
for (const check of checks)
|
|
226
|
-
results = { ...results, ...metaCheck(check._zod.def) };
|
|
227
|
-
return results;
|
|
228
|
-
};
|
|
229
|
-
const metaItem = (name, prop, optional) => {
|
|
230
|
-
for (const f of Object.values(metaFunctions)) {
|
|
231
|
-
const item = f(name, prop, optional);
|
|
232
|
-
if (item)
|
|
233
|
-
return item;
|
|
234
|
-
}
|
|
235
|
-
throw new Error(`Property ${name} (${prop._zod.def.type}) failed`);
|
|
236
|
-
};
|
|
237
|
-
const metaItems = (props) => {
|
|
238
|
-
const items = [];
|
|
239
|
-
for (const [name, prop] of Object.entries(props))
|
|
240
|
-
items.push(metaItem(name, prop));
|
|
241
|
-
return items;
|
|
242
|
-
};
|
|
243
|
-
exports.metaItems = metaItems;
|
package/dist/esm/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
__exportStar(require("./lib"), exports);
|
|
40
|
-
// A default export can help some consumers using require()
|
|
41
|
-
const _all = __importStar(require("./lib"));
|
|
42
|
-
exports.default = _all;
|
package/dist/esm/lib.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Meta"), exports);
|
|
18
|
-
__exportStar(require("./common"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
package/dist/esm/package.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
3
|
-
/// <reference path="./types/zod.d.ts" />
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
// Re-export your public types/exports so this file becomes the root .d.ts for the package.
|
|
20
|
-
// Adjust the relative path if your source layout differs.
|
|
21
|
-
__exportStar(require("./lib"), exports);
|
package/dist/esm/types.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetaCheckTypeList = exports.MetaCheckType = exports.MetaInternalType = exports.MetaTypeList = exports.MetaType = void 0;
|
|
4
|
-
var MetaType;
|
|
5
|
-
(function (MetaType) {
|
|
6
|
-
MetaType["string"] = "string";
|
|
7
|
-
MetaType["number"] = "number";
|
|
8
|
-
MetaType["int"] = "int";
|
|
9
|
-
MetaType["date"] = "date";
|
|
10
|
-
MetaType["boolean"] = "boolean";
|
|
11
|
-
MetaType["array"] = "array";
|
|
12
|
-
MetaType["record"] = "record";
|
|
13
|
-
MetaType["object"] = "object";
|
|
14
|
-
MetaType["enum"] = "enum";
|
|
15
|
-
})(MetaType || (exports.MetaType = MetaType = {}));
|
|
16
|
-
exports.MetaTypeList = Object.entries(MetaType).map(([key, value]) => ({
|
|
17
|
-
key,
|
|
18
|
-
value,
|
|
19
|
-
}));
|
|
20
|
-
var MetaInternalType;
|
|
21
|
-
(function (MetaInternalType) {
|
|
22
|
-
MetaInternalType["optional"] = "optional";
|
|
23
|
-
})(MetaInternalType || (exports.MetaInternalType = MetaInternalType = {}));
|
|
24
|
-
var MetaCheckType;
|
|
25
|
-
(function (MetaCheckType) {
|
|
26
|
-
MetaCheckType["less_than"] = "less_than";
|
|
27
|
-
MetaCheckType["greater_than"] = "greater_than";
|
|
28
|
-
MetaCheckType["multiple_of"] = "multiple_of";
|
|
29
|
-
MetaCheckType["number_format"] = "number_format";
|
|
30
|
-
MetaCheckType["bigint_format"] = "bigint_format";
|
|
31
|
-
MetaCheckType["min_size"] = "min_size";
|
|
32
|
-
MetaCheckType["max_size"] = "max_size";
|
|
33
|
-
MetaCheckType["size_equals"] = "size_equals";
|
|
34
|
-
MetaCheckType["min_length"] = "min_length";
|
|
35
|
-
MetaCheckType["max_length"] = "max_length";
|
|
36
|
-
MetaCheckType["length_equals"] = "length_equals";
|
|
37
|
-
MetaCheckType["string_format"] = "string_format";
|
|
38
|
-
MetaCheckType["regex"] = "regex";
|
|
39
|
-
})(MetaCheckType || (exports.MetaCheckType = MetaCheckType = {}));
|
|
40
|
-
exports.MetaCheckTypeList = Object.entries(MetaCheckType).map(([key, value]) => ({
|
|
41
|
-
key,
|
|
42
|
-
value,
|
|
43
|
-
}));
|
package/dist/types/Meta.d.ts
DELETED
package/dist/types/common.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ZodBoolean, ZodString, ZodNumber, ZodInt, ZodDate, ZodArray, ZodObject, ZodRecord, ZodOptional, ZodEnum, ZodRawShape } from "zod";
|
|
2
|
-
import type { $ZodType } from "zod/v4/core";
|
|
3
|
-
import type { MetaItem } from "./types";
|
|
4
|
-
export declare const castBool: (p: $ZodType) => ZodBoolean | undefined;
|
|
5
|
-
export declare const castString: (p: $ZodType) => ZodString | undefined;
|
|
6
|
-
export declare const castNumber: (p: $ZodType) => ZodNumber | undefined;
|
|
7
|
-
export declare const castInt: (p: $ZodType) => ZodInt | undefined;
|
|
8
|
-
export declare const castDate: (p: $ZodType) => ZodDate | undefined;
|
|
9
|
-
export declare const castArray: (p: $ZodType) => ZodArray<$ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>> | undefined;
|
|
10
|
-
export declare const castObject: (p: $ZodType) => ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip> | undefined;
|
|
11
|
-
export declare const castRecord: (p: $ZodType) => ZodRecord<import("zod/v4/core").$ZodRecordKey, $ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>> | undefined;
|
|
12
|
-
export declare const castOptional: (p: $ZodType) => ZodOptional<$ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>> | undefined;
|
|
13
|
-
export declare const castEnum: (p: $ZodType) => ZodEnum<Readonly<Record<string, import("node_modules/zod/v4/core/util.cjs").EnumValue>>> | undefined;
|
|
14
|
-
export declare const metaItems: (props: ZodRawShape) => MetaItem[];
|
package/dist/types/index.d.ts
DELETED
package/dist/types/lib.d.ts
DELETED
package/dist/types/package.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./lib";
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import type { $ZodCheckBigIntFormatDef, $ZodCheckGreaterThanDef, $ZodCheckLengthEqualsDef, $ZodCheckLessThanDef, $ZodCheckMaxLengthDef, $ZodCheckMaxSizeDef, $ZodCheckMinLengthDef, $ZodCheckMinSizeDef, $ZodCheckMultipleOfDef, $ZodCheckNumberFormatDef, $ZodCheckRegexDef, $ZodCheckSizeEqualsDef, $ZodCheckStringFormatDef, $ZodNumberFormats, $ZodStringFormats, $ZodType } from "zod/v4/core";
|
|
2
|
-
export declare enum MetaType {
|
|
3
|
-
string = "string",
|
|
4
|
-
number = "number",
|
|
5
|
-
int = "int",
|
|
6
|
-
date = "date",
|
|
7
|
-
boolean = "boolean",
|
|
8
|
-
array = "array",
|
|
9
|
-
record = "record",
|
|
10
|
-
object = "object",
|
|
11
|
-
enum = "enum"
|
|
12
|
-
}
|
|
13
|
-
export declare const MetaTypeList: {
|
|
14
|
-
key: string;
|
|
15
|
-
value: MetaType;
|
|
16
|
-
}[];
|
|
17
|
-
export declare enum MetaInternalType {
|
|
18
|
-
optional = "optional"
|
|
19
|
-
}
|
|
20
|
-
export declare enum MetaCheckType {
|
|
21
|
-
less_than = "less_than",
|
|
22
|
-
greater_than = "greater_than",
|
|
23
|
-
multiple_of = "multiple_of",
|
|
24
|
-
number_format = "number_format",
|
|
25
|
-
bigint_format = "bigint_format",
|
|
26
|
-
min_size = "min_size",
|
|
27
|
-
max_size = "max_size",
|
|
28
|
-
size_equals = "size_equals",
|
|
29
|
-
min_length = "min_length",
|
|
30
|
-
max_length = "max_length",
|
|
31
|
-
length_equals = "length_equals",
|
|
32
|
-
string_format = "string_format",
|
|
33
|
-
regex = "regex"
|
|
34
|
-
}
|
|
35
|
-
export declare const MetaCheckTypeList: {
|
|
36
|
-
key: string;
|
|
37
|
-
value: MetaCheckType;
|
|
38
|
-
}[];
|
|
39
|
-
export interface MetaChecks {
|
|
40
|
-
[MetaCheckType.bigint_format]?: $ZodCheckBigIntFormatDef;
|
|
41
|
-
[MetaCheckType.less_than]?: $ZodCheckLessThanDef;
|
|
42
|
-
[MetaCheckType.greater_than]?: $ZodCheckGreaterThanDef;
|
|
43
|
-
[MetaCheckType.multiple_of]?: $ZodCheckMultipleOfDef;
|
|
44
|
-
[MetaCheckType.number_format]?: $ZodCheckNumberFormatDef;
|
|
45
|
-
[MetaCheckType.min_size]?: $ZodCheckMinSizeDef;
|
|
46
|
-
[MetaCheckType.max_size]?: $ZodCheckMaxSizeDef;
|
|
47
|
-
[MetaCheckType.size_equals]?: $ZodCheckSizeEqualsDef;
|
|
48
|
-
[MetaCheckType.min_length]?: $ZodCheckMinLengthDef;
|
|
49
|
-
[MetaCheckType.max_length]?: $ZodCheckMaxLengthDef;
|
|
50
|
-
[MetaCheckType.length_equals]?: $ZodCheckLengthEqualsDef;
|
|
51
|
-
[MetaCheckType.string_format]?: $ZodCheckStringFormatDef;
|
|
52
|
-
[MetaCheckType.regex]?: $ZodCheckRegexDef;
|
|
53
|
-
}
|
|
54
|
-
export interface MetaBase {
|
|
55
|
-
type: MetaType;
|
|
56
|
-
name: string;
|
|
57
|
-
title?: string;
|
|
58
|
-
description?: string;
|
|
59
|
-
optional?: boolean;
|
|
60
|
-
}
|
|
61
|
-
export interface MetaString extends MetaBase {
|
|
62
|
-
type: MetaType.string;
|
|
63
|
-
minLength?: number;
|
|
64
|
-
maxLength?: number;
|
|
65
|
-
exactLength?: number;
|
|
66
|
-
regex?: string;
|
|
67
|
-
format?: $ZodStringFormats | string;
|
|
68
|
-
}
|
|
69
|
-
export interface MetaBool extends MetaBase {
|
|
70
|
-
type: MetaType.boolean;
|
|
71
|
-
}
|
|
72
|
-
export interface MetaNumber extends MetaBase {
|
|
73
|
-
type: MetaType.number;
|
|
74
|
-
minValue?: number;
|
|
75
|
-
minInclusive?: boolean;
|
|
76
|
-
maxValue?: number;
|
|
77
|
-
maxInclusive?: boolean;
|
|
78
|
-
multipleOf?: number;
|
|
79
|
-
format?: $ZodNumberFormats;
|
|
80
|
-
}
|
|
81
|
-
export interface MetaInt extends MetaBase {
|
|
82
|
-
type: MetaType.int;
|
|
83
|
-
minValue?: number;
|
|
84
|
-
minInclusive?: boolean;
|
|
85
|
-
maxValue?: number;
|
|
86
|
-
maxInclusive?: boolean;
|
|
87
|
-
multipleOf?: number;
|
|
88
|
-
format?: $ZodNumberFormats;
|
|
89
|
-
}
|
|
90
|
-
export interface MetaDate extends MetaBase {
|
|
91
|
-
type: MetaType.date;
|
|
92
|
-
}
|
|
93
|
-
export interface MetaArray extends MetaBase {
|
|
94
|
-
type: MetaType.array;
|
|
95
|
-
item: MetaItem;
|
|
96
|
-
minLength?: number;
|
|
97
|
-
maxLength?: number;
|
|
98
|
-
exactLength?: number;
|
|
99
|
-
}
|
|
100
|
-
export interface MetaRecord extends MetaBase {
|
|
101
|
-
type: MetaType.record;
|
|
102
|
-
keyType: MetaItem;
|
|
103
|
-
valueType: MetaItem;
|
|
104
|
-
}
|
|
105
|
-
export interface MetaObject extends MetaBase {
|
|
106
|
-
type: MetaType.object;
|
|
107
|
-
properties: MetaItem | MetaItem[];
|
|
108
|
-
}
|
|
109
|
-
export interface MetaEnumEntry {
|
|
110
|
-
key: string;
|
|
111
|
-
value: number | string;
|
|
112
|
-
title?: string;
|
|
113
|
-
}
|
|
114
|
-
export interface MetaEnumEntryTitle {
|
|
115
|
-
value: string;
|
|
116
|
-
title?: string;
|
|
117
|
-
}
|
|
118
|
-
export interface MetaEnum extends MetaBase {
|
|
119
|
-
type: MetaType.enum;
|
|
120
|
-
entries: MetaEnumEntry[];
|
|
121
|
-
}
|
|
122
|
-
export interface MetaOptional extends MetaBase {
|
|
123
|
-
type: MetaType.record;
|
|
124
|
-
inner: MetaItem;
|
|
125
|
-
}
|
|
126
|
-
export interface MetaItem {
|
|
127
|
-
boolean?: MetaBool;
|
|
128
|
-
string?: MetaString;
|
|
129
|
-
number?: MetaNumber;
|
|
130
|
-
int?: MetaInt;
|
|
131
|
-
date?: MetaDate;
|
|
132
|
-
array?: MetaArray;
|
|
133
|
-
record?: MetaRecord;
|
|
134
|
-
object?: MetaObject;
|
|
135
|
-
enum?: MetaEnum;
|
|
136
|
-
}
|
|
137
|
-
export type MetaFunc = (name: string, prop: $ZodType, optional?: boolean) => MetaItem | undefined;
|
|
138
|
-
export type MetaFuncs = {
|
|
139
|
-
[key in MetaType | MetaInternalType]: MetaFunc;
|
|
140
|
-
};
|