@cremini/skillpack 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -45
- package/dist/cli.js +3221 -192
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,82 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/runtime/adapters/attachment-utils.ts
|
|
13
|
+
import fs5 from "fs";
|
|
14
|
+
import path5 from "path";
|
|
15
|
+
import { pipeline } from "stream/promises";
|
|
16
|
+
import { Readable } from "stream";
|
|
17
|
+
function getAttachmentDir(rootDir, channelId) {
|
|
18
|
+
return path5.resolve(rootDir, "data", "sessions", channelId, ATTACHMENTS_DIR);
|
|
19
|
+
}
|
|
20
|
+
function sanitizeFilename(name) {
|
|
21
|
+
return name.replace(/[/\\:*?"<>|]/g, "_").replace(/\s+/g, "_");
|
|
22
|
+
}
|
|
23
|
+
async function downloadAndSaveAttachment(rootDir, channelId, url, filename, mimeType, headers) {
|
|
24
|
+
const dir = getAttachmentDir(rootDir, channelId);
|
|
25
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
26
|
+
const ts = Date.now();
|
|
27
|
+
const safeName = sanitizeFilename(filename);
|
|
28
|
+
const storedName = `${ts}-${safeName}`;
|
|
29
|
+
const fullPath = path5.join(dir, storedName);
|
|
30
|
+
const response = await fetch(url, { headers });
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Failed to download attachment from ${url}: ${response.status} ${response.statusText}`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const body = response.body;
|
|
37
|
+
if (!body) {
|
|
38
|
+
throw new Error(`Empty response body when downloading ${url}`);
|
|
39
|
+
}
|
|
40
|
+
const nodeStream = Readable.fromWeb(body);
|
|
41
|
+
const writeStream = fs5.createWriteStream(fullPath);
|
|
42
|
+
await pipeline(nodeStream, writeStream);
|
|
43
|
+
const stats = fs5.statSync(fullPath);
|
|
44
|
+
const detectedMime = mimeType || response.headers.get("content-type")?.split(";")[0] || void 0;
|
|
45
|
+
return {
|
|
46
|
+
filename,
|
|
47
|
+
localPath: fullPath,
|
|
48
|
+
mimeType: detectedMime,
|
|
49
|
+
size: stats.size
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function isImageMime(mimeType) {
|
|
53
|
+
return !!mimeType && mimeType.startsWith("image/");
|
|
54
|
+
}
|
|
55
|
+
function formatSize(bytes) {
|
|
56
|
+
if (bytes === void 0 || bytes === null) return "";
|
|
57
|
+
if (bytes < 1024) return `${bytes}B`;
|
|
58
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
|
|
59
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
60
|
+
}
|
|
61
|
+
function formatAttachmentsPrompt(attachments) {
|
|
62
|
+
if (attachments.length === 0) return "";
|
|
63
|
+
const lines = attachments.map((a) => {
|
|
64
|
+
const meta = [a.mimeType, formatSize(a.size)].filter(Boolean).join(", ");
|
|
65
|
+
return `- ${a.filename} (${meta}) \u2192 ${a.localPath}`;
|
|
66
|
+
});
|
|
67
|
+
return `[Attachments]
|
|
68
|
+
${lines.join("\n")}`;
|
|
69
|
+
}
|
|
70
|
+
function attachmentsToImageContent(attachments) {
|
|
71
|
+
return attachments.filter((a) => isImageMime(a.mimeType)).map((a) => {
|
|
72
|
+
const buffer = fs5.readFileSync(a.localPath);
|
|
73
|
+
return {
|
|
74
|
+
type: "image",
|
|
75
|
+
data: buffer.toString("base64"),
|
|
76
|
+
mimeType: a.mimeType || "image/png"
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
var ATTACHMENTS_DIR;
|
|
81
|
+
var init_attachment_utils = __esm({
|
|
82
|
+
"src/runtime/adapters/attachment-utils.ts"() {
|
|
83
|
+
"use strict";
|
|
84
|
+
ATTACHMENTS_DIR = "attachments";
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
12
88
|
// src/runtime/adapters/markdown.ts
|
|
13
89
|
function unwrapMarkdownSourceBlocks(text) {
|
|
14
90
|
return text.replace(
|
|
@@ -128,12 +204,14 @@ var telegram_exports = {};
|
|
|
128
204
|
__export(telegram_exports, {
|
|
129
205
|
TelegramAdapter: () => TelegramAdapter
|
|
130
206
|
});
|
|
207
|
+
import fs10 from "fs";
|
|
131
208
|
import TelegramBot from "node-telegram-bot-api";
|
|
132
209
|
var COMMANDS2, MAX_MESSAGE_LENGTH, ACK_REACTION, TelegramAdapter;
|
|
133
210
|
var init_telegram = __esm({
|
|
134
211
|
"src/runtime/adapters/telegram.ts"() {
|
|
135
212
|
"use strict";
|
|
136
213
|
init_markdown();
|
|
214
|
+
init_attachment_utils();
|
|
137
215
|
COMMANDS2 = {
|
|
138
216
|
"/clear": "clear",
|
|
139
217
|
"/restart": "restart",
|
|
@@ -149,11 +227,13 @@ var init_telegram = __esm({
|
|
|
149
227
|
bot = null;
|
|
150
228
|
agent = null;
|
|
151
229
|
options;
|
|
230
|
+
rootDir = "";
|
|
152
231
|
constructor(options) {
|
|
153
232
|
this.options = options;
|
|
154
233
|
}
|
|
155
234
|
async start(ctx) {
|
|
156
235
|
this.agent = ctx.agent;
|
|
236
|
+
this.rootDir = ctx.rootDir;
|
|
157
237
|
this.bot = new TelegramBot(this.options.token, { polling: true });
|
|
158
238
|
this.bot.on("message", (msg) => {
|
|
159
239
|
this.handleTelegramMessage(msg).catch((err) => {
|
|
@@ -182,30 +262,46 @@ var init_telegram = __esm({
|
|
|
182
262
|
if (!this.bot || !this.agent) return;
|
|
183
263
|
const chatId = msg.chat.id;
|
|
184
264
|
const messageId = msg.message_id;
|
|
185
|
-
const text = msg.text
|
|
186
|
-
if (!text) return;
|
|
265
|
+
const text = (msg.text || msg.caption || "").trim();
|
|
187
266
|
const channelId = `telegram-${chatId}`;
|
|
267
|
+
const attachments = await this.extractAttachments(msg, channelId);
|
|
268
|
+
if (!text && attachments.length === 0) return;
|
|
188
269
|
await this.tryAckReaction(chatId, messageId);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
270
|
+
if (text) {
|
|
271
|
+
const commandKey = text.split(/\s/)[0].toLowerCase();
|
|
272
|
+
const command = COMMANDS2[commandKey];
|
|
273
|
+
if (command) {
|
|
274
|
+
const result = await this.agent.handleCommand(command, channelId);
|
|
275
|
+
await this.sendSafe(chatId, result.message || `/${command} executed.`);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
195
278
|
}
|
|
196
279
|
await this.bot.sendChatAction(chatId, "typing");
|
|
197
280
|
let finalText = "";
|
|
198
281
|
let hasError = false;
|
|
199
282
|
let errorMessage = "";
|
|
283
|
+
const pendingFiles = [];
|
|
200
284
|
const onEvent = (event) => {
|
|
201
285
|
switch (event.type) {
|
|
202
286
|
case "text_delta":
|
|
203
287
|
finalText += event.delta;
|
|
204
288
|
break;
|
|
289
|
+
case "file_output":
|
|
290
|
+
pendingFiles.push({
|
|
291
|
+
filePath: event.filePath,
|
|
292
|
+
caption: event.caption
|
|
293
|
+
});
|
|
294
|
+
break;
|
|
205
295
|
}
|
|
206
296
|
};
|
|
207
297
|
try {
|
|
208
|
-
const
|
|
298
|
+
const userText = text || "(User sent an attachment)";
|
|
299
|
+
const result = await this.agent.handleMessage(
|
|
300
|
+
channelId,
|
|
301
|
+
userText,
|
|
302
|
+
onEvent,
|
|
303
|
+
attachments.length > 0 ? attachments : void 0
|
|
304
|
+
);
|
|
209
305
|
if (result.errorMessage) {
|
|
210
306
|
hasError = true;
|
|
211
307
|
errorMessage = result.errorMessage;
|
|
@@ -218,11 +314,14 @@ var init_telegram = __esm({
|
|
|
218
314
|
await this.sendSafe(chatId, `\u274C Error: ${errorMessage}`);
|
|
219
315
|
return;
|
|
220
316
|
}
|
|
221
|
-
if (
|
|
317
|
+
if (finalText.trim()) {
|
|
318
|
+
await this.sendLongMessage(chatId, finalText);
|
|
319
|
+
} else if (pendingFiles.length === 0) {
|
|
222
320
|
await this.sendSafe(chatId, "(No response generated)");
|
|
223
|
-
return;
|
|
224
321
|
}
|
|
225
|
-
|
|
322
|
+
for (const file of pendingFiles) {
|
|
323
|
+
await this.sendFileSafe(chatId, file.filePath, file.caption);
|
|
324
|
+
}
|
|
226
325
|
}
|
|
227
326
|
// -------------------------------------------------------------------------
|
|
228
327
|
// Send helpers
|
|
@@ -314,6 +413,103 @@ var init_telegram = __esm({
|
|
|
314
413
|
console.error("[Telegram] Failed to send message:", err);
|
|
315
414
|
}
|
|
316
415
|
}
|
|
416
|
+
// -------------------------------------------------------------------------
|
|
417
|
+
// Attachment extraction
|
|
418
|
+
// -------------------------------------------------------------------------
|
|
419
|
+
/**
|
|
420
|
+
* Extract attachments from a Telegram message (photo, document, audio, video, voice).
|
|
421
|
+
*/
|
|
422
|
+
async extractAttachments(msg, channelId) {
|
|
423
|
+
if (!this.bot) return [];
|
|
424
|
+
const attachments = [];
|
|
425
|
+
try {
|
|
426
|
+
if (msg.photo && msg.photo.length > 0) {
|
|
427
|
+
const photo = msg.photo[msg.photo.length - 1];
|
|
428
|
+
const attachment = await this.downloadTelegramFile(
|
|
429
|
+
photo.file_id,
|
|
430
|
+
channelId,
|
|
431
|
+
"photo.jpg",
|
|
432
|
+
"image/jpeg"
|
|
433
|
+
);
|
|
434
|
+
if (attachment) attachments.push(attachment);
|
|
435
|
+
}
|
|
436
|
+
if (msg.document) {
|
|
437
|
+
const attachment = await this.downloadTelegramFile(
|
|
438
|
+
msg.document.file_id,
|
|
439
|
+
channelId,
|
|
440
|
+
msg.document.file_name || "document",
|
|
441
|
+
msg.document.mime_type
|
|
442
|
+
);
|
|
443
|
+
if (attachment) attachments.push(attachment);
|
|
444
|
+
}
|
|
445
|
+
if (msg.audio) {
|
|
446
|
+
const attachment = await this.downloadTelegramFile(
|
|
447
|
+
msg.audio.file_id,
|
|
448
|
+
channelId,
|
|
449
|
+
msg.audio.file_name || "audio.mp3",
|
|
450
|
+
msg.audio.mime_type
|
|
451
|
+
);
|
|
452
|
+
if (attachment) attachments.push(attachment);
|
|
453
|
+
}
|
|
454
|
+
if (msg.video) {
|
|
455
|
+
const attachment = await this.downloadTelegramFile(
|
|
456
|
+
msg.video.file_id,
|
|
457
|
+
channelId,
|
|
458
|
+
msg.video.file_name || "video.mp4",
|
|
459
|
+
msg.video.mime_type
|
|
460
|
+
);
|
|
461
|
+
if (attachment) attachments.push(attachment);
|
|
462
|
+
}
|
|
463
|
+
if (msg.voice) {
|
|
464
|
+
const attachment = await this.downloadTelegramFile(
|
|
465
|
+
msg.voice.file_id,
|
|
466
|
+
channelId,
|
|
467
|
+
"voice.ogg",
|
|
468
|
+
msg.voice.mime_type || "audio/ogg"
|
|
469
|
+
);
|
|
470
|
+
if (attachment) attachments.push(attachment);
|
|
471
|
+
}
|
|
472
|
+
} catch (err) {
|
|
473
|
+
console.error("[Telegram] Error extracting attachments:", err);
|
|
474
|
+
}
|
|
475
|
+
return attachments;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Download a file from Telegram and save it locally.
|
|
479
|
+
*/
|
|
480
|
+
async downloadTelegramFile(fileId, channelId, filename, mimeType) {
|
|
481
|
+
if (!this.bot) return null;
|
|
482
|
+
try {
|
|
483
|
+
const fileLink = await this.bot.getFileLink(fileId);
|
|
484
|
+
return await downloadAndSaveAttachment(
|
|
485
|
+
this.rootDir,
|
|
486
|
+
channelId,
|
|
487
|
+
fileLink,
|
|
488
|
+
filename,
|
|
489
|
+
mimeType
|
|
490
|
+
);
|
|
491
|
+
} catch (err) {
|
|
492
|
+
console.error(`[Telegram] Failed to download file ${fileId}:`, err);
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Send a file to the Telegram chat.
|
|
498
|
+
*/
|
|
499
|
+
async sendFileSafe(chatId, filePath, caption) {
|
|
500
|
+
if (!this.bot) return;
|
|
501
|
+
try {
|
|
502
|
+
if (!fs10.existsSync(filePath)) {
|
|
503
|
+
console.error(`[Telegram] File not found for sending: ${filePath}`);
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
await this.bot.sendDocument(chatId, filePath, {
|
|
507
|
+
caption: caption || void 0
|
|
508
|
+
});
|
|
509
|
+
} catch (err) {
|
|
510
|
+
console.error("[Telegram] Failed to send file:", err);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
317
513
|
};
|
|
318
514
|
}
|
|
319
515
|
});
|
|
@@ -323,12 +519,15 @@ var slack_exports = {};
|
|
|
323
519
|
__export(slack_exports, {
|
|
324
520
|
SlackAdapter: () => SlackAdapter
|
|
325
521
|
});
|
|
522
|
+
import fs11 from "fs";
|
|
523
|
+
import path10 from "path";
|
|
326
524
|
import { App, LogLevel } from "@slack/bolt";
|
|
327
525
|
var INLINE_COMMANDS, SLASH_COMMANDS, MAX_MESSAGE_LENGTH2, ACK_REACTION2, SlackAdapter;
|
|
328
526
|
var init_slack = __esm({
|
|
329
527
|
"src/runtime/adapters/slack.ts"() {
|
|
330
528
|
"use strict";
|
|
331
529
|
init_markdown();
|
|
530
|
+
init_attachment_utils();
|
|
332
531
|
INLINE_COMMANDS = {
|
|
333
532
|
"/clear": "clear",
|
|
334
533
|
"/restart": "restart",
|
|
@@ -348,11 +547,13 @@ var init_slack = __esm({
|
|
|
348
547
|
options;
|
|
349
548
|
botUserId = null;
|
|
350
549
|
lastThreadByChannel = /* @__PURE__ */ new Map();
|
|
550
|
+
rootDir = "";
|
|
351
551
|
constructor(options) {
|
|
352
552
|
this.options = options;
|
|
353
553
|
}
|
|
354
554
|
async start(ctx) {
|
|
355
555
|
this.agent = ctx.agent;
|
|
556
|
+
this.rootDir = ctx.rootDir;
|
|
356
557
|
this.app = new App({
|
|
357
558
|
token: this.options.botToken,
|
|
358
559
|
appToken: this.options.appToken,
|
|
@@ -421,15 +622,17 @@ var init_slack = __esm({
|
|
|
421
622
|
return;
|
|
422
623
|
}
|
|
423
624
|
const text = (event.text || "").trim();
|
|
424
|
-
if (!text) return;
|
|
425
625
|
const teamId = this.getTeamId(body, context);
|
|
426
626
|
const channelId = `slack-dm-${teamId}-${event.channel}`;
|
|
427
627
|
const route = { channel: event.channel };
|
|
628
|
+
const attachments = await this.extractSlackFiles(event, channelId, client);
|
|
629
|
+
if (!text && attachments.length === 0) return;
|
|
428
630
|
await this.tryAckReaction(client, event);
|
|
429
|
-
if (await this.tryHandleInlineCommand(text, channelId, client, route)) {
|
|
631
|
+
if (text && await this.tryHandleInlineCommand(text, channelId, client, route)) {
|
|
430
632
|
return;
|
|
431
633
|
}
|
|
432
|
-
|
|
634
|
+
const userText = text || "(User sent an attachment)";
|
|
635
|
+
await this.runAgent(channelId, userText, client, route, attachments);
|
|
433
636
|
}
|
|
434
637
|
async handleMention({
|
|
435
638
|
event,
|
|
@@ -452,7 +655,8 @@ var init_slack = __esm({
|
|
|
452
655
|
threadTs
|
|
453
656
|
);
|
|
454
657
|
const text = this.stripBotMention(event.text || "").trim();
|
|
455
|
-
|
|
658
|
+
const attachments = await this.extractSlackFiles(event, channelId, client);
|
|
659
|
+
if (!text && attachments.length === 0) {
|
|
456
660
|
await this.sendSafe(
|
|
457
661
|
client,
|
|
458
662
|
route,
|
|
@@ -461,10 +665,11 @@ var init_slack = __esm({
|
|
|
461
665
|
return;
|
|
462
666
|
}
|
|
463
667
|
await this.tryAckReaction(client, event);
|
|
464
|
-
if (await this.tryHandleInlineCommand(text, channelId, client, route)) {
|
|
668
|
+
if (text && await this.tryHandleInlineCommand(text, channelId, client, route)) {
|
|
465
669
|
return;
|
|
466
670
|
}
|
|
467
|
-
|
|
671
|
+
const userText = text || "(User sent an attachment)";
|
|
672
|
+
await this.runAgent(channelId, userText, client, route, attachments);
|
|
468
673
|
}
|
|
469
674
|
async handleSlashCommand({
|
|
470
675
|
command,
|
|
@@ -493,18 +698,29 @@ var init_slack = __esm({
|
|
|
493
698
|
// -------------------------------------------------------------------------
|
|
494
699
|
// Agent bridge
|
|
495
700
|
// -------------------------------------------------------------------------
|
|
496
|
-
async runAgent(channelId, text, client, route) {
|
|
701
|
+
async runAgent(channelId, text, client, route, attachments = []) {
|
|
497
702
|
if (!this.agent) return;
|
|
498
703
|
let finalText = "";
|
|
499
704
|
let hasError = false;
|
|
500
705
|
let errorMessage = "";
|
|
706
|
+
const pendingFiles = [];
|
|
501
707
|
const onEvent = (event) => {
|
|
502
708
|
if (event.type === "text_delta") {
|
|
503
709
|
finalText += event.delta;
|
|
710
|
+
} else if (event.type === "file_output") {
|
|
711
|
+
pendingFiles.push({
|
|
712
|
+
filePath: event.filePath,
|
|
713
|
+
caption: event.caption
|
|
714
|
+
});
|
|
504
715
|
}
|
|
505
716
|
};
|
|
506
717
|
try {
|
|
507
|
-
const result = await this.agent.handleMessage(
|
|
718
|
+
const result = await this.agent.handleMessage(
|
|
719
|
+
channelId,
|
|
720
|
+
text,
|
|
721
|
+
onEvent,
|
|
722
|
+
attachments.length > 0 ? attachments : void 0
|
|
723
|
+
);
|
|
508
724
|
if (result.errorMessage) {
|
|
509
725
|
hasError = true;
|
|
510
726
|
errorMessage = result.errorMessage;
|
|
@@ -517,11 +733,14 @@ var init_slack = __esm({
|
|
|
517
733
|
await this.sendSafe(client, route, `\u274C Error: ${errorMessage}`);
|
|
518
734
|
return;
|
|
519
735
|
}
|
|
520
|
-
if (
|
|
736
|
+
if (finalText.trim()) {
|
|
737
|
+
await this.sendLongMessage(client, route, finalText);
|
|
738
|
+
} else if (pendingFiles.length === 0) {
|
|
521
739
|
await this.sendSafe(client, route, "(No response generated)");
|
|
522
|
-
return;
|
|
523
740
|
}
|
|
524
|
-
|
|
741
|
+
for (const file of pendingFiles) {
|
|
742
|
+
await this.sendFileSafe(client, route, file.filePath, file.caption);
|
|
743
|
+
}
|
|
525
744
|
}
|
|
526
745
|
// -------------------------------------------------------------------------
|
|
527
746
|
// Helpers
|
|
@@ -697,6 +916,67 @@ var init_slack = __esm({
|
|
|
697
916
|
escapeRegExp(value) {
|
|
698
917
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
699
918
|
}
|
|
919
|
+
// -------------------------------------------------------------------------
|
|
920
|
+
// Attachment extraction & sending
|
|
921
|
+
// -------------------------------------------------------------------------
|
|
922
|
+
/**
|
|
923
|
+
* Extract file attachments from a Slack event.
|
|
924
|
+
* Downloads files using the Bot Token for private URL access.
|
|
925
|
+
*/
|
|
926
|
+
async extractSlackFiles(event, channelId, _client) {
|
|
927
|
+
const files = event.files;
|
|
928
|
+
if (!Array.isArray(files) || files.length === 0) return [];
|
|
929
|
+
const attachments = [];
|
|
930
|
+
for (const file of files) {
|
|
931
|
+
try {
|
|
932
|
+
const downloadUrl = file.url_private_download || file.url_private;
|
|
933
|
+
if (!downloadUrl) {
|
|
934
|
+
console.warn(
|
|
935
|
+
`[Slack] No download URL for file: ${file.name || file.id}`
|
|
936
|
+
);
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
const attachment = await downloadAndSaveAttachment(
|
|
940
|
+
this.rootDir,
|
|
941
|
+
channelId,
|
|
942
|
+
downloadUrl,
|
|
943
|
+
file.name || file.title || "file",
|
|
944
|
+
file.mimetype,
|
|
945
|
+
{ Authorization: `Bearer ${this.options.botToken}` }
|
|
946
|
+
);
|
|
947
|
+
attachments.push(attachment);
|
|
948
|
+
} catch (err) {
|
|
949
|
+
console.error(
|
|
950
|
+
`[Slack] Failed to download file ${file.name || file.id}:`,
|
|
951
|
+
err
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
return attachments;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Send a file to the Slack channel/thread.
|
|
959
|
+
*/
|
|
960
|
+
async sendFileSafe(client, route, filePath, caption) {
|
|
961
|
+
try {
|
|
962
|
+
if (!fs11.existsSync(filePath)) {
|
|
963
|
+
console.error(`[Slack] File not found for sending: ${filePath}`);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
const filename = path10.basename(filePath);
|
|
967
|
+
const fileContent = fs11.readFileSync(filePath);
|
|
968
|
+
await client.files.uploadV2({
|
|
969
|
+
channel_id: route.channel,
|
|
970
|
+
thread_ts: route.threadTs,
|
|
971
|
+
filename,
|
|
972
|
+
file: fileContent,
|
|
973
|
+
title: caption || filename,
|
|
974
|
+
initial_comment: caption || void 0
|
|
975
|
+
});
|
|
976
|
+
} catch (err) {
|
|
977
|
+
console.error("[Slack] Failed to send file:", err);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
700
980
|
};
|
|
701
981
|
}
|
|
702
982
|
});
|
|
@@ -987,7 +1267,8 @@ function refreshDescriptionsAndSave(workDir, config) {
|
|
|
987
1267
|
// src/commands/zip.ts
|
|
988
1268
|
async function zipCommand(workDir) {
|
|
989
1269
|
const config = loadConfig(workDir);
|
|
990
|
-
const
|
|
1270
|
+
const slug = config.name.toLowerCase().replace(/\s+/g, "-");
|
|
1271
|
+
const zipName = `${slug}.zip`;
|
|
991
1272
|
const zipPath = path3.join(workDir, zipName);
|
|
992
1273
|
installConfiguredSkills(workDir, config);
|
|
993
1274
|
syncSkillDescriptions(workDir, config);
|
|
@@ -1006,7 +1287,7 @@ async function zipCommand(workDir) {
|
|
|
1006
1287
|
});
|
|
1007
1288
|
archive.on("error", (err) => reject(err));
|
|
1008
1289
|
archive.pipe(output);
|
|
1009
|
-
const prefix =
|
|
1290
|
+
const prefix = slug;
|
|
1010
1291
|
archive.file(getPackPath(workDir), {
|
|
1011
1292
|
name: `${prefix}/${PACK_FILE}`
|
|
1012
1293
|
});
|
|
@@ -1266,22 +1547,23 @@ async function interactiveCreate(workDir) {
|
|
|
1266
1547
|
}
|
|
1267
1548
|
|
|
1268
1549
|
// src/commands/run.ts
|
|
1269
|
-
import
|
|
1270
|
-
import
|
|
1550
|
+
import path12 from "path";
|
|
1551
|
+
import fs13 from "fs";
|
|
1271
1552
|
import inquirer2 from "inquirer";
|
|
1272
1553
|
import chalk4 from "chalk";
|
|
1273
1554
|
|
|
1274
1555
|
// src/runtime/server.ts
|
|
1275
1556
|
import express from "express";
|
|
1276
|
-
import
|
|
1277
|
-
import
|
|
1557
|
+
import path11 from "path";
|
|
1558
|
+
import fs12 from "fs";
|
|
1278
1559
|
import { fileURLToPath } from "url";
|
|
1279
1560
|
import { createServer } from "http";
|
|
1280
1561
|
import { exec } from "child_process";
|
|
1281
1562
|
|
|
1282
1563
|
// src/runtime/agent.ts
|
|
1283
|
-
|
|
1284
|
-
import
|
|
1564
|
+
init_attachment_utils();
|
|
1565
|
+
import path7 from "path";
|
|
1566
|
+
import fs7 from "fs";
|
|
1285
1567
|
import {
|
|
1286
1568
|
AuthStorage,
|
|
1287
1569
|
createAgentSession,
|
|
@@ -1290,142 +1572,2847 @@ import {
|
|
|
1290
1572
|
SessionManager,
|
|
1291
1573
|
DefaultResourceLoader
|
|
1292
1574
|
} from "@mariozechner/pi-coding-agent";
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1575
|
+
|
|
1576
|
+
// src/runtime/tools/send-file-tool.ts
|
|
1577
|
+
import fs6 from "fs";
|
|
1578
|
+
import path6 from "path";
|
|
1579
|
+
|
|
1580
|
+
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
1581
|
+
var value_exports = {};
|
|
1582
|
+
__export(value_exports, {
|
|
1583
|
+
HasPropertyKey: () => HasPropertyKey,
|
|
1584
|
+
IsArray: () => IsArray,
|
|
1585
|
+
IsAsyncIterator: () => IsAsyncIterator,
|
|
1586
|
+
IsBigInt: () => IsBigInt,
|
|
1587
|
+
IsBoolean: () => IsBoolean,
|
|
1588
|
+
IsDate: () => IsDate,
|
|
1589
|
+
IsFunction: () => IsFunction,
|
|
1590
|
+
IsIterator: () => IsIterator,
|
|
1591
|
+
IsNull: () => IsNull,
|
|
1592
|
+
IsNumber: () => IsNumber,
|
|
1593
|
+
IsObject: () => IsObject,
|
|
1594
|
+
IsRegExp: () => IsRegExp,
|
|
1595
|
+
IsString: () => IsString,
|
|
1596
|
+
IsSymbol: () => IsSymbol,
|
|
1597
|
+
IsUint8Array: () => IsUint8Array,
|
|
1598
|
+
IsUndefined: () => IsUndefined
|
|
1599
|
+
});
|
|
1600
|
+
function HasPropertyKey(value, key) {
|
|
1601
|
+
return key in value;
|
|
1602
|
+
}
|
|
1603
|
+
function IsAsyncIterator(value) {
|
|
1604
|
+
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
|
|
1605
|
+
}
|
|
1606
|
+
function IsArray(value) {
|
|
1607
|
+
return Array.isArray(value);
|
|
1608
|
+
}
|
|
1609
|
+
function IsBigInt(value) {
|
|
1610
|
+
return typeof value === "bigint";
|
|
1611
|
+
}
|
|
1612
|
+
function IsBoolean(value) {
|
|
1613
|
+
return typeof value === "boolean";
|
|
1614
|
+
}
|
|
1615
|
+
function IsDate(value) {
|
|
1616
|
+
return value instanceof globalThis.Date;
|
|
1617
|
+
}
|
|
1618
|
+
function IsFunction(value) {
|
|
1619
|
+
return typeof value === "function";
|
|
1620
|
+
}
|
|
1621
|
+
function IsIterator(value) {
|
|
1622
|
+
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
|
|
1623
|
+
}
|
|
1624
|
+
function IsNull(value) {
|
|
1625
|
+
return value === null;
|
|
1626
|
+
}
|
|
1627
|
+
function IsNumber(value) {
|
|
1628
|
+
return typeof value === "number";
|
|
1629
|
+
}
|
|
1630
|
+
function IsObject(value) {
|
|
1631
|
+
return typeof value === "object" && value !== null;
|
|
1632
|
+
}
|
|
1633
|
+
function IsRegExp(value) {
|
|
1634
|
+
return value instanceof globalThis.RegExp;
|
|
1635
|
+
}
|
|
1636
|
+
function IsString(value) {
|
|
1637
|
+
return typeof value === "string";
|
|
1638
|
+
}
|
|
1639
|
+
function IsSymbol(value) {
|
|
1640
|
+
return typeof value === "symbol";
|
|
1641
|
+
}
|
|
1642
|
+
function IsUint8Array(value) {
|
|
1643
|
+
return value instanceof globalThis.Uint8Array;
|
|
1644
|
+
}
|
|
1645
|
+
function IsUndefined(value) {
|
|
1646
|
+
return value === void 0;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
|
|
1650
|
+
function ArrayType(value) {
|
|
1651
|
+
return value.map((value2) => Visit(value2));
|
|
1652
|
+
}
|
|
1653
|
+
function DateType(value) {
|
|
1654
|
+
return new Date(value.getTime());
|
|
1655
|
+
}
|
|
1656
|
+
function Uint8ArrayType(value) {
|
|
1657
|
+
return new Uint8Array(value);
|
|
1658
|
+
}
|
|
1659
|
+
function RegExpType(value) {
|
|
1660
|
+
return new RegExp(value.source, value.flags);
|
|
1661
|
+
}
|
|
1662
|
+
function ObjectType(value) {
|
|
1663
|
+
const result = {};
|
|
1664
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
1665
|
+
result[key] = Visit(value[key]);
|
|
1299
1666
|
}
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
const toolCalls = content.filter(
|
|
1305
|
-
(item) => item?.type === "toolCall"
|
|
1306
|
-
).length;
|
|
1307
|
-
return { stopReason, errorMessage, hasText: text.length > 0, toolCalls };
|
|
1667
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
1668
|
+
result[key] = Visit(value[key]);
|
|
1669
|
+
}
|
|
1670
|
+
return result;
|
|
1308
1671
|
}
|
|
1309
|
-
function
|
|
1310
|
-
|
|
1311
|
-
if (channelId.startsWith("slack-")) return "slack";
|
|
1312
|
-
return "web";
|
|
1672
|
+
function Visit(value) {
|
|
1673
|
+
return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
|
|
1313
1674
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1675
|
+
function Clone(value) {
|
|
1676
|
+
return Visit(value);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
// node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
|
|
1680
|
+
function CloneType(schema, options) {
|
|
1681
|
+
return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
// node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
|
|
1685
|
+
function IsObject2(value) {
|
|
1686
|
+
return value !== null && typeof value === "object";
|
|
1687
|
+
}
|
|
1688
|
+
function IsArray2(value) {
|
|
1689
|
+
return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
|
|
1690
|
+
}
|
|
1691
|
+
function IsUndefined2(value) {
|
|
1692
|
+
return value === void 0;
|
|
1693
|
+
}
|
|
1694
|
+
function IsNumber2(value) {
|
|
1695
|
+
return typeof value === "number";
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
// node_modules/@sinclair/typebox/build/esm/system/policy.mjs
|
|
1699
|
+
var TypeSystemPolicy;
|
|
1700
|
+
(function(TypeSystemPolicy2) {
|
|
1701
|
+
TypeSystemPolicy2.InstanceMode = "default";
|
|
1702
|
+
TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
|
|
1703
|
+
TypeSystemPolicy2.AllowArrayObject = false;
|
|
1704
|
+
TypeSystemPolicy2.AllowNaN = false;
|
|
1705
|
+
TypeSystemPolicy2.AllowNullVoid = false;
|
|
1706
|
+
function IsExactOptionalProperty(value, key) {
|
|
1707
|
+
return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
|
|
1320
1708
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
const existing = this.channels.get(channelId);
|
|
1326
|
-
if (existing) return existing;
|
|
1327
|
-
const pendingCreation = this.pendingSessionCreations.get(channelId);
|
|
1328
|
-
if (pendingCreation) return pendingCreation;
|
|
1329
|
-
const createSessionPromise = (async () => {
|
|
1330
|
-
const { apiKey, rootDir, provider, modelId } = this.options;
|
|
1331
|
-
const authStorage = AuthStorage.inMemory({
|
|
1332
|
-
[provider]: { type: "api_key", key: apiKey }
|
|
1333
|
-
});
|
|
1334
|
-
authStorage.setRuntimeApiKey(provider, apiKey);
|
|
1335
|
-
const modelRegistry = new ModelRegistry(authStorage);
|
|
1336
|
-
const model = modelRegistry.find(provider, modelId);
|
|
1337
|
-
const sessionDir = path5.resolve(
|
|
1338
|
-
rootDir,
|
|
1339
|
-
"data",
|
|
1340
|
-
"sessions",
|
|
1341
|
-
channelId
|
|
1342
|
-
);
|
|
1343
|
-
fs5.mkdirSync(sessionDir, { recursive: true });
|
|
1344
|
-
const sessionManager = SessionManager.continueRecent(rootDir, sessionDir);
|
|
1345
|
-
log(`[PackAgent] Session dir: ${sessionDir}`);
|
|
1346
|
-
const workspaceDir = path5.resolve(
|
|
1347
|
-
rootDir,
|
|
1348
|
-
"data",
|
|
1349
|
-
"workspaces",
|
|
1350
|
-
channelId
|
|
1351
|
-
);
|
|
1352
|
-
fs5.mkdirSync(workspaceDir, { recursive: true });
|
|
1353
|
-
log(`[PackAgent] Workspace dir: ${workspaceDir}`);
|
|
1354
|
-
const skillsPath = path5.resolve(rootDir, "skills");
|
|
1355
|
-
log(`[PackAgent] Loading skills from: ${skillsPath}`);
|
|
1356
|
-
const resourceLoader = new DefaultResourceLoader({
|
|
1357
|
-
cwd: rootDir,
|
|
1358
|
-
additionalSkillPaths: [skillsPath]
|
|
1359
|
-
});
|
|
1360
|
-
await resourceLoader.reload();
|
|
1361
|
-
const tools = createCodingTools(workspaceDir);
|
|
1362
|
-
const { session } = await createAgentSession({
|
|
1363
|
-
cwd: workspaceDir,
|
|
1364
|
-
authStorage,
|
|
1365
|
-
modelRegistry,
|
|
1366
|
-
sessionManager,
|
|
1367
|
-
resourceLoader,
|
|
1368
|
-
model,
|
|
1369
|
-
tools
|
|
1370
|
-
});
|
|
1371
|
-
const channelSession = {
|
|
1372
|
-
session,
|
|
1373
|
-
running: false,
|
|
1374
|
-
pending: Promise.resolve()
|
|
1375
|
-
};
|
|
1376
|
-
this.channels.set(channelId, channelSession);
|
|
1377
|
-
return channelSession;
|
|
1378
|
-
})();
|
|
1379
|
-
this.pendingSessionCreations.set(channelId, createSessionPromise);
|
|
1380
|
-
try {
|
|
1381
|
-
return await createSessionPromise;
|
|
1382
|
-
} finally {
|
|
1383
|
-
this.pendingSessionCreations.delete(channelId);
|
|
1384
|
-
}
|
|
1709
|
+
TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
|
|
1710
|
+
function IsObjectLike(value) {
|
|
1711
|
+
const isObject = IsObject2(value);
|
|
1712
|
+
return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
|
|
1385
1713
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1714
|
+
TypeSystemPolicy2.IsObjectLike = IsObjectLike;
|
|
1715
|
+
function IsRecordLike(value) {
|
|
1716
|
+
return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
|
|
1717
|
+
}
|
|
1718
|
+
TypeSystemPolicy2.IsRecordLike = IsRecordLike;
|
|
1719
|
+
function IsNumberLike(value) {
|
|
1720
|
+
return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
|
|
1721
|
+
}
|
|
1722
|
+
TypeSystemPolicy2.IsNumberLike = IsNumberLike;
|
|
1723
|
+
function IsVoidLike(value) {
|
|
1724
|
+
const isUndefined = IsUndefined2(value);
|
|
1725
|
+
return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
|
|
1726
|
+
}
|
|
1727
|
+
TypeSystemPolicy2.IsVoidLike = IsVoidLike;
|
|
1728
|
+
})(TypeSystemPolicy || (TypeSystemPolicy = {}));
|
|
1729
|
+
|
|
1730
|
+
// node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
|
|
1731
|
+
function ImmutableArray(value) {
|
|
1732
|
+
return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
|
|
1733
|
+
}
|
|
1734
|
+
function ImmutableDate(value) {
|
|
1735
|
+
return value;
|
|
1736
|
+
}
|
|
1737
|
+
function ImmutableUint8Array(value) {
|
|
1738
|
+
return value;
|
|
1739
|
+
}
|
|
1740
|
+
function ImmutableRegExp(value) {
|
|
1741
|
+
return value;
|
|
1742
|
+
}
|
|
1743
|
+
function ImmutableObject(value) {
|
|
1744
|
+
const result = {};
|
|
1745
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
1746
|
+
result[key] = Immutable(value[key]);
|
|
1747
|
+
}
|
|
1748
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
1749
|
+
result[key] = Immutable(value[key]);
|
|
1750
|
+
}
|
|
1751
|
+
return globalThis.Object.freeze(result);
|
|
1752
|
+
}
|
|
1753
|
+
function Immutable(value) {
|
|
1754
|
+
return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
// node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
|
|
1758
|
+
function CreateType(schema, options) {
|
|
1759
|
+
const result = options !== void 0 ? { ...options, ...schema } : schema;
|
|
1760
|
+
switch (TypeSystemPolicy.InstanceMode) {
|
|
1761
|
+
case "freeze":
|
|
1762
|
+
return Immutable(result);
|
|
1763
|
+
case "clone":
|
|
1764
|
+
return Clone(result);
|
|
1765
|
+
default:
|
|
1766
|
+
return result;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
|
|
1771
|
+
var TypeBoxError = class extends Error {
|
|
1772
|
+
constructor(message) {
|
|
1773
|
+
super(message);
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
// node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
|
|
1778
|
+
var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
|
|
1779
|
+
var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
|
|
1780
|
+
var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
|
|
1781
|
+
var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
|
|
1782
|
+
var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
|
|
1783
|
+
|
|
1784
|
+
// node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
|
|
1785
|
+
function IsReadonly(value) {
|
|
1786
|
+
return IsObject(value) && value[ReadonlyKind] === "Readonly";
|
|
1787
|
+
}
|
|
1788
|
+
function IsOptional(value) {
|
|
1789
|
+
return IsObject(value) && value[OptionalKind] === "Optional";
|
|
1790
|
+
}
|
|
1791
|
+
function IsAny(value) {
|
|
1792
|
+
return IsKindOf(value, "Any");
|
|
1793
|
+
}
|
|
1794
|
+
function IsArgument(value) {
|
|
1795
|
+
return IsKindOf(value, "Argument");
|
|
1796
|
+
}
|
|
1797
|
+
function IsArray3(value) {
|
|
1798
|
+
return IsKindOf(value, "Array");
|
|
1799
|
+
}
|
|
1800
|
+
function IsAsyncIterator2(value) {
|
|
1801
|
+
return IsKindOf(value, "AsyncIterator");
|
|
1802
|
+
}
|
|
1803
|
+
function IsBigInt2(value) {
|
|
1804
|
+
return IsKindOf(value, "BigInt");
|
|
1805
|
+
}
|
|
1806
|
+
function IsBoolean2(value) {
|
|
1807
|
+
return IsKindOf(value, "Boolean");
|
|
1808
|
+
}
|
|
1809
|
+
function IsComputed(value) {
|
|
1810
|
+
return IsKindOf(value, "Computed");
|
|
1811
|
+
}
|
|
1812
|
+
function IsConstructor(value) {
|
|
1813
|
+
return IsKindOf(value, "Constructor");
|
|
1814
|
+
}
|
|
1815
|
+
function IsDate2(value) {
|
|
1816
|
+
return IsKindOf(value, "Date");
|
|
1817
|
+
}
|
|
1818
|
+
function IsFunction2(value) {
|
|
1819
|
+
return IsKindOf(value, "Function");
|
|
1820
|
+
}
|
|
1821
|
+
function IsInteger(value) {
|
|
1822
|
+
return IsKindOf(value, "Integer");
|
|
1823
|
+
}
|
|
1824
|
+
function IsIntersect(value) {
|
|
1825
|
+
return IsKindOf(value, "Intersect");
|
|
1826
|
+
}
|
|
1827
|
+
function IsIterator2(value) {
|
|
1828
|
+
return IsKindOf(value, "Iterator");
|
|
1829
|
+
}
|
|
1830
|
+
function IsKindOf(value, kind) {
|
|
1831
|
+
return IsObject(value) && Kind in value && value[Kind] === kind;
|
|
1832
|
+
}
|
|
1833
|
+
function IsLiteralValue(value) {
|
|
1834
|
+
return IsBoolean(value) || IsNumber(value) || IsString(value);
|
|
1835
|
+
}
|
|
1836
|
+
function IsLiteral(value) {
|
|
1837
|
+
return IsKindOf(value, "Literal");
|
|
1838
|
+
}
|
|
1839
|
+
function IsMappedKey(value) {
|
|
1840
|
+
return IsKindOf(value, "MappedKey");
|
|
1841
|
+
}
|
|
1842
|
+
function IsMappedResult(value) {
|
|
1843
|
+
return IsKindOf(value, "MappedResult");
|
|
1844
|
+
}
|
|
1845
|
+
function IsNever(value) {
|
|
1846
|
+
return IsKindOf(value, "Never");
|
|
1847
|
+
}
|
|
1848
|
+
function IsNot(value) {
|
|
1849
|
+
return IsKindOf(value, "Not");
|
|
1850
|
+
}
|
|
1851
|
+
function IsNull2(value) {
|
|
1852
|
+
return IsKindOf(value, "Null");
|
|
1853
|
+
}
|
|
1854
|
+
function IsNumber3(value) {
|
|
1855
|
+
return IsKindOf(value, "Number");
|
|
1856
|
+
}
|
|
1857
|
+
function IsObject3(value) {
|
|
1858
|
+
return IsKindOf(value, "Object");
|
|
1859
|
+
}
|
|
1860
|
+
function IsPromise(value) {
|
|
1861
|
+
return IsKindOf(value, "Promise");
|
|
1862
|
+
}
|
|
1863
|
+
function IsRecord(value) {
|
|
1864
|
+
return IsKindOf(value, "Record");
|
|
1865
|
+
}
|
|
1866
|
+
function IsRef(value) {
|
|
1867
|
+
return IsKindOf(value, "Ref");
|
|
1868
|
+
}
|
|
1869
|
+
function IsRegExp2(value) {
|
|
1870
|
+
return IsKindOf(value, "RegExp");
|
|
1871
|
+
}
|
|
1872
|
+
function IsString2(value) {
|
|
1873
|
+
return IsKindOf(value, "String");
|
|
1874
|
+
}
|
|
1875
|
+
function IsSymbol2(value) {
|
|
1876
|
+
return IsKindOf(value, "Symbol");
|
|
1877
|
+
}
|
|
1878
|
+
function IsTemplateLiteral(value) {
|
|
1879
|
+
return IsKindOf(value, "TemplateLiteral");
|
|
1880
|
+
}
|
|
1881
|
+
function IsThis(value) {
|
|
1882
|
+
return IsKindOf(value, "This");
|
|
1883
|
+
}
|
|
1884
|
+
function IsTransform(value) {
|
|
1885
|
+
return IsObject(value) && TransformKind in value;
|
|
1886
|
+
}
|
|
1887
|
+
function IsTuple(value) {
|
|
1888
|
+
return IsKindOf(value, "Tuple");
|
|
1889
|
+
}
|
|
1890
|
+
function IsUndefined3(value) {
|
|
1891
|
+
return IsKindOf(value, "Undefined");
|
|
1892
|
+
}
|
|
1893
|
+
function IsUnion(value) {
|
|
1894
|
+
return IsKindOf(value, "Union");
|
|
1895
|
+
}
|
|
1896
|
+
function IsUint8Array2(value) {
|
|
1897
|
+
return IsKindOf(value, "Uint8Array");
|
|
1898
|
+
}
|
|
1899
|
+
function IsUnknown(value) {
|
|
1900
|
+
return IsKindOf(value, "Unknown");
|
|
1901
|
+
}
|
|
1902
|
+
function IsUnsafe(value) {
|
|
1903
|
+
return IsKindOf(value, "Unsafe");
|
|
1904
|
+
}
|
|
1905
|
+
function IsVoid(value) {
|
|
1906
|
+
return IsKindOf(value, "Void");
|
|
1907
|
+
}
|
|
1908
|
+
function IsKind(value) {
|
|
1909
|
+
return IsObject(value) && Kind in value && IsString(value[Kind]);
|
|
1910
|
+
}
|
|
1911
|
+
function IsSchema(value) {
|
|
1912
|
+
return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean2(value) || IsBigInt2(value) || IsAsyncIterator2(value) || IsComputed(value) || IsConstructor(value) || IsDate2(value) || IsFunction2(value) || IsInteger(value) || IsIntersect(value) || IsIterator2(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull2(value) || IsNumber3(value) || IsObject3(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString2(value) || IsSymbol2(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array2(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
// node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
|
|
1916
|
+
var type_exports = {};
|
|
1917
|
+
__export(type_exports, {
|
|
1918
|
+
IsAny: () => IsAny2,
|
|
1919
|
+
IsArgument: () => IsArgument2,
|
|
1920
|
+
IsArray: () => IsArray4,
|
|
1921
|
+
IsAsyncIterator: () => IsAsyncIterator3,
|
|
1922
|
+
IsBigInt: () => IsBigInt3,
|
|
1923
|
+
IsBoolean: () => IsBoolean3,
|
|
1924
|
+
IsComputed: () => IsComputed2,
|
|
1925
|
+
IsConstructor: () => IsConstructor2,
|
|
1926
|
+
IsDate: () => IsDate3,
|
|
1927
|
+
IsFunction: () => IsFunction3,
|
|
1928
|
+
IsImport: () => IsImport,
|
|
1929
|
+
IsInteger: () => IsInteger2,
|
|
1930
|
+
IsIntersect: () => IsIntersect2,
|
|
1931
|
+
IsIterator: () => IsIterator3,
|
|
1932
|
+
IsKind: () => IsKind2,
|
|
1933
|
+
IsKindOf: () => IsKindOf2,
|
|
1934
|
+
IsLiteral: () => IsLiteral2,
|
|
1935
|
+
IsLiteralBoolean: () => IsLiteralBoolean,
|
|
1936
|
+
IsLiteralNumber: () => IsLiteralNumber,
|
|
1937
|
+
IsLiteralString: () => IsLiteralString,
|
|
1938
|
+
IsLiteralValue: () => IsLiteralValue2,
|
|
1939
|
+
IsMappedKey: () => IsMappedKey2,
|
|
1940
|
+
IsMappedResult: () => IsMappedResult2,
|
|
1941
|
+
IsNever: () => IsNever2,
|
|
1942
|
+
IsNot: () => IsNot2,
|
|
1943
|
+
IsNull: () => IsNull3,
|
|
1944
|
+
IsNumber: () => IsNumber4,
|
|
1945
|
+
IsObject: () => IsObject4,
|
|
1946
|
+
IsOptional: () => IsOptional2,
|
|
1947
|
+
IsPromise: () => IsPromise2,
|
|
1948
|
+
IsProperties: () => IsProperties,
|
|
1949
|
+
IsReadonly: () => IsReadonly2,
|
|
1950
|
+
IsRecord: () => IsRecord2,
|
|
1951
|
+
IsRecursive: () => IsRecursive,
|
|
1952
|
+
IsRef: () => IsRef2,
|
|
1953
|
+
IsRegExp: () => IsRegExp3,
|
|
1954
|
+
IsSchema: () => IsSchema2,
|
|
1955
|
+
IsString: () => IsString3,
|
|
1956
|
+
IsSymbol: () => IsSymbol3,
|
|
1957
|
+
IsTemplateLiteral: () => IsTemplateLiteral2,
|
|
1958
|
+
IsThis: () => IsThis2,
|
|
1959
|
+
IsTransform: () => IsTransform2,
|
|
1960
|
+
IsTuple: () => IsTuple2,
|
|
1961
|
+
IsUint8Array: () => IsUint8Array3,
|
|
1962
|
+
IsUndefined: () => IsUndefined4,
|
|
1963
|
+
IsUnion: () => IsUnion2,
|
|
1964
|
+
IsUnionLiteral: () => IsUnionLiteral,
|
|
1965
|
+
IsUnknown: () => IsUnknown2,
|
|
1966
|
+
IsUnsafe: () => IsUnsafe2,
|
|
1967
|
+
IsVoid: () => IsVoid2,
|
|
1968
|
+
TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
|
|
1969
|
+
});
|
|
1970
|
+
var TypeGuardUnknownTypeError = class extends TypeBoxError {
|
|
1971
|
+
};
|
|
1972
|
+
var KnownTypes = [
|
|
1973
|
+
"Argument",
|
|
1974
|
+
"Any",
|
|
1975
|
+
"Array",
|
|
1976
|
+
"AsyncIterator",
|
|
1977
|
+
"BigInt",
|
|
1978
|
+
"Boolean",
|
|
1979
|
+
"Computed",
|
|
1980
|
+
"Constructor",
|
|
1981
|
+
"Date",
|
|
1982
|
+
"Enum",
|
|
1983
|
+
"Function",
|
|
1984
|
+
"Integer",
|
|
1985
|
+
"Intersect",
|
|
1986
|
+
"Iterator",
|
|
1987
|
+
"Literal",
|
|
1988
|
+
"MappedKey",
|
|
1989
|
+
"MappedResult",
|
|
1990
|
+
"Not",
|
|
1991
|
+
"Null",
|
|
1992
|
+
"Number",
|
|
1993
|
+
"Object",
|
|
1994
|
+
"Promise",
|
|
1995
|
+
"Record",
|
|
1996
|
+
"Ref",
|
|
1997
|
+
"RegExp",
|
|
1998
|
+
"String",
|
|
1999
|
+
"Symbol",
|
|
2000
|
+
"TemplateLiteral",
|
|
2001
|
+
"This",
|
|
2002
|
+
"Tuple",
|
|
2003
|
+
"Undefined",
|
|
2004
|
+
"Union",
|
|
2005
|
+
"Uint8Array",
|
|
2006
|
+
"Unknown",
|
|
2007
|
+
"Void"
|
|
2008
|
+
];
|
|
2009
|
+
function IsPattern(value) {
|
|
2010
|
+
try {
|
|
2011
|
+
new RegExp(value);
|
|
2012
|
+
return true;
|
|
2013
|
+
} catch {
|
|
2014
|
+
return false;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
function IsControlCharacterFree(value) {
|
|
2018
|
+
if (!IsString(value))
|
|
2019
|
+
return false;
|
|
2020
|
+
for (let i = 0; i < value.length; i++) {
|
|
2021
|
+
const code = value.charCodeAt(i);
|
|
2022
|
+
if (code >= 7 && code <= 13 || code === 27 || code === 127) {
|
|
2023
|
+
return false;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
return true;
|
|
2027
|
+
}
|
|
2028
|
+
function IsAdditionalProperties(value) {
|
|
2029
|
+
return IsOptionalBoolean(value) || IsSchema2(value);
|
|
2030
|
+
}
|
|
2031
|
+
function IsOptionalBigInt(value) {
|
|
2032
|
+
return IsUndefined(value) || IsBigInt(value);
|
|
2033
|
+
}
|
|
2034
|
+
function IsOptionalNumber(value) {
|
|
2035
|
+
return IsUndefined(value) || IsNumber(value);
|
|
2036
|
+
}
|
|
2037
|
+
function IsOptionalBoolean(value) {
|
|
2038
|
+
return IsUndefined(value) || IsBoolean(value);
|
|
2039
|
+
}
|
|
2040
|
+
function IsOptionalString(value) {
|
|
2041
|
+
return IsUndefined(value) || IsString(value);
|
|
2042
|
+
}
|
|
2043
|
+
function IsOptionalPattern(value) {
|
|
2044
|
+
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
|
|
2045
|
+
}
|
|
2046
|
+
function IsOptionalFormat(value) {
|
|
2047
|
+
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
|
|
2048
|
+
}
|
|
2049
|
+
function IsOptionalSchema(value) {
|
|
2050
|
+
return IsUndefined(value) || IsSchema2(value);
|
|
2051
|
+
}
|
|
2052
|
+
function IsReadonly2(value) {
|
|
2053
|
+
return IsObject(value) && value[ReadonlyKind] === "Readonly";
|
|
2054
|
+
}
|
|
2055
|
+
function IsOptional2(value) {
|
|
2056
|
+
return IsObject(value) && value[OptionalKind] === "Optional";
|
|
2057
|
+
}
|
|
2058
|
+
function IsAny2(value) {
|
|
2059
|
+
return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
|
|
2060
|
+
}
|
|
2061
|
+
function IsArgument2(value) {
|
|
2062
|
+
return IsKindOf2(value, "Argument") && IsNumber(value.index);
|
|
2063
|
+
}
|
|
2064
|
+
function IsArray4(value) {
|
|
2065
|
+
return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
|
|
2066
|
+
}
|
|
2067
|
+
function IsAsyncIterator3(value) {
|
|
2068
|
+
return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
2069
|
+
}
|
|
2070
|
+
function IsBigInt3(value) {
|
|
2071
|
+
return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
|
|
2072
|
+
}
|
|
2073
|
+
function IsBoolean3(value) {
|
|
2074
|
+
return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
|
|
2075
|
+
}
|
|
2076
|
+
function IsComputed2(value) {
|
|
2077
|
+
return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
|
|
2078
|
+
}
|
|
2079
|
+
function IsConstructor2(value) {
|
|
2080
|
+
return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
2081
|
+
}
|
|
2082
|
+
function IsDate3(value) {
|
|
2083
|
+
return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
|
|
2084
|
+
}
|
|
2085
|
+
function IsFunction3(value) {
|
|
2086
|
+
return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
2087
|
+
}
|
|
2088
|
+
function IsImport(value) {
|
|
2089
|
+
return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
|
|
2090
|
+
}
|
|
2091
|
+
function IsInteger2(value) {
|
|
2092
|
+
return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
|
|
2093
|
+
}
|
|
2094
|
+
function IsProperties(value) {
|
|
2095
|
+
return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
|
|
2096
|
+
}
|
|
2097
|
+
function IsIntersect2(value) {
|
|
2098
|
+
return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
|
|
2099
|
+
}
|
|
2100
|
+
function IsIterator3(value) {
|
|
2101
|
+
return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
2102
|
+
}
|
|
2103
|
+
function IsKindOf2(value, kind) {
|
|
2104
|
+
return IsObject(value) && Kind in value && value[Kind] === kind;
|
|
2105
|
+
}
|
|
2106
|
+
function IsLiteralString(value) {
|
|
2107
|
+
return IsLiteral2(value) && IsString(value.const);
|
|
2108
|
+
}
|
|
2109
|
+
function IsLiteralNumber(value) {
|
|
2110
|
+
return IsLiteral2(value) && IsNumber(value.const);
|
|
2111
|
+
}
|
|
2112
|
+
function IsLiteralBoolean(value) {
|
|
2113
|
+
return IsLiteral2(value) && IsBoolean(value.const);
|
|
2114
|
+
}
|
|
2115
|
+
function IsLiteral2(value) {
|
|
2116
|
+
return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
|
|
2117
|
+
}
|
|
2118
|
+
function IsLiteralValue2(value) {
|
|
2119
|
+
return IsBoolean(value) || IsNumber(value) || IsString(value);
|
|
2120
|
+
}
|
|
2121
|
+
function IsMappedKey2(value) {
|
|
2122
|
+
return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
|
|
2123
|
+
}
|
|
2124
|
+
function IsMappedResult2(value) {
|
|
2125
|
+
return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
|
|
2126
|
+
}
|
|
2127
|
+
function IsNever2(value) {
|
|
2128
|
+
return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
|
|
2129
|
+
}
|
|
2130
|
+
function IsNot2(value) {
|
|
2131
|
+
return IsKindOf2(value, "Not") && IsSchema2(value.not);
|
|
2132
|
+
}
|
|
2133
|
+
function IsNull3(value) {
|
|
2134
|
+
return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
|
|
2135
|
+
}
|
|
2136
|
+
function IsNumber4(value) {
|
|
2137
|
+
return IsKindOf2(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
|
|
2138
|
+
}
|
|
2139
|
+
function IsObject4(value) {
|
|
2140
|
+
return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
|
|
2141
|
+
}
|
|
2142
|
+
function IsPromise2(value) {
|
|
2143
|
+
return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
|
|
2144
|
+
}
|
|
2145
|
+
function IsRecord2(value) {
|
|
2146
|
+
return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
|
|
2147
|
+
const keys = Object.getOwnPropertyNames(schema.patternProperties);
|
|
2148
|
+
return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
|
|
2149
|
+
})(value);
|
|
2150
|
+
}
|
|
2151
|
+
function IsRecursive(value) {
|
|
2152
|
+
return IsObject(value) && Hint in value && value[Hint] === "Recursive";
|
|
2153
|
+
}
|
|
2154
|
+
function IsRef2(value) {
|
|
2155
|
+
return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
|
|
2156
|
+
}
|
|
2157
|
+
function IsRegExp3(value) {
|
|
2158
|
+
return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
|
|
2159
|
+
}
|
|
2160
|
+
function IsString3(value) {
|
|
2161
|
+
return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
|
|
2162
|
+
}
|
|
2163
|
+
function IsSymbol3(value) {
|
|
2164
|
+
return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
|
|
2165
|
+
}
|
|
2166
|
+
function IsTemplateLiteral2(value) {
|
|
2167
|
+
return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
|
|
2168
|
+
}
|
|
2169
|
+
function IsThis2(value) {
|
|
2170
|
+
return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
|
|
2171
|
+
}
|
|
2172
|
+
function IsTransform2(value) {
|
|
2173
|
+
return IsObject(value) && TransformKind in value;
|
|
2174
|
+
}
|
|
2175
|
+
function IsTuple2(value) {
|
|
2176
|
+
return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
|
|
2177
|
+
(IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
|
|
2178
|
+
}
|
|
2179
|
+
function IsUndefined4(value) {
|
|
2180
|
+
return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
|
|
2181
|
+
}
|
|
2182
|
+
function IsUnionLiteral(value) {
|
|
2183
|
+
return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
|
|
2184
|
+
}
|
|
2185
|
+
function IsUnion2(value) {
|
|
2186
|
+
return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
|
|
2187
|
+
}
|
|
2188
|
+
function IsUint8Array3(value) {
|
|
2189
|
+
return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
|
|
2190
|
+
}
|
|
2191
|
+
function IsUnknown2(value) {
|
|
2192
|
+
return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
|
|
2193
|
+
}
|
|
2194
|
+
function IsUnsafe2(value) {
|
|
2195
|
+
return IsKindOf2(value, "Unsafe");
|
|
2196
|
+
}
|
|
2197
|
+
function IsVoid2(value) {
|
|
2198
|
+
return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
|
|
2199
|
+
}
|
|
2200
|
+
function IsKind2(value) {
|
|
2201
|
+
return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
|
|
2202
|
+
}
|
|
2203
|
+
function IsSchema2(value) {
|
|
2204
|
+
return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed2(value) || IsConstructor2(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect2(value) || IsIterator3(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull3(value) || IsNumber4(value) || IsObject4(value) || IsPromise2(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array3(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
|
|
2208
|
+
var PatternBoolean = "(true|false)";
|
|
2209
|
+
var PatternNumber = "(0|[1-9][0-9]*)";
|
|
2210
|
+
var PatternString = "(.*)";
|
|
2211
|
+
var PatternNever = "(?!.*)";
|
|
2212
|
+
var PatternBooleanExact = `^${PatternBoolean}$`;
|
|
2213
|
+
var PatternNumberExact = `^${PatternNumber}$`;
|
|
2214
|
+
var PatternStringExact = `^${PatternString}$`;
|
|
2215
|
+
var PatternNeverExact = `^${PatternNever}$`;
|
|
2216
|
+
|
|
2217
|
+
// node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
|
|
2218
|
+
function SetIncludes(T, S) {
|
|
2219
|
+
return T.includes(S);
|
|
2220
|
+
}
|
|
2221
|
+
function SetDistinct(T) {
|
|
2222
|
+
return [...new Set(T)];
|
|
2223
|
+
}
|
|
2224
|
+
function SetIntersect(T, S) {
|
|
2225
|
+
return T.filter((L) => S.includes(L));
|
|
2226
|
+
}
|
|
2227
|
+
function SetIntersectManyResolve(T, Init) {
|
|
2228
|
+
return T.reduce((Acc, L) => {
|
|
2229
|
+
return SetIntersect(Acc, L);
|
|
2230
|
+
}, Init);
|
|
2231
|
+
}
|
|
2232
|
+
function SetIntersectMany(T) {
|
|
2233
|
+
return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
|
|
2234
|
+
}
|
|
2235
|
+
function SetUnionMany(T) {
|
|
2236
|
+
const Acc = [];
|
|
2237
|
+
for (const L of T)
|
|
2238
|
+
Acc.push(...L);
|
|
2239
|
+
return Acc;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
// node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
|
|
2243
|
+
function Any(options) {
|
|
2244
|
+
return CreateType({ [Kind]: "Any" }, options);
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
// node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
|
|
2248
|
+
function Array2(items, options) {
|
|
2249
|
+
return CreateType({ [Kind]: "Array", type: "array", items }, options);
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
// node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
|
|
2253
|
+
function Argument(index) {
|
|
2254
|
+
return CreateType({ [Kind]: "Argument", index });
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
// node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
|
|
2258
|
+
function AsyncIterator(items, options) {
|
|
2259
|
+
return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
// node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
|
|
2263
|
+
function Computed(target, parameters, options) {
|
|
2264
|
+
return CreateType({ [Kind]: "Computed", target, parameters }, options);
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
// node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
|
|
2268
|
+
function DiscardKey(value, key) {
|
|
2269
|
+
const { [key]: _, ...rest } = value;
|
|
2270
|
+
return rest;
|
|
2271
|
+
}
|
|
2272
|
+
function Discard(value, keys) {
|
|
2273
|
+
return keys.reduce((acc, key) => DiscardKey(acc, key), value);
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
// node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
|
|
2277
|
+
function Never(options) {
|
|
2278
|
+
return CreateType({ [Kind]: "Never", not: {} }, options);
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
// node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
|
|
2282
|
+
function MappedResult(properties) {
|
|
2283
|
+
return CreateType({
|
|
2284
|
+
[Kind]: "MappedResult",
|
|
2285
|
+
properties
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
// node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
|
|
2290
|
+
function Constructor(parameters, returns, options) {
|
|
2291
|
+
return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
// node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
|
|
2295
|
+
function Function(parameters, returns, options) {
|
|
2296
|
+
return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
// node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
|
|
2300
|
+
function UnionCreate(T, options) {
|
|
2301
|
+
return CreateType({ [Kind]: "Union", anyOf: T }, options);
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
// node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
|
|
2305
|
+
function IsUnionOptional(types) {
|
|
2306
|
+
return types.some((type) => IsOptional(type));
|
|
2307
|
+
}
|
|
2308
|
+
function RemoveOptionalFromRest(types) {
|
|
2309
|
+
return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
|
|
2310
|
+
}
|
|
2311
|
+
function RemoveOptionalFromType(T) {
|
|
2312
|
+
return Discard(T, [OptionalKind]);
|
|
2313
|
+
}
|
|
2314
|
+
function ResolveUnion(types, options) {
|
|
2315
|
+
const isOptional = IsUnionOptional(types);
|
|
2316
|
+
return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
|
|
2317
|
+
}
|
|
2318
|
+
function UnionEvaluated(T, options) {
|
|
2319
|
+
return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
// node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
|
|
2323
|
+
function Union(types, options) {
|
|
2324
|
+
return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
|
|
2328
|
+
var TemplateLiteralParserError = class extends TypeBoxError {
|
|
2329
|
+
};
|
|
2330
|
+
function Unescape(pattern) {
|
|
2331
|
+
return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
|
|
2332
|
+
}
|
|
2333
|
+
function IsNonEscaped(pattern, index, char) {
|
|
2334
|
+
return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
|
|
2335
|
+
}
|
|
2336
|
+
function IsOpenParen(pattern, index) {
|
|
2337
|
+
return IsNonEscaped(pattern, index, "(");
|
|
2338
|
+
}
|
|
2339
|
+
function IsCloseParen(pattern, index) {
|
|
2340
|
+
return IsNonEscaped(pattern, index, ")");
|
|
2341
|
+
}
|
|
2342
|
+
function IsSeparator(pattern, index) {
|
|
2343
|
+
return IsNonEscaped(pattern, index, "|");
|
|
2344
|
+
}
|
|
2345
|
+
function IsGroup(pattern) {
|
|
2346
|
+
if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
|
|
2347
|
+
return false;
|
|
2348
|
+
let count = 0;
|
|
2349
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
2350
|
+
if (IsOpenParen(pattern, index))
|
|
2351
|
+
count += 1;
|
|
2352
|
+
if (IsCloseParen(pattern, index))
|
|
2353
|
+
count -= 1;
|
|
2354
|
+
if (count === 0 && index !== pattern.length - 1)
|
|
2355
|
+
return false;
|
|
2356
|
+
}
|
|
2357
|
+
return true;
|
|
2358
|
+
}
|
|
2359
|
+
function InGroup(pattern) {
|
|
2360
|
+
return pattern.slice(1, pattern.length - 1);
|
|
2361
|
+
}
|
|
2362
|
+
function IsPrecedenceOr(pattern) {
|
|
2363
|
+
let count = 0;
|
|
2364
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
2365
|
+
if (IsOpenParen(pattern, index))
|
|
2366
|
+
count += 1;
|
|
2367
|
+
if (IsCloseParen(pattern, index))
|
|
2368
|
+
count -= 1;
|
|
2369
|
+
if (IsSeparator(pattern, index) && count === 0)
|
|
2370
|
+
return true;
|
|
2371
|
+
}
|
|
2372
|
+
return false;
|
|
2373
|
+
}
|
|
2374
|
+
function IsPrecedenceAnd(pattern) {
|
|
2375
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
2376
|
+
if (IsOpenParen(pattern, index))
|
|
2377
|
+
return true;
|
|
2378
|
+
}
|
|
2379
|
+
return false;
|
|
2380
|
+
}
|
|
2381
|
+
function Or(pattern) {
|
|
2382
|
+
let [count, start] = [0, 0];
|
|
2383
|
+
const expressions = [];
|
|
2384
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
2385
|
+
if (IsOpenParen(pattern, index))
|
|
2386
|
+
count += 1;
|
|
2387
|
+
if (IsCloseParen(pattern, index))
|
|
2388
|
+
count -= 1;
|
|
2389
|
+
if (IsSeparator(pattern, index) && count === 0) {
|
|
2390
|
+
const range2 = pattern.slice(start, index);
|
|
2391
|
+
if (range2.length > 0)
|
|
2392
|
+
expressions.push(TemplateLiteralParse(range2));
|
|
2393
|
+
start = index + 1;
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
const range = pattern.slice(start);
|
|
2397
|
+
if (range.length > 0)
|
|
2398
|
+
expressions.push(TemplateLiteralParse(range));
|
|
2399
|
+
if (expressions.length === 0)
|
|
2400
|
+
return { type: "const", const: "" };
|
|
2401
|
+
if (expressions.length === 1)
|
|
2402
|
+
return expressions[0];
|
|
2403
|
+
return { type: "or", expr: expressions };
|
|
2404
|
+
}
|
|
2405
|
+
function And(pattern) {
|
|
2406
|
+
function Group(value, index) {
|
|
2407
|
+
if (!IsOpenParen(value, index))
|
|
2408
|
+
throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
|
|
2409
|
+
let count = 0;
|
|
2410
|
+
for (let scan = index; scan < value.length; scan++) {
|
|
2411
|
+
if (IsOpenParen(value, scan))
|
|
2412
|
+
count += 1;
|
|
2413
|
+
if (IsCloseParen(value, scan))
|
|
2414
|
+
count -= 1;
|
|
2415
|
+
if (count === 0)
|
|
2416
|
+
return [index, scan];
|
|
2417
|
+
}
|
|
2418
|
+
throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
|
|
2419
|
+
}
|
|
2420
|
+
function Range(pattern2, index) {
|
|
2421
|
+
for (let scan = index; scan < pattern2.length; scan++) {
|
|
2422
|
+
if (IsOpenParen(pattern2, scan))
|
|
2423
|
+
return [index, scan];
|
|
2424
|
+
}
|
|
2425
|
+
return [index, pattern2.length];
|
|
2426
|
+
}
|
|
2427
|
+
const expressions = [];
|
|
2428
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
2429
|
+
if (IsOpenParen(pattern, index)) {
|
|
2430
|
+
const [start, end] = Group(pattern, index);
|
|
2431
|
+
const range = pattern.slice(start, end + 1);
|
|
2432
|
+
expressions.push(TemplateLiteralParse(range));
|
|
2433
|
+
index = end;
|
|
2434
|
+
} else {
|
|
2435
|
+
const [start, end] = Range(pattern, index);
|
|
2436
|
+
const range = pattern.slice(start, end);
|
|
2437
|
+
if (range.length > 0)
|
|
2438
|
+
expressions.push(TemplateLiteralParse(range));
|
|
2439
|
+
index = end - 1;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
|
|
2443
|
+
}
|
|
2444
|
+
function TemplateLiteralParse(pattern) {
|
|
2445
|
+
return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
|
|
2446
|
+
}
|
|
2447
|
+
function TemplateLiteralParseExact(pattern) {
|
|
2448
|
+
return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
|
|
2452
|
+
var TemplateLiteralFiniteError = class extends TypeBoxError {
|
|
2453
|
+
};
|
|
2454
|
+
function IsNumberExpression(expression) {
|
|
2455
|
+
return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
|
|
2456
|
+
}
|
|
2457
|
+
function IsBooleanExpression(expression) {
|
|
2458
|
+
return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
|
|
2459
|
+
}
|
|
2460
|
+
function IsStringExpression(expression) {
|
|
2461
|
+
return expression.type === "const" && expression.const === ".*";
|
|
2462
|
+
}
|
|
2463
|
+
function IsTemplateLiteralExpressionFinite(expression) {
|
|
2464
|
+
return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
|
|
2465
|
+
throw new TemplateLiteralFiniteError(`Unknown expression type`);
|
|
2466
|
+
})();
|
|
2467
|
+
}
|
|
2468
|
+
function IsTemplateLiteralFinite(schema) {
|
|
2469
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
2470
|
+
return IsTemplateLiteralExpressionFinite(expression);
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
|
|
2474
|
+
var TemplateLiteralGenerateError = class extends TypeBoxError {
|
|
2475
|
+
};
|
|
2476
|
+
function* GenerateReduce(buffer) {
|
|
2477
|
+
if (buffer.length === 1)
|
|
2478
|
+
return yield* buffer[0];
|
|
2479
|
+
for (const left of buffer[0]) {
|
|
2480
|
+
for (const right of GenerateReduce(buffer.slice(1))) {
|
|
2481
|
+
yield `${left}${right}`;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
function* GenerateAnd(expression) {
|
|
2486
|
+
return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
|
|
2487
|
+
}
|
|
2488
|
+
function* GenerateOr(expression) {
|
|
2489
|
+
for (const expr of expression.expr)
|
|
2490
|
+
yield* TemplateLiteralExpressionGenerate(expr);
|
|
2491
|
+
}
|
|
2492
|
+
function* GenerateConst(expression) {
|
|
2493
|
+
return yield expression.const;
|
|
2494
|
+
}
|
|
2495
|
+
function* TemplateLiteralExpressionGenerate(expression) {
|
|
2496
|
+
return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
|
|
2497
|
+
throw new TemplateLiteralGenerateError("Unknown expression");
|
|
2498
|
+
})();
|
|
2499
|
+
}
|
|
2500
|
+
function TemplateLiteralGenerate(schema) {
|
|
2501
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
2502
|
+
return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
// node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
|
|
2506
|
+
function Literal(value, options) {
|
|
2507
|
+
return CreateType({
|
|
2508
|
+
[Kind]: "Literal",
|
|
2509
|
+
const: value,
|
|
2510
|
+
type: typeof value
|
|
2511
|
+
}, options);
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
// node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
|
|
2515
|
+
function Boolean2(options) {
|
|
2516
|
+
return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
// node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
|
|
2520
|
+
function BigInt(options) {
|
|
2521
|
+
return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
// node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
|
|
2525
|
+
function Number2(options) {
|
|
2526
|
+
return CreateType({ [Kind]: "Number", type: "number" }, options);
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
// node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
|
|
2530
|
+
function String2(options) {
|
|
2531
|
+
return CreateType({ [Kind]: "String", type: "string" }, options);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
|
|
2535
|
+
function* FromUnion(syntax) {
|
|
2536
|
+
const trim = syntax.trim().replace(/"|'/g, "");
|
|
2537
|
+
return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
|
|
2538
|
+
const literals = trim.split("|").map((literal) => Literal(literal.trim()));
|
|
2539
|
+
return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
|
|
2540
|
+
})();
|
|
2541
|
+
}
|
|
2542
|
+
function* FromTerminal(syntax) {
|
|
2543
|
+
if (syntax[1] !== "{") {
|
|
2544
|
+
const L = Literal("$");
|
|
2545
|
+
const R = FromSyntax(syntax.slice(1));
|
|
2546
|
+
return yield* [L, ...R];
|
|
2547
|
+
}
|
|
2548
|
+
for (let i = 2; i < syntax.length; i++) {
|
|
2549
|
+
if (syntax[i] === "}") {
|
|
2550
|
+
const L = FromUnion(syntax.slice(2, i));
|
|
2551
|
+
const R = FromSyntax(syntax.slice(i + 1));
|
|
2552
|
+
return yield* [...L, ...R];
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
yield Literal(syntax);
|
|
2556
|
+
}
|
|
2557
|
+
function* FromSyntax(syntax) {
|
|
2558
|
+
for (let i = 0; i < syntax.length; i++) {
|
|
2559
|
+
if (syntax[i] === "$") {
|
|
2560
|
+
const L = Literal(syntax.slice(0, i));
|
|
2561
|
+
const R = FromTerminal(syntax.slice(i));
|
|
2562
|
+
return yield* [L, ...R];
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
yield Literal(syntax);
|
|
2566
|
+
}
|
|
2567
|
+
function TemplateLiteralSyntax(syntax) {
|
|
2568
|
+
return [...FromSyntax(syntax)];
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
|
|
2572
|
+
var TemplateLiteralPatternError = class extends TypeBoxError {
|
|
2573
|
+
};
|
|
2574
|
+
function Escape(value) {
|
|
2575
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2576
|
+
}
|
|
2577
|
+
function Visit2(schema, acc) {
|
|
2578
|
+
return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` : IsInteger(schema) ? `${acc}${PatternNumber}` : IsBigInt2(schema) ? `${acc}${PatternNumber}` : IsString2(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean2(schema) ? `${acc}${PatternBoolean}` : (() => {
|
|
2579
|
+
throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
|
|
2580
|
+
})();
|
|
2581
|
+
}
|
|
2582
|
+
function TemplateLiteralPattern(kinds) {
|
|
2583
|
+
return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
|
|
2587
|
+
function TemplateLiteralToUnion(schema) {
|
|
2588
|
+
const R = TemplateLiteralGenerate(schema);
|
|
2589
|
+
const L = R.map((S) => Literal(S));
|
|
2590
|
+
return UnionEvaluated(L);
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
|
|
2594
|
+
function TemplateLiteral(unresolved, options) {
|
|
2595
|
+
const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
|
|
2596
|
+
return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
|
|
2600
|
+
function FromTemplateLiteral(templateLiteral) {
|
|
2601
|
+
const keys = TemplateLiteralGenerate(templateLiteral);
|
|
2602
|
+
return keys.map((key) => key.toString());
|
|
2603
|
+
}
|
|
2604
|
+
function FromUnion2(types) {
|
|
2605
|
+
const result = [];
|
|
2606
|
+
for (const type of types)
|
|
2607
|
+
result.push(...IndexPropertyKeys(type));
|
|
2608
|
+
return result;
|
|
2609
|
+
}
|
|
2610
|
+
function FromLiteral(literalValue) {
|
|
2611
|
+
return [literalValue.toString()];
|
|
2612
|
+
}
|
|
2613
|
+
function IndexPropertyKeys(type) {
|
|
2614
|
+
return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
|
|
2618
|
+
function FromProperties(type, properties, options) {
|
|
2619
|
+
const result = {};
|
|
2620
|
+
for (const K2 of Object.getOwnPropertyNames(properties)) {
|
|
2621
|
+
result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
|
|
2622
|
+
}
|
|
2623
|
+
return result;
|
|
2624
|
+
}
|
|
2625
|
+
function FromMappedResult(type, mappedResult, options) {
|
|
2626
|
+
return FromProperties(type, mappedResult.properties, options);
|
|
2627
|
+
}
|
|
2628
|
+
function IndexFromMappedResult(type, mappedResult, options) {
|
|
2629
|
+
const properties = FromMappedResult(type, mappedResult, options);
|
|
2630
|
+
return MappedResult(properties);
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
|
|
2634
|
+
function FromRest(types, key) {
|
|
2635
|
+
return types.map((type) => IndexFromPropertyKey(type, key));
|
|
2636
|
+
}
|
|
2637
|
+
function FromIntersectRest(types) {
|
|
2638
|
+
return types.filter((type) => !IsNever(type));
|
|
2639
|
+
}
|
|
2640
|
+
function FromIntersect(types, key) {
|
|
2641
|
+
return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
|
|
2642
|
+
}
|
|
2643
|
+
function FromUnionRest(types) {
|
|
2644
|
+
return types.some((L) => IsNever(L)) ? [] : types;
|
|
2645
|
+
}
|
|
2646
|
+
function FromUnion3(types, key) {
|
|
2647
|
+
return UnionEvaluated(FromUnionRest(FromRest(types, key)));
|
|
2648
|
+
}
|
|
2649
|
+
function FromTuple(types, key) {
|
|
2650
|
+
return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
|
|
2651
|
+
}
|
|
2652
|
+
function FromArray(type, key) {
|
|
2653
|
+
return key === "[number]" ? type : Never();
|
|
2654
|
+
}
|
|
2655
|
+
function FromProperty(properties, propertyKey) {
|
|
2656
|
+
return propertyKey in properties ? properties[propertyKey] : Never();
|
|
2657
|
+
}
|
|
2658
|
+
function IndexFromPropertyKey(type, propertyKey) {
|
|
2659
|
+
return IsIntersect(type) ? FromIntersect(type.allOf, propertyKey) : IsUnion(type) ? FromUnion3(type.anyOf, propertyKey) : IsTuple(type) ? FromTuple(type.items ?? [], propertyKey) : IsArray3(type) ? FromArray(type.items, propertyKey) : IsObject3(type) ? FromProperty(type.properties, propertyKey) : Never();
|
|
2660
|
+
}
|
|
2661
|
+
function IndexFromPropertyKeys(type, propertyKeys) {
|
|
2662
|
+
return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
|
|
2663
|
+
}
|
|
2664
|
+
function FromSchema(type, propertyKeys) {
|
|
2665
|
+
return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
|
|
2666
|
+
}
|
|
2667
|
+
function Index(type, key, options) {
|
|
2668
|
+
if (IsRef(type) || IsRef(key)) {
|
|
2669
|
+
const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
|
|
2670
|
+
if (!IsSchema(type) || !IsSchema(key))
|
|
2671
|
+
throw new TypeBoxError(error);
|
|
2672
|
+
return Computed("Index", [type, key]);
|
|
2673
|
+
}
|
|
2674
|
+
if (IsMappedResult(key))
|
|
2675
|
+
return IndexFromMappedResult(type, key, options);
|
|
2676
|
+
if (IsMappedKey(key))
|
|
2677
|
+
return IndexFromMappedKey(type, key, options);
|
|
2678
|
+
return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
|
|
2682
|
+
function MappedIndexPropertyKey(type, key, options) {
|
|
2683
|
+
return { [key]: Index(type, [key], Clone(options)) };
|
|
2684
|
+
}
|
|
2685
|
+
function MappedIndexPropertyKeys(type, propertyKeys, options) {
|
|
2686
|
+
return propertyKeys.reduce((result, left) => {
|
|
2687
|
+
return { ...result, ...MappedIndexPropertyKey(type, left, options) };
|
|
2688
|
+
}, {});
|
|
2689
|
+
}
|
|
2690
|
+
function MappedIndexProperties(type, mappedKey, options) {
|
|
2691
|
+
return MappedIndexPropertyKeys(type, mappedKey.keys, options);
|
|
2692
|
+
}
|
|
2693
|
+
function IndexFromMappedKey(type, mappedKey, options) {
|
|
2694
|
+
const properties = MappedIndexProperties(type, mappedKey, options);
|
|
2695
|
+
return MappedResult(properties);
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
// node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
|
|
2699
|
+
function Iterator(items, options) {
|
|
2700
|
+
return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
// node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
|
|
2704
|
+
function RequiredArray(properties) {
|
|
2705
|
+
return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
|
|
2706
|
+
}
|
|
2707
|
+
function _Object(properties, options) {
|
|
2708
|
+
const required = RequiredArray(properties);
|
|
2709
|
+
const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
|
|
2710
|
+
return CreateType(schema, options);
|
|
2711
|
+
}
|
|
2712
|
+
var Object2 = _Object;
|
|
2713
|
+
|
|
2714
|
+
// node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
|
|
2715
|
+
function Promise2(item, options) {
|
|
2716
|
+
return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
// node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
|
|
2720
|
+
function RemoveReadonly(schema) {
|
|
2721
|
+
return CreateType(Discard(schema, [ReadonlyKind]));
|
|
2722
|
+
}
|
|
2723
|
+
function AddReadonly(schema) {
|
|
2724
|
+
return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
|
|
2725
|
+
}
|
|
2726
|
+
function ReadonlyWithFlag(schema, F) {
|
|
2727
|
+
return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
|
|
2728
|
+
}
|
|
2729
|
+
function Readonly(schema, enable) {
|
|
2730
|
+
const F = enable ?? true;
|
|
2731
|
+
return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
// node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
|
|
2735
|
+
function FromProperties2(K, F) {
|
|
2736
|
+
const Acc = {};
|
|
2737
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
2738
|
+
Acc[K2] = Readonly(K[K2], F);
|
|
2739
|
+
return Acc;
|
|
2740
|
+
}
|
|
2741
|
+
function FromMappedResult2(R, F) {
|
|
2742
|
+
return FromProperties2(R.properties, F);
|
|
2743
|
+
}
|
|
2744
|
+
function ReadonlyFromMappedResult(R, F) {
|
|
2745
|
+
const P = FromMappedResult2(R, F);
|
|
2746
|
+
return MappedResult(P);
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
// node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
|
|
2750
|
+
function Tuple(types, options) {
|
|
2751
|
+
return CreateType(types.length > 0 ? { [Kind]: "Tuple", type: "array", items: types, additionalItems: false, minItems: types.length, maxItems: types.length } : { [Kind]: "Tuple", type: "array", minItems: types.length, maxItems: types.length }, options);
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
// node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
|
|
2755
|
+
function FromMappedResult3(K, P) {
|
|
2756
|
+
return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
|
|
2757
|
+
}
|
|
2758
|
+
function MappedKeyToKnownMappedResultProperties(K) {
|
|
2759
|
+
return { [K]: Literal(K) };
|
|
2760
|
+
}
|
|
2761
|
+
function MappedKeyToUnknownMappedResultProperties(P) {
|
|
2762
|
+
const Acc = {};
|
|
2763
|
+
for (const L of P)
|
|
2764
|
+
Acc[L] = Literal(L);
|
|
2765
|
+
return Acc;
|
|
2766
|
+
}
|
|
2767
|
+
function MappedKeyToMappedResultProperties(K, P) {
|
|
2768
|
+
return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
|
|
2769
|
+
}
|
|
2770
|
+
function FromMappedKey(K, P) {
|
|
2771
|
+
const R = MappedKeyToMappedResultProperties(K, P);
|
|
2772
|
+
return FromMappedResult3(K, R);
|
|
2773
|
+
}
|
|
2774
|
+
function FromRest2(K, T) {
|
|
2775
|
+
return T.map((L) => FromSchemaType(K, L));
|
|
2776
|
+
}
|
|
2777
|
+
function FromProperties3(K, T) {
|
|
2778
|
+
const Acc = {};
|
|
2779
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(T))
|
|
2780
|
+
Acc[K2] = FromSchemaType(K, T[K2]);
|
|
2781
|
+
return Acc;
|
|
2782
|
+
}
|
|
2783
|
+
function FromSchemaType(K, T) {
|
|
2784
|
+
const options = { ...T };
|
|
2785
|
+
return (
|
|
2786
|
+
// unevaluated modifier types
|
|
2787
|
+
IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
|
|
2788
|
+
// unevaluated mapped types
|
|
2789
|
+
IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
|
|
2790
|
+
// unevaluated types
|
|
2791
|
+
IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction2(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator2(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator2(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect(T) ? Intersect(FromRest2(K, T.allOf), options) : IsUnion(T) ? Union(FromRest2(K, T.anyOf), options) : IsTuple(T) ? Tuple(FromRest2(K, T.items ?? []), options) : IsObject3(T) ? Object2(FromProperties3(K, T.properties), options) : IsArray3(T) ? Array2(FromSchemaType(K, T.items), options) : IsPromise(T) ? Promise2(FromSchemaType(K, T.item), options) : T
|
|
2792
|
+
)
|
|
2793
|
+
)
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2796
|
+
function MappedFunctionReturnType(K, T) {
|
|
2797
|
+
const Acc = {};
|
|
2798
|
+
for (const L of K)
|
|
2799
|
+
Acc[L] = FromSchemaType(L, T);
|
|
2800
|
+
return Acc;
|
|
2801
|
+
}
|
|
2802
|
+
function Mapped(key, map, options) {
|
|
2803
|
+
const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
2804
|
+
const RT = map({ [Kind]: "MappedKey", keys: K });
|
|
2805
|
+
const R = MappedFunctionReturnType(K, RT);
|
|
2806
|
+
return Object2(R, options);
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
// node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
|
|
2810
|
+
function RemoveOptional(schema) {
|
|
2811
|
+
return CreateType(Discard(schema, [OptionalKind]));
|
|
2812
|
+
}
|
|
2813
|
+
function AddOptional(schema) {
|
|
2814
|
+
return CreateType({ ...schema, [OptionalKind]: "Optional" });
|
|
2815
|
+
}
|
|
2816
|
+
function OptionalWithFlag(schema, F) {
|
|
2817
|
+
return F === false ? RemoveOptional(schema) : AddOptional(schema);
|
|
2818
|
+
}
|
|
2819
|
+
function Optional(schema, enable) {
|
|
2820
|
+
const F = enable ?? true;
|
|
2821
|
+
return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
// node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
|
|
2825
|
+
function FromProperties4(P, F) {
|
|
2826
|
+
const Acc = {};
|
|
2827
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
2828
|
+
Acc[K2] = Optional(P[K2], F);
|
|
2829
|
+
return Acc;
|
|
2830
|
+
}
|
|
2831
|
+
function FromMappedResult4(R, F) {
|
|
2832
|
+
return FromProperties4(R.properties, F);
|
|
2833
|
+
}
|
|
2834
|
+
function OptionalFromMappedResult(R, F) {
|
|
2835
|
+
const P = FromMappedResult4(R, F);
|
|
2836
|
+
return MappedResult(P);
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
|
|
2840
|
+
function IntersectCreate(T, options = {}) {
|
|
2841
|
+
const allObjects = T.every((schema) => IsObject3(schema));
|
|
2842
|
+
const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
|
|
2843
|
+
return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
|
|
2847
|
+
function IsIntersectOptional(types) {
|
|
2848
|
+
return types.every((left) => IsOptional(left));
|
|
2849
|
+
}
|
|
2850
|
+
function RemoveOptionalFromType2(type) {
|
|
2851
|
+
return Discard(type, [OptionalKind]);
|
|
2852
|
+
}
|
|
2853
|
+
function RemoveOptionalFromRest2(types) {
|
|
2854
|
+
return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
|
|
2855
|
+
}
|
|
2856
|
+
function ResolveIntersect(types, options) {
|
|
2857
|
+
return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
|
|
2858
|
+
}
|
|
2859
|
+
function IntersectEvaluated(types, options = {}) {
|
|
2860
|
+
if (types.length === 1)
|
|
2861
|
+
return CreateType(types[0], options);
|
|
2862
|
+
if (types.length === 0)
|
|
2863
|
+
return Never(options);
|
|
2864
|
+
if (types.some((schema) => IsTransform(schema)))
|
|
2865
|
+
throw new Error("Cannot intersect transform types");
|
|
2866
|
+
return ResolveIntersect(types, options);
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
|
|
2870
|
+
function Intersect(types, options) {
|
|
2871
|
+
if (types.length === 1)
|
|
2872
|
+
return CreateType(types[0], options);
|
|
2873
|
+
if (types.length === 0)
|
|
2874
|
+
return Never(options);
|
|
2875
|
+
if (types.some((schema) => IsTransform(schema)))
|
|
2876
|
+
throw new Error("Cannot intersect transform types");
|
|
2877
|
+
return IntersectCreate(types, options);
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
// node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
|
|
2881
|
+
function Ref(...args) {
|
|
2882
|
+
const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
|
|
2883
|
+
if (typeof $ref !== "string")
|
|
2884
|
+
throw new TypeBoxError("Ref: $ref must be a string");
|
|
2885
|
+
return CreateType({ [Kind]: "Ref", $ref }, options);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
// node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
|
|
2889
|
+
function FromComputed(target, parameters) {
|
|
2890
|
+
return Computed("Awaited", [Computed(target, parameters)]);
|
|
2891
|
+
}
|
|
2892
|
+
function FromRef($ref) {
|
|
2893
|
+
return Computed("Awaited", [Ref($ref)]);
|
|
2894
|
+
}
|
|
2895
|
+
function FromIntersect2(types) {
|
|
2896
|
+
return Intersect(FromRest3(types));
|
|
2897
|
+
}
|
|
2898
|
+
function FromUnion4(types) {
|
|
2899
|
+
return Union(FromRest3(types));
|
|
2900
|
+
}
|
|
2901
|
+
function FromPromise(type) {
|
|
2902
|
+
return Awaited(type);
|
|
2903
|
+
}
|
|
2904
|
+
function FromRest3(types) {
|
|
2905
|
+
return types.map((type) => Awaited(type));
|
|
2906
|
+
}
|
|
2907
|
+
function Awaited(type, options) {
|
|
2908
|
+
return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
|
|
2912
|
+
function FromRest4(types) {
|
|
2913
|
+
const result = [];
|
|
2914
|
+
for (const L of types)
|
|
2915
|
+
result.push(KeyOfPropertyKeys(L));
|
|
2916
|
+
return result;
|
|
2917
|
+
}
|
|
2918
|
+
function FromIntersect3(types) {
|
|
2919
|
+
const propertyKeysArray = FromRest4(types);
|
|
2920
|
+
const propertyKeys = SetUnionMany(propertyKeysArray);
|
|
2921
|
+
return propertyKeys;
|
|
2922
|
+
}
|
|
2923
|
+
function FromUnion5(types) {
|
|
2924
|
+
const propertyKeysArray = FromRest4(types);
|
|
2925
|
+
const propertyKeys = SetIntersectMany(propertyKeysArray);
|
|
2926
|
+
return propertyKeys;
|
|
2927
|
+
}
|
|
2928
|
+
function FromTuple2(types) {
|
|
2929
|
+
return types.map((_, indexer) => indexer.toString());
|
|
2930
|
+
}
|
|
2931
|
+
function FromArray2(_) {
|
|
2932
|
+
return ["[number]"];
|
|
2933
|
+
}
|
|
2934
|
+
function FromProperties5(T) {
|
|
2935
|
+
return globalThis.Object.getOwnPropertyNames(T);
|
|
2936
|
+
}
|
|
2937
|
+
function FromPatternProperties(patternProperties) {
|
|
2938
|
+
if (!includePatternProperties)
|
|
2939
|
+
return [];
|
|
2940
|
+
const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
|
|
2941
|
+
return patternPropertyKeys.map((key) => {
|
|
2942
|
+
return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
function KeyOfPropertyKeys(type) {
|
|
2946
|
+
return IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion5(type.anyOf) : IsTuple(type) ? FromTuple2(type.items ?? []) : IsArray3(type) ? FromArray2(type.items) : IsObject3(type) ? FromProperties5(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
|
|
2947
|
+
}
|
|
2948
|
+
var includePatternProperties = false;
|
|
2949
|
+
|
|
2950
|
+
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
|
|
2951
|
+
function FromComputed2(target, parameters) {
|
|
2952
|
+
return Computed("KeyOf", [Computed(target, parameters)]);
|
|
2953
|
+
}
|
|
2954
|
+
function FromRef2($ref) {
|
|
2955
|
+
return Computed("KeyOf", [Ref($ref)]);
|
|
2956
|
+
}
|
|
2957
|
+
function KeyOfFromType(type, options) {
|
|
2958
|
+
const propertyKeys = KeyOfPropertyKeys(type);
|
|
2959
|
+
const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
|
|
2960
|
+
const result = UnionEvaluated(propertyKeyTypes);
|
|
2961
|
+
return CreateType(result, options);
|
|
2962
|
+
}
|
|
2963
|
+
function KeyOfPropertyKeysToRest(propertyKeys) {
|
|
2964
|
+
return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
|
|
2965
|
+
}
|
|
2966
|
+
function KeyOf(type, options) {
|
|
2967
|
+
return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
|
|
2971
|
+
function FromProperties6(properties, options) {
|
|
2972
|
+
const result = {};
|
|
2973
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
2974
|
+
result[K2] = KeyOf(properties[K2], Clone(options));
|
|
2975
|
+
return result;
|
|
2976
|
+
}
|
|
2977
|
+
function FromMappedResult5(mappedResult, options) {
|
|
2978
|
+
return FromProperties6(mappedResult.properties, options);
|
|
2979
|
+
}
|
|
2980
|
+
function KeyOfFromMappedResult(mappedResult, options) {
|
|
2981
|
+
const properties = FromMappedResult5(mappedResult, options);
|
|
2982
|
+
return MappedResult(properties);
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
// node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
|
|
2986
|
+
function CompositeKeys(T) {
|
|
2987
|
+
const Acc = [];
|
|
2988
|
+
for (const L of T)
|
|
2989
|
+
Acc.push(...KeyOfPropertyKeys(L));
|
|
2990
|
+
return SetDistinct(Acc);
|
|
2991
|
+
}
|
|
2992
|
+
function FilterNever(T) {
|
|
2993
|
+
return T.filter((L) => !IsNever(L));
|
|
2994
|
+
}
|
|
2995
|
+
function CompositeProperty(T, K) {
|
|
2996
|
+
const Acc = [];
|
|
2997
|
+
for (const L of T)
|
|
2998
|
+
Acc.push(...IndexFromPropertyKeys(L, [K]));
|
|
2999
|
+
return FilterNever(Acc);
|
|
3000
|
+
}
|
|
3001
|
+
function CompositeProperties(T, K) {
|
|
3002
|
+
const Acc = {};
|
|
3003
|
+
for (const L of K) {
|
|
3004
|
+
Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
|
|
3005
|
+
}
|
|
3006
|
+
return Acc;
|
|
3007
|
+
}
|
|
3008
|
+
function Composite(T, options) {
|
|
3009
|
+
const K = CompositeKeys(T);
|
|
3010
|
+
const P = CompositeProperties(T, K);
|
|
3011
|
+
const R = Object2(P, options);
|
|
3012
|
+
return R;
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
// node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
|
|
3016
|
+
function Date2(options) {
|
|
3017
|
+
return CreateType({ [Kind]: "Date", type: "Date" }, options);
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
// node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
|
|
3021
|
+
function Null(options) {
|
|
3022
|
+
return CreateType({ [Kind]: "Null", type: "null" }, options);
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
// node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
|
|
3026
|
+
function Symbol2(options) {
|
|
3027
|
+
return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
// node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
|
|
3031
|
+
function Undefined(options) {
|
|
3032
|
+
return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
// node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
|
|
3036
|
+
function Uint8Array2(options) {
|
|
3037
|
+
return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
// node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
|
|
3041
|
+
function Unknown(options) {
|
|
3042
|
+
return CreateType({ [Kind]: "Unknown" }, options);
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
// node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
|
|
3046
|
+
function FromArray3(T) {
|
|
3047
|
+
return T.map((L) => FromValue(L, false));
|
|
3048
|
+
}
|
|
3049
|
+
function FromProperties7(value) {
|
|
3050
|
+
const Acc = {};
|
|
3051
|
+
for (const K of globalThis.Object.getOwnPropertyNames(value))
|
|
3052
|
+
Acc[K] = Readonly(FromValue(value[K], false));
|
|
3053
|
+
return Acc;
|
|
3054
|
+
}
|
|
3055
|
+
function ConditionalReadonly(T, root) {
|
|
3056
|
+
return root === true ? T : Readonly(T);
|
|
3057
|
+
}
|
|
3058
|
+
function FromValue(value, root) {
|
|
3059
|
+
return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ? BigInt() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
|
|
3060
|
+
}
|
|
3061
|
+
function Const(T, options) {
|
|
3062
|
+
return CreateType(FromValue(T, true), options);
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
// node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
|
|
3066
|
+
function ConstructorParameters(schema, options) {
|
|
3067
|
+
return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
|
|
3071
|
+
function Enum(item, options) {
|
|
3072
|
+
if (IsUndefined(item))
|
|
3073
|
+
throw new Error("Enum undefined or empty");
|
|
3074
|
+
const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
|
|
3075
|
+
const values2 = [...new Set(values1)];
|
|
3076
|
+
const anyOf = values2.map((value) => Literal(value));
|
|
3077
|
+
return Union(anyOf, { ...options, [Hint]: "Enum" });
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
|
|
3081
|
+
var ExtendsResolverError = class extends TypeBoxError {
|
|
3082
|
+
};
|
|
3083
|
+
var ExtendsResult;
|
|
3084
|
+
(function(ExtendsResult2) {
|
|
3085
|
+
ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
|
|
3086
|
+
ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
|
|
3087
|
+
ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
|
|
3088
|
+
})(ExtendsResult || (ExtendsResult = {}));
|
|
3089
|
+
function IntoBooleanResult(result) {
|
|
3090
|
+
return result === ExtendsResult.False ? result : ExtendsResult.True;
|
|
3091
|
+
}
|
|
3092
|
+
function Throw(message) {
|
|
3093
|
+
throw new ExtendsResolverError(message);
|
|
3094
|
+
}
|
|
3095
|
+
function IsStructuralRight(right) {
|
|
3096
|
+
return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
|
|
3097
|
+
}
|
|
3098
|
+
function StructuralRight(left, right) {
|
|
3099
|
+
return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
|
|
3100
|
+
}
|
|
3101
|
+
function FromAnyRight(left, right) {
|
|
3102
|
+
return ExtendsResult.True;
|
|
3103
|
+
}
|
|
3104
|
+
function FromAny(left, right) {
|
|
3105
|
+
return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) && right.anyOf.some((schema) => type_exports.IsAny(schema) || type_exports.IsUnknown(schema)) ? ExtendsResult.True : type_exports.IsUnion(right) ? ExtendsResult.Union : type_exports.IsUnknown(right) ? ExtendsResult.True : type_exports.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
|
|
3106
|
+
}
|
|
3107
|
+
function FromArrayRight(left, right) {
|
|
3108
|
+
return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
3109
|
+
}
|
|
3110
|
+
function FromArray4(left, right) {
|
|
3111
|
+
return type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
3112
|
+
}
|
|
3113
|
+
function FromAsyncIterator(left, right) {
|
|
3114
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
3115
|
+
}
|
|
3116
|
+
function FromBigInt(left, right) {
|
|
3117
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3118
|
+
}
|
|
3119
|
+
function FromBooleanRight(left, right) {
|
|
3120
|
+
return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
3121
|
+
}
|
|
3122
|
+
function FromBoolean(left, right) {
|
|
3123
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3124
|
+
}
|
|
3125
|
+
function FromConstructor(left, right) {
|
|
3126
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
|
|
3127
|
+
}
|
|
3128
|
+
function FromDate(left, right) {
|
|
3129
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3130
|
+
}
|
|
3131
|
+
function FromFunction(left, right) {
|
|
3132
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
|
|
3133
|
+
}
|
|
3134
|
+
function FromIntegerRight(left, right) {
|
|
3135
|
+
return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
3136
|
+
}
|
|
3137
|
+
function FromInteger(left, right) {
|
|
3138
|
+
return type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
|
|
3139
|
+
}
|
|
3140
|
+
function FromIntersectRight(left, right) {
|
|
3141
|
+
return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
3142
|
+
}
|
|
3143
|
+
function FromIntersect4(left, right) {
|
|
3144
|
+
return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
3145
|
+
}
|
|
3146
|
+
function FromIterator(left, right) {
|
|
3147
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
3148
|
+
}
|
|
3149
|
+
function FromLiteral2(left, right) {
|
|
3150
|
+
return type_exports.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
|
|
3151
|
+
}
|
|
3152
|
+
function FromNeverRight(left, right) {
|
|
3153
|
+
return ExtendsResult.False;
|
|
3154
|
+
}
|
|
3155
|
+
function FromNever(left, right) {
|
|
3156
|
+
return ExtendsResult.True;
|
|
3157
|
+
}
|
|
3158
|
+
function UnwrapTNot(schema) {
|
|
3159
|
+
let [current, depth] = [schema, 0];
|
|
3160
|
+
while (true) {
|
|
3161
|
+
if (!type_exports.IsNot(current))
|
|
3162
|
+
break;
|
|
3163
|
+
current = current.not;
|
|
3164
|
+
depth += 1;
|
|
3165
|
+
}
|
|
3166
|
+
return depth % 2 === 0 ? current : Unknown();
|
|
3167
|
+
}
|
|
3168
|
+
function FromNot(left, right) {
|
|
3169
|
+
return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
|
|
3170
|
+
}
|
|
3171
|
+
function FromNull(left, right) {
|
|
3172
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3173
|
+
}
|
|
3174
|
+
function FromNumberRight(left, right) {
|
|
3175
|
+
return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
3176
|
+
}
|
|
3177
|
+
function FromNumber(left, right) {
|
|
3178
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3179
|
+
}
|
|
3180
|
+
function IsObjectPropertyCount(schema, count) {
|
|
3181
|
+
return Object.getOwnPropertyNames(schema.properties).length === count;
|
|
3182
|
+
}
|
|
3183
|
+
function IsObjectStringLike(schema) {
|
|
3184
|
+
return IsObjectArrayLike(schema);
|
|
3185
|
+
}
|
|
3186
|
+
function IsObjectSymbolLike(schema) {
|
|
3187
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && type_exports.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (type_exports.IsString(schema.properties.description.anyOf[0]) && type_exports.IsUndefined(schema.properties.description.anyOf[1]) || type_exports.IsString(schema.properties.description.anyOf[1]) && type_exports.IsUndefined(schema.properties.description.anyOf[0]));
|
|
3188
|
+
}
|
|
3189
|
+
function IsObjectNumberLike(schema) {
|
|
3190
|
+
return IsObjectPropertyCount(schema, 0);
|
|
3191
|
+
}
|
|
3192
|
+
function IsObjectBooleanLike(schema) {
|
|
3193
|
+
return IsObjectPropertyCount(schema, 0);
|
|
3194
|
+
}
|
|
3195
|
+
function IsObjectBigIntLike(schema) {
|
|
3196
|
+
return IsObjectPropertyCount(schema, 0);
|
|
3197
|
+
}
|
|
3198
|
+
function IsObjectDateLike(schema) {
|
|
3199
|
+
return IsObjectPropertyCount(schema, 0);
|
|
3200
|
+
}
|
|
3201
|
+
function IsObjectUint8ArrayLike(schema) {
|
|
3202
|
+
return IsObjectArrayLike(schema);
|
|
3203
|
+
}
|
|
3204
|
+
function IsObjectFunctionLike(schema) {
|
|
3205
|
+
const length = Number2();
|
|
3206
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
|
|
3207
|
+
}
|
|
3208
|
+
function IsObjectConstructorLike(schema) {
|
|
3209
|
+
return IsObjectPropertyCount(schema, 0);
|
|
3210
|
+
}
|
|
3211
|
+
function IsObjectArrayLike(schema) {
|
|
3212
|
+
const length = Number2();
|
|
3213
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
|
|
3214
|
+
}
|
|
3215
|
+
function IsObjectPromiseLike(schema) {
|
|
3216
|
+
const then = Function([Any()], Any());
|
|
3217
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
|
|
3218
|
+
}
|
|
3219
|
+
function Property(left, right) {
|
|
3220
|
+
return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
|
|
3221
|
+
}
|
|
3222
|
+
function FromObjectRight(left, right) {
|
|
3223
|
+
return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) || type_exports.IsLiteralString(left) && IsObjectStringLike(right) || type_exports.IsLiteralNumber(left) && IsObjectNumberLike(right) || type_exports.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsBigInt(left) && IsObjectBigIntLike(right) || type_exports.IsString(left) && IsObjectStringLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsNumber(left) && IsObjectNumberLike(right) || type_exports.IsInteger(left) && IsObjectNumberLike(right) || type_exports.IsBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || type_exports.IsDate(left) && IsObjectDateLike(right) || type_exports.IsConstructor(left) && IsObjectConstructorLike(right) || type_exports.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : type_exports.IsRecord(left) && type_exports.IsString(RecordKey(left)) ? (() => {
|
|
3224
|
+
return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
|
|
3225
|
+
})() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
|
|
3226
|
+
return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
|
|
3227
|
+
})() : ExtendsResult.False;
|
|
3228
|
+
}
|
|
3229
|
+
function FromObject(left, right) {
|
|
3230
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
|
|
3231
|
+
for (const key of Object.getOwnPropertyNames(right.properties)) {
|
|
3232
|
+
if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
|
|
3233
|
+
return ExtendsResult.False;
|
|
3234
|
+
}
|
|
3235
|
+
if (type_exports.IsOptional(right.properties[key])) {
|
|
3236
|
+
return ExtendsResult.True;
|
|
3237
|
+
}
|
|
3238
|
+
if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
|
|
3239
|
+
return ExtendsResult.False;
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
return ExtendsResult.True;
|
|
3243
|
+
})();
|
|
3244
|
+
}
|
|
3245
|
+
function FromPromise2(left, right) {
|
|
3246
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !type_exports.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
|
|
3247
|
+
}
|
|
3248
|
+
function RecordKey(schema) {
|
|
3249
|
+
return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
|
|
3250
|
+
}
|
|
3251
|
+
function RecordValue(schema) {
|
|
3252
|
+
return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
|
|
3253
|
+
}
|
|
3254
|
+
function FromRecordRight(left, right) {
|
|
3255
|
+
const [Key, Value] = [RecordKey(right), RecordValue(right)];
|
|
3256
|
+
return type_exports.IsLiteralString(left) && type_exports.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : type_exports.IsUint8Array(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsString(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsArray(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsObject(left) ? (() => {
|
|
3257
|
+
for (const key of Object.getOwnPropertyNames(left.properties)) {
|
|
3258
|
+
if (Property(Value, left.properties[key]) === ExtendsResult.False) {
|
|
3259
|
+
return ExtendsResult.False;
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
return ExtendsResult.True;
|
|
3263
|
+
})() : ExtendsResult.False;
|
|
3264
|
+
}
|
|
3265
|
+
function FromRecord(left, right) {
|
|
3266
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
|
|
3267
|
+
}
|
|
3268
|
+
function FromRegExp(left, right) {
|
|
3269
|
+
const L = type_exports.IsRegExp(left) ? String2() : left;
|
|
3270
|
+
const R = type_exports.IsRegExp(right) ? String2() : right;
|
|
3271
|
+
return Visit3(L, R);
|
|
3272
|
+
}
|
|
3273
|
+
function FromStringRight(left, right) {
|
|
3274
|
+
return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
3275
|
+
}
|
|
3276
|
+
function FromString(left, right) {
|
|
3277
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3278
|
+
}
|
|
3279
|
+
function FromSymbol(left, right) {
|
|
3280
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3281
|
+
}
|
|
3282
|
+
function FromTemplateLiteral2(left, right) {
|
|
3283
|
+
return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
|
|
3284
|
+
}
|
|
3285
|
+
function IsArrayOfTuple(left, right) {
|
|
3286
|
+
return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
|
|
3287
|
+
}
|
|
3288
|
+
function FromTupleRight(left, right) {
|
|
3289
|
+
return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
|
|
3290
|
+
}
|
|
3291
|
+
function FromTuple3(left, right) {
|
|
3292
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : type_exports.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !type_exports.IsTuple(right) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) || !value_exports.IsUndefined(left.items) && value_exports.IsUndefined(right.items) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit3(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
3293
|
+
}
|
|
3294
|
+
function FromUint8Array(left, right) {
|
|
3295
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3296
|
+
}
|
|
3297
|
+
function FromUndefined(left, right) {
|
|
3298
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsVoid(right) ? FromVoidRight(left, right) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3299
|
+
}
|
|
3300
|
+
function FromUnionRight(left, right) {
|
|
3301
|
+
return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
3302
|
+
}
|
|
3303
|
+
function FromUnion6(left, right) {
|
|
3304
|
+
return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
3305
|
+
}
|
|
3306
|
+
function FromUnknownRight(left, right) {
|
|
3307
|
+
return ExtendsResult.True;
|
|
3308
|
+
}
|
|
3309
|
+
function FromUnknown(left, right) {
|
|
3310
|
+
return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : type_exports.IsArray(right) ? FromArrayRight(left, right) : type_exports.IsTuple(right) ? FromTupleRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3311
|
+
}
|
|
3312
|
+
function FromVoidRight(left, right) {
|
|
3313
|
+
return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
3314
|
+
}
|
|
3315
|
+
function FromVoid(left, right) {
|
|
3316
|
+
return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
3317
|
+
}
|
|
3318
|
+
function Visit3(left, right) {
|
|
3319
|
+
return (
|
|
3320
|
+
// resolvable
|
|
3321
|
+
type_exports.IsTemplateLiteral(left) || type_exports.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : type_exports.IsRegExp(left) || type_exports.IsRegExp(right) ? FromRegExp(left, right) : type_exports.IsNot(left) || type_exports.IsNot(right) ? FromNot(left, right) : (
|
|
3322
|
+
// standard
|
|
3323
|
+
type_exports.IsAny(left) ? FromAny(left, right) : type_exports.IsArray(left) ? FromArray4(left, right) : type_exports.IsBigInt(left) ? FromBigInt(left, right) : type_exports.IsBoolean(left) ? FromBoolean(left, right) : type_exports.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : type_exports.IsConstructor(left) ? FromConstructor(left, right) : type_exports.IsDate(left) ? FromDate(left, right) : type_exports.IsFunction(left) ? FromFunction(left, right) : type_exports.IsInteger(left) ? FromInteger(left, right) : type_exports.IsIntersect(left) ? FromIntersect4(left, right) : type_exports.IsIterator(left) ? FromIterator(left, right) : type_exports.IsLiteral(left) ? FromLiteral2(left, right) : type_exports.IsNever(left) ? FromNever(left, right) : type_exports.IsNull(left) ? FromNull(left, right) : type_exports.IsNumber(left) ? FromNumber(left, right) : type_exports.IsObject(left) ? FromObject(left, right) : type_exports.IsRecord(left) ? FromRecord(left, right) : type_exports.IsString(left) ? FromString(left, right) : type_exports.IsSymbol(left) ? FromSymbol(left, right) : type_exports.IsTuple(left) ? FromTuple3(left, right) : type_exports.IsPromise(left) ? FromPromise2(left, right) : type_exports.IsUint8Array(left) ? FromUint8Array(left, right) : type_exports.IsUndefined(left) ? FromUndefined(left, right) : type_exports.IsUnion(left) ? FromUnion6(left, right) : type_exports.IsUnknown(left) ? FromUnknown(left, right) : type_exports.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`)
|
|
3324
|
+
)
|
|
3325
|
+
);
|
|
3326
|
+
}
|
|
3327
|
+
function ExtendsCheck(left, right) {
|
|
3328
|
+
return Visit3(left, right);
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
|
|
3332
|
+
function FromProperties8(P, Right, True, False, options) {
|
|
3333
|
+
const Acc = {};
|
|
3334
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
3335
|
+
Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
|
|
3336
|
+
return Acc;
|
|
3337
|
+
}
|
|
3338
|
+
function FromMappedResult6(Left, Right, True, False, options) {
|
|
3339
|
+
return FromProperties8(Left.properties, Right, True, False, options);
|
|
3340
|
+
}
|
|
3341
|
+
function ExtendsFromMappedResult(Left, Right, True, False, options) {
|
|
3342
|
+
const P = FromMappedResult6(Left, Right, True, False, options);
|
|
3343
|
+
return MappedResult(P);
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
|
|
3347
|
+
function ExtendsResolve(left, right, trueType, falseType) {
|
|
3348
|
+
const R = ExtendsCheck(left, right);
|
|
3349
|
+
return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
|
|
3350
|
+
}
|
|
3351
|
+
function Extends(L, R, T, F, options) {
|
|
3352
|
+
return IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
|
|
3356
|
+
function FromPropertyKey(K, U, L, R, options) {
|
|
3357
|
+
return {
|
|
3358
|
+
[K]: Extends(Literal(K), U, L, R, Clone(options))
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3361
|
+
function FromPropertyKeys(K, U, L, R, options) {
|
|
3362
|
+
return K.reduce((Acc, LK) => {
|
|
3363
|
+
return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
|
|
3364
|
+
}, {});
|
|
3365
|
+
}
|
|
3366
|
+
function FromMappedKey2(K, U, L, R, options) {
|
|
3367
|
+
return FromPropertyKeys(K.keys, U, L, R, options);
|
|
3368
|
+
}
|
|
3369
|
+
function ExtendsFromMappedKey(T, U, L, R, options) {
|
|
3370
|
+
const P = FromMappedKey2(T, U, L, R, options);
|
|
3371
|
+
return MappedResult(P);
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
|
|
3375
|
+
function ExcludeFromTemplateLiteral(L, R) {
|
|
3376
|
+
return Exclude(TemplateLiteralToUnion(L), R);
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
|
|
3380
|
+
function ExcludeRest(L, R) {
|
|
3381
|
+
const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
|
|
3382
|
+
return excluded.length === 1 ? excluded[0] : Union(excluded);
|
|
3383
|
+
}
|
|
3384
|
+
function Exclude(L, R, options = {}) {
|
|
3385
|
+
if (IsTemplateLiteral(L))
|
|
3386
|
+
return CreateType(ExcludeFromTemplateLiteral(L, R), options);
|
|
3387
|
+
if (IsMappedResult(L))
|
|
3388
|
+
return CreateType(ExcludeFromMappedResult(L, R), options);
|
|
3389
|
+
return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
|
|
3393
|
+
function FromProperties9(P, U) {
|
|
3394
|
+
const Acc = {};
|
|
3395
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
3396
|
+
Acc[K2] = Exclude(P[K2], U);
|
|
3397
|
+
return Acc;
|
|
3398
|
+
}
|
|
3399
|
+
function FromMappedResult7(R, T) {
|
|
3400
|
+
return FromProperties9(R.properties, T);
|
|
3401
|
+
}
|
|
3402
|
+
function ExcludeFromMappedResult(R, T) {
|
|
3403
|
+
const P = FromMappedResult7(R, T);
|
|
3404
|
+
return MappedResult(P);
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
// node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
|
|
3408
|
+
function ExtractFromTemplateLiteral(L, R) {
|
|
3409
|
+
return Extract(TemplateLiteralToUnion(L), R);
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
// node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
|
|
3413
|
+
function ExtractRest(L, R) {
|
|
3414
|
+
const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
|
|
3415
|
+
return extracted.length === 1 ? extracted[0] : Union(extracted);
|
|
3416
|
+
}
|
|
3417
|
+
function Extract(L, R, options) {
|
|
3418
|
+
if (IsTemplateLiteral(L))
|
|
3419
|
+
return CreateType(ExtractFromTemplateLiteral(L, R), options);
|
|
3420
|
+
if (IsMappedResult(L))
|
|
3421
|
+
return CreateType(ExtractFromMappedResult(L, R), options);
|
|
3422
|
+
return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
// node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
|
|
3426
|
+
function FromProperties10(P, T) {
|
|
3427
|
+
const Acc = {};
|
|
3428
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
3429
|
+
Acc[K2] = Extract(P[K2], T);
|
|
3430
|
+
return Acc;
|
|
3431
|
+
}
|
|
3432
|
+
function FromMappedResult8(R, T) {
|
|
3433
|
+
return FromProperties10(R.properties, T);
|
|
3434
|
+
}
|
|
3435
|
+
function ExtractFromMappedResult(R, T) {
|
|
3436
|
+
const P = FromMappedResult8(R, T);
|
|
3437
|
+
return MappedResult(P);
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
// node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
|
|
3441
|
+
function InstanceType(schema, options) {
|
|
3442
|
+
return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
// node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
|
|
3446
|
+
function ReadonlyOptional(schema) {
|
|
3447
|
+
return Readonly(Optional(schema));
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
// node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
|
|
3451
|
+
function RecordCreateFromPattern(pattern, T, options) {
|
|
3452
|
+
return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
|
|
3453
|
+
}
|
|
3454
|
+
function RecordCreateFromKeys(K, T, options) {
|
|
3455
|
+
const result = {};
|
|
3456
|
+
for (const K2 of K)
|
|
3457
|
+
result[K2] = T;
|
|
3458
|
+
return Object2(result, { ...options, [Hint]: "Record" });
|
|
3459
|
+
}
|
|
3460
|
+
function FromTemplateLiteralKey(K, T, options) {
|
|
3461
|
+
return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
|
|
3462
|
+
}
|
|
3463
|
+
function FromUnionKey(key, type, options) {
|
|
3464
|
+
return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
|
|
3465
|
+
}
|
|
3466
|
+
function FromLiteralKey(key, type, options) {
|
|
3467
|
+
return RecordCreateFromKeys([key.toString()], type, options);
|
|
3468
|
+
}
|
|
3469
|
+
function FromRegExpKey(key, type, options) {
|
|
3470
|
+
return RecordCreateFromPattern(key.source, type, options);
|
|
3471
|
+
}
|
|
3472
|
+
function FromStringKey(key, type, options) {
|
|
3473
|
+
const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
|
|
3474
|
+
return RecordCreateFromPattern(pattern, type, options);
|
|
3475
|
+
}
|
|
3476
|
+
function FromAnyKey(_, type, options) {
|
|
3477
|
+
return RecordCreateFromPattern(PatternStringExact, type, options);
|
|
3478
|
+
}
|
|
3479
|
+
function FromNeverKey(_key, type, options) {
|
|
3480
|
+
return RecordCreateFromPattern(PatternNeverExact, type, options);
|
|
3481
|
+
}
|
|
3482
|
+
function FromBooleanKey(_key, type, options) {
|
|
3483
|
+
return Object2({ true: type, false: type }, options);
|
|
3484
|
+
}
|
|
3485
|
+
function FromIntegerKey(_key, type, options) {
|
|
3486
|
+
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
3487
|
+
}
|
|
3488
|
+
function FromNumberKey(_, type, options) {
|
|
3489
|
+
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
3490
|
+
}
|
|
3491
|
+
function Record(key, type, options = {}) {
|
|
3492
|
+
return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean2(key) ? FromBooleanKey(key, type, options) : IsInteger(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString2(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
|
|
3493
|
+
}
|
|
3494
|
+
function RecordPattern(record) {
|
|
3495
|
+
return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
|
|
3496
|
+
}
|
|
3497
|
+
function RecordKey2(type) {
|
|
3498
|
+
const pattern = RecordPattern(type);
|
|
3499
|
+
return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
|
|
3500
|
+
}
|
|
3501
|
+
function RecordValue2(type) {
|
|
3502
|
+
return type.patternProperties[RecordPattern(type)];
|
|
3503
|
+
}
|
|
3504
|
+
|
|
3505
|
+
// node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
|
|
3506
|
+
function FromConstructor2(args, type) {
|
|
3507
|
+
type.parameters = FromTypes(args, type.parameters);
|
|
3508
|
+
type.returns = FromType(args, type.returns);
|
|
3509
|
+
return type;
|
|
3510
|
+
}
|
|
3511
|
+
function FromFunction2(args, type) {
|
|
3512
|
+
type.parameters = FromTypes(args, type.parameters);
|
|
3513
|
+
type.returns = FromType(args, type.returns);
|
|
3514
|
+
return type;
|
|
3515
|
+
}
|
|
3516
|
+
function FromIntersect5(args, type) {
|
|
3517
|
+
type.allOf = FromTypes(args, type.allOf);
|
|
3518
|
+
return type;
|
|
3519
|
+
}
|
|
3520
|
+
function FromUnion7(args, type) {
|
|
3521
|
+
type.anyOf = FromTypes(args, type.anyOf);
|
|
3522
|
+
return type;
|
|
3523
|
+
}
|
|
3524
|
+
function FromTuple4(args, type) {
|
|
3525
|
+
if (IsUndefined(type.items))
|
|
3526
|
+
return type;
|
|
3527
|
+
type.items = FromTypes(args, type.items);
|
|
3528
|
+
return type;
|
|
3529
|
+
}
|
|
3530
|
+
function FromArray5(args, type) {
|
|
3531
|
+
type.items = FromType(args, type.items);
|
|
3532
|
+
return type;
|
|
3533
|
+
}
|
|
3534
|
+
function FromAsyncIterator2(args, type) {
|
|
3535
|
+
type.items = FromType(args, type.items);
|
|
3536
|
+
return type;
|
|
3537
|
+
}
|
|
3538
|
+
function FromIterator2(args, type) {
|
|
3539
|
+
type.items = FromType(args, type.items);
|
|
3540
|
+
return type;
|
|
3541
|
+
}
|
|
3542
|
+
function FromPromise3(args, type) {
|
|
3543
|
+
type.item = FromType(args, type.item);
|
|
3544
|
+
return type;
|
|
3545
|
+
}
|
|
3546
|
+
function FromObject2(args, type) {
|
|
3547
|
+
const mappedProperties = FromProperties11(args, type.properties);
|
|
3548
|
+
return { ...type, ...Object2(mappedProperties) };
|
|
3549
|
+
}
|
|
3550
|
+
function FromRecord2(args, type) {
|
|
3551
|
+
const mappedKey = FromType(args, RecordKey2(type));
|
|
3552
|
+
const mappedValue = FromType(args, RecordValue2(type));
|
|
3553
|
+
const result = Record(mappedKey, mappedValue);
|
|
3554
|
+
return { ...type, ...result };
|
|
3555
|
+
}
|
|
3556
|
+
function FromArgument(args, argument) {
|
|
3557
|
+
return argument.index in args ? args[argument.index] : Unknown();
|
|
3558
|
+
}
|
|
3559
|
+
function FromProperty2(args, type) {
|
|
3560
|
+
const isReadonly = IsReadonly(type);
|
|
3561
|
+
const isOptional = IsOptional(type);
|
|
3562
|
+
const mapped = FromType(args, type);
|
|
3563
|
+
return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
|
|
3564
|
+
}
|
|
3565
|
+
function FromProperties11(args, properties) {
|
|
3566
|
+
return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
|
|
3567
|
+
return { ...result, [key]: FromProperty2(args, properties[key]) };
|
|
3568
|
+
}, {});
|
|
3569
|
+
}
|
|
3570
|
+
function FromTypes(args, types) {
|
|
3571
|
+
return types.map((type) => FromType(args, type));
|
|
3572
|
+
}
|
|
3573
|
+
function FromType(args, type) {
|
|
3574
|
+
return IsConstructor(type) ? FromConstructor2(args, type) : IsFunction2(type) ? FromFunction2(args, type) : IsIntersect(type) ? FromIntersect5(args, type) : IsUnion(type) ? FromUnion7(args, type) : IsTuple(type) ? FromTuple4(args, type) : IsArray3(type) ? FromArray5(args, type) : IsAsyncIterator2(type) ? FromAsyncIterator2(args, type) : IsIterator2(type) ? FromIterator2(args, type) : IsPromise(type) ? FromPromise3(args, type) : IsObject3(type) ? FromObject2(args, type) : IsRecord(type) ? FromRecord2(args, type) : IsArgument(type) ? FromArgument(args, type) : type;
|
|
3575
|
+
}
|
|
3576
|
+
function Instantiate(type, args) {
|
|
3577
|
+
return FromType(args, CloneType(type));
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
// node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
|
|
3581
|
+
function Integer(options) {
|
|
3582
|
+
return CreateType({ [Kind]: "Integer", type: "integer" }, options);
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
|
|
3586
|
+
function MappedIntrinsicPropertyKey(K, M, options) {
|
|
3587
|
+
return {
|
|
3588
|
+
[K]: Intrinsic(Literal(K), M, Clone(options))
|
|
3589
|
+
};
|
|
3590
|
+
}
|
|
3591
|
+
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
3592
|
+
const result = K.reduce((Acc, L) => {
|
|
3593
|
+
return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
|
|
3594
|
+
}, {});
|
|
3595
|
+
return result;
|
|
3596
|
+
}
|
|
3597
|
+
function MappedIntrinsicProperties(T, M, options) {
|
|
3598
|
+
return MappedIntrinsicPropertyKeys(T["keys"], M, options);
|
|
3599
|
+
}
|
|
3600
|
+
function IntrinsicFromMappedKey(T, M, options) {
|
|
3601
|
+
const P = MappedIntrinsicProperties(T, M, options);
|
|
3602
|
+
return MappedResult(P);
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
|
|
3606
|
+
function ApplyUncapitalize(value) {
|
|
3607
|
+
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
3608
|
+
return [first.toLowerCase(), rest].join("");
|
|
3609
|
+
}
|
|
3610
|
+
function ApplyCapitalize(value) {
|
|
3611
|
+
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
3612
|
+
return [first.toUpperCase(), rest].join("");
|
|
3613
|
+
}
|
|
3614
|
+
function ApplyUppercase(value) {
|
|
3615
|
+
return value.toUpperCase();
|
|
3616
|
+
}
|
|
3617
|
+
function ApplyLowercase(value) {
|
|
3618
|
+
return value.toLowerCase();
|
|
3619
|
+
}
|
|
3620
|
+
function FromTemplateLiteral3(schema, mode, options) {
|
|
3621
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
3622
|
+
const finite = IsTemplateLiteralExpressionFinite(expression);
|
|
3623
|
+
if (!finite)
|
|
3624
|
+
return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
|
|
3625
|
+
const strings = [...TemplateLiteralExpressionGenerate(expression)];
|
|
3626
|
+
const literals = strings.map((value) => Literal(value));
|
|
3627
|
+
const mapped = FromRest5(literals, mode);
|
|
3628
|
+
const union = Union(mapped);
|
|
3629
|
+
return TemplateLiteral([union], options);
|
|
3630
|
+
}
|
|
3631
|
+
function FromLiteralValue(value, mode) {
|
|
3632
|
+
return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
|
|
3633
|
+
}
|
|
3634
|
+
function FromRest5(T, M) {
|
|
3635
|
+
return T.map((L) => Intrinsic(L, M));
|
|
3636
|
+
}
|
|
3637
|
+
function Intrinsic(schema, mode, options = {}) {
|
|
3638
|
+
return (
|
|
3639
|
+
// Intrinsic-Mapped-Inference
|
|
3640
|
+
IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
|
|
3641
|
+
// Standard-Inference
|
|
3642
|
+
IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
|
|
3643
|
+
// Default Type
|
|
3644
|
+
CreateType(schema, options)
|
|
3645
|
+
)
|
|
3646
|
+
)
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
|
|
3651
|
+
function Capitalize(T, options = {}) {
|
|
3652
|
+
return Intrinsic(T, "Capitalize", options);
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
|
|
3656
|
+
function Lowercase(T, options = {}) {
|
|
3657
|
+
return Intrinsic(T, "Lowercase", options);
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
|
|
3661
|
+
function Uncapitalize(T, options = {}) {
|
|
3662
|
+
return Intrinsic(T, "Uncapitalize", options);
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
|
|
3666
|
+
function Uppercase(T, options = {}) {
|
|
3667
|
+
return Intrinsic(T, "Uppercase", options);
|
|
3668
|
+
}
|
|
3669
|
+
|
|
3670
|
+
// node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
|
|
3671
|
+
function FromProperties12(properties, propertyKeys, options) {
|
|
3672
|
+
const result = {};
|
|
3673
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
3674
|
+
result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
|
|
3675
|
+
return result;
|
|
3676
|
+
}
|
|
3677
|
+
function FromMappedResult9(mappedResult, propertyKeys, options) {
|
|
3678
|
+
return FromProperties12(mappedResult.properties, propertyKeys, options);
|
|
3679
|
+
}
|
|
3680
|
+
function OmitFromMappedResult(mappedResult, propertyKeys, options) {
|
|
3681
|
+
const properties = FromMappedResult9(mappedResult, propertyKeys, options);
|
|
3682
|
+
return MappedResult(properties);
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
// node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
|
|
3686
|
+
function FromIntersect6(types, propertyKeys) {
|
|
3687
|
+
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
3688
|
+
}
|
|
3689
|
+
function FromUnion8(types, propertyKeys) {
|
|
3690
|
+
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
3691
|
+
}
|
|
3692
|
+
function FromProperty3(properties, key) {
|
|
3693
|
+
const { [key]: _, ...R } = properties;
|
|
3694
|
+
return R;
|
|
3695
|
+
}
|
|
3696
|
+
function FromProperties13(properties, propertyKeys) {
|
|
3697
|
+
return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
|
|
3698
|
+
}
|
|
3699
|
+
function FromObject3(type, propertyKeys, properties) {
|
|
3700
|
+
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
3701
|
+
const mappedProperties = FromProperties13(properties, propertyKeys);
|
|
3702
|
+
return Object2(mappedProperties, options);
|
|
3703
|
+
}
|
|
3704
|
+
function UnionFromPropertyKeys(propertyKeys) {
|
|
3705
|
+
const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
|
|
3706
|
+
return Union(result);
|
|
3707
|
+
}
|
|
3708
|
+
function OmitResolve(type, propertyKeys) {
|
|
3709
|
+
return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
|
|
3710
|
+
}
|
|
3711
|
+
function Omit(type, key, options) {
|
|
3712
|
+
const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
|
|
3713
|
+
const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
3714
|
+
const isTypeRef = IsRef(type);
|
|
3715
|
+
const isKeyRef = IsRef(key);
|
|
3716
|
+
return IsMappedResult(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({ ...OmitResolve(type, propertyKeys), ...options });
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
// node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
|
|
3720
|
+
function FromPropertyKey2(type, key, options) {
|
|
3721
|
+
return { [key]: Omit(type, [key], Clone(options)) };
|
|
3722
|
+
}
|
|
3723
|
+
function FromPropertyKeys2(type, propertyKeys, options) {
|
|
3724
|
+
return propertyKeys.reduce((Acc, LK) => {
|
|
3725
|
+
return { ...Acc, ...FromPropertyKey2(type, LK, options) };
|
|
3726
|
+
}, {});
|
|
3727
|
+
}
|
|
3728
|
+
function FromMappedKey3(type, mappedKey, options) {
|
|
3729
|
+
return FromPropertyKeys2(type, mappedKey.keys, options);
|
|
3730
|
+
}
|
|
3731
|
+
function OmitFromMappedKey(type, mappedKey, options) {
|
|
3732
|
+
const properties = FromMappedKey3(type, mappedKey, options);
|
|
3733
|
+
return MappedResult(properties);
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
// node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
|
|
3737
|
+
function FromProperties14(properties, propertyKeys, options) {
|
|
3738
|
+
const result = {};
|
|
3739
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
3740
|
+
result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
|
|
3741
|
+
return result;
|
|
3742
|
+
}
|
|
3743
|
+
function FromMappedResult10(mappedResult, propertyKeys, options) {
|
|
3744
|
+
return FromProperties14(mappedResult.properties, propertyKeys, options);
|
|
3745
|
+
}
|
|
3746
|
+
function PickFromMappedResult(mappedResult, propertyKeys, options) {
|
|
3747
|
+
const properties = FromMappedResult10(mappedResult, propertyKeys, options);
|
|
3748
|
+
return MappedResult(properties);
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
// node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
|
|
3752
|
+
function FromIntersect7(types, propertyKeys) {
|
|
3753
|
+
return types.map((type) => PickResolve(type, propertyKeys));
|
|
3754
|
+
}
|
|
3755
|
+
function FromUnion9(types, propertyKeys) {
|
|
3756
|
+
return types.map((type) => PickResolve(type, propertyKeys));
|
|
3757
|
+
}
|
|
3758
|
+
function FromProperties15(properties, propertyKeys) {
|
|
3759
|
+
const result = {};
|
|
3760
|
+
for (const K2 of propertyKeys)
|
|
3761
|
+
if (K2 in properties)
|
|
3762
|
+
result[K2] = properties[K2];
|
|
3763
|
+
return result;
|
|
3764
|
+
}
|
|
3765
|
+
function FromObject4(Type2, keys, properties) {
|
|
3766
|
+
const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
|
|
3767
|
+
const mappedProperties = FromProperties15(properties, keys);
|
|
3768
|
+
return Object2(mappedProperties, options);
|
|
3769
|
+
}
|
|
3770
|
+
function UnionFromPropertyKeys2(propertyKeys) {
|
|
3771
|
+
const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
|
|
3772
|
+
return Union(result);
|
|
3773
|
+
}
|
|
3774
|
+
function PickResolve(type, propertyKeys) {
|
|
3775
|
+
return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
|
|
3776
|
+
}
|
|
3777
|
+
function Pick(type, key, options) {
|
|
3778
|
+
const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
|
|
3779
|
+
const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
3780
|
+
const isTypeRef = IsRef(type);
|
|
3781
|
+
const isKeyRef = IsRef(key);
|
|
3782
|
+
return IsMappedResult(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({ ...PickResolve(type, propertyKeys), ...options });
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
// node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
|
|
3786
|
+
function FromPropertyKey3(type, key, options) {
|
|
3787
|
+
return {
|
|
3788
|
+
[key]: Pick(type, [key], Clone(options))
|
|
3789
|
+
};
|
|
3790
|
+
}
|
|
3791
|
+
function FromPropertyKeys3(type, propertyKeys, options) {
|
|
3792
|
+
return propertyKeys.reduce((result, leftKey) => {
|
|
3793
|
+
return { ...result, ...FromPropertyKey3(type, leftKey, options) };
|
|
3794
|
+
}, {});
|
|
3795
|
+
}
|
|
3796
|
+
function FromMappedKey4(type, mappedKey, options) {
|
|
3797
|
+
return FromPropertyKeys3(type, mappedKey.keys, options);
|
|
3798
|
+
}
|
|
3799
|
+
function PickFromMappedKey(type, mappedKey, options) {
|
|
3800
|
+
const properties = FromMappedKey4(type, mappedKey, options);
|
|
3801
|
+
return MappedResult(properties);
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
// node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
|
|
3805
|
+
function FromComputed3(target, parameters) {
|
|
3806
|
+
return Computed("Partial", [Computed(target, parameters)]);
|
|
3807
|
+
}
|
|
3808
|
+
function FromRef3($ref) {
|
|
3809
|
+
return Computed("Partial", [Ref($ref)]);
|
|
3810
|
+
}
|
|
3811
|
+
function FromProperties16(properties) {
|
|
3812
|
+
const partialProperties = {};
|
|
3813
|
+
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
3814
|
+
partialProperties[K] = Optional(properties[K]);
|
|
3815
|
+
return partialProperties;
|
|
3816
|
+
}
|
|
3817
|
+
function FromObject5(type, properties) {
|
|
3818
|
+
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
3819
|
+
const mappedProperties = FromProperties16(properties);
|
|
3820
|
+
return Object2(mappedProperties, options);
|
|
3821
|
+
}
|
|
3822
|
+
function FromRest6(types) {
|
|
3823
|
+
return types.map((type) => PartialResolve(type));
|
|
3824
|
+
}
|
|
3825
|
+
function PartialResolve(type) {
|
|
3826
|
+
return (
|
|
3827
|
+
// Mappable
|
|
3828
|
+
IsComputed(type) ? FromComputed3(type.target, type.parameters) : IsRef(type) ? FromRef3(type.$ref) : IsIntersect(type) ? Intersect(FromRest6(type.allOf)) : IsUnion(type) ? Union(FromRest6(type.anyOf)) : IsObject3(type) ? FromObject5(type, type.properties) : (
|
|
3829
|
+
// Intrinsic
|
|
3830
|
+
IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
|
|
3831
|
+
// Passthrough
|
|
3832
|
+
Object2({})
|
|
3833
|
+
)
|
|
3834
|
+
)
|
|
3835
|
+
);
|
|
3836
|
+
}
|
|
3837
|
+
function Partial(type, options) {
|
|
3838
|
+
if (IsMappedResult(type)) {
|
|
3839
|
+
return PartialFromMappedResult(type, options);
|
|
3840
|
+
} else {
|
|
3841
|
+
return CreateType({ ...PartialResolve(type), ...options });
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
// node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
|
|
3846
|
+
function FromProperties17(K, options) {
|
|
3847
|
+
const Acc = {};
|
|
3848
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
3849
|
+
Acc[K2] = Partial(K[K2], Clone(options));
|
|
3850
|
+
return Acc;
|
|
3851
|
+
}
|
|
3852
|
+
function FromMappedResult11(R, options) {
|
|
3853
|
+
return FromProperties17(R.properties, options);
|
|
3854
|
+
}
|
|
3855
|
+
function PartialFromMappedResult(R, options) {
|
|
3856
|
+
const P = FromMappedResult11(R, options);
|
|
3857
|
+
return MappedResult(P);
|
|
3858
|
+
}
|
|
3859
|
+
|
|
3860
|
+
// node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
|
|
3861
|
+
function FromComputed4(target, parameters) {
|
|
3862
|
+
return Computed("Required", [Computed(target, parameters)]);
|
|
3863
|
+
}
|
|
3864
|
+
function FromRef4($ref) {
|
|
3865
|
+
return Computed("Required", [Ref($ref)]);
|
|
3866
|
+
}
|
|
3867
|
+
function FromProperties18(properties) {
|
|
3868
|
+
const requiredProperties = {};
|
|
3869
|
+
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
3870
|
+
requiredProperties[K] = Discard(properties[K], [OptionalKind]);
|
|
3871
|
+
return requiredProperties;
|
|
3872
|
+
}
|
|
3873
|
+
function FromObject6(type, properties) {
|
|
3874
|
+
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
3875
|
+
const mappedProperties = FromProperties18(properties);
|
|
3876
|
+
return Object2(mappedProperties, options);
|
|
3877
|
+
}
|
|
3878
|
+
function FromRest7(types) {
|
|
3879
|
+
return types.map((type) => RequiredResolve(type));
|
|
3880
|
+
}
|
|
3881
|
+
function RequiredResolve(type) {
|
|
3882
|
+
return (
|
|
3883
|
+
// Mappable
|
|
3884
|
+
IsComputed(type) ? FromComputed4(type.target, type.parameters) : IsRef(type) ? FromRef4(type.$ref) : IsIntersect(type) ? Intersect(FromRest7(type.allOf)) : IsUnion(type) ? Union(FromRest7(type.anyOf)) : IsObject3(type) ? FromObject6(type, type.properties) : (
|
|
3885
|
+
// Intrinsic
|
|
3886
|
+
IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
|
|
3887
|
+
// Passthrough
|
|
3888
|
+
Object2({})
|
|
3889
|
+
)
|
|
3890
|
+
)
|
|
3891
|
+
);
|
|
3892
|
+
}
|
|
3893
|
+
function Required(type, options) {
|
|
3894
|
+
if (IsMappedResult(type)) {
|
|
3895
|
+
return RequiredFromMappedResult(type, options);
|
|
3896
|
+
} else {
|
|
3897
|
+
return CreateType({ ...RequiredResolve(type), ...options });
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
// node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
|
|
3902
|
+
function FromProperties19(P, options) {
|
|
3903
|
+
const Acc = {};
|
|
3904
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
3905
|
+
Acc[K2] = Required(P[K2], options);
|
|
3906
|
+
return Acc;
|
|
3907
|
+
}
|
|
3908
|
+
function FromMappedResult12(R, options) {
|
|
3909
|
+
return FromProperties19(R.properties, options);
|
|
3910
|
+
}
|
|
3911
|
+
function RequiredFromMappedResult(R, options) {
|
|
3912
|
+
const P = FromMappedResult12(R, options);
|
|
3913
|
+
return MappedResult(P);
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
// node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
|
|
3917
|
+
function DereferenceParameters(moduleProperties, types) {
|
|
3918
|
+
return types.map((type) => {
|
|
3919
|
+
return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
|
|
3920
|
+
});
|
|
3921
|
+
}
|
|
3922
|
+
function Dereference(moduleProperties, ref) {
|
|
3923
|
+
return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
|
|
3924
|
+
}
|
|
3925
|
+
function FromAwaited(parameters) {
|
|
3926
|
+
return Awaited(parameters[0]);
|
|
3927
|
+
}
|
|
3928
|
+
function FromIndex(parameters) {
|
|
3929
|
+
return Index(parameters[0], parameters[1]);
|
|
3930
|
+
}
|
|
3931
|
+
function FromKeyOf(parameters) {
|
|
3932
|
+
return KeyOf(parameters[0]);
|
|
3933
|
+
}
|
|
3934
|
+
function FromPartial(parameters) {
|
|
3935
|
+
return Partial(parameters[0]);
|
|
3936
|
+
}
|
|
3937
|
+
function FromOmit(parameters) {
|
|
3938
|
+
return Omit(parameters[0], parameters[1]);
|
|
3939
|
+
}
|
|
3940
|
+
function FromPick(parameters) {
|
|
3941
|
+
return Pick(parameters[0], parameters[1]);
|
|
3942
|
+
}
|
|
3943
|
+
function FromRequired(parameters) {
|
|
3944
|
+
return Required(parameters[0]);
|
|
3945
|
+
}
|
|
3946
|
+
function FromComputed5(moduleProperties, target, parameters) {
|
|
3947
|
+
const dereferenced = DereferenceParameters(moduleProperties, parameters);
|
|
3948
|
+
return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
|
|
3949
|
+
}
|
|
3950
|
+
function FromArray6(moduleProperties, type) {
|
|
3951
|
+
return Array2(FromType2(moduleProperties, type));
|
|
3952
|
+
}
|
|
3953
|
+
function FromAsyncIterator3(moduleProperties, type) {
|
|
3954
|
+
return AsyncIterator(FromType2(moduleProperties, type));
|
|
3955
|
+
}
|
|
3956
|
+
function FromConstructor3(moduleProperties, parameters, instanceType) {
|
|
3957
|
+
return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
|
|
3958
|
+
}
|
|
3959
|
+
function FromFunction3(moduleProperties, parameters, returnType) {
|
|
3960
|
+
return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
|
|
3961
|
+
}
|
|
3962
|
+
function FromIntersect8(moduleProperties, types) {
|
|
3963
|
+
return Intersect(FromTypes2(moduleProperties, types));
|
|
3964
|
+
}
|
|
3965
|
+
function FromIterator3(moduleProperties, type) {
|
|
3966
|
+
return Iterator(FromType2(moduleProperties, type));
|
|
3967
|
+
}
|
|
3968
|
+
function FromObject7(moduleProperties, properties) {
|
|
3969
|
+
return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
|
|
3970
|
+
return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
|
|
3971
|
+
}, {}));
|
|
3972
|
+
}
|
|
3973
|
+
function FromRecord3(moduleProperties, type) {
|
|
3974
|
+
const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
|
|
3975
|
+
const result = CloneType(type);
|
|
3976
|
+
result.patternProperties[pattern] = value;
|
|
3977
|
+
return result;
|
|
3978
|
+
}
|
|
3979
|
+
function FromTransform(moduleProperties, transform) {
|
|
3980
|
+
return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
|
|
3981
|
+
}
|
|
3982
|
+
function FromTuple5(moduleProperties, types) {
|
|
3983
|
+
return Tuple(FromTypes2(moduleProperties, types));
|
|
3984
|
+
}
|
|
3985
|
+
function FromUnion10(moduleProperties, types) {
|
|
3986
|
+
return Union(FromTypes2(moduleProperties, types));
|
|
3987
|
+
}
|
|
3988
|
+
function FromTypes2(moduleProperties, types) {
|
|
3989
|
+
return types.map((type) => FromType2(moduleProperties, type));
|
|
3990
|
+
}
|
|
3991
|
+
function FromType2(moduleProperties, type) {
|
|
3992
|
+
return (
|
|
3993
|
+
// Modifiers
|
|
3994
|
+
IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
|
|
3995
|
+
// Transform
|
|
3996
|
+
IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
|
|
3997
|
+
// Types
|
|
3998
|
+
IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator2(type) ? CreateType(FromAsyncIterator3(moduleProperties, type.items), type) : IsComputed(type) ? CreateType(FromComputed5(moduleProperties, type.target, type.parameters)) : IsConstructor(type) ? CreateType(FromConstructor3(moduleProperties, type.parameters, type.returns), type) : IsFunction2(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator2(type) ? CreateType(FromIterator3(moduleProperties, type.items), type) : IsObject3(type) ? CreateType(FromObject7(moduleProperties, type.properties), type) : IsRecord(type) ? CreateType(FromRecord3(moduleProperties, type)) : IsTuple(type) ? CreateType(FromTuple5(moduleProperties, type.items || []), type) : IsUnion(type) ? CreateType(FromUnion10(moduleProperties, type.anyOf), type) : type
|
|
3999
|
+
)
|
|
4000
|
+
)
|
|
4001
|
+
);
|
|
4002
|
+
}
|
|
4003
|
+
function ComputeType(moduleProperties, key) {
|
|
4004
|
+
return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
|
|
4005
|
+
}
|
|
4006
|
+
function ComputeModuleProperties(moduleProperties) {
|
|
4007
|
+
return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
|
|
4008
|
+
return { ...result, [key]: ComputeType(moduleProperties, key) };
|
|
4009
|
+
}, {});
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
// node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
|
|
4013
|
+
var TModule = class {
|
|
4014
|
+
constructor($defs) {
|
|
4015
|
+
const computed = ComputeModuleProperties($defs);
|
|
4016
|
+
const identified = this.WithIdentifiers(computed);
|
|
4017
|
+
this.$defs = identified;
|
|
4018
|
+
}
|
|
4019
|
+
/** `[Json]` Imports a Type by Key. */
|
|
4020
|
+
Import(key, options) {
|
|
4021
|
+
const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
|
|
4022
|
+
return CreateType({ [Kind]: "Import", $defs, $ref: key });
|
|
4023
|
+
}
|
|
4024
|
+
// prettier-ignore
|
|
4025
|
+
WithIdentifiers($defs) {
|
|
4026
|
+
return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
|
|
4027
|
+
return { ...result, [key]: { ...$defs[key], $id: key } };
|
|
4028
|
+
}, {});
|
|
4029
|
+
}
|
|
4030
|
+
};
|
|
4031
|
+
function Module(properties) {
|
|
4032
|
+
return new TModule(properties);
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
// node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
|
|
4036
|
+
function Not(type, options) {
|
|
4037
|
+
return CreateType({ [Kind]: "Not", not: type }, options);
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
// node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
|
|
4041
|
+
function Parameters(schema, options) {
|
|
4042
|
+
return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
// node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
|
|
4046
|
+
var Ordinal = 0;
|
|
4047
|
+
function Recursive(callback, options = {}) {
|
|
4048
|
+
if (IsUndefined(options.$id))
|
|
4049
|
+
options.$id = `T${Ordinal++}`;
|
|
4050
|
+
const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
|
|
4051
|
+
thisType.$id = options.$id;
|
|
4052
|
+
return CreateType({ [Hint]: "Recursive", ...thisType }, options);
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
// node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
|
|
4056
|
+
function RegExp2(unresolved, options) {
|
|
4057
|
+
const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
|
|
4058
|
+
return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
|
|
4059
|
+
}
|
|
4060
|
+
|
|
4061
|
+
// node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
|
|
4062
|
+
function RestResolve(T) {
|
|
4063
|
+
return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
|
|
4064
|
+
}
|
|
4065
|
+
function Rest(T) {
|
|
4066
|
+
return RestResolve(T);
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
// node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
|
|
4070
|
+
function ReturnType(schema, options) {
|
|
4071
|
+
return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
// node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
|
|
4075
|
+
var TransformDecodeBuilder = class {
|
|
4076
|
+
constructor(schema) {
|
|
4077
|
+
this.schema = schema;
|
|
4078
|
+
}
|
|
4079
|
+
Decode(decode) {
|
|
4080
|
+
return new TransformEncodeBuilder(this.schema, decode);
|
|
4081
|
+
}
|
|
4082
|
+
};
|
|
4083
|
+
var TransformEncodeBuilder = class {
|
|
4084
|
+
constructor(schema, decode) {
|
|
4085
|
+
this.schema = schema;
|
|
4086
|
+
this.decode = decode;
|
|
4087
|
+
}
|
|
4088
|
+
EncodeTransform(encode, schema) {
|
|
4089
|
+
const Encode = (value) => schema[TransformKind].Encode(encode(value));
|
|
4090
|
+
const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
|
|
4091
|
+
const Codec = { Encode, Decode };
|
|
4092
|
+
return { ...schema, [TransformKind]: Codec };
|
|
4093
|
+
}
|
|
4094
|
+
EncodeSchema(encode, schema) {
|
|
4095
|
+
const Codec = { Decode: this.decode, Encode: encode };
|
|
4096
|
+
return { ...schema, [TransformKind]: Codec };
|
|
4097
|
+
}
|
|
4098
|
+
Encode(encode) {
|
|
4099
|
+
return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
|
|
4100
|
+
}
|
|
4101
|
+
};
|
|
4102
|
+
function Transform(schema) {
|
|
4103
|
+
return new TransformDecodeBuilder(schema);
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
// node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
|
|
4107
|
+
function Unsafe(options = {}) {
|
|
4108
|
+
return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
// node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
|
|
4112
|
+
function Void(options) {
|
|
4113
|
+
return CreateType({ [Kind]: "Void", type: "void" }, options);
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
// node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
|
|
4117
|
+
var type_exports2 = {};
|
|
4118
|
+
__export(type_exports2, {
|
|
4119
|
+
Any: () => Any,
|
|
4120
|
+
Argument: () => Argument,
|
|
4121
|
+
Array: () => Array2,
|
|
4122
|
+
AsyncIterator: () => AsyncIterator,
|
|
4123
|
+
Awaited: () => Awaited,
|
|
4124
|
+
BigInt: () => BigInt,
|
|
4125
|
+
Boolean: () => Boolean2,
|
|
4126
|
+
Capitalize: () => Capitalize,
|
|
4127
|
+
Composite: () => Composite,
|
|
4128
|
+
Const: () => Const,
|
|
4129
|
+
Constructor: () => Constructor,
|
|
4130
|
+
ConstructorParameters: () => ConstructorParameters,
|
|
4131
|
+
Date: () => Date2,
|
|
4132
|
+
Enum: () => Enum,
|
|
4133
|
+
Exclude: () => Exclude,
|
|
4134
|
+
Extends: () => Extends,
|
|
4135
|
+
Extract: () => Extract,
|
|
4136
|
+
Function: () => Function,
|
|
4137
|
+
Index: () => Index,
|
|
4138
|
+
InstanceType: () => InstanceType,
|
|
4139
|
+
Instantiate: () => Instantiate,
|
|
4140
|
+
Integer: () => Integer,
|
|
4141
|
+
Intersect: () => Intersect,
|
|
4142
|
+
Iterator: () => Iterator,
|
|
4143
|
+
KeyOf: () => KeyOf,
|
|
4144
|
+
Literal: () => Literal,
|
|
4145
|
+
Lowercase: () => Lowercase,
|
|
4146
|
+
Mapped: () => Mapped,
|
|
4147
|
+
Module: () => Module,
|
|
4148
|
+
Never: () => Never,
|
|
4149
|
+
Not: () => Not,
|
|
4150
|
+
Null: () => Null,
|
|
4151
|
+
Number: () => Number2,
|
|
4152
|
+
Object: () => Object2,
|
|
4153
|
+
Omit: () => Omit,
|
|
4154
|
+
Optional: () => Optional,
|
|
4155
|
+
Parameters: () => Parameters,
|
|
4156
|
+
Partial: () => Partial,
|
|
4157
|
+
Pick: () => Pick,
|
|
4158
|
+
Promise: () => Promise2,
|
|
4159
|
+
Readonly: () => Readonly,
|
|
4160
|
+
ReadonlyOptional: () => ReadonlyOptional,
|
|
4161
|
+
Record: () => Record,
|
|
4162
|
+
Recursive: () => Recursive,
|
|
4163
|
+
Ref: () => Ref,
|
|
4164
|
+
RegExp: () => RegExp2,
|
|
4165
|
+
Required: () => Required,
|
|
4166
|
+
Rest: () => Rest,
|
|
4167
|
+
ReturnType: () => ReturnType,
|
|
4168
|
+
String: () => String2,
|
|
4169
|
+
Symbol: () => Symbol2,
|
|
4170
|
+
TemplateLiteral: () => TemplateLiteral,
|
|
4171
|
+
Transform: () => Transform,
|
|
4172
|
+
Tuple: () => Tuple,
|
|
4173
|
+
Uint8Array: () => Uint8Array2,
|
|
4174
|
+
Uncapitalize: () => Uncapitalize,
|
|
4175
|
+
Undefined: () => Undefined,
|
|
4176
|
+
Union: () => Union,
|
|
4177
|
+
Unknown: () => Unknown,
|
|
4178
|
+
Unsafe: () => Unsafe,
|
|
4179
|
+
Uppercase: () => Uppercase,
|
|
4180
|
+
Void: () => Void
|
|
4181
|
+
});
|
|
4182
|
+
|
|
4183
|
+
// node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
|
|
4184
|
+
var Type = type_exports2;
|
|
4185
|
+
|
|
4186
|
+
// src/runtime/tools/send-file-tool.ts
|
|
4187
|
+
var SendFileParams = Type.Object({
|
|
4188
|
+
filePath: Type.String({
|
|
4189
|
+
description: "Absolute path to the file to send to the user. The file must exist and be readable."
|
|
4190
|
+
}),
|
|
4191
|
+
caption: Type.Optional(
|
|
4192
|
+
Type.String({
|
|
4193
|
+
description: "Optional caption or description to accompany the file."
|
|
4194
|
+
})
|
|
4195
|
+
)
|
|
4196
|
+
});
|
|
4197
|
+
var MIME_BY_EXT = {
|
|
4198
|
+
".png": "image/png",
|
|
4199
|
+
".jpg": "image/jpeg",
|
|
4200
|
+
".jpeg": "image/jpeg",
|
|
4201
|
+
".gif": "image/gif",
|
|
4202
|
+
".webp": "image/webp",
|
|
4203
|
+
".svg": "image/svg+xml",
|
|
4204
|
+
".pdf": "application/pdf",
|
|
4205
|
+
".csv": "text/csv",
|
|
4206
|
+
".json": "application/json",
|
|
4207
|
+
".txt": "text/plain",
|
|
4208
|
+
".md": "text/markdown",
|
|
4209
|
+
".html": "text/html",
|
|
4210
|
+
".xml": "application/xml",
|
|
4211
|
+
".zip": "application/zip",
|
|
4212
|
+
".mp3": "audio/mpeg",
|
|
4213
|
+
".mp4": "video/mp4",
|
|
4214
|
+
".wav": "audio/wav",
|
|
4215
|
+
".ogg": "audio/ogg"
|
|
4216
|
+
};
|
|
4217
|
+
function detectMimeType(filePath) {
|
|
4218
|
+
const ext = path6.extname(filePath).toLowerCase();
|
|
4219
|
+
return MIME_BY_EXT[ext];
|
|
4220
|
+
}
|
|
4221
|
+
function createSendFileTool(fileOutputCallbackRef) {
|
|
4222
|
+
return {
|
|
4223
|
+
name: "send_file",
|
|
4224
|
+
label: "Send File",
|
|
4225
|
+
description: "Send a file to the user via the current chat channel (Telegram, Slack, or Web). IMPORTANT: Do NOT proactively send files. Only use this tool when the user EXPLICITLY asks you to send, share, or deliver a file (e.g. '\u628A\u6587\u4EF6\u53D1\u7ED9\u6211', 'send me the file', 'share the result'). Never send intermediate/temporary files. When the user asks, send only the specific file(s) the user requested, not all generated files.",
|
|
4226
|
+
promptSnippet: "send_file: Send a file to the user ONLY when they explicitly request it. Never send files proactively or automatically.",
|
|
4227
|
+
parameters: SendFileParams,
|
|
4228
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
4229
|
+
const { filePath, caption } = params;
|
|
4230
|
+
if (!fs6.existsSync(filePath)) {
|
|
4231
|
+
return {
|
|
4232
|
+
content: [{ type: "text", text: `Error: File not found: ${filePath}` }],
|
|
4233
|
+
details: void 0
|
|
4234
|
+
};
|
|
4235
|
+
}
|
|
4236
|
+
const stats = fs6.statSync(filePath);
|
|
4237
|
+
if (!stats.isFile()) {
|
|
4238
|
+
return {
|
|
4239
|
+
content: [
|
|
4240
|
+
{ type: "text", text: `Error: Path is not a file: ${filePath}` }
|
|
4241
|
+
],
|
|
4242
|
+
details: void 0
|
|
4243
|
+
};
|
|
4244
|
+
}
|
|
4245
|
+
const filename = path6.basename(filePath);
|
|
4246
|
+
const mimeType = detectMimeType(filePath);
|
|
4247
|
+
const callback = fileOutputCallbackRef.current;
|
|
4248
|
+
if (callback) {
|
|
4249
|
+
callback({
|
|
4250
|
+
type: "file_output",
|
|
4251
|
+
filePath,
|
|
4252
|
+
filename,
|
|
4253
|
+
mimeType,
|
|
4254
|
+
caption
|
|
4255
|
+
});
|
|
4256
|
+
}
|
|
4257
|
+
const sizeKB = (stats.size / 1024).toFixed(1);
|
|
4258
|
+
return {
|
|
4259
|
+
content: [
|
|
4260
|
+
{
|
|
4261
|
+
type: "text",
|
|
4262
|
+
text: `File "${filename}" (${sizeKB}KB) has been sent to the user.`
|
|
4263
|
+
}
|
|
4264
|
+
],
|
|
4265
|
+
details: void 0
|
|
4266
|
+
};
|
|
4267
|
+
}
|
|
4268
|
+
};
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
// src/runtime/agent.ts
|
|
4272
|
+
var DEBUG = true;
|
|
4273
|
+
var log = (...args) => DEBUG && console.log(...args);
|
|
4274
|
+
var write = (data) => DEBUG && process.stdout.write(data);
|
|
4275
|
+
function getAssistantDiagnostics(message) {
|
|
4276
|
+
if (!message || message.role !== "assistant") {
|
|
4277
|
+
return null;
|
|
4278
|
+
}
|
|
4279
|
+
const stopReason = message.stopReason ?? "unknown";
|
|
4280
|
+
const errorMessage = message.errorMessage || (stopReason === "error" || stopReason === "aborted" ? `Request ${stopReason}` : "");
|
|
4281
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
4282
|
+
const text = content.filter((item) => item?.type === "text").map((item) => item.text || "").join("").trim();
|
|
4283
|
+
const toolCalls = content.filter(
|
|
4284
|
+
(item) => item?.type === "toolCall"
|
|
4285
|
+
).length;
|
|
4286
|
+
return { stopReason, errorMessage, hasText: text.length > 0, toolCalls };
|
|
4287
|
+
}
|
|
4288
|
+
function getLifecycleTrigger(channelId) {
|
|
4289
|
+
if (channelId.startsWith("telegram-")) return "telegram";
|
|
4290
|
+
if (channelId.startsWith("slack-")) return "slack";
|
|
4291
|
+
return "web";
|
|
4292
|
+
}
|
|
4293
|
+
var PackAgent = class {
|
|
4294
|
+
options;
|
|
4295
|
+
channels = /* @__PURE__ */ new Map();
|
|
4296
|
+
pendingSessionCreations = /* @__PURE__ */ new Map();
|
|
4297
|
+
fileOutputCallbackRef = {
|
|
4298
|
+
current: null
|
|
4299
|
+
};
|
|
4300
|
+
sendFileToolDef = createSendFileTool(this.fileOutputCallbackRef);
|
|
4301
|
+
constructor(options) {
|
|
4302
|
+
this.options = options;
|
|
4303
|
+
}
|
|
4304
|
+
/**
|
|
4305
|
+
* Lazily create (or return existing) session for a channel.
|
|
4306
|
+
*/
|
|
4307
|
+
async getOrCreateSession(channelId) {
|
|
4308
|
+
const existing = this.channels.get(channelId);
|
|
4309
|
+
if (existing) return existing;
|
|
4310
|
+
const pendingCreation = this.pendingSessionCreations.get(channelId);
|
|
4311
|
+
if (pendingCreation) return pendingCreation;
|
|
4312
|
+
const createSessionPromise = (async () => {
|
|
4313
|
+
const { apiKey, rootDir, provider, modelId } = this.options;
|
|
4314
|
+
const authStorage = AuthStorage.inMemory({
|
|
4315
|
+
[provider]: { type: "api_key", key: apiKey }
|
|
4316
|
+
});
|
|
4317
|
+
authStorage.setRuntimeApiKey(provider, apiKey);
|
|
4318
|
+
const modelRegistry = new ModelRegistry(authStorage);
|
|
4319
|
+
const model = modelRegistry.find(provider, modelId);
|
|
4320
|
+
const sessionDir = path7.resolve(
|
|
4321
|
+
rootDir,
|
|
4322
|
+
"data",
|
|
4323
|
+
"sessions",
|
|
4324
|
+
channelId
|
|
4325
|
+
);
|
|
4326
|
+
fs7.mkdirSync(sessionDir, { recursive: true });
|
|
4327
|
+
const sessionManager = SessionManager.continueRecent(rootDir, sessionDir);
|
|
4328
|
+
log(`[PackAgent] Session dir: ${sessionDir}`);
|
|
4329
|
+
const workspaceDir = path7.resolve(
|
|
4330
|
+
rootDir,
|
|
4331
|
+
"data",
|
|
4332
|
+
"workspaces",
|
|
4333
|
+
channelId
|
|
4334
|
+
);
|
|
4335
|
+
fs7.mkdirSync(workspaceDir, { recursive: true });
|
|
4336
|
+
log(`[PackAgent] Workspace dir: ${workspaceDir}`);
|
|
4337
|
+
const skillsPath = path7.resolve(rootDir, "skills");
|
|
4338
|
+
log(`[PackAgent] Loading skills from: ${skillsPath}`);
|
|
4339
|
+
const resourceLoader = new DefaultResourceLoader({
|
|
4340
|
+
cwd: rootDir,
|
|
4341
|
+
additionalSkillPaths: [skillsPath]
|
|
4342
|
+
});
|
|
4343
|
+
await resourceLoader.reload();
|
|
4344
|
+
const tools = createCodingTools(workspaceDir);
|
|
4345
|
+
const { session } = await createAgentSession({
|
|
4346
|
+
cwd: workspaceDir,
|
|
4347
|
+
authStorage,
|
|
4348
|
+
modelRegistry,
|
|
4349
|
+
sessionManager,
|
|
4350
|
+
resourceLoader,
|
|
4351
|
+
model,
|
|
4352
|
+
tools,
|
|
4353
|
+
customTools: [this.sendFileToolDef]
|
|
4354
|
+
});
|
|
4355
|
+
const channelSession = {
|
|
4356
|
+
session,
|
|
4357
|
+
running: false,
|
|
4358
|
+
pending: Promise.resolve()
|
|
4359
|
+
};
|
|
4360
|
+
this.channels.set(channelId, channelSession);
|
|
4361
|
+
return channelSession;
|
|
4362
|
+
})();
|
|
4363
|
+
this.pendingSessionCreations.set(channelId, createSessionPromise);
|
|
4364
|
+
try {
|
|
4365
|
+
return await createSessionPromise;
|
|
4366
|
+
} finally {
|
|
4367
|
+
this.pendingSessionCreations.delete(channelId);
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
async handleMessage(channelId, text, onEvent, attachments) {
|
|
4371
|
+
const cs = await this.getOrCreateSession(channelId);
|
|
4372
|
+
const run = async () => {
|
|
4373
|
+
cs.running = true;
|
|
4374
|
+
let turnHadVisibleOutput = false;
|
|
4375
|
+
this.fileOutputCallbackRef.current = (event) => {
|
|
4376
|
+
onEvent(event);
|
|
4377
|
+
};
|
|
4378
|
+
const unsubscribe = cs.session.subscribe((event) => {
|
|
4379
|
+
switch (event.type) {
|
|
4380
|
+
case "agent_start":
|
|
4381
|
+
log("\n=== [AGENT SESSION START] ===");
|
|
4382
|
+
log("System Prompt:\n", cs.session.systemPrompt);
|
|
4383
|
+
log("============================\n");
|
|
4384
|
+
onEvent({ type: "agent_start" });
|
|
4385
|
+
break;
|
|
4386
|
+
case "message_start":
|
|
4387
|
+
log(`
|
|
4388
|
+
--- [Message Start: ${event.message?.role}] ---`);
|
|
4389
|
+
if (event.message?.role === "user") {
|
|
4390
|
+
log(JSON.stringify(event.message.content, null, 2));
|
|
4391
|
+
}
|
|
4392
|
+
onEvent({ type: "message_start", role: event.message?.role ?? "" });
|
|
4393
|
+
break;
|
|
4394
|
+
case "message_update":
|
|
4395
|
+
if (event.assistantMessageEvent?.type === "text_delta") {
|
|
4396
|
+
turnHadVisibleOutput = true;
|
|
4397
|
+
write(event.assistantMessageEvent.delta);
|
|
4398
|
+
onEvent({
|
|
4399
|
+
type: "text_delta",
|
|
4400
|
+
delta: event.assistantMessageEvent.delta
|
|
4401
|
+
});
|
|
4402
|
+
} else if (event.assistantMessageEvent?.type === "thinking_delta") {
|
|
4403
|
+
turnHadVisibleOutput = true;
|
|
4404
|
+
onEvent({
|
|
4405
|
+
type: "thinking_delta",
|
|
4406
|
+
delta: event.assistantMessageEvent.delta
|
|
4407
|
+
});
|
|
4408
|
+
}
|
|
4409
|
+
break;
|
|
4410
|
+
case "message_end":
|
|
4411
|
+
log(`
|
|
4412
|
+
--- [Message End: ${event.message?.role}] ---`);
|
|
4413
|
+
if (event.message?.role === "assistant") {
|
|
4414
|
+
const diagnostics = getAssistantDiagnostics(event.message);
|
|
4415
|
+
if (diagnostics) {
|
|
1429
4416
|
log(
|
|
1430
4417
|
`[Assistant Diagnostics] stopReason=${diagnostics.stopReason} text=${diagnostics.hasText ? "yes" : "no"} toolCalls=${diagnostics.toolCalls}`
|
|
1431
4418
|
);
|
|
@@ -1465,7 +4452,24 @@ var PackAgent = class {
|
|
|
1465
4452
|
}
|
|
1466
4453
|
});
|
|
1467
4454
|
try {
|
|
1468
|
-
|
|
4455
|
+
let promptText = text;
|
|
4456
|
+
const promptOptions = {};
|
|
4457
|
+
if (attachments && attachments.length > 0) {
|
|
4458
|
+
const imageAttachments = attachments.filter((a) => isImageMime(a.mimeType));
|
|
4459
|
+
const nonImageAttachments = attachments.filter((a) => !isImageMime(a.mimeType));
|
|
4460
|
+
if (imageAttachments.length > 0) {
|
|
4461
|
+
promptOptions.images = attachmentsToImageContent(imageAttachments);
|
|
4462
|
+
log(`[PackAgent] Passing ${imageAttachments.length} image(s) to LLM`);
|
|
4463
|
+
}
|
|
4464
|
+
if (nonImageAttachments.length > 0) {
|
|
4465
|
+
const attachmentPrompt = formatAttachmentsPrompt(nonImageAttachments);
|
|
4466
|
+
promptText = `${attachmentPrompt}
|
|
4467
|
+
|
|
4468
|
+
${text}`;
|
|
4469
|
+
log(`[PackAgent] Injecting ${nonImageAttachments.length} non-image attachment(s) into prompt`);
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
await cs.session.prompt(promptText, promptOptions);
|
|
1469
4473
|
const lastMessage = cs.session.state.messages.at(-1);
|
|
1470
4474
|
const diagnostics = getAssistantDiagnostics(lastMessage);
|
|
1471
4475
|
if (diagnostics?.errorMessage) {
|
|
@@ -1483,6 +4487,7 @@ var PackAgent = class {
|
|
|
1483
4487
|
return { stopReason: diagnostics?.stopReason ?? "unknown" };
|
|
1484
4488
|
} finally {
|
|
1485
4489
|
cs.running = false;
|
|
4490
|
+
this.fileOutputCallbackRef.current = null;
|
|
1486
4491
|
unsubscribe();
|
|
1487
4492
|
}
|
|
1488
4493
|
};
|
|
@@ -1500,9 +4505,9 @@ var PackAgent = class {
|
|
|
1500
4505
|
this.channels.delete(channelId);
|
|
1501
4506
|
}
|
|
1502
4507
|
const { rootDir } = this.options;
|
|
1503
|
-
const sessionDir =
|
|
1504
|
-
if (
|
|
1505
|
-
|
|
4508
|
+
const sessionDir = path7.resolve(rootDir, "data", "sessions", channelId);
|
|
4509
|
+
if (fs7.existsSync(sessionDir)) {
|
|
4510
|
+
fs7.rmSync(sessionDir, { recursive: true, force: true });
|
|
1506
4511
|
log(`[PackAgent] Cleared session dir: ${sessionDir}`);
|
|
1507
4512
|
}
|
|
1508
4513
|
return {
|
|
@@ -1550,13 +4555,13 @@ var PackAgent = class {
|
|
|
1550
4555
|
};
|
|
1551
4556
|
|
|
1552
4557
|
// src/runtime/adapters/web.ts
|
|
1553
|
-
import
|
|
1554
|
-
import
|
|
4558
|
+
import fs9 from "fs";
|
|
4559
|
+
import path9 from "path";
|
|
1555
4560
|
import { WebSocketServer } from "ws";
|
|
1556
4561
|
|
|
1557
4562
|
// src/runtime/config.ts
|
|
1558
|
-
import
|
|
1559
|
-
import
|
|
4563
|
+
import fs8 from "fs";
|
|
4564
|
+
import path8 from "path";
|
|
1560
4565
|
var ConfigManager = class _ConfigManager {
|
|
1561
4566
|
static instance;
|
|
1562
4567
|
configData = {};
|
|
@@ -1570,10 +4575,10 @@ var ConfigManager = class _ConfigManager {
|
|
|
1570
4575
|
return _ConfigManager.instance;
|
|
1571
4576
|
}
|
|
1572
4577
|
load(rootDir) {
|
|
1573
|
-
this.configPath =
|
|
1574
|
-
if (
|
|
4578
|
+
this.configPath = path8.join(rootDir, "data", "config.json");
|
|
4579
|
+
if (fs8.existsSync(this.configPath)) {
|
|
1575
4580
|
try {
|
|
1576
|
-
this.configData = JSON.parse(
|
|
4581
|
+
this.configData = JSON.parse(fs8.readFileSync(this.configPath, "utf-8"));
|
|
1577
4582
|
console.log(" Loaded config from data/config.json");
|
|
1578
4583
|
} catch (err) {
|
|
1579
4584
|
console.warn(" Warning: Failed to parse data/config.json:", err);
|
|
@@ -1597,12 +4602,12 @@ var ConfigManager = class _ConfigManager {
|
|
|
1597
4602
|
return this.configData;
|
|
1598
4603
|
}
|
|
1599
4604
|
save(rootDir, updates) {
|
|
1600
|
-
const configDir =
|
|
4605
|
+
const configDir = path8.join(rootDir, "data");
|
|
1601
4606
|
if (!this.configPath) {
|
|
1602
|
-
this.configPath =
|
|
4607
|
+
this.configPath = path8.join(rootDir, "data", "config.json");
|
|
1603
4608
|
}
|
|
1604
|
-
if (!
|
|
1605
|
-
|
|
4609
|
+
if (!fs8.existsSync(configDir)) {
|
|
4610
|
+
fs8.mkdirSync(configDir, { recursive: true });
|
|
1606
4611
|
}
|
|
1607
4612
|
if (updates.apiKey !== void 0) this.configData.apiKey = updates.apiKey;
|
|
1608
4613
|
if (updates.provider !== void 0) this.configData.provider = updates.provider;
|
|
@@ -1618,7 +4623,7 @@ var ConfigManager = class _ConfigManager {
|
|
|
1618
4623
|
this.configData.adapters = merged;
|
|
1619
4624
|
}
|
|
1620
4625
|
try {
|
|
1621
|
-
|
|
4626
|
+
fs8.writeFileSync(
|
|
1622
4627
|
this.configPath,
|
|
1623
4628
|
JSON.stringify(this.configData, null, 2),
|
|
1624
4629
|
"utf-8"
|
|
@@ -1632,7 +4637,7 @@ var configManager = ConfigManager.getInstance();
|
|
|
1632
4637
|
|
|
1633
4638
|
// src/runtime/adapters/web.ts
|
|
1634
4639
|
function getPackConfig(rootDir) {
|
|
1635
|
-
const raw =
|
|
4640
|
+
const raw = fs9.readFileSync(path9.join(rootDir, "skillpack.json"), "utf-8");
|
|
1636
4641
|
return JSON.parse(raw);
|
|
1637
4642
|
}
|
|
1638
4643
|
var COMMANDS = {
|
|
@@ -1732,6 +4737,30 @@ var WebAdapter = class {
|
|
|
1732
4737
|
app.get("/api/sessions/:id", (_req, res) => {
|
|
1733
4738
|
res.status(501).json({ error: "Not implemented yet" });
|
|
1734
4739
|
});
|
|
4740
|
+
app.get("/api/files", (req, res) => {
|
|
4741
|
+
const filePath = req.query.path;
|
|
4742
|
+
if (!filePath) {
|
|
4743
|
+
res.status(400).json({ error: "Missing 'path' query parameter" });
|
|
4744
|
+
return;
|
|
4745
|
+
}
|
|
4746
|
+
const resolvedPath = path9.resolve(filePath);
|
|
4747
|
+
const dataDir = path9.resolve(rootDir, "data");
|
|
4748
|
+
if (!resolvedPath.startsWith(dataDir)) {
|
|
4749
|
+
res.status(403).json({ error: "Access denied" });
|
|
4750
|
+
return;
|
|
4751
|
+
}
|
|
4752
|
+
if (!fs9.existsSync(resolvedPath)) {
|
|
4753
|
+
res.status(404).json({ error: "File not found" });
|
|
4754
|
+
return;
|
|
4755
|
+
}
|
|
4756
|
+
const filename = path9.basename(resolvedPath);
|
|
4757
|
+
res.setHeader("Content-Type", "application/octet-stream");
|
|
4758
|
+
res.setHeader(
|
|
4759
|
+
"Content-Disposition",
|
|
4760
|
+
`attachment; filename="${filename}"`
|
|
4761
|
+
);
|
|
4762
|
+
fs9.createReadStream(resolvedPath).pipe(res);
|
|
4763
|
+
});
|
|
1735
4764
|
this.wss = new WebSocketServer({ noServer: true });
|
|
1736
4765
|
server.on("upgrade", (request, socket, head) => {
|
|
1737
4766
|
if (request.url?.startsWith("/api/chat")) {
|
|
@@ -1895,7 +4924,7 @@ var Lifecycle = class {
|
|
|
1895
4924
|
};
|
|
1896
4925
|
|
|
1897
4926
|
// src/runtime/server.ts
|
|
1898
|
-
var __dirname =
|
|
4927
|
+
var __dirname = path11.dirname(fileURLToPath(import.meta.url));
|
|
1899
4928
|
async function startServer(options) {
|
|
1900
4929
|
const {
|
|
1901
4930
|
rootDir,
|
|
@@ -1907,8 +4936,8 @@ async function startServer(options) {
|
|
|
1907
4936
|
const apiKey = dataConfig.apiKey || "";
|
|
1908
4937
|
const provider = dataConfig.provider || "openai";
|
|
1909
4938
|
const modelId = provider === "anthropic" ? "claude-opus-4-6" : "gpt-5.4";
|
|
1910
|
-
const packageRoot =
|
|
1911
|
-
const webDir =
|
|
4939
|
+
const packageRoot = path11.resolve(__dirname, "..");
|
|
4940
|
+
const webDir = fs12.existsSync(path11.join(rootDir, "web")) ? path11.join(rootDir, "web") : path11.join(packageRoot, "web");
|
|
1912
4941
|
const app = express();
|
|
1913
4942
|
app.use(express.json());
|
|
1914
4943
|
app.use(express.static(webDir));
|
|
@@ -2011,23 +5040,23 @@ function findMissingSkills(workDir, config) {
|
|
|
2011
5040
|
});
|
|
2012
5041
|
}
|
|
2013
5042
|
function copyStartTemplates2(workDir) {
|
|
2014
|
-
const templateDir =
|
|
5043
|
+
const templateDir = path12.resolve(
|
|
2015
5044
|
new URL("../templates", import.meta.url).pathname
|
|
2016
5045
|
);
|
|
2017
5046
|
for (const file of ["start.sh", "start.bat"]) {
|
|
2018
|
-
const src =
|
|
2019
|
-
const dest =
|
|
2020
|
-
if (
|
|
2021
|
-
|
|
5047
|
+
const src = path12.join(templateDir, file);
|
|
5048
|
+
const dest = path12.join(workDir, file);
|
|
5049
|
+
if (fs13.existsSync(src)) {
|
|
5050
|
+
fs13.copyFileSync(src, dest);
|
|
2022
5051
|
if (file === "start.sh") {
|
|
2023
|
-
|
|
5052
|
+
fs13.chmodSync(dest, 493);
|
|
2024
5053
|
}
|
|
2025
5054
|
}
|
|
2026
5055
|
}
|
|
2027
5056
|
}
|
|
2028
5057
|
async function runCommand(directory) {
|
|
2029
|
-
const workDir = directory ?
|
|
2030
|
-
|
|
5058
|
+
const workDir = directory ? path12.resolve(directory) : process.cwd();
|
|
5059
|
+
fs13.mkdirSync(workDir, { recursive: true });
|
|
2031
5060
|
if (!configExists(workDir)) {
|
|
2032
5061
|
console.log(chalk4.blue("\n No skillpack.json found. Let's set one up.\n"));
|
|
2033
5062
|
const { name, description } = await inquirer2.prompt([
|
|
@@ -2067,9 +5096,9 @@ async function runCommand(directory) {
|
|
|
2067
5096
|
}
|
|
2068
5097
|
|
|
2069
5098
|
// src/cli.ts
|
|
2070
|
-
import
|
|
5099
|
+
import fs14 from "fs";
|
|
2071
5100
|
var packageJson = JSON.parse(
|
|
2072
|
-
|
|
5101
|
+
fs14.readFileSync(new URL("../package.json", import.meta.url), "utf-8")
|
|
2073
5102
|
);
|
|
2074
5103
|
var program = new Command();
|
|
2075
5104
|
program.name("skillpack").description("Assemble, package, and run Agent Skills packs").version(packageJson.version);
|