drizzle-kit 0.20.0-3aac705 → 0.20.0-50d6b73

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3325 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+
36
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
37
+ function assembleStyles() {
38
+ const codes = /* @__PURE__ */ new Map();
39
+ for (const [groupName, group] of Object.entries(styles)) {
40
+ for (const [styleName, style] of Object.entries(group)) {
41
+ styles[styleName] = {
42
+ open: `\x1B[${style[0]}m`,
43
+ close: `\x1B[${style[1]}m`
44
+ };
45
+ group[styleName] = styles[styleName];
46
+ codes.set(style[0], style[1]);
47
+ }
48
+ Object.defineProperty(styles, groupName, {
49
+ value: group,
50
+ enumerable: false
51
+ });
52
+ }
53
+ Object.defineProperty(styles, "codes", {
54
+ value: codes,
55
+ enumerable: false
56
+ });
57
+ styles.color.close = "\x1B[39m";
58
+ styles.bgColor.close = "\x1B[49m";
59
+ styles.color.ansi = wrapAnsi16();
60
+ styles.color.ansi256 = wrapAnsi256();
61
+ styles.color.ansi16m = wrapAnsi16m();
62
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
63
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
64
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
65
+ Object.defineProperties(styles, {
66
+ rgbToAnsi256: {
67
+ value(red, green, blue) {
68
+ if (red === green && green === blue) {
69
+ if (red < 8) {
70
+ return 16;
71
+ }
72
+ if (red > 248) {
73
+ return 231;
74
+ }
75
+ return Math.round((red - 8) / 247 * 24) + 232;
76
+ }
77
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
78
+ },
79
+ enumerable: false
80
+ },
81
+ hexToRgb: {
82
+ value(hex) {
83
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
84
+ if (!matches) {
85
+ return [0, 0, 0];
86
+ }
87
+ let [colorString] = matches;
88
+ if (colorString.length === 3) {
89
+ colorString = [...colorString].map((character) => character + character).join("");
90
+ }
91
+ const integer = Number.parseInt(colorString, 16);
92
+ return [
93
+ /* eslint-disable no-bitwise */
94
+ integer >> 16 & 255,
95
+ integer >> 8 & 255,
96
+ integer & 255
97
+ /* eslint-enable no-bitwise */
98
+ ];
99
+ },
100
+ enumerable: false
101
+ },
102
+ hexToAnsi256: {
103
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
104
+ enumerable: false
105
+ },
106
+ ansi256ToAnsi: {
107
+ value(code) {
108
+ if (code < 8) {
109
+ return 30 + code;
110
+ }
111
+ if (code < 16) {
112
+ return 90 + (code - 8);
113
+ }
114
+ let red;
115
+ let green;
116
+ let blue;
117
+ if (code >= 232) {
118
+ red = ((code - 232) * 10 + 8) / 255;
119
+ green = red;
120
+ blue = red;
121
+ } else {
122
+ code -= 16;
123
+ const remainder = code % 36;
124
+ red = Math.floor(code / 36) / 5;
125
+ green = Math.floor(remainder / 6) / 5;
126
+ blue = remainder % 6 / 5;
127
+ }
128
+ const value = Math.max(red, green, blue) * 2;
129
+ if (value === 0) {
130
+ return 30;
131
+ }
132
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
133
+ if (value === 2) {
134
+ result += 60;
135
+ }
136
+ return result;
137
+ },
138
+ enumerable: false
139
+ },
140
+ rgbToAnsi: {
141
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
142
+ enumerable: false
143
+ },
144
+ hexToAnsi: {
145
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
146
+ enumerable: false
147
+ }
148
+ });
149
+ return styles;
150
+ }
151
+ var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
152
+ var init_ansi_styles = __esm({
153
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
154
+ ANSI_BACKGROUND_OFFSET = 10;
155
+ wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
156
+ wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
157
+ wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
158
+ styles = {
159
+ modifier: {
160
+ reset: [0, 0],
161
+ // 21 isn't widely supported and 22 does the same thing
162
+ bold: [1, 22],
163
+ dim: [2, 22],
164
+ italic: [3, 23],
165
+ underline: [4, 24],
166
+ overline: [53, 55],
167
+ inverse: [7, 27],
168
+ hidden: [8, 28],
169
+ strikethrough: [9, 29]
170
+ },
171
+ color: {
172
+ black: [30, 39],
173
+ red: [31, 39],
174
+ green: [32, 39],
175
+ yellow: [33, 39],
176
+ blue: [34, 39],
177
+ magenta: [35, 39],
178
+ cyan: [36, 39],
179
+ white: [37, 39],
180
+ // Bright color
181
+ blackBright: [90, 39],
182
+ gray: [90, 39],
183
+ // Alias of `blackBright`
184
+ grey: [90, 39],
185
+ // Alias of `blackBright`
186
+ redBright: [91, 39],
187
+ greenBright: [92, 39],
188
+ yellowBright: [93, 39],
189
+ blueBright: [94, 39],
190
+ magentaBright: [95, 39],
191
+ cyanBright: [96, 39],
192
+ whiteBright: [97, 39]
193
+ },
194
+ bgColor: {
195
+ bgBlack: [40, 49],
196
+ bgRed: [41, 49],
197
+ bgGreen: [42, 49],
198
+ bgYellow: [43, 49],
199
+ bgBlue: [44, 49],
200
+ bgMagenta: [45, 49],
201
+ bgCyan: [46, 49],
202
+ bgWhite: [47, 49],
203
+ // Bright color
204
+ bgBlackBright: [100, 49],
205
+ bgGray: [100, 49],
206
+ // Alias of `bgBlackBright`
207
+ bgGrey: [100, 49],
208
+ // Alias of `bgBlackBright`
209
+ bgRedBright: [101, 49],
210
+ bgGreenBright: [102, 49],
211
+ bgYellowBright: [103, 49],
212
+ bgBlueBright: [104, 49],
213
+ bgMagentaBright: [105, 49],
214
+ bgCyanBright: [106, 49],
215
+ bgWhiteBright: [107, 49]
216
+ }
217
+ };
218
+ modifierNames = Object.keys(styles.modifier);
219
+ foregroundColorNames = Object.keys(styles.color);
220
+ backgroundColorNames = Object.keys(styles.bgColor);
221
+ colorNames = [...foregroundColorNames, ...backgroundColorNames];
222
+ ansiStyles = assembleStyles();
223
+ ansi_styles_default = ansiStyles;
224
+ }
225
+ });
226
+
227
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
228
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
229
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
230
+ const position = argv.indexOf(prefix + flag);
231
+ const terminatorPosition = argv.indexOf("--");
232
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
233
+ }
234
+ function envForceColor() {
235
+ if ("FORCE_COLOR" in env) {
236
+ if (env.FORCE_COLOR === "true") {
237
+ return 1;
238
+ }
239
+ if (env.FORCE_COLOR === "false") {
240
+ return 0;
241
+ }
242
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
243
+ }
244
+ }
245
+ function translateLevel(level) {
246
+ if (level === 0) {
247
+ return false;
248
+ }
249
+ return {
250
+ level,
251
+ hasBasic: true,
252
+ has256: level >= 2,
253
+ has16m: level >= 3
254
+ };
255
+ }
256
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
257
+ const noFlagForceColor = envForceColor();
258
+ if (noFlagForceColor !== void 0) {
259
+ flagForceColor = noFlagForceColor;
260
+ }
261
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
262
+ if (forceColor === 0) {
263
+ return 0;
264
+ }
265
+ if (sniffFlags) {
266
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
267
+ return 3;
268
+ }
269
+ if (hasFlag("color=256")) {
270
+ return 2;
271
+ }
272
+ }
273
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
274
+ return 1;
275
+ }
276
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
277
+ return 0;
278
+ }
279
+ const min = forceColor || 0;
280
+ if (env.TERM === "dumb") {
281
+ return min;
282
+ }
283
+ if (import_node_process.default.platform === "win32") {
284
+ const osRelease = import_node_os.default.release().split(".");
285
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
286
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
287
+ }
288
+ return 1;
289
+ }
290
+ if ("CI" in env) {
291
+ if ("GITHUB_ACTIONS" in env) {
292
+ return 3;
293
+ }
294
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
295
+ return 1;
296
+ }
297
+ return min;
298
+ }
299
+ if ("TEAMCITY_VERSION" in env) {
300
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
301
+ }
302
+ if (env.COLORTERM === "truecolor") {
303
+ return 3;
304
+ }
305
+ if (env.TERM === "xterm-kitty") {
306
+ return 3;
307
+ }
308
+ if ("TERM_PROGRAM" in env) {
309
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
310
+ switch (env.TERM_PROGRAM) {
311
+ case "iTerm.app": {
312
+ return version >= 3 ? 3 : 2;
313
+ }
314
+ case "Apple_Terminal": {
315
+ return 2;
316
+ }
317
+ }
318
+ }
319
+ if (/-256(color)?$/i.test(env.TERM)) {
320
+ return 2;
321
+ }
322
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
323
+ return 1;
324
+ }
325
+ if ("COLORTERM" in env) {
326
+ return 1;
327
+ }
328
+ return min;
329
+ }
330
+ function createSupportsColor(stream, options = {}) {
331
+ const level = _supportsColor(stream, {
332
+ streamIsTTY: stream && stream.isTTY,
333
+ ...options
334
+ });
335
+ return translateLevel(level);
336
+ }
337
+ var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
338
+ var init_supports_color = __esm({
339
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
340
+ import_node_process = __toESM(require("node:process"), 1);
341
+ import_node_os = __toESM(require("node:os"), 1);
342
+ import_node_tty = __toESM(require("node:tty"), 1);
343
+ ({ env } = import_node_process.default);
344
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
345
+ flagForceColor = 0;
346
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
347
+ flagForceColor = 1;
348
+ }
349
+ supportsColor = {
350
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
351
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
352
+ };
353
+ supports_color_default = supportsColor;
354
+ }
355
+ });
356
+
357
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
358
+ function stringReplaceAll(string, substring, replacer) {
359
+ let index = string.indexOf(substring);
360
+ if (index === -1) {
361
+ return string;
362
+ }
363
+ const substringLength = substring.length;
364
+ let endIndex = 0;
365
+ let returnValue = "";
366
+ do {
367
+ returnValue += string.slice(endIndex, index) + substring + replacer;
368
+ endIndex = index + substringLength;
369
+ index = string.indexOf(substring, endIndex);
370
+ } while (index !== -1);
371
+ returnValue += string.slice(endIndex);
372
+ return returnValue;
373
+ }
374
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
375
+ let endIndex = 0;
376
+ let returnValue = "";
377
+ do {
378
+ const gotCR = string[index - 1] === "\r";
379
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
380
+ endIndex = index + 1;
381
+ index = string.indexOf("\n", endIndex);
382
+ } while (index !== -1);
383
+ returnValue += string.slice(endIndex);
384
+ return returnValue;
385
+ }
386
+ var init_utilities = __esm({
387
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
388
+ }
389
+ });
390
+
391
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
392
+ function createChalk(options) {
393
+ return chalkFactory(options);
394
+ }
395
+ var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr;
396
+ var init_source = __esm({
397
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
398
+ init_ansi_styles();
399
+ init_supports_color();
400
+ init_utilities();
401
+ init_ansi_styles();
402
+ ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
403
+ GENERATOR = Symbol("GENERATOR");
404
+ STYLER = Symbol("STYLER");
405
+ IS_EMPTY = Symbol("IS_EMPTY");
406
+ levelMapping = [
407
+ "ansi",
408
+ "ansi",
409
+ "ansi256",
410
+ "ansi16m"
411
+ ];
412
+ styles2 = /* @__PURE__ */ Object.create(null);
413
+ applyOptions = (object, options = {}) => {
414
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
415
+ throw new Error("The `level` option should be an integer from 0 to 3");
416
+ }
417
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
418
+ object.level = options.level === void 0 ? colorLevel : options.level;
419
+ };
420
+ chalkFactory = (options) => {
421
+ const chalk2 = (...strings) => strings.join(" ");
422
+ applyOptions(chalk2, options);
423
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
424
+ return chalk2;
425
+ };
426
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
427
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
428
+ styles2[styleName] = {
429
+ get() {
430
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
431
+ Object.defineProperty(this, styleName, { value: builder });
432
+ return builder;
433
+ }
434
+ };
435
+ }
436
+ styles2.visible = {
437
+ get() {
438
+ const builder = createBuilder(this, this[STYLER], true);
439
+ Object.defineProperty(this, "visible", { value: builder });
440
+ return builder;
441
+ }
442
+ };
443
+ getModelAnsi = (model, level, type, ...arguments_) => {
444
+ if (model === "rgb") {
445
+ if (level === "ansi16m") {
446
+ return ansi_styles_default[type].ansi16m(...arguments_);
447
+ }
448
+ if (level === "ansi256") {
449
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
450
+ }
451
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
452
+ }
453
+ if (model === "hex") {
454
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
455
+ }
456
+ return ansi_styles_default[type][model](...arguments_);
457
+ };
458
+ usedModels = ["rgb", "hex", "ansi256"];
459
+ for (const model of usedModels) {
460
+ styles2[model] = {
461
+ get() {
462
+ const { level } = this;
463
+ return function(...arguments_) {
464
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
465
+ return createBuilder(this, styler, this[IS_EMPTY]);
466
+ };
467
+ }
468
+ };
469
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
470
+ styles2[bgModel] = {
471
+ get() {
472
+ const { level } = this;
473
+ return function(...arguments_) {
474
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
475
+ return createBuilder(this, styler, this[IS_EMPTY]);
476
+ };
477
+ }
478
+ };
479
+ }
480
+ proto = Object.defineProperties(() => {
481
+ }, {
482
+ ...styles2,
483
+ level: {
484
+ enumerable: true,
485
+ get() {
486
+ return this[GENERATOR].level;
487
+ },
488
+ set(level) {
489
+ this[GENERATOR].level = level;
490
+ }
491
+ }
492
+ });
493
+ createStyler = (open, close, parent) => {
494
+ let openAll;
495
+ let closeAll;
496
+ if (parent === void 0) {
497
+ openAll = open;
498
+ closeAll = close;
499
+ } else {
500
+ openAll = parent.openAll + open;
501
+ closeAll = close + parent.closeAll;
502
+ }
503
+ return {
504
+ open,
505
+ close,
506
+ openAll,
507
+ closeAll,
508
+ parent
509
+ };
510
+ };
511
+ createBuilder = (self2, _styler, _isEmpty) => {
512
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
513
+ Object.setPrototypeOf(builder, proto);
514
+ builder[GENERATOR] = self2;
515
+ builder[STYLER] = _styler;
516
+ builder[IS_EMPTY] = _isEmpty;
517
+ return builder;
518
+ };
519
+ applyStyle = (self2, string) => {
520
+ if (self2.level <= 0 || !string) {
521
+ return self2[IS_EMPTY] ? "" : string;
522
+ }
523
+ let styler = self2[STYLER];
524
+ if (styler === void 0) {
525
+ return string;
526
+ }
527
+ const { openAll, closeAll } = styler;
528
+ if (string.includes("\x1B")) {
529
+ while (styler !== void 0) {
530
+ string = stringReplaceAll(string, styler.close, styler.open);
531
+ styler = styler.parent;
532
+ }
533
+ }
534
+ const lfIndex = string.indexOf("\n");
535
+ if (lfIndex !== -1) {
536
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
537
+ }
538
+ return openAll + string + closeAll;
539
+ };
540
+ Object.defineProperties(createChalk.prototype, styles2);
541
+ chalk = createChalk();
542
+ chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
543
+ }
544
+ });
545
+
546
+ // src/serializer/index.ts
547
+ var glob;
548
+ var init_serializer = __esm({
549
+ "src/serializer/index.ts"() {
550
+ glob = __toESM(require("glob"));
551
+ init_source();
552
+ }
553
+ });
554
+
555
+ // src/cli/validations/outputs.ts
556
+ var init_outputs = __esm({
557
+ "src/cli/validations/outputs.ts"() {
558
+ init_source();
559
+ }
560
+ });
561
+
562
+ // src/serializer/pgSerializer.ts
563
+ var import_pg_core, import_pg_core2, import_drizzle_orm, dialect, trimChar, fromDatabase, columnToDefault, defaultForColumn, toDrizzle;
564
+ var init_pgSerializer = __esm({
565
+ "src/serializer/pgSerializer.ts"() {
566
+ import_pg_core = require("drizzle-orm/pg-core");
567
+ import_pg_core2 = require("drizzle-orm/pg-core");
568
+ import_drizzle_orm = require("drizzle-orm");
569
+ init_serializer();
570
+ init_source();
571
+ init_outputs();
572
+ dialect = new import_pg_core.PgDialect();
573
+ trimChar = (str, char) => {
574
+ let start = 0;
575
+ let end = str.length;
576
+ while (start < end && str[start] === char)
577
+ ++start;
578
+ while (end > start && str[end - 1] === char)
579
+ --end;
580
+ return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
581
+ };
582
+ fromDatabase = async (db, tablesFilter = (table) => true, schemaFilters, progressCallback) => {
583
+ const result = {};
584
+ const internals = { tables: {} };
585
+ const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
586
+ const allTables = await db.query(
587
+ `SELECT table_schema, table_name FROM information_schema.tables WHERE ${where};`
588
+ );
589
+ const schemas = new Set(allTables.map((it) => it.table_schema));
590
+ schemas.delete("public");
591
+ const allSchemas = await db.query(`select s.nspname as table_schema
592
+ from pg_catalog.pg_namespace s
593
+ join pg_catalog.pg_user u on u.usesysid = s.nspowner
594
+ where nspname not in ('information_schema', 'pg_catalog', 'public')
595
+ and nspname not like 'pg_toast%'
596
+ and nspname not like 'pg_temp_%'
597
+ order by table_schema;`);
598
+ allSchemas.forEach((item) => {
599
+ if (schemaFilters.includes(item.table_schema)) {
600
+ schemas.add(item.table_schema);
601
+ }
602
+ });
603
+ let columnsCount = 0;
604
+ let indexesCount = 0;
605
+ let foreignKeysCount = 0;
606
+ let tableCount = 0;
607
+ const all = allTables.map((row) => {
608
+ return new Promise(async (res, rej) => {
609
+ const tableName = row.table_name;
610
+ if (!tablesFilter(tableName))
611
+ return res("");
612
+ tableCount += 1;
613
+ const tableSchema = row.table_schema;
614
+ try {
615
+ const columnToReturn = {};
616
+ const indexToReturn = {};
617
+ const foreignKeysToReturn = {};
618
+ const primaryKeys = {};
619
+ const uniqueConstrains = {};
620
+ const tableResponse = await db.query(
621
+ `SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
622
+ , CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
623
+ AND EXISTS (
624
+ SELECT FROM pg_attrdef ad
625
+ WHERE ad.adrelid = a.attrelid
626
+ AND ad.adnum = a.attnum
627
+ AND pg_get_expr(ad.adbin, ad.adrelid)
628
+ = 'nextval('''
629
+ || (pg_get_serial_sequence (a.attrelid::regclass::text
630
+ , a.attname))::regclass
631
+ || '''::regclass)'
632
+ )
633
+ THEN CASE a.atttypid
634
+ WHEN 'int'::regtype THEN 'serial'
635
+ WHEN 'int8'::regtype THEN 'bigserial'
636
+ WHEN 'int2'::regtype THEN 'smallserial'
637
+ END
638
+ ELSE format_type(a.atttypid, a.atttypmod)
639
+ END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, INFORMATION_SCHEMA.COLUMNS.column_name, INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt
640
+ FROM pg_attribute a
641
+ JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
642
+ WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}'
643
+ AND a.attnum > 0
644
+ AND NOT a.attisdropped
645
+ ORDER BY a.attnum;`
646
+ );
647
+ const tableConstraints = await db.query(
648
+ `SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
649
+ FROM information_schema.table_constraints tc
650
+ JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
651
+ JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
652
+ AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
653
+ WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
654
+ );
655
+ columnsCount += tableResponse.length;
656
+ if (progressCallback) {
657
+ progressCallback("columns", columnsCount, "fetching");
658
+ }
659
+ const tableForeignKeys = await db.query(
660
+ `SELECT
661
+ tc.table_schema,
662
+ tc.constraint_name,
663
+ tc.table_name,
664
+ kcu.column_name,
665
+ ccu.table_schema AS foreign_table_schema,
666
+ ccu.table_name AS foreign_table_name,
667
+ ccu.column_name AS foreign_column_name,
668
+ rc.delete_rule, rc.update_rule
669
+ FROM
670
+ information_schema.table_constraints AS tc
671
+ JOIN information_schema.key_column_usage AS kcu
672
+ ON tc.constraint_name = kcu.constraint_name
673
+ AND tc.table_schema = kcu.table_schema
674
+ JOIN information_schema.constraint_column_usage AS ccu
675
+ ON ccu.constraint_name = tc.constraint_name
676
+ AND ccu.table_schema = tc.table_schema
677
+ JOIN information_schema.referential_constraints AS rc
678
+ ON ccu.constraint_name = rc.constraint_name
679
+ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name='${tableName}' and tc.table_schema='${tableSchema}';`
680
+ );
681
+ foreignKeysCount += tableForeignKeys.length;
682
+ if (progressCallback) {
683
+ progressCallback("fks", foreignKeysCount, "fetching");
684
+ }
685
+ for (const fk of tableForeignKeys) {
686
+ const columnFrom = fk.column_name;
687
+ const tableTo = fk.foreign_table_name;
688
+ const columnTo = fk.foreign_column_name;
689
+ const foreignKeyName = fk.constraint_name;
690
+ const onUpdate = fk.update_rule.toLowerCase();
691
+ const onDelete = fk.delete_rule.toLowerCase();
692
+ if (typeof foreignKeysToReturn[foreignKeyName] !== "undefined") {
693
+ foreignKeysToReturn[foreignKeyName].columnsFrom.push(columnFrom);
694
+ foreignKeysToReturn[foreignKeyName].columnsTo.push(columnTo);
695
+ } else {
696
+ foreignKeysToReturn[foreignKeyName] = {
697
+ name: foreignKeyName,
698
+ tableFrom: tableName,
699
+ tableTo,
700
+ columnsFrom: [columnFrom],
701
+ columnsTo: [columnTo],
702
+ onDelete,
703
+ onUpdate
704
+ };
705
+ }
706
+ foreignKeysToReturn[foreignKeyName].columnsFrom = [
707
+ ...new Set(foreignKeysToReturn[foreignKeyName].columnsFrom)
708
+ ];
709
+ foreignKeysToReturn[foreignKeyName].columnsTo = [
710
+ ...new Set(foreignKeysToReturn[foreignKeyName].columnsTo)
711
+ ];
712
+ }
713
+ const uniqueConstrainsRows = tableConstraints.filter(
714
+ (mapRow) => mapRow.constraint_type === "UNIQUE"
715
+ );
716
+ for (const unqs of uniqueConstrainsRows) {
717
+ const columnName = unqs.column_name;
718
+ const constraintName = unqs.constraint_name;
719
+ if (typeof uniqueConstrains[constraintName] !== "undefined") {
720
+ uniqueConstrains[constraintName].columns.push(columnName);
721
+ } else {
722
+ uniqueConstrains[constraintName] = {
723
+ columns: [columnName],
724
+ nullsNotDistinct: false,
725
+ name: constraintName
726
+ };
727
+ }
728
+ }
729
+ for (const columnResponse of tableResponse) {
730
+ const columnName = columnResponse.attname;
731
+ const columnAdditionalDT = columnResponse.additional_dt;
732
+ const columnDimensions = columnResponse.array_dimensions;
733
+ let columnType = columnResponse.data_type;
734
+ const primaryKey = tableConstraints.filter(
735
+ (mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "PRIMARY KEY"
736
+ );
737
+ const cprimaryKey = tableConstraints.filter(
738
+ (mapRow) => mapRow.constraint_type === "PRIMARY KEY"
739
+ );
740
+ if (cprimaryKey.length > 1) {
741
+ const tableCompositePkName = await db.query(
742
+ `SELECT conname AS primary_key
743
+ FROM pg_constraint
744
+ WHERE contype = 'p'
745
+ AND connamespace = '${tableSchema}'::regnamespace
746
+ AND (conrelid::regclass::text = '"${tableName}"' OR conrelid::regclass::text = '${tableName}');`
747
+ );
748
+ primaryKeys[`${tableName}_${cprimaryKey.map((pk) => pk.column_name).join("_")}`] = {
749
+ name: tableCompositePkName[0].primary_key,
750
+ columns: cprimaryKey.map((c) => c.column_name)
751
+ };
752
+ }
753
+ const defaultValue = defaultForColumn(columnResponse);
754
+ const isSerial = columnType === "serial";
755
+ let columnTypeMapped = columnType;
756
+ if (columnTypeMapped.startsWith("numeric(")) {
757
+ columnTypeMapped = columnTypeMapped.replace(",", ", ");
758
+ }
759
+ if (columnAdditionalDT === "ARRAY") {
760
+ if (typeof internals.tables[tableName] === "undefined") {
761
+ internals.tables[tableName] = {
762
+ columns: {
763
+ [columnName]: {
764
+ isArray: true,
765
+ dimensions: columnDimensions,
766
+ rawType: columnTypeMapped.substring(
767
+ 0,
768
+ columnTypeMapped.length - 2
769
+ )
770
+ }
771
+ }
772
+ };
773
+ } else {
774
+ if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
775
+ internals.tables[tableName].columns[columnName] = {
776
+ isArray: true,
777
+ dimensions: columnDimensions,
778
+ rawType: columnTypeMapped.substring(
779
+ 0,
780
+ columnTypeMapped.length - 2
781
+ )
782
+ };
783
+ }
784
+ }
785
+ }
786
+ if (columnAdditionalDT === "ARRAY") {
787
+ for (let i = 1; i < Number(columnDimensions); i++) {
788
+ columnTypeMapped += "[]";
789
+ }
790
+ }
791
+ columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char");
792
+ columnTypeMapped = trimChar(columnTypeMapped, '"');
793
+ columnToReturn[columnName] = {
794
+ name: columnName,
795
+ type: columnTypeMapped,
796
+ primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
797
+ // default: isSerial ? undefined : defaultValue,
798
+ notNull: columnResponse.is_nullable === "NO"
799
+ };
800
+ if (!isSerial && typeof defaultValue !== "undefined") {
801
+ columnToReturn[columnName].default = defaultValue;
802
+ }
803
+ }
804
+ const dbIndexes = await db.query(
805
+ `SELECT t.relname as table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
806
+ FROM pg_class t
807
+ JOIN pg_index ix ON t.oid = ix.indrelid
808
+ JOIN pg_class i ON i.oid = ix.indexrelid
809
+ JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
810
+ JOIN pg_namespace ns ON ns.oid = t.relnamespace
811
+ WHERE ns.nspname = '${tableSchema}'
812
+ AND t.relname = '${tableName}'
813
+ and ix.indisprimary = false;`
814
+ );
815
+ const dbIndexFromConstraint = await db.query(
816
+ `SELECT
817
+ idx.indexrelname AS index_name,
818
+ idx.relname AS table_name,
819
+ schemaname,
820
+ CASE WHEN con.conname IS NOT NULL THEN 1 ELSE 0 END AS generated_by_constraint
821
+ FROM
822
+ pg_stat_user_indexes idx
823
+ LEFT JOIN
824
+ pg_constraint con ON con.conindid = idx.indexrelid
825
+ WHERE idx.relname = '${tableName}' and schemaname = '${tableSchema}'
826
+ group by index_name, table_name,schemaname, generated_by_constraint;`
827
+ );
828
+ const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
829
+ for (const dbIndex of dbIndexes) {
830
+ const indexName2 = dbIndex.index_name;
831
+ const indexColumnName = dbIndex.column_name;
832
+ const indexIsUnique = dbIndex.is_unique;
833
+ if (idxsInConsteraint.includes(indexName2))
834
+ continue;
835
+ if (typeof indexToReturn[indexName2] !== "undefined") {
836
+ indexToReturn[indexName2].columns.push(indexColumnName);
837
+ } else {
838
+ indexToReturn[indexName2] = {
839
+ name: indexName2,
840
+ columns: [indexColumnName],
841
+ isUnique: indexIsUnique
842
+ };
843
+ }
844
+ }
845
+ indexesCount += Object.keys(indexToReturn).length;
846
+ if (progressCallback) {
847
+ progressCallback("indexes", indexesCount, "fetching");
848
+ }
849
+ result[tableName] = {
850
+ name: tableName,
851
+ schema: tableSchema !== "public" ? tableSchema : "",
852
+ columns: columnToReturn,
853
+ indexes: indexToReturn,
854
+ foreignKeys: foreignKeysToReturn,
855
+ compositePrimaryKeys: primaryKeys,
856
+ uniqueConstraints: uniqueConstrains
857
+ };
858
+ } catch (e) {
859
+ rej(e);
860
+ return;
861
+ }
862
+ res("");
863
+ });
864
+ });
865
+ if (progressCallback) {
866
+ progressCallback("tables", tableCount, "done");
867
+ }
868
+ for await (const _ of all) {
869
+ }
870
+ if (progressCallback) {
871
+ progressCallback("columns", columnsCount, "done");
872
+ progressCallback("indexes", indexesCount, "done");
873
+ progressCallback("fks", foreignKeysCount, "done");
874
+ }
875
+ const allEnums = await db.query(
876
+ `select n.nspname as enum_schema,
877
+ t.typname as enum_name,
878
+ e.enumlabel as enum_value
879
+ from pg_type t
880
+ join pg_enum e on t.oid = e.enumtypid
881
+ join pg_catalog.pg_namespace n ON n.oid = t.typnamespace;`
882
+ );
883
+ const enumsToReturn = {};
884
+ for (const dbEnum of allEnums) {
885
+ const enumName = dbEnum.enum_name;
886
+ const enumValue = dbEnum.enum_value;
887
+ if (enumsToReturn[enumName] !== void 0 && enumsToReturn[enumName] !== null) {
888
+ enumsToReturn[enumName].values[enumValue] = enumValue;
889
+ } else {
890
+ enumsToReturn[enumName] = {
891
+ name: enumName,
892
+ values: { [enumValue]: enumValue }
893
+ };
894
+ }
895
+ }
896
+ if (progressCallback) {
897
+ progressCallback("enums", Object.keys(enumsToReturn).length, "done");
898
+ }
899
+ const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
900
+ return {
901
+ version: "5",
902
+ dialect: "pg",
903
+ tables: result,
904
+ enums: enumsToReturn,
905
+ schemas: schemasObject,
906
+ _meta: {
907
+ schemas: {},
908
+ tables: {},
909
+ columns: {}
910
+ },
911
+ internal: internals
912
+ };
913
+ };
914
+ columnToDefault = {
915
+ "numeric(": "::numeric",
916
+ // text: "::text",
917
+ // "character varying": "::character varying",
918
+ // "double precision": "::double precision",
919
+ // "time with time zone": "::time with time zone",
920
+ "time without time zone": "::time without time zone",
921
+ // "timestamp with time zone": "::timestamp with time zone",
922
+ "timestamp without time zone": "::timestamp without time zone",
923
+ // date: "::date",
924
+ // interval: "::interval",
925
+ // character: "::bpchar",
926
+ // macaddr8: "::macaddr8",
927
+ // macaddr: "::macaddr",
928
+ // inet: "::inet",
929
+ // cidr: "::cidr",
930
+ // jsonb: "::jsonb",
931
+ // json: "::json",
932
+ "character(": "::bpchar"
933
+ };
934
+ defaultForColumn = (column) => {
935
+ if (column.data_type === "serial" || column.data_type === "smallserial" || column.data_type === "bigserial") {
936
+ return void 0;
937
+ }
938
+ const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
939
+ (it) => column.data_type.startsWith(it)
940
+ );
941
+ if (column.column_default === null) {
942
+ return void 0;
943
+ }
944
+ const columnDefaultAsString = column.column_default.toString();
945
+ if (columnDefaultAsString.endsWith(
946
+ hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column.data_type
947
+ )) {
948
+ const nonPrefixPart = column.column_default.length - (hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column.data_type}`).length - 1;
949
+ const rt = column.column_default.toString().substring(1, nonPrefixPart);
950
+ if (/^-?[\d.]+(?:e-?\d+)?$/.test(rt) && !column.data_type.startsWith("numeric")) {
951
+ return Number(rt);
952
+ } else if (column.data_type === "json" || column.data_type === "jsonb") {
953
+ const jsonWithoutSpaces = JSON.stringify(JSON.parse(rt));
954
+ return `'${jsonWithoutSpaces}'${hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : `::${column.data_type}`}`;
955
+ } else if (column.data_type === "boolean") {
956
+ return column.column_default === "true";
957
+ } else {
958
+ return `'${rt}'`;
959
+ }
960
+ } else {
961
+ if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString) && !column.data_type.startsWith("numeric")) {
962
+ return Number(columnDefaultAsString);
963
+ } else if (column.data_type === "boolean") {
964
+ return column.column_default === "true";
965
+ } else {
966
+ return `${columnDefaultAsString}`;
967
+ }
968
+ }
969
+ };
970
+ toDrizzle = (schema) => {
971
+ const tables = {};
972
+ Object.values(schema.tables).forEach((t) => {
973
+ const columns = {};
974
+ Object.values(t.columns).forEach((c) => {
975
+ const columnName = c.name;
976
+ const type = c.type;
977
+ let columnBuilder;
978
+ if (type === "bigint") {
979
+ columnBuilder = new import_pg_core.PgBigInt53Builder(columnName);
980
+ } else if (type === "bigserial") {
981
+ columnBuilder = new import_pg_core.PgBigSerial53Builder(columnName);
982
+ } else if (type === "boolean") {
983
+ columnBuilder = new import_pg_core.PgBooleanBuilder(columnName);
984
+ } else if (type === "cidr") {
985
+ columnBuilder = new import_pg_core.PgCidrBuilder(columnName);
986
+ } else if (type === "date") {
987
+ columnBuilder = new import_pg_core.PgDateBuilder(columnName);
988
+ } else if (type === "double precision") {
989
+ columnBuilder = new import_pg_core.PgDoublePrecisionBuilder(columnName);
990
+ } else if (type === "inet") {
991
+ columnBuilder = new import_pg_core.PgInetBuilder(columnName);
992
+ } else if (type === "integer") {
993
+ columnBuilder = new import_pg_core.PgIntegerBuilder(columnName);
994
+ } else if (type === "interval" || type.startsWith("interval ")) {
995
+ columnBuilder = new import_pg_core.PgIntervalBuilder(columnName, {});
996
+ } else if (type === "json") {
997
+ columnBuilder = new import_pg_core.PgJsonBuilder(columnName);
998
+ } else if (type === "jsonb") {
999
+ columnBuilder = new import_pg_core.PgJsonbBuilder(columnName);
1000
+ } else if (type === "macaddr") {
1001
+ columnBuilder = new import_pg_core.PgMacaddrBuilder(columnName);
1002
+ } else if (type === "macaddr8") {
1003
+ columnBuilder = new import_pg_core.PgMacaddr8Builder(columnName);
1004
+ } else if (type === "numeric" || type.startsWith("numeric(")) {
1005
+ columnBuilder = new import_pg_core.PgNumericBuilder(columnName);
1006
+ } else if (type === "real") {
1007
+ columnBuilder = new import_pg_core.PgRealBuilder(columnName);
1008
+ } else if (type === "serial") {
1009
+ columnBuilder = new import_pg_core.PgSerialBuilder(columnName);
1010
+ } else if (type === "smallint") {
1011
+ columnBuilder = new import_pg_core.PgSmallIntBuilder(columnName);
1012
+ } else if (type === "smallserial") {
1013
+ columnBuilder = new import_pg_core.PgSmallSerialBuilder(columnName);
1014
+ } else if (type === "text") {
1015
+ columnBuilder = new import_pg_core.PgTextBuilder(columnName, {});
1016
+ } else if (type === "time" || type.startsWith("time(") || type === "time with time zone") {
1017
+ columnBuilder = new import_pg_core.PgTimeBuilder(columnName, false, void 0);
1018
+ } else if (type === "timestamp" || type.startsWith("timestamp(") || type === "timestamp with time zone") {
1019
+ columnBuilder = new import_pg_core.PgTimestampBuilder(columnName, false, void 0);
1020
+ } else if (type === "uuid") {
1021
+ columnBuilder = new import_pg_core.PgUUIDBuilder(columnName);
1022
+ } else if (type === "varchar" || type.startsWith("varchar(")) {
1023
+ columnBuilder = new import_pg_core.PgVarcharBuilder(columnName, {});
1024
+ } else if (type === "char" || type.startsWith("char(")) {
1025
+ columnBuilder = new import_pg_core.PgCharBuilder(columnName, {});
1026
+ } else {
1027
+ columnBuilder = (0, import_pg_core.customType)({
1028
+ dataType() {
1029
+ return type;
1030
+ }
1031
+ })(columnName);
1032
+ }
1033
+ if (c.notNull) {
1034
+ columnBuilder = columnBuilder.notNull();
1035
+ }
1036
+ if (c.default) {
1037
+ columnBuilder = columnBuilder.default(c.default);
1038
+ }
1039
+ if (c.primaryKey) {
1040
+ columnBuilder = columnBuilder.primaryKey();
1041
+ }
1042
+ columns[columnName] = columnBuilder;
1043
+ });
1044
+ tables[t.name] = (0, import_pg_core.pgTable)(t.name, columns, (cb) => {
1045
+ const res = {};
1046
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
1047
+ const gh = cpk.columns.map((c) => cb[c]);
1048
+ res[cpk.name] = new import_pg_core.PrimaryKeyBuilder(
1049
+ gh,
1050
+ cpk.name
1051
+ );
1052
+ });
1053
+ return res;
1054
+ });
1055
+ });
1056
+ return tables;
1057
+ };
1058
+ }
1059
+ });
1060
+
1061
+ // src/serializer/sqliteSerializer.ts
1062
+ function mapSqlToSqliteType(sqlType) {
1063
+ if ([
1064
+ "int",
1065
+ "integer",
1066
+ "integer auto_increment",
1067
+ "tinyint",
1068
+ "smallint",
1069
+ "mediumint",
1070
+ "bigint",
1071
+ "unsigned big int",
1072
+ "int2",
1073
+ "int8"
1074
+ ].includes(sqlType.toLowerCase())) {
1075
+ return "integer";
1076
+ } else if ([
1077
+ "character",
1078
+ "varchar",
1079
+ "vatying character",
1080
+ "nchar",
1081
+ "native character",
1082
+ "nvarchar",
1083
+ "text",
1084
+ "clob"
1085
+ ].some((it) => it.startsWith(sqlType.toLowerCase()))) {
1086
+ return "text";
1087
+ } else if (sqlType.toLowerCase() === "blob") {
1088
+ return "blob";
1089
+ } else if (["real", "double", "double precision", "float"].includes(
1090
+ sqlType.toLowerCase()
1091
+ )) {
1092
+ return "real";
1093
+ } else {
1094
+ return "numeric";
1095
+ }
1096
+ }
1097
+ var import_drizzle_orm2, import_sqlite_core, dialect2, fromDatabase2, toDrizzle2;
1098
+ var init_sqliteSerializer = __esm({
1099
+ "src/serializer/sqliteSerializer.ts"() {
1100
+ import_drizzle_orm2 = require("drizzle-orm");
1101
+ import_sqlite_core = require("drizzle-orm/sqlite-core");
1102
+ init_serializer();
1103
+ init_outputs();
1104
+ init_source();
1105
+ dialect2 = new import_sqlite_core.SQLiteSyncDialect();
1106
+ fromDatabase2 = async (db, tablesFilter = (table) => true, progressCallback) => {
1107
+ const result = {};
1108
+ const columns = await db.query(
1109
+ `SELECT
1110
+ m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
1111
+ FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
1112
+ WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table';
1113
+ `
1114
+ );
1115
+ const tablesWithSeq = [];
1116
+ const seq = await db.query(
1117
+ `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence' and name != 'sqlite_stat1' and name != '_litestream_seq' and name != '_litestream_lock' and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
1118
+ );
1119
+ for (const s of seq) {
1120
+ tablesWithSeq.push(s.name);
1121
+ }
1122
+ let columnsCount = 0;
1123
+ let tablesCount = /* @__PURE__ */ new Set();
1124
+ let indexesCount = 0;
1125
+ let foreignKeysCount = 0;
1126
+ const tableToPk = {};
1127
+ for (const column of columns) {
1128
+ if (!tablesFilter(column.tableName))
1129
+ continue;
1130
+ columnsCount += 1;
1131
+ if (progressCallback) {
1132
+ progressCallback("columns", columnsCount, "fetching");
1133
+ }
1134
+ const tableName = column.tableName;
1135
+ tablesCount.add(tableName);
1136
+ if (progressCallback) {
1137
+ progressCallback("tables", tablesCount.size, "fetching");
1138
+ }
1139
+ const columnName = column.columnName;
1140
+ const isNotNull = column.notNull === 1;
1141
+ const columnType = column.columnType;
1142
+ const isPrimary = column.pk !== 0;
1143
+ const columnDefault = column.defaultValue;
1144
+ const isAutoincrement = isPrimary && tablesWithSeq.includes(tableName);
1145
+ if (isPrimary) {
1146
+ if (typeof tableToPk[tableName] === "undefined") {
1147
+ tableToPk[tableName] = [columnName];
1148
+ } else {
1149
+ tableToPk[tableName].push(columnName);
1150
+ }
1151
+ }
1152
+ const table = result[tableName];
1153
+ const newColumn = {
1154
+ default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) ? Number(columnDefault) : ["CURRENT_TIME", "CURRENT_DATE", "CURRENT_TIMESTAMP"].includes(
1155
+ columnDefault
1156
+ ) ? `(${columnDefault})` : columnDefault === "false" ? false : columnDefault === "true" ? true : columnDefault.startsWith("'") && columnDefault.endsWith("'") ? columnDefault : (
1157
+ // ? columnDefault.substring(1, columnDefault.length - 1)
1158
+ `(${columnDefault})`
1159
+ ),
1160
+ autoincrement: isAutoincrement,
1161
+ name: columnName,
1162
+ type: mapSqlToSqliteType(columnType),
1163
+ primaryKey: false,
1164
+ notNull: isNotNull
1165
+ };
1166
+ if (!table) {
1167
+ result[tableName] = {
1168
+ name: tableName,
1169
+ columns: {
1170
+ [columnName]: newColumn
1171
+ },
1172
+ compositePrimaryKeys: {},
1173
+ indexes: {},
1174
+ foreignKeys: {},
1175
+ uniqueConstraints: {}
1176
+ };
1177
+ } else {
1178
+ result[tableName].columns[columnName] = newColumn;
1179
+ }
1180
+ }
1181
+ for (const [key, value] of Object.entries(tableToPk)) {
1182
+ if (value.length > 1) {
1183
+ value.sort();
1184
+ result[key].compositePrimaryKeys = {
1185
+ [`${key}_${value.join("_")}_pk`]: {
1186
+ columns: value,
1187
+ name: `${key}_${value.join("_")}_pk`
1188
+ }
1189
+ };
1190
+ } else if (value.length === 1) {
1191
+ result[key].columns[value[0]].primaryKey = true;
1192
+ } else {
1193
+ }
1194
+ }
1195
+ if (progressCallback) {
1196
+ progressCallback("columns", columnsCount, "done");
1197
+ progressCallback("tables", tablesCount.size, "done");
1198
+ }
1199
+ try {
1200
+ const fks = await db.query(
1201
+ `SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
1202
+ FROM sqlite_master m, pragma_foreign_key_list(m.name) as f;`
1203
+ );
1204
+ const fkByTableName = {};
1205
+ for (const fkRow of fks) {
1206
+ foreignKeysCount += 1;
1207
+ if (progressCallback) {
1208
+ progressCallback("fks", foreignKeysCount, "fetching");
1209
+ }
1210
+ const tableName = fkRow.tableFrom;
1211
+ const columnName = fkRow.from;
1212
+ const refTableName = fkRow.tableTo;
1213
+ const refColumnName = fkRow.to;
1214
+ const updateRule = fkRow.onUpdate;
1215
+ const deleteRule = fkRow.onDelete;
1216
+ const sequence = fkRow.seq;
1217
+ const id = fkRow.id;
1218
+ const tableInResult = result[tableName];
1219
+ if (typeof tableInResult === "undefined")
1220
+ continue;
1221
+ if (typeof fkByTableName[`${tableName}_${id}`] !== "undefined") {
1222
+ fkByTableName[`${tableName}_${id}`].columnsFrom.push(columnName);
1223
+ fkByTableName[`${tableName}_${id}`].columnsTo.push(refColumnName);
1224
+ } else {
1225
+ fkByTableName[`${tableName}_${id}`] = {
1226
+ name: "",
1227
+ tableFrom: tableName,
1228
+ tableTo: refTableName,
1229
+ columnsFrom: [columnName],
1230
+ columnsTo: [refColumnName],
1231
+ onDelete: deleteRule == null ? void 0 : deleteRule.toLowerCase(),
1232
+ onUpdate: updateRule == null ? void 0 : updateRule.toLowerCase()
1233
+ };
1234
+ }
1235
+ const columnsFrom = fkByTableName[`${tableName}_${id}`].columnsFrom;
1236
+ const columnsTo = fkByTableName[`${tableName}_${id}`].columnsTo;
1237
+ fkByTableName[`${tableName}_${id}`].name = `${tableName}_${columnsFrom.join(
1238
+ "_"
1239
+ )}_${refTableName}_${columnsTo.join("_")}_fk`;
1240
+ }
1241
+ for (const idx of Object.keys(fkByTableName)) {
1242
+ const value = fkByTableName[idx];
1243
+ result[value.tableFrom].foreignKeys[value.name] = value;
1244
+ }
1245
+ } catch (e) {
1246
+ }
1247
+ if (progressCallback) {
1248
+ progressCallback("fks", foreignKeysCount, "done");
1249
+ }
1250
+ const idxs = await db.query(
1251
+ `SELECT
1252
+ m.tbl_name as tableName,
1253
+ il.name as indexName,
1254
+ ii.name as columnName,
1255
+ il.[unique] as isUnique,
1256
+ il.seq as seq
1257
+ FROM sqlite_master AS m,
1258
+ pragma_index_list(m.name) AS il,
1259
+ pragma_index_info(il.name) AS ii
1260
+ WHERE
1261
+ m.type = 'table' and il.name NOT LIKE 'sqlite_autoindex_%';`
1262
+ );
1263
+ for (const idxRow of idxs) {
1264
+ const tableName = idxRow.tableName;
1265
+ const constraintName = idxRow.indexName;
1266
+ const columnName = idxRow.columnName;
1267
+ const isUnique = idxRow.isUnique === 1;
1268
+ const tableInResult = result[tableName];
1269
+ if (typeof tableInResult === "undefined")
1270
+ continue;
1271
+ indexesCount += 1;
1272
+ if (progressCallback) {
1273
+ progressCallback("indexes", indexesCount, "fetching");
1274
+ }
1275
+ if (typeof tableInResult.indexes[constraintName] !== "undefined") {
1276
+ tableInResult.indexes[constraintName].columns.push(columnName);
1277
+ } else {
1278
+ tableInResult.indexes[constraintName] = {
1279
+ name: constraintName,
1280
+ columns: [columnName],
1281
+ isUnique
1282
+ };
1283
+ }
1284
+ }
1285
+ if (progressCallback) {
1286
+ progressCallback("indexes", indexesCount, "done");
1287
+ progressCallback("enums", 0, "done");
1288
+ }
1289
+ return {
1290
+ version: "5",
1291
+ dialect: "sqlite",
1292
+ tables: result,
1293
+ enums: {},
1294
+ _meta: {
1295
+ tables: {},
1296
+ columns: {}
1297
+ }
1298
+ };
1299
+ };
1300
+ toDrizzle2 = (schema) => {
1301
+ const tables = {};
1302
+ Object.values(schema.tables).forEach((t) => {
1303
+ const columns = {};
1304
+ Object.values(t.columns).forEach((c) => {
1305
+ const columnName = c.name;
1306
+ const type = c.type;
1307
+ let columnBuilder;
1308
+ if (type === "integer") {
1309
+ columnBuilder = new import_sqlite_core.SQLiteIntegerBuilder(columnName);
1310
+ } else if (type === "text") {
1311
+ columnBuilder = new import_sqlite_core.SQLiteTextBuilder(columnName, {});
1312
+ } else if (type === "blob") {
1313
+ columnBuilder = new import_sqlite_core.SQLiteBlobBufferBuilder(columnName);
1314
+ } else if (type === "real") {
1315
+ columnBuilder = new import_sqlite_core.SQLiteRealBuilder(columnName);
1316
+ } else {
1317
+ columnBuilder = new import_sqlite_core.SQLiteNumericBuilder(columnName);
1318
+ }
1319
+ if (c.notNull) {
1320
+ columnBuilder = columnBuilder.notNull();
1321
+ }
1322
+ if (c.default) {
1323
+ columnBuilder = columnBuilder.default(c.default);
1324
+ }
1325
+ if (c.primaryKey) {
1326
+ columnBuilder = columnBuilder.primaryKey();
1327
+ }
1328
+ columns[columnName] = columnBuilder;
1329
+ });
1330
+ tables[t.name] = (0, import_sqlite_core.sqliteTable)(t.name, columns, (cb) => {
1331
+ const res = {};
1332
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
1333
+ const gh = cpk.columns.map((c) => cb[c]);
1334
+ res[cpk.name] = new import_sqlite_core.PrimaryKeyBuilder(
1335
+ gh,
1336
+ cpk.name
1337
+ );
1338
+ });
1339
+ return res;
1340
+ });
1341
+ });
1342
+ return tables;
1343
+ };
1344
+ }
1345
+ });
1346
+
1347
+ // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
1348
+ var require_readline = __commonJS({
1349
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
1350
+ "use strict";
1351
+ Object.defineProperty(exports, "__esModule", { value: true });
1352
+ exports.prepareReadLine = void 0;
1353
+ var prepareReadLine = () => {
1354
+ const stdin = process.stdin;
1355
+ const stdout = process.stdout;
1356
+ const readline = require("readline");
1357
+ const rl = readline.createInterface({
1358
+ input: stdin,
1359
+ escapeCodeTimeout: 50
1360
+ });
1361
+ readline.emitKeypressEvents(stdin, rl);
1362
+ return {
1363
+ stdin,
1364
+ stdout,
1365
+ closable: rl
1366
+ };
1367
+ };
1368
+ exports.prepareReadLine = prepareReadLine;
1369
+ }
1370
+ });
1371
+
1372
+ // node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
1373
+ var require_src = __commonJS({
1374
+ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
1375
+ "use strict";
1376
+ var ESC = "\x1B";
1377
+ var CSI = `${ESC}[`;
1378
+ var beep = "\x07";
1379
+ var cursor = {
1380
+ to(x, y) {
1381
+ if (!y)
1382
+ return `${CSI}${x + 1}G`;
1383
+ return `${CSI}${y + 1};${x + 1}H`;
1384
+ },
1385
+ move(x, y) {
1386
+ let ret = "";
1387
+ if (x < 0)
1388
+ ret += `${CSI}${-x}D`;
1389
+ else if (x > 0)
1390
+ ret += `${CSI}${x}C`;
1391
+ if (y < 0)
1392
+ ret += `${CSI}${-y}A`;
1393
+ else if (y > 0)
1394
+ ret += `${CSI}${y}B`;
1395
+ return ret;
1396
+ },
1397
+ up: (count = 1) => `${CSI}${count}A`,
1398
+ down: (count = 1) => `${CSI}${count}B`,
1399
+ forward: (count = 1) => `${CSI}${count}C`,
1400
+ backward: (count = 1) => `${CSI}${count}D`,
1401
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
1402
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
1403
+ left: `${CSI}G`,
1404
+ hide: `${CSI}?25l`,
1405
+ show: `${CSI}?25h`,
1406
+ save: `${ESC}7`,
1407
+ restore: `${ESC}8`
1408
+ };
1409
+ var scroll = {
1410
+ up: (count = 1) => `${CSI}S`.repeat(count),
1411
+ down: (count = 1) => `${CSI}T`.repeat(count)
1412
+ };
1413
+ var erase = {
1414
+ screen: `${CSI}2J`,
1415
+ up: (count = 1) => `${CSI}1J`.repeat(count),
1416
+ down: (count = 1) => `${CSI}J`.repeat(count),
1417
+ line: `${CSI}2K`,
1418
+ lineEnd: `${CSI}K`,
1419
+ lineStart: `${CSI}1K`,
1420
+ lines(count) {
1421
+ let clear = "";
1422
+ for (let i = 0; i < count; i++)
1423
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
1424
+ if (count)
1425
+ clear += cursor.left;
1426
+ return clear;
1427
+ }
1428
+ };
1429
+ module2.exports = { cursor, scroll, erase, beep };
1430
+ }
1431
+ });
1432
+
1433
+ // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
1434
+ var require_utils = __commonJS({
1435
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
1436
+ "use strict";
1437
+ Object.defineProperty(exports, "__esModule", { value: true });
1438
+ exports.clear = void 0;
1439
+ var sisteransi_1 = require_src();
1440
+ var strip = (str) => {
1441
+ const pattern = [
1442
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
1443
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
1444
+ ].join("|");
1445
+ const RGX = new RegExp(pattern, "g");
1446
+ return typeof str === "string" ? str.replace(RGX, "") : str;
1447
+ };
1448
+ var stringWidth = (str) => [...strip(str)].length;
1449
+ var clear = function(prompt, perLine) {
1450
+ if (!perLine)
1451
+ return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);
1452
+ let rows = 0;
1453
+ const lines = prompt.split(/\r?\n/);
1454
+ for (let line of lines) {
1455
+ rows += 1 + Math.floor(Math.max(stringWidth(line) - 1, 0) / perLine);
1456
+ }
1457
+ return sisteransi_1.erase.lines(rows);
1458
+ };
1459
+ exports.clear = clear;
1460
+ }
1461
+ });
1462
+
1463
+ // node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
1464
+ var require_lodash = __commonJS({
1465
+ "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module2) {
1466
+ var FUNC_ERROR_TEXT = "Expected a function";
1467
+ var NAN = 0 / 0;
1468
+ var symbolTag = "[object Symbol]";
1469
+ var reTrim = /^\s+|\s+$/g;
1470
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1471
+ var reIsBinary = /^0b[01]+$/i;
1472
+ var reIsOctal = /^0o[0-7]+$/i;
1473
+ var freeParseInt = parseInt;
1474
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
1475
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1476
+ var root = freeGlobal || freeSelf || Function("return this")();
1477
+ var objectProto = Object.prototype;
1478
+ var objectToString = objectProto.toString;
1479
+ var nativeMax = Math.max;
1480
+ var nativeMin = Math.min;
1481
+ var now = function() {
1482
+ return root.Date.now();
1483
+ };
1484
+ function debounce(func, wait, options) {
1485
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
1486
+ if (typeof func != "function") {
1487
+ throw new TypeError(FUNC_ERROR_TEXT);
1488
+ }
1489
+ wait = toNumber(wait) || 0;
1490
+ if (isObject(options)) {
1491
+ leading = !!options.leading;
1492
+ maxing = "maxWait" in options;
1493
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
1494
+ trailing = "trailing" in options ? !!options.trailing : trailing;
1495
+ }
1496
+ function invokeFunc(time) {
1497
+ var args = lastArgs, thisArg = lastThis;
1498
+ lastArgs = lastThis = void 0;
1499
+ lastInvokeTime = time;
1500
+ result = func.apply(thisArg, args);
1501
+ return result;
1502
+ }
1503
+ function leadingEdge(time) {
1504
+ lastInvokeTime = time;
1505
+ timerId = setTimeout(timerExpired, wait);
1506
+ return leading ? invokeFunc(time) : result;
1507
+ }
1508
+ function remainingWait(time) {
1509
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
1510
+ return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
1511
+ }
1512
+ function shouldInvoke(time) {
1513
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
1514
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1515
+ }
1516
+ function timerExpired() {
1517
+ var time = now();
1518
+ if (shouldInvoke(time)) {
1519
+ return trailingEdge(time);
1520
+ }
1521
+ timerId = setTimeout(timerExpired, remainingWait(time));
1522
+ }
1523
+ function trailingEdge(time) {
1524
+ timerId = void 0;
1525
+ if (trailing && lastArgs) {
1526
+ return invokeFunc(time);
1527
+ }
1528
+ lastArgs = lastThis = void 0;
1529
+ return result;
1530
+ }
1531
+ function cancel() {
1532
+ if (timerId !== void 0) {
1533
+ clearTimeout(timerId);
1534
+ }
1535
+ lastInvokeTime = 0;
1536
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
1537
+ }
1538
+ function flush() {
1539
+ return timerId === void 0 ? result : trailingEdge(now());
1540
+ }
1541
+ function debounced() {
1542
+ var time = now(), isInvoking = shouldInvoke(time);
1543
+ lastArgs = arguments;
1544
+ lastThis = this;
1545
+ lastCallTime = time;
1546
+ if (isInvoking) {
1547
+ if (timerId === void 0) {
1548
+ return leadingEdge(lastCallTime);
1549
+ }
1550
+ if (maxing) {
1551
+ timerId = setTimeout(timerExpired, wait);
1552
+ return invokeFunc(lastCallTime);
1553
+ }
1554
+ }
1555
+ if (timerId === void 0) {
1556
+ timerId = setTimeout(timerExpired, wait);
1557
+ }
1558
+ return result;
1559
+ }
1560
+ debounced.cancel = cancel;
1561
+ debounced.flush = flush;
1562
+ return debounced;
1563
+ }
1564
+ function throttle(func, wait, options) {
1565
+ var leading = true, trailing = true;
1566
+ if (typeof func != "function") {
1567
+ throw new TypeError(FUNC_ERROR_TEXT);
1568
+ }
1569
+ if (isObject(options)) {
1570
+ leading = "leading" in options ? !!options.leading : leading;
1571
+ trailing = "trailing" in options ? !!options.trailing : trailing;
1572
+ }
1573
+ return debounce(func, wait, {
1574
+ "leading": leading,
1575
+ "maxWait": wait,
1576
+ "trailing": trailing
1577
+ });
1578
+ }
1579
+ function isObject(value) {
1580
+ var type = typeof value;
1581
+ return !!value && (type == "object" || type == "function");
1582
+ }
1583
+ function isObjectLike(value) {
1584
+ return !!value && typeof value == "object";
1585
+ }
1586
+ function isSymbol(value) {
1587
+ return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
1588
+ }
1589
+ function toNumber(value) {
1590
+ if (typeof value == "number") {
1591
+ return value;
1592
+ }
1593
+ if (isSymbol(value)) {
1594
+ return NAN;
1595
+ }
1596
+ if (isObject(value)) {
1597
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
1598
+ value = isObject(other) ? other + "" : other;
1599
+ }
1600
+ if (typeof value != "string") {
1601
+ return value === 0 ? value : +value;
1602
+ }
1603
+ value = value.replace(reTrim, "");
1604
+ var isBinary = reIsBinary.test(value);
1605
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
1606
+ }
1607
+ module2.exports = throttle;
1608
+ }
1609
+ });
1610
+
1611
+ // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
1612
+ var require_hanji = __commonJS({
1613
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports) {
1614
+ "use strict";
1615
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
1616
+ function adopt(value) {
1617
+ return value instanceof P ? value : new P(function(resolve) {
1618
+ resolve(value);
1619
+ });
1620
+ }
1621
+ return new (P || (P = Promise))(function(resolve, reject) {
1622
+ function fulfilled(value) {
1623
+ try {
1624
+ step(generator.next(value));
1625
+ } catch (e) {
1626
+ reject(e);
1627
+ }
1628
+ }
1629
+ function rejected(value) {
1630
+ try {
1631
+ step(generator["throw"](value));
1632
+ } catch (e) {
1633
+ reject(e);
1634
+ }
1635
+ }
1636
+ function step(result) {
1637
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1638
+ }
1639
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1640
+ });
1641
+ };
1642
+ var __importDefault = exports && exports.__importDefault || function(mod) {
1643
+ return mod && mod.__esModule ? mod : { "default": mod };
1644
+ };
1645
+ Object.defineProperty(exports, "__esModule", { value: true });
1646
+ exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
1647
+ var readline_1 = require_readline();
1648
+ var sisteransi_1 = require_src();
1649
+ var utils_1 = require_utils();
1650
+ var lodash_throttle_1 = __importDefault(require_lodash());
1651
+ var Prompt2 = class {
1652
+ constructor() {
1653
+ this.attachCallbacks = [];
1654
+ this.detachCallbacks = [];
1655
+ this.inputCallbacks = [];
1656
+ }
1657
+ requestLayout() {
1658
+ this.terminal.requestLayout();
1659
+ }
1660
+ on(type, callback) {
1661
+ if (type === "attach") {
1662
+ this.attachCallbacks.push(callback);
1663
+ } else if (type === "detach") {
1664
+ this.detachCallbacks.push(callback);
1665
+ } else if (type === "input") {
1666
+ this.inputCallbacks.push(callback);
1667
+ }
1668
+ }
1669
+ attach(terminal) {
1670
+ this.terminal = terminal;
1671
+ this.attachCallbacks.forEach((it) => it(terminal));
1672
+ }
1673
+ detach(terminal) {
1674
+ this.detachCallbacks.forEach((it) => it(terminal));
1675
+ this.terminal = void 0;
1676
+ }
1677
+ input(str, key) {
1678
+ this.inputCallbacks.forEach((it) => it(str, key));
1679
+ }
1680
+ };
1681
+ exports.Prompt = Prompt2;
1682
+ var SelectState2 = class {
1683
+ constructor(items) {
1684
+ this.items = items;
1685
+ this.selectedIdx = 0;
1686
+ }
1687
+ bind(prompt) {
1688
+ prompt.on("input", (str, key) => {
1689
+ const invalidate = this.consume(str, key);
1690
+ if (invalidate)
1691
+ prompt.requestLayout();
1692
+ });
1693
+ }
1694
+ consume(str, key) {
1695
+ if (!key)
1696
+ return false;
1697
+ if (key.name === "down") {
1698
+ this.selectedIdx = (this.selectedIdx + 1) % this.items.length;
1699
+ return true;
1700
+ }
1701
+ if (key.name === "up") {
1702
+ this.selectedIdx -= 1;
1703
+ this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;
1704
+ return true;
1705
+ }
1706
+ return false;
1707
+ }
1708
+ };
1709
+ exports.SelectState = SelectState2;
1710
+ var deferred = () => {
1711
+ let resolve;
1712
+ let reject;
1713
+ const promise = new Promise((res, rej) => {
1714
+ resolve = res;
1715
+ reject = rej;
1716
+ });
1717
+ return {
1718
+ resolve,
1719
+ reject,
1720
+ promise
1721
+ };
1722
+ };
1723
+ exports.deferred = deferred;
1724
+ var Terminal = class {
1725
+ constructor(view, stdin, stdout, closable) {
1726
+ this.view = view;
1727
+ this.stdin = stdin;
1728
+ this.stdout = stdout;
1729
+ this.closable = closable;
1730
+ this.text = "";
1731
+ this.status = "idle";
1732
+ if (this.stdin.isTTY)
1733
+ this.stdin.setRawMode(true);
1734
+ const keypress = (str, key) => {
1735
+ if (key.name === "c" && key.ctrl === true) {
1736
+ this.requestLayout();
1737
+ this.view.detach(this);
1738
+ this.tearDown(keypress);
1739
+ if (terminateHandler) {
1740
+ terminateHandler(this.stdin, this.stdout);
1741
+ return;
1742
+ }
1743
+ this.stdout.write(`
1744
+ ^C
1745
+ `);
1746
+ process.exit(1);
1747
+ }
1748
+ if (key.name === "escape") {
1749
+ this.status = "aborted";
1750
+ this.requestLayout();
1751
+ this.view.detach(this);
1752
+ this.tearDown(keypress);
1753
+ this.resolve({ status: "aborted", data: void 0 });
1754
+ return;
1755
+ }
1756
+ if (key.name === "return") {
1757
+ this.status = "submitted";
1758
+ this.requestLayout();
1759
+ this.view.detach(this);
1760
+ this.tearDown(keypress);
1761
+ this.resolve({ status: "submitted", data: this.view.result() });
1762
+ return;
1763
+ }
1764
+ view.input(str, key);
1765
+ };
1766
+ this.stdin.on("keypress", keypress);
1767
+ this.view.attach(this);
1768
+ const { resolve, promise } = (0, exports.deferred)();
1769
+ this.resolve = resolve;
1770
+ this.promise = promise;
1771
+ this.renderFunc = (0, lodash_throttle_1.default)((str) => {
1772
+ this.stdout.write(str);
1773
+ });
1774
+ }
1775
+ tearDown(keypress) {
1776
+ this.stdout.write(sisteransi_1.cursor.show);
1777
+ this.stdin.removeListener("keypress", keypress);
1778
+ if (this.stdin.isTTY)
1779
+ this.stdin.setRawMode(false);
1780
+ this.closable.close();
1781
+ }
1782
+ result() {
1783
+ return this.promise;
1784
+ }
1785
+ toggleCursor(state) {
1786
+ if (state === "hide") {
1787
+ this.stdout.write(sisteransi_1.cursor.hide);
1788
+ } else {
1789
+ this.stdout.write(sisteransi_1.cursor.show);
1790
+ }
1791
+ }
1792
+ requestLayout() {
1793
+ const string = this.view.render(this.status);
1794
+ const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
1795
+ this.text = string;
1796
+ this.renderFunc(`${clearPrefix}${string}`);
1797
+ }
1798
+ };
1799
+ exports.Terminal = Terminal;
1800
+ var TaskView2 = class {
1801
+ constructor() {
1802
+ this.attachCallbacks = [];
1803
+ this.detachCallbacks = [];
1804
+ }
1805
+ requestLayout() {
1806
+ this.terminal.requestLayout();
1807
+ }
1808
+ attach(terminal) {
1809
+ this.terminal = terminal;
1810
+ this.attachCallbacks.forEach((it) => it(terminal));
1811
+ }
1812
+ detach(terminal) {
1813
+ this.detachCallbacks.forEach((it) => it(terminal));
1814
+ this.terminal = void 0;
1815
+ }
1816
+ on(type, callback) {
1817
+ if (type === "attach") {
1818
+ this.attachCallbacks.push(callback);
1819
+ } else if (type === "detach") {
1820
+ this.detachCallbacks.push(callback);
1821
+ }
1822
+ }
1823
+ };
1824
+ exports.TaskView = TaskView2;
1825
+ var TaskTerminal = class {
1826
+ constructor(view, stdout) {
1827
+ this.view = view;
1828
+ this.stdout = stdout;
1829
+ this.text = "";
1830
+ this.view.attach(this);
1831
+ }
1832
+ requestLayout() {
1833
+ const string = this.view.render("pending");
1834
+ const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
1835
+ this.text = string;
1836
+ this.stdout.write(`${clearPrefix}${string}`);
1837
+ }
1838
+ clear() {
1839
+ const string = this.view.render("done");
1840
+ this.view.detach(this);
1841
+ const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
1842
+ this.stdout.write(`${clearPrefix}${string}`);
1843
+ }
1844
+ };
1845
+ exports.TaskTerminal = TaskTerminal;
1846
+ function render2(view) {
1847
+ const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
1848
+ if (view instanceof Prompt2) {
1849
+ const terminal = new Terminal(view, stdin, stdout, closable);
1850
+ terminal.requestLayout();
1851
+ return terminal.result();
1852
+ }
1853
+ stdout.write(`${view}
1854
+ `);
1855
+ closable.close();
1856
+ return;
1857
+ }
1858
+ exports.render = render2;
1859
+ function renderWithTask3(view, task) {
1860
+ return __awaiter(this, void 0, void 0, function* () {
1861
+ const terminal = new TaskTerminal(view, process.stdout);
1862
+ terminal.requestLayout();
1863
+ const result = yield task;
1864
+ terminal.clear();
1865
+ return result;
1866
+ });
1867
+ }
1868
+ exports.renderWithTask = renderWithTask3;
1869
+ var terminateHandler;
1870
+ function onTerminate(callback) {
1871
+ terminateHandler = callback;
1872
+ }
1873
+ exports.onTerminate = onTerminate;
1874
+ }
1875
+ });
1876
+
1877
+ // src/cli/views.ts
1878
+ var import_hanji;
1879
+ var init_views = __esm({
1880
+ "src/cli/views.ts"() {
1881
+ init_source();
1882
+ import_hanji = __toESM(require_hanji());
1883
+ }
1884
+ });
1885
+
1886
+ // node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
1887
+ var require_balanced_match = __commonJS({
1888
+ "node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module2) {
1889
+ "use strict";
1890
+ module2.exports = balanced;
1891
+ function balanced(a, b, str) {
1892
+ if (a instanceof RegExp)
1893
+ a = maybeMatch(a, str);
1894
+ if (b instanceof RegExp)
1895
+ b = maybeMatch(b, str);
1896
+ var r = range(a, b, str);
1897
+ return r && {
1898
+ start: r[0],
1899
+ end: r[1],
1900
+ pre: str.slice(0, r[0]),
1901
+ body: str.slice(r[0] + a.length, r[1]),
1902
+ post: str.slice(r[1] + b.length)
1903
+ };
1904
+ }
1905
+ function maybeMatch(reg, str) {
1906
+ var m = str.match(reg);
1907
+ return m ? m[0] : null;
1908
+ }
1909
+ balanced.range = range;
1910
+ function range(a, b, str) {
1911
+ var begs, beg, left, right, result;
1912
+ var ai = str.indexOf(a);
1913
+ var bi = str.indexOf(b, ai + 1);
1914
+ var i = ai;
1915
+ if (ai >= 0 && bi > 0) {
1916
+ if (a === b) {
1917
+ return [ai, bi];
1918
+ }
1919
+ begs = [];
1920
+ left = str.length;
1921
+ while (i >= 0 && !result) {
1922
+ if (i == ai) {
1923
+ begs.push(i);
1924
+ ai = str.indexOf(a, i + 1);
1925
+ } else if (begs.length == 1) {
1926
+ result = [begs.pop(), bi];
1927
+ } else {
1928
+ beg = begs.pop();
1929
+ if (beg < left) {
1930
+ left = beg;
1931
+ right = bi;
1932
+ }
1933
+ bi = str.indexOf(b, i + 1);
1934
+ }
1935
+ i = ai < bi && ai >= 0 ? ai : bi;
1936
+ }
1937
+ if (begs.length) {
1938
+ result = [left, right];
1939
+ }
1940
+ }
1941
+ return result;
1942
+ }
1943
+ }
1944
+ });
1945
+
1946
+ // node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js
1947
+ var require_brace_expansion = __commonJS({
1948
+ "node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module2) {
1949
+ var balanced = require_balanced_match();
1950
+ module2.exports = expandTop;
1951
+ var escSlash = "\0SLASH" + Math.random() + "\0";
1952
+ var escOpen = "\0OPEN" + Math.random() + "\0";
1953
+ var escClose = "\0CLOSE" + Math.random() + "\0";
1954
+ var escComma = "\0COMMA" + Math.random() + "\0";
1955
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
1956
+ function numeric(str) {
1957
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
1958
+ }
1959
+ function escapeBraces(str) {
1960
+ return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
1961
+ }
1962
+ function unescapeBraces(str) {
1963
+ return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
1964
+ }
1965
+ function parseCommaParts(str) {
1966
+ if (!str)
1967
+ return [""];
1968
+ var parts = [];
1969
+ var m = balanced("{", "}", str);
1970
+ if (!m)
1971
+ return str.split(",");
1972
+ var pre = m.pre;
1973
+ var body = m.body;
1974
+ var post = m.post;
1975
+ var p = pre.split(",");
1976
+ p[p.length - 1] += "{" + body + "}";
1977
+ var postParts = parseCommaParts(post);
1978
+ if (post.length) {
1979
+ p[p.length - 1] += postParts.shift();
1980
+ p.push.apply(p, postParts);
1981
+ }
1982
+ parts.push.apply(parts, p);
1983
+ return parts;
1984
+ }
1985
+ function expandTop(str) {
1986
+ if (!str)
1987
+ return [];
1988
+ if (str.substr(0, 2) === "{}") {
1989
+ str = "\\{\\}" + str.substr(2);
1990
+ }
1991
+ return expand2(escapeBraces(str), true).map(unescapeBraces);
1992
+ }
1993
+ function embrace(str) {
1994
+ return "{" + str + "}";
1995
+ }
1996
+ function isPadded(el) {
1997
+ return /^-?0\d/.test(el);
1998
+ }
1999
+ function lte(i, y) {
2000
+ return i <= y;
2001
+ }
2002
+ function gte(i, y) {
2003
+ return i >= y;
2004
+ }
2005
+ function expand2(str, isTop) {
2006
+ var expansions = [];
2007
+ var m = balanced("{", "}", str);
2008
+ if (!m)
2009
+ return [str];
2010
+ var pre = m.pre;
2011
+ var post = m.post.length ? expand2(m.post, false) : [""];
2012
+ if (/\$$/.test(m.pre)) {
2013
+ for (var k = 0; k < post.length; k++) {
2014
+ var expansion = pre + "{" + m.body + "}" + post[k];
2015
+ expansions.push(expansion);
2016
+ }
2017
+ } else {
2018
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
2019
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
2020
+ var isSequence = isNumericSequence || isAlphaSequence;
2021
+ var isOptions = m.body.indexOf(",") >= 0;
2022
+ if (!isSequence && !isOptions) {
2023
+ if (m.post.match(/,.*\}/)) {
2024
+ str = m.pre + "{" + m.body + escClose + m.post;
2025
+ return expand2(str);
2026
+ }
2027
+ return [str];
2028
+ }
2029
+ var n;
2030
+ if (isSequence) {
2031
+ n = m.body.split(/\.\./);
2032
+ } else {
2033
+ n = parseCommaParts(m.body);
2034
+ if (n.length === 1) {
2035
+ n = expand2(n[0], false).map(embrace);
2036
+ if (n.length === 1) {
2037
+ return post.map(function(p) {
2038
+ return m.pre + n[0] + p;
2039
+ });
2040
+ }
2041
+ }
2042
+ }
2043
+ var N;
2044
+ if (isSequence) {
2045
+ var x = numeric(n[0]);
2046
+ var y = numeric(n[1]);
2047
+ var width = Math.max(n[0].length, n[1].length);
2048
+ var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
2049
+ var test = lte;
2050
+ var reverse = y < x;
2051
+ if (reverse) {
2052
+ incr *= -1;
2053
+ test = gte;
2054
+ }
2055
+ var pad = n.some(isPadded);
2056
+ N = [];
2057
+ for (var i = x; test(i, y); i += incr) {
2058
+ var c;
2059
+ if (isAlphaSequence) {
2060
+ c = String.fromCharCode(i);
2061
+ if (c === "\\")
2062
+ c = "";
2063
+ } else {
2064
+ c = String(i);
2065
+ if (pad) {
2066
+ var need = width - c.length;
2067
+ if (need > 0) {
2068
+ var z = new Array(need + 1).join("0");
2069
+ if (i < 0)
2070
+ c = "-" + z + c.slice(1);
2071
+ else
2072
+ c = z + c;
2073
+ }
2074
+ }
2075
+ }
2076
+ N.push(c);
2077
+ }
2078
+ } else {
2079
+ N = [];
2080
+ for (var j = 0; j < n.length; j++) {
2081
+ N.push.apply(N, expand2(n[j], false));
2082
+ }
2083
+ }
2084
+ for (var j = 0; j < N.length; j++) {
2085
+ for (var k = 0; k < post.length; k++) {
2086
+ var expansion = pre + N[j] + post[k];
2087
+ if (!isTop || isSequence || expansion)
2088
+ expansions.push(expansion);
2089
+ }
2090
+ }
2091
+ }
2092
+ return expansions;
2093
+ }
2094
+ }
2095
+ });
2096
+
2097
+ // src/utils-studio.ts
2098
+ var utils_studio_exports = {};
2099
+ __export(utils_studio_exports, {
2100
+ drizzleSchemaPg: () => toDrizzle,
2101
+ drizzleSchemaSQLite: () => toDrizzle2,
2102
+ pgPushIntrospect: () => pgPushIntrospect,
2103
+ sqlitePushIntrospect: () => sqlitePushIntrospect
2104
+ });
2105
+ module.exports = __toCommonJS(utils_studio_exports);
2106
+ init_pgSerializer();
2107
+ init_sqliteSerializer();
2108
+
2109
+ // src/cli/commands/sqliteIntrospect.ts
2110
+ init_views();
2111
+
2112
+ // src/global.ts
2113
+ var originUUID = "00000000-0000-0000-0000-000000000000";
2114
+
2115
+ // src/cli/commands/sqliteIntrospect.ts
2116
+ init_sqliteSerializer();
2117
+
2118
+ // node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
2119
+ var UPPERCASE = /[\p{Lu}]/u;
2120
+ var LOWERCASE = /[\p{Ll}]/u;
2121
+ var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
2122
+ var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
2123
+ var SEPARATORS = /[_.\- ]+/;
2124
+ var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
2125
+ var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
2126
+ var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
2127
+ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
2128
+ let isLastCharLower = false;
2129
+ let isLastCharUpper = false;
2130
+ let isLastLastCharUpper = false;
2131
+ let isLastLastCharPreserved = false;
2132
+ for (let index = 0; index < string.length; index++) {
2133
+ const character = string[index];
2134
+ isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
2135
+ if (isLastCharLower && UPPERCASE.test(character)) {
2136
+ string = string.slice(0, index) + "-" + string.slice(index);
2137
+ isLastCharLower = false;
2138
+ isLastLastCharUpper = isLastCharUpper;
2139
+ isLastCharUpper = true;
2140
+ index++;
2141
+ } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
2142
+ string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
2143
+ isLastLastCharUpper = isLastCharUpper;
2144
+ isLastCharUpper = false;
2145
+ isLastCharLower = true;
2146
+ } else {
2147
+ isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
2148
+ isLastLastCharUpper = isLastCharUpper;
2149
+ isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
2150
+ }
2151
+ }
2152
+ return string;
2153
+ };
2154
+ var preserveConsecutiveUppercase = (input, toLowerCase) => {
2155
+ LEADING_CAPITAL.lastIndex = 0;
2156
+ return input.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
2157
+ };
2158
+ var postProcess = (input, toUpperCase) => {
2159
+ SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
2160
+ NUMBERS_AND_IDENTIFIER.lastIndex = 0;
2161
+ return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m) => toUpperCase(m));
2162
+ };
2163
+ function camelCase(input, options) {
2164
+ if (!(typeof input === "string" || Array.isArray(input))) {
2165
+ throw new TypeError("Expected the input to be `string | string[]`");
2166
+ }
2167
+ options = {
2168
+ pascalCase: false,
2169
+ preserveConsecutiveUppercase: false,
2170
+ ...options
2171
+ };
2172
+ if (Array.isArray(input)) {
2173
+ input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
2174
+ } else {
2175
+ input = input.trim();
2176
+ }
2177
+ if (input.length === 0) {
2178
+ return "";
2179
+ }
2180
+ const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
2181
+ const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
2182
+ if (input.length === 1) {
2183
+ if (SEPARATORS.test(input)) {
2184
+ return "";
2185
+ }
2186
+ return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
2187
+ }
2188
+ const hasUpperCase = input !== toLowerCase(input);
2189
+ if (hasUpperCase) {
2190
+ input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
2191
+ }
2192
+ input = input.replace(LEADING_SEPARATORS, "");
2193
+ input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
2194
+ if (options.pascalCase) {
2195
+ input = toUpperCase(input.charAt(0)) + input.slice(1);
2196
+ }
2197
+ return postProcess(input, toUpperCase);
2198
+ }
2199
+
2200
+ // src/@types/utils.ts
2201
+ String.prototype.trimChar = function(char) {
2202
+ let start = 0;
2203
+ let end = this.length;
2204
+ while (start < end && this[start] === char)
2205
+ ++start;
2206
+ while (end > start && this[end - 1] === char)
2207
+ --end;
2208
+ return start > 0 || end < this.length ? this.substring(start, end) : this.toString();
2209
+ };
2210
+ String.prototype.squashSpaces = function() {
2211
+ return this.replace(/ +/g, " ").trim();
2212
+ };
2213
+ String.prototype.camelCase = function() {
2214
+ return camelCase(String(this));
2215
+ };
2216
+ String.prototype.concatIf = function(it, condition) {
2217
+ return condition ? `${this}${it}` : this;
2218
+ };
2219
+ Array.prototype.random = function() {
2220
+ return this[~~(Math.random() * this.length)];
2221
+ };
2222
+
2223
+ // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
2224
+ var import_brace_expansion = __toESM(require_brace_expansion(), 1);
2225
+
2226
+ // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js
2227
+ var posixClasses = {
2228
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
2229
+ "[:alpha:]": ["\\p{L}\\p{Nl}", true],
2230
+ "[:ascii:]": ["\\x00-\\x7f", false],
2231
+ "[:blank:]": ["\\p{Zs}\\t", true],
2232
+ "[:cntrl:]": ["\\p{Cc}", true],
2233
+ "[:digit:]": ["\\p{Nd}", true],
2234
+ "[:graph:]": ["\\p{Z}\\p{C}", true, true],
2235
+ "[:lower:]": ["\\p{Ll}", true],
2236
+ "[:print:]": ["\\p{C}", true],
2237
+ "[:punct:]": ["\\p{P}", true],
2238
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
2239
+ "[:upper:]": ["\\p{Lu}", true],
2240
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
2241
+ "[:xdigit:]": ["A-Fa-f0-9", false]
2242
+ };
2243
+ var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
2244
+ var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2245
+ var rangesToString = (ranges) => ranges.join("");
2246
+ var parseClass = (glob2, position) => {
2247
+ const pos = position;
2248
+ if (glob2.charAt(pos) !== "[") {
2249
+ throw new Error("not in a brace expression");
2250
+ }
2251
+ const ranges = [];
2252
+ const negs = [];
2253
+ let i = pos + 1;
2254
+ let sawStart = false;
2255
+ let uflag = false;
2256
+ let escaping = false;
2257
+ let negate = false;
2258
+ let endPos = pos;
2259
+ let rangeStart = "";
2260
+ WHILE:
2261
+ while (i < glob2.length) {
2262
+ const c = glob2.charAt(i);
2263
+ if ((c === "!" || c === "^") && i === pos + 1) {
2264
+ negate = true;
2265
+ i++;
2266
+ continue;
2267
+ }
2268
+ if (c === "]" && sawStart && !escaping) {
2269
+ endPos = i + 1;
2270
+ break;
2271
+ }
2272
+ sawStart = true;
2273
+ if (c === "\\") {
2274
+ if (!escaping) {
2275
+ escaping = true;
2276
+ i++;
2277
+ continue;
2278
+ }
2279
+ }
2280
+ if (c === "[" && !escaping) {
2281
+ for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
2282
+ if (glob2.startsWith(cls, i)) {
2283
+ if (rangeStart) {
2284
+ return ["$.", false, glob2.length - pos, true];
2285
+ }
2286
+ i += cls.length;
2287
+ if (neg)
2288
+ negs.push(unip);
2289
+ else
2290
+ ranges.push(unip);
2291
+ uflag = uflag || u;
2292
+ continue WHILE;
2293
+ }
2294
+ }
2295
+ }
2296
+ escaping = false;
2297
+ if (rangeStart) {
2298
+ if (c > rangeStart) {
2299
+ ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
2300
+ } else if (c === rangeStart) {
2301
+ ranges.push(braceEscape(c));
2302
+ }
2303
+ rangeStart = "";
2304
+ i++;
2305
+ continue;
2306
+ }
2307
+ if (glob2.startsWith("-]", i + 1)) {
2308
+ ranges.push(braceEscape(c + "-"));
2309
+ i += 2;
2310
+ continue;
2311
+ }
2312
+ if (glob2.startsWith("-", i + 1)) {
2313
+ rangeStart = c;
2314
+ i += 2;
2315
+ continue;
2316
+ }
2317
+ ranges.push(braceEscape(c));
2318
+ i++;
2319
+ }
2320
+ if (endPos < i) {
2321
+ return ["", false, 0, false];
2322
+ }
2323
+ if (!ranges.length && !negs.length) {
2324
+ return ["$.", false, glob2.length - pos, true];
2325
+ }
2326
+ if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
2327
+ const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
2328
+ return [regexpEscape(r), false, endPos - pos, false];
2329
+ }
2330
+ const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
2331
+ const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
2332
+ const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
2333
+ return [comb, uflag, endPos - pos, true];
2334
+ };
2335
+
2336
+ // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js
2337
+ var escape = (s, { windowsPathsNoEscape = false } = {}) => {
2338
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
2339
+ };
2340
+
2341
+ // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js
2342
+ var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
2343
+ return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
2344
+ };
2345
+
2346
+ // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
2347
+ var minimatch = (p, pattern, options = {}) => {
2348
+ assertValidPattern(pattern);
2349
+ if (!options.nocomment && pattern.charAt(0) === "#") {
2350
+ return false;
2351
+ }
2352
+ return new Minimatch(pattern, options).match(p);
2353
+ };
2354
+ var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
2355
+ var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
2356
+ var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
2357
+ var starDotExtTestNocase = (ext2) => {
2358
+ ext2 = ext2.toLowerCase();
2359
+ return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
2360
+ };
2361
+ var starDotExtTestNocaseDot = (ext2) => {
2362
+ ext2 = ext2.toLowerCase();
2363
+ return (f) => f.toLowerCase().endsWith(ext2);
2364
+ };
2365
+ var starDotStarRE = /^\*+\.\*+$/;
2366
+ var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
2367
+ var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
2368
+ var dotStarRE = /^\.\*+$/;
2369
+ var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
2370
+ var starRE = /^\*+$/;
2371
+ var starTest = (f) => f.length !== 0 && !f.startsWith(".");
2372
+ var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
2373
+ var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
2374
+ var qmarksTestNocase = ([$0, ext2 = ""]) => {
2375
+ const noext = qmarksTestNoExt([$0]);
2376
+ if (!ext2)
2377
+ return noext;
2378
+ ext2 = ext2.toLowerCase();
2379
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
2380
+ };
2381
+ var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
2382
+ const noext = qmarksTestNoExtDot([$0]);
2383
+ if (!ext2)
2384
+ return noext;
2385
+ ext2 = ext2.toLowerCase();
2386
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
2387
+ };
2388
+ var qmarksTestDot = ([$0, ext2 = ""]) => {
2389
+ const noext = qmarksTestNoExtDot([$0]);
2390
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
2391
+ };
2392
+ var qmarksTest = ([$0, ext2 = ""]) => {
2393
+ const noext = qmarksTestNoExt([$0]);
2394
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
2395
+ };
2396
+ var qmarksTestNoExt = ([$0]) => {
2397
+ const len = $0.length;
2398
+ return (f) => f.length === len && !f.startsWith(".");
2399
+ };
2400
+ var qmarksTestNoExtDot = ([$0]) => {
2401
+ const len = $0.length;
2402
+ return (f) => f.length === len && f !== "." && f !== "..";
2403
+ };
2404
+ var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2405
+ var path = {
2406
+ win32: { sep: "\\" },
2407
+ posix: { sep: "/" }
2408
+ };
2409
+ var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
2410
+ minimatch.sep = sep;
2411
+ var GLOBSTAR = Symbol("globstar **");
2412
+ minimatch.GLOBSTAR = GLOBSTAR;
2413
+ var plTypes = {
2414
+ "!": { open: "(?:(?!(?:", close: "))[^/]*?)" },
2415
+ "?": { open: "(?:", close: ")?" },
2416
+ "+": { open: "(?:", close: ")+" },
2417
+ "*": { open: "(?:", close: ")*" },
2418
+ "@": { open: "(?:", close: ")" }
2419
+ };
2420
+ var qmark = "[^/]";
2421
+ var star = qmark + "*?";
2422
+ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
2423
+ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
2424
+ var charSet = (s) => s.split("").reduce((set, c) => {
2425
+ set[c] = true;
2426
+ return set;
2427
+ }, {});
2428
+ var reSpecials = charSet("().*{}+?[]^$\\!");
2429
+ var addPatternStartSet = charSet("[.(");
2430
+ var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
2431
+ minimatch.filter = filter;
2432
+ var ext = (a, b = {}) => Object.assign({}, a, b);
2433
+ var defaults = (def) => {
2434
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
2435
+ return minimatch;
2436
+ }
2437
+ const orig = minimatch;
2438
+ const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
2439
+ return Object.assign(m, {
2440
+ Minimatch: class Minimatch extends orig.Minimatch {
2441
+ constructor(pattern, options = {}) {
2442
+ super(pattern, ext(def, options));
2443
+ }
2444
+ static defaults(options) {
2445
+ return orig.defaults(ext(def, options)).Minimatch;
2446
+ }
2447
+ },
2448
+ unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
2449
+ escape: (s, options = {}) => orig.escape(s, ext(def, options)),
2450
+ filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
2451
+ defaults: (options) => orig.defaults(ext(def, options)),
2452
+ makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
2453
+ braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
2454
+ match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
2455
+ sep: orig.sep,
2456
+ GLOBSTAR
2457
+ });
2458
+ };
2459
+ minimatch.defaults = defaults;
2460
+ var braceExpand = (pattern, options = {}) => {
2461
+ assertValidPattern(pattern);
2462
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
2463
+ return [pattern];
2464
+ }
2465
+ return (0, import_brace_expansion.default)(pattern);
2466
+ };
2467
+ minimatch.braceExpand = braceExpand;
2468
+ var MAX_PATTERN_LENGTH = 1024 * 64;
2469
+ var assertValidPattern = (pattern) => {
2470
+ if (typeof pattern !== "string") {
2471
+ throw new TypeError("invalid pattern");
2472
+ }
2473
+ if (pattern.length > MAX_PATTERN_LENGTH) {
2474
+ throw new TypeError("pattern is too long");
2475
+ }
2476
+ };
2477
+ var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
2478
+ minimatch.makeRe = makeRe;
2479
+ var match = (list, pattern, options = {}) => {
2480
+ const mm = new Minimatch(pattern, options);
2481
+ list = list.filter((f) => mm.match(f));
2482
+ if (mm.options.nonull && !list.length) {
2483
+ list.push(pattern);
2484
+ }
2485
+ return list;
2486
+ };
2487
+ minimatch.match = match;
2488
+ var globUnescape = (s) => s.replace(/\\(.)/g, "$1");
2489
+ var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
2490
+ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2491
+ var Minimatch = class {
2492
+ options;
2493
+ set;
2494
+ pattern;
2495
+ windowsPathsNoEscape;
2496
+ nonegate;
2497
+ negate;
2498
+ comment;
2499
+ empty;
2500
+ preserveMultipleSlashes;
2501
+ partial;
2502
+ globSet;
2503
+ globParts;
2504
+ nocase;
2505
+ isWindows;
2506
+ platform;
2507
+ windowsNoMagicRoot;
2508
+ regexp;
2509
+ constructor(pattern, options = {}) {
2510
+ assertValidPattern(pattern);
2511
+ options = options || {};
2512
+ this.options = options;
2513
+ this.pattern = pattern;
2514
+ this.platform = options.platform || defaultPlatform;
2515
+ this.isWindows = this.platform === "win32";
2516
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
2517
+ if (this.windowsPathsNoEscape) {
2518
+ this.pattern = this.pattern.replace(/\\/g, "/");
2519
+ }
2520
+ this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
2521
+ this.regexp = null;
2522
+ this.negate = false;
2523
+ this.nonegate = !!options.nonegate;
2524
+ this.comment = false;
2525
+ this.empty = false;
2526
+ this.partial = !!options.partial;
2527
+ this.nocase = !!this.options.nocase;
2528
+ this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
2529
+ this.globSet = [];
2530
+ this.globParts = [];
2531
+ this.set = [];
2532
+ this.make();
2533
+ }
2534
+ hasMagic() {
2535
+ if (this.options.magicalBraces && this.set.length > 1) {
2536
+ return true;
2537
+ }
2538
+ for (const pattern of this.set) {
2539
+ for (const part of pattern) {
2540
+ if (typeof part !== "string")
2541
+ return true;
2542
+ }
2543
+ }
2544
+ return false;
2545
+ }
2546
+ debug(..._) {
2547
+ }
2548
+ make() {
2549
+ const pattern = this.pattern;
2550
+ const options = this.options;
2551
+ if (!options.nocomment && pattern.charAt(0) === "#") {
2552
+ this.comment = true;
2553
+ return;
2554
+ }
2555
+ if (!pattern) {
2556
+ this.empty = true;
2557
+ return;
2558
+ }
2559
+ this.parseNegate();
2560
+ this.globSet = [...new Set(this.braceExpand())];
2561
+ if (options.debug) {
2562
+ this.debug = (...args) => console.error(...args);
2563
+ }
2564
+ this.debug(this.pattern, this.globSet);
2565
+ const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
2566
+ this.globParts = this.preprocess(rawGlobParts);
2567
+ this.debug(this.pattern, this.globParts);
2568
+ let set = this.globParts.map((s, _, __) => {
2569
+ if (this.isWindows && this.windowsNoMagicRoot) {
2570
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
2571
+ const isDrive = /^[a-z]:/i.test(s[0]);
2572
+ if (isUNC) {
2573
+ return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
2574
+ } else if (isDrive) {
2575
+ return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
2576
+ }
2577
+ }
2578
+ return s.map((ss) => this.parse(ss));
2579
+ });
2580
+ this.debug(this.pattern, set);
2581
+ this.set = set.filter((s) => s.indexOf(false) === -1);
2582
+ if (this.isWindows) {
2583
+ for (let i = 0; i < this.set.length; i++) {
2584
+ const p = this.set[i];
2585
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
2586
+ p[2] = "?";
2587
+ }
2588
+ }
2589
+ }
2590
+ this.debug(this.pattern, this.set);
2591
+ }
2592
+ // various transforms to equivalent pattern sets that are
2593
+ // faster to process in a filesystem walk. The goal is to
2594
+ // eliminate what we can, and push all ** patterns as far
2595
+ // to the right as possible, even if it increases the number
2596
+ // of patterns that we have to process.
2597
+ preprocess(globParts) {
2598
+ if (this.options.noglobstar) {
2599
+ for (let i = 0; i < globParts.length; i++) {
2600
+ for (let j = 0; j < globParts[i].length; j++) {
2601
+ if (globParts[i][j] === "**") {
2602
+ globParts[i][j] = "*";
2603
+ }
2604
+ }
2605
+ }
2606
+ }
2607
+ const { optimizationLevel = 1 } = this.options;
2608
+ if (optimizationLevel >= 2) {
2609
+ globParts = this.firstPhasePreProcess(globParts);
2610
+ globParts = this.secondPhasePreProcess(globParts);
2611
+ } else if (optimizationLevel >= 1) {
2612
+ globParts = this.levelOneOptimize(globParts);
2613
+ } else {
2614
+ globParts = this.adjascentGlobstarOptimize(globParts);
2615
+ }
2616
+ return globParts;
2617
+ }
2618
+ // just get rid of adjascent ** portions
2619
+ adjascentGlobstarOptimize(globParts) {
2620
+ return globParts.map((parts) => {
2621
+ let gs = -1;
2622
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
2623
+ let i = gs;
2624
+ while (parts[i + 1] === "**") {
2625
+ i++;
2626
+ }
2627
+ if (i !== gs) {
2628
+ parts.splice(gs, i - gs);
2629
+ }
2630
+ }
2631
+ return parts;
2632
+ });
2633
+ }
2634
+ // get rid of adjascent ** and resolve .. portions
2635
+ levelOneOptimize(globParts) {
2636
+ return globParts.map((parts) => {
2637
+ parts = parts.reduce((set, part) => {
2638
+ const prev = set[set.length - 1];
2639
+ if (part === "**" && prev === "**") {
2640
+ return set;
2641
+ }
2642
+ if (part === "..") {
2643
+ if (prev && prev !== ".." && prev !== "." && prev !== "**") {
2644
+ set.pop();
2645
+ return set;
2646
+ }
2647
+ }
2648
+ set.push(part);
2649
+ return set;
2650
+ }, []);
2651
+ return parts.length === 0 ? [""] : parts;
2652
+ });
2653
+ }
2654
+ levelTwoFileOptimize(parts) {
2655
+ if (!Array.isArray(parts)) {
2656
+ parts = this.slashSplit(parts);
2657
+ }
2658
+ let didSomething = false;
2659
+ do {
2660
+ didSomething = false;
2661
+ if (!this.preserveMultipleSlashes) {
2662
+ for (let i = 1; i < parts.length - 1; i++) {
2663
+ const p = parts[i];
2664
+ if (i === 1 && p === "" && parts[0] === "")
2665
+ continue;
2666
+ if (p === "." || p === "") {
2667
+ didSomething = true;
2668
+ parts.splice(i, 1);
2669
+ i--;
2670
+ }
2671
+ }
2672
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
2673
+ didSomething = true;
2674
+ parts.pop();
2675
+ }
2676
+ }
2677
+ let dd = 0;
2678
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2679
+ const p = parts[dd - 1];
2680
+ if (p && p !== "." && p !== ".." && p !== "**") {
2681
+ didSomething = true;
2682
+ parts.splice(dd - 1, 2);
2683
+ dd -= 2;
2684
+ }
2685
+ }
2686
+ } while (didSomething);
2687
+ return parts.length === 0 ? [""] : parts;
2688
+ }
2689
+ // First phase: single-pattern processing
2690
+ // <pre> is 1 or more portions
2691
+ // <rest> is 1 or more portions
2692
+ // <p> is any portion other than ., .., '', or **
2693
+ // <e> is . or ''
2694
+ //
2695
+ // **/.. is *brutal* for filesystem walking performance, because
2696
+ // it effectively resets the recursive walk each time it occurs,
2697
+ // and ** cannot be reduced out by a .. pattern part like a regexp
2698
+ // or most strings (other than .., ., and '') can be.
2699
+ //
2700
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
2701
+ // <pre>/<e>/<rest> -> <pre>/<rest>
2702
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
2703
+ // **/**/<rest> -> **/<rest>
2704
+ //
2705
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
2706
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
2707
+ firstPhasePreProcess(globParts) {
2708
+ let didSomething = false;
2709
+ do {
2710
+ didSomething = false;
2711
+ for (let parts of globParts) {
2712
+ let gs = -1;
2713
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
2714
+ let gss = gs;
2715
+ while (parts[gss + 1] === "**") {
2716
+ gss++;
2717
+ }
2718
+ if (gss > gs) {
2719
+ parts.splice(gs + 1, gss - gs);
2720
+ }
2721
+ let next = parts[gs + 1];
2722
+ const p = parts[gs + 2];
2723
+ const p2 = parts[gs + 3];
2724
+ if (next !== "..")
2725
+ continue;
2726
+ if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
2727
+ continue;
2728
+ }
2729
+ didSomething = true;
2730
+ parts.splice(gs, 1);
2731
+ const other = parts.slice(0);
2732
+ other[gs] = "**";
2733
+ globParts.push(other);
2734
+ gs--;
2735
+ }
2736
+ if (!this.preserveMultipleSlashes) {
2737
+ for (let i = 1; i < parts.length - 1; i++) {
2738
+ const p = parts[i];
2739
+ if (i === 1 && p === "" && parts[0] === "")
2740
+ continue;
2741
+ if (p === "." || p === "") {
2742
+ didSomething = true;
2743
+ parts.splice(i, 1);
2744
+ i--;
2745
+ }
2746
+ }
2747
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
2748
+ didSomething = true;
2749
+ parts.pop();
2750
+ }
2751
+ }
2752
+ let dd = 0;
2753
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2754
+ const p = parts[dd - 1];
2755
+ if (p && p !== "." && p !== ".." && p !== "**") {
2756
+ didSomething = true;
2757
+ const needDot = dd === 1 && parts[dd + 1] === "**";
2758
+ const splin = needDot ? ["."] : [];
2759
+ parts.splice(dd - 1, 2, ...splin);
2760
+ if (parts.length === 0)
2761
+ parts.push("");
2762
+ dd -= 2;
2763
+ }
2764
+ }
2765
+ }
2766
+ } while (didSomething);
2767
+ return globParts;
2768
+ }
2769
+ // second phase: multi-pattern dedupes
2770
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
2771
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
2772
+ // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
2773
+ //
2774
+ // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
2775
+ // ^-- not valid because ** doens't follow symlinks
2776
+ secondPhasePreProcess(globParts) {
2777
+ for (let i = 0; i < globParts.length - 1; i++) {
2778
+ for (let j = i + 1; j < globParts.length; j++) {
2779
+ const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
2780
+ if (!matched)
2781
+ continue;
2782
+ globParts[i] = matched;
2783
+ globParts[j] = [];
2784
+ }
2785
+ }
2786
+ return globParts.filter((gs) => gs.length);
2787
+ }
2788
+ partsMatch(a, b, emptyGSMatch = false) {
2789
+ let ai = 0;
2790
+ let bi = 0;
2791
+ let result = [];
2792
+ let which = "";
2793
+ while (ai < a.length && bi < b.length) {
2794
+ if (a[ai] === b[bi]) {
2795
+ result.push(which === "b" ? b[bi] : a[ai]);
2796
+ ai++;
2797
+ bi++;
2798
+ } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
2799
+ result.push(a[ai]);
2800
+ ai++;
2801
+ } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
2802
+ result.push(b[bi]);
2803
+ bi++;
2804
+ } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
2805
+ if (which === "b")
2806
+ return false;
2807
+ which = "a";
2808
+ result.push(a[ai]);
2809
+ ai++;
2810
+ bi++;
2811
+ } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
2812
+ if (which === "a")
2813
+ return false;
2814
+ which = "b";
2815
+ result.push(b[bi]);
2816
+ ai++;
2817
+ bi++;
2818
+ } else {
2819
+ return false;
2820
+ }
2821
+ }
2822
+ return a.length === b.length && result;
2823
+ }
2824
+ parseNegate() {
2825
+ if (this.nonegate)
2826
+ return;
2827
+ const pattern = this.pattern;
2828
+ let negate = false;
2829
+ let negateOffset = 0;
2830
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
2831
+ negate = !negate;
2832
+ negateOffset++;
2833
+ }
2834
+ if (negateOffset)
2835
+ this.pattern = pattern.slice(negateOffset);
2836
+ this.negate = negate;
2837
+ }
2838
+ // set partial to true to test if, for example,
2839
+ // "/a/b" matches the start of "/*/b/*/d"
2840
+ // Partial means, if you run out of file before you run
2841
+ // out of pattern, then that's fine, as long as all
2842
+ // the parts match.
2843
+ matchOne(file, pattern, partial = false) {
2844
+ const options = this.options;
2845
+ if (this.isWindows) {
2846
+ const fileUNC = file[0] === "" && file[1] === "" && file[2] === "?" && typeof file[3] === "string" && /^[a-z]:$/i.test(file[3]);
2847
+ const patternUNC = pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
2848
+ if (fileUNC && patternUNC) {
2849
+ const fd = file[3];
2850
+ const pd = pattern[3];
2851
+ if (fd.toLowerCase() === pd.toLowerCase()) {
2852
+ file[3] = pd;
2853
+ }
2854
+ } else if (patternUNC && typeof file[0] === "string") {
2855
+ const pd = pattern[3];
2856
+ const fd = file[0];
2857
+ if (pd.toLowerCase() === fd.toLowerCase()) {
2858
+ pattern[3] = fd;
2859
+ pattern = pattern.slice(3);
2860
+ }
2861
+ } else if (fileUNC && typeof pattern[0] === "string") {
2862
+ const fd = file[3];
2863
+ if (fd.toLowerCase() === pattern[0].toLowerCase()) {
2864
+ pattern[0] = fd;
2865
+ file = file.slice(3);
2866
+ }
2867
+ }
2868
+ }
2869
+ const { optimizationLevel = 1 } = this.options;
2870
+ if (optimizationLevel >= 2) {
2871
+ file = this.levelTwoFileOptimize(file);
2872
+ }
2873
+ this.debug("matchOne", this, { file, pattern });
2874
+ this.debug("matchOne", file.length, pattern.length);
2875
+ for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2876
+ this.debug("matchOne loop");
2877
+ var p = pattern[pi];
2878
+ var f = file[fi];
2879
+ this.debug(pattern, p, f);
2880
+ if (p === false) {
2881
+ return false;
2882
+ }
2883
+ if (p === GLOBSTAR) {
2884
+ this.debug("GLOBSTAR", [pattern, p, f]);
2885
+ var fr = fi;
2886
+ var pr = pi + 1;
2887
+ if (pr === pl) {
2888
+ this.debug("** at the end");
2889
+ for (; fi < fl; fi++) {
2890
+ if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
2891
+ return false;
2892
+ }
2893
+ return true;
2894
+ }
2895
+ while (fr < fl) {
2896
+ var swallowee = file[fr];
2897
+ this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
2898
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
2899
+ this.debug("globstar found match!", fr, fl, swallowee);
2900
+ return true;
2901
+ } else {
2902
+ if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
2903
+ this.debug("dot detected!", file, fr, pattern, pr);
2904
+ break;
2905
+ }
2906
+ this.debug("globstar swallow a segment, and continue");
2907
+ fr++;
2908
+ }
2909
+ }
2910
+ if (partial) {
2911
+ this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
2912
+ if (fr === fl) {
2913
+ return true;
2914
+ }
2915
+ }
2916
+ return false;
2917
+ }
2918
+ let hit;
2919
+ if (typeof p === "string") {
2920
+ hit = f === p;
2921
+ this.debug("string match", p, f, hit);
2922
+ } else {
2923
+ hit = p.test(f);
2924
+ this.debug("pattern match", p, f, hit);
2925
+ }
2926
+ if (!hit)
2927
+ return false;
2928
+ }
2929
+ if (fi === fl && pi === pl) {
2930
+ return true;
2931
+ } else if (fi === fl) {
2932
+ return partial;
2933
+ } else if (pi === pl) {
2934
+ return fi === fl - 1 && file[fi] === "";
2935
+ } else {
2936
+ throw new Error("wtf?");
2937
+ }
2938
+ }
2939
+ braceExpand() {
2940
+ return braceExpand(this.pattern, this.options);
2941
+ }
2942
+ parse(pattern) {
2943
+ assertValidPattern(pattern);
2944
+ const options = this.options;
2945
+ if (pattern === "**")
2946
+ return GLOBSTAR;
2947
+ if (pattern === "")
2948
+ return "";
2949
+ let m;
2950
+ let fastTest = null;
2951
+ if (m = pattern.match(starRE)) {
2952
+ fastTest = options.dot ? starTestDot : starTest;
2953
+ } else if (m = pattern.match(starDotExtRE)) {
2954
+ fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
2955
+ } else if (m = pattern.match(qmarksRE)) {
2956
+ fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
2957
+ } else if (m = pattern.match(starDotStarRE)) {
2958
+ fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
2959
+ } else if (m = pattern.match(dotStarRE)) {
2960
+ fastTest = dotStarTest;
2961
+ }
2962
+ let re = "";
2963
+ let hasMagic = false;
2964
+ let escaping = false;
2965
+ const patternListStack = [];
2966
+ const negativeLists = [];
2967
+ let stateChar = false;
2968
+ let uflag = false;
2969
+ let pl;
2970
+ let dotTravAllowed = pattern.charAt(0) === ".";
2971
+ let dotFileAllowed = options.dot || dotTravAllowed;
2972
+ const patternStart = () => dotTravAllowed ? "" : dotFileAllowed ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
2973
+ const subPatternStart = (p) => p.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
2974
+ const clearStateChar = () => {
2975
+ if (stateChar) {
2976
+ switch (stateChar) {
2977
+ case "*":
2978
+ re += star;
2979
+ hasMagic = true;
2980
+ break;
2981
+ case "?":
2982
+ re += qmark;
2983
+ hasMagic = true;
2984
+ break;
2985
+ default:
2986
+ re += "\\" + stateChar;
2987
+ break;
2988
+ }
2989
+ this.debug("clearStateChar %j %j", stateChar, re);
2990
+ stateChar = false;
2991
+ }
2992
+ };
2993
+ for (let i = 0, c; i < pattern.length && (c = pattern.charAt(i)); i++) {
2994
+ this.debug("%s %s %s %j", pattern, i, re, c);
2995
+ if (escaping) {
2996
+ if (c === "/") {
2997
+ return false;
2998
+ }
2999
+ if (reSpecials[c]) {
3000
+ re += "\\";
3001
+ }
3002
+ re += c;
3003
+ escaping = false;
3004
+ continue;
3005
+ }
3006
+ switch (c) {
3007
+ case "/": {
3008
+ return false;
3009
+ }
3010
+ case "\\":
3011
+ clearStateChar();
3012
+ escaping = true;
3013
+ continue;
3014
+ case "?":
3015
+ case "*":
3016
+ case "+":
3017
+ case "@":
3018
+ case "!":
3019
+ this.debug("%s %s %s %j <-- stateChar", pattern, i, re, c);
3020
+ this.debug("call clearStateChar %j", stateChar);
3021
+ clearStateChar();
3022
+ stateChar = c;
3023
+ if (options.noext)
3024
+ clearStateChar();
3025
+ continue;
3026
+ case "(": {
3027
+ if (!stateChar) {
3028
+ re += "\\(";
3029
+ continue;
3030
+ }
3031
+ const plEntry = {
3032
+ type: stateChar,
3033
+ start: i - 1,
3034
+ reStart: re.length,
3035
+ open: plTypes[stateChar].open,
3036
+ close: plTypes[stateChar].close
3037
+ };
3038
+ this.debug(this.pattern, " ", plEntry);
3039
+ patternListStack.push(plEntry);
3040
+ re += plEntry.open;
3041
+ if (plEntry.start === 0 && plEntry.type !== "!") {
3042
+ dotTravAllowed = true;
3043
+ re += subPatternStart(pattern.slice(i + 1));
3044
+ }
3045
+ this.debug("plType %j %j", stateChar, re);
3046
+ stateChar = false;
3047
+ continue;
3048
+ }
3049
+ case ")": {
3050
+ const plEntry = patternListStack[patternListStack.length - 1];
3051
+ if (!plEntry) {
3052
+ re += "\\)";
3053
+ continue;
3054
+ }
3055
+ patternListStack.pop();
3056
+ clearStateChar();
3057
+ hasMagic = true;
3058
+ pl = plEntry;
3059
+ re += pl.close;
3060
+ if (pl.type === "!") {
3061
+ negativeLists.push(Object.assign(pl, { reEnd: re.length }));
3062
+ }
3063
+ continue;
3064
+ }
3065
+ case "|": {
3066
+ const plEntry = patternListStack[patternListStack.length - 1];
3067
+ if (!plEntry) {
3068
+ re += "\\|";
3069
+ continue;
3070
+ }
3071
+ clearStateChar();
3072
+ re += "|";
3073
+ if (plEntry.start === 0 && plEntry.type !== "!") {
3074
+ dotTravAllowed = true;
3075
+ re += subPatternStart(pattern.slice(i + 1));
3076
+ }
3077
+ continue;
3078
+ }
3079
+ case "[":
3080
+ clearStateChar();
3081
+ const [src, needUflag, consumed, magic] = parseClass(pattern, i);
3082
+ if (consumed) {
3083
+ re += src;
3084
+ uflag = uflag || needUflag;
3085
+ i += consumed - 1;
3086
+ hasMagic = hasMagic || magic;
3087
+ } else {
3088
+ re += "\\[";
3089
+ }
3090
+ continue;
3091
+ case "]":
3092
+ re += "\\" + c;
3093
+ continue;
3094
+ default:
3095
+ clearStateChar();
3096
+ re += regExpEscape(c);
3097
+ break;
3098
+ }
3099
+ }
3100
+ for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
3101
+ let tail;
3102
+ tail = re.slice(pl.reStart + pl.open.length);
3103
+ this.debug(this.pattern, "setting tail", re, pl);
3104
+ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
3105
+ if (!$2) {
3106
+ $2 = "\\";
3107
+ }
3108
+ return $1 + $1 + $2 + "|";
3109
+ });
3110
+ this.debug("tail=%j\n %s", tail, tail, pl, re);
3111
+ const t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
3112
+ hasMagic = true;
3113
+ re = re.slice(0, pl.reStart) + t + "\\(" + tail;
3114
+ }
3115
+ clearStateChar();
3116
+ if (escaping) {
3117
+ re += "\\\\";
3118
+ }
3119
+ const addPatternStart = addPatternStartSet[re.charAt(0)];
3120
+ for (let n = negativeLists.length - 1; n > -1; n--) {
3121
+ const nl = negativeLists[n];
3122
+ const nlBefore = re.slice(0, nl.reStart);
3123
+ const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
3124
+ let nlAfter = re.slice(nl.reEnd);
3125
+ const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
3126
+ const closeParensBefore = nlBefore.split(")").length;
3127
+ const openParensBefore = nlBefore.split("(").length - closeParensBefore;
3128
+ let cleanAfter = nlAfter;
3129
+ for (let i = 0; i < openParensBefore; i++) {
3130
+ cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
3131
+ }
3132
+ nlAfter = cleanAfter;
3133
+ const dollar = nlAfter === "" ? "(?:$|\\/)" : "";
3134
+ re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
3135
+ }
3136
+ if (re !== "" && hasMagic) {
3137
+ re = "(?=.)" + re;
3138
+ }
3139
+ if (addPatternStart) {
3140
+ re = patternStart() + re;
3141
+ }
3142
+ if (options.nocase && !hasMagic && !options.nocaseMagicOnly) {
3143
+ hasMagic = pattern.toUpperCase() !== pattern.toLowerCase();
3144
+ }
3145
+ if (!hasMagic) {
3146
+ return globUnescape(re);
3147
+ }
3148
+ const flags = (options.nocase ? "i" : "") + (uflag ? "u" : "");
3149
+ try {
3150
+ const ext2 = fastTest ? {
3151
+ _glob: pattern,
3152
+ _src: re,
3153
+ test: fastTest
3154
+ } : {
3155
+ _glob: pattern,
3156
+ _src: re
3157
+ };
3158
+ return Object.assign(new RegExp("^" + re + "$", flags), ext2);
3159
+ } catch (er) {
3160
+ this.debug("invalid regexp", er);
3161
+ return new RegExp("$.");
3162
+ }
3163
+ }
3164
+ makeRe() {
3165
+ if (this.regexp || this.regexp === false)
3166
+ return this.regexp;
3167
+ const set = this.set;
3168
+ if (!set.length) {
3169
+ this.regexp = false;
3170
+ return this.regexp;
3171
+ }
3172
+ const options = this.options;
3173
+ const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
3174
+ const flags = options.nocase ? "i" : "";
3175
+ let re = set.map((pattern) => {
3176
+ const pp = pattern.map((p) => typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src);
3177
+ pp.forEach((p, i) => {
3178
+ const next = pp[i + 1];
3179
+ const prev = pp[i - 1];
3180
+ if (p !== GLOBSTAR || prev === GLOBSTAR) {
3181
+ return;
3182
+ }
3183
+ if (prev === void 0) {
3184
+ if (next !== void 0 && next !== GLOBSTAR) {
3185
+ pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
3186
+ } else {
3187
+ pp[i] = twoStar;
3188
+ }
3189
+ } else if (next === void 0) {
3190
+ pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
3191
+ } else if (next !== GLOBSTAR) {
3192
+ pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
3193
+ pp[i + 1] = GLOBSTAR;
3194
+ }
3195
+ });
3196
+ return pp.filter((p) => p !== GLOBSTAR).join("/");
3197
+ }).join("|");
3198
+ re = "^(?:" + re + ")$";
3199
+ if (this.negate)
3200
+ re = "^(?!" + re + ").*$";
3201
+ try {
3202
+ this.regexp = new RegExp(re, flags);
3203
+ } catch (ex) {
3204
+ this.regexp = false;
3205
+ }
3206
+ return this.regexp;
3207
+ }
3208
+ slashSplit(p) {
3209
+ if (this.preserveMultipleSlashes) {
3210
+ return p.split("/");
3211
+ } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
3212
+ return ["", ...p.split(/\/+/)];
3213
+ } else {
3214
+ return p.split(/\/+/);
3215
+ }
3216
+ }
3217
+ match(f, partial = this.partial) {
3218
+ this.debug("match", f, this.pattern);
3219
+ if (this.comment) {
3220
+ return false;
3221
+ }
3222
+ if (this.empty) {
3223
+ return f === "";
3224
+ }
3225
+ if (f === "/" && partial) {
3226
+ return true;
3227
+ }
3228
+ const options = this.options;
3229
+ if (this.isWindows) {
3230
+ f = f.split("\\").join("/");
3231
+ }
3232
+ const ff = this.slashSplit(f);
3233
+ this.debug(this.pattern, "split", ff);
3234
+ const set = this.set;
3235
+ this.debug(this.pattern, "set", set);
3236
+ let filename = ff[ff.length - 1];
3237
+ if (!filename) {
3238
+ for (let i = ff.length - 2; !filename && i >= 0; i--) {
3239
+ filename = ff[i];
3240
+ }
3241
+ }
3242
+ for (let i = 0; i < set.length; i++) {
3243
+ const pattern = set[i];
3244
+ let file = ff;
3245
+ if (options.matchBase && pattern.length === 1) {
3246
+ file = [filename];
3247
+ }
3248
+ const hit = this.matchOne(file, pattern, partial);
3249
+ if (hit) {
3250
+ if (options.flipNegate) {
3251
+ return true;
3252
+ }
3253
+ return !this.negate;
3254
+ }
3255
+ }
3256
+ if (options.flipNegate) {
3257
+ return false;
3258
+ }
3259
+ return this.negate;
3260
+ }
3261
+ static defaults(def) {
3262
+ return minimatch.defaults(def).Minimatch;
3263
+ }
3264
+ };
3265
+ minimatch.Minimatch = Minimatch;
3266
+ minimatch.escape = escape;
3267
+ minimatch.unescape = unescape;
3268
+
3269
+ // src/cli/commands/sqliteIntrospect.ts
3270
+ var import_hanji2 = __toESM(require_hanji());
3271
+ var sqlitePushIntrospect = async (client, filters) => {
3272
+ const matchers = filters.map((it) => {
3273
+ return new Minimatch(it);
3274
+ });
3275
+ const filter2 = (tableName) => {
3276
+ if (matchers.length === 0)
3277
+ return true;
3278
+ for (let i = 0; i < matchers.length; i++) {
3279
+ const matcher = matchers[i];
3280
+ if (matcher.match(tableName))
3281
+ return true;
3282
+ }
3283
+ return false;
3284
+ };
3285
+ const res = await fromDatabase2(client, filter2);
3286
+ const schema = { id: originUUID, prevId: "", ...res };
3287
+ return { schema };
3288
+ };
3289
+
3290
+ // src/cli/commands/pgIntrospect.ts
3291
+ var import_hanji3 = __toESM(require_hanji());
3292
+ init_views();
3293
+ init_pgSerializer();
3294
+
3295
+ // src/introspect.ts
3296
+ init_pgSerializer();
3297
+
3298
+ // src/cli/commands/pgIntrospect.ts
3299
+ var pgPushIntrospect = async (connection, filters, schemaFilters) => {
3300
+ const { client } = connection;
3301
+ const matchers = filters.map((it) => {
3302
+ return new Minimatch(it);
3303
+ });
3304
+ const filter2 = (tableName) => {
3305
+ if (matchers.length === 0)
3306
+ return true;
3307
+ for (let i = 0; i < matchers.length; i++) {
3308
+ const matcher = matchers[i];
3309
+ if (matcher.match(tableName))
3310
+ return true;
3311
+ }
3312
+ return false;
3313
+ };
3314
+ const res = await fromDatabase(client, filter2, schemaFilters);
3315
+ const schema = { id: originUUID, prevId: "", ...res };
3316
+ const { internal, ...schemaWithoutInternals } = schema;
3317
+ return { schema: schemaWithoutInternals };
3318
+ };
3319
+ // Annotate the CommonJS export names for ESM import in node:
3320
+ 0 && (module.exports = {
3321
+ drizzleSchemaPg,
3322
+ drizzleSchemaSQLite,
3323
+ pgPushIntrospect,
3324
+ sqlitePushIntrospect
3325
+ });