@loopstack/loopstack-studio 0.23.1 → 0.24.0

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.
Files changed (62) hide show
  1. package/dist/api/index.js +12 -10
  2. package/dist/api/secrets.js +16 -0
  3. package/dist/components/dynamic-form/ArrayController.js +68 -64
  4. package/dist/components/dynamic-form/Form.js +46 -40
  5. package/dist/components/dynamic-form/FormElement.js +1 -1
  6. package/dist/components/dynamic-form/FormElementHeader.js +2 -2
  7. package/dist/components/dynamic-form/ObjectController.js +24 -21
  8. package/dist/components/dynamic-form/fields/BaseFieldWrapper.js +1 -1
  9. package/dist/components/dynamic-form/fields/InputField.js +20 -19
  10. package/dist/components/dynamic-form/fields/RadioField.js +18 -18
  11. package/dist/components/dynamic-form/fields/SelectField.js +19 -19
  12. package/dist/components/dynamic-form/fields/TextareaField.js +17 -17
  13. package/dist/components/layout/MainLayout.js +18 -31
  14. package/dist/components/layout/StudioSidebar.js +168 -108
  15. package/dist/components/page/PageBreadcrumbs.js +79 -32
  16. package/dist/components/ui-widgets/UiWidget.js +36 -27
  17. package/dist/components/ui-widgets/widgets/SecretInput.js +42 -0
  18. package/dist/features/code-explorer/components/FileContentViewer.js +47 -30
  19. package/dist/features/documents/components/DocumentList.js +5 -1
  20. package/dist/features/documents/renderers/AiMessage.js +11 -11
  21. package/dist/features/documents/renderers/DocumentFormRenderer.js +17 -11
  22. package/dist/features/workbench/components/WorkbenchFilesPanel.js +32 -25
  23. package/dist/features/workbench/components/WorkbenchFloatingPanel.js +57 -49
  24. package/dist/features/workbench/components/WorkbenchIconSidebar.js +46 -34
  25. package/dist/features/workbench/components/WorkbenchSecretsPanel.js +182 -0
  26. package/dist/features/workbench/providers/RemoteFileExplorerProvider.js +132 -117
  27. package/dist/hooks/index.js +1 -1
  28. package/dist/hooks/query-keys.js +41 -34
  29. package/dist/hooks/useSecrets.js +69 -0
  30. package/dist/index.d.ts +43 -0
  31. package/dist/index.js +2 -2
  32. package/dist/pages/DashboardPage.js +87 -35
  33. package/dist/pages/EmbedWorkbenchPage.js +43 -39
  34. package/dist/types/ai.types.js +13 -0
  35. package/package.json +2 -3
  36. package/dist/node_modules/@ai-sdk/provider/dist/index.js +0 -65
  37. package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js +0 -1008
  38. package/dist/node_modules/ai/dist/index.js +0 -1083
  39. package/dist/node_modules/zod/v3/ZodError.js +0 -79
  40. package/dist/node_modules/zod/v3/errors.js +0 -6
  41. package/dist/node_modules/zod/v3/helpers/errorUtil.js +0 -5
  42. package/dist/node_modules/zod/v3/helpers/parseUtil.js +0 -90
  43. package/dist/node_modules/zod/v3/helpers/util.js +0 -72
  44. package/dist/node_modules/zod/v3/locales/en.js +0 -58
  45. package/dist/node_modules/zod/v3/types.js +0 -2425
  46. package/dist/node_modules/zod/v4/classic/errors.js +0 -21
  47. package/dist/node_modules/zod/v4/classic/iso.js +0 -29
  48. package/dist/node_modules/zod/v4/classic/parse.js +0 -4
  49. package/dist/node_modules/zod/v4/classic/schemas.js +0 -392
  50. package/dist/node_modules/zod/v4/core/api.js +0 -532
  51. package/dist/node_modules/zod/v4/core/checks.js +0 -283
  52. package/dist/node_modules/zod/v4/core/core.js +0 -44
  53. package/dist/node_modules/zod/v4/core/doc.js +0 -21
  54. package/dist/node_modules/zod/v4/core/errors.js +0 -40
  55. package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -305
  56. package/dist/node_modules/zod/v4/core/parse.js +0 -66
  57. package/dist/node_modules/zod/v4/core/regexes.js +0 -28
  58. package/dist/node_modules/zod/v4/core/registries.js +0 -38
  59. package/dist/node_modules/zod/v4/core/schemas.js +0 -863
  60. package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -220
  61. package/dist/node_modules/zod/v4/core/util.js +0 -267
  62. package/dist/node_modules/zod/v4/core/versions.js +0 -6
