llmz 0.0.6 → 0.0.7
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/README.md +0 -4
- package/package.json +5 -3
- package/dist/chat.d.ts +0 -17
- package/dist/chunk-4I7UPBLN.cjs +0 -104
- package/dist/chunk-4QTK5ALH.cjs +0 -211
- package/dist/chunk-5TRUJES5.js +0 -220
- package/dist/chunk-6WT5VZBG.cjs +0 -755
- package/dist/chunk-7WRN4E42.js +0 -3087
- package/dist/chunk-BEPRLBPK.cjs +0 -3123
- package/dist/chunk-CH5T6SPC.cjs +0 -694
- package/dist/chunk-D3ESDRLH.js +0 -3123
- package/dist/chunk-EJRCDWBA.cjs +0 -153
- package/dist/chunk-FIVFS4HG.cjs +0 -152
- package/dist/chunk-HP7RKM25.js +0 -153
- package/dist/chunk-HYVKY3W6.cjs +0 -283
- package/dist/chunk-IKSIOIIP.cjs +0 -28
- package/dist/chunk-JDABP4SD.cjs +0 -161
- package/dist/chunk-JKVVQN2P.js +0 -161
- package/dist/chunk-JQBT7UWN.js +0 -28
- package/dist/chunk-KMZDFWYZ.cjs +0 -33
- package/dist/chunk-ORQP26SZ.js +0 -33
- package/dist/chunk-P7J2WCBB.cjs +0 -220
- package/dist/chunk-QBXIE6EY.js +0 -211
- package/dist/chunk-QT4QF3YA.js +0 -152
- package/dist/chunk-S6FOL2HY.js +0 -104
- package/dist/chunk-UNMKB2DA.js +0 -283
- package/dist/chunk-UQOBUJIQ.cjs +0 -3087
- package/dist/chunk-WLUVY5QU.js +0 -755
- package/dist/chunk-XJNRORSK.js +0 -694
- package/dist/citations.d.ts +0 -63
- package/dist/compiler/compiler.d.ts +0 -28
- package/dist/compiler/index.d.ts +0 -2
- package/dist/compiler/plugins/async-iterator.d.ts +0 -4
- package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
- package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
- package/dist/compiler/plugins/line-tracking.d.ts +0 -5
- package/dist/compiler/plugins/replace-comment.d.ts +0 -5
- package/dist/compiler/plugins/return-async.d.ts +0 -4
- package/dist/compiler/plugins/track-tool-calls.d.ts +0 -16
- package/dist/compiler/plugins/variable-extraction.d.ts +0 -5
- package/dist/component-R2Y74VUI.js +0 -16
- package/dist/component-TSNW3SC7.cjs +0 -16
- package/dist/component.d.ts +0 -60
- package/dist/component.default.d.ts +0 -316
- package/dist/context.d.ts +0 -177
- package/dist/dual-modes-UHNDHNIF.cjs +0 -12
- package/dist/dual-modes-ZUQKPJFH.js +0 -12
- package/dist/errors.d.ts +0 -64
- package/dist/exit-KJ4COC5N.cjs +0 -8
- package/dist/exit-OIYZLBVJ.js +0 -8
- package/dist/exit.d.ts +0 -26
- package/dist/formatting.d.ts +0 -5
- package/dist/getter.d.ts +0 -2
- package/dist/handlers.d.ts +0 -10
- package/dist/hoist.d.ts +0 -2
- package/dist/index.cjs +0 -919
- package/dist/index.d.ts +0 -22
- package/dist/index.js +0 -919
- package/dist/inspect.d.ts +0 -6
- package/dist/jsx-AEHVFB3L.js +0 -13
- package/dist/jsx-AJAXBWFE.cjs +0 -13
- package/dist/jsx.d.ts +0 -11
- package/dist/llmz-CPMVYIOJ.cjs +0 -581
- package/dist/llmz-LAN4WDFW.js +0 -581
- package/dist/llmz.d.ts +0 -40
- package/dist/objects.d.ts +0 -24
- package/dist/openai.d.ts +0 -8
- package/dist/prompts/chat-mode/system.md.d.ts +0 -2
- package/dist/prompts/chat-mode/user.md.d.ts +0 -2
- package/dist/prompts/common.d.ts +0 -6
- package/dist/prompts/dual-modes.d.ts +0 -2
- package/dist/prompts/prompt.d.ts +0 -50
- package/dist/prompts/worker-mode/system.md.d.ts +0 -2
- package/dist/prompts/worker-mode/user.md.d.ts +0 -2
- package/dist/result.d.ts +0 -33
- package/dist/snapshots.d.ts +0 -69
- package/dist/stack-traces.d.ts +0 -1
- package/dist/tool-LY77IWV2.js +0 -11
- package/dist/tool-SWJYOR2Z.cjs +0 -11
- package/dist/tool.d.ts +0 -55
- package/dist/transcript.d.ts +0 -9
- package/dist/truncator-NYN7BGKJ.cjs +0 -10
- package/dist/truncator-WAL2GCUY.js +0 -10
- package/dist/truncator.d.ts +0 -21
- package/dist/types.d.ts +0 -105
- package/dist/typings-AIV2OASX.js +0 -10
- package/dist/typings-XR6CYHW4.cjs +0 -10
- package/dist/typings.d.ts +0 -5
- package/dist/utils-L5GLCS3C.js +0 -37
- package/dist/utils-QC4I2L6R.cjs +0 -37
- package/dist/utils.d.ts +0 -21
- package/dist/vm-2DLG7V4G.cjs +0 -12
- package/dist/vm-FLBMZUA2.js +0 -12
- package/dist/vm.d.ts +0 -3
package/dist/chunk-S6FOL2HY.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isJsonSchema,
|
|
3
|
-
isValidIdentifier
|
|
4
|
-
} from "./chunk-5TRUJES5.js";
|
|
5
|
-
import {
|
|
6
|
-
uniq_default
|
|
7
|
-
} from "./chunk-7WRN4E42.js";
|
|
8
|
-
|
|
9
|
-
// src/exit.ts
|
|
10
|
-
import { z } from "@bpinternal/zui";
|
|
11
|
-
var Exit = class _Exit {
|
|
12
|
-
name;
|
|
13
|
-
aliases = [];
|
|
14
|
-
description;
|
|
15
|
-
metadata;
|
|
16
|
-
schema;
|
|
17
|
-
get zSchema() {
|
|
18
|
-
return this.schema ? z.fromJsonSchema(this.schema) : void 0;
|
|
19
|
-
}
|
|
20
|
-
rename(name) {
|
|
21
|
-
const before = this.name;
|
|
22
|
-
if (!isValidIdentifier(name)) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`Invalid name for exit ${name}. An exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
this.name = name;
|
|
28
|
-
this.aliases = uniq_default([name, ...this.aliases.map((alias) => alias === before ? name : alias)]);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
clone() {
|
|
32
|
-
return new _Exit({
|
|
33
|
-
name: this.name,
|
|
34
|
-
aliases: [...this.aliases],
|
|
35
|
-
description: this.description,
|
|
36
|
-
metadata: JSON.parse(JSON.stringify(this.metadata)),
|
|
37
|
-
schema: this.zSchema
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
is(exit) {
|
|
41
|
-
return this.name === exit.name;
|
|
42
|
-
}
|
|
43
|
-
match(result) {
|
|
44
|
-
return result.exit instanceof _Exit && this.name === result.exit.name;
|
|
45
|
-
}
|
|
46
|
-
constructor(props) {
|
|
47
|
-
if (!isValidIdentifier(props.name)) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Invalid name for exit ${props.name}. A exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (typeof props.description !== "string" || props.description.trim().length === 0) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Invalid description for exit ${props.name}. Expected a non-empty string, but got type "${typeof props.description}"`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (props.metadata !== void 0 && typeof props.metadata !== "object") {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`Invalid metadata for exit ${props.name}. Expected an object, but got type "${typeof props.metadata}"`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
if (props.aliases !== void 0 && !Array.isArray(props.aliases)) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
if (props.aliases && props.aliases.some((alias) => !isValidIdentifier(alias))) {
|
|
68
|
-
throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
|
|
69
|
-
}
|
|
70
|
-
if (typeof props.schema !== "undefined") {
|
|
71
|
-
if (props.schema && "toJsonSchema" in props.schema && typeof props.schema.toJsonSchema === "function") {
|
|
72
|
-
this.schema = props.schema.toJsonSchema();
|
|
73
|
-
} else if (isJsonSchema(props.schema)) {
|
|
74
|
-
this.schema = props.schema;
|
|
75
|
-
} else {
|
|
76
|
-
throw new Error(
|
|
77
|
-
`Invalid input schema for exit ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.schema}"`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
this.name = props.name;
|
|
82
|
-
this.aliases = uniq_default([props.name, ...props.aliases ?? []]);
|
|
83
|
-
this.description = props.description;
|
|
84
|
-
this.metadata = props.metadata ?? {};
|
|
85
|
-
}
|
|
86
|
-
static withUniqueNames = (exits) => {
|
|
87
|
-
const names = /* @__PURE__ */ new Set();
|
|
88
|
-
return exits.map((exit) => {
|
|
89
|
-
if (exits.filter((t) => t.name === exit.name).length === 1) {
|
|
90
|
-
return exit;
|
|
91
|
-
}
|
|
92
|
-
let counter = 1;
|
|
93
|
-
let exitName = exit.name + counter;
|
|
94
|
-
while (names.has(exitName)) {
|
|
95
|
-
exitName = `${exit.name}${++counter}`;
|
|
96
|
-
}
|
|
97
|
-
return exit.rename(exitName);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export {
|
|
103
|
-
Exit
|
|
104
|
-
};
|
package/dist/chunk-UNMKB2DA.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CodeFormattingError
|
|
3
|
-
} from "./chunk-JKVVQN2P.js";
|
|
4
|
-
import {
|
|
5
|
-
escapeString,
|
|
6
|
-
getMultilineComment,
|
|
7
|
-
toPropertyKey
|
|
8
|
-
} from "./chunk-5TRUJES5.js";
|
|
9
|
-
|
|
10
|
-
// src/typings.ts
|
|
11
|
-
import { z } from "@bpinternal/zui";
|
|
12
|
-
|
|
13
|
-
// src/formatting.ts
|
|
14
|
-
import { LRUCache } from "lru-cache";
|
|
15
|
-
import babel from "prettier/plugins/babel";
|
|
16
|
-
import estree from "prettier/plugins/estree";
|
|
17
|
-
import typescript from "prettier/plugins/typescript";
|
|
18
|
-
import { format } from "prettier/standalone";
|
|
19
|
-
var cache = new 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 format(typings, {
|
|
28
|
-
singleAttributePerLine: true,
|
|
29
|
-
bracketSameLine: true,
|
|
30
|
-
semi: false,
|
|
31
|
-
...options,
|
|
32
|
-
embeddedLanguageFormatting: "off",
|
|
33
|
-
plugins: [estree, babel, typescript],
|
|
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 CodeFormattingError(err instanceof Error ? err.message : (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) && schema instanceof z.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 = getMultilineComment(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 (schema.schema instanceof z.ZodFunction) {
|
|
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 (schema.value instanceof z.ZodOptional) {
|
|
128
|
-
let innerType = schema.value._def.innerType;
|
|
129
|
-
if (innerType instanceof z.Schema && !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 = getMultilineComment(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 (schema.schema instanceof z.ZodTuple) {
|
|
142
|
-
let args = "";
|
|
143
|
-
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
|
-
const argName = ((_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(toPropertyKey(argName), item), newOptions)}, `;
|
|
147
|
-
}
|
|
148
|
-
return args;
|
|
149
|
-
}
|
|
150
|
-
const isLiteral = schema.schema.naked() instanceof z.ZodLiteral;
|
|
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 (schema.schema instanceof z.ZodOptional) {
|
|
161
|
-
return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
|
|
162
|
-
}
|
|
163
|
-
return sUnwrapZodRecursive(schema.schema, newOptions);
|
|
164
|
-
}
|
|
165
|
-
if (schema instanceof z.ZodDefault) {
|
|
166
|
-
return sUnwrapZodRecursive(schema._def.innerType, options);
|
|
167
|
-
}
|
|
168
|
-
if (schema instanceof z.ZodVoid) {
|
|
169
|
-
return "void";
|
|
170
|
-
}
|
|
171
|
-
if (schema instanceof z.ZodUnknown) {
|
|
172
|
-
return "unknown";
|
|
173
|
-
}
|
|
174
|
-
if (schema instanceof z.ZodAny) {
|
|
175
|
-
return "any";
|
|
176
|
-
}
|
|
177
|
-
if (schema instanceof z.ZodPromise) {
|
|
178
|
-
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
179
|
-
}
|
|
180
|
-
if (schema instanceof z.ZodFunction) {
|
|
181
|
-
const description = getMultilineComment(schema._def.description);
|
|
182
|
-
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
183
|
-
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
184
|
-
if (options == null ? void 0 : options.declaration) {
|
|
185
|
-
return `${description}
|
|
186
|
-
(${input}): ${output}`;
|
|
187
|
-
}
|
|
188
|
-
return `${description}
|
|
189
|
-
(${input}) => ${output}`;
|
|
190
|
-
}
|
|
191
|
-
if (schema instanceof z.ZodArray) {
|
|
192
|
-
const item = await sUnwrapZodRecursive(schema._def.type, newOptions);
|
|
193
|
-
if (isPrimitive(item)) {
|
|
194
|
-
return `${item}[]`;
|
|
195
|
-
}
|
|
196
|
-
return `Array<${item}>`;
|
|
197
|
-
}
|
|
198
|
-
if (schema instanceof z.ZodEnum) {
|
|
199
|
-
const values = schema._def.values.map(escapeString);
|
|
200
|
-
return values.join(" | ");
|
|
201
|
-
}
|
|
202
|
-
if (schema instanceof z.ZodTuple) {
|
|
203
|
-
if (schema.items.length === 0) {
|
|
204
|
-
return "[]";
|
|
205
|
-
}
|
|
206
|
-
const items = await Promise.all(schema.items.map((i) => sUnwrapZodRecursive(i, newOptions)));
|
|
207
|
-
return `[${items.join(", ")}]`;
|
|
208
|
-
}
|
|
209
|
-
if (schema instanceof z.ZodNullable) {
|
|
210
|
-
return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
|
|
211
|
-
}
|
|
212
|
-
if (schema instanceof z.ZodOptional) {
|
|
213
|
-
if ((options == null ? void 0 : options.declaration) || (options == null ? void 0 : options.parent) instanceof z.ZodRecord) {
|
|
214
|
-
return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)} | undefined`;
|
|
215
|
-
}
|
|
216
|
-
const optionalToken = options.parent instanceof KeyValue ? "| undefined" : "";
|
|
217
|
-
const val = `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)}${optionalToken}`;
|
|
218
|
-
return val;
|
|
219
|
-
}
|
|
220
|
-
if (schema instanceof z.ZodObject) {
|
|
221
|
-
const props = await Promise.all(
|
|
222
|
-
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
223
|
-
if (value instanceof z.Schema) {
|
|
224
|
-
return sUnwrapZodRecursive(new KeyValue(toPropertyKey(key), value), newOptions);
|
|
225
|
-
}
|
|
226
|
-
return `${key}: unknown`;
|
|
227
|
-
})
|
|
228
|
-
);
|
|
229
|
-
return `{ ${props.join("; ")} }`;
|
|
230
|
-
}
|
|
231
|
-
if (schema instanceof z.ZodString) {
|
|
232
|
-
const description = getMultilineComment(schema._def.description);
|
|
233
|
-
return `${description} string`.trim();
|
|
234
|
-
}
|
|
235
|
-
if (schema instanceof z.ZodUnion) {
|
|
236
|
-
const description = getMultilineComment(schema._def.description);
|
|
237
|
-
const options2 = await Promise.all(
|
|
238
|
-
schema.options.map(async (option) => {
|
|
239
|
-
return sUnwrapZodRecursive(option, newOptions);
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
return `${description}
|
|
243
|
-
${options2.join(" | ")}`;
|
|
244
|
-
}
|
|
245
|
-
if (schema instanceof z.ZodLiteral) {
|
|
246
|
-
const description = getMultilineComment(schema._def.description);
|
|
247
|
-
return `${description}
|
|
248
|
-
${typeof schema.value === "string" ? escapeString(schema.value) : schema.value}`.trim();
|
|
249
|
-
}
|
|
250
|
-
if (schema instanceof z.ZodNumber) {
|
|
251
|
-
const description = getMultilineComment(schema._def.description);
|
|
252
|
-
return `${description} number`.trim();
|
|
253
|
-
}
|
|
254
|
-
if (schema instanceof z.ZodBoolean) {
|
|
255
|
-
const description = getMultilineComment(schema._def.description);
|
|
256
|
-
return `${description} boolean`.trim();
|
|
257
|
-
}
|
|
258
|
-
if (schema instanceof z.ZodCatch) {
|
|
259
|
-
return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
|
|
260
|
-
}
|
|
261
|
-
if (schema instanceof z.ZodLazy) {
|
|
262
|
-
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
263
|
-
}
|
|
264
|
-
if (schema instanceof z.ZodRecord) {
|
|
265
|
-
const description = getMultilineComment(schema._def.description);
|
|
266
|
-
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
267
|
-
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
268
|
-
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
269
|
-
}
|
|
270
|
-
try {
|
|
271
|
-
let typings = await (schema == null ? void 0 : schema.toTypescriptAsync());
|
|
272
|
-
typings ??= "unknown";
|
|
273
|
-
return stripSpaces(typings);
|
|
274
|
-
} catch (error) {
|
|
275
|
-
console.error("Error in sUnwrapZod", { error, schema, parent: options == null ? void 0 : options.parent });
|
|
276
|
-
return "unknown";
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export {
|
|
281
|
-
formatTypings,
|
|
282
|
-
getTypings
|
|
283
|
-
};
|