@alfe.ai/openclaw 0.0.11 → 0.0.13
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/index.js +27 -2
- package/dist/plugin2.js +49 -3266
- package/package.json +5 -4
package/dist/plugin2.js
CHANGED
|
@@ -1,3251 +1,11 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { join } from "node:path";
|
|
3
2
|
import { homedir } from "node:os";
|
|
4
3
|
import { Type } from "@sinclair/typebox";
|
|
4
|
+
import { resolveConfig } from "@alfe.ai/config";
|
|
5
5
|
import { createConnection } from "node:net";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { EventEmitter } from "node:events";
|
|
8
8
|
import { createLogger } from "@auriclabs/logger";
|
|
9
|
-
//#region \0rolldown/runtime.js
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
-
key = keys[i];
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
-
get: ((k) => from[k]).bind(null, key),
|
|
22
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region ../../packages-internal/ids/dist/prefixes.js
|
|
34
|
-
const ID_PREFIXES = {
|
|
35
|
-
agent: "agt",
|
|
36
|
-
organization: "org",
|
|
37
|
-
person: "per",
|
|
38
|
-
auditEvent: "evt",
|
|
39
|
-
token: "tok",
|
|
40
|
-
transaction: "txn",
|
|
41
|
-
subscription: "sub",
|
|
42
|
-
conversation: "conv",
|
|
43
|
-
referral: "ref",
|
|
44
|
-
promoCode: "prc",
|
|
45
|
-
promoRedemption: "prr",
|
|
46
|
-
pendingPromo: "pdp",
|
|
47
|
-
webhook: "whk",
|
|
48
|
-
webhookDelivery: "wdl",
|
|
49
|
-
onboardingSession: "obs",
|
|
50
|
-
inviteToken: "inv",
|
|
51
|
-
claimToken: "clm",
|
|
52
|
-
run: "run",
|
|
53
|
-
request: "req",
|
|
54
|
-
connection: "conn",
|
|
55
|
-
correlation: "cor",
|
|
56
|
-
command: "cmd",
|
|
57
|
-
message: "msg",
|
|
58
|
-
ipcRequest: "ipc",
|
|
59
|
-
pluginConnection: "plg"
|
|
60
|
-
};
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region ../../packages-internal/ids/dist/create.js
|
|
63
|
-
var import_index_umd = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64
|
-
(function(global, factory) {
|
|
65
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.ULID = {}));
|
|
66
|
-
})(exports, (function(exports$1) {
|
|
67
|
-
"use strict";
|
|
68
|
-
function createError(message) {
|
|
69
|
-
const err = new Error(message);
|
|
70
|
-
err.source = "ulid";
|
|
71
|
-
return err;
|
|
72
|
-
}
|
|
73
|
-
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
74
|
-
const ENCODING_LEN = 32;
|
|
75
|
-
const TIME_MAX = Math.pow(2, 48) - 1;
|
|
76
|
-
const TIME_LEN = 10;
|
|
77
|
-
const RANDOM_LEN = 16;
|
|
78
|
-
function replaceCharAt(str, index, char) {
|
|
79
|
-
if (index > str.length - 1) return str;
|
|
80
|
-
return str.substr(0, index) + char + str.substr(index + 1);
|
|
81
|
-
}
|
|
82
|
-
function incrementBase32(str) {
|
|
83
|
-
let done = void 0;
|
|
84
|
-
let index = str.length;
|
|
85
|
-
let char;
|
|
86
|
-
let charIndex;
|
|
87
|
-
const maxCharIndex = ENCODING_LEN - 1;
|
|
88
|
-
while (!done && index-- >= 0) {
|
|
89
|
-
char = str[index];
|
|
90
|
-
charIndex = ENCODING.indexOf(char);
|
|
91
|
-
if (charIndex === -1) throw createError("incorrectly encoded string");
|
|
92
|
-
if (charIndex === maxCharIndex) {
|
|
93
|
-
str = replaceCharAt(str, index, ENCODING[0]);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
done = replaceCharAt(str, index, ENCODING[charIndex + 1]);
|
|
97
|
-
}
|
|
98
|
-
if (typeof done === "string") return done;
|
|
99
|
-
throw createError("cannot increment this string");
|
|
100
|
-
}
|
|
101
|
-
function randomChar(prng) {
|
|
102
|
-
let rand = Math.floor(prng() * ENCODING_LEN);
|
|
103
|
-
if (rand === ENCODING_LEN) rand = ENCODING_LEN - 1;
|
|
104
|
-
return ENCODING.charAt(rand);
|
|
105
|
-
}
|
|
106
|
-
function encodeTime(now, len) {
|
|
107
|
-
if (isNaN(now)) throw new Error(now + " must be a number");
|
|
108
|
-
if (now > TIME_MAX) throw createError("cannot encode time greater than " + TIME_MAX);
|
|
109
|
-
if (now < 0) throw createError("time must be positive");
|
|
110
|
-
if (Number.isInteger(Number(now)) === false) throw createError("time must be an integer");
|
|
111
|
-
let mod;
|
|
112
|
-
let str = "";
|
|
113
|
-
for (; len > 0; len--) {
|
|
114
|
-
mod = now % ENCODING_LEN;
|
|
115
|
-
str = ENCODING.charAt(mod) + str;
|
|
116
|
-
now = (now - mod) / ENCODING_LEN;
|
|
117
|
-
}
|
|
118
|
-
return str;
|
|
119
|
-
}
|
|
120
|
-
function encodeRandom(len, prng) {
|
|
121
|
-
let str = "";
|
|
122
|
-
for (; len > 0; len--) str = randomChar(prng) + str;
|
|
123
|
-
return str;
|
|
124
|
-
}
|
|
125
|
-
function decodeTime(id) {
|
|
126
|
-
if (id.length !== TIME_LEN + RANDOM_LEN) throw createError("malformed ulid");
|
|
127
|
-
var time = id.substr(0, TIME_LEN).split("").reverse().reduce((carry, char, index) => {
|
|
128
|
-
const encodingIndex = ENCODING.indexOf(char);
|
|
129
|
-
if (encodingIndex === -1) throw createError("invalid character found: " + char);
|
|
130
|
-
return carry += encodingIndex * Math.pow(ENCODING_LEN, index);
|
|
131
|
-
}, 0);
|
|
132
|
-
if (time > TIME_MAX) throw createError("malformed ulid, timestamp too large");
|
|
133
|
-
return time;
|
|
134
|
-
}
|
|
135
|
-
function detectPrng(allowInsecure = false, root) {
|
|
136
|
-
if (!root) root = typeof window !== "undefined" ? window : null;
|
|
137
|
-
const browserCrypto = root && (root.crypto || root.msCrypto);
|
|
138
|
-
if (browserCrypto) return () => {
|
|
139
|
-
const buffer = new Uint8Array(1);
|
|
140
|
-
browserCrypto.getRandomValues(buffer);
|
|
141
|
-
return buffer[0] / 255;
|
|
142
|
-
};
|
|
143
|
-
else try {
|
|
144
|
-
const nodeCrypto = __require("crypto");
|
|
145
|
-
return () => nodeCrypto.randomBytes(1).readUInt8() / 255;
|
|
146
|
-
} catch (e) {}
|
|
147
|
-
if (allowInsecure) {
|
|
148
|
-
try {
|
|
149
|
-
console.error("secure crypto unusable, falling back to insecure Math.random()!");
|
|
150
|
-
} catch (e) {}
|
|
151
|
-
return () => Math.random();
|
|
152
|
-
}
|
|
153
|
-
throw createError("secure crypto unusable, insecure Math.random not allowed");
|
|
154
|
-
}
|
|
155
|
-
function factory(currPrng) {
|
|
156
|
-
if (!currPrng) currPrng = detectPrng();
|
|
157
|
-
return function ulid(seedTime) {
|
|
158
|
-
if (isNaN(seedTime)) seedTime = Date.now();
|
|
159
|
-
return encodeTime(seedTime, TIME_LEN) + encodeRandom(RANDOM_LEN, currPrng);
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
function monotonicFactory(currPrng) {
|
|
163
|
-
if (!currPrng) currPrng = detectPrng();
|
|
164
|
-
let lastTime = 0;
|
|
165
|
-
let lastRandom;
|
|
166
|
-
return function ulid(seedTime) {
|
|
167
|
-
if (isNaN(seedTime)) seedTime = Date.now();
|
|
168
|
-
if (seedTime <= lastTime) {
|
|
169
|
-
const incrementedRandom = lastRandom = incrementBase32(lastRandom);
|
|
170
|
-
return encodeTime(lastTime, TIME_LEN) + incrementedRandom;
|
|
171
|
-
}
|
|
172
|
-
lastTime = seedTime;
|
|
173
|
-
const newRandom = lastRandom = encodeRandom(RANDOM_LEN, currPrng);
|
|
174
|
-
return encodeTime(seedTime, TIME_LEN) + newRandom;
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
const ulid = factory();
|
|
178
|
-
exports$1.decodeTime = decodeTime;
|
|
179
|
-
exports$1.detectPrng = detectPrng;
|
|
180
|
-
exports$1.encodeRandom = encodeRandom;
|
|
181
|
-
exports$1.encodeTime = encodeTime;
|
|
182
|
-
exports$1.factory = factory;
|
|
183
|
-
exports$1.incrementBase32 = incrementBase32;
|
|
184
|
-
exports$1.monotonicFactory = monotonicFactory;
|
|
185
|
-
exports$1.randomChar = randomChar;
|
|
186
|
-
exports$1.replaceCharAt = replaceCharAt;
|
|
187
|
-
exports$1.ulid = ulid;
|
|
188
|
-
}));
|
|
189
|
-
})))();
|
|
190
|
-
function createId(prefix) {
|
|
191
|
-
return `${prefix}_${(0, import_index_umd.ulid)()}`;
|
|
192
|
-
}
|
|
193
|
-
function correlationId() {
|
|
194
|
-
return createId(ID_PREFIXES.correlation);
|
|
195
|
-
}
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region ../../packages-internal/api-client/dist/client.js
|
|
198
|
-
/**
|
|
199
|
-
* @alfe/api-client — Typed HTTP client for Alfe services.
|
|
200
|
-
*
|
|
201
|
-
* Platform-agnostic: works in React Native and browser environments.
|
|
202
|
-
* Uses standard fetch() API — no Node.js dependencies.
|
|
203
|
-
*/
|
|
204
|
-
var AlfeApiClient = class {
|
|
205
|
-
apiBaseUrl;
|
|
206
|
-
getToken;
|
|
207
|
-
onAuthFailure;
|
|
208
|
-
constructor(options) {
|
|
209
|
-
this.apiBaseUrl = options.apiBaseUrl;
|
|
210
|
-
this.getToken = options.getToken;
|
|
211
|
-
this.onAuthFailure = options.onAuthFailure;
|
|
212
|
-
}
|
|
213
|
-
/** Shared fetch logic — handles auth, 401, and network errors. */
|
|
214
|
-
async _fetch(path, options) {
|
|
215
|
-
try {
|
|
216
|
-
const token = await this.getToken();
|
|
217
|
-
if (!token) {
|
|
218
|
-
this.onAuthFailure?.();
|
|
219
|
-
return {
|
|
220
|
-
ok: false,
|
|
221
|
-
result: {
|
|
222
|
-
ok: false,
|
|
223
|
-
error: "No auth token available",
|
|
224
|
-
status: 401
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
const url = `${this.apiBaseUrl}${path}`;
|
|
229
|
-
const headers = new Headers(options?.headers);
|
|
230
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
231
|
-
headers.set("Content-Type", "application/json");
|
|
232
|
-
headers.set("x-correlation-id", correlationId());
|
|
233
|
-
const res = await fetch(url, {
|
|
234
|
-
...options,
|
|
235
|
-
headers
|
|
236
|
-
});
|
|
237
|
-
if (res.status === 401) {
|
|
238
|
-
this.onAuthFailure?.();
|
|
239
|
-
return {
|
|
240
|
-
ok: false,
|
|
241
|
-
result: {
|
|
242
|
-
ok: false,
|
|
243
|
-
error: "Session expired",
|
|
244
|
-
status: 401
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
const body = await res.json();
|
|
249
|
-
if (!res.ok) return {
|
|
250
|
-
ok: false,
|
|
251
|
-
result: {
|
|
252
|
-
ok: false,
|
|
253
|
-
error: body.message || `API error: ${String(res.status)}`,
|
|
254
|
-
status: res.status
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
return {
|
|
258
|
-
ok: true,
|
|
259
|
-
res,
|
|
260
|
-
body
|
|
261
|
-
};
|
|
262
|
-
} catch (err) {
|
|
263
|
-
return {
|
|
264
|
-
ok: false,
|
|
265
|
-
result: {
|
|
266
|
-
ok: false,
|
|
267
|
-
error: err instanceof Error ? err.message : "Network error"
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Make an authenticated request to an Alfe API endpoint.
|
|
274
|
-
* Unwraps the @auriclabs/api-core `{ data, timestamp, requestId }` envelope.
|
|
275
|
-
*/
|
|
276
|
-
async request(path, options) {
|
|
277
|
-
const result = await this._fetch(path, options);
|
|
278
|
-
if (!result.ok) return result.result;
|
|
279
|
-
return {
|
|
280
|
-
ok: true,
|
|
281
|
-
data: result.body.data
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Make an authenticated request that returns the body directly (no envelope unwrap).
|
|
286
|
-
* Use for APIs that don't use the @auriclabs/api-core response format (e.g. gateway).
|
|
287
|
-
*/
|
|
288
|
-
async rawRequest(path, options) {
|
|
289
|
-
const result = await this._fetch(path, options);
|
|
290
|
-
if (!result.ok) return result.result;
|
|
291
|
-
return {
|
|
292
|
-
ok: true,
|
|
293
|
-
data: result.body
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
getApiBaseUrl() {
|
|
297
|
-
return this.apiBaseUrl;
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
//#endregion
|
|
301
|
-
//#region ../../packages-internal/api-client/dist/services/integrations.js
|
|
302
|
-
var IntegrationsService = class {
|
|
303
|
-
client;
|
|
304
|
-
voiceClient;
|
|
305
|
-
constructor(client, voiceClient) {
|
|
306
|
-
this.client = client;
|
|
307
|
-
this.voiceClient = voiceClient;
|
|
308
|
-
}
|
|
309
|
-
listIntegrations(agentId) {
|
|
310
|
-
return this.client.request(`/integrations/agents/${agentId}`);
|
|
311
|
-
}
|
|
312
|
-
installIntegration(agentId, data) {
|
|
313
|
-
return this.client.request(`/integrations/agents/${agentId}`, {
|
|
314
|
-
method: "POST",
|
|
315
|
-
body: JSON.stringify(data)
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
getIntegrationConfig(agentId, integrationId) {
|
|
319
|
-
return this.client.request(`/integrations/agents/${agentId}/${integrationId}/config`);
|
|
320
|
-
}
|
|
321
|
-
updateIntegration(agentId, integrationId, data) {
|
|
322
|
-
return this.client.request(`/integrations/agents/${agentId}/${integrationId}`, {
|
|
323
|
-
method: "PATCH",
|
|
324
|
-
body: JSON.stringify(data)
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
removeIntegration(agentId, integrationId) {
|
|
328
|
-
return this.client.request(`/integrations/agents/${agentId}/${integrationId}`, { method: "DELETE" });
|
|
329
|
-
}
|
|
330
|
-
getRegistry() {
|
|
331
|
-
return this.client.request("/integrations/registry");
|
|
332
|
-
}
|
|
333
|
-
triggerSync(agentId) {
|
|
334
|
-
return this.client.request("/integrations/sync/trigger", {
|
|
335
|
-
method: "POST",
|
|
336
|
-
body: JSON.stringify({ agentId })
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
listVoices() {
|
|
340
|
-
if (this.voiceClient) return this.voiceClient.request("/api/voices");
|
|
341
|
-
return this.client.request("/integrations/voices");
|
|
342
|
-
}
|
|
343
|
-
getDiscordGuildChannels(guildId) {
|
|
344
|
-
return this.client.request(`/discord/guilds/${encodeURIComponent(guildId)}/channels`);
|
|
345
|
-
}
|
|
346
|
-
listMobileNumbers() {
|
|
347
|
-
return this.client.request("/mobile/numbers");
|
|
348
|
-
}
|
|
349
|
-
assignMobileNumber(agentId, phoneNumber) {
|
|
350
|
-
return this.client.request("/mobile/numbers/assign", {
|
|
351
|
-
method: "POST",
|
|
352
|
-
body: JSON.stringify({
|
|
353
|
-
agentId,
|
|
354
|
-
phoneNumber
|
|
355
|
-
})
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
recallJoinMeeting(agentId, meetingUrl, botName) {
|
|
359
|
-
if (this.voiceClient) return this.voiceClient.request("/api/join", {
|
|
360
|
-
method: "POST",
|
|
361
|
-
body: JSON.stringify({
|
|
362
|
-
agentId,
|
|
363
|
-
meetingUrl,
|
|
364
|
-
botName
|
|
365
|
-
})
|
|
366
|
-
});
|
|
367
|
-
return this.client.request("/integrations/recall/join", {
|
|
368
|
-
method: "POST",
|
|
369
|
-
body: JSON.stringify({
|
|
370
|
-
agentId,
|
|
371
|
-
meetingUrl,
|
|
372
|
-
botName
|
|
373
|
-
})
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
listSlackChannels(agentId) {
|
|
377
|
-
return this.client.request(`/slack/agents/${encodeURIComponent(agentId)}/channels`);
|
|
378
|
-
}
|
|
379
|
-
sendSlackMessage(agentId, channel, text) {
|
|
380
|
-
return this.client.request(`/slack/agents/${encodeURIComponent(agentId)}/send`, {
|
|
381
|
-
method: "POST",
|
|
382
|
-
body: JSON.stringify({
|
|
383
|
-
channel,
|
|
384
|
-
text
|
|
385
|
-
})
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region ../../packages-internal/types/dist/lib/enum-values.js
|
|
391
|
-
/**
|
|
392
|
-
* Converts a const enum object into a non-empty readonly tuple.
|
|
393
|
-
*
|
|
394
|
-
* Satisfies both `z.enum()` and ElectroDB `type` field requirements
|
|
395
|
-
* (both need `readonly [string, ...string[]]`).
|
|
396
|
-
*/
|
|
397
|
-
function enumValues(obj) {
|
|
398
|
-
return Object.values(obj);
|
|
399
|
-
}
|
|
400
|
-
Object.freeze({ status: "aborted" });
|
|
401
|
-
function $constructor(name, initializer, params) {
|
|
402
|
-
function init(inst, def) {
|
|
403
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
404
|
-
value: {
|
|
405
|
-
def,
|
|
406
|
-
constr: _,
|
|
407
|
-
traits: /* @__PURE__ */ new Set()
|
|
408
|
-
},
|
|
409
|
-
enumerable: false
|
|
410
|
-
});
|
|
411
|
-
if (inst._zod.traits.has(name)) return;
|
|
412
|
-
inst._zod.traits.add(name);
|
|
413
|
-
initializer(inst, def);
|
|
414
|
-
const proto = _.prototype;
|
|
415
|
-
const keys = Object.keys(proto);
|
|
416
|
-
for (let i = 0; i < keys.length; i++) {
|
|
417
|
-
const k = keys[i];
|
|
418
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
const Parent = params?.Parent ?? Object;
|
|
422
|
-
class Definition extends Parent {}
|
|
423
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
424
|
-
function _(def) {
|
|
425
|
-
var _a;
|
|
426
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
427
|
-
init(inst, def);
|
|
428
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
429
|
-
for (const fn of inst._zod.deferred) fn();
|
|
430
|
-
return inst;
|
|
431
|
-
}
|
|
432
|
-
Object.defineProperty(_, "init", { value: init });
|
|
433
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
434
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
435
|
-
return inst?._zod?.traits?.has(name);
|
|
436
|
-
} });
|
|
437
|
-
Object.defineProperty(_, "name", { value: name });
|
|
438
|
-
return _;
|
|
439
|
-
}
|
|
440
|
-
var $ZodAsyncError = class extends Error {
|
|
441
|
-
constructor() {
|
|
442
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
var $ZodEncodeError = class extends Error {
|
|
446
|
-
constructor(name) {
|
|
447
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
448
|
-
this.name = "ZodEncodeError";
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
const globalConfig = {};
|
|
452
|
-
function config(newConfig) {
|
|
453
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
454
|
-
return globalConfig;
|
|
455
|
-
}
|
|
456
|
-
//#endregion
|
|
457
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
|
|
458
|
-
function getEnumValues(entries) {
|
|
459
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
460
|
-
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
461
|
-
}
|
|
462
|
-
function jsonStringifyReplacer(_, value) {
|
|
463
|
-
if (typeof value === "bigint") return value.toString();
|
|
464
|
-
return value;
|
|
465
|
-
}
|
|
466
|
-
function cached(getter) {
|
|
467
|
-
return { get value() {
|
|
468
|
-
{
|
|
469
|
-
const value = getter();
|
|
470
|
-
Object.defineProperty(this, "value", { value });
|
|
471
|
-
return value;
|
|
472
|
-
}
|
|
473
|
-
throw new Error("cached value already set");
|
|
474
|
-
} };
|
|
475
|
-
}
|
|
476
|
-
function nullish(input) {
|
|
477
|
-
return input === null || input === void 0;
|
|
478
|
-
}
|
|
479
|
-
function cleanRegex(source) {
|
|
480
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
481
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
482
|
-
return source.slice(start, end);
|
|
483
|
-
}
|
|
484
|
-
function floatSafeRemainder(val, step) {
|
|
485
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
486
|
-
const stepString = step.toString();
|
|
487
|
-
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
488
|
-
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
489
|
-
const match = stepString.match(/\d?e-(\d?)/);
|
|
490
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
491
|
-
}
|
|
492
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
493
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
494
|
-
}
|
|
495
|
-
const EVALUATING = Symbol("evaluating");
|
|
496
|
-
function defineLazy(object, key, getter) {
|
|
497
|
-
let value = void 0;
|
|
498
|
-
Object.defineProperty(object, key, {
|
|
499
|
-
get() {
|
|
500
|
-
if (value === EVALUATING) return;
|
|
501
|
-
if (value === void 0) {
|
|
502
|
-
value = EVALUATING;
|
|
503
|
-
value = getter();
|
|
504
|
-
}
|
|
505
|
-
return value;
|
|
506
|
-
},
|
|
507
|
-
set(v) {
|
|
508
|
-
Object.defineProperty(object, key, { value: v });
|
|
509
|
-
},
|
|
510
|
-
configurable: true
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
function assignProp(target, prop, value) {
|
|
514
|
-
Object.defineProperty(target, prop, {
|
|
515
|
-
value,
|
|
516
|
-
writable: true,
|
|
517
|
-
enumerable: true,
|
|
518
|
-
configurable: true
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
function mergeDefs(...defs) {
|
|
522
|
-
const mergedDescriptors = {};
|
|
523
|
-
for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
|
|
524
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
525
|
-
}
|
|
526
|
-
function esc(str) {
|
|
527
|
-
return JSON.stringify(str);
|
|
528
|
-
}
|
|
529
|
-
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
530
|
-
function isObject(data) {
|
|
531
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
532
|
-
}
|
|
533
|
-
const allowsEval = cached(() => {
|
|
534
|
-
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
535
|
-
try {
|
|
536
|
-
new Function("");
|
|
537
|
-
return true;
|
|
538
|
-
} catch (_) {
|
|
539
|
-
return false;
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
function isPlainObject(o) {
|
|
543
|
-
if (isObject(o) === false) return false;
|
|
544
|
-
const ctor = o.constructor;
|
|
545
|
-
if (ctor === void 0) return true;
|
|
546
|
-
if (typeof ctor !== "function") return true;
|
|
547
|
-
const prot = ctor.prototype;
|
|
548
|
-
if (isObject(prot) === false) return false;
|
|
549
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
550
|
-
return true;
|
|
551
|
-
}
|
|
552
|
-
function shallowClone(o) {
|
|
553
|
-
if (isPlainObject(o)) return { ...o };
|
|
554
|
-
if (Array.isArray(o)) return [...o];
|
|
555
|
-
return o;
|
|
556
|
-
}
|
|
557
|
-
const propertyKeyTypes = new Set([
|
|
558
|
-
"string",
|
|
559
|
-
"number",
|
|
560
|
-
"symbol"
|
|
561
|
-
]);
|
|
562
|
-
function escapeRegex(str) {
|
|
563
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
564
|
-
}
|
|
565
|
-
function clone(inst, def, params) {
|
|
566
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
567
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
568
|
-
return cl;
|
|
569
|
-
}
|
|
570
|
-
function normalizeParams(_params) {
|
|
571
|
-
const params = _params;
|
|
572
|
-
if (!params) return {};
|
|
573
|
-
if (typeof params === "string") return { error: () => params };
|
|
574
|
-
if (params?.message !== void 0) {
|
|
575
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
576
|
-
params.error = params.message;
|
|
577
|
-
}
|
|
578
|
-
delete params.message;
|
|
579
|
-
if (typeof params.error === "string") return {
|
|
580
|
-
...params,
|
|
581
|
-
error: () => params.error
|
|
582
|
-
};
|
|
583
|
-
return params;
|
|
584
|
-
}
|
|
585
|
-
function optionalKeys(shape) {
|
|
586
|
-
return Object.keys(shape).filter((k) => {
|
|
587
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
const NUMBER_FORMAT_RANGES = {
|
|
591
|
-
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
592
|
-
int32: [-2147483648, 2147483647],
|
|
593
|
-
uint32: [0, 4294967295],
|
|
594
|
-
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
595
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
596
|
-
};
|
|
597
|
-
function pick(schema, mask) {
|
|
598
|
-
const currDef = schema._zod.def;
|
|
599
|
-
const checks = currDef.checks;
|
|
600
|
-
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
601
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
602
|
-
get shape() {
|
|
603
|
-
const newShape = {};
|
|
604
|
-
for (const key in mask) {
|
|
605
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
606
|
-
if (!mask[key]) continue;
|
|
607
|
-
newShape[key] = currDef.shape[key];
|
|
608
|
-
}
|
|
609
|
-
assignProp(this, "shape", newShape);
|
|
610
|
-
return newShape;
|
|
611
|
-
},
|
|
612
|
-
checks: []
|
|
613
|
-
}));
|
|
614
|
-
}
|
|
615
|
-
function omit(schema, mask) {
|
|
616
|
-
const currDef = schema._zod.def;
|
|
617
|
-
const checks = currDef.checks;
|
|
618
|
-
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
619
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
620
|
-
get shape() {
|
|
621
|
-
const newShape = { ...schema._zod.def.shape };
|
|
622
|
-
for (const key in mask) {
|
|
623
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
624
|
-
if (!mask[key]) continue;
|
|
625
|
-
delete newShape[key];
|
|
626
|
-
}
|
|
627
|
-
assignProp(this, "shape", newShape);
|
|
628
|
-
return newShape;
|
|
629
|
-
},
|
|
630
|
-
checks: []
|
|
631
|
-
}));
|
|
632
|
-
}
|
|
633
|
-
function extend(schema, shape) {
|
|
634
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
635
|
-
const checks = schema._zod.def.checks;
|
|
636
|
-
if (checks && checks.length > 0) {
|
|
637
|
-
const existingShape = schema._zod.def.shape;
|
|
638
|
-
for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
639
|
-
}
|
|
640
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
641
|
-
const _shape = {
|
|
642
|
-
...schema._zod.def.shape,
|
|
643
|
-
...shape
|
|
644
|
-
};
|
|
645
|
-
assignProp(this, "shape", _shape);
|
|
646
|
-
return _shape;
|
|
647
|
-
} }));
|
|
648
|
-
}
|
|
649
|
-
function safeExtend(schema, shape) {
|
|
650
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
651
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
652
|
-
const _shape = {
|
|
653
|
-
...schema._zod.def.shape,
|
|
654
|
-
...shape
|
|
655
|
-
};
|
|
656
|
-
assignProp(this, "shape", _shape);
|
|
657
|
-
return _shape;
|
|
658
|
-
} }));
|
|
659
|
-
}
|
|
660
|
-
function merge(a, b) {
|
|
661
|
-
return clone(a, mergeDefs(a._zod.def, {
|
|
662
|
-
get shape() {
|
|
663
|
-
const _shape = {
|
|
664
|
-
...a._zod.def.shape,
|
|
665
|
-
...b._zod.def.shape
|
|
666
|
-
};
|
|
667
|
-
assignProp(this, "shape", _shape);
|
|
668
|
-
return _shape;
|
|
669
|
-
},
|
|
670
|
-
get catchall() {
|
|
671
|
-
return b._zod.def.catchall;
|
|
672
|
-
},
|
|
673
|
-
checks: []
|
|
674
|
-
}));
|
|
675
|
-
}
|
|
676
|
-
function partial(Class, schema, mask) {
|
|
677
|
-
const checks = schema._zod.def.checks;
|
|
678
|
-
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
679
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
680
|
-
get shape() {
|
|
681
|
-
const oldShape = schema._zod.def.shape;
|
|
682
|
-
const shape = { ...oldShape };
|
|
683
|
-
if (mask) for (const key in mask) {
|
|
684
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
685
|
-
if (!mask[key]) continue;
|
|
686
|
-
shape[key] = Class ? new Class({
|
|
687
|
-
type: "optional",
|
|
688
|
-
innerType: oldShape[key]
|
|
689
|
-
}) : oldShape[key];
|
|
690
|
-
}
|
|
691
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
692
|
-
type: "optional",
|
|
693
|
-
innerType: oldShape[key]
|
|
694
|
-
}) : oldShape[key];
|
|
695
|
-
assignProp(this, "shape", shape);
|
|
696
|
-
return shape;
|
|
697
|
-
},
|
|
698
|
-
checks: []
|
|
699
|
-
}));
|
|
700
|
-
}
|
|
701
|
-
function required(Class, schema, mask) {
|
|
702
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
703
|
-
const oldShape = schema._zod.def.shape;
|
|
704
|
-
const shape = { ...oldShape };
|
|
705
|
-
if (mask) for (const key in mask) {
|
|
706
|
-
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
707
|
-
if (!mask[key]) continue;
|
|
708
|
-
shape[key] = new Class({
|
|
709
|
-
type: "nonoptional",
|
|
710
|
-
innerType: oldShape[key]
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
714
|
-
type: "nonoptional",
|
|
715
|
-
innerType: oldShape[key]
|
|
716
|
-
});
|
|
717
|
-
assignProp(this, "shape", shape);
|
|
718
|
-
return shape;
|
|
719
|
-
} }));
|
|
720
|
-
}
|
|
721
|
-
function aborted(x, startIndex = 0) {
|
|
722
|
-
if (x.aborted === true) return true;
|
|
723
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
function prefixIssues(path, issues) {
|
|
727
|
-
return issues.map((iss) => {
|
|
728
|
-
var _a;
|
|
729
|
-
(_a = iss).path ?? (_a.path = []);
|
|
730
|
-
iss.path.unshift(path);
|
|
731
|
-
return iss;
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
function unwrapMessage(message) {
|
|
735
|
-
return typeof message === "string" ? message : message?.message;
|
|
736
|
-
}
|
|
737
|
-
function finalizeIssue(iss, ctx, config) {
|
|
738
|
-
const full = {
|
|
739
|
-
...iss,
|
|
740
|
-
path: iss.path ?? []
|
|
741
|
-
};
|
|
742
|
-
if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
743
|
-
delete full.inst;
|
|
744
|
-
delete full.continue;
|
|
745
|
-
if (!ctx?.reportInput) delete full.input;
|
|
746
|
-
return full;
|
|
747
|
-
}
|
|
748
|
-
function getLengthableOrigin(input) {
|
|
749
|
-
if (Array.isArray(input)) return "array";
|
|
750
|
-
if (typeof input === "string") return "string";
|
|
751
|
-
return "unknown";
|
|
752
|
-
}
|
|
753
|
-
function issue(...args) {
|
|
754
|
-
const [iss, input, inst] = args;
|
|
755
|
-
if (typeof iss === "string") return {
|
|
756
|
-
message: iss,
|
|
757
|
-
code: "custom",
|
|
758
|
-
input,
|
|
759
|
-
inst
|
|
760
|
-
};
|
|
761
|
-
return { ...iss };
|
|
762
|
-
}
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
|
|
765
|
-
const initializer$1 = (inst, def) => {
|
|
766
|
-
inst.name = "$ZodError";
|
|
767
|
-
Object.defineProperty(inst, "_zod", {
|
|
768
|
-
value: inst._zod,
|
|
769
|
-
enumerable: false
|
|
770
|
-
});
|
|
771
|
-
Object.defineProperty(inst, "issues", {
|
|
772
|
-
value: def,
|
|
773
|
-
enumerable: false
|
|
774
|
-
});
|
|
775
|
-
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
776
|
-
Object.defineProperty(inst, "toString", {
|
|
777
|
-
value: () => inst.message,
|
|
778
|
-
enumerable: false
|
|
779
|
-
});
|
|
780
|
-
};
|
|
781
|
-
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
782
|
-
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
783
|
-
function flattenError(error, mapper = (issue) => issue.message) {
|
|
784
|
-
const fieldErrors = {};
|
|
785
|
-
const formErrors = [];
|
|
786
|
-
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
787
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
788
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
789
|
-
} else formErrors.push(mapper(sub));
|
|
790
|
-
return {
|
|
791
|
-
formErrors,
|
|
792
|
-
fieldErrors
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
function formatError(error, mapper = (issue) => issue.message) {
|
|
796
|
-
const fieldErrors = { _errors: [] };
|
|
797
|
-
const processError = (error) => {
|
|
798
|
-
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
|
|
799
|
-
else if (issue.code === "invalid_key") processError({ issues: issue.issues });
|
|
800
|
-
else if (issue.code === "invalid_element") processError({ issues: issue.issues });
|
|
801
|
-
else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
802
|
-
else {
|
|
803
|
-
let curr = fieldErrors;
|
|
804
|
-
let i = 0;
|
|
805
|
-
while (i < issue.path.length) {
|
|
806
|
-
const el = issue.path[i];
|
|
807
|
-
if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
808
|
-
else {
|
|
809
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
810
|
-
curr[el]._errors.push(mapper(issue));
|
|
811
|
-
}
|
|
812
|
-
curr = curr[el];
|
|
813
|
-
i++;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
processError(error);
|
|
818
|
-
return fieldErrors;
|
|
819
|
-
}
|
|
820
|
-
//#endregion
|
|
821
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js
|
|
822
|
-
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
823
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
824
|
-
const result = schema._zod.run({
|
|
825
|
-
value,
|
|
826
|
-
issues: []
|
|
827
|
-
}, ctx);
|
|
828
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
829
|
-
if (result.issues.length) {
|
|
830
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
831
|
-
captureStackTrace(e, _params?.callee);
|
|
832
|
-
throw e;
|
|
833
|
-
}
|
|
834
|
-
return result.value;
|
|
835
|
-
};
|
|
836
|
-
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
837
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
838
|
-
let result = schema._zod.run({
|
|
839
|
-
value,
|
|
840
|
-
issues: []
|
|
841
|
-
}, ctx);
|
|
842
|
-
if (result instanceof Promise) result = await result;
|
|
843
|
-
if (result.issues.length) {
|
|
844
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
845
|
-
captureStackTrace(e, params?.callee);
|
|
846
|
-
throw e;
|
|
847
|
-
}
|
|
848
|
-
return result.value;
|
|
849
|
-
};
|
|
850
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
851
|
-
const ctx = _ctx ? {
|
|
852
|
-
..._ctx,
|
|
853
|
-
async: false
|
|
854
|
-
} : { async: false };
|
|
855
|
-
const result = schema._zod.run({
|
|
856
|
-
value,
|
|
857
|
-
issues: []
|
|
858
|
-
}, ctx);
|
|
859
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
860
|
-
return result.issues.length ? {
|
|
861
|
-
success: false,
|
|
862
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
863
|
-
} : {
|
|
864
|
-
success: true,
|
|
865
|
-
data: result.value
|
|
866
|
-
};
|
|
867
|
-
};
|
|
868
|
-
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
869
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
870
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
871
|
-
let result = schema._zod.run({
|
|
872
|
-
value,
|
|
873
|
-
issues: []
|
|
874
|
-
}, ctx);
|
|
875
|
-
if (result instanceof Promise) result = await result;
|
|
876
|
-
return result.issues.length ? {
|
|
877
|
-
success: false,
|
|
878
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
879
|
-
} : {
|
|
880
|
-
success: true,
|
|
881
|
-
data: result.value
|
|
882
|
-
};
|
|
883
|
-
};
|
|
884
|
-
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
885
|
-
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
886
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
887
|
-
return _parse(_Err)(schema, value, ctx);
|
|
888
|
-
};
|
|
889
|
-
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
890
|
-
return _parse(_Err)(schema, value, _ctx);
|
|
891
|
-
};
|
|
892
|
-
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
893
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
894
|
-
return _parseAsync(_Err)(schema, value, ctx);
|
|
895
|
-
};
|
|
896
|
-
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
897
|
-
return _parseAsync(_Err)(schema, value, _ctx);
|
|
898
|
-
};
|
|
899
|
-
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
900
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
901
|
-
return _safeParse(_Err)(schema, value, ctx);
|
|
902
|
-
};
|
|
903
|
-
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
904
|
-
return _safeParse(_Err)(schema, value, _ctx);
|
|
905
|
-
};
|
|
906
|
-
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
907
|
-
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
908
|
-
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
909
|
-
};
|
|
910
|
-
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
911
|
-
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
912
|
-
};
|
|
913
|
-
const integer = /^-?\d+$/;
|
|
914
|
-
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
915
|
-
//#endregion
|
|
916
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
|
|
917
|
-
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
918
|
-
var _a;
|
|
919
|
-
inst._zod ?? (inst._zod = {});
|
|
920
|
-
inst._zod.def = def;
|
|
921
|
-
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
922
|
-
});
|
|
923
|
-
const numericOriginMap = {
|
|
924
|
-
number: "number",
|
|
925
|
-
bigint: "bigint",
|
|
926
|
-
object: "date"
|
|
927
|
-
};
|
|
928
|
-
const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
929
|
-
$ZodCheck.init(inst, def);
|
|
930
|
-
const origin = numericOriginMap[typeof def.value];
|
|
931
|
-
inst._zod.onattach.push((inst) => {
|
|
932
|
-
const bag = inst._zod.bag;
|
|
933
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
934
|
-
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
935
|
-
else bag.exclusiveMaximum = def.value;
|
|
936
|
-
});
|
|
937
|
-
inst._zod.check = (payload) => {
|
|
938
|
-
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
939
|
-
payload.issues.push({
|
|
940
|
-
origin,
|
|
941
|
-
code: "too_big",
|
|
942
|
-
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
943
|
-
input: payload.value,
|
|
944
|
-
inclusive: def.inclusive,
|
|
945
|
-
inst,
|
|
946
|
-
continue: !def.abort
|
|
947
|
-
});
|
|
948
|
-
};
|
|
949
|
-
});
|
|
950
|
-
const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
951
|
-
$ZodCheck.init(inst, def);
|
|
952
|
-
const origin = numericOriginMap[typeof def.value];
|
|
953
|
-
inst._zod.onattach.push((inst) => {
|
|
954
|
-
const bag = inst._zod.bag;
|
|
955
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
956
|
-
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
957
|
-
else bag.exclusiveMinimum = def.value;
|
|
958
|
-
});
|
|
959
|
-
inst._zod.check = (payload) => {
|
|
960
|
-
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
961
|
-
payload.issues.push({
|
|
962
|
-
origin,
|
|
963
|
-
code: "too_small",
|
|
964
|
-
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
965
|
-
input: payload.value,
|
|
966
|
-
inclusive: def.inclusive,
|
|
967
|
-
inst,
|
|
968
|
-
continue: !def.abort
|
|
969
|
-
});
|
|
970
|
-
};
|
|
971
|
-
});
|
|
972
|
-
const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
973
|
-
$ZodCheck.init(inst, def);
|
|
974
|
-
inst._zod.onattach.push((inst) => {
|
|
975
|
-
var _a;
|
|
976
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
977
|
-
});
|
|
978
|
-
inst._zod.check = (payload) => {
|
|
979
|
-
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
980
|
-
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
981
|
-
payload.issues.push({
|
|
982
|
-
origin: typeof payload.value,
|
|
983
|
-
code: "not_multiple_of",
|
|
984
|
-
divisor: def.value,
|
|
985
|
-
input: payload.value,
|
|
986
|
-
inst,
|
|
987
|
-
continue: !def.abort
|
|
988
|
-
});
|
|
989
|
-
};
|
|
990
|
-
});
|
|
991
|
-
const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
992
|
-
$ZodCheck.init(inst, def);
|
|
993
|
-
def.format = def.format || "float64";
|
|
994
|
-
const isInt = def.format?.includes("int");
|
|
995
|
-
const origin = isInt ? "int" : "number";
|
|
996
|
-
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
997
|
-
inst._zod.onattach.push((inst) => {
|
|
998
|
-
const bag = inst._zod.bag;
|
|
999
|
-
bag.format = def.format;
|
|
1000
|
-
bag.minimum = minimum;
|
|
1001
|
-
bag.maximum = maximum;
|
|
1002
|
-
if (isInt) bag.pattern = integer;
|
|
1003
|
-
});
|
|
1004
|
-
inst._zod.check = (payload) => {
|
|
1005
|
-
const input = payload.value;
|
|
1006
|
-
if (isInt) {
|
|
1007
|
-
if (!Number.isInteger(input)) {
|
|
1008
|
-
payload.issues.push({
|
|
1009
|
-
expected: origin,
|
|
1010
|
-
format: def.format,
|
|
1011
|
-
code: "invalid_type",
|
|
1012
|
-
continue: false,
|
|
1013
|
-
input,
|
|
1014
|
-
inst
|
|
1015
|
-
});
|
|
1016
|
-
return;
|
|
1017
|
-
}
|
|
1018
|
-
if (!Number.isSafeInteger(input)) {
|
|
1019
|
-
if (input > 0) payload.issues.push({
|
|
1020
|
-
input,
|
|
1021
|
-
code: "too_big",
|
|
1022
|
-
maximum: Number.MAX_SAFE_INTEGER,
|
|
1023
|
-
note: "Integers must be within the safe integer range.",
|
|
1024
|
-
inst,
|
|
1025
|
-
origin,
|
|
1026
|
-
inclusive: true,
|
|
1027
|
-
continue: !def.abort
|
|
1028
|
-
});
|
|
1029
|
-
else payload.issues.push({
|
|
1030
|
-
input,
|
|
1031
|
-
code: "too_small",
|
|
1032
|
-
minimum: Number.MIN_SAFE_INTEGER,
|
|
1033
|
-
note: "Integers must be within the safe integer range.",
|
|
1034
|
-
inst,
|
|
1035
|
-
origin,
|
|
1036
|
-
inclusive: true,
|
|
1037
|
-
continue: !def.abort
|
|
1038
|
-
});
|
|
1039
|
-
return;
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
if (input < minimum) payload.issues.push({
|
|
1043
|
-
origin: "number",
|
|
1044
|
-
input,
|
|
1045
|
-
code: "too_small",
|
|
1046
|
-
minimum,
|
|
1047
|
-
inclusive: true,
|
|
1048
|
-
inst,
|
|
1049
|
-
continue: !def.abort
|
|
1050
|
-
});
|
|
1051
|
-
if (input > maximum) payload.issues.push({
|
|
1052
|
-
origin: "number",
|
|
1053
|
-
input,
|
|
1054
|
-
code: "too_big",
|
|
1055
|
-
maximum,
|
|
1056
|
-
inclusive: true,
|
|
1057
|
-
inst,
|
|
1058
|
-
continue: !def.abort
|
|
1059
|
-
});
|
|
1060
|
-
};
|
|
1061
|
-
});
|
|
1062
|
-
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1063
|
-
var _a;
|
|
1064
|
-
$ZodCheck.init(inst, def);
|
|
1065
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1066
|
-
const val = payload.value;
|
|
1067
|
-
return !nullish(val) && val.length !== void 0;
|
|
1068
|
-
});
|
|
1069
|
-
inst._zod.onattach.push((inst) => {
|
|
1070
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1071
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
1072
|
-
});
|
|
1073
|
-
inst._zod.check = (payload) => {
|
|
1074
|
-
const input = payload.value;
|
|
1075
|
-
if (input.length <= def.maximum) return;
|
|
1076
|
-
const origin = getLengthableOrigin(input);
|
|
1077
|
-
payload.issues.push({
|
|
1078
|
-
origin,
|
|
1079
|
-
code: "too_big",
|
|
1080
|
-
maximum: def.maximum,
|
|
1081
|
-
inclusive: true,
|
|
1082
|
-
input,
|
|
1083
|
-
inst,
|
|
1084
|
-
continue: !def.abort
|
|
1085
|
-
});
|
|
1086
|
-
};
|
|
1087
|
-
});
|
|
1088
|
-
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1089
|
-
var _a;
|
|
1090
|
-
$ZodCheck.init(inst, def);
|
|
1091
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1092
|
-
const val = payload.value;
|
|
1093
|
-
return !nullish(val) && val.length !== void 0;
|
|
1094
|
-
});
|
|
1095
|
-
inst._zod.onattach.push((inst) => {
|
|
1096
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1097
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
1098
|
-
});
|
|
1099
|
-
inst._zod.check = (payload) => {
|
|
1100
|
-
const input = payload.value;
|
|
1101
|
-
if (input.length >= def.minimum) return;
|
|
1102
|
-
const origin = getLengthableOrigin(input);
|
|
1103
|
-
payload.issues.push({
|
|
1104
|
-
origin,
|
|
1105
|
-
code: "too_small",
|
|
1106
|
-
minimum: def.minimum,
|
|
1107
|
-
inclusive: true,
|
|
1108
|
-
input,
|
|
1109
|
-
inst,
|
|
1110
|
-
continue: !def.abort
|
|
1111
|
-
});
|
|
1112
|
-
};
|
|
1113
|
-
});
|
|
1114
|
-
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1115
|
-
var _a;
|
|
1116
|
-
$ZodCheck.init(inst, def);
|
|
1117
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1118
|
-
const val = payload.value;
|
|
1119
|
-
return !nullish(val) && val.length !== void 0;
|
|
1120
|
-
});
|
|
1121
|
-
inst._zod.onattach.push((inst) => {
|
|
1122
|
-
const bag = inst._zod.bag;
|
|
1123
|
-
bag.minimum = def.length;
|
|
1124
|
-
bag.maximum = def.length;
|
|
1125
|
-
bag.length = def.length;
|
|
1126
|
-
});
|
|
1127
|
-
inst._zod.check = (payload) => {
|
|
1128
|
-
const input = payload.value;
|
|
1129
|
-
const length = input.length;
|
|
1130
|
-
if (length === def.length) return;
|
|
1131
|
-
const origin = getLengthableOrigin(input);
|
|
1132
|
-
const tooBig = length > def.length;
|
|
1133
|
-
payload.issues.push({
|
|
1134
|
-
origin,
|
|
1135
|
-
...tooBig ? {
|
|
1136
|
-
code: "too_big",
|
|
1137
|
-
maximum: def.length
|
|
1138
|
-
} : {
|
|
1139
|
-
code: "too_small",
|
|
1140
|
-
minimum: def.length
|
|
1141
|
-
},
|
|
1142
|
-
inclusive: true,
|
|
1143
|
-
exact: true,
|
|
1144
|
-
input: payload.value,
|
|
1145
|
-
inst,
|
|
1146
|
-
continue: !def.abort
|
|
1147
|
-
});
|
|
1148
|
-
};
|
|
1149
|
-
});
|
|
1150
|
-
const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1151
|
-
$ZodCheck.init(inst, def);
|
|
1152
|
-
inst._zod.check = (payload) => {
|
|
1153
|
-
payload.value = def.tx(payload.value);
|
|
1154
|
-
};
|
|
1155
|
-
});
|
|
1156
|
-
//#endregion
|
|
1157
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js
|
|
1158
|
-
var Doc = class {
|
|
1159
|
-
constructor(args = []) {
|
|
1160
|
-
this.content = [];
|
|
1161
|
-
this.indent = 0;
|
|
1162
|
-
if (this) this.args = args;
|
|
1163
|
-
}
|
|
1164
|
-
indented(fn) {
|
|
1165
|
-
this.indent += 1;
|
|
1166
|
-
fn(this);
|
|
1167
|
-
this.indent -= 1;
|
|
1168
|
-
}
|
|
1169
|
-
write(arg) {
|
|
1170
|
-
if (typeof arg === "function") {
|
|
1171
|
-
arg(this, { execution: "sync" });
|
|
1172
|
-
arg(this, { execution: "async" });
|
|
1173
|
-
return;
|
|
1174
|
-
}
|
|
1175
|
-
const lines = arg.split("\n").filter((x) => x);
|
|
1176
|
-
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
1177
|
-
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
1178
|
-
for (const line of dedented) this.content.push(line);
|
|
1179
|
-
}
|
|
1180
|
-
compile() {
|
|
1181
|
-
const F = Function;
|
|
1182
|
-
const args = this?.args;
|
|
1183
|
-
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
|
|
1184
|
-
return new F(...args, lines.join("\n"));
|
|
1185
|
-
}
|
|
1186
|
-
};
|
|
1187
|
-
//#endregion
|
|
1188
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
|
|
1189
|
-
const version = {
|
|
1190
|
-
major: 4,
|
|
1191
|
-
minor: 3,
|
|
1192
|
-
patch: 6
|
|
1193
|
-
};
|
|
1194
|
-
//#endregion
|
|
1195
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js
|
|
1196
|
-
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1197
|
-
var _a;
|
|
1198
|
-
inst ?? (inst = {});
|
|
1199
|
-
inst._zod.def = def;
|
|
1200
|
-
inst._zod.bag = inst._zod.bag || {};
|
|
1201
|
-
inst._zod.version = version;
|
|
1202
|
-
const checks = [...inst._zod.def.checks ?? []];
|
|
1203
|
-
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
1204
|
-
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1205
|
-
if (checks.length === 0) {
|
|
1206
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1207
|
-
inst._zod.deferred?.push(() => {
|
|
1208
|
-
inst._zod.run = inst._zod.parse;
|
|
1209
|
-
});
|
|
1210
|
-
} else {
|
|
1211
|
-
const runChecks = (payload, checks, ctx) => {
|
|
1212
|
-
let isAborted = aborted(payload);
|
|
1213
|
-
let asyncResult;
|
|
1214
|
-
for (const ch of checks) {
|
|
1215
|
-
if (ch._zod.def.when) {
|
|
1216
|
-
if (!ch._zod.def.when(payload)) continue;
|
|
1217
|
-
} else if (isAborted) continue;
|
|
1218
|
-
const currLen = payload.issues.length;
|
|
1219
|
-
const _ = ch._zod.check(payload);
|
|
1220
|
-
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
1221
|
-
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1222
|
-
await _;
|
|
1223
|
-
if (payload.issues.length === currLen) return;
|
|
1224
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1225
|
-
});
|
|
1226
|
-
else {
|
|
1227
|
-
if (payload.issues.length === currLen) continue;
|
|
1228
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
if (asyncResult) return asyncResult.then(() => {
|
|
1232
|
-
return payload;
|
|
1233
|
-
});
|
|
1234
|
-
return payload;
|
|
1235
|
-
};
|
|
1236
|
-
const handleCanaryResult = (canary, payload, ctx) => {
|
|
1237
|
-
if (aborted(canary)) {
|
|
1238
|
-
canary.aborted = true;
|
|
1239
|
-
return canary;
|
|
1240
|
-
}
|
|
1241
|
-
const checkResult = runChecks(payload, checks, ctx);
|
|
1242
|
-
if (checkResult instanceof Promise) {
|
|
1243
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1244
|
-
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
1245
|
-
}
|
|
1246
|
-
return inst._zod.parse(checkResult, ctx);
|
|
1247
|
-
};
|
|
1248
|
-
inst._zod.run = (payload, ctx) => {
|
|
1249
|
-
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
|
|
1250
|
-
if (ctx.direction === "backward") {
|
|
1251
|
-
const canary = inst._zod.parse({
|
|
1252
|
-
value: payload.value,
|
|
1253
|
-
issues: []
|
|
1254
|
-
}, {
|
|
1255
|
-
...ctx,
|
|
1256
|
-
skipChecks: true
|
|
1257
|
-
});
|
|
1258
|
-
if (canary instanceof Promise) return canary.then((canary) => {
|
|
1259
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
1260
|
-
});
|
|
1261
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
1262
|
-
}
|
|
1263
|
-
const result = inst._zod.parse(payload, ctx);
|
|
1264
|
-
if (result instanceof Promise) {
|
|
1265
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1266
|
-
return result.then((result) => runChecks(result, checks, ctx));
|
|
1267
|
-
}
|
|
1268
|
-
return runChecks(result, checks, ctx);
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
defineLazy(inst, "~standard", () => ({
|
|
1272
|
-
validate: (value) => {
|
|
1273
|
-
try {
|
|
1274
|
-
const r = safeParse$1(inst, value);
|
|
1275
|
-
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
1276
|
-
} catch (_) {
|
|
1277
|
-
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1278
|
-
}
|
|
1279
|
-
},
|
|
1280
|
-
vendor: "zod",
|
|
1281
|
-
version: 1
|
|
1282
|
-
}));
|
|
1283
|
-
});
|
|
1284
|
-
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1285
|
-
$ZodType.init(inst, def);
|
|
1286
|
-
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
|
|
1287
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1288
|
-
if (def.coerce) try {
|
|
1289
|
-
payload.value = Number(payload.value);
|
|
1290
|
-
} catch (_) {}
|
|
1291
|
-
const input = payload.value;
|
|
1292
|
-
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1293
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
1294
|
-
payload.issues.push({
|
|
1295
|
-
expected: "number",
|
|
1296
|
-
code: "invalid_type",
|
|
1297
|
-
input,
|
|
1298
|
-
inst,
|
|
1299
|
-
...received ? { received } : {}
|
|
1300
|
-
});
|
|
1301
|
-
return payload;
|
|
1302
|
-
};
|
|
1303
|
-
});
|
|
1304
|
-
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1305
|
-
$ZodCheckNumberFormat.init(inst, def);
|
|
1306
|
-
$ZodNumber.init(inst, def);
|
|
1307
|
-
});
|
|
1308
|
-
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1309
|
-
$ZodType.init(inst, def);
|
|
1310
|
-
inst._zod.parse = (payload) => payload;
|
|
1311
|
-
});
|
|
1312
|
-
const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1313
|
-
$ZodType.init(inst, def);
|
|
1314
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1315
|
-
payload.issues.push({
|
|
1316
|
-
expected: "never",
|
|
1317
|
-
code: "invalid_type",
|
|
1318
|
-
input: payload.value,
|
|
1319
|
-
inst
|
|
1320
|
-
});
|
|
1321
|
-
return payload;
|
|
1322
|
-
};
|
|
1323
|
-
});
|
|
1324
|
-
function handleArrayResult(result, final, index) {
|
|
1325
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1326
|
-
final.value[index] = result.value;
|
|
1327
|
-
}
|
|
1328
|
-
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1329
|
-
$ZodType.init(inst, def);
|
|
1330
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1331
|
-
const input = payload.value;
|
|
1332
|
-
if (!Array.isArray(input)) {
|
|
1333
|
-
payload.issues.push({
|
|
1334
|
-
expected: "array",
|
|
1335
|
-
code: "invalid_type",
|
|
1336
|
-
input,
|
|
1337
|
-
inst
|
|
1338
|
-
});
|
|
1339
|
-
return payload;
|
|
1340
|
-
}
|
|
1341
|
-
payload.value = Array(input.length);
|
|
1342
|
-
const proms = [];
|
|
1343
|
-
for (let i = 0; i < input.length; i++) {
|
|
1344
|
-
const item = input[i];
|
|
1345
|
-
const result = def.element._zod.run({
|
|
1346
|
-
value: item,
|
|
1347
|
-
issues: []
|
|
1348
|
-
}, ctx);
|
|
1349
|
-
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1350
|
-
else handleArrayResult(result, payload, i);
|
|
1351
|
-
}
|
|
1352
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1353
|
-
return payload;
|
|
1354
|
-
};
|
|
1355
|
-
});
|
|
1356
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
1357
|
-
if (result.issues.length) {
|
|
1358
|
-
if (isOptionalOut && !(key in input)) return;
|
|
1359
|
-
final.issues.push(...prefixIssues(key, result.issues));
|
|
1360
|
-
}
|
|
1361
|
-
if (result.value === void 0) {
|
|
1362
|
-
if (key in input) final.value[key] = void 0;
|
|
1363
|
-
} else final.value[key] = result.value;
|
|
1364
|
-
}
|
|
1365
|
-
function normalizeDef(def) {
|
|
1366
|
-
const keys = Object.keys(def.shape);
|
|
1367
|
-
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1368
|
-
const okeys = optionalKeys(def.shape);
|
|
1369
|
-
return {
|
|
1370
|
-
...def,
|
|
1371
|
-
keys,
|
|
1372
|
-
keySet: new Set(keys),
|
|
1373
|
-
numKeys: keys.length,
|
|
1374
|
-
optionalKeys: new Set(okeys)
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1378
|
-
const unrecognized = [];
|
|
1379
|
-
const keySet = def.keySet;
|
|
1380
|
-
const _catchall = def.catchall._zod;
|
|
1381
|
-
const t = _catchall.def.type;
|
|
1382
|
-
const isOptionalOut = _catchall.optout === "optional";
|
|
1383
|
-
for (const key in input) {
|
|
1384
|
-
if (keySet.has(key)) continue;
|
|
1385
|
-
if (t === "never") {
|
|
1386
|
-
unrecognized.push(key);
|
|
1387
|
-
continue;
|
|
1388
|
-
}
|
|
1389
|
-
const r = _catchall.run({
|
|
1390
|
-
value: input[key],
|
|
1391
|
-
issues: []
|
|
1392
|
-
}, ctx);
|
|
1393
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
1394
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1395
|
-
}
|
|
1396
|
-
if (unrecognized.length) payload.issues.push({
|
|
1397
|
-
code: "unrecognized_keys",
|
|
1398
|
-
keys: unrecognized,
|
|
1399
|
-
input,
|
|
1400
|
-
inst
|
|
1401
|
-
});
|
|
1402
|
-
if (!proms.length) return payload;
|
|
1403
|
-
return Promise.all(proms).then(() => {
|
|
1404
|
-
return payload;
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1408
|
-
$ZodType.init(inst, def);
|
|
1409
|
-
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
|
|
1410
|
-
const sh = def.shape;
|
|
1411
|
-
Object.defineProperty(def, "shape", { get: () => {
|
|
1412
|
-
const newSh = { ...sh };
|
|
1413
|
-
Object.defineProperty(def, "shape", { value: newSh });
|
|
1414
|
-
return newSh;
|
|
1415
|
-
} });
|
|
1416
|
-
}
|
|
1417
|
-
const _normalized = cached(() => normalizeDef(def));
|
|
1418
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
1419
|
-
const shape = def.shape;
|
|
1420
|
-
const propValues = {};
|
|
1421
|
-
for (const key in shape) {
|
|
1422
|
-
const field = shape[key]._zod;
|
|
1423
|
-
if (field.values) {
|
|
1424
|
-
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
1425
|
-
for (const v of field.values) propValues[key].add(v);
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
return propValues;
|
|
1429
|
-
});
|
|
1430
|
-
const isObject$2 = isObject;
|
|
1431
|
-
const catchall = def.catchall;
|
|
1432
|
-
let value;
|
|
1433
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1434
|
-
value ?? (value = _normalized.value);
|
|
1435
|
-
const input = payload.value;
|
|
1436
|
-
if (!isObject$2(input)) {
|
|
1437
|
-
payload.issues.push({
|
|
1438
|
-
expected: "object",
|
|
1439
|
-
code: "invalid_type",
|
|
1440
|
-
input,
|
|
1441
|
-
inst
|
|
1442
|
-
});
|
|
1443
|
-
return payload;
|
|
1444
|
-
}
|
|
1445
|
-
payload.value = {};
|
|
1446
|
-
const proms = [];
|
|
1447
|
-
const shape = value.shape;
|
|
1448
|
-
for (const key of value.keys) {
|
|
1449
|
-
const el = shape[key];
|
|
1450
|
-
const isOptionalOut = el._zod.optout === "optional";
|
|
1451
|
-
const r = el._zod.run({
|
|
1452
|
-
value: input[key],
|
|
1453
|
-
issues: []
|
|
1454
|
-
}, ctx);
|
|
1455
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
1456
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1457
|
-
}
|
|
1458
|
-
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1459
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
1460
|
-
};
|
|
1461
|
-
});
|
|
1462
|
-
const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1463
|
-
$ZodObject.init(inst, def);
|
|
1464
|
-
const superParse = inst._zod.parse;
|
|
1465
|
-
const _normalized = cached(() => normalizeDef(def));
|
|
1466
|
-
const generateFastpass = (shape) => {
|
|
1467
|
-
const doc = new Doc([
|
|
1468
|
-
"shape",
|
|
1469
|
-
"payload",
|
|
1470
|
-
"ctx"
|
|
1471
|
-
]);
|
|
1472
|
-
const normalized = _normalized.value;
|
|
1473
|
-
const parseStr = (key) => {
|
|
1474
|
-
const k = esc(key);
|
|
1475
|
-
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1476
|
-
};
|
|
1477
|
-
doc.write(`const input = payload.value;`);
|
|
1478
|
-
const ids = Object.create(null);
|
|
1479
|
-
let counter = 0;
|
|
1480
|
-
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
1481
|
-
doc.write(`const newResult = {};`);
|
|
1482
|
-
for (const key of normalized.keys) {
|
|
1483
|
-
const id = ids[key];
|
|
1484
|
-
const k = esc(key);
|
|
1485
|
-
const isOptionalOut = shape[key]?._zod?.optout === "optional";
|
|
1486
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1487
|
-
if (isOptionalOut) doc.write(`
|
|
1488
|
-
if (${id}.issues.length) {
|
|
1489
|
-
if (${k} in input) {
|
|
1490
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1491
|
-
...iss,
|
|
1492
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1493
|
-
})));
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
if (${id}.value === undefined) {
|
|
1498
|
-
if (${k} in input) {
|
|
1499
|
-
newResult[${k}] = undefined;
|
|
1500
|
-
}
|
|
1501
|
-
} else {
|
|
1502
|
-
newResult[${k}] = ${id}.value;
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
`);
|
|
1506
|
-
else doc.write(`
|
|
1507
|
-
if (${id}.issues.length) {
|
|
1508
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1509
|
-
...iss,
|
|
1510
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1511
|
-
})));
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
if (${id}.value === undefined) {
|
|
1515
|
-
if (${k} in input) {
|
|
1516
|
-
newResult[${k}] = undefined;
|
|
1517
|
-
}
|
|
1518
|
-
} else {
|
|
1519
|
-
newResult[${k}] = ${id}.value;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
`);
|
|
1523
|
-
}
|
|
1524
|
-
doc.write(`payload.value = newResult;`);
|
|
1525
|
-
doc.write(`return payload;`);
|
|
1526
|
-
const fn = doc.compile();
|
|
1527
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
1528
|
-
};
|
|
1529
|
-
let fastpass;
|
|
1530
|
-
const isObject$1 = isObject;
|
|
1531
|
-
const jit = !globalConfig.jitless;
|
|
1532
|
-
const fastEnabled = jit && allowsEval.value;
|
|
1533
|
-
const catchall = def.catchall;
|
|
1534
|
-
let value;
|
|
1535
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1536
|
-
value ?? (value = _normalized.value);
|
|
1537
|
-
const input = payload.value;
|
|
1538
|
-
if (!isObject$1(input)) {
|
|
1539
|
-
payload.issues.push({
|
|
1540
|
-
expected: "object",
|
|
1541
|
-
code: "invalid_type",
|
|
1542
|
-
input,
|
|
1543
|
-
inst
|
|
1544
|
-
});
|
|
1545
|
-
return payload;
|
|
1546
|
-
}
|
|
1547
|
-
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
1548
|
-
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1549
|
-
payload = fastpass(payload, ctx);
|
|
1550
|
-
if (!catchall) return payload;
|
|
1551
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
1552
|
-
}
|
|
1553
|
-
return superParse(payload, ctx);
|
|
1554
|
-
};
|
|
1555
|
-
});
|
|
1556
|
-
function handleUnionResults(results, final, inst, ctx) {
|
|
1557
|
-
for (const result of results) if (result.issues.length === 0) {
|
|
1558
|
-
final.value = result.value;
|
|
1559
|
-
return final;
|
|
1560
|
-
}
|
|
1561
|
-
const nonaborted = results.filter((r) => !aborted(r));
|
|
1562
|
-
if (nonaborted.length === 1) {
|
|
1563
|
-
final.value = nonaborted[0].value;
|
|
1564
|
-
return nonaborted[0];
|
|
1565
|
-
}
|
|
1566
|
-
final.issues.push({
|
|
1567
|
-
code: "invalid_union",
|
|
1568
|
-
input: final.value,
|
|
1569
|
-
inst,
|
|
1570
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1571
|
-
});
|
|
1572
|
-
return final;
|
|
1573
|
-
}
|
|
1574
|
-
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1575
|
-
$ZodType.init(inst, def);
|
|
1576
|
-
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
1577
|
-
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
1578
|
-
defineLazy(inst._zod, "values", () => {
|
|
1579
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1580
|
-
});
|
|
1581
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1582
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1583
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1584
|
-
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1585
|
-
}
|
|
1586
|
-
});
|
|
1587
|
-
const single = def.options.length === 1;
|
|
1588
|
-
const first = def.options[0]._zod.run;
|
|
1589
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1590
|
-
if (single) return first(payload, ctx);
|
|
1591
|
-
let async = false;
|
|
1592
|
-
const results = [];
|
|
1593
|
-
for (const option of def.options) {
|
|
1594
|
-
const result = option._zod.run({
|
|
1595
|
-
value: payload.value,
|
|
1596
|
-
issues: []
|
|
1597
|
-
}, ctx);
|
|
1598
|
-
if (result instanceof Promise) {
|
|
1599
|
-
results.push(result);
|
|
1600
|
-
async = true;
|
|
1601
|
-
} else {
|
|
1602
|
-
if (result.issues.length === 0) return result;
|
|
1603
|
-
results.push(result);
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
1607
|
-
return Promise.all(results).then((results) => {
|
|
1608
|
-
return handleUnionResults(results, payload, inst, ctx);
|
|
1609
|
-
});
|
|
1610
|
-
};
|
|
1611
|
-
});
|
|
1612
|
-
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
1613
|
-
$ZodType.init(inst, def);
|
|
1614
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1615
|
-
const input = payload.value;
|
|
1616
|
-
const left = def.left._zod.run({
|
|
1617
|
-
value: input,
|
|
1618
|
-
issues: []
|
|
1619
|
-
}, ctx);
|
|
1620
|
-
const right = def.right._zod.run({
|
|
1621
|
-
value: input,
|
|
1622
|
-
issues: []
|
|
1623
|
-
}, ctx);
|
|
1624
|
-
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
|
|
1625
|
-
return handleIntersectionResults(payload, left, right);
|
|
1626
|
-
});
|
|
1627
|
-
return handleIntersectionResults(payload, left, right);
|
|
1628
|
-
};
|
|
1629
|
-
});
|
|
1630
|
-
function mergeValues(a, b) {
|
|
1631
|
-
if (a === b) return {
|
|
1632
|
-
valid: true,
|
|
1633
|
-
data: a
|
|
1634
|
-
};
|
|
1635
|
-
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
1636
|
-
valid: true,
|
|
1637
|
-
data: a
|
|
1638
|
-
};
|
|
1639
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1640
|
-
const bKeys = Object.keys(b);
|
|
1641
|
-
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1642
|
-
const newObj = {
|
|
1643
|
-
...a,
|
|
1644
|
-
...b
|
|
1645
|
-
};
|
|
1646
|
-
for (const key of sharedKeys) {
|
|
1647
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
1648
|
-
if (!sharedValue.valid) return {
|
|
1649
|
-
valid: false,
|
|
1650
|
-
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
1651
|
-
};
|
|
1652
|
-
newObj[key] = sharedValue.data;
|
|
1653
|
-
}
|
|
1654
|
-
return {
|
|
1655
|
-
valid: true,
|
|
1656
|
-
data: newObj
|
|
1657
|
-
};
|
|
1658
|
-
}
|
|
1659
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1660
|
-
if (a.length !== b.length) return {
|
|
1661
|
-
valid: false,
|
|
1662
|
-
mergeErrorPath: []
|
|
1663
|
-
};
|
|
1664
|
-
const newArray = [];
|
|
1665
|
-
for (let index = 0; index < a.length; index++) {
|
|
1666
|
-
const itemA = a[index];
|
|
1667
|
-
const itemB = b[index];
|
|
1668
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
1669
|
-
if (!sharedValue.valid) return {
|
|
1670
|
-
valid: false,
|
|
1671
|
-
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
1672
|
-
};
|
|
1673
|
-
newArray.push(sharedValue.data);
|
|
1674
|
-
}
|
|
1675
|
-
return {
|
|
1676
|
-
valid: true,
|
|
1677
|
-
data: newArray
|
|
1678
|
-
};
|
|
1679
|
-
}
|
|
1680
|
-
return {
|
|
1681
|
-
valid: false,
|
|
1682
|
-
mergeErrorPath: []
|
|
1683
|
-
};
|
|
1684
|
-
}
|
|
1685
|
-
function handleIntersectionResults(result, left, right) {
|
|
1686
|
-
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1687
|
-
let unrecIssue;
|
|
1688
|
-
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
1689
|
-
unrecIssue ?? (unrecIssue = iss);
|
|
1690
|
-
for (const k of iss.keys) {
|
|
1691
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1692
|
-
unrecKeys.get(k).l = true;
|
|
1693
|
-
}
|
|
1694
|
-
} else result.issues.push(iss);
|
|
1695
|
-
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
1696
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1697
|
-
unrecKeys.get(k).r = true;
|
|
1698
|
-
}
|
|
1699
|
-
else result.issues.push(iss);
|
|
1700
|
-
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1701
|
-
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
1702
|
-
...unrecIssue,
|
|
1703
|
-
keys: bothKeys
|
|
1704
|
-
});
|
|
1705
|
-
if (aborted(result)) return result;
|
|
1706
|
-
const merged = mergeValues(left.value, right.value);
|
|
1707
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1708
|
-
result.value = merged.data;
|
|
1709
|
-
return result;
|
|
1710
|
-
}
|
|
1711
|
-
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1712
|
-
$ZodType.init(inst, def);
|
|
1713
|
-
const values = getEnumValues(def.entries);
|
|
1714
|
-
const valuesSet = new Set(values);
|
|
1715
|
-
inst._zod.values = valuesSet;
|
|
1716
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1717
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1718
|
-
const input = payload.value;
|
|
1719
|
-
if (valuesSet.has(input)) return payload;
|
|
1720
|
-
payload.issues.push({
|
|
1721
|
-
code: "invalid_value",
|
|
1722
|
-
values,
|
|
1723
|
-
input,
|
|
1724
|
-
inst
|
|
1725
|
-
});
|
|
1726
|
-
return payload;
|
|
1727
|
-
};
|
|
1728
|
-
});
|
|
1729
|
-
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1730
|
-
$ZodType.init(inst, def);
|
|
1731
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1732
|
-
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
1733
|
-
const _out = def.transform(payload.value, payload);
|
|
1734
|
-
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
1735
|
-
payload.value = output;
|
|
1736
|
-
return payload;
|
|
1737
|
-
});
|
|
1738
|
-
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
1739
|
-
payload.value = _out;
|
|
1740
|
-
return payload;
|
|
1741
|
-
};
|
|
1742
|
-
});
|
|
1743
|
-
function handleOptionalResult(result, input) {
|
|
1744
|
-
if (result.issues.length && input === void 0) return {
|
|
1745
|
-
issues: [],
|
|
1746
|
-
value: void 0
|
|
1747
|
-
};
|
|
1748
|
-
return result;
|
|
1749
|
-
}
|
|
1750
|
-
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1751
|
-
$ZodType.init(inst, def);
|
|
1752
|
-
inst._zod.optin = "optional";
|
|
1753
|
-
inst._zod.optout = "optional";
|
|
1754
|
-
defineLazy(inst._zod, "values", () => {
|
|
1755
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1756
|
-
});
|
|
1757
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1758
|
-
const pattern = def.innerType._zod.pattern;
|
|
1759
|
-
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1760
|
-
});
|
|
1761
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1762
|
-
if (def.innerType._zod.optin === "optional") {
|
|
1763
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1764
|
-
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1765
|
-
return handleOptionalResult(result, payload.value);
|
|
1766
|
-
}
|
|
1767
|
-
if (payload.value === void 0) return payload;
|
|
1768
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1769
|
-
};
|
|
1770
|
-
});
|
|
1771
|
-
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
1772
|
-
$ZodOptional.init(inst, def);
|
|
1773
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1774
|
-
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
1775
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1776
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1777
|
-
};
|
|
1778
|
-
});
|
|
1779
|
-
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1780
|
-
$ZodType.init(inst, def);
|
|
1781
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1782
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1783
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1784
|
-
const pattern = def.innerType._zod.pattern;
|
|
1785
|
-
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1786
|
-
});
|
|
1787
|
-
defineLazy(inst._zod, "values", () => {
|
|
1788
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1789
|
-
});
|
|
1790
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1791
|
-
if (payload.value === null) return payload;
|
|
1792
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1793
|
-
};
|
|
1794
|
-
});
|
|
1795
|
-
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1796
|
-
$ZodType.init(inst, def);
|
|
1797
|
-
inst._zod.optin = "optional";
|
|
1798
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1799
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1800
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1801
|
-
if (payload.value === void 0) {
|
|
1802
|
-
payload.value = def.defaultValue;
|
|
1803
|
-
/**
|
|
1804
|
-
* $ZodDefault returns the default value immediately in forward direction.
|
|
1805
|
-
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1806
|
-
return payload;
|
|
1807
|
-
}
|
|
1808
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1809
|
-
if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
|
|
1810
|
-
return handleDefaultResult(result, def);
|
|
1811
|
-
};
|
|
1812
|
-
});
|
|
1813
|
-
function handleDefaultResult(payload, def) {
|
|
1814
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1815
|
-
return payload;
|
|
1816
|
-
}
|
|
1817
|
-
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1818
|
-
$ZodType.init(inst, def);
|
|
1819
|
-
inst._zod.optin = "optional";
|
|
1820
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1821
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1822
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1823
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1824
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1825
|
-
};
|
|
1826
|
-
});
|
|
1827
|
-
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1828
|
-
$ZodType.init(inst, def);
|
|
1829
|
-
defineLazy(inst._zod, "values", () => {
|
|
1830
|
-
const v = def.innerType._zod.values;
|
|
1831
|
-
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
1832
|
-
});
|
|
1833
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1834
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1835
|
-
if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
|
|
1836
|
-
return handleNonOptionalResult(result, inst);
|
|
1837
|
-
};
|
|
1838
|
-
});
|
|
1839
|
-
function handleNonOptionalResult(payload, inst) {
|
|
1840
|
-
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
1841
|
-
code: "invalid_type",
|
|
1842
|
-
expected: "nonoptional",
|
|
1843
|
-
input: payload.value,
|
|
1844
|
-
inst
|
|
1845
|
-
});
|
|
1846
|
-
return payload;
|
|
1847
|
-
}
|
|
1848
|
-
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
1849
|
-
$ZodType.init(inst, def);
|
|
1850
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1851
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1852
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1853
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1854
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1855
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1856
|
-
if (result instanceof Promise) return result.then((result) => {
|
|
1857
|
-
payload.value = result.value;
|
|
1858
|
-
if (result.issues.length) {
|
|
1859
|
-
payload.value = def.catchValue({
|
|
1860
|
-
...payload,
|
|
1861
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1862
|
-
input: payload.value
|
|
1863
|
-
});
|
|
1864
|
-
payload.issues = [];
|
|
1865
|
-
}
|
|
1866
|
-
return payload;
|
|
1867
|
-
});
|
|
1868
|
-
payload.value = result.value;
|
|
1869
|
-
if (result.issues.length) {
|
|
1870
|
-
payload.value = def.catchValue({
|
|
1871
|
-
...payload,
|
|
1872
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1873
|
-
input: payload.value
|
|
1874
|
-
});
|
|
1875
|
-
payload.issues = [];
|
|
1876
|
-
}
|
|
1877
|
-
return payload;
|
|
1878
|
-
};
|
|
1879
|
-
});
|
|
1880
|
-
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
1881
|
-
$ZodType.init(inst, def);
|
|
1882
|
-
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1883
|
-
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1884
|
-
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1885
|
-
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1886
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1887
|
-
if (ctx.direction === "backward") {
|
|
1888
|
-
const right = def.out._zod.run(payload, ctx);
|
|
1889
|
-
if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
1890
|
-
return handlePipeResult(right, def.in, ctx);
|
|
1891
|
-
}
|
|
1892
|
-
const left = def.in._zod.run(payload, ctx);
|
|
1893
|
-
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
1894
|
-
return handlePipeResult(left, def.out, ctx);
|
|
1895
|
-
};
|
|
1896
|
-
});
|
|
1897
|
-
function handlePipeResult(left, next, ctx) {
|
|
1898
|
-
if (left.issues.length) {
|
|
1899
|
-
left.aborted = true;
|
|
1900
|
-
return left;
|
|
1901
|
-
}
|
|
1902
|
-
return next._zod.run({
|
|
1903
|
-
value: left.value,
|
|
1904
|
-
issues: left.issues
|
|
1905
|
-
}, ctx);
|
|
1906
|
-
}
|
|
1907
|
-
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
1908
|
-
$ZodType.init(inst, def);
|
|
1909
|
-
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1910
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1911
|
-
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
1912
|
-
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
1913
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1914
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1915
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1916
|
-
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
1917
|
-
return handleReadonlyResult(result);
|
|
1918
|
-
};
|
|
1919
|
-
});
|
|
1920
|
-
function handleReadonlyResult(payload) {
|
|
1921
|
-
payload.value = Object.freeze(payload.value);
|
|
1922
|
-
return payload;
|
|
1923
|
-
}
|
|
1924
|
-
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
1925
|
-
$ZodCheck.init(inst, def);
|
|
1926
|
-
$ZodType.init(inst, def);
|
|
1927
|
-
inst._zod.parse = (payload, _) => {
|
|
1928
|
-
return payload;
|
|
1929
|
-
};
|
|
1930
|
-
inst._zod.check = (payload) => {
|
|
1931
|
-
const input = payload.value;
|
|
1932
|
-
const r = def.fn(input);
|
|
1933
|
-
if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
1934
|
-
handleRefineResult(r, payload, input, inst);
|
|
1935
|
-
};
|
|
1936
|
-
});
|
|
1937
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
1938
|
-
if (!result) {
|
|
1939
|
-
const _iss = {
|
|
1940
|
-
code: "custom",
|
|
1941
|
-
input,
|
|
1942
|
-
inst,
|
|
1943
|
-
path: [...inst._zod.def.path ?? []],
|
|
1944
|
-
continue: !inst._zod.def.abort
|
|
1945
|
-
};
|
|
1946
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
1947
|
-
payload.issues.push(issue(_iss));
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
//#endregion
|
|
1951
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
|
|
1952
|
-
var _a;
|
|
1953
|
-
var $ZodRegistry = class {
|
|
1954
|
-
constructor() {
|
|
1955
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
1956
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
1957
|
-
}
|
|
1958
|
-
add(schema, ..._meta) {
|
|
1959
|
-
const meta = _meta[0];
|
|
1960
|
-
this._map.set(schema, meta);
|
|
1961
|
-
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
1962
|
-
return this;
|
|
1963
|
-
}
|
|
1964
|
-
clear() {
|
|
1965
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
1966
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
1967
|
-
return this;
|
|
1968
|
-
}
|
|
1969
|
-
remove(schema) {
|
|
1970
|
-
const meta = this._map.get(schema);
|
|
1971
|
-
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
1972
|
-
this._map.delete(schema);
|
|
1973
|
-
return this;
|
|
1974
|
-
}
|
|
1975
|
-
get(schema) {
|
|
1976
|
-
const p = schema._zod.parent;
|
|
1977
|
-
if (p) {
|
|
1978
|
-
const pm = { ...this.get(p) ?? {} };
|
|
1979
|
-
delete pm.id;
|
|
1980
|
-
const f = {
|
|
1981
|
-
...pm,
|
|
1982
|
-
...this._map.get(schema)
|
|
1983
|
-
};
|
|
1984
|
-
return Object.keys(f).length ? f : void 0;
|
|
1985
|
-
}
|
|
1986
|
-
return this._map.get(schema);
|
|
1987
|
-
}
|
|
1988
|
-
has(schema) {
|
|
1989
|
-
return this._map.has(schema);
|
|
1990
|
-
}
|
|
1991
|
-
};
|
|
1992
|
-
function registry() {
|
|
1993
|
-
return new $ZodRegistry();
|
|
1994
|
-
}
|
|
1995
|
-
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
1996
|
-
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
1997
|
-
//#endregion
|
|
1998
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
|
|
1999
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2000
|
-
function _number(Class, params) {
|
|
2001
|
-
return new Class({
|
|
2002
|
-
type: "number",
|
|
2003
|
-
checks: [],
|
|
2004
|
-
...normalizeParams(params)
|
|
2005
|
-
});
|
|
2006
|
-
}
|
|
2007
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2008
|
-
function _int(Class, params) {
|
|
2009
|
-
return new Class({
|
|
2010
|
-
type: "number",
|
|
2011
|
-
check: "number_format",
|
|
2012
|
-
abort: false,
|
|
2013
|
-
format: "safeint",
|
|
2014
|
-
...normalizeParams(params)
|
|
2015
|
-
});
|
|
2016
|
-
}
|
|
2017
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2018
|
-
function _unknown(Class) {
|
|
2019
|
-
return new Class({ type: "unknown" });
|
|
2020
|
-
}
|
|
2021
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2022
|
-
function _never(Class, params) {
|
|
2023
|
-
return new Class({
|
|
2024
|
-
type: "never",
|
|
2025
|
-
...normalizeParams(params)
|
|
2026
|
-
});
|
|
2027
|
-
}
|
|
2028
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2029
|
-
function _lt(value, params) {
|
|
2030
|
-
return new $ZodCheckLessThan({
|
|
2031
|
-
check: "less_than",
|
|
2032
|
-
...normalizeParams(params),
|
|
2033
|
-
value,
|
|
2034
|
-
inclusive: false
|
|
2035
|
-
});
|
|
2036
|
-
}
|
|
2037
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2038
|
-
function _lte(value, params) {
|
|
2039
|
-
return new $ZodCheckLessThan({
|
|
2040
|
-
check: "less_than",
|
|
2041
|
-
...normalizeParams(params),
|
|
2042
|
-
value,
|
|
2043
|
-
inclusive: true
|
|
2044
|
-
});
|
|
2045
|
-
}
|
|
2046
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2047
|
-
function _gt(value, params) {
|
|
2048
|
-
return new $ZodCheckGreaterThan({
|
|
2049
|
-
check: "greater_than",
|
|
2050
|
-
...normalizeParams(params),
|
|
2051
|
-
value,
|
|
2052
|
-
inclusive: false
|
|
2053
|
-
});
|
|
2054
|
-
}
|
|
2055
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2056
|
-
function _gte(value, params) {
|
|
2057
|
-
return new $ZodCheckGreaterThan({
|
|
2058
|
-
check: "greater_than",
|
|
2059
|
-
...normalizeParams(params),
|
|
2060
|
-
value,
|
|
2061
|
-
inclusive: true
|
|
2062
|
-
});
|
|
2063
|
-
}
|
|
2064
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2065
|
-
function _multipleOf(value, params) {
|
|
2066
|
-
return new $ZodCheckMultipleOf({
|
|
2067
|
-
check: "multiple_of",
|
|
2068
|
-
...normalizeParams(params),
|
|
2069
|
-
value
|
|
2070
|
-
});
|
|
2071
|
-
}
|
|
2072
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2073
|
-
function _maxLength(maximum, params) {
|
|
2074
|
-
return new $ZodCheckMaxLength({
|
|
2075
|
-
check: "max_length",
|
|
2076
|
-
...normalizeParams(params),
|
|
2077
|
-
maximum
|
|
2078
|
-
});
|
|
2079
|
-
}
|
|
2080
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2081
|
-
function _minLength(minimum, params) {
|
|
2082
|
-
return new $ZodCheckMinLength({
|
|
2083
|
-
check: "min_length",
|
|
2084
|
-
...normalizeParams(params),
|
|
2085
|
-
minimum
|
|
2086
|
-
});
|
|
2087
|
-
}
|
|
2088
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2089
|
-
function _length(length, params) {
|
|
2090
|
-
return new $ZodCheckLengthEquals({
|
|
2091
|
-
check: "length_equals",
|
|
2092
|
-
...normalizeParams(params),
|
|
2093
|
-
length
|
|
2094
|
-
});
|
|
2095
|
-
}
|
|
2096
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2097
|
-
function _overwrite(tx) {
|
|
2098
|
-
return new $ZodCheckOverwrite({
|
|
2099
|
-
check: "overwrite",
|
|
2100
|
-
tx
|
|
2101
|
-
});
|
|
2102
|
-
}
|
|
2103
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2104
|
-
function _array(Class, element, params) {
|
|
2105
|
-
return new Class({
|
|
2106
|
-
type: "array",
|
|
2107
|
-
element,
|
|
2108
|
-
...normalizeParams(params)
|
|
2109
|
-
});
|
|
2110
|
-
}
|
|
2111
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2112
|
-
function _refine(Class, fn, _params) {
|
|
2113
|
-
return new Class({
|
|
2114
|
-
type: "custom",
|
|
2115
|
-
check: "custom",
|
|
2116
|
-
fn,
|
|
2117
|
-
...normalizeParams(_params)
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2120
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2121
|
-
function _superRefine(fn) {
|
|
2122
|
-
const ch = /* @__PURE__ */ _check((payload) => {
|
|
2123
|
-
payload.addIssue = (issue$2) => {
|
|
2124
|
-
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
2125
|
-
else {
|
|
2126
|
-
const _issue = issue$2;
|
|
2127
|
-
if (_issue.fatal) _issue.continue = false;
|
|
2128
|
-
_issue.code ?? (_issue.code = "custom");
|
|
2129
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
2130
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
2131
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2132
|
-
payload.issues.push(issue(_issue));
|
|
2133
|
-
}
|
|
2134
|
-
};
|
|
2135
|
-
return fn(payload.value, payload);
|
|
2136
|
-
});
|
|
2137
|
-
return ch;
|
|
2138
|
-
}
|
|
2139
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
2140
|
-
function _check(fn, params) {
|
|
2141
|
-
const ch = new $ZodCheck({
|
|
2142
|
-
check: "custom",
|
|
2143
|
-
...normalizeParams(params)
|
|
2144
|
-
});
|
|
2145
|
-
ch._zod.check = fn;
|
|
2146
|
-
return ch;
|
|
2147
|
-
}
|
|
2148
|
-
//#endregion
|
|
2149
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
|
|
2150
|
-
function initializeContext(params) {
|
|
2151
|
-
let target = params?.target ?? "draft-2020-12";
|
|
2152
|
-
if (target === "draft-4") target = "draft-04";
|
|
2153
|
-
if (target === "draft-7") target = "draft-07";
|
|
2154
|
-
return {
|
|
2155
|
-
processors: params.processors ?? {},
|
|
2156
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
2157
|
-
target,
|
|
2158
|
-
unrepresentable: params?.unrepresentable ?? "throw",
|
|
2159
|
-
override: params?.override ?? (() => {}),
|
|
2160
|
-
io: params?.io ?? "output",
|
|
2161
|
-
counter: 0,
|
|
2162
|
-
seen: /* @__PURE__ */ new Map(),
|
|
2163
|
-
cycles: params?.cycles ?? "ref",
|
|
2164
|
-
reused: params?.reused ?? "inline",
|
|
2165
|
-
external: params?.external ?? void 0
|
|
2166
|
-
};
|
|
2167
|
-
}
|
|
2168
|
-
function process$1(schema, ctx, _params = {
|
|
2169
|
-
path: [],
|
|
2170
|
-
schemaPath: []
|
|
2171
|
-
}) {
|
|
2172
|
-
var _a;
|
|
2173
|
-
const def = schema._zod.def;
|
|
2174
|
-
const seen = ctx.seen.get(schema);
|
|
2175
|
-
if (seen) {
|
|
2176
|
-
seen.count++;
|
|
2177
|
-
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
2178
|
-
return seen.schema;
|
|
2179
|
-
}
|
|
2180
|
-
const result = {
|
|
2181
|
-
schema: {},
|
|
2182
|
-
count: 1,
|
|
2183
|
-
cycle: void 0,
|
|
2184
|
-
path: _params.path
|
|
2185
|
-
};
|
|
2186
|
-
ctx.seen.set(schema, result);
|
|
2187
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2188
|
-
if (overrideSchema) result.schema = overrideSchema;
|
|
2189
|
-
else {
|
|
2190
|
-
const params = {
|
|
2191
|
-
..._params,
|
|
2192
|
-
schemaPath: [..._params.schemaPath, schema],
|
|
2193
|
-
path: _params.path
|
|
2194
|
-
};
|
|
2195
|
-
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
2196
|
-
else {
|
|
2197
|
-
const _json = result.schema;
|
|
2198
|
-
const processor = ctx.processors[def.type];
|
|
2199
|
-
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
2200
|
-
processor(schema, ctx, _json, params);
|
|
2201
|
-
}
|
|
2202
|
-
const parent = schema._zod.parent;
|
|
2203
|
-
if (parent) {
|
|
2204
|
-
if (!result.ref) result.ref = parent;
|
|
2205
|
-
process$1(parent, ctx, params);
|
|
2206
|
-
ctx.seen.get(parent).isParent = true;
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
const meta = ctx.metadataRegistry.get(schema);
|
|
2210
|
-
if (meta) Object.assign(result.schema, meta);
|
|
2211
|
-
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2212
|
-
delete result.schema.examples;
|
|
2213
|
-
delete result.schema.default;
|
|
2214
|
-
}
|
|
2215
|
-
if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
2216
|
-
delete result.schema._prefault;
|
|
2217
|
-
return ctx.seen.get(schema).schema;
|
|
2218
|
-
}
|
|
2219
|
-
function extractDefs(ctx, schema) {
|
|
2220
|
-
const root = ctx.seen.get(schema);
|
|
2221
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2222
|
-
const idToSchema = /* @__PURE__ */ new Map();
|
|
2223
|
-
for (const entry of ctx.seen.entries()) {
|
|
2224
|
-
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
2225
|
-
if (id) {
|
|
2226
|
-
const existing = idToSchema.get(id);
|
|
2227
|
-
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
2228
|
-
idToSchema.set(id, entry[0]);
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
const makeURI = (entry) => {
|
|
2232
|
-
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
2233
|
-
if (ctx.external) {
|
|
2234
|
-
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
2235
|
-
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
2236
|
-
if (externalId) return { ref: uriGenerator(externalId) };
|
|
2237
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
2238
|
-
entry[1].defId = id;
|
|
2239
|
-
return {
|
|
2240
|
-
defId: id,
|
|
2241
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
2242
|
-
};
|
|
2243
|
-
}
|
|
2244
|
-
if (entry[1] === root) return { ref: "#" };
|
|
2245
|
-
const defUriPrefix = `#/${defsSegment}/`;
|
|
2246
|
-
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2247
|
-
return {
|
|
2248
|
-
defId,
|
|
2249
|
-
ref: defUriPrefix + defId
|
|
2250
|
-
};
|
|
2251
|
-
};
|
|
2252
|
-
const extractToDef = (entry) => {
|
|
2253
|
-
if (entry[1].schema.$ref) return;
|
|
2254
|
-
const seen = entry[1];
|
|
2255
|
-
const { ref, defId } = makeURI(entry);
|
|
2256
|
-
seen.def = { ...seen.schema };
|
|
2257
|
-
if (defId) seen.defId = defId;
|
|
2258
|
-
const schema = seen.schema;
|
|
2259
|
-
for (const key in schema) delete schema[key];
|
|
2260
|
-
schema.$ref = ref;
|
|
2261
|
-
};
|
|
2262
|
-
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
2263
|
-
const seen = entry[1];
|
|
2264
|
-
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
2265
|
-
|
|
2266
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
2267
|
-
}
|
|
2268
|
-
for (const entry of ctx.seen.entries()) {
|
|
2269
|
-
const seen = entry[1];
|
|
2270
|
-
if (schema === entry[0]) {
|
|
2271
|
-
extractToDef(entry);
|
|
2272
|
-
continue;
|
|
2273
|
-
}
|
|
2274
|
-
if (ctx.external) {
|
|
2275
|
-
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
2276
|
-
if (schema !== entry[0] && ext) {
|
|
2277
|
-
extractToDef(entry);
|
|
2278
|
-
continue;
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
2282
|
-
extractToDef(entry);
|
|
2283
|
-
continue;
|
|
2284
|
-
}
|
|
2285
|
-
if (seen.cycle) {
|
|
2286
|
-
extractToDef(entry);
|
|
2287
|
-
continue;
|
|
2288
|
-
}
|
|
2289
|
-
if (seen.count > 1) {
|
|
2290
|
-
if (ctx.reused === "ref") {
|
|
2291
|
-
extractToDef(entry);
|
|
2292
|
-
continue;
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
function finalize(ctx, schema) {
|
|
2298
|
-
const root = ctx.seen.get(schema);
|
|
2299
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2300
|
-
const flattenRef = (zodSchema) => {
|
|
2301
|
-
const seen = ctx.seen.get(zodSchema);
|
|
2302
|
-
if (seen.ref === null) return;
|
|
2303
|
-
const schema = seen.def ?? seen.schema;
|
|
2304
|
-
const _cached = { ...schema };
|
|
2305
|
-
const ref = seen.ref;
|
|
2306
|
-
seen.ref = null;
|
|
2307
|
-
if (ref) {
|
|
2308
|
-
flattenRef(ref);
|
|
2309
|
-
const refSeen = ctx.seen.get(ref);
|
|
2310
|
-
const refSchema = refSeen.schema;
|
|
2311
|
-
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2312
|
-
schema.allOf = schema.allOf ?? [];
|
|
2313
|
-
schema.allOf.push(refSchema);
|
|
2314
|
-
} else Object.assign(schema, refSchema);
|
|
2315
|
-
Object.assign(schema, _cached);
|
|
2316
|
-
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
2317
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
2318
|
-
if (!(key in _cached)) delete schema[key];
|
|
2319
|
-
}
|
|
2320
|
-
if (refSchema.$ref && refSeen.def) for (const key in schema) {
|
|
2321
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
2322
|
-
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
const parent = zodSchema._zod.parent;
|
|
2326
|
-
if (parent && parent !== ref) {
|
|
2327
|
-
flattenRef(parent);
|
|
2328
|
-
const parentSeen = ctx.seen.get(parent);
|
|
2329
|
-
if (parentSeen?.schema.$ref) {
|
|
2330
|
-
schema.$ref = parentSeen.schema.$ref;
|
|
2331
|
-
if (parentSeen.def) for (const key in schema) {
|
|
2332
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
2333
|
-
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
ctx.override({
|
|
2338
|
-
zodSchema,
|
|
2339
|
-
jsonSchema: schema,
|
|
2340
|
-
path: seen.path ?? []
|
|
2341
|
-
});
|
|
2342
|
-
};
|
|
2343
|
-
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
2344
|
-
const result = {};
|
|
2345
|
-
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
2346
|
-
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
2347
|
-
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
2348
|
-
else if (ctx.target === "openapi-3.0") {}
|
|
2349
|
-
if (ctx.external?.uri) {
|
|
2350
|
-
const id = ctx.external.registry.get(schema)?.id;
|
|
2351
|
-
if (!id) throw new Error("Schema is missing an `id` property");
|
|
2352
|
-
result.$id = ctx.external.uri(id);
|
|
2353
|
-
}
|
|
2354
|
-
Object.assign(result, root.def ?? root.schema);
|
|
2355
|
-
const defs = ctx.external?.defs ?? {};
|
|
2356
|
-
for (const entry of ctx.seen.entries()) {
|
|
2357
|
-
const seen = entry[1];
|
|
2358
|
-
if (seen.def && seen.defId) defs[seen.defId] = seen.def;
|
|
2359
|
-
}
|
|
2360
|
-
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
2361
|
-
else result.definitions = defs;
|
|
2362
|
-
try {
|
|
2363
|
-
const finalized = JSON.parse(JSON.stringify(result));
|
|
2364
|
-
Object.defineProperty(finalized, "~standard", {
|
|
2365
|
-
value: {
|
|
2366
|
-
...schema["~standard"],
|
|
2367
|
-
jsonSchema: {
|
|
2368
|
-
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
2369
|
-
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
2370
|
-
}
|
|
2371
|
-
},
|
|
2372
|
-
enumerable: false,
|
|
2373
|
-
writable: false
|
|
2374
|
-
});
|
|
2375
|
-
return finalized;
|
|
2376
|
-
} catch (_err) {
|
|
2377
|
-
throw new Error("Error converting schema to JSON.");
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
function isTransforming(_schema, _ctx) {
|
|
2381
|
-
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
2382
|
-
if (ctx.seen.has(_schema)) return false;
|
|
2383
|
-
ctx.seen.add(_schema);
|
|
2384
|
-
const def = _schema._zod.def;
|
|
2385
|
-
if (def.type === "transform") return true;
|
|
2386
|
-
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
2387
|
-
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
2388
|
-
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
2389
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
2390
|
-
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
2391
|
-
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
2392
|
-
if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
2393
|
-
if (def.type === "object") {
|
|
2394
|
-
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
2395
|
-
return false;
|
|
2396
|
-
}
|
|
2397
|
-
if (def.type === "union") {
|
|
2398
|
-
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
2399
|
-
return false;
|
|
2400
|
-
}
|
|
2401
|
-
if (def.type === "tuple") {
|
|
2402
|
-
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
2403
|
-
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
2404
|
-
return false;
|
|
2405
|
-
}
|
|
2406
|
-
return false;
|
|
2407
|
-
}
|
|
2408
|
-
/**
|
|
2409
|
-
* Creates a toJSONSchema method for a schema instance.
|
|
2410
|
-
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
2411
|
-
*/
|
|
2412
|
-
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
2413
|
-
const ctx = initializeContext({
|
|
2414
|
-
...params,
|
|
2415
|
-
processors
|
|
2416
|
-
});
|
|
2417
|
-
process$1(schema, ctx);
|
|
2418
|
-
extractDefs(ctx, schema);
|
|
2419
|
-
return finalize(ctx, schema);
|
|
2420
|
-
};
|
|
2421
|
-
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
2422
|
-
const { libraryOptions, target } = params ?? {};
|
|
2423
|
-
const ctx = initializeContext({
|
|
2424
|
-
...libraryOptions ?? {},
|
|
2425
|
-
target,
|
|
2426
|
-
io,
|
|
2427
|
-
processors
|
|
2428
|
-
});
|
|
2429
|
-
process$1(schema, ctx);
|
|
2430
|
-
extractDefs(ctx, schema);
|
|
2431
|
-
return finalize(ctx, schema);
|
|
2432
|
-
};
|
|
2433
|
-
//#endregion
|
|
2434
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
|
|
2435
|
-
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
2436
|
-
const json = _json;
|
|
2437
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
2438
|
-
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
2439
|
-
else json.type = "number";
|
|
2440
|
-
if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
2441
|
-
json.minimum = exclusiveMinimum;
|
|
2442
|
-
json.exclusiveMinimum = true;
|
|
2443
|
-
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
2444
|
-
if (typeof minimum === "number") {
|
|
2445
|
-
json.minimum = minimum;
|
|
2446
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
2447
|
-
else delete json.exclusiveMinimum;
|
|
2448
|
-
}
|
|
2449
|
-
if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
2450
|
-
json.maximum = exclusiveMaximum;
|
|
2451
|
-
json.exclusiveMaximum = true;
|
|
2452
|
-
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
2453
|
-
if (typeof maximum === "number") {
|
|
2454
|
-
json.maximum = maximum;
|
|
2455
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
2456
|
-
else delete json.exclusiveMaximum;
|
|
2457
|
-
}
|
|
2458
|
-
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
2459
|
-
};
|
|
2460
|
-
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
2461
|
-
json.not = {};
|
|
2462
|
-
};
|
|
2463
|
-
const unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
2464
|
-
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
2465
|
-
const def = schema._zod.def;
|
|
2466
|
-
const values = getEnumValues(def.entries);
|
|
2467
|
-
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
2468
|
-
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
2469
|
-
json.enum = values;
|
|
2470
|
-
};
|
|
2471
|
-
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
2472
|
-
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
2473
|
-
};
|
|
2474
|
-
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
2475
|
-
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
2476
|
-
};
|
|
2477
|
-
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
2478
|
-
const json = _json;
|
|
2479
|
-
const def = schema._zod.def;
|
|
2480
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
2481
|
-
if (typeof minimum === "number") json.minItems = minimum;
|
|
2482
|
-
if (typeof maximum === "number") json.maxItems = maximum;
|
|
2483
|
-
json.type = "array";
|
|
2484
|
-
json.items = process$1(def.element, ctx, {
|
|
2485
|
-
...params,
|
|
2486
|
-
path: [...params.path, "items"]
|
|
2487
|
-
});
|
|
2488
|
-
};
|
|
2489
|
-
const objectProcessor = (schema, ctx, _json, params) => {
|
|
2490
|
-
const json = _json;
|
|
2491
|
-
const def = schema._zod.def;
|
|
2492
|
-
json.type = "object";
|
|
2493
|
-
json.properties = {};
|
|
2494
|
-
const shape = def.shape;
|
|
2495
|
-
for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
|
|
2496
|
-
...params,
|
|
2497
|
-
path: [
|
|
2498
|
-
...params.path,
|
|
2499
|
-
"properties",
|
|
2500
|
-
key
|
|
2501
|
-
]
|
|
2502
|
-
});
|
|
2503
|
-
const allKeys = new Set(Object.keys(shape));
|
|
2504
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
2505
|
-
const v = def.shape[key]._zod;
|
|
2506
|
-
if (ctx.io === "input") return v.optin === void 0;
|
|
2507
|
-
else return v.optout === void 0;
|
|
2508
|
-
}));
|
|
2509
|
-
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
|
|
2510
|
-
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
2511
|
-
else if (!def.catchall) {
|
|
2512
|
-
if (ctx.io === "output") json.additionalProperties = false;
|
|
2513
|
-
} else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
|
|
2514
|
-
...params,
|
|
2515
|
-
path: [...params.path, "additionalProperties"]
|
|
2516
|
-
});
|
|
2517
|
-
};
|
|
2518
|
-
const unionProcessor = (schema, ctx, json, params) => {
|
|
2519
|
-
const def = schema._zod.def;
|
|
2520
|
-
const isExclusive = def.inclusive === false;
|
|
2521
|
-
const options = def.options.map((x, i) => process$1(x, ctx, {
|
|
2522
|
-
...params,
|
|
2523
|
-
path: [
|
|
2524
|
-
...params.path,
|
|
2525
|
-
isExclusive ? "oneOf" : "anyOf",
|
|
2526
|
-
i
|
|
2527
|
-
]
|
|
2528
|
-
}));
|
|
2529
|
-
if (isExclusive) json.oneOf = options;
|
|
2530
|
-
else json.anyOf = options;
|
|
2531
|
-
};
|
|
2532
|
-
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
2533
|
-
const def = schema._zod.def;
|
|
2534
|
-
const a = process$1(def.left, ctx, {
|
|
2535
|
-
...params,
|
|
2536
|
-
path: [
|
|
2537
|
-
...params.path,
|
|
2538
|
-
"allOf",
|
|
2539
|
-
0
|
|
2540
|
-
]
|
|
2541
|
-
});
|
|
2542
|
-
const b = process$1(def.right, ctx, {
|
|
2543
|
-
...params,
|
|
2544
|
-
path: [
|
|
2545
|
-
...params.path,
|
|
2546
|
-
"allOf",
|
|
2547
|
-
1
|
|
2548
|
-
]
|
|
2549
|
-
});
|
|
2550
|
-
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
2551
|
-
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
2552
|
-
};
|
|
2553
|
-
const nullableProcessor = (schema, ctx, json, params) => {
|
|
2554
|
-
const def = schema._zod.def;
|
|
2555
|
-
const inner = process$1(def.innerType, ctx, params);
|
|
2556
|
-
const seen = ctx.seen.get(schema);
|
|
2557
|
-
if (ctx.target === "openapi-3.0") {
|
|
2558
|
-
seen.ref = def.innerType;
|
|
2559
|
-
json.nullable = true;
|
|
2560
|
-
} else json.anyOf = [inner, { type: "null" }];
|
|
2561
|
-
};
|
|
2562
|
-
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
2563
|
-
const def = schema._zod.def;
|
|
2564
|
-
process$1(def.innerType, ctx, params);
|
|
2565
|
-
const seen = ctx.seen.get(schema);
|
|
2566
|
-
seen.ref = def.innerType;
|
|
2567
|
-
};
|
|
2568
|
-
const defaultProcessor = (schema, ctx, json, params) => {
|
|
2569
|
-
const def = schema._zod.def;
|
|
2570
|
-
process$1(def.innerType, ctx, params);
|
|
2571
|
-
const seen = ctx.seen.get(schema);
|
|
2572
|
-
seen.ref = def.innerType;
|
|
2573
|
-
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
2574
|
-
};
|
|
2575
|
-
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
2576
|
-
const def = schema._zod.def;
|
|
2577
|
-
process$1(def.innerType, ctx, params);
|
|
2578
|
-
const seen = ctx.seen.get(schema);
|
|
2579
|
-
seen.ref = def.innerType;
|
|
2580
|
-
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
2581
|
-
};
|
|
2582
|
-
const catchProcessor = (schema, ctx, json, params) => {
|
|
2583
|
-
const def = schema._zod.def;
|
|
2584
|
-
process$1(def.innerType, ctx, params);
|
|
2585
|
-
const seen = ctx.seen.get(schema);
|
|
2586
|
-
seen.ref = def.innerType;
|
|
2587
|
-
let catchValue;
|
|
2588
|
-
try {
|
|
2589
|
-
catchValue = def.catchValue(void 0);
|
|
2590
|
-
} catch {
|
|
2591
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
2592
|
-
}
|
|
2593
|
-
json.default = catchValue;
|
|
2594
|
-
};
|
|
2595
|
-
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
2596
|
-
const def = schema._zod.def;
|
|
2597
|
-
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
2598
|
-
process$1(innerType, ctx, params);
|
|
2599
|
-
const seen = ctx.seen.get(schema);
|
|
2600
|
-
seen.ref = innerType;
|
|
2601
|
-
};
|
|
2602
|
-
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
2603
|
-
const def = schema._zod.def;
|
|
2604
|
-
process$1(def.innerType, ctx, params);
|
|
2605
|
-
const seen = ctx.seen.get(schema);
|
|
2606
|
-
seen.ref = def.innerType;
|
|
2607
|
-
json.readOnly = true;
|
|
2608
|
-
};
|
|
2609
|
-
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
2610
|
-
const def = schema._zod.def;
|
|
2611
|
-
process$1(def.innerType, ctx, params);
|
|
2612
|
-
const seen = ctx.seen.get(schema);
|
|
2613
|
-
seen.ref = def.innerType;
|
|
2614
|
-
};
|
|
2615
|
-
//#endregion
|
|
2616
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
|
|
2617
|
-
const initializer = (inst, issues) => {
|
|
2618
|
-
$ZodError.init(inst, issues);
|
|
2619
|
-
inst.name = "ZodError";
|
|
2620
|
-
Object.defineProperties(inst, {
|
|
2621
|
-
format: { value: (mapper) => formatError(inst, mapper) },
|
|
2622
|
-
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
2623
|
-
addIssue: { value: (issue) => {
|
|
2624
|
-
inst.issues.push(issue);
|
|
2625
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2626
|
-
} },
|
|
2627
|
-
addIssues: { value: (issues) => {
|
|
2628
|
-
inst.issues.push(...issues);
|
|
2629
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2630
|
-
} },
|
|
2631
|
-
isEmpty: { get() {
|
|
2632
|
-
return inst.issues.length === 0;
|
|
2633
|
-
} }
|
|
2634
|
-
});
|
|
2635
|
-
};
|
|
2636
|
-
$constructor("ZodError", initializer);
|
|
2637
|
-
const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
2638
|
-
//#endregion
|
|
2639
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/parse.js
|
|
2640
|
-
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
2641
|
-
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
2642
|
-
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
2643
|
-
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
2644
|
-
const encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
2645
|
-
const decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
2646
|
-
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
2647
|
-
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
2648
|
-
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
2649
|
-
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
2650
|
-
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
2651
|
-
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
2652
|
-
//#endregion
|
|
2653
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
|
|
2654
|
-
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
2655
|
-
$ZodType.init(inst, def);
|
|
2656
|
-
Object.assign(inst["~standard"], { jsonSchema: {
|
|
2657
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
2658
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
2659
|
-
} });
|
|
2660
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
2661
|
-
inst.def = def;
|
|
2662
|
-
inst.type = def.type;
|
|
2663
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
2664
|
-
inst.check = (...checks) => {
|
|
2665
|
-
return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
2666
|
-
check: ch,
|
|
2667
|
-
def: { check: "custom" },
|
|
2668
|
-
onattach: []
|
|
2669
|
-
} } : ch)] }), { parent: true });
|
|
2670
|
-
};
|
|
2671
|
-
inst.with = inst.check;
|
|
2672
|
-
inst.clone = (def, params) => clone(inst, def, params);
|
|
2673
|
-
inst.brand = () => inst;
|
|
2674
|
-
inst.register = ((reg, meta) => {
|
|
2675
|
-
reg.add(inst, meta);
|
|
2676
|
-
return inst;
|
|
2677
|
-
});
|
|
2678
|
-
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
2679
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
2680
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
2681
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
2682
|
-
inst.spa = inst.safeParseAsync;
|
|
2683
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
2684
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
2685
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
2686
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
2687
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
2688
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
2689
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
2690
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
2691
|
-
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
2692
|
-
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
2693
|
-
inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
|
|
2694
|
-
inst.optional = () => optional(inst);
|
|
2695
|
-
inst.exactOptional = () => exactOptional(inst);
|
|
2696
|
-
inst.nullable = () => nullable(inst);
|
|
2697
|
-
inst.nullish = () => optional(nullable(inst));
|
|
2698
|
-
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
2699
|
-
inst.array = () => array(inst);
|
|
2700
|
-
inst.or = (arg) => union([inst, arg]);
|
|
2701
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
2702
|
-
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
2703
|
-
inst.default = (def) => _default(inst, def);
|
|
2704
|
-
inst.prefault = (def) => prefault(inst, def);
|
|
2705
|
-
inst.catch = (params) => _catch(inst, params);
|
|
2706
|
-
inst.pipe = (target) => pipe(inst, target);
|
|
2707
|
-
inst.readonly = () => readonly(inst);
|
|
2708
|
-
inst.describe = (description) => {
|
|
2709
|
-
const cl = inst.clone();
|
|
2710
|
-
globalRegistry.add(cl, { description });
|
|
2711
|
-
return cl;
|
|
2712
|
-
};
|
|
2713
|
-
Object.defineProperty(inst, "description", {
|
|
2714
|
-
get() {
|
|
2715
|
-
return globalRegistry.get(inst)?.description;
|
|
2716
|
-
},
|
|
2717
|
-
configurable: true
|
|
2718
|
-
});
|
|
2719
|
-
inst.meta = (...args) => {
|
|
2720
|
-
if (args.length === 0) return globalRegistry.get(inst);
|
|
2721
|
-
const cl = inst.clone();
|
|
2722
|
-
globalRegistry.add(cl, args[0]);
|
|
2723
|
-
return cl;
|
|
2724
|
-
};
|
|
2725
|
-
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
2726
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
2727
|
-
inst.apply = (fn) => fn(inst);
|
|
2728
|
-
return inst;
|
|
2729
|
-
});
|
|
2730
|
-
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
2731
|
-
$ZodNumber.init(inst, def);
|
|
2732
|
-
ZodType.init(inst, def);
|
|
2733
|
-
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
2734
|
-
inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
|
|
2735
|
-
inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
|
|
2736
|
-
inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
|
|
2737
|
-
inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
|
|
2738
|
-
inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
|
|
2739
|
-
inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
|
|
2740
|
-
inst.int = (params) => inst.check(int(params));
|
|
2741
|
-
inst.safe = (params) => inst.check(int(params));
|
|
2742
|
-
inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(0, params));
|
|
2743
|
-
inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(0, params));
|
|
2744
|
-
inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(0, params));
|
|
2745
|
-
inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(0, params));
|
|
2746
|
-
inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
2747
|
-
inst.step = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
2748
|
-
inst.finite = () => inst;
|
|
2749
|
-
const bag = inst._zod.bag;
|
|
2750
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
2751
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
2752
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
2753
|
-
inst.isFinite = true;
|
|
2754
|
-
inst.format = bag.format ?? null;
|
|
2755
|
-
});
|
|
2756
|
-
function number(params) {
|
|
2757
|
-
return /* @__PURE__ */ _number(ZodNumber, params);
|
|
2758
|
-
}
|
|
2759
|
-
const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
2760
|
-
$ZodNumberFormat.init(inst, def);
|
|
2761
|
-
ZodNumber.init(inst, def);
|
|
2762
|
-
});
|
|
2763
|
-
function int(params) {
|
|
2764
|
-
return /* @__PURE__ */ _int(ZodNumberFormat, params);
|
|
2765
|
-
}
|
|
2766
|
-
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
2767
|
-
$ZodUnknown.init(inst, def);
|
|
2768
|
-
ZodType.init(inst, def);
|
|
2769
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
2770
|
-
});
|
|
2771
|
-
function unknown() {
|
|
2772
|
-
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
2773
|
-
}
|
|
2774
|
-
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
2775
|
-
$ZodNever.init(inst, def);
|
|
2776
|
-
ZodType.init(inst, def);
|
|
2777
|
-
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
2778
|
-
});
|
|
2779
|
-
function never(params) {
|
|
2780
|
-
return /* @__PURE__ */ _never(ZodNever, params);
|
|
2781
|
-
}
|
|
2782
|
-
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
2783
|
-
$ZodArray.init(inst, def);
|
|
2784
|
-
ZodType.init(inst, def);
|
|
2785
|
-
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
2786
|
-
inst.element = def.element;
|
|
2787
|
-
inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
|
|
2788
|
-
inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
|
|
2789
|
-
inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
|
|
2790
|
-
inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
|
|
2791
|
-
inst.unwrap = () => inst.element;
|
|
2792
|
-
});
|
|
2793
|
-
function array(element, params) {
|
|
2794
|
-
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
2795
|
-
}
|
|
2796
|
-
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
2797
|
-
$ZodObjectJIT.init(inst, def);
|
|
2798
|
-
ZodType.init(inst, def);
|
|
2799
|
-
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
2800
|
-
defineLazy(inst, "shape", () => {
|
|
2801
|
-
return def.shape;
|
|
2802
|
-
});
|
|
2803
|
-
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
2804
|
-
inst.catchall = (catchall) => inst.clone({
|
|
2805
|
-
...inst._zod.def,
|
|
2806
|
-
catchall
|
|
2807
|
-
});
|
|
2808
|
-
inst.passthrough = () => inst.clone({
|
|
2809
|
-
...inst._zod.def,
|
|
2810
|
-
catchall: unknown()
|
|
2811
|
-
});
|
|
2812
|
-
inst.loose = () => inst.clone({
|
|
2813
|
-
...inst._zod.def,
|
|
2814
|
-
catchall: unknown()
|
|
2815
|
-
});
|
|
2816
|
-
inst.strict = () => inst.clone({
|
|
2817
|
-
...inst._zod.def,
|
|
2818
|
-
catchall: never()
|
|
2819
|
-
});
|
|
2820
|
-
inst.strip = () => inst.clone({
|
|
2821
|
-
...inst._zod.def,
|
|
2822
|
-
catchall: void 0
|
|
2823
|
-
});
|
|
2824
|
-
inst.extend = (incoming) => {
|
|
2825
|
-
return extend(inst, incoming);
|
|
2826
|
-
};
|
|
2827
|
-
inst.safeExtend = (incoming) => {
|
|
2828
|
-
return safeExtend(inst, incoming);
|
|
2829
|
-
};
|
|
2830
|
-
inst.merge = (other) => merge(inst, other);
|
|
2831
|
-
inst.pick = (mask) => pick(inst, mask);
|
|
2832
|
-
inst.omit = (mask) => omit(inst, mask);
|
|
2833
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
2834
|
-
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
2835
|
-
});
|
|
2836
|
-
function object(shape, params) {
|
|
2837
|
-
return new ZodObject({
|
|
2838
|
-
type: "object",
|
|
2839
|
-
shape: shape ?? {},
|
|
2840
|
-
...normalizeParams(params)
|
|
2841
|
-
});
|
|
2842
|
-
}
|
|
2843
|
-
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
2844
|
-
$ZodUnion.init(inst, def);
|
|
2845
|
-
ZodType.init(inst, def);
|
|
2846
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
2847
|
-
inst.options = def.options;
|
|
2848
|
-
});
|
|
2849
|
-
function union(options, params) {
|
|
2850
|
-
return new ZodUnion({
|
|
2851
|
-
type: "union",
|
|
2852
|
-
options,
|
|
2853
|
-
...normalizeParams(params)
|
|
2854
|
-
});
|
|
2855
|
-
}
|
|
2856
|
-
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
2857
|
-
$ZodIntersection.init(inst, def);
|
|
2858
|
-
ZodType.init(inst, def);
|
|
2859
|
-
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
2860
|
-
});
|
|
2861
|
-
function intersection(left, right) {
|
|
2862
|
-
return new ZodIntersection({
|
|
2863
|
-
type: "intersection",
|
|
2864
|
-
left,
|
|
2865
|
-
right
|
|
2866
|
-
});
|
|
2867
|
-
}
|
|
2868
|
-
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
2869
|
-
$ZodEnum.init(inst, def);
|
|
2870
|
-
ZodType.init(inst, def);
|
|
2871
|
-
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
2872
|
-
inst.enum = def.entries;
|
|
2873
|
-
inst.options = Object.values(def.entries);
|
|
2874
|
-
const keys = new Set(Object.keys(def.entries));
|
|
2875
|
-
inst.extract = (values, params) => {
|
|
2876
|
-
const newEntries = {};
|
|
2877
|
-
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
2878
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
2879
|
-
return new ZodEnum({
|
|
2880
|
-
...def,
|
|
2881
|
-
checks: [],
|
|
2882
|
-
...normalizeParams(params),
|
|
2883
|
-
entries: newEntries
|
|
2884
|
-
});
|
|
2885
|
-
};
|
|
2886
|
-
inst.exclude = (values, params) => {
|
|
2887
|
-
const newEntries = { ...def.entries };
|
|
2888
|
-
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
2889
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
2890
|
-
return new ZodEnum({
|
|
2891
|
-
...def,
|
|
2892
|
-
checks: [],
|
|
2893
|
-
...normalizeParams(params),
|
|
2894
|
-
entries: newEntries
|
|
2895
|
-
});
|
|
2896
|
-
};
|
|
2897
|
-
});
|
|
2898
|
-
function _enum(values, params) {
|
|
2899
|
-
return new ZodEnum({
|
|
2900
|
-
type: "enum",
|
|
2901
|
-
entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
|
|
2902
|
-
...normalizeParams(params)
|
|
2903
|
-
});
|
|
2904
|
-
}
|
|
2905
|
-
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
2906
|
-
$ZodTransform.init(inst, def);
|
|
2907
|
-
ZodType.init(inst, def);
|
|
2908
|
-
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
2909
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2910
|
-
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
2911
|
-
payload.addIssue = (issue$1) => {
|
|
2912
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
2913
|
-
else {
|
|
2914
|
-
const _issue = issue$1;
|
|
2915
|
-
if (_issue.fatal) _issue.continue = false;
|
|
2916
|
-
_issue.code ?? (_issue.code = "custom");
|
|
2917
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
2918
|
-
_issue.inst ?? (_issue.inst = inst);
|
|
2919
|
-
payload.issues.push(issue(_issue));
|
|
2920
|
-
}
|
|
2921
|
-
};
|
|
2922
|
-
const output = def.transform(payload.value, payload);
|
|
2923
|
-
if (output instanceof Promise) return output.then((output) => {
|
|
2924
|
-
payload.value = output;
|
|
2925
|
-
return payload;
|
|
2926
|
-
});
|
|
2927
|
-
payload.value = output;
|
|
2928
|
-
return payload;
|
|
2929
|
-
};
|
|
2930
|
-
});
|
|
2931
|
-
function transform(fn) {
|
|
2932
|
-
return new ZodTransform({
|
|
2933
|
-
type: "transform",
|
|
2934
|
-
transform: fn
|
|
2935
|
-
});
|
|
2936
|
-
}
|
|
2937
|
-
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
2938
|
-
$ZodOptional.init(inst, def);
|
|
2939
|
-
ZodType.init(inst, def);
|
|
2940
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
2941
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2942
|
-
});
|
|
2943
|
-
function optional(innerType) {
|
|
2944
|
-
return new ZodOptional({
|
|
2945
|
-
type: "optional",
|
|
2946
|
-
innerType
|
|
2947
|
-
});
|
|
2948
|
-
}
|
|
2949
|
-
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
2950
|
-
$ZodExactOptional.init(inst, def);
|
|
2951
|
-
ZodType.init(inst, def);
|
|
2952
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
2953
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2954
|
-
});
|
|
2955
|
-
function exactOptional(innerType) {
|
|
2956
|
-
return new ZodExactOptional({
|
|
2957
|
-
type: "optional",
|
|
2958
|
-
innerType
|
|
2959
|
-
});
|
|
2960
|
-
}
|
|
2961
|
-
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
2962
|
-
$ZodNullable.init(inst, def);
|
|
2963
|
-
ZodType.init(inst, def);
|
|
2964
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
2965
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2966
|
-
});
|
|
2967
|
-
function nullable(innerType) {
|
|
2968
|
-
return new ZodNullable({
|
|
2969
|
-
type: "nullable",
|
|
2970
|
-
innerType
|
|
2971
|
-
});
|
|
2972
|
-
}
|
|
2973
|
-
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
2974
|
-
$ZodDefault.init(inst, def);
|
|
2975
|
-
ZodType.init(inst, def);
|
|
2976
|
-
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
2977
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2978
|
-
inst.removeDefault = inst.unwrap;
|
|
2979
|
-
});
|
|
2980
|
-
function _default(innerType, defaultValue) {
|
|
2981
|
-
return new ZodDefault({
|
|
2982
|
-
type: "default",
|
|
2983
|
-
innerType,
|
|
2984
|
-
get defaultValue() {
|
|
2985
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
2986
|
-
}
|
|
2987
|
-
});
|
|
2988
|
-
}
|
|
2989
|
-
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
2990
|
-
$ZodPrefault.init(inst, def);
|
|
2991
|
-
ZodType.init(inst, def);
|
|
2992
|
-
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
2993
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2994
|
-
});
|
|
2995
|
-
function prefault(innerType, defaultValue) {
|
|
2996
|
-
return new ZodPrefault({
|
|
2997
|
-
type: "prefault",
|
|
2998
|
-
innerType,
|
|
2999
|
-
get defaultValue() {
|
|
3000
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3001
|
-
}
|
|
3002
|
-
});
|
|
3003
|
-
}
|
|
3004
|
-
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
3005
|
-
$ZodNonOptional.init(inst, def);
|
|
3006
|
-
ZodType.init(inst, def);
|
|
3007
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
3008
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3009
|
-
});
|
|
3010
|
-
function nonoptional(innerType, params) {
|
|
3011
|
-
return new ZodNonOptional({
|
|
3012
|
-
type: "nonoptional",
|
|
3013
|
-
innerType,
|
|
3014
|
-
...normalizeParams(params)
|
|
3015
|
-
});
|
|
3016
|
-
}
|
|
3017
|
-
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
3018
|
-
$ZodCatch.init(inst, def);
|
|
3019
|
-
ZodType.init(inst, def);
|
|
3020
|
-
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
3021
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3022
|
-
inst.removeCatch = inst.unwrap;
|
|
3023
|
-
});
|
|
3024
|
-
function _catch(innerType, catchValue) {
|
|
3025
|
-
return new ZodCatch({
|
|
3026
|
-
type: "catch",
|
|
3027
|
-
innerType,
|
|
3028
|
-
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
3029
|
-
});
|
|
3030
|
-
}
|
|
3031
|
-
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
3032
|
-
$ZodPipe.init(inst, def);
|
|
3033
|
-
ZodType.init(inst, def);
|
|
3034
|
-
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
3035
|
-
inst.in = def.in;
|
|
3036
|
-
inst.out = def.out;
|
|
3037
|
-
});
|
|
3038
|
-
function pipe(in_, out) {
|
|
3039
|
-
return new ZodPipe({
|
|
3040
|
-
type: "pipe",
|
|
3041
|
-
in: in_,
|
|
3042
|
-
out
|
|
3043
|
-
});
|
|
3044
|
-
}
|
|
3045
|
-
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3046
|
-
$ZodReadonly.init(inst, def);
|
|
3047
|
-
ZodType.init(inst, def);
|
|
3048
|
-
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
3049
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
3050
|
-
});
|
|
3051
|
-
function readonly(innerType) {
|
|
3052
|
-
return new ZodReadonly({
|
|
3053
|
-
type: "readonly",
|
|
3054
|
-
innerType
|
|
3055
|
-
});
|
|
3056
|
-
}
|
|
3057
|
-
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
3058
|
-
$ZodCustom.init(inst, def);
|
|
3059
|
-
ZodType.init(inst, def);
|
|
3060
|
-
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
3061
|
-
});
|
|
3062
|
-
function refine(fn, _params = {}) {
|
|
3063
|
-
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
3064
|
-
}
|
|
3065
|
-
function superRefine(fn) {
|
|
3066
|
-
return /* @__PURE__ */ _superRefine(fn);
|
|
3067
|
-
}
|
|
3068
|
-
enumValues({
|
|
3069
|
-
Active: "active",
|
|
3070
|
-
PastDue: "past_due",
|
|
3071
|
-
Canceled: "canceled",
|
|
3072
|
-
Incomplete: "incomplete"
|
|
3073
|
-
});
|
|
3074
|
-
enumValues({
|
|
3075
|
-
Anthropic: "anthropic",
|
|
3076
|
-
OpenAI: "openai",
|
|
3077
|
-
ElevenLabs: "elevenlabs"
|
|
3078
|
-
});
|
|
3079
|
-
enumValues({
|
|
3080
|
-
Month: "month",
|
|
3081
|
-
Year: "year"
|
|
3082
|
-
});
|
|
3083
|
-
object({ gracePeriodDays: number().int().positive().optional() });
|
|
3084
|
-
enumValues({
|
|
3085
|
-
Active: "active",
|
|
3086
|
-
Pending: "pending",
|
|
3087
|
-
Provisioning: "provisioning",
|
|
3088
|
-
Starting: "starting",
|
|
3089
|
-
Running: "running",
|
|
3090
|
-
Stopping: "stopping",
|
|
3091
|
-
Stopped: "stopped",
|
|
3092
|
-
Rebooting: "rebooting",
|
|
3093
|
-
Failing: "failing",
|
|
3094
|
-
Failed: "failed",
|
|
3095
|
-
BillingSuspended: "billing_suspended",
|
|
3096
|
-
Deleted: "deleted"
|
|
3097
|
-
});
|
|
3098
|
-
enumValues({
|
|
3099
|
-
SelfHosted: "self-hosted",
|
|
3100
|
-
Managed: "managed"
|
|
3101
|
-
});
|
|
3102
|
-
enumValues({
|
|
3103
|
-
OpenClaw: "openclaw",
|
|
3104
|
-
NanoClaw: "nanoclaw"
|
|
3105
|
-
});
|
|
3106
|
-
enumValues({
|
|
3107
|
-
Active: "active",
|
|
3108
|
-
Removed: "removed"
|
|
3109
|
-
});
|
|
3110
|
-
enumValues({
|
|
3111
|
-
Installing: "installing",
|
|
3112
|
-
Active: "active",
|
|
3113
|
-
Error: "error",
|
|
3114
|
-
Removing: "removing",
|
|
3115
|
-
Inactive: "inactive",
|
|
3116
|
-
Unknown: "unknown"
|
|
3117
|
-
});
|
|
3118
|
-
enumValues({
|
|
3119
|
-
Active: "active",
|
|
3120
|
-
Depleted: "depleted",
|
|
3121
|
-
Paused: "paused"
|
|
3122
|
-
});
|
|
3123
|
-
enumValues({
|
|
3124
|
-
Usage: "usage",
|
|
3125
|
-
TopUp: "top_up",
|
|
3126
|
-
SubscriptionCredit: "subscription_credit",
|
|
3127
|
-
AutoRecharge: "auto_recharge",
|
|
3128
|
-
AdminGift: "admin_gift",
|
|
3129
|
-
ReferralCredit: "referral_credit",
|
|
3130
|
-
PromoCredit: "promo_credit",
|
|
3131
|
-
Refund: "refund"
|
|
3132
|
-
});
|
|
3133
|
-
enumValues({
|
|
3134
|
-
Pending: "pending",
|
|
3135
|
-
Completed: "completed",
|
|
3136
|
-
Failed: "failed"
|
|
3137
|
-
});
|
|
3138
|
-
enumValues({
|
|
3139
|
-
Hour: "hour",
|
|
3140
|
-
Day: "day",
|
|
3141
|
-
Week: "week",
|
|
3142
|
-
Month: "month"
|
|
3143
|
-
});
|
|
3144
|
-
enumValues({
|
|
3145
|
-
Active: "active",
|
|
3146
|
-
Paused: "paused",
|
|
3147
|
-
Revoked: "revoked"
|
|
3148
|
-
});
|
|
3149
|
-
enumValues({
|
|
3150
|
-
Pending: "pending",
|
|
3151
|
-
Completed: "completed",
|
|
3152
|
-
Failed: "failed"
|
|
3153
|
-
});
|
|
3154
|
-
enumValues({
|
|
3155
|
-
BalanceCredit: "balance_credit",
|
|
3156
|
-
SubscriptionDiscount: "subscription_discount",
|
|
3157
|
-
FreeTrial: "free_trial"
|
|
3158
|
-
});
|
|
3159
|
-
enumValues({
|
|
3160
|
-
Active: "active",
|
|
3161
|
-
Paused: "paused",
|
|
3162
|
-
Revoked: "revoked"
|
|
3163
|
-
});
|
|
3164
|
-
enumValues({
|
|
3165
|
-
Pending: "pending",
|
|
3166
|
-
Completed: "completed",
|
|
3167
|
-
Failed: "failed"
|
|
3168
|
-
});
|
|
3169
|
-
enumValues({
|
|
3170
|
-
Pending: "pending",
|
|
3171
|
-
Consumed: "consumed",
|
|
3172
|
-
Expired: "expired"
|
|
3173
|
-
});
|
|
3174
|
-
enumValues({
|
|
3175
|
-
Synced: "synced",
|
|
3176
|
-
Stale: "stale",
|
|
3177
|
-
Error: "error"
|
|
3178
|
-
});
|
|
3179
|
-
enumValues({
|
|
3180
|
-
Standard: "STANDARD",
|
|
3181
|
-
GlacierIR: "GLACIER_IR"
|
|
3182
|
-
});
|
|
3183
|
-
enumValues({
|
|
3184
|
-
Push: "push",
|
|
3185
|
-
Pull: "pull",
|
|
3186
|
-
Delete: "delete",
|
|
3187
|
-
Restore: "restore"
|
|
3188
|
-
});
|
|
3189
|
-
enumValues({
|
|
3190
|
-
Success: "success",
|
|
3191
|
-
Error: "error"
|
|
3192
|
-
});
|
|
3193
|
-
enumValues({
|
|
3194
|
-
User: "user",
|
|
3195
|
-
Agent: "agent",
|
|
3196
|
-
Support: "support"
|
|
3197
|
-
});
|
|
3198
|
-
enumValues({
|
|
3199
|
-
Dev: "dev",
|
|
3200
|
-
Test: "test",
|
|
3201
|
-
Live: "live"
|
|
3202
|
-
});
|
|
3203
|
-
//#endregion
|
|
3204
|
-
//#region ../../packages-internal/types/dist/models.js
|
|
3205
|
-
const AnthropicModel = {
|
|
3206
|
-
Opus: "claude-opus-4-6",
|
|
3207
|
-
Sonnet: "claude-sonnet-4-6",
|
|
3208
|
-
Haiku: "claude-haiku-4-5"
|
|
3209
|
-
};
|
|
3210
|
-
const ANTHROPIC_MODELS = enumValues(AnthropicModel);
|
|
3211
|
-
const OpenAIModel = {
|
|
3212
|
-
GPT4o: "gpt-4o",
|
|
3213
|
-
GPT4oMini: "gpt-4o-mini",
|
|
3214
|
-
O3: "o3"
|
|
3215
|
-
};
|
|
3216
|
-
const OPENAI_MODELS = enumValues(OpenAIModel);
|
|
3217
|
-
[...ANTHROPIC_MODELS, ...OPENAI_MODELS];
|
|
3218
|
-
_enum(ANTHROPIC_MODELS);
|
|
3219
|
-
_enum(OPENAI_MODELS);
|
|
3220
|
-
_enum([...ANTHROPIC_MODELS, ...OPENAI_MODELS]);
|
|
3221
|
-
AnthropicModel.Opus, AnthropicModel.Sonnet, AnthropicModel.Haiku, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3;
|
|
3222
|
-
AnthropicModel.Opus, AnthropicModel.Sonnet, AnthropicModel.Haiku, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3;
|
|
3223
|
-
enumValues({
|
|
3224
|
-
PendingChallenge: "pending_challenge",
|
|
3225
|
-
Creating: "creating",
|
|
3226
|
-
Complete: "complete",
|
|
3227
|
-
Failed: "failed",
|
|
3228
|
-
Expired: "expired"
|
|
3229
|
-
});
|
|
3230
|
-
enumValues({
|
|
3231
|
-
Active: "active",
|
|
3232
|
-
Used: "used",
|
|
3233
|
-
Expired: "expired",
|
|
3234
|
-
Revoked: "revoked"
|
|
3235
|
-
});
|
|
3236
|
-
enumValues({
|
|
3237
|
-
Pending: "pending",
|
|
3238
|
-
Claimed: "claimed",
|
|
3239
|
-
Expired: "expired"
|
|
3240
|
-
});
|
|
3241
|
-
enumValues({
|
|
3242
|
-
Mcp: "mcp",
|
|
3243
|
-
Api: "api",
|
|
3244
|
-
Cli: "cli",
|
|
3245
|
-
Dashboard: "dashboard",
|
|
3246
|
-
Agent: "agent"
|
|
3247
|
-
});
|
|
3248
|
-
//#endregion
|
|
3249
9
|
//#region src/types.ts
|
|
3250
10
|
function isIPCRequest(msg) {
|
|
3251
11
|
return typeof msg === "object" && msg !== null && msg.type === "req" && typeof msg.id === "string" && typeof msg.method === "string";
|
|
@@ -3544,7 +304,6 @@ async function registerWithDaemon(client, log) {
|
|
|
3544
304
|
*/
|
|
3545
305
|
const DEFAULT_SOCKET_PATH = join(homedir(), ".alfe", "gateway.sock");
|
|
3546
306
|
let ipcClient = null;
|
|
3547
|
-
let pluginAgentId = "";
|
|
3548
307
|
function ok(result) {
|
|
3549
308
|
return { content: [{
|
|
3550
309
|
type: "text",
|
|
@@ -3572,17 +331,13 @@ function defineTool(def) {
|
|
|
3572
331
|
}
|
|
3573
332
|
};
|
|
3574
333
|
}
|
|
3575
|
-
function buildIntegrationTools(
|
|
334
|
+
function buildIntegrationTools(client) {
|
|
3576
335
|
return [
|
|
3577
336
|
defineTool({
|
|
3578
337
|
name: "list_integrations",
|
|
3579
338
|
description: "List all integrations installed for this agent, including their status and available config fields.",
|
|
3580
339
|
parameters: Type.Object({}),
|
|
3581
|
-
handler: async () =>
|
|
3582
|
-
const result = await svc.listIntegrations(pluginAgentId);
|
|
3583
|
-
if (!result.ok) throw new Error(result.error);
|
|
3584
|
-
return result.data;
|
|
3585
|
-
}
|
|
340
|
+
handler: async () => client.listIntegrations()
|
|
3586
341
|
}),
|
|
3587
342
|
defineTool({
|
|
3588
343
|
name: "get_integration_config",
|
|
@@ -3590,9 +345,7 @@ function buildIntegrationTools(svc) {
|
|
|
3590
345
|
parameters: Type.Object({ integrationId: Type.String({ description: "The integration to inspect (e.g. \"voice\", \"slack\")" }) }),
|
|
3591
346
|
handler: async (params) => {
|
|
3592
347
|
const integrationId = params.integrationId;
|
|
3593
|
-
|
|
3594
|
-
if (!result.ok) throw new Error(result.error);
|
|
3595
|
-
return result.data;
|
|
348
|
+
return client.getIntegrationConfig(integrationId);
|
|
3596
349
|
}
|
|
3597
350
|
}),
|
|
3598
351
|
defineTool({
|
|
@@ -3605,10 +358,41 @@ function buildIntegrationTools(svc) {
|
|
|
3605
358
|
handler: async (params) => {
|
|
3606
359
|
const integrationId = params.integrationId;
|
|
3607
360
|
const fields = params.fields;
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
361
|
+
return client.updateIntegrationConfig(integrationId, fields);
|
|
362
|
+
}
|
|
363
|
+
}),
|
|
364
|
+
defineTool({
|
|
365
|
+
name: "install_integration",
|
|
366
|
+
description: "Install an integration from the registry. Returns the newly created integration record.",
|
|
367
|
+
parameters: Type.Object({
|
|
368
|
+
integrationId: Type.String({ description: "The integration to install (e.g. \"voice\", \"slack\", \"discord\")" }),
|
|
369
|
+
version: Type.Optional(Type.String({ description: "Specific version to install (defaults to latest)" })),
|
|
370
|
+
config: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Initial configuration key-value pairs" }))
|
|
371
|
+
}),
|
|
372
|
+
handler: async (params) => {
|
|
373
|
+
const integrationId = params.integrationId;
|
|
374
|
+
const version = params.version;
|
|
375
|
+
const config = params.config;
|
|
376
|
+
return client.installIntegration(integrationId, {
|
|
377
|
+
version,
|
|
378
|
+
config
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}),
|
|
382
|
+
defineTool({
|
|
383
|
+
name: "remove_integration",
|
|
384
|
+
description: "Remove an installed integration. The daemon will handle teardown during reconciliation.",
|
|
385
|
+
parameters: Type.Object({ integrationId: Type.String({ description: "The integration to remove" }) }),
|
|
386
|
+
handler: async (params) => {
|
|
387
|
+
const integrationId = params.integrationId;
|
|
388
|
+
return client.removeIntegration(integrationId);
|
|
3611
389
|
}
|
|
390
|
+
}),
|
|
391
|
+
defineTool({
|
|
392
|
+
name: "browse_integration_registry",
|
|
393
|
+
description: "Browse available integrations in the registry. Shows all integrations that can be installed.",
|
|
394
|
+
parameters: Type.Object({}),
|
|
395
|
+
handler: async () => client.getRegistry()
|
|
3612
396
|
})
|
|
3613
397
|
];
|
|
3614
398
|
}
|
|
@@ -3620,19 +404,18 @@ const plugin = {
|
|
|
3620
404
|
activate(api) {
|
|
3621
405
|
const log = api.logger;
|
|
3622
406
|
log.info("Alfe OpenClaw Plugin activating...");
|
|
3623
|
-
const
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
apiBaseUrl: apiUrl,
|
|
3631
|
-
getToken: () => Promise.resolve(apiKey)
|
|
3632
|
-
})));
|
|
407
|
+
const socketPath = ((api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw"]?.config ?? {}).socketPath ?? process.env.ALFE_GATEWAY_SOCKET ?? DEFAULT_SOCKET_PATH;
|
|
408
|
+
resolveConfig().then(async (cfg) => {
|
|
409
|
+
const { AgentApiClient } = await import("@alfe.ai/agent-api-client");
|
|
410
|
+
const tools = buildIntegrationTools(new AgentApiClient({
|
|
411
|
+
apiKey: cfg.apiKey,
|
|
412
|
+
apiUrl: cfg.apiUrl
|
|
413
|
+
}));
|
|
3633
414
|
for (const tool of tools) api.registerTool(tool);
|
|
3634
415
|
log.info(`Registered ${String(tools.length)} integration tools: ${tools.map((t) => t.name).join(", ")}`);
|
|
3635
|
-
}
|
|
416
|
+
}).catch((err) => {
|
|
417
|
+
log.warn(`Integration tools not registered — config not available: ${err.message}`);
|
|
418
|
+
});
|
|
3636
419
|
ipcClient = new IPCClient(socketPath);
|
|
3637
420
|
ipcClient.on("event", (event, payload) => {
|
|
3638
421
|
switch (event) {
|
|
@@ -3684,4 +467,4 @@ const plugin = {
|
|
|
3684
467
|
}
|
|
3685
468
|
};
|
|
3686
469
|
//#endregion
|
|
3687
|
-
export { isIPCEvent as a,
|
|
470
|
+
export { isIPCEvent as a, PROTOCOL_VERSION as i, registerWithDaemon as n, isIPCRequest as o, IPCClient as r, isIPCResponse as s, plugin as t };
|