@@ -1,283 +0,0 @@
1
- import { $constructor } from "./core.js";
2
- import { NUMBER_FORMAT_RANGES, escapeRegex, floatSafeRemainder, getLengthableOrigin, nullish } from "./util.js";
3
- import { integer, lowercase, uppercase } from "./regexes.js";
4
- const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (t, y) => {
5
- var b;
6
- t._zod ??= {}, t._zod.def = y, (b = t._zod).onattach ?? (b.onattach = []);
7
- });
8
- var numericOriginMap = {
9
- number: "number",
10
- bigint: "bigint",
11
- object: "date"
12
- };
13
- const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (t, y) => {
14
- $ZodCheck.init(t, y);
15
- let b = numericOriginMap[typeof y.value];
16
- t._zod.onattach.push((t) => {
17
- let b = t._zod.bag, x = (y.inclusive ? b.maximum : b.exclusiveMaximum) ?? Infinity;
18
- y.value < x && (y.inclusive ? b.maximum = y.value : b.exclusiveMaximum = y.value);
19
- }), t._zod.check = (x) => {
20
- (y.inclusive ? x.value <= y.value : x.value < y.value) || x.issues.push({
21
- origin: b,
22
- code: "too_big",
23
- maximum: typeof y.value == "object" ? y.value.getTime() : y.value,
24
- input: x.value,
25
- inclusive: y.inclusive,
26
- inst: t,
27
- continue: !y.abort
28
- });
29
- };
30
- }), $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (t, y) => {
31
- $ZodCheck.init(t, y);
32
- let b = numericOriginMap[typeof y.value];
33
- t._zod.onattach.push((t) => {
34
- let b = t._zod.bag, x = (y.inclusive ? b.minimum : b.exclusiveMinimum) ?? -Infinity;
35
- y.value > x && (y.inclusive ? b.minimum = y.value : b.exclusiveMinimum = y.value);
36
- }), t._zod.check = (x) => {
37
- (y.inclusive ? x.value >= y.value : x.value > y.value) || x.issues.push({
38
- origin: b,
39
- code: "too_small",
40
- minimum: typeof y.value == "object" ? y.value.getTime() : y.value,
41
- input: x.value,
42
- inclusive: y.inclusive,
43
- inst: t,
44
- continue: !y.abort
45
- });
46
- };
47
- }), $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (t, y) => {
48
- $ZodCheck.init(t, y), t._zod.onattach.push((t) => {
49
- var b;
50
- (b = t._zod.bag).multipleOf ?? (b.multipleOf = y.value);
51
- }), t._zod.check = (b) => {
52
- if (typeof b.value != typeof y.value) throw Error("Cannot mix number and bigint in multiple_of check.");
53
- (typeof b.value == "bigint" ? b.value % y.value === BigInt(0) : floatSafeRemainder(b.value, y.value) === 0) || b.issues.push({
54
- origin: typeof b.value,
55
- code: "not_multiple_of",
56
- divisor: y.value,
57
- input: b.value,
58
- inst: t,
59
- continue: !y.abort
60
- });
61
- };
62
- }), $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (t, b) => {
63
- $ZodCheck.init(t, b), b.format = b.format || "float64";
64
- let x = b.format?.includes("int"), S = x ? "int" : "number", [C, T] = NUMBER_FORMAT_RANGES[b.format];
65
- t._zod.onattach.push((t) => {
66
- let y = t._zod.bag;
67
- y.format = b.format, y.minimum = C, y.maximum = T, x && (y.pattern = integer);
68
- }), t._zod.check = (y) => {
69
- let w = y.value;
70
- if (x) {
71
- if (!Number.isInteger(w)) {
72
- y.issues.push({
73
- expected: S,
74
- format: b.format,
75
- code: "invalid_type",
76
- continue: !1,
77
- input: w,
78
- inst: t
79
- });
80
- return;
81
- }
82
- if (!Number.isSafeInteger(w)) {
83
- w > 0 ? y.issues.push({
84
- input: w,
85
- code: "too_big",
86
- maximum: 2 ** 53 - 1,
87
- note: "Integers must be within the safe integer range.",
88
- inst: t,
89
- origin: S,
90
- inclusive: !0,
91
- continue: !b.abort
92
- }) : y.issues.push({
93
- input: w,
94
- code: "too_small",
95
- minimum: -(2 ** 53 - 1),
96
- note: "Integers must be within the safe integer range.",
97
- inst: t,
98
- origin: S,
99
- inclusive: !0,
100
- continue: !b.abort
101
- });
102
- return;
103
- }
104
- }
105
- w < C && y.issues.push({
106
- origin: "number",
107
- input: w,
108
- code: "too_small",
109
- minimum: C,
110
- inclusive: !0,
111
- inst: t,
112
- continue: !b.abort
113
- }), w > T && y.issues.push({
114
- origin: "number",
115
- input: w,
116
- code: "too_big",
117
- maximum: T,
118
- inclusive: !0,
119
- inst: t,
120
- continue: !b.abort
121
- });
122
- };
123
- }), $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (t, y) => {
124
- var b;
125
- $ZodCheck.init(t, y), (b = t._zod.def).when ?? (b.when = (t) => {
126
- let y = t.value;
127
- return !nullish(y) && y.length !== void 0;
128
- }), t._zod.onattach.push((t) => {
129
- let b = t._zod.bag.maximum ?? Infinity;
130
- y.maximum < b && (t._zod.bag.maximum = y.maximum);
131
- }), t._zod.check = (b) => {
132
- let x = b.value;
133
- if (x.length <= y.maximum) return;
134
- let C = getLengthableOrigin(x);
135
- b.issues.push({
136
- origin: C,
137
- code: "too_big",
138
- maximum: y.maximum,
139
- inclusive: !0,
140
- input: x,
141
- inst: t,
142
- continue: !y.abort
143
- });
144
- };
145
- }), $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (t, y) => {
146
- var b;
147
- $ZodCheck.init(t, y), (b = t._zod.def).when ?? (b.when = (t) => {
148
- let y = t.value;
149
- return !nullish(y) && y.length !== void 0;
150
- }), t._zod.onattach.push((t) => {
151
- let b = t._zod.bag.minimum ?? -Infinity;
152
- y.minimum > b && (t._zod.bag.minimum = y.minimum);
153
- }), t._zod.check = (b) => {
154
- let x = b.value;
155
- if (x.length >= y.minimum) return;
156
- let C = getLengthableOrigin(x);
157
- b.issues.push({
158
- origin: C,
159
- code: "too_small",
160
- minimum: y.minimum,
161
- inclusive: !0,
162
- input: x,
163
- inst: t,
164
- continue: !y.abort
165
- });
166
- };
167
- }), $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (t, y) => {
168
- var b;
169
- $ZodCheck.init(t, y), (b = t._zod.def).when ?? (b.when = (t) => {
170
- let y = t.value;
171
- return !nullish(y) && y.length !== void 0;
172
- }), t._zod.onattach.push((t) => {
173
- let b = t._zod.bag;
174
- b.minimum = y.length, b.maximum = y.length, b.length = y.length;
175
- }), t._zod.check = (b) => {
176
- let x = b.value, C = x.length;
177
- if (C === y.length) return;
178
- let w = getLengthableOrigin(x), T = C > y.length;
179
- b.issues.push({
180
- origin: w,
181
- ...T ? {
182
- code: "too_big",
183
- maximum: y.length
184
- } : {
185
- code: "too_small",
186
- minimum: y.length
187
- },
188
- inclusive: !0,
189
- exact: !0,
190
- input: b.value,
191
- inst: t,
192
- continue: !y.abort
193
- });
194
- };
195
- }), $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (t, y) => {
196
- var b, x;
197
- $ZodCheck.init(t, y), t._zod.onattach.push((t) => {
198
- let b = t._zod.bag;
199
- b.format = y.format, y.pattern && (b.patterns ??= /* @__PURE__ */ new Set(), b.patterns.add(y.pattern));
200
- }), y.pattern ? (b = t._zod).check ?? (b.check = (b) => {
201
- y.pattern.lastIndex = 0, !y.pattern.test(b.value) && b.issues.push({
202
- origin: "string",
203
- code: "invalid_format",
204
- format: y.format,
205
- input: b.value,
206
- ...y.pattern ? { pattern: y.pattern.toString() } : {},
207
- inst: t,
208
- continue: !y.abort
209
- });
210
- }) : (x = t._zod).check ?? (x.check = () => {});
211
- }), $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (t, y) => {
212
- $ZodCheckStringFormat.init(t, y), t._zod.check = (b) => {
213
- y.pattern.lastIndex = 0, !y.pattern.test(b.value) && b.issues.push({
214
- origin: "string",
215
- code: "invalid_format",
216
- format: "regex",
217
- input: b.value,
218
- pattern: y.pattern.toString(),
219
- inst: t,
220
- continue: !y.abort
221
- });
222
- };
223
- }), $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (t, y) => {
224
- y.pattern ??= lowercase, $ZodCheckStringFormat.init(t, y);
225
- }), $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (t, y) => {
226
- y.pattern ??= uppercase, $ZodCheckStringFormat.init(t, y);
227
- }), $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (t, y) => {
228
- $ZodCheck.init(t, y);
229
- let x = escapeRegex(y.includes), S = new RegExp(typeof y.position == "number" ? `^.{${y.position}}${x}` : x);
230
- y.pattern = S, t._zod.onattach.push((t) => {
231
- let y = t._zod.bag;
232
- y.patterns ??= /* @__PURE__ */ new Set(), y.patterns.add(S);
233
- }), t._zod.check = (b) => {
234
- b.value.includes(y.includes, y.position) || b.issues.push({
235
- origin: "string",
236
- code: "invalid_format",
237
- format: "includes",
238
- includes: y.includes,
239
- input: b.value,
240
- inst: t,
241
- continue: !y.abort
242
- });
243
- };
244
- }), $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (t, y) => {
245
- $ZodCheck.init(t, y);
246
- let x = /* @__PURE__ */ RegExp(`^${escapeRegex(y.prefix)}.*`);
247
- y.pattern ??= x, t._zod.onattach.push((t) => {
248
- let y = t._zod.bag;
249
- y.patterns ??= /* @__PURE__ */ new Set(), y.patterns.add(x);
250
- }), t._zod.check = (b) => {
251
- b.value.startsWith(y.prefix) || b.issues.push({
252
- origin: "string",
253
- code: "invalid_format",
254
- format: "starts_with",
255
- prefix: y.prefix,
256
- input: b.value,
257
- inst: t,
258
- continue: !y.abort
259
- });
260
- };
261
- }), $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (t, y) => {
262
- $ZodCheck.init(t, y);
263
- let x = /* @__PURE__ */ RegExp(`.*${escapeRegex(y.suffix)}$`);
264
- y.pattern ??= x, t._zod.onattach.push((t) => {
265
- let y = t._zod.bag;
266
- y.patterns ??= /* @__PURE__ */ new Set(), y.patterns.add(x);
267
- }), t._zod.check = (b) => {
268
- b.value.endsWith(y.suffix) || b.issues.push({
269
- origin: "string",
270
- code: "invalid_format",
271
- format: "ends_with",
272
- suffix: y.suffix,
273
- input: b.value,
274
- inst: t,
275
- continue: !y.abort
276
- });
277
- };
278
- }), $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (t, y) => {
279
- $ZodCheck.init(t, y), t._zod.check = (t) => {
280
- t.value = y.tx(t.value);
281
- };
282
- });
283
- export { $ZodCheck, $ZodCheckEndsWith, $ZodCheckGreaterThan, $ZodCheckIncludes, $ZodCheckLengthEquals, $ZodCheckLessThan, $ZodCheckLowerCase, $ZodCheckMaxLength, $ZodCheckMinLength, $ZodCheckMultipleOf, $ZodCheckNumberFormat, $ZodCheckOverwrite, $ZodCheckRegex, $ZodCheckStartsWith, $ZodCheckStringFormat, $ZodCheckUpperCase };
@@ -1,44 +0,0 @@
1
- Object.freeze({ status: "aborted" });
2
- function $constructor(e, t, n) {
3
- function r(n, r) {
4
- if (n._zod || Object.defineProperty(n, "_zod", {
5
- value: {
6
- def: r,
7
- constr: o,
8
- traits: /* @__PURE__ */ new Set()
9
- },
10
- enumerable: !1
11
- }), n._zod.traits.has(e)) return;
12
- n._zod.traits.add(e), t(n, r);
13
- let i = o.prototype, a = Object.keys(i);
14
- for (let e = 0; e < a.length; e++) {
15
- let t = a[e];
16
- t in n || (n[t] = i[t].bind(n));
17
- }
18
- }
19
- let i = n?.Parent ?? Object;
20
- class a extends i {}
21
- Object.defineProperty(a, "name", { value: e });
22
- function o(e) {
23
- var t;
24
- let i = n?.Parent ? new a() : this;
25
- r(i, e), (t = i._zod).deferred ?? (t.deferred = []);
26
- for (let e of i._zod.deferred) e();
27
- return i;
28
- }
29
- return Object.defineProperty(o, "init", { value: r }), Object.defineProperty(o, Symbol.hasInstance, { value: (t) => n?.Parent && t instanceof n.Parent ? !0 : t?._zod?.traits?.has(e) }), Object.defineProperty(o, "name", { value: e }), o;
30
- }
31
- var $ZodAsyncError = class extends Error {
32
- constructor() {
33
- super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
34
- }
35
- }, $ZodEncodeError = class extends Error {
36
- constructor(e) {
37
- super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
38
- }
39
- };
40
- const globalConfig = {};
41
- function config(e) {
42
- return e && Object.assign(globalConfig, e), globalConfig;
43
- }
44
- export { $ZodAsyncError, $ZodEncodeError, $constructor, config, globalConfig };
@@ -1,21 +0,0 @@
1
- var Doc = class {
2
- constructor(e = []) {
3
- this.content = [], this.indent = 0, this && (this.args = e);
4
- }
5
- indented(e) {
6
- this.indent += 1, e(this), --this.indent;
7
- }
8
- write(e) {
9
- if (typeof e == "function") {
10
- e(this, { execution: "sync" }), e(this, { execution: "async" });
11
- return;
12
- }
13
- let t = e.split("\n").filter((e) => e), n = Math.min(...t.map((e) => e.length - e.trimStart().length)), r = t.map((e) => e.slice(n)).map((e) => " ".repeat(this.indent * 2) + e);
14
- for (let e of r) this.content.push(e);
15
- }
16
- compile() {
17
- let e = Function, t = this?.args, n = [...(this?.content ?? [""]).map((e) => ` ${e}`)];
18
- return new e(...t, n.join("\n"));
19
- }
20
- };
21
- export { Doc };
@@ -1,40 +0,0 @@
1
- import { $constructor } from "./core.js";
2
- import { jsonStringifyReplacer } from "./util.js";
3
- var initializer = (e, i) => {
4
- e.name = "$ZodError", Object.defineProperty(e, "_zod", {
5
- value: e._zod,
6
- enumerable: !1
7
- }), Object.defineProperty(e, "issues", {
8
- value: i,
9
- enumerable: !1
10
- }), e.message = JSON.stringify(i, jsonStringifyReplacer, 2), Object.defineProperty(e, "toString", {
11
- value: () => e.message,
12
- enumerable: !1
13
- });
14
- };
15
- const $ZodError = $constructor("$ZodError", initializer), $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
16
- function flattenError(e, r = (e) => e.message) {
17
- let i = {}, a = [];
18
- for (let o of e.issues) o.path.length > 0 ? (i[o.path[0]] = i[o.path[0]] || [], i[o.path[0]].push(r(o))) : a.push(r(o));
19
- return {
20
- formErrors: a,
21
- fieldErrors: i
22
- };
23
- }
24
- function formatError(e, r = (e) => e.message) {
25
- let i = { _errors: [] }, a = (e) => {
26
- for (let o of e.issues) if (o.code === "invalid_union" && o.errors.length) o.errors.map((e) => a({ issues: e }));
27
- else if (o.code === "invalid_key") a({ issues: o.issues });
28
- else if (o.code === "invalid_element") a({ issues: o.issues });
29
- else if (o.path.length === 0) i._errors.push(r(o));
30
- else {
31
- let e = i, a = 0;
32
- for (; a < o.path.length;) {
33
- let i = o.path[a];
34
- a === o.path.length - 1 ? (e[i] = e[i] || { _errors: [] }, e[i]._errors.push(r(o))) : e[i] = e[i] || { _errors: [] }, e = e[i], a++;
35
- }
36
- }
37
- };
38
- return a(e), i;
39
- }
40
- export { $ZodError, $ZodRealError, flattenError, formatError };
@@ -1,305 +0,0 @@
1
- import { getEnumValues } from "./util.js";
2
- import { extractDefs, finalize, initializeContext, process } from "./to-json-schema.js";
3
- var formatMap = {
4
- guid: "uuid",
5
- url: "uri",
6
- datetime: "date-time",
7
- json_string: "json-string",
8
- regex: ""
9
- };
10
- const stringProcessor = (l, F, I, L) => {
11
- let R = I;
12
- R.type = "string";
13
- let { minimum: B, maximum: V, format: H, patterns: U, contentEncoding: W } = l._zod.bag;
14
- if (typeof B == "number" && (R.minLength = B), typeof V == "number" && (R.maxLength = V), H && (R.format = formatMap[H] ?? H, R.format === "" && delete R.format, H === "time" && delete R.format), W && (R.contentEncoding = W), U && U.size > 0) {
15
- let l = [...U];
16
- l.length === 1 ? R.pattern = l[0].source : l.length > 1 && (R.allOf = [...l.map((l) => ({
17
- ...F.target === "draft-07" || F.target === "draft-04" || F.target === "openapi-3.0" ? { type: "string" } : {},
18
- pattern: l.source
19
- }))]);
20
- }
21
- }, numberProcessor = (l, F, I, L) => {
22
- let R = I, { minimum: z, maximum: B, format: V, multipleOf: H, exclusiveMaximum: U, exclusiveMinimum: W } = l._zod.bag;
23
- typeof V == "string" && V.includes("int") ? R.type = "integer" : R.type = "number", typeof W == "number" && (F.target === "draft-04" || F.target === "openapi-3.0" ? (R.minimum = W, R.exclusiveMinimum = !0) : R.exclusiveMinimum = W), typeof z == "number" && (R.minimum = z, typeof W == "number" && F.target !== "draft-04" && (W >= z ? delete R.minimum : delete R.exclusiveMinimum)), typeof U == "number" && (F.target === "draft-04" || F.target === "openapi-3.0" ? (R.maximum = U, R.exclusiveMaximum = !0) : R.exclusiveMaximum = U), typeof B == "number" && (R.maximum = B, typeof U == "number" && F.target !== "draft-04" && (U <= B ? delete R.maximum : delete R.exclusiveMaximum)), typeof H == "number" && (R.multipleOf = H);
24
- }, booleanProcessor = (l, F, I, L) => {
25
- I.type = "boolean";
26
- }, bigintProcessor = (l, F, I, L) => {
27
- if (F.unrepresentable === "throw") throw Error("BigInt cannot be represented in JSON Schema");
28
- }, symbolProcessor = (l, F, I, L) => {
29
- if (F.unrepresentable === "throw") throw Error("Symbols cannot be represented in JSON Schema");
30
- }, nullProcessor = (l, F, I, L) => {
31
- F.target === "openapi-3.0" ? (I.type = "string", I.nullable = !0, I.enum = [null]) : I.type = "null";
32
- }, undefinedProcessor = (l, F, I, L) => {
33
- if (F.unrepresentable === "throw") throw Error("Undefined cannot be represented in JSON Schema");
34
- }, voidProcessor = (l, F, I, L) => {
35
- if (F.unrepresentable === "throw") throw Error("Void cannot be represented in JSON Schema");
36
- }, neverProcessor = (l, F, I, L) => {
37
- I.not = {};
38
- }, anyProcessor = (l, F, I, L) => {}, unknownProcessor = (l, F, I, L) => {}, dateProcessor = (l, F, I, L) => {
39
- if (F.unrepresentable === "throw") throw Error("Date cannot be represented in JSON Schema");
40
- }, enumProcessor = (F, I, L, R) => {
41
- let z = F._zod.def, B = getEnumValues(z.entries);
42
- B.every((l) => typeof l == "number") && (L.type = "number"), B.every((l) => typeof l == "string") && (L.type = "string"), L.enum = B;
43
- }, literalProcessor = (l, F, I, L) => {
44
- let R = l._zod.def, z = [];
45
- for (let l of R.values) if (l === void 0) {
46
- if (F.unrepresentable === "throw") throw Error("Literal `undefined` cannot be represented in JSON Schema");
47
- } else if (typeof l == "bigint") {
48
- if (F.unrepresentable === "throw") throw Error("BigInt literals cannot be represented in JSON Schema");
49
- z.push(Number(l));
50
- } else z.push(l);
51
- if (z.length !== 0) if (z.length === 1) {
52
- let l = z[0];
53
- I.type = l === null ? "null" : typeof l, F.target === "draft-04" || F.target === "openapi-3.0" ? I.enum = [l] : I.const = l;
54
- } else z.every((l) => typeof l == "number") && (I.type = "number"), z.every((l) => typeof l == "string") && (I.type = "string"), z.every((l) => typeof l == "boolean") && (I.type = "boolean"), z.every((l) => l === null) && (I.type = "null"), I.enum = z;
55
- }, nanProcessor = (l, F, I, L) => {
56
- if (F.unrepresentable === "throw") throw Error("NaN cannot be represented in JSON Schema");
57
- }, templateLiteralProcessor = (l, F, I, L) => {
58
- let R = I, z = l._zod.pattern;
59
- if (!z) throw Error("Pattern not found in template literal");
60
- R.type = "string", R.pattern = z.source;
61
- }, fileProcessor = (l, F, I, L) => {
62
- let R = I, z = {
63
- type: "string",
64
- format: "binary",
65
- contentEncoding: "binary"
66
- }, { minimum: B, maximum: V, mime: H } = l._zod.bag;
67
- B !== void 0 && (z.minLength = B), V !== void 0 && (z.maxLength = V), H ? H.length === 1 ? (z.contentMediaType = H[0], Object.assign(R, z)) : (Object.assign(R, z), R.anyOf = H.map((l) => ({ contentMediaType: l }))) : Object.assign(R, z);
68
- }, successProcessor = (l, F, I, L) => {
69
- I.type = "boolean";
70
- }, customProcessor = (l, F, I, L) => {
71
- if (F.unrepresentable === "throw") throw Error("Custom types cannot be represented in JSON Schema");
72
- }, functionProcessor = (l, F, I, L) => {
73
- if (F.unrepresentable === "throw") throw Error("Function types cannot be represented in JSON Schema");
74
- }, transformProcessor = (l, F, I, L) => {
75
- if (F.unrepresentable === "throw") throw Error("Transforms cannot be represented in JSON Schema");
76
- }, mapProcessor = (l, F, I, L) => {
77
- if (F.unrepresentable === "throw") throw Error("Map cannot be represented in JSON Schema");
78
- }, setProcessor = (l, F, I, L) => {
79
- if (F.unrepresentable === "throw") throw Error("Set cannot be represented in JSON Schema");
80
- }, arrayProcessor = (l, F, I, L) => {
81
- let z = I, B = l._zod.def, { minimum: V, maximum: H } = l._zod.bag;
82
- typeof V == "number" && (z.minItems = V), typeof H == "number" && (z.maxItems = H), z.type = "array", z.items = process(B.element, F, {
83
- ...L,
84
- path: [...L.path, "items"]
85
- });
86
- }, objectProcessor = (l, F, I, L) => {
87
- let z = I, B = l._zod.def;
88
- z.type = "object", z.properties = {};
89
- let V = B.shape;
90
- for (let l in V) z.properties[l] = process(V[l], F, {
91
- ...L,
92
- path: [
93
- ...L.path,
94
- "properties",
95
- l
96
- ]
97
- });
98
- let H = new Set(Object.keys(V)), U = new Set([...H].filter((l) => {
99
- let I = B.shape[l]._zod;
100
- return F.io === "input" ? I.optin === void 0 : I.optout === void 0;
101
- }));
102
- U.size > 0 && (z.required = Array.from(U)), B.catchall?._zod.def.type === "never" ? z.additionalProperties = !1 : B.catchall ? B.catchall && (z.additionalProperties = process(B.catchall, F, {
103
- ...L,
104
- path: [...L.path, "additionalProperties"]
105
- })) : F.io === "output" && (z.additionalProperties = !1);
106
- }, unionProcessor = (l, F, I, L) => {
107
- let z = l._zod.def, B = z.inclusive === !1, V = z.options.map((l, I) => process(l, F, {
108
- ...L,
109
- path: [
110
- ...L.path,
111
- B ? "oneOf" : "anyOf",
112
- I
113
- ]
114
- }));
115
- B ? I.oneOf = V : I.anyOf = V;
116
- }, intersectionProcessor = (l, F, I, L) => {
117
- let z = l._zod.def, B = process(z.left, F, {
118
- ...L,
119
- path: [
120
- ...L.path,
121
- "allOf",
122
- 0
123
- ]
124
- }), V = process(z.right, F, {
125
- ...L,
126
- path: [
127
- ...L.path,
128
- "allOf",
129
- 1
130
- ]
131
- }), H = (l) => "allOf" in l && Object.keys(l).length === 1;
132
- I.allOf = [...H(B) ? B.allOf : [B], ...H(V) ? V.allOf : [V]];
133
- }, tupleProcessor = (l, F, I, L) => {
134
- let z = I, B = l._zod.def;
135
- z.type = "array";
136
- let V = F.target === "draft-2020-12" ? "prefixItems" : "items", H = F.target === "draft-2020-12" || F.target === "openapi-3.0" ? "items" : "additionalItems", U = B.items.map((l, I) => process(l, F, {
137
- ...L,
138
- path: [
139
- ...L.path,
140
- V,
141
- I
142
- ]
143
- })), W = B.rest ? process(B.rest, F, {
144
- ...L,
145
- path: [
146
- ...L.path,
147
- H,
148
- ...F.target === "openapi-3.0" ? [B.items.length] : []
149
- ]
150
- }) : null;
151
- F.target === "draft-2020-12" ? (z.prefixItems = U, W && (z.items = W)) : F.target === "openapi-3.0" ? (z.items = { anyOf: U }, W && z.items.anyOf.push(W), z.minItems = U.length, W || (z.maxItems = U.length)) : (z.items = U, W && (z.additionalItems = W));
152
- let { minimum: G, maximum: K } = l._zod.bag;
153
- typeof G == "number" && (z.minItems = G), typeof K == "number" && (z.maxItems = K);
154
- }, recordProcessor = (l, F, I, L) => {
155
- let z = I, B = l._zod.def;
156
- z.type = "object";
157
- let V = B.keyType, H = V._zod.bag?.patterns;
158
- if (B.mode === "loose" && H && H.size > 0) {
159
- let l = process(B.valueType, F, {
160
- ...L,
161
- path: [
162
- ...L.path,
163
- "patternProperties",
164
- "*"
165
- ]
166
- });
167
- z.patternProperties = {};
168
- for (let F of H) z.patternProperties[F.source] = l;
169
- } else (F.target === "draft-07" || F.target === "draft-2020-12") && (z.propertyNames = process(B.keyType, F, {
170
- ...L,
171
- path: [...L.path, "propertyNames"]
172
- })), z.additionalProperties = process(B.valueType, F, {
173
- ...L,
174
- path: [...L.path, "additionalProperties"]
175
- });
176
- let U = V._zod.values;
177
- if (U) {
178
- let l = [...U].filter((l) => typeof l == "string" || typeof l == "number");
179
- l.length > 0 && (z.required = l);
180
- }
181
- }, nullableProcessor = (l, F, I, L) => {
182
- let z = l._zod.def, B = process(z.innerType, F, L), V = F.seen.get(l);
183
- F.target === "openapi-3.0" ? (V.ref = z.innerType, I.nullable = !0) : I.anyOf = [B, { type: "null" }];
184
- }, nonoptionalProcessor = (l, F, I, L) => {
185
- let z = l._zod.def;
186
- process(z.innerType, F, L);
187
- let B = F.seen.get(l);
188
- B.ref = z.innerType;
189
- }, defaultProcessor = (l, F, I, L) => {
190
- let z = l._zod.def;
191
- process(z.innerType, F, L);
192
- let B = F.seen.get(l);
193
- B.ref = z.innerType, I.default = JSON.parse(JSON.stringify(z.defaultValue));
194
- }, prefaultProcessor = (l, F, I, L) => {
195
- let z = l._zod.def;
196
- process(z.innerType, F, L);
197
- let B = F.seen.get(l);
198
- B.ref = z.innerType, F.io === "input" && (I._prefault = JSON.parse(JSON.stringify(z.defaultValue)));
199
- }, catchProcessor = (l, F, I, L) => {
200
- let z = l._zod.def;
201
- process(z.innerType, F, L);
202
- let B = F.seen.get(l);
203
- B.ref = z.innerType;
204
- let V;
205
- try {
206
- V = z.catchValue(void 0);
207
- } catch {
208
- throw Error("Dynamic catch values are not supported in JSON Schema");
209
- }
210
- I.default = V;
211
- }, pipeProcessor = (l, F, I, L) => {
212
- let z = l._zod.def, B = F.io === "input" ? z.in._zod.def.type === "transform" ? z.out : z.in : z.out;
213
- process(B, F, L);
214
- let V = F.seen.get(l);
215
- V.ref = B;
216
- }, readonlyProcessor = (l, F, I, L) => {
217
- let z = l._zod.def;
218
- process(z.innerType, F, L);
219
- let B = F.seen.get(l);
220
- B.ref = z.innerType, I.readOnly = !0;
221
- }, promiseProcessor = (l, F, I, L) => {
222
- let z = l._zod.def;
223
- process(z.innerType, F, L);
224
- let B = F.seen.get(l);
225
- B.ref = z.innerType;
226
- }, optionalProcessor = (l, F, I, L) => {
227
- let z = l._zod.def;
228
- process(z.innerType, F, L);
229
- let B = F.seen.get(l);
230
- B.ref = z.innerType;
231
- }, lazyProcessor = (l, F, I, L) => {
232
- let z = l._zod.innerType;
233
- process(z, F, L);
234
- let B = F.seen.get(l);
235
- B.ref = z;
236
- }, allProcessors = {
237
- string: stringProcessor,
238
- number: numberProcessor,
239
- boolean: booleanProcessor,
240
- bigint: bigintProcessor,
241
- symbol: symbolProcessor,
242
- null: nullProcessor,
243
- undefined: undefinedProcessor,
244
- void: voidProcessor,
245
- never: neverProcessor,
246
- any: anyProcessor,
247
- unknown: unknownProcessor,
248
- date: dateProcessor,
249
- enum: enumProcessor,
250
- literal: literalProcessor,
251
- nan: nanProcessor,
252
- template_literal: templateLiteralProcessor,
253
- file: fileProcessor,
254
- success: successProcessor,
255
- custom: customProcessor,
256
- function: functionProcessor,
257
- transform: transformProcessor,
258
- map: mapProcessor,
259
- set: setProcessor,
260
- array: arrayProcessor,
261
- object: objectProcessor,
262
- union: unionProcessor,
263
- intersection: intersectionProcessor,
264
- tuple: tupleProcessor,
265
- record: recordProcessor,
266
- nullable: nullableProcessor,
267
- nonoptional: nonoptionalProcessor,
268
- default: defaultProcessor,
269
- prefault: prefaultProcessor,
270
- catch: catchProcessor,
271
- pipe: pipeProcessor,
272
- readonly: readonlyProcessor,
273
- promise: promiseProcessor,
274
- optional: optionalProcessor,
275
- lazy: lazyProcessor
276
- };
277
- function toJSONSchema(l, z) {
278
- if ("_idmap" in l) {
279
- let B = l, V = initializeContext({
280
- ...z,
281
- processors: allProcessors
282
- }), H = {};
283
- for (let l of B._idmap.entries()) {
284
- let [F, I] = l;
285
- process(I, V);
286
- }
287
- let U = {};
288
- V.external = {
289
- registry: B,
290
- uri: z?.uri,
291
- defs: H
292
- };
293
- for (let l of B._idmap.entries()) {
294
- let [L, R] = l;
295
- extractDefs(V, R), U[L] = finalize(V, R);
296
- }
297
- return Object.keys(H).length > 0 && (U.__shared = { [V.target === "draft-2020-12" ? "$defs" : "definitions"]: H }), { schemas: U };
298
- }
299
- let B = initializeContext({
300
- ...z,
301
- processors: allProcessors
302
- });
303
- return process(l, B), extractDefs(B, l), finalize(B, l);
304
- }
305
- export { arrayProcessor, booleanProcessor, catchProcessor, customProcessor, defaultProcessor, enumProcessor, intersectionProcessor, lazyProcessor, literalProcessor, neverProcessor, nonoptionalProcessor, nullProcessor, nullableProcessor, numberProcessor, objectProcessor, optionalProcessor, pipeProcessor, prefaultProcessor, readonlyProcessor, recordProcessor, stringProcessor, toJSONSchema, transformProcessor, unionProcessor, unknownProcessor };