llmz 0.2.0 → 0.2.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/{chunk-WWZ2W4WR.cjs → chunk-2EZSVF5X.cjs} +382 -492
- package/dist/{chunk-33AB6SVX.js → chunk-2MSLOTFO.js} +2 -2
- package/dist/{chunk-IRCB4FRM.js → chunk-3OSQ4XL4.js} +1 -1
- package/dist/{chunk-E5NHK3FS.js → chunk-5ISVDYBA.js} +3 -3
- package/dist/{chunk-IKLFMVSW.cjs → chunk-5XPEVOOW.cjs} +8 -8
- package/dist/{chunk-YGKQEVQQ.cjs → chunk-C2KND2PS.cjs} +3 -3
- package/dist/{chunk-DH35WO5G.js → chunk-EJIDFDQP.js} +373 -483
- package/dist/chunk-GDWRFHM5.js +792 -0
- package/dist/chunk-MHVORH33.cjs +792 -0
- package/dist/{chunk-WODK7Y4J.cjs → chunk-S46T73HR.cjs} +2 -2
- package/dist/compiler/ast.d.ts +26 -0
- package/dist/compiler/compiler.d.ts +13 -11
- package/dist/compiler/plugins/line-tracking.d.ts +6 -4
- package/dist/compiler/plugins/replace-comment.d.ts +8 -4
- package/dist/compiler/plugins/return-async.d.ts +18 -4
- package/dist/compiler/plugins/track-tool-calls.d.ts +21 -4
- package/dist/compiler/plugins/variable-extraction.d.ts +9 -4
- package/dist/component.default.d.ts +13 -91
- package/dist/{dual-modes-ZZY6QPYT.cjs → dual-modes-IZQJTXR7.cjs} +2 -2
- package/dist/{dual-modes-RMF7V7ZQ.js → dual-modes-J4RWHJ2O.js} +1 -1
- package/dist/{execute-BXPFSEVX.cjs → execute-4IL4QPAR.cjs} +23 -23
- package/dist/{execute-HIRXXR6X.js → execute-6AYBMTRM.js} +5 -5
- package/dist/formatting.d.ts +1 -2
- package/dist/index.cjs +185 -234
- package/dist/index.js +172 -221
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/user.md.d.ts +1 -1
- package/dist/{tool-GJ6ZXWS2.cjs → tool-56I7OSKU.cjs} +3 -3
- package/dist/{tool-DNHVW3KC.js → tool-I3MAWDN2.js} +2 -2
- package/dist/{typings-ZTFPPA5W.cjs → typings-LVI4VGE2.cjs} +2 -2
- package/dist/{typings-3YV3RDMP.js → typings-SR3EE6LR.js} +1 -1
- package/dist/typings-formatter.d.ts +34 -0
- package/dist/typings-formatter.test.d.ts +1 -0
- package/dist/{vm-44H4UKI2.js → vm-ZLWGAYYJ.js} +1 -1
- package/dist/{vm-A3OTQVIR.cjs → vm-ZVONLAZV.cjs} +2 -2
- package/package.json +5 -14
- package/dist/chunk-7LMIOS6H.cjs +0 -287
- package/dist/chunk-TOGYDN6U.js +0 -287
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal, dependency-free formatter for the TypeScript typings generated by
|
|
3
|
+
* llmz (typings.ts, objects.ts, hoist.ts). It supports only the small grammar
|
|
4
|
+
* those generators emit — type expressions, `declare const` / `declare function`
|
|
5
|
+
* declarations, `type` aliases and `export namespace` blocks — and produces
|
|
6
|
+
* prettier-like output: 80 columns, 2-space indent, no semicolons in broken
|
|
7
|
+
* objects, hugged single-object function params, unions wrapped with leading `|`.
|
|
8
|
+
*
|
|
9
|
+
* If the input cannot be tokenized or has unbalanced brackets, it is returned
|
|
10
|
+
* unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export type TokKind = 'word' | 'string' | 'punct' | 'block-comment' | 'line-comment';
|
|
13
|
+
export type Tok = {
|
|
14
|
+
kind: TokKind;
|
|
15
|
+
text: string;
|
|
16
|
+
/** number of newlines in the source right before this token */
|
|
17
|
+
nl: number;
|
|
18
|
+
};
|
|
19
|
+
export type Group = {
|
|
20
|
+
kind: 'group';
|
|
21
|
+
open: string;
|
|
22
|
+
close: string;
|
|
23
|
+
children: Node[];
|
|
24
|
+
nl: number;
|
|
25
|
+
};
|
|
26
|
+
export type Node = Tok | Group;
|
|
27
|
+
export declare const isGroup: (n: Node) => n is Group;
|
|
28
|
+
export declare const isPunct: (n: Node, text: string) => boolean;
|
|
29
|
+
export declare function tokenize(src: string): Tok[];
|
|
30
|
+
export declare function parse(toks: Tok[]): Node[];
|
|
31
|
+
/** Formats typings, throwing on input it cannot parse (unbalanced brackets, etc.) */
|
|
32
|
+
export declare function formatTypingsUnsafe(typings: string): string;
|
|
33
|
+
/** Formats typings, returning the input unchanged when it cannot be parsed */
|
|
34
|
+
export declare function formatTypings(typings: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk2EZSVF5Xcjs = require('./chunk-2EZSVF5X.cjs');
|
|
5
5
|
require('./chunk-PK72FAKD.cjs');
|
|
6
6
|
require('./chunk-KIN7Y247.cjs');
|
|
7
7
|
require('./chunk-HC2QZTVT.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.runAsyncFunction =
|
|
11
|
+
exports.runAsyncFunction = _chunk2EZSVF5Xcjs.runAsyncFunction; exports.warmupVM = _chunk2EZSVF5Xcjs.warmupVM;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "llmz",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "LLMz - An LLM-native Typescript VM built on top of Zui",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.2",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -30,32 +30,22 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@babel/generator": "^7.26.3",
|
|
34
|
-
"@babel/parser": "^7.26.3",
|
|
35
|
-
"@babel/standalone": "^7.26.4",
|
|
36
|
-
"@babel/traverse": "^7.26.4",
|
|
37
|
-
"@babel/types": "^7.26.3",
|
|
38
33
|
"@jitl/quickjs-singlefile-browser-release-sync": "^0.31.0",
|
|
34
|
+
"acorn": "^8.17.0",
|
|
39
35
|
"bytes": "^3.1.2",
|
|
40
36
|
"exponential-backoff": "^3.1.1",
|
|
41
37
|
"handlebars": "^4.7.8",
|
|
42
38
|
"json5": "^2.2.3",
|
|
43
39
|
"jsonrepair": "^3.10.0",
|
|
44
40
|
"lodash-es": "^4.17.21",
|
|
45
|
-
"
|
|
41
|
+
"magic-string": "^0.30.21",
|
|
46
42
|
"ms": "^2.1.3",
|
|
47
|
-
"prettier": "^3.4.2",
|
|
48
43
|
"quickjs-emscripten-core": "^0.31.0",
|
|
49
44
|
"ulid": "^2.3.0"
|
|
50
45
|
},
|
|
51
46
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "^7.26.0",
|
|
53
47
|
"@botpress/cli": "workspace:*",
|
|
54
48
|
"@microsoft/api-extractor": "^7.49.0",
|
|
55
|
-
"@types/babel__core": "^7.20.5",
|
|
56
|
-
"@types/babel__generator": "^7.6.8",
|
|
57
|
-
"@types/babel__standalone": "^7.1.9",
|
|
58
|
-
"@types/babel__traverse": "^7.20.6",
|
|
59
49
|
"@types/bytes": "^3.1.5",
|
|
60
50
|
"@types/json-schema": "^7.0.12",
|
|
61
51
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -66,6 +56,7 @@
|
|
|
66
56
|
"dotenv": "^16.4.4",
|
|
67
57
|
"esbuild": "^0.25.10",
|
|
68
58
|
"glob": "^9.3.4",
|
|
59
|
+
"prettier": "^3.4.2",
|
|
69
60
|
"source-map-js": "1.2.1",
|
|
70
61
|
"tsup": "^8.0.2",
|
|
71
62
|
"tsx": "^4.19.2"
|
|
@@ -74,7 +65,7 @@
|
|
|
74
65
|
"@botpress/client": "1.49.0",
|
|
75
66
|
"@botpress/cognitive": "0.6.2",
|
|
76
67
|
"@bpinternal/thicktoken": "^3.0.0",
|
|
77
|
-
"@bpinternal/zui": "^2.
|
|
68
|
+
"@bpinternal/zui": "^2.4.0"
|
|
78
69
|
},
|
|
79
70
|
"dependenciesMeta": {
|
|
80
71
|
"@bpinternal/zui": {
|
package/dist/chunk-7LMIOS6H.cjs
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
9
|
-
|
|
10
|
-
// src/typings.ts
|
|
11
|
-
var _zui = require('@bpinternal/zui');
|
|
12
|
-
|
|
13
|
-
// src/formatting.ts
|
|
14
|
-
var _lrucache = require('lru-cache');
|
|
15
|
-
var _babel = require('prettier/plugins/babel'); var _babel2 = _interopRequireDefault(_babel);
|
|
16
|
-
var _estree = require('prettier/plugins/estree'); var _estree2 = _interopRequireDefault(_estree);
|
|
17
|
-
var _typescript = require('prettier/plugins/typescript'); var _typescript2 = _interopRequireDefault(_typescript);
|
|
18
|
-
var _standalone = require('prettier/standalone');
|
|
19
|
-
var cache = new (0, _lrucache.LRUCache)({ max: 1e3 });
|
|
20
|
-
async function formatTypings(typings, options) {
|
|
21
|
-
if (cache.has(typings)) {
|
|
22
|
-
return cache.get(typings);
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
options ??= {};
|
|
26
|
-
options.throwOnError ??= true;
|
|
27
|
-
const result = (await _standalone.format.call(void 0, typings, {
|
|
28
|
-
singleAttributePerLine: true,
|
|
29
|
-
bracketSameLine: true,
|
|
30
|
-
semi: false,
|
|
31
|
-
...options,
|
|
32
|
-
embeddedLanguageFormatting: "off",
|
|
33
|
-
plugins: [_estree2.default, _babel2.default, _typescript2.default],
|
|
34
|
-
parser: "typescript",
|
|
35
|
-
filepath: "tools.d.ts"
|
|
36
|
-
})).trim();
|
|
37
|
-
cache.set(typings, result);
|
|
38
|
-
return result;
|
|
39
|
-
} catch (err) {
|
|
40
|
-
if (options == null ? void 0 : options.throwOnError) {
|
|
41
|
-
throw new (0, _chunkPK72FAKDcjs.CodeFormattingError)(err instanceof Error ? err.message : _nullishCoalesce((err == null ? void 0 : err.toString()), () => ( "Unknown Error")), typings);
|
|
42
|
-
}
|
|
43
|
-
return typings;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/typings.ts
|
|
48
|
-
var Primitives = [
|
|
49
|
-
"string",
|
|
50
|
-
"number",
|
|
51
|
-
"boolean",
|
|
52
|
-
"unknown",
|
|
53
|
-
"void",
|
|
54
|
-
"any",
|
|
55
|
-
"null",
|
|
56
|
-
"undefined",
|
|
57
|
-
"never",
|
|
58
|
-
"bigint",
|
|
59
|
-
"symbol",
|
|
60
|
-
"object"
|
|
61
|
-
];
|
|
62
|
-
var LARGE_DECLARATION_LINES = 5;
|
|
63
|
-
var isPrimitive = (type) => Primitives.includes(type);
|
|
64
|
-
var isArrayOfPrimitives = (type) => Primitives.map((p) => `${p}[]`).includes(type);
|
|
65
|
-
var stripSpaces = (typings) => typings.replace(/ +/g, " ").trim();
|
|
66
|
-
var KeyValue = class {
|
|
67
|
-
constructor(key, value) {
|
|
68
|
-
this.key = key;
|
|
69
|
-
this.value = value;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var FnParameters = class {
|
|
73
|
-
constructor(schema) {
|
|
74
|
-
this.schema = schema;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var FnReturn = class {
|
|
78
|
-
constructor(schema) {
|
|
79
|
-
this.schema = schema;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var Declaration = class {
|
|
83
|
-
constructor(schema, identifier) {
|
|
84
|
-
this.schema = schema;
|
|
85
|
-
this.identifier = identifier;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
async function getTypings(schema, options) {
|
|
89
|
-
options ??= {};
|
|
90
|
-
options.declaration ??= false;
|
|
91
|
-
let wrappedSchema = schema;
|
|
92
|
-
if ((options == null ? void 0 : options.declaration) && _zui.z.is.zuiType(schema)) {
|
|
93
|
-
const title = "title" in schema.ui ? schema.ui.title : null;
|
|
94
|
-
if (!title) {
|
|
95
|
-
throw new Error('Only schemas with "title" Zui property can be declared.');
|
|
96
|
-
}
|
|
97
|
-
wrappedSchema = new Declaration(schema, title);
|
|
98
|
-
}
|
|
99
|
-
let dts = await sUnwrapZodRecursive(wrappedSchema, { ...options });
|
|
100
|
-
dts = await formatTypings(dts, { throwOnError: false });
|
|
101
|
-
return dts;
|
|
102
|
-
}
|
|
103
|
-
async function sUnwrapZodRecursive(schema, options) {
|
|
104
|
-
return sUnwrapZod(schema, options);
|
|
105
|
-
}
|
|
106
|
-
async function sUnwrapZod(schema, options) {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
const newOptions = {
|
|
109
|
-
...options,
|
|
110
|
-
declaration: false,
|
|
111
|
-
parent: schema
|
|
112
|
-
};
|
|
113
|
-
if (schema instanceof Declaration) {
|
|
114
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema.schema.description);
|
|
115
|
-
const withoutDesc = schema.schema.describe("");
|
|
116
|
-
const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
|
|
117
|
-
const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
|
|
118
|
-
const closingTag = isLargeDeclaration ? `// end of ${schema.identifier}` : "";
|
|
119
|
-
if (_zui.z.is.zuiFunction(schema.schema)) {
|
|
120
|
-
return stripSpaces(`${description}
|
|
121
|
-
declare function ${schema.identifier}${typings};${closingTag}`);
|
|
122
|
-
}
|
|
123
|
-
return stripSpaces(`${description}
|
|
124
|
-
declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
125
|
-
}
|
|
126
|
-
if (schema instanceof KeyValue) {
|
|
127
|
-
if (_zui.z.is.zuiOptional(schema.value) || _zui.z.is.zuiDefault(schema.value)) {
|
|
128
|
-
let innerType = schema.value._def.innerType;
|
|
129
|
-
if (_zui.z.is.zuiType(innerType) && !innerType.description && schema.value.description) {
|
|
130
|
-
innerType = innerType == null ? void 0 : innerType.describe(schema.value.description);
|
|
131
|
-
}
|
|
132
|
-
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
133
|
-
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
134
|
-
}
|
|
135
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema.value._def.description || schema.value.description);
|
|
136
|
-
const delimiter = (description == null ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
137
|
-
const withoutDesc = schema.value.describe("");
|
|
138
|
-
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
139
|
-
}
|
|
140
|
-
if (schema instanceof FnParameters) {
|
|
141
|
-
if (_zui.z.is.zuiTuple(schema.schema)) {
|
|
142
|
-
let args = "";
|
|
143
|
-
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
|
-
const argName = _nullishCoalesce(((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title), () => ( `arg${i}`));
|
|
145
|
-
const item = schema.schema.items[i];
|
|
146
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(_chunkFPLSJF4Scjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
147
|
-
}
|
|
148
|
-
return args;
|
|
149
|
-
}
|
|
150
|
-
const isLiteral = _zui.z.is.zuiLiteral(schema.schema.naked());
|
|
151
|
-
const typings = (await sUnwrapZodRecursive(schema.schema, newOptions)).trim();
|
|
152
|
-
const startsWithPairs = typings.startsWith("{") && typings.endsWith("}") || typings.startsWith("[") && typings.endsWith("]") || typings.startsWith("(") && typings.endsWith(")") || typings.startsWith("Array<") && typings.endsWith(">") || typings.startsWith("Record<") && typings.endsWith(">") || isArrayOfPrimitives(typings);
|
|
153
|
-
if (startsWithPairs || isLiteral) {
|
|
154
|
-
return `args: ${typings}`;
|
|
155
|
-
} else {
|
|
156
|
-
return typings;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (schema instanceof FnReturn) {
|
|
160
|
-
if (_zui.z.is.zuiOptional(schema.schema)) {
|
|
161
|
-
return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
|
|
162
|
-
}
|
|
163
|
-
return sUnwrapZodRecursive(schema.schema, newOptions);
|
|
164
|
-
}
|
|
165
|
-
if (schema === null) {
|
|
166
|
-
return "unknown";
|
|
167
|
-
}
|
|
168
|
-
schema;
|
|
169
|
-
if (_zui.z.is.zuiDefault(schema)) {
|
|
170
|
-
return sUnwrapZodRecursive(schema._def.innerType, options);
|
|
171
|
-
}
|
|
172
|
-
if (_zui.z.is.zuiVoid(schema)) {
|
|
173
|
-
return "void";
|
|
174
|
-
}
|
|
175
|
-
if (_zui.z.is.zuiUnknown(schema)) {
|
|
176
|
-
return "unknown";
|
|
177
|
-
}
|
|
178
|
-
if (_zui.z.is.zuiAny(schema)) {
|
|
179
|
-
return "any";
|
|
180
|
-
}
|
|
181
|
-
if (_zui.z.is.zuiPromise(schema)) {
|
|
182
|
-
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
183
|
-
}
|
|
184
|
-
if (_zui.z.is.zuiFunction(schema)) {
|
|
185
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
186
|
-
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
187
|
-
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
188
|
-
if (options == null ? void 0 : options.declaration) {
|
|
189
|
-
return `${description}
|
|
190
|
-
(${input}): ${output}`;
|
|
191
|
-
}
|
|
192
|
-
return `${description}
|
|
193
|
-
(${input}) => ${output}`;
|
|
194
|
-
}
|
|
195
|
-
if (_zui.z.is.zuiArray(schema)) {
|
|
196
|
-
const item = await sUnwrapZodRecursive(schema._def.type, newOptions);
|
|
197
|
-
if (isPrimitive(item)) {
|
|
198
|
-
return `${item}[]`;
|
|
199
|
-
}
|
|
200
|
-
return `Array<${item}>`;
|
|
201
|
-
}
|
|
202
|
-
if (_zui.z.is.zuiEnum(schema)) {
|
|
203
|
-
const values = schema._def.values.map(_chunkFPLSJF4Scjs.escapeString);
|
|
204
|
-
return values.join(" | ");
|
|
205
|
-
}
|
|
206
|
-
if (_zui.z.is.zuiTuple(schema)) {
|
|
207
|
-
if (schema.items.length === 0) {
|
|
208
|
-
return "[]";
|
|
209
|
-
}
|
|
210
|
-
const items = await Promise.all(schema.items.map((i) => sUnwrapZodRecursive(i, newOptions)));
|
|
211
|
-
return `[${items.join(", ")}]`;
|
|
212
|
-
}
|
|
213
|
-
if (_zui.z.is.zuiNullable(schema)) {
|
|
214
|
-
return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
|
|
215
|
-
}
|
|
216
|
-
if (_zui.z.is.zuiOptional(schema)) {
|
|
217
|
-
if ((options == null ? void 0 : options.declaration) || _zui.z.is.zuiType(options == null ? void 0 : options.parent) && options.parent.typeName === "ZodRecord") {
|
|
218
|
-
return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)} | undefined`;
|
|
219
|
-
}
|
|
220
|
-
const optionalToken = options.parent instanceof KeyValue ? "| undefined" : "";
|
|
221
|
-
const val = `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)}${optionalToken}`;
|
|
222
|
-
return val;
|
|
223
|
-
}
|
|
224
|
-
if (_zui.z.is.zuiObject(schema)) {
|
|
225
|
-
const props = await Promise.all(
|
|
226
|
-
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
227
|
-
if (_zui.z.is.zuiType(value)) {
|
|
228
|
-
return sUnwrapZodRecursive(new KeyValue(_chunkFPLSJF4Scjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
229
|
-
}
|
|
230
|
-
return `${key}: unknown`;
|
|
231
|
-
})
|
|
232
|
-
);
|
|
233
|
-
return `{ ${props.join("; ")} }`;
|
|
234
|
-
}
|
|
235
|
-
if (_zui.z.is.zuiString(schema)) {
|
|
236
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
237
|
-
return `${description} string`.trim();
|
|
238
|
-
}
|
|
239
|
-
if (_zui.z.is.zuiUnion(schema)) {
|
|
240
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
241
|
-
const options2 = await Promise.all(
|
|
242
|
-
schema.options.map(async (option) => {
|
|
243
|
-
return sUnwrapZodRecursive(option, newOptions);
|
|
244
|
-
})
|
|
245
|
-
);
|
|
246
|
-
return `${description}
|
|
247
|
-
${options2.join(" | ")}`;
|
|
248
|
-
}
|
|
249
|
-
if (_zui.z.is.zuiLiteral(schema)) {
|
|
250
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
251
|
-
return `${description}
|
|
252
|
-
${typeof schema.value === "string" ? _chunkFPLSJF4Scjs.escapeString.call(void 0, schema.value) : String(schema.value)}`.trim();
|
|
253
|
-
}
|
|
254
|
-
if (_zui.z.is.zuiNumber(schema)) {
|
|
255
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
256
|
-
return `${description} number`.trim();
|
|
257
|
-
}
|
|
258
|
-
if (_zui.z.is.zuiBoolean(schema)) {
|
|
259
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
260
|
-
return `${description} boolean`.trim();
|
|
261
|
-
}
|
|
262
|
-
if (_zui.z.is.zuiCatch(schema)) {
|
|
263
|
-
return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
|
|
264
|
-
}
|
|
265
|
-
if (_zui.z.is.zuiLazy(schema)) {
|
|
266
|
-
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
267
|
-
}
|
|
268
|
-
if (_zui.z.is.zuiRecord(schema)) {
|
|
269
|
-
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
270
|
-
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
271
|
-
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
272
|
-
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
273
|
-
}
|
|
274
|
-
try {
|
|
275
|
-
let typings = schema == null ? void 0 : schema.toTypescriptType({ treatDefaultAsOptional: true });
|
|
276
|
-
typings ??= "unknown";
|
|
277
|
-
return stripSpaces(typings);
|
|
278
|
-
} catch (error) {
|
|
279
|
-
console.error("Error in sUnwrapZod", { error, schema, parent: options == null ? void 0 : options.parent });
|
|
280
|
-
return "unknown";
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
exports.formatTypings = formatTypings; exports.getTypings = getTypings;
|