@prisma/cli-init 0.3.0 → 0.4.1

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.
@@ -0,0 +1,1763 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+
3
+ // ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
4
+ var store;
5
+ // @__NO_SIDE_EFFECTS__
6
+ function getGlobalConfig(config2) {
7
+ return {
8
+ lang: config2?.lang ?? store?.lang,
9
+ message: config2?.message,
10
+ abortEarly: config2?.abortEarly ?? store?.abortEarly,
11
+ abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
12
+ };
13
+ }
14
+ var store2;
15
+ // @__NO_SIDE_EFFECTS__
16
+ function getGlobalMessage(lang) {
17
+ return store2?.get(lang);
18
+ }
19
+ var store3;
20
+ // @__NO_SIDE_EFFECTS__
21
+ function getSchemaMessage(lang) {
22
+ return store3?.get(lang);
23
+ }
24
+ var store4;
25
+ // @__NO_SIDE_EFFECTS__
26
+ function getSpecificMessage(reference, lang) {
27
+ return store4?.get(reference)?.get(lang);
28
+ }
29
+ // @__NO_SIDE_EFFECTS__
30
+ function _stringify(input) {
31
+ const type = typeof input;
32
+ if (type === "string") {
33
+ return `"${input}"`;
34
+ }
35
+ if (type === "number" || type === "bigint" || type === "boolean") {
36
+ return `${input}`;
37
+ }
38
+ if (type === "object" || type === "function") {
39
+ return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
40
+ }
41
+ return type;
42
+ }
43
+ function _addIssue(context, label, dataset, config2, other) {
44
+ const input = other && "input" in other ? other.input : dataset.value;
45
+ const expected = other?.expected ?? context.expects ?? null;
46
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
47
+ const issue = {
48
+ kind: context.kind,
49
+ type: context.type,
50
+ input,
51
+ expected,
52
+ received,
53
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
54
+ requirement: context.requirement,
55
+ path: other?.path,
56
+ issues: other?.issues,
57
+ lang: config2.lang,
58
+ abortEarly: config2.abortEarly,
59
+ abortPipeEarly: config2.abortPipeEarly
60
+ };
61
+ const isSchema = context.kind === "schema";
62
+ const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
63
+ if (message2 !== void 0) {
64
+ issue.message = typeof message2 === "function" ? (
65
+ // @ts-expect-error
66
+ message2(issue)
67
+ ) : message2;
68
+ }
69
+ if (isSchema) {
70
+ dataset.typed = false;
71
+ }
72
+ if (dataset.issues) {
73
+ dataset.issues.push(issue);
74
+ } else {
75
+ dataset.issues = [issue];
76
+ }
77
+ }
78
+ // @__NO_SIDE_EFFECTS__
79
+ function _getStandardProps(context) {
80
+ return {
81
+ version: 1,
82
+ vendor: "valibot",
83
+ validate(value2) {
84
+ return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
85
+ }
86
+ };
87
+ }
88
+ // @__NO_SIDE_EFFECTS__
89
+ function _isValidObjectKey(object2, key) {
90
+ return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
91
+ }
92
+ // @__NO_SIDE_EFFECTS__
93
+ function _joinExpects(values2, separator) {
94
+ const list = [...new Set(values2)];
95
+ if (list.length > 1) {
96
+ return `(${list.join(` ${separator} `)})`;
97
+ }
98
+ return list[0] ?? "never";
99
+ }
100
+ // @__NO_SIDE_EFFECTS__
101
+ function integer(message2) {
102
+ return {
103
+ kind: "validation",
104
+ type: "integer",
105
+ reference: integer,
106
+ async: false,
107
+ expects: null,
108
+ requirement: Number.isInteger,
109
+ message: message2,
110
+ "~run"(dataset, config2) {
111
+ if (dataset.typed && !this.requirement(dataset.value)) {
112
+ _addIssue(this, "integer", dataset, config2);
113
+ }
114
+ return dataset;
115
+ }
116
+ };
117
+ }
118
+ // @__NO_SIDE_EFFECTS__
119
+ function minLength(requirement, message2) {
120
+ return {
121
+ kind: "validation",
122
+ type: "min_length",
123
+ reference: minLength,
124
+ async: false,
125
+ expects: `>=${requirement}`,
126
+ requirement,
127
+ message: message2,
128
+ "~run"(dataset, config2) {
129
+ if (dataset.typed && dataset.value.length < this.requirement) {
130
+ _addIssue(this, "length", dataset, config2, {
131
+ received: `${dataset.value.length}`
132
+ });
133
+ }
134
+ return dataset;
135
+ }
136
+ };
137
+ }
138
+ // @__NO_SIDE_EFFECTS__
139
+ function minValue(requirement, message2) {
140
+ return {
141
+ kind: "validation",
142
+ type: "min_value",
143
+ reference: minValue,
144
+ async: false,
145
+ expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
146
+ requirement,
147
+ message: message2,
148
+ "~run"(dataset, config2) {
149
+ if (dataset.typed && !(dataset.value >= this.requirement)) {
150
+ _addIssue(this, "value", dataset, config2, {
151
+ received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
152
+ });
153
+ }
154
+ return dataset;
155
+ }
156
+ };
157
+ }
158
+ // @__NO_SIDE_EFFECTS__
159
+ function parseJson(config2, message2) {
160
+ return {
161
+ kind: "transformation",
162
+ type: "parse_json",
163
+ reference: parseJson,
164
+ config: config2,
165
+ message: message2,
166
+ async: false,
167
+ "~run"(dataset, config3) {
168
+ try {
169
+ dataset.value = JSON.parse(dataset.value, this.config?.reviver);
170
+ } catch (error) {
171
+ if (error instanceof Error) {
172
+ _addIssue(this, "JSON", dataset, config3, {
173
+ received: `"${error.message}"`
174
+ });
175
+ dataset.typed = false;
176
+ } else {
177
+ throw error;
178
+ }
179
+ }
180
+ return dataset;
181
+ }
182
+ };
183
+ }
184
+ // @__NO_SIDE_EFFECTS__
185
+ function regex(requirement, message2) {
186
+ return {
187
+ kind: "validation",
188
+ type: "regex",
189
+ reference: regex,
190
+ async: false,
191
+ expects: `${requirement}`,
192
+ requirement,
193
+ message: message2,
194
+ "~run"(dataset, config2) {
195
+ if (dataset.typed && !this.requirement.test(dataset.value)) {
196
+ _addIssue(this, "format", dataset, config2);
197
+ }
198
+ return dataset;
199
+ }
200
+ };
201
+ }
202
+ // @__NO_SIDE_EFFECTS__
203
+ function url(message2) {
204
+ return {
205
+ kind: "validation",
206
+ type: "url",
207
+ reference: url,
208
+ async: false,
209
+ expects: null,
210
+ requirement(input) {
211
+ try {
212
+ new URL(input);
213
+ return true;
214
+ } catch {
215
+ return false;
216
+ }
217
+ },
218
+ message: message2,
219
+ "~run"(dataset, config2) {
220
+ if (dataset.typed && !this.requirement(dataset.value)) {
221
+ _addIssue(this, "URL", dataset, config2);
222
+ }
223
+ return dataset;
224
+ }
225
+ };
226
+ }
227
+ // @__NO_SIDE_EFFECTS__
228
+ function getFallback(schema, dataset, config2) {
229
+ return typeof schema.fallback === "function" ? (
230
+ // @ts-expect-error
231
+ schema.fallback(dataset, config2)
232
+ ) : (
233
+ // @ts-expect-error
234
+ schema.fallback
235
+ );
236
+ }
237
+ // @__NO_SIDE_EFFECTS__
238
+ function getDefault(schema, dataset, config2) {
239
+ return typeof schema.default === "function" ? (
240
+ // @ts-expect-error
241
+ schema.default(dataset, config2)
242
+ ) : (
243
+ // @ts-expect-error
244
+ schema.default
245
+ );
246
+ }
247
+ // @__NO_SIDE_EFFECTS__
248
+ function array(item, message2) {
249
+ return {
250
+ kind: "schema",
251
+ type: "array",
252
+ reference: array,
253
+ expects: "Array",
254
+ async: false,
255
+ item,
256
+ message: message2,
257
+ get "~standard"() {
258
+ return /* @__PURE__ */ _getStandardProps(this);
259
+ },
260
+ "~run"(dataset, config2) {
261
+ const input = dataset.value;
262
+ if (Array.isArray(input)) {
263
+ dataset.typed = true;
264
+ dataset.value = [];
265
+ for (let key = 0; key < input.length; key++) {
266
+ const value2 = input[key];
267
+ const itemDataset = this.item["~run"]({ value: value2 }, config2);
268
+ if (itemDataset.issues) {
269
+ const pathItem = {
270
+ type: "array",
271
+ origin: "value",
272
+ input,
273
+ key,
274
+ value: value2
275
+ };
276
+ for (const issue of itemDataset.issues) {
277
+ if (issue.path) {
278
+ issue.path.unshift(pathItem);
279
+ } else {
280
+ issue.path = [pathItem];
281
+ }
282
+ dataset.issues?.push(issue);
283
+ }
284
+ if (!dataset.issues) {
285
+ dataset.issues = itemDataset.issues;
286
+ }
287
+ if (config2.abortEarly) {
288
+ dataset.typed = false;
289
+ break;
290
+ }
291
+ }
292
+ if (!itemDataset.typed) {
293
+ dataset.typed = false;
294
+ }
295
+ dataset.value.push(itemDataset.value);
296
+ }
297
+ } else {
298
+ _addIssue(this, "type", dataset, config2);
299
+ }
300
+ return dataset;
301
+ }
302
+ };
303
+ }
304
+ // @__NO_SIDE_EFFECTS__
305
+ function literal(literal_, message2) {
306
+ return {
307
+ kind: "schema",
308
+ type: "literal",
309
+ reference: literal,
310
+ expects: /* @__PURE__ */ _stringify(literal_),
311
+ async: false,
312
+ literal: literal_,
313
+ message: message2,
314
+ get "~standard"() {
315
+ return /* @__PURE__ */ _getStandardProps(this);
316
+ },
317
+ "~run"(dataset, config2) {
318
+ if (dataset.value === this.literal) {
319
+ dataset.typed = true;
320
+ } else {
321
+ _addIssue(this, "type", dataset, config2);
322
+ }
323
+ return dataset;
324
+ }
325
+ };
326
+ }
327
+ // @__NO_SIDE_EFFECTS__
328
+ function looseObject(entries2, message2) {
329
+ return {
330
+ kind: "schema",
331
+ type: "loose_object",
332
+ reference: looseObject,
333
+ expects: "Object",
334
+ async: false,
335
+ entries: entries2,
336
+ message: message2,
337
+ get "~standard"() {
338
+ return /* @__PURE__ */ _getStandardProps(this);
339
+ },
340
+ "~run"(dataset, config2) {
341
+ const input = dataset.value;
342
+ if (input && typeof input === "object") {
343
+ dataset.typed = true;
344
+ dataset.value = {};
345
+ for (const key in this.entries) {
346
+ const valueSchema = this.entries[key];
347
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
348
+ valueSchema.default !== void 0) {
349
+ const value2 = key in input ? (
350
+ // @ts-expect-error
351
+ input[key]
352
+ ) : /* @__PURE__ */ getDefault(valueSchema);
353
+ const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
354
+ if (valueDataset.issues) {
355
+ const pathItem = {
356
+ type: "object",
357
+ origin: "value",
358
+ input,
359
+ key,
360
+ value: value2
361
+ };
362
+ for (const issue of valueDataset.issues) {
363
+ if (issue.path) {
364
+ issue.path.unshift(pathItem);
365
+ } else {
366
+ issue.path = [pathItem];
367
+ }
368
+ dataset.issues?.push(issue);
369
+ }
370
+ if (!dataset.issues) {
371
+ dataset.issues = valueDataset.issues;
372
+ }
373
+ if (config2.abortEarly) {
374
+ dataset.typed = false;
375
+ break;
376
+ }
377
+ }
378
+ if (!valueDataset.typed) {
379
+ dataset.typed = false;
380
+ }
381
+ dataset.value[key] = valueDataset.value;
382
+ } else if (valueSchema.fallback !== void 0) {
383
+ dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
384
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
385
+ _addIssue(this, "key", dataset, config2, {
386
+ input: void 0,
387
+ expected: `"${key}"`,
388
+ path: [
389
+ {
390
+ type: "object",
391
+ origin: "key",
392
+ input,
393
+ key,
394
+ // @ts-expect-error
395
+ value: input[key]
396
+ }
397
+ ]
398
+ });
399
+ if (config2.abortEarly) {
400
+ break;
401
+ }
402
+ }
403
+ }
404
+ if (!dataset.issues || !config2.abortEarly) {
405
+ for (const key in input) {
406
+ if (/* @__PURE__ */ _isValidObjectKey(input, key) && !(key in this.entries)) {
407
+ dataset.value[key] = input[key];
408
+ }
409
+ }
410
+ }
411
+ } else {
412
+ _addIssue(this, "type", dataset, config2);
413
+ }
414
+ return dataset;
415
+ }
416
+ };
417
+ }
418
+ // @__NO_SIDE_EFFECTS__
419
+ function number(message2) {
420
+ return {
421
+ kind: "schema",
422
+ type: "number",
423
+ reference: number,
424
+ expects: "number",
425
+ async: false,
426
+ message: message2,
427
+ get "~standard"() {
428
+ return /* @__PURE__ */ _getStandardProps(this);
429
+ },
430
+ "~run"(dataset, config2) {
431
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
432
+ dataset.typed = true;
433
+ } else {
434
+ _addIssue(this, "type", dataset, config2);
435
+ }
436
+ return dataset;
437
+ }
438
+ };
439
+ }
440
+ // @__NO_SIDE_EFFECTS__
441
+ function object(entries2, message2) {
442
+ return {
443
+ kind: "schema",
444
+ type: "object",
445
+ reference: object,
446
+ expects: "Object",
447
+ async: false,
448
+ entries: entries2,
449
+ message: message2,
450
+ get "~standard"() {
451
+ return /* @__PURE__ */ _getStandardProps(this);
452
+ },
453
+ "~run"(dataset, config2) {
454
+ const input = dataset.value;
455
+ if (input && typeof input === "object") {
456
+ dataset.typed = true;
457
+ dataset.value = {};
458
+ for (const key in this.entries) {
459
+ const valueSchema = this.entries[key];
460
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
461
+ valueSchema.default !== void 0) {
462
+ const value2 = key in input ? (
463
+ // @ts-expect-error
464
+ input[key]
465
+ ) : /* @__PURE__ */ getDefault(valueSchema);
466
+ const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
467
+ if (valueDataset.issues) {
468
+ const pathItem = {
469
+ type: "object",
470
+ origin: "value",
471
+ input,
472
+ key,
473
+ value: value2
474
+ };
475
+ for (const issue of valueDataset.issues) {
476
+ if (issue.path) {
477
+ issue.path.unshift(pathItem);
478
+ } else {
479
+ issue.path = [pathItem];
480
+ }
481
+ dataset.issues?.push(issue);
482
+ }
483
+ if (!dataset.issues) {
484
+ dataset.issues = valueDataset.issues;
485
+ }
486
+ if (config2.abortEarly) {
487
+ dataset.typed = false;
488
+ break;
489
+ }
490
+ }
491
+ if (!valueDataset.typed) {
492
+ dataset.typed = false;
493
+ }
494
+ dataset.value[key] = valueDataset.value;
495
+ } else if (valueSchema.fallback !== void 0) {
496
+ dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
497
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
498
+ _addIssue(this, "key", dataset, config2, {
499
+ input: void 0,
500
+ expected: `"${key}"`,
501
+ path: [
502
+ {
503
+ type: "object",
504
+ origin: "key",
505
+ input,
506
+ key,
507
+ // @ts-expect-error
508
+ value: input[key]
509
+ }
510
+ ]
511
+ });
512
+ if (config2.abortEarly) {
513
+ break;
514
+ }
515
+ }
516
+ }
517
+ } else {
518
+ _addIssue(this, "type", dataset, config2);
519
+ }
520
+ return dataset;
521
+ }
522
+ };
523
+ }
524
+ // @__NO_SIDE_EFFECTS__
525
+ function optional(wrapped, default_) {
526
+ return {
527
+ kind: "schema",
528
+ type: "optional",
529
+ reference: optional,
530
+ expects: `(${wrapped.expects} | undefined)`,
531
+ async: false,
532
+ wrapped,
533
+ default: default_,
534
+ get "~standard"() {
535
+ return /* @__PURE__ */ _getStandardProps(this);
536
+ },
537
+ "~run"(dataset, config2) {
538
+ if (dataset.value === void 0) {
539
+ if (this.default !== void 0) {
540
+ dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
541
+ }
542
+ if (dataset.value === void 0) {
543
+ dataset.typed = true;
544
+ return dataset;
545
+ }
546
+ }
547
+ return this.wrapped["~run"](dataset, config2);
548
+ }
549
+ };
550
+ }
551
+ // @__NO_SIDE_EFFECTS__
552
+ function string(message2) {
553
+ return {
554
+ kind: "schema",
555
+ type: "string",
556
+ reference: string,
557
+ expects: "string",
558
+ async: false,
559
+ message: message2,
560
+ get "~standard"() {
561
+ return /* @__PURE__ */ _getStandardProps(this);
562
+ },
563
+ "~run"(dataset, config2) {
564
+ if (typeof dataset.value === "string") {
565
+ dataset.typed = true;
566
+ } else {
567
+ _addIssue(this, "type", dataset, config2);
568
+ }
569
+ return dataset;
570
+ }
571
+ };
572
+ }
573
+ // @__NO_SIDE_EFFECTS__
574
+ function _subIssues(datasets) {
575
+ let issues;
576
+ if (datasets) {
577
+ for (const dataset of datasets) {
578
+ if (issues) {
579
+ issues.push(...dataset.issues);
580
+ } else {
581
+ issues = dataset.issues;
582
+ }
583
+ }
584
+ }
585
+ return issues;
586
+ }
587
+ // @__NO_SIDE_EFFECTS__
588
+ function union(options, message2) {
589
+ return {
590
+ kind: "schema",
591
+ type: "union",
592
+ reference: union,
593
+ expects: /* @__PURE__ */ _joinExpects(
594
+ options.map((option) => option.expects),
595
+ "|"
596
+ ),
597
+ async: false,
598
+ options,
599
+ message: message2,
600
+ get "~standard"() {
601
+ return /* @__PURE__ */ _getStandardProps(this);
602
+ },
603
+ "~run"(dataset, config2) {
604
+ let validDataset;
605
+ let typedDatasets;
606
+ let untypedDatasets;
607
+ for (const schema of this.options) {
608
+ const optionDataset = schema["~run"]({ value: dataset.value }, config2);
609
+ if (optionDataset.typed) {
610
+ if (optionDataset.issues) {
611
+ if (typedDatasets) {
612
+ typedDatasets.push(optionDataset);
613
+ } else {
614
+ typedDatasets = [optionDataset];
615
+ }
616
+ } else {
617
+ validDataset = optionDataset;
618
+ break;
619
+ }
620
+ } else {
621
+ if (untypedDatasets) {
622
+ untypedDatasets.push(optionDataset);
623
+ } else {
624
+ untypedDatasets = [optionDataset];
625
+ }
626
+ }
627
+ }
628
+ if (validDataset) {
629
+ return validDataset;
630
+ }
631
+ if (typedDatasets) {
632
+ if (typedDatasets.length === 1) {
633
+ return typedDatasets[0];
634
+ }
635
+ _addIssue(this, "type", dataset, config2, {
636
+ issues: /* @__PURE__ */ _subIssues(typedDatasets)
637
+ });
638
+ dataset.typed = true;
639
+ } else if (untypedDatasets?.length === 1) {
640
+ return untypedDatasets[0];
641
+ } else {
642
+ _addIssue(this, "type", dataset, config2, {
643
+ issues: /* @__PURE__ */ _subIssues(untypedDatasets)
644
+ });
645
+ }
646
+ return dataset;
647
+ }
648
+ };
649
+ }
650
+ // @__NO_SIDE_EFFECTS__
651
+ function pipe(...pipe2) {
652
+ return {
653
+ ...pipe2[0],
654
+ pipe: pipe2,
655
+ get "~standard"() {
656
+ return /* @__PURE__ */ _getStandardProps(this);
657
+ },
658
+ "~run"(dataset, config2) {
659
+ for (const item of pipe2) {
660
+ if (item.kind !== "metadata") {
661
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
662
+ dataset.typed = false;
663
+ break;
664
+ }
665
+ if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
666
+ dataset = item["~run"](dataset, config2);
667
+ }
668
+ }
669
+ }
670
+ return dataset;
671
+ }
672
+ };
673
+ }
674
+ // @__NO_SIDE_EFFECTS__
675
+ function safeParse(schema, input, config2) {
676
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
677
+ return {
678
+ typed: dataset.typed,
679
+ success: !dataset.issues,
680
+ output: dataset.value,
681
+ issues: dataset.issues
682
+ };
683
+ }
684
+
685
+ // ../../dev/server/src/api-key.ts
686
+ var POSTGRES_PROTOCOL_REGEX = /^(postgres|postgresql):\/\//;
687
+ var decodedAPIKeySchema = pipe(
688
+ string(),
689
+ parseJson(),
690
+ object({
691
+ databaseUrl: pipe(string(), url(), regex(POSTGRES_PROTOCOL_REGEX)),
692
+ name: optional(pipe(string(), minLength(1))),
693
+ shadowDatabaseUrl: pipe(string(), url(), regex(POSTGRES_PROTOCOL_REGEX))
694
+ })
695
+ );
696
+ function encodeAPIKey(payload) {
697
+ return Buffer.from(
698
+ // we sort the keys to ensure consistent encoding
699
+ JSON.stringify(Object.fromEntries(Object.entries(payload).sort(([[key0], [key1]]) => key0.localeCompare(key1)))),
700
+ "utf8"
701
+ ).toString("base64url");
702
+ }
703
+ function decodeAPIKey(apiKey) {
704
+ const serialized = Buffer.from(apiKey, "base64url").toString("utf8");
705
+ const { issues, output, success } = safeParse(decodedAPIKeySchema, serialized, { abortEarly: true });
706
+ if (!success) {
707
+ return [issues];
708
+ }
709
+ return [null, output];
710
+ }
711
+ var apiKeyValidator = async (value, ctx) => {
712
+ const { authorization } = value;
713
+ const { HTTPException } = await import("hono/http-exception");
714
+ if (!authorization) {
715
+ throw new HTTPException(401, { message: "Missing API Key" });
716
+ }
717
+ const [keyType, apiKey = "", extras] = authorization.split(" ");
718
+ if (keyType !== "Bearer" || extras) {
719
+ throw new HTTPException(401, { message: "Invalid API Key" });
720
+ }
721
+ const [issues, decodedAPIKey] = decodeAPIKey(apiKey);
722
+ if (issues) {
723
+ throw new HTTPException(401, { message: "Invalid API Key", cause: issues.join(", ") });
724
+ }
725
+ const { databaseUrl, name, shadowDatabaseUrl } = decodedAPIKey;
726
+ const { name: expectedName } = ctx.get("serverState");
727
+ if (!name) {
728
+ throw new HTTPException(401, {
729
+ message: `Wrong API Key; The Prisma Dev server running at port ${ctx.get("port")} requires an API Key from a newer version of \`prisma dev\`. Check the "${expectedName}" server's output for the updated \`DATABASE_URL\` value.`
730
+ });
731
+ }
732
+ if (name !== expectedName) {
733
+ throw new HTTPException(401, {
734
+ message: `Wrong API Key; The Prisma Dev server running at port ${ctx.get("port")} is named "${expectedName}", but the API Key is for "${name}"`
735
+ });
736
+ }
737
+ const { hostname, port } = new URL(databaseUrl);
738
+ const { port: expectedPort } = ctx.get("db");
739
+ const { hostname: shadowHostname, port: shadowPort } = new URL(shadowDatabaseUrl);
740
+ const expectedShadowPort = ctx.get("shadowDBPort");
741
+ if (hostname !== "localhost" || Number(port) !== expectedPort || shadowHostname !== "localhost" || Number(shadowPort) !== expectedShadowPort) {
742
+ throw new HTTPException(401, {
743
+ message: "Wrong API Key; Check your Prisma schema's `provider.url` value (probably defined in `.env`'s `DATABASE_URL` environment variable) is aligned with `prisma dev`'s output"
744
+ });
745
+ }
746
+ return { decodedAPIKey };
747
+ };
748
+
749
+ // ../../dev/server/src/engine.ts
750
+ import { spawn } from "child_process";
751
+ import { once } from "events";
752
+ import { mkdir as mkdir2 } from "fs/promises";
753
+ import { join } from "path";
754
+ import { setTimeout } from "timers/promises";
755
+
756
+ // ../../common/stuff/with-resolvers.ts
757
+ function withResolvers(options) {
758
+ let succeed, fail;
759
+ const promise = new Promise((resolve2, reject) => {
760
+ succeed = resolve2;
761
+ fail = reject;
762
+ });
763
+ let failOnce = (reason) => {
764
+ failOnce = succeedOnce = null;
765
+ fail(reason);
766
+ options?.onRejected?.(reason);
767
+ options?.onFulfilled?.();
768
+ };
769
+ let succeedOnce = (value) => {
770
+ succeedOnce = failOnce = null;
771
+ succeed(value);
772
+ options?.onResolved?.(value);
773
+ options?.onFulfilled?.();
774
+ };
775
+ return {
776
+ isFulfilled: () => succeedOnce === failOnce,
777
+ promise,
778
+ reject: (reason) => failOnce?.(reason),
779
+ resolve: (value) => succeedOnce?.(value)
780
+ };
781
+ }
782
+
783
+ // ../../node_modules/.pnpm/std-env@3.9.0/node_modules/std-env/dist/index.mjs
784
+ var r = /* @__PURE__ */ Object.create(null);
785
+ var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
786
+ var o = new Proxy(r, { get(e, s) {
787
+ return i()[s] ?? r[s];
788
+ }, has(e, s) {
789
+ const E = i();
790
+ return s in E || s in r;
791
+ }, set(e, s, E) {
792
+ const B = i(true);
793
+ return B[s] = E, true;
794
+ }, deleteProperty(e, s) {
795
+ if (!s)
796
+ return false;
797
+ const E = i(true);
798
+ return delete E[s], true;
799
+ }, ownKeys() {
800
+ const e = i(true);
801
+ return Object.keys(e);
802
+ } });
803
+ var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
804
+ var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CLOUDFLARE_WORKERS", "WORKERS_CI", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
805
+ function b() {
806
+ if (globalThis.process?.env)
807
+ for (const e of f) {
808
+ const s = e[1] || e[0];
809
+ if (globalThis.process?.env[s])
810
+ return { name: e[0].toLowerCase(), ...e[2] };
811
+ }
812
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
813
+ }
814
+ var l = b();
815
+ var p = l.name;
816
+ function n(e) {
817
+ return e ? e !== "false" : false;
818
+ }
819
+ var I = globalThis.process?.platform || "";
820
+ var T = n(o.CI) || l.ci !== false;
821
+ var R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
822
+ var d = n(o.DEBUG);
823
+ var a = t === "test" || n(o.TEST);
824
+ var v = n(o.MINIMAL) || T || a || !R;
825
+ var A = /^win/i.test(I);
826
+ var M = /^linux/i.test(I);
827
+ var m = /^darwin/i.test(I);
828
+ var Y = !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (R || A) && o.TERM !== "dumb" || T);
829
+ var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
830
+ var V = Number(C?.split(".")[0]) || null;
831
+ var W = globalThis.process || /* @__PURE__ */ Object.create(null);
832
+ var _ = { versions: {} };
833
+ var y = new Proxy(W, { get(e, s) {
834
+ if (s === "env")
835
+ return o;
836
+ if (s in e)
837
+ return e[s];
838
+ if (s in _)
839
+ return _[s];
840
+ } });
841
+ var O = globalThis.process?.release?.name === "node";
842
+ var c = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
843
+ var D = !!globalThis.Deno;
844
+ var L = !!globalThis.fastly;
845
+ var S = !!globalThis.Netlify;
846
+ var u = !!globalThis.EdgeRuntime;
847
+ var N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
848
+ var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [c, "bun"], [O, "node"]];
849
+ function G() {
850
+ const e = F.find((s) => s[0]);
851
+ if (e)
852
+ return { name: e[1] };
853
+ }
854
+ var P = G();
855
+ var K = P?.name || "";
856
+
857
+ // ../../dev/server/src/filesystem.ts
858
+ import { createWriteStream, WriteStream } from "fs";
859
+ import { access, chmod, constants, mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
860
+ import { promisify } from "util";
861
+ import { unzip } from "zlib";
862
+
863
+ // ../../node_modules/.pnpm/env-paths@3.0.0/node_modules/env-paths/index.js
864
+ import path from "path";
865
+ import os from "os";
866
+ import process2 from "process";
867
+ var homedir = os.homedir();
868
+ var tmpdir = os.tmpdir();
869
+ var { env } = process2;
870
+ var macos = (name) => {
871
+ const library = path.join(homedir, "Library");
872
+ return {
873
+ data: path.join(library, "Application Support", name),
874
+ config: path.join(library, "Preferences", name),
875
+ cache: path.join(library, "Caches", name),
876
+ log: path.join(library, "Logs", name),
877
+ temp: path.join(tmpdir, name)
878
+ };
879
+ };
880
+ var windows = (name) => {
881
+ const appData = env.APPDATA || path.join(homedir, "AppData", "Roaming");
882
+ const localAppData = env.LOCALAPPDATA || path.join(homedir, "AppData", "Local");
883
+ return {
884
+ // Data/config/cache/log are invented by me as Windows isn't opinionated about this
885
+ data: path.join(localAppData, name, "Data"),
886
+ config: path.join(appData, name, "Config"),
887
+ cache: path.join(localAppData, name, "Cache"),
888
+ log: path.join(localAppData, name, "Log"),
889
+ temp: path.join(tmpdir, name)
890
+ };
891
+ };
892
+ var linux = (name) => {
893
+ const username = path.basename(homedir);
894
+ return {
895
+ data: path.join(env.XDG_DATA_HOME || path.join(homedir, ".local", "share"), name),
896
+ config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, ".config"), name),
897
+ cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, ".cache"), name),
898
+ // https://wiki.debian.org/XDGBaseDirectorySpecification#state
899
+ log: path.join(env.XDG_STATE_HOME || path.join(homedir, ".local", "state"), name),
900
+ temp: path.join(tmpdir, username, name)
901
+ };
902
+ };
903
+ function envPaths(name, { suffix = "nodejs" } = {}) {
904
+ if (typeof name !== "string") {
905
+ throw new TypeError(`Expected a string, got ${typeof name}`);
906
+ }
907
+ if (suffix) {
908
+ name += `-${suffix}`;
909
+ }
910
+ if (process2.platform === "darwin") {
911
+ return macos(name);
912
+ }
913
+ if (process2.platform === "win32") {
914
+ return windows(name);
915
+ }
916
+ return linux(name);
917
+ }
918
+
919
+ // ../../node_modules/.pnpm/grammex@3.1.10/node_modules/grammex/dist/utils.js
920
+ var isArray = (value) => {
921
+ return Array.isArray(value);
922
+ };
923
+ var isFunction = (value) => {
924
+ return typeof value === "function";
925
+ };
926
+ var isFunctionNullary = (value) => {
927
+ return value.length === 0;
928
+ };
929
+ var isFunctionStrictlyNullaryOrUnary = (() => {
930
+ const { toString } = Function.prototype;
931
+ const re = /(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;
932
+ return (value) => {
933
+ return (value.length === 0 || value.length === 1) && re.test(toString.call(value));
934
+ };
935
+ })();
936
+ var isNumber = (value) => {
937
+ return typeof value === "number";
938
+ };
939
+ var isObject = (value) => {
940
+ return typeof value === "object" && value !== null;
941
+ };
942
+ var isRegExp = (value) => {
943
+ return value instanceof RegExp;
944
+ };
945
+ var isRegExpCapturing = /* @__PURE__ */ (() => {
946
+ const sourceRe = /\\\(|\((?!\?(?::|=|!|<=|<!))/;
947
+ return (re) => {
948
+ return sourceRe.test(re.source);
949
+ };
950
+ })();
951
+ var isRegExpStatic = /* @__PURE__ */ (() => {
952
+ const sourceRe = /^[a-zA-Z0-9_-]+$/;
953
+ return (re) => {
954
+ return sourceRe.test(re.source) && !re.flags.includes("i");
955
+ };
956
+ })();
957
+ var isString = (value) => {
958
+ return typeof value === "string";
959
+ };
960
+ var isUndefined = (value) => {
961
+ return value === void 0;
962
+ };
963
+ var memoize = (fn) => {
964
+ const cache = /* @__PURE__ */ new Map();
965
+ return (arg) => {
966
+ const cached = cache.get(arg);
967
+ if (cached !== void 0)
968
+ return cached;
969
+ const value = fn(arg);
970
+ cache.set(arg, value);
971
+ return value;
972
+ };
973
+ };
974
+
975
+ // ../../node_modules/.pnpm/grammex@3.1.10/node_modules/grammex/dist/index.js
976
+ var parse = (input, rule, options = {}) => {
977
+ const state = { cache: {}, input, index: 0, indexBacktrackMax: 0, options, output: [] };
978
+ const matched = resolve(rule)(state);
979
+ const indexMax = Math.max(state.index, state.indexBacktrackMax);
980
+ if (matched && state.index === input.length) {
981
+ return state.output;
982
+ } else {
983
+ throw new Error(`Failed to parse at index ${indexMax}`);
984
+ }
985
+ };
986
+ var match = (target, handler) => {
987
+ if (isArray(target)) {
988
+ return chars(target, handler);
989
+ } else if (isString(target)) {
990
+ return string2(target, handler);
991
+ } else {
992
+ return regex2(target, handler);
993
+ }
994
+ };
995
+ var chars = (target, handler) => {
996
+ const charCodes = {};
997
+ for (const char of target) {
998
+ if (char.length !== 1)
999
+ throw new Error(`Invalid character: "${char}"`);
1000
+ const charCode = char.charCodeAt(0);
1001
+ charCodes[charCode] = true;
1002
+ }
1003
+ return (state) => {
1004
+ const input = state.input;
1005
+ let indexStart = state.index;
1006
+ let indexEnd = indexStart;
1007
+ while (indexEnd < input.length) {
1008
+ const charCode = input.charCodeAt(indexEnd);
1009
+ if (!(charCode in charCodes))
1010
+ break;
1011
+ indexEnd += 1;
1012
+ }
1013
+ if (indexEnd > indexStart) {
1014
+ if (!isUndefined(handler) && !state.options.silent) {
1015
+ const target2 = input.slice(indexStart, indexEnd);
1016
+ const output = isFunction(handler) ? handler(target2, input, `${indexStart}`) : handler;
1017
+ if (!isUndefined(output)) {
1018
+ state.output.push(output);
1019
+ }
1020
+ }
1021
+ state.index = indexEnd;
1022
+ }
1023
+ return true;
1024
+ };
1025
+ };
1026
+ var regex2 = (target, handler) => {
1027
+ if (isRegExpStatic(target)) {
1028
+ return string2(target.source, handler);
1029
+ } else {
1030
+ const source = target.source;
1031
+ const flags = target.flags.replace(/y|$/, "y");
1032
+ const re = new RegExp(source, flags);
1033
+ if (isRegExpCapturing(target) && isFunction(handler) && !isFunctionStrictlyNullaryOrUnary(handler)) {
1034
+ return regexCapturing(re, handler);
1035
+ } else {
1036
+ return regexNonCapturing(re, handler);
1037
+ }
1038
+ }
1039
+ };
1040
+ var regexCapturing = (re, handler) => {
1041
+ return (state) => {
1042
+ const indexStart = state.index;
1043
+ const input = state.input;
1044
+ re.lastIndex = indexStart;
1045
+ const match2 = re.exec(input);
1046
+ if (match2) {
1047
+ const indexEnd = re.lastIndex;
1048
+ if (!state.options.silent) {
1049
+ const output = handler(...match2, input, `${indexStart}`);
1050
+ if (!isUndefined(output)) {
1051
+ state.output.push(output);
1052
+ }
1053
+ }
1054
+ state.index = indexEnd;
1055
+ return true;
1056
+ } else {
1057
+ return false;
1058
+ }
1059
+ };
1060
+ };
1061
+ var regexNonCapturing = (re, handler) => {
1062
+ return (state) => {
1063
+ const indexStart = state.index;
1064
+ const input = state.input;
1065
+ re.lastIndex = indexStart;
1066
+ const matched = re.test(input);
1067
+ if (matched) {
1068
+ const indexEnd = re.lastIndex;
1069
+ if (!isUndefined(handler) && !state.options.silent) {
1070
+ const output = isFunction(handler) ? handler(input.slice(indexStart, indexEnd), input, `${indexStart}`) : handler;
1071
+ if (!isUndefined(output)) {
1072
+ state.output.push(output);
1073
+ }
1074
+ }
1075
+ state.index = indexEnd;
1076
+ return true;
1077
+ } else {
1078
+ return false;
1079
+ }
1080
+ };
1081
+ };
1082
+ var string2 = (target, handler) => {
1083
+ return (state) => {
1084
+ const indexStart = state.index;
1085
+ const input = state.input;
1086
+ const matched = input.startsWith(target, indexStart);
1087
+ if (matched) {
1088
+ if (!isUndefined(handler) && !state.options.silent) {
1089
+ const output = isFunction(handler) ? handler(target, input, `${indexStart}`) : handler;
1090
+ if (!isUndefined(output)) {
1091
+ state.output.push(output);
1092
+ }
1093
+ }
1094
+ state.index += target.length;
1095
+ return true;
1096
+ } else {
1097
+ return false;
1098
+ }
1099
+ };
1100
+ };
1101
+ var repeat = (rule, min, max, handler) => {
1102
+ const erule = resolve(rule);
1103
+ const isBacktrackable = min > 1;
1104
+ return memoizable(handleable(backtrackable((state) => {
1105
+ let repetitions = 0;
1106
+ while (repetitions < max) {
1107
+ const index = state.index;
1108
+ const matched = erule(state);
1109
+ if (!matched)
1110
+ break;
1111
+ repetitions += 1;
1112
+ if (state.index === index)
1113
+ break;
1114
+ }
1115
+ return repetitions >= min;
1116
+ }, isBacktrackable), handler));
1117
+ };
1118
+ var optional2 = (rule, handler) => {
1119
+ return repeat(rule, 0, 1, handler);
1120
+ };
1121
+ var star = (rule, handler) => {
1122
+ return repeat(rule, 0, Infinity, handler);
1123
+ };
1124
+ var and = (rules, handler) => {
1125
+ const erules = rules.map(resolve);
1126
+ return memoizable(handleable(backtrackable((state) => {
1127
+ for (let i2 = 0, l2 = erules.length; i2 < l2; i2++) {
1128
+ if (!erules[i2](state))
1129
+ return false;
1130
+ }
1131
+ return true;
1132
+ }), handler));
1133
+ };
1134
+ var or = (rules, handler) => {
1135
+ const erules = rules.map(resolve);
1136
+ return memoizable(handleable((state) => {
1137
+ for (let i2 = 0, l2 = erules.length; i2 < l2; i2++) {
1138
+ if (erules[i2](state))
1139
+ return true;
1140
+ }
1141
+ return false;
1142
+ }, handler));
1143
+ };
1144
+ var backtrackable = (rule, enabled = true, force = false) => {
1145
+ const erule = resolve(rule);
1146
+ if (!enabled)
1147
+ return erule;
1148
+ return (state) => {
1149
+ const index = state.index;
1150
+ const length = state.output.length;
1151
+ const matched = erule(state);
1152
+ if (!matched && !force) {
1153
+ state.indexBacktrackMax = Math.max(state.indexBacktrackMax, state.index);
1154
+ }
1155
+ if (!matched || force) {
1156
+ state.index = index;
1157
+ if (state.output.length !== length) {
1158
+ state.output.length = length;
1159
+ }
1160
+ }
1161
+ return matched;
1162
+ };
1163
+ };
1164
+ var handleable = (rule, handler) => {
1165
+ const erule = resolve(rule);
1166
+ if (!handler)
1167
+ return erule;
1168
+ return (state) => {
1169
+ if (state.options.silent)
1170
+ return erule(state);
1171
+ const length = state.output.length;
1172
+ const matched = erule(state);
1173
+ if (matched) {
1174
+ const outputs = state.output.splice(length, Infinity);
1175
+ const output = handler(outputs);
1176
+ if (!isUndefined(output)) {
1177
+ state.output.push(output);
1178
+ }
1179
+ return true;
1180
+ } else {
1181
+ return false;
1182
+ }
1183
+ };
1184
+ };
1185
+ var memoizable = /* @__PURE__ */ (() => {
1186
+ let RULE_ID = 0;
1187
+ return (rule) => {
1188
+ const erule = resolve(rule);
1189
+ const ruleId = RULE_ID += 1;
1190
+ return (state) => {
1191
+ var _a;
1192
+ if (state.options.memoization === false)
1193
+ return erule(state);
1194
+ const indexStart = state.index;
1195
+ const cache = (_a = state.cache)[ruleId] || (_a[ruleId] = { indexMax: -1, queue: [] });
1196
+ const cacheQueue = cache.queue;
1197
+ const isPotentiallyCached = indexStart <= cache.indexMax;
1198
+ if (isPotentiallyCached) {
1199
+ const cacheStore = cache.store || (cache.store = /* @__PURE__ */ new Map());
1200
+ if (cacheQueue.length) {
1201
+ for (let i2 = 0, l2 = cacheQueue.length; i2 < l2; i2 += 2) {
1202
+ const key = cacheQueue[i2 * 2];
1203
+ const value = cacheQueue[i2 * 2 + 1];
1204
+ cacheStore.set(key, value);
1205
+ }
1206
+ cacheQueue.length = 0;
1207
+ }
1208
+ const cached = cacheStore.get(indexStart);
1209
+ if (cached === false) {
1210
+ return false;
1211
+ } else if (isNumber(cached)) {
1212
+ state.index = cached;
1213
+ return true;
1214
+ } else if (cached) {
1215
+ state.index = cached.index;
1216
+ if (cached.output?.length) {
1217
+ state.output.push(...cached.output);
1218
+ }
1219
+ return true;
1220
+ }
1221
+ }
1222
+ const lengthStart = state.output.length;
1223
+ const matched = erule(state);
1224
+ cache.indexMax = Math.max(cache.indexMax, indexStart);
1225
+ if (matched) {
1226
+ const indexEnd = state.index;
1227
+ const lengthEnd = state.output.length;
1228
+ if (lengthEnd > lengthStart) {
1229
+ const output = state.output.slice(lengthStart, lengthEnd);
1230
+ cacheQueue.push(indexStart, { index: indexEnd, output });
1231
+ } else {
1232
+ cacheQueue.push(indexStart, indexEnd);
1233
+ }
1234
+ return true;
1235
+ } else {
1236
+ cacheQueue.push(indexStart, false);
1237
+ return false;
1238
+ }
1239
+ };
1240
+ };
1241
+ })();
1242
+ var lazy = (getter) => {
1243
+ let erule;
1244
+ return (state) => {
1245
+ erule || (erule = resolve(getter()));
1246
+ return erule(state);
1247
+ };
1248
+ };
1249
+ var resolve = memoize((rule) => {
1250
+ if (isFunction(rule)) {
1251
+ if (isFunctionNullary(rule)) {
1252
+ return lazy(rule);
1253
+ } else {
1254
+ return rule;
1255
+ }
1256
+ }
1257
+ if (isString(rule) || isRegExp(rule)) {
1258
+ return match(rule);
1259
+ }
1260
+ if (isArray(rule)) {
1261
+ return and(rule);
1262
+ }
1263
+ if (isObject(rule)) {
1264
+ return or(Object.values(rule));
1265
+ }
1266
+ throw new Error("Invalid rule");
1267
+ });
1268
+
1269
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/utils.js
1270
+ var identity = (value) => {
1271
+ return value;
1272
+ };
1273
+ var makeParser = (grammar) => {
1274
+ return (input) => {
1275
+ return parse(input, grammar, { memoization: false }).join("");
1276
+ };
1277
+ };
1278
+ var memoize2 = (fn) => {
1279
+ const cache = {};
1280
+ return (arg) => {
1281
+ return cache[arg] ?? (cache[arg] = fn(arg));
1282
+ };
1283
+ };
1284
+
1285
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/range.js
1286
+ var ALPHABET = "abcdefghijklmnopqrstuvwxyz";
1287
+ var int2alpha = (int) => {
1288
+ let alpha = "";
1289
+ while (int > 0) {
1290
+ const reminder = (int - 1) % 26;
1291
+ alpha = ALPHABET[reminder] + alpha;
1292
+ int = Math.floor((int - 1) / 26);
1293
+ }
1294
+ return alpha;
1295
+ };
1296
+ var alpha2int = (str) => {
1297
+ let int = 0;
1298
+ for (let i2 = 0, l2 = str.length; i2 < l2; i2++) {
1299
+ int = int * 26 + ALPHABET.indexOf(str[i2]) + 1;
1300
+ }
1301
+ return int;
1302
+ };
1303
+ var makeRangeInt = (start, end) => {
1304
+ if (end < start)
1305
+ return makeRangeInt(end, start);
1306
+ const range = [];
1307
+ while (start <= end) {
1308
+ range.push(start++);
1309
+ }
1310
+ return range;
1311
+ };
1312
+ var makeRangePaddedInt = (start, end, paddingLength) => {
1313
+ return makeRangeInt(start, end).map((int) => String(int).padStart(paddingLength, "0"));
1314
+ };
1315
+ var makeRangeAlpha = (start, end) => {
1316
+ return makeRangeInt(alpha2int(start), alpha2int(end)).map(int2alpha);
1317
+ };
1318
+
1319
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/convert/grammar.js
1320
+ var Escaped = match(/\\./, identity);
1321
+ var Escape = match(/[$.*+?^(){}[\]\|]/, (char) => `\\${char}`);
1322
+ var Slash = match(/[\\/]/, "[\\\\/]");
1323
+ var Passthrough = match(/./, identity);
1324
+ var NegationOdd = match(/^(?:!!)*!(.*)$/, (_2, glob) => `(?!^${parser_default(glob)}$).*?`);
1325
+ var NegationEven = match(/^(!!)+/, "");
1326
+ var Negation = or([NegationOdd, NegationEven]);
1327
+ var StarStarBetween = match(/\/(\*\*\/)+/, "(?:[\\\\/].+[\\\\/]|[\\\\/])");
1328
+ var StarStarStart = match(/^(\*\*\/)+/, "(?:^|.*[\\\\/])");
1329
+ var StarStarEnd = match(/\/(\*\*)$/, "(?:[\\\\/].*|$)");
1330
+ var StarStarNone = match(/\*\*/, ".*");
1331
+ var StarStar = or([StarStarBetween, StarStarStart, StarStarEnd, StarStarNone]);
1332
+ var StarDouble = match(/\*\/(?!\*\*\/|\*$)/, "[^\\\\/]*[\\\\/]");
1333
+ var StarSingle = match(/\*/, "[^\\\\/]*");
1334
+ var Star = or([StarDouble, StarSingle]);
1335
+ var Question = match("?", "[^\\\\/]");
1336
+ var ClassOpen = match("[", identity);
1337
+ var ClassClose = match("]", identity);
1338
+ var ClassNegation = match(/[!^]/, "^\\\\/");
1339
+ var ClassRange = match(/[a-z]-[a-z]|[0-9]-[0-9]/i, identity);
1340
+ var ClassEscape = match(/[$.*+?^(){}[\|]/, (char) => `\\${char}`);
1341
+ var ClassPassthrough = match(/[^\]]/, identity);
1342
+ var ClassValue = or([Escaped, ClassEscape, ClassRange, ClassPassthrough]);
1343
+ var Class = and([ClassOpen, optional2(ClassNegation), star(ClassValue), ClassClose]);
1344
+ var RangeOpen = match("{", "(?:");
1345
+ var RangeClose = match("}", ")");
1346
+ var RangeNumeric = match(/(\d+)\.\.(\d+)/, (_2, $1, $2) => makeRangePaddedInt(+$1, +$2, Math.min($1.length, $2.length)).join("|"));
1347
+ var RangeAlphaLower = match(/([a-z]+)\.\.([a-z]+)/, (_2, $1, $2) => makeRangeAlpha($1, $2).join("|"));
1348
+ var RangeAlphaUpper = match(/([A-Z]+)\.\.([A-Z]+)/, (_2, $1, $2) => makeRangeAlpha($1.toLowerCase(), $2.toLowerCase()).join("|").toUpperCase());
1349
+ var RangeValue = or([RangeNumeric, RangeAlphaLower, RangeAlphaUpper]);
1350
+ var Range = and([RangeOpen, RangeValue, RangeClose]);
1351
+ var BracesOpen = match("{", "(?:");
1352
+ var BracesClose = match("}", ")");
1353
+ var BracesComma = match(",", "|");
1354
+ var BracesEscape = match(/[$.*+?^(){[\]\|]/, (char) => `\\${char}`);
1355
+ var BracesPassthrough = match(/[^}]/, identity);
1356
+ var BracesNested = lazy(() => Braces);
1357
+ var BracesValue = or([StarStar, Star, Question, Class, Range, BracesNested, Escaped, BracesEscape, BracesComma, BracesPassthrough]);
1358
+ var Braces = and([BracesOpen, star(BracesValue), BracesClose]);
1359
+ var Grammar = star(or([Negation, StarStar, Star, Question, Class, Range, Braces, Escaped, Escape, Slash, Passthrough]));
1360
+ var grammar_default = Grammar;
1361
+
1362
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/convert/parser.js
1363
+ var parser = makeParser(grammar_default);
1364
+ var parser_default = parser;
1365
+
1366
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/normalize/grammar.js
1367
+ var Escaped2 = match(/\\./, identity);
1368
+ var Passthrough2 = match(/./, identity);
1369
+ var StarStarStar = match(/\*\*\*+/, "*");
1370
+ var StarStarNoLeft = match(/([^/{[(!])\*\*/, (_2, $1) => `${$1}*`);
1371
+ var StarStarNoRight = match(/(^|.)\*\*(?=[^*/)\]}])/, (_2, $1) => `${$1}*`);
1372
+ var Grammar2 = star(or([Escaped2, StarStarStar, StarStarNoLeft, StarStarNoRight, Passthrough2]));
1373
+ var grammar_default2 = Grammar2;
1374
+
1375
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/normalize/parser.js
1376
+ var parser2 = makeParser(grammar_default2);
1377
+ var parser_default2 = parser2;
1378
+
1379
+ // ../../node_modules/.pnpm/zeptomatch@2.0.2/node_modules/zeptomatch/dist/index.js
1380
+ var zeptomatch = (glob, path2) => {
1381
+ if (Array.isArray(glob)) {
1382
+ const res = glob.map(zeptomatch.compile);
1383
+ const isMatch = res.some((re) => re.test(path2));
1384
+ return isMatch;
1385
+ } else {
1386
+ const re = zeptomatch.compile(glob);
1387
+ const isMatch = re.test(path2);
1388
+ return isMatch;
1389
+ }
1390
+ };
1391
+ zeptomatch.compile = memoize2((glob) => {
1392
+ return new RegExp(`^${parser_default(parser_default2(glob))}[\\\\/]?$`, "s");
1393
+ });
1394
+ var dist_default = zeptomatch;
1395
+
1396
+ // ../../dev/server/src/filesystem.ts
1397
+ var GLOBAL_DIR_ROOT_PATH = envPaths("prisma-dev");
1398
+ var unzipAsync = promisify(unzip);
1399
+ function getEngineCacheDirPath(version, commitHash) {
1400
+ return `${GLOBAL_DIR_ROOT_PATH.cache}/engine/${version}/${commitHash}`;
1401
+ }
1402
+ function getDataDirPath(name) {
1403
+ return `${GLOBAL_DIR_ROOT_PATH.data}/${name}`;
1404
+ }
1405
+ async function checkFileExists(filePath) {
1406
+ try {
1407
+ await access(filePath, constants.F_OK);
1408
+ return true;
1409
+ } catch (error) {
1410
+ if (isFileNotFoundError(error)) {
1411
+ return false;
1412
+ }
1413
+ throw error;
1414
+ }
1415
+ }
1416
+ async function writeBinaryFile(buffer, path2) {
1417
+ const result = await unzipAsync(buffer);
1418
+ await writeFile(path2, result);
1419
+ await chmod(path2, "755");
1420
+ }
1421
+ async function streamAsTextTo(file, path2) {
1422
+ await file.stream().pipeTo(WriteStream.toWeb(createWriteStream(path2, { encoding: "utf-8" })));
1423
+ }
1424
+ function isFileNotFoundError(error) {
1425
+ return error != null && typeof error === "object" && "code" in error && error.code === "ENOENT";
1426
+ }
1427
+ async function readFileAsText(path2) {
1428
+ try {
1429
+ return await readFile(path2, { encoding: "utf-8" });
1430
+ } catch (error) {
1431
+ if (isFileNotFoundError(error)) {
1432
+ return null;
1433
+ }
1434
+ throw error;
1435
+ }
1436
+ }
1437
+ async function ensureDirectory(path2) {
1438
+ await mkdir(path2, { recursive: true });
1439
+ }
1440
+ async function readDirectoryNames(path2, globs) {
1441
+ try {
1442
+ const dirents = await readdir(path2, { withFileTypes: true });
1443
+ return dirents.reduce((names, dirent) => {
1444
+ if (dirent.isDirectory() && !dirent.name.startsWith(".") && (!globs || dist_default(globs, dirent.name))) {
1445
+ names.push(dirent.name);
1446
+ }
1447
+ return names;
1448
+ }, []);
1449
+ } catch (error) {
1450
+ if (isFileNotFoundError(error)) {
1451
+ return [];
1452
+ }
1453
+ throw error;
1454
+ }
1455
+ }
1456
+
1457
+ // ../../dev/server/src/engine.ts
1458
+ var {
1459
+ PRISMA_DEV_FORCE_ENGINE_BINARY_DOWNLOAD,
1460
+ PRISMA_DEV_FORCE_ENGINE_BINARY_PATH,
1461
+ PRISMA_DEV_FORCE_NETWORK_DELAY_MS
1462
+ } = y.env;
1463
+ var Engine = class _Engine {
1464
+ static #enginesBySchemaAndClientVersion = /* @__PURE__ */ new Map();
1465
+ #options;
1466
+ #session;
1467
+ constructor(options) {
1468
+ this.#options = options;
1469
+ this.#session = null;
1470
+ }
1471
+ static async get(options) {
1472
+ const { debug } = options;
1473
+ const engineId = `${options.schemaHash}:${options.clientVersion}`;
1474
+ try {
1475
+ const engine = _Engine.#enginesBySchemaAndClientVersion.get(engineId);
1476
+ if (engine) {
1477
+ return engine;
1478
+ }
1479
+ const newEngine = new _Engine(options);
1480
+ _Engine.#enginesBySchemaAndClientVersion.set(engineId, newEngine);
1481
+ if (debug) {
1482
+ console.debug("[Query Engine] starting...", options);
1483
+ }
1484
+ await newEngine.start();
1485
+ if (debug) {
1486
+ console.debug("[Query Engine] started!");
1487
+ }
1488
+ return newEngine;
1489
+ } finally {
1490
+ void _Engine.stopAll(engineId);
1491
+ }
1492
+ }
1493
+ static async stopAll(excludingEngineId) {
1494
+ const results = await Promise.allSettled(
1495
+ Array.from(_Engine.#enginesBySchemaAndClientVersion.entries()).filter(([engineId]) => engineId !== excludingEngineId).map(async ([engineId, engine]) => {
1496
+ try {
1497
+ await engine.stop();
1498
+ } finally {
1499
+ _Engine.#enginesBySchemaAndClientVersion.delete(engineId);
1500
+ }
1501
+ })
1502
+ );
1503
+ const errors = results.filter((result) => result.status === "rejected").map((result) => result.reason);
1504
+ if (errors.length > 0) {
1505
+ throw new AggregateError(errors, "Failed to stop engines");
1506
+ }
1507
+ }
1508
+ async commitTransaction(transactionId, headers) {
1509
+ return await this.#commitOrRollbackTransaction(transactionId, headers, "commit");
1510
+ }
1511
+ async request(body, headers) {
1512
+ const { url: url2 } = await this.start();
1513
+ const sanitizedHeaders = this.#sanitizeHeaders(headers);
1514
+ const response = await fetch(url2, {
1515
+ body: typeof body === "string" ? body : JSON.stringify(body),
1516
+ headers: { ...sanitizedHeaders, "Content-Type": "application/json" },
1517
+ method: "POST"
1518
+ });
1519
+ if (!response.ok) {
1520
+ throw await EngineHttpError.fromResponse(response);
1521
+ }
1522
+ return await response.text();
1523
+ }
1524
+ async rollbackTransaction(transactionId, headers) {
1525
+ return await this.#commitOrRollbackTransaction(transactionId, headers, "rollback");
1526
+ }
1527
+ async startTransaction(options, headers) {
1528
+ const { url: url2 } = await this.start();
1529
+ const sanitizedHeaders = this.#sanitizeHeaders(headers);
1530
+ const response = await fetch(`${url2}/transaction/start`, {
1531
+ body: JSON.stringify(options),
1532
+ headers: { ...sanitizedHeaders, "Content-Type": "application/json" },
1533
+ method: "POST"
1534
+ });
1535
+ if (!response.ok) {
1536
+ throw await EngineHttpError.fromResponse(response);
1537
+ }
1538
+ return await response.json();
1539
+ }
1540
+ async start() {
1541
+ if (this.#session != null) {
1542
+ return await this.#session;
1543
+ }
1544
+ const { promise: session, reject, resolve: resolve2 } = withResolvers();
1545
+ this.#session = session;
1546
+ const engineBinaryPath = PRISMA_DEV_FORCE_ENGINE_BINARY_PATH || await this.#getEngineBinaryPath();
1547
+ if (this.#options.debug) {
1548
+ console.debug("[Query Engine] spinning up at path...", engineBinaryPath);
1549
+ }
1550
+ const { proxySignals } = await import("foreground-child/proxy-signals");
1551
+ const childProcess = spawn(
1552
+ engineBinaryPath,
1553
+ ["--enable-raw-queries", "--enable-telemetry-in-response", "--port", "0"],
1554
+ {
1555
+ env: {
1556
+ LOG_QUERIES: "y",
1557
+ PRISMA_DML: this.#options.base64Schema,
1558
+ QE_LOG_LEVEL: "TRACE",
1559
+ RUST_BACKTRACE: "1",
1560
+ RUST_LOG: "info"
1561
+ },
1562
+ stdio: ["ignore", "pipe", "pipe"],
1563
+ windowsHide: true
1564
+ }
1565
+ );
1566
+ proxySignals(childProcess);
1567
+ childProcess.stderr.setEncoding("utf8");
1568
+ childProcess.stdout.setEncoding("utf8");
1569
+ const waitForListening = (data) => {
1570
+ const readyMessage = data.split("\n").find((line) => line.includes("Started query engine http server"));
1571
+ if (!readyMessage) {
1572
+ return;
1573
+ }
1574
+ childProcess.stdout.removeListener("data", waitForListening);
1575
+ const { fields } = JSON.parse(readyMessage);
1576
+ if (fields == null) {
1577
+ return reject(new Error(`Unexpected data during initialization, "fields" are missing: ${data}`));
1578
+ }
1579
+ const { ip, port } = fields;
1580
+ if (ip == null || port == null) {
1581
+ return reject(
1582
+ new Error(
1583
+ `This version of query-engine is not compatible with minippg, "ip" and "port" are missing in the startup log entry.
1584
+ Received data: ${data}`
1585
+ )
1586
+ );
1587
+ }
1588
+ resolve2({ childProcess, url: `http://${ip}:${port}` });
1589
+ };
1590
+ const errorListener = (error) => {
1591
+ this.#session = null;
1592
+ reject(new EngineStartError(String(error)));
1593
+ childProcess.removeListener("exit", exitListener);
1594
+ childProcess.kill();
1595
+ };
1596
+ childProcess.once("error", errorListener);
1597
+ const exitListener = (code, signal) => {
1598
+ this.#session = null;
1599
+ reject(new EngineStartError(`Query Engine exited with code ${code} and signal ${signal}`));
1600
+ };
1601
+ childProcess.once("exit", exitListener);
1602
+ childProcess.stdout.on("data", waitForListening);
1603
+ if (this.#options.debug) {
1604
+ childProcess.stderr.on("data", console.error.bind(console, "[Query Engine]"));
1605
+ childProcess.stdout.on("data", console.debug.bind(console, "[Query Engine]"));
1606
+ }
1607
+ return await this.#session;
1608
+ }
1609
+ async stop() {
1610
+ if (this.#session == null) {
1611
+ return;
1612
+ }
1613
+ const { childProcess } = await this.#session;
1614
+ const isStillRunning = childProcess.exitCode == null && childProcess.signalCode == null;
1615
+ if (!isStillRunning) {
1616
+ return;
1617
+ }
1618
+ this.#session = null;
1619
+ childProcess.kill();
1620
+ await once(childProcess, "exit");
1621
+ }
1622
+ async #getEngineBinaryPath() {
1623
+ if (this.#options.debug) {
1624
+ console.debug(`[Query Engine] getting engine commit hash...`);
1625
+ }
1626
+ const commitHash = await this.#getEngineCommitHash();
1627
+ if (this.#options.debug) {
1628
+ console.debug("[Query Engine] got engine commit hash", commitHash);
1629
+ }
1630
+ const cacheDirectoryPath = getEngineCacheDirPath(this.#options.clientVersion, commitHash);
1631
+ if (this.#options.debug) {
1632
+ console.debug("[Query Engine] cache directory path", cacheDirectoryPath);
1633
+ }
1634
+ await mkdir2(cacheDirectoryPath, { recursive: true });
1635
+ const { platform } = this.#options.platform;
1636
+ const extension = platform === "windows" ? ".exe" : "";
1637
+ const engineBinaryPath = join(cacheDirectoryPath, `query-engine-${platform}${extension}`);
1638
+ if (this.#options.debug) {
1639
+ console.debug("[Query Engine] binary path", engineBinaryPath);
1640
+ }
1641
+ const shouldDownloadEngine = PRISMA_DEV_FORCE_ENGINE_BINARY_DOWNLOAD === "1" || await checkFileExists(engineBinaryPath) === false;
1642
+ if (shouldDownloadEngine) {
1643
+ await this.#downloadEngineBinary({ commitHash, extension, engineBinaryPath });
1644
+ }
1645
+ return engineBinaryPath;
1646
+ }
1647
+ async #getEngineCommitHash() {
1648
+ const response = await fetch(`https://registry.npmjs.org/@prisma/client/${this.#options.clientVersion}`);
1649
+ if (!response.ok) {
1650
+ throw new Error(`Couldn't fetch package.json from npm registry, status code: ${response.status}`);
1651
+ }
1652
+ const pkg = await response.json();
1653
+ const enginesVersion = pkg.devDependencies?.["@prisma/engines-version"];
1654
+ if (!enginesVersion) {
1655
+ throw new Error(`Couldn't find engines version in package.json`);
1656
+ }
1657
+ const commitHash = enginesVersion.split(".").at(-1);
1658
+ if (!commitHash) {
1659
+ throw new Error(`Couldn't find commit hash in engines version`);
1660
+ }
1661
+ return commitHash;
1662
+ }
1663
+ async #downloadEngineBinary(options) {
1664
+ const { commitHash, extension, engineBinaryPath } = options;
1665
+ const { binaryTarget } = this.#options.platform;
1666
+ const url2 = `https://binaries.prisma.sh/all_commits/${commitHash}/${binaryTarget}/query-engine${extension}.gz`;
1667
+ if (this.#options.debug) {
1668
+ console.debug("[Query Engine] downloading engine from url", url2);
1669
+ }
1670
+ const response = await fetch(url2);
1671
+ if (!response.ok) {
1672
+ throw new Error(`Couldn't download engine. URL: ${url2}, status code: ${response.status}`);
1673
+ }
1674
+ if (PRISMA_DEV_FORCE_NETWORK_DELAY_MS) {
1675
+ await setTimeout(Number(PRISMA_DEV_FORCE_NETWORK_DELAY_MS));
1676
+ }
1677
+ await writeBinaryFile(await response.arrayBuffer(), engineBinaryPath);
1678
+ if (this.#options.debug) {
1679
+ console.debug("[Query Engine] downloaded and saved at", engineBinaryPath);
1680
+ }
1681
+ }
1682
+ #sanitizeHeaders(headers) {
1683
+ const sanitizedHeaders = {};
1684
+ for (const [key, value] of Object.entries(headers)) {
1685
+ if (value != null) {
1686
+ sanitizedHeaders[key] = value;
1687
+ }
1688
+ }
1689
+ return sanitizedHeaders;
1690
+ }
1691
+ async #commitOrRollbackTransaction(transactionId, headers, action) {
1692
+ const { url: url2 } = await this.#session;
1693
+ const sanitizedHeaders = this.#sanitizeHeaders(headers);
1694
+ const response = await fetch(`${url2}/transaction/${transactionId}/${action}`, {
1695
+ headers: { ...sanitizedHeaders, "Content-Type": "application/json" },
1696
+ method: "POST"
1697
+ });
1698
+ if (!response.ok) {
1699
+ throw await EngineHttpError.fromResponse(response);
1700
+ }
1701
+ try {
1702
+ return await response.json();
1703
+ } catch {
1704
+ return {};
1705
+ }
1706
+ }
1707
+ };
1708
+ function handleEngineError(error, ctx) {
1709
+ console.error(error);
1710
+ if (error instanceof EngineStartError) {
1711
+ return ctx.json({ EngineNotStarted: { reason: { EngineStartupError: { logs: [], msg: error.message } } } }, 500);
1712
+ }
1713
+ if (error instanceof EngineHttpError) {
1714
+ return ctx.text(error.responseBody, error.statusCode);
1715
+ }
1716
+ return ctx.body(null, 500);
1717
+ }
1718
+ var EngineStartError = class extends Error {
1719
+ name = "EngineStartError";
1720
+ };
1721
+ var EngineHttpError = class _EngineHttpError extends Error {
1722
+ constructor(action, statusCode, responseBody) {
1723
+ super(`${action}: Query Engine response status ${statusCode}, body: ${responseBody}`);
1724
+ this.action = action;
1725
+ this.statusCode = statusCode;
1726
+ this.responseBody = responseBody;
1727
+ }
1728
+ name = "EngineHttpError";
1729
+ static async fromResponse(response) {
1730
+ const url2 = new URL(response.url);
1731
+ const responseBody = await response.text();
1732
+ return new _EngineHttpError(url2.pathname, response.status, responseBody);
1733
+ }
1734
+ };
1735
+
1736
+ export {
1737
+ integer,
1738
+ minLength,
1739
+ minValue,
1740
+ parseJson,
1741
+ url,
1742
+ array,
1743
+ literal,
1744
+ looseObject,
1745
+ number,
1746
+ object,
1747
+ optional,
1748
+ string,
1749
+ union,
1750
+ pipe,
1751
+ safeParse,
1752
+ encodeAPIKey,
1753
+ apiKeyValidator,
1754
+ getDataDirPath,
1755
+ streamAsTextTo,
1756
+ readFileAsText,
1757
+ ensureDirectory,
1758
+ readDirectoryNames,
1759
+ withResolvers,
1760
+ y,
1761
+ Engine,
1762
+ handleEngineError
1763
+ };