@carllee1983/dbcli 9.1.0 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.mjs CHANGED
@@ -1,141 +1,36 @@
1
1
  // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
- var __returnValue = (v) => v;
34
- function __exportSetter(name, newValue) {
35
- this[name] = __returnValue.bind(null, newValue);
36
- }
37
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, {
40
- get: all[name],
41
- enumerable: true,
42
- configurable: true,
43
- set: __exportSetter.bind(all, name)
44
- });
2
+ var __esm = (fn, res, err) => () => {
3
+ if (fn)
4
+ try {
5
+ res = fn(fn = 0);
6
+ } catch (e) {
7
+ err = [e];
8
+ }
9
+ if (err)
10
+ throw err[0];
11
+ return res;
45
12
  };
46
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
- var __require = import.meta.require;
48
-
49
- // node_modules/picocolors/picocolors.js
50
- var require_picocolors = __commonJS((exports, module) => {
51
- var p = process || {};
52
- var argv = p.argv || [];
53
- var env = p.env || {};
54
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
55
- var formatter = (open, close, replace = open) => (input) => {
56
- let string = "" + input, index = string.indexOf(close, open.length);
57
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
58
- };
59
- var replaceClose = (string, close, replace, index) => {
60
- let result = "", cursor = 0;
61
- do {
62
- result += string.substring(cursor, index) + replace;
63
- cursor = index + close.length;
64
- index = string.indexOf(close, cursor);
65
- } while (~index);
66
- return result + string.substring(cursor);
67
- };
68
- var createColors = (enabled = isColorSupported) => {
69
- let f = enabled ? formatter : () => String;
70
- return {
71
- isColorSupported: enabled,
72
- reset: f("\x1B[0m", "\x1B[0m"),
73
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
74
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
75
- italic: f("\x1B[3m", "\x1B[23m"),
76
- underline: f("\x1B[4m", "\x1B[24m"),
77
- inverse: f("\x1B[7m", "\x1B[27m"),
78
- hidden: f("\x1B[8m", "\x1B[28m"),
79
- strikethrough: f("\x1B[9m", "\x1B[29m"),
80
- black: f("\x1B[30m", "\x1B[39m"),
81
- red: f("\x1B[31m", "\x1B[39m"),
82
- green: f("\x1B[32m", "\x1B[39m"),
83
- yellow: f("\x1B[33m", "\x1B[39m"),
84
- blue: f("\x1B[34m", "\x1B[39m"),
85
- magenta: f("\x1B[35m", "\x1B[39m"),
86
- cyan: f("\x1B[36m", "\x1B[39m"),
87
- white: f("\x1B[37m", "\x1B[39m"),
88
- gray: f("\x1B[90m", "\x1B[39m"),
89
- bgBlack: f("\x1B[40m", "\x1B[49m"),
90
- bgRed: f("\x1B[41m", "\x1B[49m"),
91
- bgGreen: f("\x1B[42m", "\x1B[49m"),
92
- bgYellow: f("\x1B[43m", "\x1B[49m"),
93
- bgBlue: f("\x1B[44m", "\x1B[49m"),
94
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
95
- bgCyan: f("\x1B[46m", "\x1B[49m"),
96
- bgWhite: f("\x1B[47m", "\x1B[49m"),
97
- blackBright: f("\x1B[90m", "\x1B[39m"),
98
- redBright: f("\x1B[91m", "\x1B[39m"),
99
- greenBright: f("\x1B[92m", "\x1B[39m"),
100
- yellowBright: f("\x1B[93m", "\x1B[39m"),
101
- blueBright: f("\x1B[94m", "\x1B[39m"),
102
- magentaBright: f("\x1B[95m", "\x1B[39m"),
103
- cyanBright: f("\x1B[96m", "\x1B[39m"),
104
- whiteBright: f("\x1B[97m", "\x1B[39m"),
105
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
106
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
107
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
108
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
109
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
110
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
111
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
112
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
113
- };
114
- };
115
- module.exports = createColors();
116
- module.exports.createColors = createColors;
117
- });
118
13
 
119
14
  // node_modules/lru-cache/dist/esm/node/index.min.js
120
15
  import { tracingChannel as j, channel as G } from "diagnostics_channel";
121
- var w, W, C, D = () => w.hasSubscribers || W.hasSubscribers, I, L, P = (u, e, t2, i) => {
122
- typeof L.emitWarning == "function" ? L.emitWarning(u, e, t2, i) : console.error(`[${t2}] ${e}: ${u}`);
16
+ var w, W, C, D = () => w.hasSubscribers || W.hasSubscribers, I, L, P = (u, e, t, i) => {
17
+ typeof L.emitWarning == "function" ? L.emitWarning(u, e, t, i) : console.error(`[${t}] ${e}: ${u}`);
123
18
  }, H = (u) => !I.has(u), T = (u) => !!u && u === Math.floor(u) && u > 0 && isFinite(u), U = (u) => T(u) ? u <= Math.pow(2, 8) ? Uint8Array : u <= Math.pow(2, 16) ? Uint16Array : u <= Math.pow(2, 32) ? Uint32Array : u <= Number.MAX_SAFE_INTEGER ? O : null : null, O, R = class u {
124
19
  heap;
125
20
  length;
126
21
  static #o = false;
127
22
  static create(e) {
128
- let t2 = U(e);
129
- if (!t2)
23
+ let t = U(e);
24
+ if (!t)
130
25
  return [];
131
26
  u.#o = true;
132
- let i = new u(e, t2);
27
+ let i = new u(e, t);
133
28
  return u.#o = false, i;
134
29
  }
135
- constructor(e, t2) {
30
+ constructor(e, t) {
136
31
  if (!u.#o)
137
32
  throw new TypeError("instantiate Stack using Stack.create(n)");
138
- this.heap = new t2(e), this.length = 0;
33
+ this.heap = new t(e), this.length = 0;
139
34
  }
140
35
  push(e) {
141
36
  this.heap[this.length++] = e;
@@ -155,7 +50,7 @@ var init_index_min = __esm(() => {
155
50
  super(e), this.fill(0);
156
51
  }
157
52
  };
158
- M = class u2 {
53
+ M = class u {
159
54
  #o;
160
55
  #c;
161
56
  #w;
@@ -206,7 +101,7 @@ var init_index_min = __esm(() => {
206
101
  return e.#a;
207
102
  }, get tail() {
208
103
  return e.#h;
209
- }, free: e.#y, isBackgroundFetch: (t2) => e.#e(t2), backgroundFetch: (t2, i, s, n) => e.#P(t2, i, s, n), moveToTail: (t2) => e.#L(t2), indexes: (t2) => e.#A(t2), rindexes: (t2) => e.#z(t2), isStale: (t2) => e.#p(t2) };
104
+ }, free: e.#y, isBackgroundFetch: (t) => e.#e(t), backgroundFetch: (t, i, s, n) => e.#P(t, i, s, n), moveToTail: (t) => e.#L(t), indexes: (t) => e.#A(t), rindexes: (t) => e.#z(t), isStale: (t) => e.#p(t) };
210
105
  }
211
106
  get max() {
212
107
  return this.#o;
@@ -236,15 +131,15 @@ var init_index_min = __esm(() => {
236
131
  return this.#S;
237
132
  }
238
133
  constructor(e) {
239
- let { max: t2 = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: r, updateAgeOnHas: h, allowStale: a, dispose: o, onInsert: p, disposeAfter: m, noDisposeOnSet: _, noUpdateTTL: c, maxSize: d = 0, maxEntrySize: f = 0, sizeCalculation: y, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: g, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, perf: x } = e;
134
+ let { max: t = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: r, updateAgeOnHas: h, allowStale: a, dispose: o, onInsert: p, disposeAfter: m, noDisposeOnSet: _, noUpdateTTL: c, maxSize: d = 0, maxEntrySize: f = 0, sizeCalculation: y, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: g, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, perf: x } = e;
240
135
  if (x !== undefined && typeof x?.now != "function")
241
136
  throw new TypeError("perf option must have a now() method if specified");
242
- if (this.#m = x ?? C, t2 !== 0 && !T(t2))
137
+ if (this.#m = x ?? C, t !== 0 && !T(t))
243
138
  throw new TypeError("max option must be a nonnegative integer");
244
- let E = t2 ? U(t2) : Array;
139
+ let E = t ? U(t) : Array;
245
140
  if (!E)
246
- throw new Error("invalid max value: " + t2);
247
- if (this.#o = t2, this.#c = d, this.maxEntrySize = f || this.#c, this.sizeCalculation = y, this.sizeCalculation) {
141
+ throw new Error("invalid max value: " + t);
142
+ if (this.#o = t, this.#c = d, this.maxEntrySize = f || this.#c, this.sizeCalculation = y, this.sizeCalculation) {
248
143
  if (!this.#c && !this.maxEntrySize)
249
144
  throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
250
145
  if (typeof this.sizeCalculation != "function")
@@ -254,7 +149,7 @@ var init_index_min = __esm(() => {
254
149
  throw new TypeError("memoMethod must be a function if defined");
255
150
  if (this.#I = S, l !== undefined && typeof l != "function")
256
151
  throw new TypeError("fetchMethod must be a function if specified");
257
- if (this.#M = l, this.#U = !!l, this.#s = new Map, this.#i = Array.from({ length: t2 }).fill(undefined), this.#t = Array.from({ length: t2 }).fill(undefined), this.#l = new E(t2), this.#u = new E(t2), this.#a = 0, this.#h = 0, this.#y = R.create(t2), this.#n = 0, this.#b = 0, typeof o == "function" && (this.#w = o), typeof p == "function" && (this.#O = p), typeof m == "function" ? (this.#S = m, this.#r = []) : (this.#S = undefined, this.#r = undefined), this.#T = !!this.#w, this.#x = !!this.#O, this.#f = !!this.#S, this.noDisposeOnSet = !!_, this.noUpdateTTL = !!c, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!g, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
152
+ if (this.#M = l, this.#U = !!l, this.#s = new Map, this.#i = Array.from({ length: t }).fill(undefined), this.#t = Array.from({ length: t }).fill(undefined), this.#l = new E(t), this.#u = new E(t), this.#a = 0, this.#h = 0, this.#y = R.create(t), this.#n = 0, this.#b = 0, typeof o == "function" && (this.#w = o), typeof p == "function" && (this.#O = p), typeof m == "function" ? (this.#S = m, this.#r = []) : (this.#S = undefined, this.#r = undefined), this.#T = !!this.#w, this.#x = !!this.#O, this.#f = !!this.#S, this.noDisposeOnSet = !!_, this.noUpdateTTL = !!c, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!g, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
258
153
  if (this.#c !== 0 && !T(this.#c))
259
154
  throw new TypeError("maxSize must be a positive integer if specified");
260
155
  if (!T(this.maxEntrySize))
@@ -270,20 +165,20 @@ var init_index_min = __esm(() => {
270
165
  throw new TypeError("At least one of max, maxSize, or ttl is required");
271
166
  if (!this.ttlAutopurge && !this.#o && !this.#c) {
272
167
  let v = "LRU_CACHE_UNBOUNDED";
273
- H(v) && (I.add(v), P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", v, u2));
168
+ H(v) && (I.add(v), P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", v, u));
274
169
  }
275
170
  }
276
171
  getRemainingTTL(e) {
277
172
  return this.#s.has(e) ? 1 / 0 : 0;
278
173
  }
279
174
  #H() {
280
- let e = new O(this.#o), t2 = new O(this.#o);
281
- this.#d = e, this.#F = t2;
175
+ let e = new O(this.#o), t = new O(this.#o);
176
+ this.#d = e, this.#F = t;
282
177
  let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : undefined;
283
178
  this.#g = i, this.#N = (h, a, o = this.#m.now()) => {
284
- t2[h] = a !== 0 ? o : 0, e[h] = a, s(h, a);
179
+ t[h] = a !== 0 ? o : 0, e[h] = a, s(h, a);
285
180
  }, this.#D = (h) => {
286
- t2[h] = e[h] !== 0 ? this.#m.now() : 0, s(h, e[h]);
181
+ t[h] = e[h] !== 0 ? this.#m.now() : 0, s(h, e[h]);
287
182
  };
288
183
  let s = this.ttlAutopurge ? (h, a) => {
289
184
  if (i?.[h] && (clearTimeout(i[h]), i[h] = undefined), a && a !== 0 && i) {
@@ -295,7 +190,7 @@ var init_index_min = __esm(() => {
295
190
  } : () => {};
296
191
  this.#v = (h, a) => {
297
192
  if (e[a]) {
298
- let o = e[a], p = t2[a];
193
+ let o = e[a], p = t[a];
299
194
  if (!o || !p)
300
195
  return;
301
196
  h.ttl = o, h.start = p, h.now = n || r();
@@ -316,13 +211,13 @@ var init_index_min = __esm(() => {
316
211
  let a = this.#s.get(h);
317
212
  if (a === undefined)
318
213
  return 0;
319
- let o = e[a], p = t2[a];
214
+ let o = e[a], p = t[a];
320
215
  if (!o || !p)
321
216
  return 1 / 0;
322
217
  let m = (n || r()) - p;
323
218
  return o - m;
324
219
  }, this.#p = (h) => {
325
- let a = t2[h], o = e[h];
220
+ let a = t[h], o = e[h];
326
221
  return !!o && !!a && (n || r()) - a > o;
327
222
  };
328
223
  }
@@ -332,45 +227,45 @@ var init_index_min = __esm(() => {
332
227
  #p = () => false;
333
228
  #X() {
334
229
  let e = new O(this.#o);
335
- this.#b = 0, this.#_ = e, this.#R = (t2) => {
336
- this.#b -= e[t2], e[t2] = 0;
337
- }, this.#V = (t2, i, s, n) => {
230
+ this.#b = 0, this.#_ = e, this.#R = (t) => {
231
+ this.#b -= e[t], e[t] = 0;
232
+ }, this.#V = (t, i, s, n) => {
338
233
  if (this.#e(i))
339
234
  return 0;
340
235
  if (!T(s))
341
236
  if (n) {
342
237
  if (typeof n != "function")
343
238
  throw new TypeError("sizeCalculation must be a function");
344
- if (s = n(i, t2), !T(s))
239
+ if (s = n(i, t), !T(s))
345
240
  throw new TypeError("sizeCalculation return invalid (expect positive integer)");
346
241
  } else
347
242
  throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
348
243
  return s;
349
- }, this.#j = (t2, i, s) => {
350
- if (e[t2] = i, this.#c) {
351
- let n = this.#c - e[t2];
244
+ }, this.#j = (t, i, s) => {
245
+ if (e[t] = i, this.#c) {
246
+ let n = this.#c - e[t];
352
247
  for (;this.#b > n; )
353
248
  this.#G(true);
354
249
  }
355
- this.#b += e[t2], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
250
+ this.#b += e[t], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
356
251
  };
357
252
  }
358
253
  #R = (e) => {};
359
- #j = (e, t2, i) => {};
360
- #V = (e, t2, i, s) => {
254
+ #j = (e, t, i) => {};
255
+ #V = (e, t, i, s) => {
361
256
  if (i || s)
362
257
  throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
363
258
  return 0;
364
259
  };
365
260
  *#A({ allowStale: e = this.allowStale } = {}) {
366
261
  if (this.#n)
367
- for (let t2 = this.#h;this.#B(t2) && ((e || !this.#p(t2)) && (yield t2), t2 !== this.#a); )
368
- t2 = this.#u[t2];
262
+ for (let t = this.#h;this.#B(t) && ((e || !this.#p(t)) && (yield t), t !== this.#a); )
263
+ t = this.#u[t];
369
264
  }
370
265
  *#z({ allowStale: e = this.allowStale } = {}) {
371
266
  if (this.#n)
372
- for (let t2 = this.#a;this.#B(t2) && ((e || !this.#p(t2)) && (yield t2), t2 !== this.#h); )
373
- t2 = this.#l[t2];
267
+ for (let t = this.#a;this.#B(t) && ((e || !this.#p(t)) && (yield t), t !== this.#h); )
268
+ t = this.#l[t];
374
269
  }
375
270
  #B(e) {
376
271
  return e !== undefined && this.#s.get(this.#i[e]) === e;
@@ -385,14 +280,14 @@ var init_index_min = __esm(() => {
385
280
  }
386
281
  *keys() {
387
282
  for (let e of this.#A()) {
388
- let t2 = this.#i[e];
389
- t2 !== undefined && !this.#e(this.#t[e]) && (yield t2);
283
+ let t = this.#i[e];
284
+ t !== undefined && !this.#e(this.#t[e]) && (yield t);
390
285
  }
391
286
  }
392
287
  *rkeys() {
393
288
  for (let e of this.#z()) {
394
- let t2 = this.#i[e];
395
- t2 !== undefined && !this.#e(this.#t[e]) && (yield t2);
289
+ let t = this.#i[e];
290
+ t !== undefined && !this.#e(this.#t[e]) && (yield t);
396
291
  }
397
292
  }
398
293
  *values() {
@@ -407,109 +302,109 @@ var init_index_min = __esm(() => {
407
302
  return this.entries();
408
303
  }
409
304
  [Symbol.toStringTag] = "LRUCache";
410
- find(e, t2 = {}) {
305
+ find(e, t = {}) {
411
306
  for (let i of this.#A()) {
412
307
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
413
308
  if (n !== undefined && e(n, this.#i[i], this))
414
- return this.#C(this.#i[i], t2);
309
+ return this.#C(this.#i[i], t);
415
310
  }
416
311
  }
417
- forEach(e, t2 = this) {
312
+ forEach(e, t = this) {
418
313
  for (let i of this.#A()) {
419
314
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
420
- n !== undefined && e.call(t2, n, this.#i[i], this);
315
+ n !== undefined && e.call(t, n, this.#i[i], this);
421
316
  }
422
317
  }
423
- rforEach(e, t2 = this) {
318
+ rforEach(e, t = this) {
424
319
  for (let i of this.#z()) {
425
320
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
426
- n !== undefined && e.call(t2, n, this.#i[i], this);
321
+ n !== undefined && e.call(t, n, this.#i[i], this);
427
322
  }
428
323
  }
429
324
  purgeStale() {
430
325
  let e = false;
431
- for (let t2 of this.#z({ allowStale: true }))
432
- this.#p(t2) && (this.#E(this.#i[t2], "expire"), e = true);
326
+ for (let t of this.#z({ allowStale: true }))
327
+ this.#p(t) && (this.#E(this.#i[t], "expire"), e = true);
433
328
  return e;
434
329
  }
435
330
  info(e) {
436
- let t2 = this.#s.get(e);
437
- if (t2 === undefined)
331
+ let t = this.#s.get(e);
332
+ if (t === undefined)
438
333
  return;
439
- let i = this.#t[t2], s = this.#e(i) ? i.__staleWhileFetching : i;
334
+ let i = this.#t[t], s = this.#e(i) ? i.__staleWhileFetching : i;
440
335
  if (s === undefined)
441
336
  return;
442
337
  let n = { value: s };
443
338
  if (this.#d && this.#F) {
444
- let r = this.#d[t2], h = this.#F[t2];
339
+ let r = this.#d[t], h = this.#F[t];
445
340
  if (r && h) {
446
341
  let a = r - (this.#m.now() - h);
447
342
  n.ttl = a, n.start = Date.now();
448
343
  }
449
344
  }
450
- return this.#_ && (n.size = this.#_[t2]), n;
345
+ return this.#_ && (n.size = this.#_[t]), n;
451
346
  }
452
347
  dump() {
453
348
  let e = [];
454
- for (let t2 of this.#A({ allowStale: true })) {
455
- let i = this.#i[t2], s = this.#t[t2], n = this.#e(s) ? s.__staleWhileFetching : s;
349
+ for (let t of this.#A({ allowStale: true })) {
350
+ let i = this.#i[t], s = this.#t[t], n = this.#e(s) ? s.__staleWhileFetching : s;
456
351
  if (n === undefined || i === undefined)
457
352
  continue;
458
353
  let r = { value: n };
459
354
  if (this.#d && this.#F) {
460
- r.ttl = this.#d[t2];
461
- let h = this.#m.now() - this.#F[t2];
355
+ r.ttl = this.#d[t];
356
+ let h = this.#m.now() - this.#F[t];
462
357
  r.start = Math.floor(Date.now() - h);
463
358
  }
464
- this.#_ && (r.size = this.#_[t2]), e.unshift([i, r]);
359
+ this.#_ && (r.size = this.#_[t]), e.unshift([i, r]);
465
360
  }
466
361
  return e;
467
362
  }
468
363
  load(e) {
469
364
  this.clear();
470
- for (let [t2, i] of e) {
365
+ for (let [t, i] of e) {
471
366
  if (i.start) {
472
367
  let s = Date.now() - i.start;
473
368
  i.start = this.#m.now() - s;
474
369
  }
475
- this.#W(t2, i.value, i);
370
+ this.#W(t, i.value, i);
476
371
  }
477
372
  }
478
- set(e, t2, i = {}) {
373
+ set(e, t, i = {}) {
479
374
  let { status: s = w.hasSubscribers ? {} : undefined } = i;
480
- i.status = s, s && (s.op = "set", s.key = e, t2 !== undefined && (s.value = t2), s.cache = this);
481
- let n = this.#W(e, t2, i);
375
+ i.status = s, s && (s.op = "set", s.key = e, t !== undefined && (s.value = t), s.cache = this);
376
+ let n = this.#W(e, t, i);
482
377
  return s && w.hasSubscribers && w.publish(s), n;
483
378
  }
484
- #W(e, t2, i, s) {
379
+ #W(e, t, i, s) {
485
380
  let { ttl: n = this.ttl, start: r, noDisposeOnSet: h = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: o } = i;
486
- if (t2 === undefined)
381
+ if (t === undefined)
487
382
  return o && (o.set = "deleted"), this.delete(e), this;
488
- let { noUpdateTTL: p = this.noUpdateTTL } = i, m = this.#e(t2);
489
- o && !m && (o.value = t2);
490
- let _ = this.#V(e, t2, i.size || 0, a, o);
383
+ let { noUpdateTTL: p = this.noUpdateTTL } = i, m = this.#e(t);
384
+ o && !m && (o.value = t);
385
+ let _ = this.#V(e, t, i.size || 0, a, o);
491
386
  if (this.maxEntrySize && _ > this.maxEntrySize)
492
387
  return this.#E(e, "set"), o && (o.set = "miss", o.maxEntrySizeExceeded = true), this;
493
388
  let c = this.#n === 0 ? undefined : this.#s.get(e);
494
389
  if (c === undefined)
495
- c = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[c] = e, this.#t[c] = t2, this.#s.set(e, c), this.#l[this.#h] = c, this.#u[c] = this.#h, this.#h = c, this.#n++, this.#j(c, _, o), o && (o.set = "add"), p = false, this.#x && !m && this.#O?.(t2, e, "add");
390
+ c = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[c] = e, this.#t[c] = t, this.#s.set(e, c), this.#l[this.#h] = c, this.#u[c] = this.#h, this.#h = c, this.#n++, this.#j(c, _, o), o && (o.set = "add"), p = false, this.#x && !m && this.#O?.(t, e, "add");
496
391
  else {
497
392
  this.#L(c);
498
393
  let d = this.#t[c];
499
- if (t2 !== d) {
394
+ if (t !== d) {
500
395
  if (!h)
501
396
  if (this.#e(d)) {
502
397
  d !== s && d.__abortController.abort(new Error("replaced"));
503
398
  let { __staleWhileFetching: f } = d;
504
- f !== undefined && f !== t2 && (this.#T && this.#w?.(f, e, "set"), this.#f && this.#r?.push([f, e, "set"]));
399
+ f !== undefined && f !== t && (this.#T && this.#w?.(f, e, "set"), this.#f && this.#r?.push([f, e, "set"]));
505
400
  } else
506
401
  this.#T && this.#w?.(d, e, "set"), this.#f && this.#r?.push([d, e, "set"]);
507
- if (this.#R(c), this.#j(c, _, o), this.#t[c] = t2, !m) {
508
- let f = d && this.#e(d) ? d.__staleWhileFetching : d, y = f === undefined ? "add" : t2 !== f ? "replace" : "update";
509
- o && (o.set = y, f !== undefined && (o.oldValue = f)), this.#x && this.onInsert?.(t2, e, y);
402
+ if (this.#R(c), this.#j(c, _, o), this.#t[c] = t, !m) {
403
+ let f = d && this.#e(d) ? d.__staleWhileFetching : d, y = f === undefined ? "add" : t !== f ? "replace" : "update";
404
+ o && (o.set = y, f !== undefined && (o.oldValue = f)), this.#x && this.onInsert?.(t, e, y);
510
405
  }
511
406
  } else
512
- m || (o && (o.set = "update"), this.#x && this.onInsert?.(t2, e, "update"));
407
+ m || (o && (o.set = "update"), this.#x && this.onInsert?.(t, e, "update"));
513
408
  }
514
409
  if (n !== 0 && !this.#d && this.#H(), this.#d && (p || this.#N(c, n, r), o && this.#v(o, c)), !h && this.#f && this.#r) {
515
410
  let d = this.#r, f;
@@ -530,26 +425,26 @@ var init_index_min = __esm(() => {
530
425
  }
531
426
  } finally {
532
427
  if (this.#f && this.#r) {
533
- let e = this.#r, t2;
534
- for (;t2 = e?.shift(); )
535
- this.#S?.(...t2);
428
+ let e = this.#r, t;
429
+ for (;t = e?.shift(); )
430
+ this.#S?.(...t);
536
431
  }
537
432
  }
538
433
  }
539
434
  #G(e) {
540
- let t2 = this.#a, i = this.#i[t2], s = this.#t[t2], n = this.#e(s);
435
+ let t = this.#a, i = this.#i[t], s = this.#t[t], n = this.#e(s);
541
436
  n && s.__abortController.abort(new Error("evicted"));
542
437
  let r = n ? s.__staleWhileFetching : s;
543
- return (this.#T || this.#f) && r !== undefined && (this.#T && this.#w?.(r, i, "evict"), this.#f && this.#r?.push([r, i, "evict"])), this.#R(t2), this.#g?.[t2] && (clearTimeout(this.#g[t2]), this.#g[t2] = undefined), e && (this.#i[t2] = undefined, this.#t[t2] = undefined, this.#y.push(t2)), this.#n === 1 ? (this.#a = this.#h = 0, this.#y.length = 0) : this.#a = this.#l[t2], this.#s.delete(i), this.#n--, t2;
438
+ return (this.#T || this.#f) && r !== undefined && (this.#T && this.#w?.(r, i, "evict"), this.#f && this.#r?.push([r, i, "evict"])), this.#R(t), this.#g?.[t] && (clearTimeout(this.#g[t]), this.#g[t] = undefined), e && (this.#i[t] = undefined, this.#t[t] = undefined, this.#y.push(t)), this.#n === 1 ? (this.#a = this.#h = 0, this.#y.length = 0) : this.#a = this.#l[t], this.#s.delete(i), this.#n--, t;
544
439
  }
545
- has(e, t2 = {}) {
546
- let { status: i = w.hasSubscribers ? {} : undefined } = t2;
547
- t2.status = i, i && (i.op = "has", i.key = e, i.cache = this);
548
- let s = this.#Y(e, t2);
440
+ has(e, t = {}) {
441
+ let { status: i = w.hasSubscribers ? {} : undefined } = t;
442
+ t.status = i, i && (i.op = "has", i.key = e, i.cache = this);
443
+ let s = this.#Y(e, t);
549
444
  return w.hasSubscribers && w.publish(i), s;
550
445
  }
551
- #Y(e, t2 = {}) {
552
- let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t2, n = this.#s.get(e);
446
+ #Y(e, t = {}) {
447
+ let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t, n = this.#s.get(e);
553
448
  if (n !== undefined) {
554
449
  let r = this.#t[n];
555
450
  if (this.#e(r) && r.__staleWhileFetching === undefined)
@@ -562,14 +457,14 @@ var init_index_min = __esm(() => {
562
457
  s && (s.has = "miss");
563
458
  return false;
564
459
  }
565
- peek(e, t2 = {}) {
566
- let { status: i = D() ? {} : undefined } = t2;
567
- i && (i.op = "peek", i.key = e, i.cache = this), t2.status = i;
568
- let s = this.#J(e, t2);
460
+ peek(e, t = {}) {
461
+ let { status: i = D() ? {} : undefined } = t;
462
+ i && (i.op = "peek", i.key = e, i.cache = this), t.status = i;
463
+ let s = this.#J(e, t);
569
464
  return w.hasSubscribers && w.publish(i), s;
570
465
  }
571
- #J(e, t2) {
572
- let { status: i, allowStale: s = this.allowStale } = t2, n = this.#s.get(e);
466
+ #J(e, t) {
467
+ let { status: i, allowStale: s = this.allowStale } = t, n = this.#s.get(e);
573
468
  if (n === undefined || !s && this.#p(n)) {
574
469
  i && (i.peek = n === undefined ? "miss" : "stale");
575
470
  return;
@@ -577,8 +472,8 @@ var init_index_min = __esm(() => {
577
472
  let r = this.#t[n], h = this.#e(r) ? r.__staleWhileFetching : r;
578
473
  return i && (h !== undefined ? (i.peek = "hit", i.value = h) : i.peek = "miss"), h;
579
474
  }
580
- #P(e, t2, i, s) {
581
- let n = t2 === undefined ? undefined : this.#t[t2];
475
+ #P(e, t, i, s) {
476
+ let n = t === undefined ? undefined : this.#t[t];
582
477
  if (this.#e(n))
583
478
  return n;
584
479
  let r = new AbortController, { signal: h } = i;
@@ -587,11 +482,11 @@ var init_index_min = __esm(() => {
587
482
  let { aborted: l } = r.signal, S = i.ignoreFetchAbort && f !== undefined, F = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && f !== undefined);
588
483
  if (i.status && (l && !y ? (i.status.fetchAborted = true, i.status.fetchError = r.signal.reason, S && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), l && !S && !y)
589
484
  return m(r.signal.reason, F);
590
- let b = c, g = this.#t[t2];
591
- return (g === c || g === undefined && S && y) && (f === undefined ? b.__staleWhileFetching !== undefined ? this.#t[t2] = b.__staleWhileFetching : this.#E(e, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#W(e, f, a.options, b))), f;
485
+ let b = c, g = this.#t[t];
486
+ return (g === c || g === undefined && S && y) && (f === undefined ? b.__staleWhileFetching !== undefined ? this.#t[t] = b.__staleWhileFetching : this.#E(e, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#W(e, f, a.options, b))), f;
592
487
  }, p = (f) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = f), m(f, false)), m = (f, y) => {
593
488
  let { aborted: l } = r.signal, S = l && i.allowStaleOnFetchAbort, F = S || i.allowStaleOnFetchRejection, b = F || i.noDeleteOnFetchRejection, g = c;
594
- if (this.#t[t2] === c && (!b || !y && g.__staleWhileFetching === undefined ? this.#E(e, "fetch") : S || (this.#t[t2] = g.__staleWhileFetching)), F)
489
+ if (this.#t[t] === c && (!b || !y && g.__staleWhileFetching === undefined ? this.#E(e, "fetch") : S || (this.#t[t] = g.__staleWhileFetching)), F)
595
490
  return i.status && g.__staleWhileFetching !== undefined && (i.status.returnedStale = true), g.__staleWhileFetching;
596
491
  if (g.__returned === g)
597
492
  throw f;
@@ -603,22 +498,22 @@ var init_index_min = __esm(() => {
603
498
  };
604
499
  i.status && (i.status.fetchDispatched = true);
605
500
  let c = new Promise(_).then(o, p), d = Object.assign(c, { __abortController: r, __staleWhileFetching: n, __returned: undefined });
606
- return t2 === undefined ? (this.#W(e, d, { ...a.options, status: undefined }), t2 = this.#s.get(e)) : this.#t[t2] = d, d;
501
+ return t === undefined ? (this.#W(e, d, { ...a.options, status: undefined }), t = this.#s.get(e)) : this.#t[t] = d, d;
607
502
  }
608
503
  #e(e) {
609
504
  if (!this.#U)
610
505
  return false;
611
- let t2 = e;
612
- return !!t2 && t2 instanceof Promise && t2.hasOwnProperty("__staleWhileFetching") && t2.__abortController instanceof AbortController;
506
+ let t = e;
507
+ return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof AbortController;
613
508
  }
614
- fetch(e, t2 = {}) {
615
- let i = W.hasSubscribers, { status: s = D() ? {} : undefined } = t2;
616
- t2.status = s, s && t2.context && (s.context = t2.context);
617
- let n = this.#k(e, t2);
509
+ fetch(e, t = {}) {
510
+ let i = W.hasSubscribers, { status: s = D() ? {} : undefined } = t;
511
+ t.status = s, s && t.context && (s.context = t.context);
512
+ let n = this.#k(e, t);
618
513
  return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {})), n;
619
514
  }
620
- async#k(e, t2 = {}) {
621
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: r = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: o = this.sizeCalculation, noUpdateTTL: p = this.noUpdateTTL, noDeleteOnFetchRejection: m = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: _ = this.allowStaleOnFetchRejection, ignoreFetchAbort: c = this.ignoreFetchAbort, allowStaleOnFetchAbort: d = this.allowStaleOnFetchAbort, context: f, forceRefresh: y = false, status: l, signal: S } = t2;
515
+ async#k(e, t = {}) {
516
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: r = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: o = this.sizeCalculation, noUpdateTTL: p = this.noUpdateTTL, noDeleteOnFetchRejection: m = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: _ = this.allowStaleOnFetchRejection, ignoreFetchAbort: c = this.ignoreFetchAbort, allowStaleOnFetchAbort: d = this.allowStaleOnFetchAbort, context: f, forceRefresh: y = false, status: l, signal: S } = t;
622
517
  if (l && (l.op = "fetch", l.key = e, y && (l.forceRefresh = true), l.cache = this), !this.#U)
623
518
  return l && (l.fetch = "get"), this.#C(e, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: l });
624
519
  let F = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: r, noDisposeOnSet: h, size: a, sizeCalculation: o, noUpdateTTL: p, noDeleteOnFetchRejection: m, allowStaleOnFetchRejection: _, allowStaleOnFetchAbort: d, ignoreFetchAbort: c, status: l, signal: S }, b = this.#s.get(e);
@@ -639,29 +534,29 @@ var init_index_min = __esm(() => {
639
534
  return l && (l.fetch = A ? "stale" : "refresh", E && A && (l.returnedStale = true)), E ? z.__staleWhileFetching : z.__returned = z;
640
535
  }
641
536
  }
642
- forceFetch(e, t2 = {}) {
643
- let i = W.hasSubscribers, { status: s = D() ? {} : undefined } = t2;
644
- t2.status = s, s && t2.context && (s.context = t2.context);
645
- let n = this.#K(e, t2);
537
+ forceFetch(e, t = {}) {
538
+ let i = W.hasSubscribers, { status: s = D() ? {} : undefined } = t;
539
+ t.status = s, s && t.context && (s.context = t.context);
540
+ let n = this.#K(e, t);
646
541
  return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {})), n;
647
542
  }
648
- async#K(e, t2 = {}) {
649
- let i = await this.#k(e, t2);
543
+ async#K(e, t = {}) {
544
+ let i = await this.#k(e, t);
650
545
  if (i === undefined)
651
546
  throw new Error("fetch() returned undefined");
652
547
  return i;
653
548
  }
654
- memo(e, t2 = {}) {
655
- let { status: i = w.hasSubscribers ? {} : undefined } = t2;
656
- t2.status = i, i && (i.op = "memo", i.key = e, t2.context && (i.context = t2.context), i.cache = this);
657
- let s = this.#Q(e, t2);
549
+ memo(e, t = {}) {
550
+ let { status: i = w.hasSubscribers ? {} : undefined } = t;
551
+ t.status = i, i && (i.op = "memo", i.key = e, t.context && (i.context = t.context), i.cache = this);
552
+ let s = this.#Q(e, t);
658
553
  return i && (i.value = s), w.hasSubscribers && w.publish(i), s;
659
554
  }
660
- #Q(e, t2 = {}) {
555
+ #Q(e, t = {}) {
661
556
  let i = this.#I;
662
557
  if (!i)
663
558
  throw new Error("no memoMethod provided to constructor");
664
- let { context: s, status: n, forceRefresh: r, ...h } = t2;
559
+ let { context: s, status: n, forceRefresh: r, ...h } = t;
665
560
  n && r && (n.forceRefresh = true);
666
561
  let a = this.#C(e, h), o = r || a === undefined;
667
562
  if (n && (n.memo = o ? "miss" : "hit", o || (n.value = a)), !o)
@@ -669,14 +564,14 @@ var init_index_min = __esm(() => {
669
564
  let p = i(e, a, { options: h, context: s });
670
565
  return n && (n.value = p), this.#W(e, p, h), p;
671
566
  }
672
- get(e, t2 = {}) {
673
- let { status: i = w.hasSubscribers ? {} : undefined } = t2;
674
- t2.status = i, i && (i.op = "get", i.key = e, i.cache = this);
675
- let s = this.#C(e, t2);
567
+ get(e, t = {}) {
568
+ let { status: i = w.hasSubscribers ? {} : undefined } = t;
569
+ t.status = i, i && (i.op = "get", i.key = e, i.cache = this);
570
+ let s = this.#C(e, t);
676
571
  return i && (s !== undefined && (i.value = s), w.hasSubscribers && w.publish(i)), s;
677
572
  }
678
- #C(e, t2 = {}) {
679
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: r } = t2, h = this.#s.get(e);
573
+ #C(e, t = {}) {
574
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: r } = t, h = this.#s.get(e);
680
575
  if (h === undefined) {
681
576
  r && (r.get = "miss");
682
577
  return;
@@ -684,8 +579,8 @@ var init_index_min = __esm(() => {
684
579
  let a = this.#t[h], o = this.#e(a);
685
580
  return r && this.#v(r, h), this.#p(h) ? o ? (r && (r.get = "stale-fetching"), i && a.__staleWhileFetching !== undefined ? (r && (r.returnedStale = true), a.__staleWhileFetching) : undefined) : (n || this.#E(e, "expire"), r && (r.get = "stale"), i ? (r && (r.returnedStale = true), a) : undefined) : (r && (r.get = o ? "fetching" : "hit"), this.#L(h), s && this.#D(h), o ? a.__staleWhileFetching : a);
686
581
  }
687
- #$(e, t2) {
688
- this.#u[t2] = e, this.#l[e] = t2;
582
+ #$(e, t) {
583
+ this.#u[t] = e, this.#l[e] = t;
689
584
  }
690
585
  #L(e) {
691
586
  e !== this.#h && (e === this.#a ? this.#a = this.#l[e] : this.#$(this.#u[e], this.#l[e]), this.#$(this.#h, e), this.#h = e);
@@ -693,18 +588,18 @@ var init_index_min = __esm(() => {
693
588
  delete(e) {
694
589
  return this.#E(e, "delete");
695
590
  }
696
- #E(e, t2) {
697
- w.hasSubscribers && w.publish({ op: "delete", delete: t2, key: e, cache: this });
591
+ #E(e, t) {
592
+ w.hasSubscribers && w.publish({ op: "delete", delete: t, key: e, cache: this });
698
593
  let i = false;
699
594
  if (this.#n !== 0) {
700
595
  let s = this.#s.get(e);
701
596
  if (s !== undefined)
702
597
  if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = undefined), i = true, this.#n === 1)
703
- this.#q(t2);
598
+ this.#q(t);
704
599
  else {
705
600
  this.#R(s);
706
601
  let n = this.#t[s];
707
- if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e, t2), this.#f && this.#r?.push([n, e, t2])), this.#s.delete(e), this.#i[s] = undefined, this.#t[s] = undefined, s === this.#h)
602
+ if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e, t), this.#f && this.#r?.push([n, e, t])), this.#s.delete(e), this.#i[s] = undefined, this.#t[s] = undefined, s === this.#h)
708
603
  this.#h = this.#u[s];
709
604
  else if (s === this.#a)
710
605
  this.#a = this.#l[s];
@@ -728,24 +623,24 @@ var init_index_min = __esm(() => {
728
623
  return this.#q("delete");
729
624
  }
730
625
  #q(e) {
731
- for (let t2 of this.#z({ allowStale: true })) {
732
- let i = this.#t[t2];
626
+ for (let t of this.#z({ allowStale: true })) {
627
+ let i = this.#t[t];
733
628
  if (this.#e(i))
734
629
  i.__abortController.abort(new Error("deleted"));
735
630
  else {
736
- let s = this.#i[t2];
631
+ let s = this.#i[t];
737
632
  this.#T && this.#w?.(i, s, e), this.#f && this.#r?.push([i, s, e]);
738
633
  }
739
634
  }
740
635
  if (this.#s.clear(), this.#t.fill(undefined), this.#i.fill(undefined), this.#d && this.#F) {
741
636
  this.#d.fill(0), this.#F.fill(0);
742
- for (let t2 of this.#g ?? [])
743
- t2 !== undefined && clearTimeout(t2);
637
+ for (let t of this.#g ?? [])
638
+ t !== undefined && clearTimeout(t);
744
639
  this.#g?.fill(undefined);
745
640
  }
746
641
  if (this.#_ && this.#_.fill(0), this.#a = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
747
- let t2 = this.#r, i;
748
- for (;i = t2?.shift(); )
642
+ let t = this.#r, i;
643
+ for (;i = t?.shift(); )
749
644
  this.#S?.(...i);
750
645
  }
751
646
  }
@@ -976,10 +871,6 @@ var init_schema_index = __esm(() => {
976
871
  });
977
872
 
978
873
  // src/core/schema-loader.ts
979
- var exports_schema_loader = {};
980
- __export(exports_schema_loader, {
981
- SchemaLayeredLoader: () => SchemaLayeredLoader
982
- });
983
874
  import { join as join4 } from "path";
984
875
 
985
876
  class SchemaLayeredLoader {
@@ -1352,267 +1243,6 @@ var ENGINE_CAPABILITIES = Object.freeze({
1352
1243
  shell: cap("limited", "interactive", "Dedicated Kibana Dev Tools-style REPL (method/path + JSON body, blank-line submit); read-focused.")
1353
1244
  })
1354
1245
  });
1355
- // src/adapters/error-mapper.ts
1356
- var TRANSPORT_CODES = {
1357
- ECONNREFUSED: "ECONNREFUSED",
1358
- ETIMEDOUT: "ETIMEDOUT",
1359
- ESOCKETTIMEDOUT: "ETIMEDOUT",
1360
- ENOTFOUND: "ENOTFOUND",
1361
- EAI_AGAIN: "ENOTFOUND",
1362
- PROTOCOL_CONNECTION_LOST: "CONNECTION_LOST",
1363
- PROTOCOL_SEQUENCE_TIMEOUT: "ETIMEDOUT",
1364
- ECONNRESET: "CONNECTION_LOST",
1365
- EPIPE: "CONNECTION_LOST",
1366
- ECONNABORTED: "CONNECTION_LOST",
1367
- EHOSTUNREACH: "EHOSTUNREACH",
1368
- ENETUNREACH: "EHOSTUNREACH",
1369
- ENETDOWN: "EHOSTUNREACH"
1370
- };
1371
- function isTransportDriverCode(code) {
1372
- return TLS_CODE_PREFIX.test(code) || TRANSPORT_CODES[code] !== undefined;
1373
- }
1374
- var TLS_CODE_PREFIX = /^(CERT_|SELF_SIGNED_|DEPTH_ZERO_|UNABLE_TO_(?:GET|VERIFY)_|ERR_TLS_|ERR_SSL_)/;
1375
- var MYSQL_CODES = {
1376
- ER_NO_SUCH_TABLE: "TABLE_NOT_FOUND",
1377
- ER_BAD_FIELD_ERROR: "COLUMN_NOT_FOUND",
1378
- ER_PARSE_ERROR: "SQL_SYNTAX_ERROR",
1379
- ER_ACCESS_DENIED_ERROR: "AUTH_FAILED",
1380
- ER_DBACCESS_DENIED_ERROR: "AUTH_FAILED",
1381
- ER_NOT_SUPPORTED_AUTH_MODE: "AUTH_FAILED",
1382
- ER_MUST_CHANGE_PASSWORD_LOGIN: "AUTH_FAILED",
1383
- ER_QUERY_TIMEOUT: "STATEMENT_TIMEOUT",
1384
- ER_STATEMENT_TIMEOUT: "STATEMENT_TIMEOUT",
1385
- ER_CON_COUNT_ERROR: "TOO_MANY_CONNECTIONS",
1386
- ER_SERVER_SHUTDOWN: "CONNECTION_LOST"
1387
- };
1388
- var MYSQL_ERRNOS = {
1389
- 1045: "AUTH_FAILED",
1390
- 1044: "AUTH_FAILED",
1391
- 1054: "COLUMN_NOT_FOUND",
1392
- 1064: "SQL_SYNTAX_ERROR",
1393
- 1146: "TABLE_NOT_FOUND",
1394
- 1251: "AUTH_FAILED",
1395
- 1698: "AUTH_FAILED",
1396
- 1040: "TOO_MANY_CONNECTIONS",
1397
- 1053: "CONNECTION_LOST",
1398
- 2006: "CONNECTION_LOST",
1399
- 2013: "CONNECTION_LOST",
1400
- 1969: "STATEMENT_TIMEOUT",
1401
- 3024: "STATEMENT_TIMEOUT"
1402
- };
1403
- var SQLSTATES = {
1404
- "28000": "AUTH_FAILED",
1405
- "28P01": "AUTH_FAILED",
1406
- "42601": "SQL_SYNTAX_ERROR",
1407
- "42P01": "TABLE_NOT_FOUND",
1408
- "42703": "COLUMN_NOT_FOUND",
1409
- "57014": "STATEMENT_TIMEOUT",
1410
- "08000": "CONNECTION_LOST",
1411
- "08003": "CONNECTION_LOST",
1412
- "08006": "CONNECTION_LOST",
1413
- "08001": "ECONNREFUSED",
1414
- "08004": "CONNECTION_REJECTED",
1415
- "53300": "TOO_MANY_CONNECTIONS",
1416
- "57P01": "CONNECTION_LOST",
1417
- "57P02": "CONNECTION_LOST",
1418
- "57P03": "SERVER_NOT_READY"
1419
- };
1420
- var REDIS_PREFIXES = {
1421
- NOAUTH: "AUTH_FAILED",
1422
- WRONGPASS: "AUTH_FAILED"
1423
- };
1424
- var FALLBACK_PATTERNS = [
1425
- [/connection refused/i, "ECONNREFUSED"],
1426
- [/\bECONNREFUSED\b/, "ECONNREFUSED"],
1427
- [/connect(?:ion)? time(?:d )?out/i, "ETIMEDOUT"],
1428
- [/timeout exceeded/i, "ETIMEDOUT"],
1429
- [/timed out/i, "ETIMEDOUT"],
1430
- [/connection terminated/i, "CONNECTION_LOST"],
1431
- [/server closed the connection/i, "CONNECTION_LOST"],
1432
- [/server has gone away/i, "CONNECTION_LOST"],
1433
- [/lost connection to \S+ server/i, "CONNECTION_LOST"],
1434
- [/getaddrinfo/i, "ENOTFOUND"],
1435
- [/authentication failed/i, "AUTH_FAILED"],
1436
- [/access denied for user/i, "AUTH_FAILED"],
1437
- [/no pg_hba\.conf entry/i, "AUTH_FAILED"],
1438
- [/role\s+".*?"\s+does not exist/i, "AUTH_FAILED"],
1439
- [/password supplied/i, "AUTH_FAILED"]
1440
- ];
1441
- var PG_CANCEL_BY_TIMEOUT = /statement timeout/i;
1442
- function categorize(errCode, errno, errMsg, system) {
1443
- if (errCode) {
1444
- if (TLS_CODE_PREFIX.test(errCode))
1445
- return "TLS_ERROR";
1446
- const known = TRANSPORT_CODES[errCode] ?? MYSQL_CODES[errCode] ?? SQLSTATES[errCode] ?? REDIS_PREFIXES[errCode];
1447
- if (known === "STATEMENT_TIMEOUT" && errCode === "57014" && !PG_CANCEL_BY_TIMEOUT.test(errMsg)) {
1448
- return null;
1449
- }
1450
- if (known)
1451
- return known;
1452
- }
1453
- const isMysqlFamily = system === "mysql" || system === "mariadb";
1454
- if (isMysqlFamily && typeof errno === "number" && MYSQL_ERRNOS[errno]) {
1455
- return MYSQL_ERRNOS[errno];
1456
- }
1457
- const redisPrefix = errMsg.match(/^([A-Z]+)\s/)?.[1];
1458
- if (redisPrefix && REDIS_PREFIXES[redisPrefix])
1459
- return REDIS_PREFIXES[redisPrefix];
1460
- if (errCode || isMysqlFamily && typeof errno === "number")
1461
- return null;
1462
- for (const [pattern, category] of FALLBACK_PATTERNS) {
1463
- if (pattern.test(errMsg))
1464
- return category;
1465
- }
1466
- return null;
1467
- }
1468
- var SYSTEM_FACTS = {
1469
- postgresql: {
1470
- serviceCheck: "systemctl status postgresql",
1471
- defaultPort: "default 5432",
1472
- firewallRule: "allow TCP 5432",
1473
- client: "psql",
1474
- logFile: "postgresql.log"
1475
- },
1476
- mysql: {
1477
- serviceCheck: "systemctl status mysql",
1478
- defaultPort: "default 3306",
1479
- firewallRule: "allow TCP 3306",
1480
- client: "mysql",
1481
- logFile: "mysql.log"
1482
- },
1483
- mariadb: {
1484
- serviceCheck: "systemctl status mariadb",
1485
- defaultPort: "default 3306",
1486
- firewallRule: "allow TCP 3306",
1487
- client: "mariadb",
1488
- logFile: "mariadb.log"
1489
- },
1490
- redis: {
1491
- serviceCheck: "redis-cli ping",
1492
- defaultPort: "default 6379",
1493
- firewallRule: "allow TCP 6379",
1494
- client: "redis-cli",
1495
- logFile: "redis.log"
1496
- }
1497
- };
1498
- function serviceHints(system, options) {
1499
- const facts = SYSTEM_FACTS[system];
1500
- return [
1501
- `Check that the ${system} service is running: ${facts.serviceCheck}`,
1502
- `Verify the port is correct: ${facts.defaultPort}`,
1503
- `Check that ${options.host} is reachable: ping ${options.host} or telnet ${options.host} ${options.port}`
1504
- ];
1505
- }
1506
- function mapError(error, system, options) {
1507
- if (error instanceof ConnectionError)
1508
- return error;
1509
- const err = error;
1510
- const errMsg = String(err?.message || String(error));
1511
- const errCode = String(err?.code || "");
1512
- const errno = err?.errno;
1513
- switch (categorize(errCode, errno, errMsg, system)) {
1514
- case "ECONNREFUSED":
1515
- return new ConnectionError("ECONNREFUSED", `Cannot connect to ${options.host}:${options.port} \u2014 server is not running or not listening on this port`, serviceHints(system, options));
1516
- case "ETIMEDOUT":
1517
- return new ConnectionError("ETIMEDOUT", `Connection timed out (${options.timeout || 5000}ms) \u2014 may be blocked by a firewall or slow network`, [
1518
- `Check firewall rules: ${SYSTEM_FACTS[system].firewallRule}`,
1519
- `Increase timeout: edit .dbcli and add "timeout": 15000`,
1520
- `Verify network connectivity: ping ${options.host} -c 3`
1521
- ]);
1522
- case "CONNECTION_LOST":
1523
- return new ConnectionError("CONNECTION_LOST", `Connection to ${options.host}:${options.port} was lost mid-session \u2014 the server closed it or the network dropped`, [
1524
- "Re-run the command: a dropped connection is often transient",
1525
- `Check whether the server restarted or is cycling: ${SYSTEM_FACTS[system].logFile}`,
1526
- "If it happens on long-running work, look at the server idle/wait timeout"
1527
- ]);
1528
- case "SERVER_NOT_READY":
1529
- return new ConnectionError("SERVER_NOT_READY", `${options.host}:${options.port} is not accepting connections yet \u2014 the server is starting up or recovering`, [
1530
- "Retry shortly: this clears on its own once startup or recovery finishes",
1531
- `Watch progress in the server log: ${SYSTEM_FACTS[system].logFile}`,
1532
- "On a replica, this also appears while it catches up with the primary"
1533
- ]);
1534
- case "CONNECTION_REJECTED":
1535
- return new ConnectionError("CONNECTION_REJECTED", `${options.host}:${options.port} answered but rejected the connection attempt`, [
1536
- "Check the server access rules (pg_hba.conf) for this user, database, and client address",
1537
- "If a pooler (pgbouncer / ProxySQL) sits in front, check its own rules and limits",
1538
- "Check whether the connection limit for this user or database is exhausted"
1539
- ]);
1540
- case "TOO_MANY_CONNECTIONS":
1541
- return new ConnectionError("TOO_MANY_CONNECTIONS", `${options.host}:${options.port} refused the connection \u2014 the server has no connection slots left`, [
1542
- "Wait and retry: the limit is on concurrent connections, not on you",
1543
- system === "postgresql" ? "Inspect usage: SELECT count(*) FROM pg_stat_activity \u2014 compare against max_connections" : 'Inspect usage: SHOW STATUS LIKE "Threads_connected" \u2014 compare against max_connections',
1544
- "Close idle sessions, or raise max_connections if the load is legitimate"
1545
- ]);
1546
- case "EHOSTUNREACH":
1547
- return new ConnectionError("EHOSTUNREACH", `No route to ${options.host} \u2014 the name resolved, but the host or network is unreachable`, [
1548
- "Check that you are on the right network or VPN",
1549
- `Check routing and firewall between here and ${options.host}`,
1550
- `Confirm the address is the one you meant: ${options.host}:${options.port}`
1551
- ]);
1552
- case "TLS_ERROR":
1553
- return new ConnectionError("TLS_ERROR", `TLS handshake failed: ${errMsg}`, [
1554
- 'Point the connection at the right CA bundle: set "caPath" in .dbcli',
1555
- 'For a self-signed certificate in a trusted network, set "rejectUnauthorized": false',
1556
- `Confirm the certificate covers the host you connected to: ${options.host}`
1557
- ]);
1558
- case "ENOTFOUND":
1559
- return new ConnectionError("ENOTFOUND", `Host not found: ${options.host}`, [
1560
- `Check the hostname spelling: ${options.host}`,
1561
- `Verify DNS resolution: nslookup ${options.host}`,
1562
- `If using localhost, try 127.0.0.1 (IPv4 vs IPv6 issue)`
1563
- ]);
1564
- case "AUTH_FAILED":
1565
- return new ConnectionError("AUTH_FAILED", `Authentication failed \u2014 check your username or password`, [
1566
- `Verify credentials: ${SYSTEM_FACTS[system].client} ${system === "postgresql" ? "-U" : "-u"} ${options.user} -h ${options.host}`,
1567
- `Check pg_hba.conf (PostgreSQL) or user privileges (MySQL)`,
1568
- `Re-run dbcli init to update credentials`
1569
- ]);
1570
- case "TABLE_NOT_FOUND": {
1571
- const mysqlMatch = errMsg.match(/Table\s+'(?:[^.']+\.)?([^']+)'/i);
1572
- const pgMatch = errMsg.match(/relation\s+"([^"]+)"/i);
1573
- const tableName = mysqlMatch?.[1] || pgMatch?.[1] || "unknown";
1574
- return new ConnectionError("TABLE_NOT_FOUND", `Table '${tableName}' not found in database '${options.database || "unknown"}'`, [
1575
- "Run `dbcli list` to see available tables",
1576
- "Run `dbcli schema <table>` to confirm the exact name (ORM export names may differ from DB table names)"
1577
- ]);
1578
- }
1579
- case "COLUMN_NOT_FOUND": {
1580
- const mysqlMatch = errMsg.match(/Unknown column\s+'([^']+)'/i);
1581
- const pgMatch = errMsg.match(/column\s+"([^"]+)"\s+does not exist/i);
1582
- const columnName = mysqlMatch?.[1] || pgMatch?.[1] || "unknown";
1583
- return new ConnectionError("COLUMN_NOT_FOUND", `Column '${columnName}' not found`, [
1584
- "Run `dbcli schema <table>` to see the actual column names",
1585
- "Column names are case-sensitive on some databases (PostgreSQL with quoted identifiers)"
1586
- ]);
1587
- }
1588
- case "STATEMENT_TIMEOUT": {
1589
- const limitMs = options.statementTimeout ?? options.timeout;
1590
- return new ConnectionError("STATEMENT_TIMEOUT", `Statement timed out${limitMs ? ` (${limitMs}ms)` : ""} \u2014 the server canceled this query before it finished`, [
1591
- 'Inspect the query plan: dbcli explain "<sql>"',
1592
- "Raise the ceiling for this run: dbcli --statement-timeout <ms> \u2026 (0 removes it)",
1593
- "Narrow the query: add WHERE filters, reduce the LIMIT, or index the scanned columns"
1594
- ], limitMs);
1595
- }
1596
- case "SQL_SYNTAX_ERROR":
1597
- return new ConnectionError("SQL_SYNTAX_ERROR", `SQL syntax error: ${errMsg}`, [
1598
- "Check your SQL syntax near the position reported above",
1599
- "In query-only mode, dbcli auto-appends LIMIT 1000; use --no-limit to disable",
1600
- "For SHOW/DESCRIBE/EXPLAIN statements, LIMIT is not allowed \u2014 these are not auto-limited"
1601
- ]);
1602
- }
1603
- const reportedCode = errCode || (typeof errno === "number" ? String(errno) : "");
1604
- if (reportedCode) {
1605
- return new ConnectionError("UNKNOWN", `Database error (${reportedCode}): ${errMsg}`, [
1606
- "Run `dbcli schema <table>` to confirm the objects referenced by this statement",
1607
- `Look up ${reportedCode} in the ${system} error reference for the exact cause`
1608
- ]);
1609
- }
1610
- return new ConnectionError("UNKNOWN", `Connection failed: ${errMsg}`, [
1611
- `Check connection parameters: host=${options.host}, port=${options.port}, user=${options.user}`,
1612
- `View server logs: ${SYSTEM_FACTS[system].logFile}`,
1613
- `Try connecting directly with the ${SYSTEM_FACTS[system].client} command-line tool`
1614
- ]);
1615
- }
1616
1246
  // resources/lang/en/messages.json
1617
1247
  var messages_default = {
1618
1248
  cli: {
@@ -1800,7 +1430,7 @@ var messages_default = {
1800
1430
  elasticsearch_requires_level: "Elasticsearch {type} operation requires {minimum} permission or higher (current level: {permission})",
1801
1431
  escalated_write_requires_admin: "This statement opens as a read but contains an executable {keyword}. A write hidden inside a read statement requires admin permission (current level: {permission}).",
1802
1432
  multiple_statements_refused: "SQL containing multiple statements is refused below admin permission, because only the first statement determines the permission check. Run each statement separately.",
1803
- unknown_statement_query_only: "Unrecognised SQL statement (current level: query-only). Security policy requires read-write+ for unknown statements. If this is a legitimate read-only statement, please open an issue at https://github.com/CarlLee1983/dbcli/issues.",
1433
+ unknown_statement_query_only: "Unrecognised SQL statement (current level: query-only). Security policy requires admin for unknown statements. If this is a legitimate read-only statement, please open an issue at https://github.com/CarlLee1983/dbcli/issues.",
1804
1434
  permission_denied_reason: "Permission denied: {reason}",
1805
1435
  table_not_found: "Table not found: {table}",
1806
1436
  unsupported_lang: "Language '{lang}' not supported, using English",
@@ -2132,7 +1762,7 @@ var messages_default2 = {
2132
1762
  elasticsearch_requires_level: "Elasticsearch {type} \u64CD\u4F5C\u9700\u8981 {minimum} \u4EE5\u4E0A\u7684\u6B0A\u9650\uFF08\u76EE\u524D\u5C64\u7D1A\uFF1A{permission}\uFF09",
2133
1763
  escalated_write_requires_admin: "\u6B64\u8A9E\u53E5\u8868\u9762\u4E0A\u662F\u8B80\u53D6\uFF0C\u4F46\u5BE6\u969B\u5305\u542B\u53EF\u57F7\u884C\u7684 {keyword}\u3002\u8B80\u53D6\u8A9E\u53E5\u4E2D\u96B1\u85CF\u5BEB\u5165\u64CD\u4F5C\u9700\u8981 admin \u6B0A\u9650\uFF08\u76EE\u524D\u5C64\u7D1A\uFF1A{permission}\uFF09\u3002",
2134
1764
  multiple_statements_refused: "\u4F4E\u65BC admin \u6B0A\u9650\u6642\u62D2\u7D55\u57F7\u884C\u5305\u542B\u591A\u500B\u8A9E\u53E5\u7684 SQL\uFF0C\u56E0\u70BA\u6B0A\u9650\u6AA2\u67E5\u53EA\u6703\u4F9D\u64DA\u7B2C\u4E00\u500B\u8A9E\u53E5\u5224\u65B7\u3002\u8ACB\u5C07\u5404\u8A9E\u53E5\u5206\u958B\u57F7\u884C\u3002",
2135
- unknown_statement_query_only: "\u7121\u6CD5\u8FA8\u8B58\u7684 SQL \u8A9E\u53E5\uFF08\u76EE\u524D\u5C64\u7D1A\uFF1Aquery-only\uFF09\u3002\u5B89\u5168\u653F\u7B56\u8981\u6C42\u672A\u77E5\u8A9E\u53E5\u81F3\u5C11\u9700\u8981 read-write \u4EE5\u4E0A\u6B0A\u9650\u3002\u82E5\u9019\u5176\u5BE6\u662F\u5408\u6CD5\u7684\u552F\u8B80\u8A9E\u53E5\uFF0C\u8ACB\u81F3 https://github.com/CarlLee1983/dbcli/issues \u63D0\u51FA\u8B70\u984C\u3002",
1765
+ unknown_statement_query_only: "\u7121\u6CD5\u8FA8\u8B58\u7684 SQL \u8A9E\u53E5\uFF08\u76EE\u524D\u5C64\u7D1A\uFF1Aquery-only\uFF09\u3002\u5B89\u5168\u653F\u7B56\u8981\u6C42\u672A\u77E5\u8A9E\u53E5\u9700\u8981 admin \u6B0A\u9650\u3002\u82E5\u9019\u5176\u5BE6\u662F\u5408\u6CD5\u7684\u552F\u8B80\u8A9E\u53E5\uFF0C\u8ACB\u81F3 https://github.com/CarlLee1983/dbcli/issues \u63D0\u51FA\u8B70\u984C\u3002",
2136
1766
  permission_denied_reason: "\u6B0A\u9650\u88AB\u62D2\uFF1A{reason}",
2137
1767
  table_not_found: "\u627E\u4E0D\u5230\u8868\u683C\uFF1A{table}",
2138
1768
  unsupported_lang: "\u4E0D\u652F\u63F4\u7684\u8A9E\u8A00 '{lang}'\uFF0C\u4F7F\u7528\u82F1\u6587",
@@ -2528,495 +2158,6 @@ var messageLoader = MessageLoader.getInstance();
2528
2158
  var t = (key) => messageLoader.t(key);
2529
2159
  var t_vars = (key, vars) => messageLoader.interpolate(key, vars);
2530
2160
 
2531
- // src/adapters/sql-adapter-utils.ts
2532
- function queryOnlyBoundaryError(system, error) {
2533
- const detail = error instanceof Error ? error.message : String(error);
2534
- return new ConnectionError("QUERY_ONLY_BOUNDARY_FAILED", t_vars("errors.query_only_boundary_failed", { system, detail }), [
2535
- t_vars("errors.query_only_boundary_verify", { system }),
2536
- t_vars("errors.query_only_boundary_not_executed", {})
2537
- ]);
2538
- }
2539
- function queryOnlyCleanupError(system, error, targetCompleted) {
2540
- const detail = error instanceof Error ? error.message : String(error);
2541
- return new ConnectionError("CONNECTION_LOST", targetCompleted ? t_vars("errors.query_only_cleanup_completed", { system, detail }) : t_vars("errors.query_only_cleanup_uncertain", { system, detail }), [
2542
- targetCompleted ? t_vars("errors.query_only_cleanup_completed_retry", {}) : t_vars("errors.query_only_cleanup_uncertain_retry", {}),
2543
- t_vars("errors.query_only_cleanup_reconnect", {})
2544
- ], undefined, false);
2545
- }
2546
- function requireConnected(connection) {
2547
- if (!connection) {
2548
- throw new ConnectionError("UNKNOWN", "Database connection not established", [
2549
- "Call connect() to establish a connection"
2550
- ]);
2551
- }
2552
- return connection;
2553
- }
2554
- async function withMappedConnectionError(system, options, operation) {
2555
- try {
2556
- return await operation();
2557
- } catch (error) {
2558
- throw mapError(error, system, options);
2559
- }
2560
- }
2561
-
2562
- // src/utils/colors.ts
2563
- var import_picocolors = __toESM(require_picocolors(), 1);
2564
- var colors = {
2565
- success: (text) => import_picocolors.default.green(text),
2566
- error: (text) => import_picocolors.default.red(text),
2567
- warn: (text) => import_picocolors.default.yellow(text),
2568
- info: (text) => import_picocolors.default.blue(text),
2569
- dim: (text) => import_picocolors.default.dim(text),
2570
- bold: (text) => import_picocolors.default.bold(text),
2571
- keyword: (text) => import_picocolors.default.blue(import_picocolors.default.bold(text))
2572
- };
2573
-
2574
- // src/utils/db-version-check.ts
2575
- var MIN_SUPPORTED_VERSIONS = {
2576
- postgresql: "12.0",
2577
- mysql: "8.0",
2578
- mariadb: "10.5",
2579
- elasticsearch: "7.10"
2580
- };
2581
- function parseVersionSegments(version) {
2582
- const match = version.match(/^(\d+(?:\.\d+)*)/);
2583
- if (!match)
2584
- return [];
2585
- return (match[1] ?? "").split(".").map(Number);
2586
- }
2587
- function isMariaDBVersion(versionString) {
2588
- return /mariadb/i.test(versionString);
2589
- }
2590
- function extractMariaDBVersion(versionString) {
2591
- const match = versionString.match(/(\d+\.\d+\.\d+)-MariaDB/i);
2592
- if (match)
2593
- return match[1] ?? versionString;
2594
- const prefixMatch = versionString.match(/^5\.5\.5-(\d+\.\d+\.\d+)/);
2595
- if (prefixMatch)
2596
- return prefixMatch[1] ?? versionString;
2597
- return versionString;
2598
- }
2599
- function compareVersions(a, b) {
2600
- const segA = parseVersionSegments(a);
2601
- const segB = parseVersionSegments(b);
2602
- const len = Math.max(segA.length, segB.length);
2603
- for (let i = 0;i < len; i++) {
2604
- const diff = (segA[i] ?? 0) - (segB[i] ?? 0);
2605
- if (diff !== 0)
2606
- return diff;
2607
- }
2608
- return 0;
2609
- }
2610
- function checkDbVersion(rawVersion, declaredSystem) {
2611
- const isMariaDB = isMariaDBVersion(rawVersion);
2612
- const system = isMariaDB ? "mariadb" : declaredSystem;
2613
- const serverVersion = isMariaDB ? extractMariaDBVersion(rawVersion) : rawVersion;
2614
- const minVersion = MIN_SUPPORTED_VERSIONS[system];
2615
- const supported = compareVersions(serverVersion, minVersion ?? "0") >= 0;
2616
- return {
2617
- serverVersion,
2618
- system,
2619
- supported,
2620
- minVersion: minVersion ?? "0"
2621
- };
2622
- }
2623
- function warnIfUnsupported(result) {
2624
- if (result.supported)
2625
- return;
2626
- const message = t_vars("version.unsupported_warning", {
2627
- system: result.system,
2628
- version: result.serverVersion,
2629
- minVersion: result.minVersion
2630
- });
2631
- process.stderr.write(colors.warn(`\u26A0 ${message}`) + `
2632
- `);
2633
- }
2634
-
2635
- // src/utils/encoding.ts
2636
- var CP1252_REVERSE = {
2637
- 8364: 128,
2638
- 8218: 130,
2639
- 402: 131,
2640
- 8222: 132,
2641
- 8230: 133,
2642
- 8224: 134,
2643
- 8225: 135,
2644
- 710: 136,
2645
- 8240: 137,
2646
- 352: 138,
2647
- 8249: 139,
2648
- 338: 140,
2649
- 381: 142,
2650
- 8216: 145,
2651
- 8217: 146,
2652
- 8220: 147,
2653
- 8221: 148,
2654
- 8226: 149,
2655
- 8211: 150,
2656
- 8212: 151,
2657
- 732: 152,
2658
- 8482: 153,
2659
- 353: 154,
2660
- 8250: 155,
2661
- 339: 156,
2662
- 382: 158,
2663
- 376: 159
2664
- };
2665
- function fixDoubleEncodedUtf8(str) {
2666
- if (!str)
2667
- return str;
2668
- const bytes = [];
2669
- for (const char of str) {
2670
- const code = char.codePointAt(0);
2671
- if (code < 128) {
2672
- bytes.push(code);
2673
- } else if (code <= 255) {
2674
- bytes.push(code);
2675
- } else {
2676
- const cp1252Byte = CP1252_REVERSE[code];
2677
- if (cp1252Byte !== undefined) {
2678
- bytes.push(cp1252Byte);
2679
- } else {
2680
- return str;
2681
- }
2682
- }
2683
- }
2684
- try {
2685
- const decoded = new TextDecoder("utf-8", { fatal: true }).decode(new Uint8Array(bytes));
2686
- if (decoded !== str) {
2687
- return decoded;
2688
- }
2689
- } catch {}
2690
- return str;
2691
- }
2692
-
2693
- // src/adapters/identifier-quote.ts
2694
- function quoteCharFor(dialect) {
2695
- return dialect === "postgresql" || dialect === "sqlite" ? '"' : "`";
2696
- }
2697
- function assertQuotable(name, what) {
2698
- if (name.length === 0) {
2699
- throw new Error(`${what} must not be empty`);
2700
- }
2701
- if (name.includes(String.fromCharCode(0))) {
2702
- throw new Error(`${what} must not contain a NUL character`);
2703
- }
2704
- }
2705
- function quoteIdentifier(name, dialect) {
2706
- assertQuotable(name, "identifier");
2707
- const q = quoteCharFor(dialect);
2708
- return `${q}${name.split(q).join(q + q)}${q}`;
2709
- }
2710
-
2711
- // src/adapters/timeout-policy.ts
2712
- var DEFAULT_CONNECT_TIMEOUT_MS = 5000;
2713
- function resolveTimeoutPolicy(options) {
2714
- return {
2715
- connectMs: options.timeout ?? DEFAULT_CONNECT_TIMEOUT_MS,
2716
- statementMs: options.statementTimeout ?? options.timeout
2717
- };
2718
- }
2719
- function statementTimeoutSql(system, ms) {
2720
- if (system === "mariadb") {
2721
- return `SET SESSION max_statement_time = ${ms / 1000}`;
2722
- }
2723
- return `SET SESSION max_execution_time = ${Math.round(ms)}`;
2724
- }
2725
-
2726
- // src/utils/connection-error-message.ts
2727
- var IS_TRANSPORT_FAILURE = {
2728
- ECONNREFUSED: true,
2729
- ETIMEDOUT: true,
2730
- AUTH_FAILED: true,
2731
- ENOTFOUND: true,
2732
- EHOSTUNREACH: true,
2733
- CONNECTION_LOST: true,
2734
- TOO_MANY_CONNECTIONS: true,
2735
- TLS_ERROR: true,
2736
- SERVER_NOT_READY: true,
2737
- CONNECTION_REJECTED: true,
2738
- STATEMENT_TIMEOUT: false,
2739
- SQL_SYNTAX_ERROR: false,
2740
- TABLE_NOT_FOUND: false,
2741
- COLUMN_NOT_FOUND: false,
2742
- QUERY_ONLY_BOUNDARY_FAILED: false,
2743
- UNKNOWN: false
2744
- };
2745
- function isTransportFailure(error) {
2746
- if (error instanceof ConnectionError)
2747
- return IS_TRANSPORT_FAILURE[error.code];
2748
- const raw = error?.code;
2749
- return typeof raw === "string" && isTransportDriverCode(raw);
2750
- }
2751
-
2752
- // src/adapters/mysql-adapter.ts
2753
- function parseEnumValues(columnType) {
2754
- const match = columnType.match(/^enum\((.+)\)$/i);
2755
- if (!match)
2756
- return;
2757
- return (match[1] ?? "").split(",").map((v) => v.trim().replace(/^'|'$/g, ""));
2758
- }
2759
-
2760
- class MySQLAdapter {
2761
- db = null;
2762
- executionTail = Promise.resolve();
2763
- options;
2764
- system;
2765
- constructor(options) {
2766
- this.options = options;
2767
- this.system = options.system === "mariadb" ? "mariadb" : "mysql";
2768
- if (options.port < 1 || options.port > 65535) {
2769
- throw new Error(`Invalid port number: ${options.port}`);
2770
- }
2771
- }
2772
- async connect() {
2773
- await withMappedConnectionError(this.system, this.options, async () => {
2774
- const timeouts = resolveTimeoutPolicy(this.options);
2775
- const { default: driver } = await import("mysql2/promise");
2776
- this.db = await driver.createConnection({
2777
- host: this.options.host,
2778
- port: this.options.port,
2779
- user: this.options.user,
2780
- password: this.options.password || undefined,
2781
- database: this.options.database,
2782
- charset: "utf8mb4",
2783
- connectTimeout: timeouts.connectMs
2784
- });
2785
- await this.db.execute("SET NAMES utf8mb4");
2786
- if (timeouts.statementMs !== undefined) {
2787
- try {
2788
- await this.db.query(statementTimeoutSql(this.system, timeouts.statementMs));
2789
- } catch {}
2790
- }
2791
- await this.testConnection();
2792
- try {
2793
- const rawVersion = await this.getServerVersion();
2794
- const result = checkDbVersion(rawVersion, this.system);
2795
- warnIfUnsupported(result);
2796
- } catch {}
2797
- });
2798
- }
2799
- async disconnect() {
2800
- try {
2801
- if (this.db) {
2802
- await this.db.end();
2803
- this.db = null;
2804
- }
2805
- } catch {}
2806
- }
2807
- async testConnection() {
2808
- requireConnected(this.db);
2809
- return withMappedConnectionError(this.system, this.options, async () => {
2810
- const result = await this.execute("SELECT 1 as count");
2811
- return result.rows.length > 0;
2812
- });
2813
- }
2814
- async execute(sql, params, options) {
2815
- const db = requireConnected(this.db);
2816
- return withMappedConnectionError(this.system, this.options, async () => {
2817
- const execution = this.executionTail.then(async () => {
2818
- if (options?.sqlMode === "native-read-only") {
2819
- return this.executeReadOnly(db, sql, params);
2820
- }
2821
- const [result] = params ? await db.execute(sql, params) : await db.execute(sql);
2822
- if (Array.isArray(result)) {
2823
- return {
2824
- rows: result,
2825
- affectedRows: result.length
2826
- };
2827
- }
2828
- const header = result;
2829
- return {
2830
- rows: [],
2831
- affectedRows: header.affectedRows || 0,
2832
- lastInsertId: header.insertId
2833
- };
2834
- });
2835
- this.executionTail = execution.then(() => {
2836
- return;
2837
- }, () => {
2838
- return;
2839
- });
2840
- return execution;
2841
- });
2842
- }
2843
- async executeReadOnly(db, sql, params) {
2844
- let primaryError;
2845
- let cleanupError;
2846
- let executionResult;
2847
- let transactionStarted = false;
2848
- try {
2849
- try {
2850
- await db.query("START TRANSACTION READ ONLY");
2851
- transactionStarted = true;
2852
- } catch (error) {
2853
- const mapped = mapError(error, this.system, this.options);
2854
- if (isTransportFailure(mapped))
2855
- throw mapped;
2856
- throw queryOnlyBoundaryError(this.system, error);
2857
- }
2858
- const [result] = params ? await db.execute(sql, params) : await db.execute(sql);
2859
- if (Array.isArray(result)) {
2860
- executionResult = { rows: result, affectedRows: result.length };
2861
- } else {
2862
- const header = result;
2863
- executionResult = {
2864
- rows: [],
2865
- affectedRows: header.affectedRows || 0,
2866
- lastInsertId: header.insertId
2867
- };
2868
- }
2869
- } catch (error) {
2870
- primaryError = error;
2871
- } finally {
2872
- if (transactionStarted) {
2873
- try {
2874
- await db.query("ROLLBACK");
2875
- } catch (error) {
2876
- db.destroy();
2877
- this.db = null;
2878
- cleanupError = error;
2879
- }
2880
- }
2881
- }
2882
- if (cleanupError !== undefined) {
2883
- throw queryOnlyCleanupError(this.system, cleanupError, primaryError === undefined);
2884
- }
2885
- if (primaryError !== undefined)
2886
- throw primaryError;
2887
- return executionResult;
2888
- }
2889
- async getServerVersion() {
2890
- const result = await this.execute("SELECT VERSION() as version");
2891
- return result.rows[0]?.version ?? "unknown";
2892
- }
2893
- async listTables() {
2894
- requireConnected(this.db);
2895
- return withMappedConnectionError(this.system, this.options, async () => {
2896
- const query = `
2897
- SELECT
2898
- t.TABLE_NAME as table_name,
2899
- t.TABLE_ROWS as row_count,
2900
- t.ENGINE as engine,
2901
- t.TABLE_TYPE as table_type,
2902
- COUNT(c.COLUMN_NAME) as column_count
2903
- FROM information_schema.TABLES t
2904
- LEFT JOIN information_schema.COLUMNS c
2905
- ON t.TABLE_SCHEMA = c.TABLE_SCHEMA AND t.TABLE_NAME = c.TABLE_NAME
2906
- WHERE t.TABLE_SCHEMA = DATABASE()
2907
- GROUP BY t.TABLE_NAME, t.TABLE_ROWS, t.ENGINE, t.TABLE_TYPE
2908
- ORDER BY t.TABLE_NAME
2909
- `;
2910
- const result = await this.execute(query);
2911
- return result.rows.map((row) => ({
2912
- name: row.table_name,
2913
- columns: [],
2914
- columnCount: row.column_count,
2915
- rowCount: row.row_count || 0,
2916
- engine: row.engine,
2917
- estimatedRowCount: row.row_count || 0,
2918
- tableType: row.table_type === "VIEW" ? "view" : "table"
2919
- }));
2920
- });
2921
- }
2922
- async getTableSchema(tableName, options) {
2923
- requireConnected(this.db);
2924
- return withMappedConnectionError(this.system, this.options, async () => {
2925
- const columnQuery = `
2926
- SELECT
2927
- COLUMN_NAME as name,
2928
- COLUMN_TYPE as type,
2929
- IS_NULLABLE = 'YES' as nullable,
2930
- COLUMN_DEFAULT as default_value,
2931
- COLUMN_KEY = 'PRI' as is_primary_key,
2932
- EXTRA LIKE '%auto_increment%' as auto_increment,
2933
- COLUMN_COMMENT as comment
2934
- FROM information_schema.COLUMNS
2935
- WHERE TABLE_SCHEMA = DATABASE()
2936
- AND TABLE_NAME = ?
2937
- ORDER BY ORDINAL_POSITION
2938
- `;
2939
- const columnResult = await this.execute(columnQuery, [tableName]);
2940
- const columns = columnResult.rows;
2941
- const fkQuery = `
2942
- SELECT
2943
- rc.CONSTRAINT_NAME as name,
2944
- GROUP_CONCAT(kcu.COLUMN_NAME) as columns,
2945
- rc.REFERENCED_TABLE_NAME as ref_table,
2946
- GROUP_CONCAT(kcu.REFERENCED_COLUMN_NAME) as ref_columns
2947
- FROM information_schema.REFERENTIAL_CONSTRAINTS rc
2948
- JOIN information_schema.KEY_COLUMN_USAGE kcu
2949
- ON rc.CONSTRAINT_NAME = kcu.CONSTRAINT_NAME AND rc.TABLE_NAME = kcu.TABLE_NAME
2950
- WHERE kcu.TABLE_NAME = ? AND rc.CONSTRAINT_SCHEMA = DATABASE()
2951
- GROUP BY rc.CONSTRAINT_NAME, rc.REFERENCED_TABLE_NAME
2952
- `;
2953
- const fkResult = await this.execute(fkQuery, [tableName]);
2954
- const fkResults = fkResult.rows;
2955
- const fkMap = new Map;
2956
- for (const fk of fkResults) {
2957
- const cols = fk.columns.split(",").map((c) => c.trim());
2958
- const refCols = fk.ref_columns.split(",").map((c) => c.trim());
2959
- if (cols.length === 1 && refCols.length === 1) {
2960
- fkMap.set(cols[0], { table: fk.ref_table, column: refCols[0] });
2961
- }
2962
- }
2963
- const primaryKeyColumns = columns.filter((col) => col.is_primary_key).map((col) => col.name);
2964
- const indexQuery = `
2965
- SELECT
2966
- INDEX_NAME as name,
2967
- GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX) as columns,
2968
- NOT NON_UNIQUE as is_unique
2969
- FROM information_schema.STATISTICS
2970
- WHERE TABLE_SCHEMA = DATABASE()
2971
- AND TABLE_NAME = ?
2972
- AND INDEX_NAME != 'PRIMARY'
2973
- GROUP BY INDEX_NAME, NON_UNIQUE
2974
- `;
2975
- const indexResult = await this.execute(indexQuery, [tableName]);
2976
- const indexResults = indexResult.rows;
2977
- const tableMetaQuery = `
2978
- SELECT ENGINE as engine, TABLE_ROWS as estimated_rows
2979
- FROM information_schema.TABLES
2980
- WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?
2981
- `;
2982
- const tableMetaResult = await this.execute(tableMetaQuery, [tableName]);
2983
- const tableMeta = tableMetaResult.rows[0];
2984
- const estimatedRowCount = Math.max(0, tableMeta?.estimated_rows || 0);
2985
- const exactRowCount = options?.exactRowCount === false ? undefined : (await this.execute(`SELECT COUNT(*) as count FROM ${quoteIdentifier(tableName, this.system)}`)).rows[0]?.count;
2986
- const schema = {
2987
- name: tableName,
2988
- columns: columns.map((col) => ({
2989
- name: col.name,
2990
- type: col.type,
2991
- nullable: col.nullable,
2992
- default: col.default_value || undefined,
2993
- primaryKey: col.is_primary_key,
2994
- foreignKey: fkMap.get(col.name),
2995
- autoIncrement: col.auto_increment,
2996
- comment: col.comment ? fixDoubleEncodedUtf8(col.comment) : null,
2997
- enumValues: parseEnumValues(col.type)
2998
- })),
2999
- rowCount: exactRowCount ?? estimatedRowCount,
3000
- engine: tableMeta?.engine || "MySQL",
3001
- primaryKey: primaryKeyColumns,
3002
- foreignKeys: fkResults.map((fk) => ({
3003
- name: fk.name,
3004
- columns: fk.columns.split(",").map((c) => c.trim()),
3005
- refTable: fk.ref_table,
3006
- refColumns: fk.ref_columns.split(",").map((c) => c.trim())
3007
- })),
3008
- indexes: indexResults.map((idx) => ({
3009
- name: idx.name,
3010
- columns: idx.columns.split(",").map((c) => c.trim()),
3011
- unique: idx.is_unique
3012
- })),
3013
- estimatedRowCount
3014
- };
3015
- return schema;
3016
- });
3017
- }
3018
- }
3019
-
3020
2161
  // src/utils/case-fold.ts
3021
2162
  function foldCase(text) {
3022
2163
  const lowered = (text.includes("\u0130") ? text.replaceAll("\u0130", "i") : text).toLowerCase();
@@ -4359,7 +3500,7 @@ function checkPermissionForClassification(classification, permission) {
4359
3500
  allowed: false,
4360
3501
  reason: isUnknown ? t("errors.unknown_statement_query_only") : refusalReason(classification.type, permission),
4361
3502
  classification,
4362
- requiredPermission: isUnknown ? "read-write" : minimumPermissionFor(classification.type)
3503
+ requiredPermission: minimumPermissionFor(classification.type)
4363
3504
  };
4364
3505
  }
4365
3506
  return {
@@ -4444,10 +3585,10 @@ async function suggestTableName(errorMessage, adapter) {
4444
3585
  try {
4445
3586
  const extractedTableName = extractTableNameFromError(errorMessage);
4446
3587
  if (!extractedTableName) {
4447
- const allTables2 = await getAllTablesFromAdapter(adapter);
3588
+ const allTables = await getAllTablesFromAdapter(adapter);
4448
3589
  return {
4449
3590
  suggestions: [],
4450
- tables: allTables2
3591
+ tables: allTables
4451
3592
  };
4452
3593
  }
4453
3594
  const allTables = await getAllTablesFromAdapter(adapter);
@@ -4495,7 +3636,7 @@ function extractTableNameFromError(errorMessage) {
4495
3636
  async function getAllTablesFromAdapter(adapter) {
4496
3637
  try {
4497
3638
  const tables = await adapter.listTables();
4498
- return tables.map((t2) => t2.name);
3639
+ return tables.map((t) => t.name);
4499
3640
  } catch (error) {
4500
3641
  console.warn("Failed to list tables for suggestions:", error);
4501
3642
  return [];
@@ -5519,149 +4660,37 @@ class DataExecutor {
5519
4660
  // src/core/public.ts
5520
4661
  init_schema_loader();
5521
4662
 
5522
- // node_modules/zod/v3/external.js
5523
- var exports_external = {};
5524
- __export(exports_external, {
5525
- void: () => voidType,
5526
- util: () => util,
5527
- unknown: () => unknownType,
5528
- union: () => unionType,
5529
- undefined: () => undefinedType,
5530
- tuple: () => tupleType,
5531
- transformer: () => effectsType,
5532
- symbol: () => symbolType,
5533
- string: () => stringType,
5534
- strictObject: () => strictObjectType,
5535
- setErrorMap: () => setErrorMap,
5536
- set: () => setType,
5537
- record: () => recordType,
5538
- quotelessJson: () => quotelessJson,
5539
- promise: () => promiseType,
5540
- preprocess: () => preprocessType,
5541
- pipeline: () => pipelineType,
5542
- ostring: () => ostring,
5543
- optional: () => optionalType,
5544
- onumber: () => onumber,
5545
- oboolean: () => oboolean,
5546
- objectUtil: () => objectUtil,
5547
- object: () => objectType,
5548
- number: () => numberType,
5549
- nullable: () => nullableType,
5550
- null: () => nullType,
5551
- never: () => neverType,
5552
- nativeEnum: () => nativeEnumType,
5553
- nan: () => nanType,
5554
- map: () => mapType,
5555
- makeIssue: () => makeIssue,
5556
- literal: () => literalType,
5557
- lazy: () => lazyType,
5558
- late: () => late,
5559
- isValid: () => isValid,
5560
- isDirty: () => isDirty,
5561
- isAsync: () => isAsync,
5562
- isAborted: () => isAborted,
5563
- intersection: () => intersectionType,
5564
- instanceof: () => instanceOfType,
5565
- getParsedType: () => getParsedType,
5566
- getErrorMap: () => getErrorMap,
5567
- function: () => functionType,
5568
- enum: () => enumType,
5569
- effect: () => effectsType,
5570
- discriminatedUnion: () => discriminatedUnionType,
5571
- defaultErrorMap: () => en_default,
5572
- datetimeRegex: () => datetimeRegex,
5573
- date: () => dateType,
5574
- custom: () => custom,
5575
- coerce: () => coerce,
5576
- boolean: () => booleanType,
5577
- bigint: () => bigIntType,
5578
- array: () => arrayType,
5579
- any: () => anyType,
5580
- addIssueToContext: () => addIssueToContext,
5581
- ZodVoid: () => ZodVoid,
5582
- ZodUnknown: () => ZodUnknown,
5583
- ZodUnion: () => ZodUnion,
5584
- ZodUndefined: () => ZodUndefined,
5585
- ZodType: () => ZodType,
5586
- ZodTuple: () => ZodTuple,
5587
- ZodTransformer: () => ZodEffects,
5588
- ZodSymbol: () => ZodSymbol,
5589
- ZodString: () => ZodString,
5590
- ZodSet: () => ZodSet,
5591
- ZodSchema: () => ZodType,
5592
- ZodRecord: () => ZodRecord,
5593
- ZodReadonly: () => ZodReadonly,
5594
- ZodPromise: () => ZodPromise,
5595
- ZodPipeline: () => ZodPipeline,
5596
- ZodParsedType: () => ZodParsedType,
5597
- ZodOptional: () => ZodOptional,
5598
- ZodObject: () => ZodObject,
5599
- ZodNumber: () => ZodNumber,
5600
- ZodNullable: () => ZodNullable,
5601
- ZodNull: () => ZodNull,
5602
- ZodNever: () => ZodNever,
5603
- ZodNativeEnum: () => ZodNativeEnum,
5604
- ZodNaN: () => ZodNaN,
5605
- ZodMap: () => ZodMap,
5606
- ZodLiteral: () => ZodLiteral,
5607
- ZodLazy: () => ZodLazy,
5608
- ZodIssueCode: () => ZodIssueCode,
5609
- ZodIntersection: () => ZodIntersection,
5610
- ZodFunction: () => ZodFunction,
5611
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
5612
- ZodError: () => ZodError,
5613
- ZodEnum: () => ZodEnum,
5614
- ZodEffects: () => ZodEffects,
5615
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
5616
- ZodDefault: () => ZodDefault,
5617
- ZodDate: () => ZodDate,
5618
- ZodCatch: () => ZodCatch,
5619
- ZodBranded: () => ZodBranded,
5620
- ZodBoolean: () => ZodBoolean,
5621
- ZodBigInt: () => ZodBigInt,
5622
- ZodArray: () => ZodArray,
5623
- ZodAny: () => ZodAny,
5624
- Schema: () => ZodType,
5625
- ParseStatus: () => ParseStatus,
5626
- OK: () => OK,
5627
- NEVER: () => NEVER,
5628
- INVALID: () => INVALID,
5629
- EMPTY_PATH: () => EMPTY_PATH,
5630
- DIRTY: () => DIRTY,
5631
- BRAND: () => BRAND
5632
- });
5633
-
5634
4663
  // node_modules/zod/v3/helpers/util.js
5635
4664
  var util;
5636
- (function(util2) {
5637
- util2.assertEqual = (_) => {};
4665
+ (function(util) {
4666
+ util.assertEqual = (_) => {};
5638
4667
  function assertIs(_arg) {}
5639
- util2.assertIs = assertIs;
4668
+ util.assertIs = assertIs;
5640
4669
  function assertNever(_x) {
5641
4670
  throw new Error;
5642
4671
  }
5643
- util2.assertNever = assertNever;
5644
- util2.arrayToEnum = (items) => {
4672
+ util.assertNever = assertNever;
4673
+ util.arrayToEnum = (items) => {
5645
4674
  const obj = {};
5646
4675
  for (const item of items) {
5647
4676
  obj[item] = item;
5648
4677
  }
5649
4678
  return obj;
5650
4679
  };
5651
- util2.getValidEnumValues = (obj) => {
5652
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
4680
+ util.getValidEnumValues = (obj) => {
4681
+ const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
5653
4682
  const filtered = {};
5654
4683
  for (const k of validKeys) {
5655
4684
  filtered[k] = obj[k];
5656
4685
  }
5657
- return util2.objectValues(filtered);
4686
+ return util.objectValues(filtered);
5658
4687
  };
5659
- util2.objectValues = (obj) => {
5660
- return util2.objectKeys(obj).map(function(e) {
4688
+ util.objectValues = (obj) => {
4689
+ return util.objectKeys(obj).map(function(e) {
5661
4690
  return obj[e];
5662
4691
  });
5663
4692
  };
5664
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
4693
+ util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
5665
4694
  const keys = [];
5666
4695
  for (const key in object) {
5667
4696
  if (Object.prototype.hasOwnProperty.call(object, key)) {
@@ -5670,19 +4699,19 @@ var util;
5670
4699
  }
5671
4700
  return keys;
5672
4701
  };
5673
- util2.find = (arr, checker) => {
4702
+ util.find = (arr, checker) => {
5674
4703
  for (const item of arr) {
5675
4704
  if (checker(item))
5676
4705
  return item;
5677
4706
  }
5678
4707
  return;
5679
4708
  };
5680
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
4709
+ util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
5681
4710
  function joinValues(array, separator = " | ") {
5682
4711
  return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
5683
4712
  }
5684
- util2.joinValues = joinValues;
5685
- util2.jsonStringifyReplacer = (_, value) => {
4713
+ util.joinValues = joinValues;
4714
+ util.jsonStringifyReplacer = (_, value) => {
5686
4715
  if (typeof value === "bigint") {
5687
4716
  return value.toString();
5688
4717
  }
@@ -5690,8 +4719,8 @@ var util;
5690
4719
  };
5691
4720
  })(util || (util = {}));
5692
4721
  var objectUtil;
5693
- (function(objectUtil2) {
5694
- objectUtil2.mergeShapes = (first, second) => {
4722
+ (function(objectUtil) {
4723
+ objectUtil.mergeShapes = (first, second) => {
5695
4724
  return {
5696
4725
  ...first,
5697
4726
  ...second
@@ -5721,8 +4750,8 @@ var ZodParsedType = util.arrayToEnum([
5721
4750
  "set"
5722
4751
  ]);
5723
4752
  var getParsedType = (data) => {
5724
- const t2 = typeof data;
5725
- switch (t2) {
4753
+ const t = typeof data;
4754
+ switch (t) {
5726
4755
  case "undefined":
5727
4756
  return ZodParsedType.undefined;
5728
4757
  case "string":
@@ -5781,11 +4810,6 @@ var ZodIssueCode = util.arrayToEnum([
5781
4810
  "not_multiple_of",
5782
4811
  "not_finite"
5783
4812
  ]);
5784
- var quotelessJson = (obj) => {
5785
- const json = JSON.stringify(obj, null, 2);
5786
- return json.replace(/"([^"]+)":/g, "$1:");
5787
- };
5788
-
5789
4813
  class ZodError extends Error {
5790
4814
  get errors() {
5791
4815
  return this.issues;
@@ -5986,12 +5010,10 @@ var en_default = errorMap;
5986
5010
 
5987
5011
  // node_modules/zod/v3/errors.js
5988
5012
  var overrideErrorMap = en_default;
5989
- function setErrorMap(map) {
5990
- overrideErrorMap = map;
5991
- }
5992
5013
  function getErrorMap() {
5993
5014
  return overrideErrorMap;
5994
5015
  }
5016
+
5995
5017
  // node_modules/zod/v3/helpers/parseUtil.js
5996
5018
  var makeIssue = (params) => {
5997
5019
  const { data, path, errorMaps, issueData } = params;
@@ -6018,7 +5040,6 @@ var makeIssue = (params) => {
6018
5040
  message: errorMessage
6019
5041
  };
6020
5042
  };
6021
- var EMPTY_PATH = [];
6022
5043
  function addIssueToContext(ctx, issueData) {
6023
5044
  const overrideMap = getErrorMap();
6024
5045
  const issue = makeIssue({
@@ -6098,11 +5119,12 @@ var isAborted = (x) => x.status === "aborted";
6098
5119
  var isDirty = (x) => x.status === "dirty";
6099
5120
  var isValid = (x) => x.status === "valid";
6100
5121
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
5122
+
6101
5123
  // node_modules/zod/v3/helpers/errorUtil.js
6102
5124
  var errorUtil;
6103
- (function(errorUtil2) {
6104
- errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
6105
- errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
5125
+ (function(errorUtil) {
5126
+ errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
5127
+ errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
6106
5128
  })(errorUtil || (errorUtil = {}));
6107
5129
 
6108
5130
  // node_modules/zod/v3/types.js
@@ -6147,12 +5169,12 @@ var handleResult = (ctx, result) => {
6147
5169
  function processCreateParams(params) {
6148
5170
  if (!params)
6149
5171
  return {};
6150
- const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
6151
- if (errorMap2 && (invalid_type_error || required_error)) {
5172
+ const { errorMap, invalid_type_error, required_error, description } = params;
5173
+ if (errorMap && (invalid_type_error || required_error)) {
6152
5174
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
6153
5175
  }
6154
- if (errorMap2)
6155
- return { errorMap: errorMap2, description };
5176
+ if (errorMap)
5177
+ return { errorMap, description };
6156
5178
  const customMap = (iss, ctx) => {
6157
5179
  const { message } = params;
6158
5180
  if (iss.code === "invalid_enum_value") {
@@ -6539,11 +5561,11 @@ class ZodString extends ZodType {
6539
5561
  }
6540
5562
  const parsedType = this._getType(input);
6541
5563
  if (parsedType !== ZodParsedType.string) {
6542
- const ctx2 = this._getOrReturnCtx(input);
6543
- addIssueToContext(ctx2, {
5564
+ const ctx = this._getOrReturnCtx(input);
5565
+ addIssueToContext(ctx, {
6544
5566
  code: ZodIssueCode.invalid_type,
6545
5567
  expected: ZodParsedType.string,
6546
- received: ctx2.parsedType
5568
+ received: ctx.parsedType
6547
5569
  });
6548
5570
  return INVALID;
6549
5571
  }
@@ -7097,11 +6119,11 @@ class ZodNumber extends ZodType {
7097
6119
  }
7098
6120
  const parsedType = this._getType(input);
7099
6121
  if (parsedType !== ZodParsedType.number) {
7100
- const ctx2 = this._getOrReturnCtx(input);
7101
- addIssueToContext(ctx2, {
6122
+ const ctx = this._getOrReturnCtx(input);
6123
+ addIssueToContext(ctx, {
7102
6124
  code: ZodIssueCode.invalid_type,
7103
6125
  expected: ZodParsedType.number,
7104
- received: ctx2.parsedType
6126
+ received: ctx.parsedType
7105
6127
  });
7106
6128
  return INVALID;
7107
6129
  }
@@ -7523,17 +6545,17 @@ class ZodDate extends ZodType {
7523
6545
  }
7524
6546
  const parsedType = this._getType(input);
7525
6547
  if (parsedType !== ZodParsedType.date) {
7526
- const ctx2 = this._getOrReturnCtx(input);
7527
- addIssueToContext(ctx2, {
6548
+ const ctx = this._getOrReturnCtx(input);
6549
+ addIssueToContext(ctx, {
7528
6550
  code: ZodIssueCode.invalid_type,
7529
6551
  expected: ZodParsedType.date,
7530
- received: ctx2.parsedType
6552
+ received: ctx.parsedType
7531
6553
  });
7532
6554
  return INVALID;
7533
6555
  }
7534
6556
  if (Number.isNaN(input.data.getTime())) {
7535
- const ctx2 = this._getOrReturnCtx(input);
7536
- addIssueToContext(ctx2, {
6557
+ const ctx = this._getOrReturnCtx(input);
6558
+ addIssueToContext(ctx, {
7537
6559
  code: ZodIssueCode.invalid_date
7538
6560
  });
7539
6561
  return INVALID;
@@ -7821,8 +6843,8 @@ class ZodArray extends ZodType {
7821
6843
  if (ctx.common.async) {
7822
6844
  return Promise.all([...ctx.data].map((item, i) => {
7823
6845
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
7824
- })).then((result2) => {
7825
- return ParseStatus.mergeArray(status, result2);
6846
+ })).then((result) => {
6847
+ return ParseStatus.mergeArray(status, result);
7826
6848
  });
7827
6849
  }
7828
6850
  const result = [...ctx.data].map((item, i) => {
@@ -7910,11 +6932,11 @@ class ZodObject extends ZodType {
7910
6932
  _parse(input) {
7911
6933
  const parsedType = this._getType(input);
7912
6934
  if (parsedType !== ZodParsedType.object) {
7913
- const ctx2 = this._getOrReturnCtx(input);
7914
- addIssueToContext(ctx2, {
6935
+ const ctx = this._getOrReturnCtx(input);
6936
+ addIssueToContext(ctx, {
7915
6937
  code: ZodIssueCode.invalid_type,
7916
6938
  expected: ZodParsedType.object,
7917
- received: ctx2.parsedType
6939
+ received: ctx.parsedType
7918
6940
  });
7919
6941
  return INVALID;
7920
6942
  }
@@ -8218,7 +7240,7 @@ class ZodUnion extends ZodType {
8218
7240
  ctx.common.issues.push(...dirty.ctx.common.issues);
8219
7241
  return dirty.result;
8220
7242
  }
8221
- const unionErrors = issues.map((issues2) => new ZodError(issues2));
7243
+ const unionErrors = issues.map((issues) => new ZodError(issues));
8222
7244
  addIssueToContext(ctx, {
8223
7245
  code: ZodIssueCode.invalid_union,
8224
7246
  unionErrors
@@ -8658,9 +7680,9 @@ class ZodSet extends ZodType {
8658
7680
  }
8659
7681
  }
8660
7682
  const valueType = this._def.valueType;
8661
- function finalizeSet(elements2) {
7683
+ function finalizeSet(elements) {
8662
7684
  const parsedSet = new Set;
8663
- for (const element of elements2) {
7685
+ for (const element of elements) {
8664
7686
  if (element.status === "aborted")
8665
7687
  return INVALID;
8666
7688
  if (element.status === "dirty")
@@ -8671,7 +7693,7 @@ class ZodSet extends ZodType {
8671
7693
  }
8672
7694
  const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
8673
7695
  if (ctx.common.async) {
8674
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
7696
+ return Promise.all(elements).then((elements) => finalizeSet(elements));
8675
7697
  } else {
8676
7698
  return finalizeSet(elements);
8677
7699
  }
@@ -9024,11 +8046,11 @@ class ZodEffects extends ZodType {
9024
8046
  if (effect.type === "preprocess") {
9025
8047
  const processed = effect.transform(ctx.data, checkCtx);
9026
8048
  if (ctx.common.async) {
9027
- return Promise.resolve(processed).then(async (processed2) => {
8049
+ return Promise.resolve(processed).then(async (processed) => {
9028
8050
  if (status.value === "aborted")
9029
8051
  return INVALID;
9030
8052
  const result = await this._def.schema._parseAsync({
9031
- data: processed2,
8053
+ data: processed,
9032
8054
  path: ctx.path,
9033
8055
  parent: ctx
9034
8056
  });
@@ -9220,10 +8242,10 @@ class ZodCatch extends ZodType {
9220
8242
  }
9221
8243
  });
9222
8244
  if (isAsync(result)) {
9223
- return result.then((result2) => {
8245
+ return result.then((result) => {
9224
8246
  return {
9225
8247
  status: "valid",
9226
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
8248
+ value: result.status === "valid" ? result.value : this._def.catchValue({
9227
8249
  get error() {
9228
8250
  return new ZodError(newCtx.common.issues);
9229
8251
  },
@@ -9372,78 +8394,48 @@ ZodReadonly.create = (type, params) => {
9372
8394
  ...processCreateParams(params)
9373
8395
  });
9374
8396
  };
9375
- function cleanParams(params, data) {
9376
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
9377
- const p2 = typeof p === "string" ? { message: p } : p;
9378
- return p2;
9379
- }
9380
- function custom(check, _params = {}, fatal) {
9381
- if (check)
9382
- return ZodAny.create().superRefine((data, ctx) => {
9383
- const r = check(data);
9384
- if (r instanceof Promise) {
9385
- return r.then((r2) => {
9386
- if (!r2) {
9387
- const params = cleanParams(_params, data);
9388
- const _fatal = params.fatal ?? fatal ?? true;
9389
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
9390
- }
9391
- });
9392
- }
9393
- if (!r) {
9394
- const params = cleanParams(_params, data);
9395
- const _fatal = params.fatal ?? fatal ?? true;
9396
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
9397
- }
9398
- return;
9399
- });
9400
- return ZodAny.create();
9401
- }
9402
8397
  var late = {
9403
8398
  object: ZodObject.lazycreate
9404
8399
  };
9405
8400
  var ZodFirstPartyTypeKind;
9406
- (function(ZodFirstPartyTypeKind2) {
9407
- ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
9408
- ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
9409
- ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
9410
- ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
9411
- ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
9412
- ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
9413
- ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
9414
- ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
9415
- ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
9416
- ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
9417
- ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
9418
- ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
9419
- ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
9420
- ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
9421
- ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
9422
- ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
9423
- ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
9424
- ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
9425
- ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
9426
- ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
9427
- ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
9428
- ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
9429
- ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
9430
- ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
9431
- ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
9432
- ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
9433
- ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
9434
- ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
9435
- ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
9436
- ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
9437
- ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
9438
- ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
9439
- ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
9440
- ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
9441
- ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
9442
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
8401
+ (function(ZodFirstPartyTypeKind) {
8402
+ ZodFirstPartyTypeKind["ZodString"] = "ZodString";
8403
+ ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
8404
+ ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
8405
+ ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
8406
+ ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
8407
+ ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
8408
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
8409
+ ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
8410
+ ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
8411
+ ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
8412
+ ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
8413
+ ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
8414
+ ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
8415
+ ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
8416
+ ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
8417
+ ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
8418
+ ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
8419
+ ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
8420
+ ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
8421
+ ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
8422
+ ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
8423
+ ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
8424
+ ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
8425
+ ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
8426
+ ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
8427
+ ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
8428
+ ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
8429
+ ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
8430
+ ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
8431
+ ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
8432
+ ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
8433
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
8434
+ ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
8435
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
8436
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
8437
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
9443
8438
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
9444
- var instanceOfType = (cls, params = {
9445
- message: `Input not instance of ${cls.name}`
9446
- }) => custom((data) => data instanceof cls, params);
9447
8439
  var stringType = ZodString.create;
9448
8440
  var numberType = ZodNumber.create;
9449
8441
  var nanType = ZodNaN.create;
@@ -9478,56 +8470,42 @@ var optionalType = ZodOptional.create;
9478
8470
  var nullableType = ZodNullable.create;
9479
8471
  var preprocessType = ZodEffects.createWithPreprocess;
9480
8472
  var pipelineType = ZodPipeline.create;
9481
- var ostring = () => stringType().optional();
9482
- var onumber = () => numberType().optional();
9483
- var oboolean = () => booleanType().optional();
9484
- var coerce = {
9485
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
9486
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
9487
- boolean: (arg) => ZodBoolean.create({
9488
- ...arg,
9489
- coerce: true
9490
- }),
9491
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
9492
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
9493
- };
9494
- var NEVER = INVALID;
9495
8473
  // src/utils/validation.ts
9496
- var EnvRefSchema = exports_external.object({
9497
- $env: exports_external.string()
8474
+ var EnvRefSchema = objectType({
8475
+ $env: stringType()
9498
8476
  }).strict();
9499
- var StringOrEnvRef = exports_external.union([exports_external.string().min(1), EnvRefSchema]);
9500
- var NumberOrEnvRef = exports_external.union([exports_external.number().int().min(1).max(65535), EnvRefSchema]);
9501
- var OptStringOrEnvRef = exports_external.union([exports_external.string(), EnvRefSchema]).optional().default("");
9502
- var OptNumberOrEnvRef = exports_external.union([exports_external.number().int(), EnvRefSchema]).optional().default(27017);
8477
+ var StringOrEnvRef = unionType([stringType().min(1), EnvRefSchema]);
8478
+ var NumberOrEnvRef = unionType([numberType().int().min(1).max(65535), EnvRefSchema]);
8479
+ var OptStringOrEnvRef = unionType([stringType(), EnvRefSchema]).optional().default("");
8480
+ var OptNumberOrEnvRef = unionType([numberType().int(), EnvRefSchema]).optional().default(27017);
9503
8481
  var MIN_CONNECTION_TIMEOUT_MS = 100;
9504
8482
  var MAX_CONNECTION_TIMEOUT_MS = 600000;
9505
8483
  var MIN_STATEMENT_TIMEOUT_MS = 0;
9506
8484
  var MAX_STATEMENT_TIMEOUT_MS = 3600000;
9507
8485
  var TimeoutField = {
9508
- timeout: exports_external.number().int().min(MIN_CONNECTION_TIMEOUT_MS).max(MAX_CONNECTION_TIMEOUT_MS).optional(),
9509
- statementTimeout: exports_external.number().int().min(MIN_STATEMENT_TIMEOUT_MS).max(MAX_STATEMENT_TIMEOUT_MS).optional()
8486
+ timeout: numberType().int().min(MIN_CONNECTION_TIMEOUT_MS).max(MAX_CONNECTION_TIMEOUT_MS).optional(),
8487
+ statementTimeout: numberType().int().min(MIN_STATEMENT_TIMEOUT_MS).max(MAX_STATEMENT_TIMEOUT_MS).optional()
9510
8488
  };
9511
- var MongoDBConnectionConfigSchema = exports_external.object({
9512
- system: exports_external.literal("mongodb"),
9513
- uri: exports_external.union([exports_external.string(), EnvRefSchema]).optional(),
8489
+ var MongoDBConnectionConfigSchema = objectType({
8490
+ system: literalType("mongodb"),
8491
+ uri: unionType([stringType(), EnvRefSchema]).optional(),
9514
8492
  host: OptStringOrEnvRef,
9515
8493
  port: OptNumberOrEnvRef,
9516
8494
  user: OptStringOrEnvRef,
9517
8495
  password: OptStringOrEnvRef,
9518
8496
  database: OptStringOrEnvRef,
9519
- authSource: exports_external.union([exports_external.string(), EnvRefSchema]).optional(),
9520
- replicaSet: exports_external.union([exports_external.string(), EnvRefSchema]).optional(),
9521
- tls: exports_external.boolean().optional(),
9522
- srv: exports_external.boolean().optional().default(false),
8497
+ authSource: unionType([stringType(), EnvRefSchema]).optional(),
8498
+ replicaSet: unionType([stringType(), EnvRefSchema]).optional(),
8499
+ tls: booleanType().optional(),
8500
+ srv: booleanType().optional().default(false),
9523
8501
  ...TimeoutField
9524
8502
  });
9525
- var SqlConnectionConfigSchema = exports_external.object({
9526
- system: exports_external.enum(["postgresql", "mysql", "mariadb"]),
8503
+ var SqlConnectionConfigSchema = objectType({
8504
+ system: enumType(["postgresql", "mysql", "mariadb"]),
9527
8505
  host: StringOrEnvRef,
9528
8506
  port: NumberOrEnvRef,
9529
8507
  user: StringOrEnvRef,
9530
- password: exports_external.union([exports_external.string(), EnvRefSchema]).default(""),
8508
+ password: unionType([stringType(), EnvRefSchema]).default(""),
9531
8509
  database: StringOrEnvRef,
9532
8510
  ...TimeoutField
9533
8511
  });
@@ -9546,58 +8524,58 @@ function isSqliteMemoryTarget(value) {
9546
8524
  const query = queryStart === -1 ? "" : withoutScheme.slice(queryStart + 1);
9547
8525
  return new URLSearchParams(query).get("mode")?.toLowerCase() === "memory";
9548
8526
  }
9549
- var SqliteConnectionConfigSchema = exports_external.object({
9550
- system: exports_external.literal("sqlite"),
9551
- file: exports_external.union([exports_external.string().min(1), EnvRefSchema]).superRefine((value, ctx) => {
8527
+ var SqliteConnectionConfigSchema = objectType({
8528
+ system: literalType("sqlite"),
8529
+ file: unionType([stringType().min(1), EnvRefSchema]).superRefine((value, ctx) => {
9552
8530
  if (typeof value === "string" && isSqliteMemoryTarget(value)) {
9553
- ctx.addIssue({ code: exports_external.ZodIssueCode.custom, message: SQLITE_MEMORY_TARGET_MESSAGE });
8531
+ ctx.addIssue({ code: ZodIssueCode.custom, message: SQLITE_MEMORY_TARGET_MESSAGE });
9554
8532
  }
9555
8533
  }),
9556
8534
  host: OptStringOrEnvRef,
9557
- port: exports_external.union([exports_external.number().int(), EnvRefSchema]).optional().default(0),
8535
+ port: unionType([numberType().int(), EnvRefSchema]).optional().default(0),
9558
8536
  user: OptStringOrEnvRef,
9559
- password: exports_external.union([exports_external.string(), EnvRefSchema]).optional().default(""),
8537
+ password: unionType([stringType(), EnvRefSchema]).optional().default(""),
9560
8538
  database: OptStringOrEnvRef,
9561
8539
  ...TimeoutField
9562
8540
  });
9563
- var RedisConnectionConfigSchema = exports_external.object({
9564
- system: exports_external.literal("redis"),
8541
+ var RedisConnectionConfigSchema = objectType({
8542
+ system: literalType("redis"),
9565
8543
  host: StringOrEnvRef,
9566
8544
  port: NumberOrEnvRef,
9567
8545
  user: OptStringOrEnvRef,
9568
- password: exports_external.union([exports_external.string(), EnvRefSchema]).optional().default(""),
8546
+ password: unionType([stringType(), EnvRefSchema]).optional().default(""),
9569
8547
  database: OptStringOrEnvRef,
9570
8548
  ...TimeoutField
9571
8549
  });
9572
- var ElasticsearchConnectionConfigSchema = exports_external.object({
9573
- system: exports_external.literal("elasticsearch"),
9574
- protocol: exports_external.enum(["http", "https"]).optional().default("https"),
8550
+ var ElasticsearchConnectionConfigSchema = objectType({
8551
+ system: literalType("elasticsearch"),
8552
+ protocol: enumType(["http", "https"]).optional().default("https"),
9575
8553
  host: OptStringOrEnvRef,
9576
- port: exports_external.union([exports_external.number().int(), EnvRefSchema]).optional().default(9200),
8554
+ port: unionType([numberType().int(), EnvRefSchema]).optional().default(9200),
9577
8555
  user: OptStringOrEnvRef,
9578
- password: exports_external.union([exports_external.string(), EnvRefSchema]).optional().default(""),
8556
+ password: unionType([stringType(), EnvRefSchema]).optional().default(""),
9579
8557
  database: OptStringOrEnvRef,
9580
- nodes: exports_external.array(exports_external.string()).optional(),
9581
- cloudId: exports_external.union([exports_external.string(), EnvRefSchema]).optional(),
9582
- apiKey: exports_external.union([exports_external.string(), EnvRefSchema]).optional(),
9583
- caPath: exports_external.string().optional(),
9584
- rejectUnauthorized: exports_external.boolean().optional().default(true),
8558
+ nodes: arrayType(stringType()).optional(),
8559
+ cloudId: unionType([stringType(), EnvRefSchema]).optional(),
8560
+ apiKey: unionType([stringType(), EnvRefSchema]).optional(),
8561
+ caPath: stringType().optional(),
8562
+ rejectUnauthorized: booleanType().optional().default(true),
9585
8563
  ...TimeoutField
9586
8564
  });
9587
- var ConnectionConfigSchema = exports_external.union([
8565
+ var ConnectionConfigSchema = unionType([
9588
8566
  SqlConnectionConfigSchema,
9589
8567
  SqliteConnectionConfigSchema,
9590
8568
  MongoDBConnectionConfigSchema,
9591
8569
  RedisConnectionConfigSchema,
9592
8570
  ElasticsearchConnectionConfigSchema
9593
8571
  ]);
9594
- var PermissionSchema = exports_external.enum(["query-only", "read-write", "data-admin", "admin"]).default("query-only");
9595
- var EnvironmentLabelSchema = exports_external.string().trim().transform((value) => value || undefined).optional();
9596
- var MetadataSchema = exports_external.object({
9597
- createdAt: exports_external.string().datetime().optional(),
9598
- version: exports_external.string().default("1.0"),
9599
- schemaLastUpdated: exports_external.string().datetime().optional(),
9600
- schemaTableCount: exports_external.number().int().nonnegative().optional()
8572
+ var PermissionSchema = enumType(["query-only", "read-write", "data-admin", "admin"]).default("query-only");
8573
+ var EnvironmentLabelSchema = stringType().trim().transform((value) => value || undefined).optional();
8574
+ var MetadataSchema = objectType({
8575
+ createdAt: stringType().datetime().optional(),
8576
+ version: stringType().default("1.0"),
8577
+ schemaLastUpdated: stringType().datetime().optional(),
8578
+ schemaTableCount: numberType().int().nonnegative().optional()
9601
8579
  }).optional().default({});
9602
8580
  var BLACKLIST_KEY_ALIASES = {
9603
8581
  indices: "tables",
@@ -9605,35 +8583,35 @@ var BLACKLIST_KEY_ALIASES = {
9605
8583
  fields: "columns",
9606
8584
  keys: "tables"
9607
8585
  };
9608
- var BlacklistConfigSchema = exports_external.object({
9609
- tables: exports_external.array(exports_external.string()).default([]),
9610
- columns: exports_external.record(exports_external.array(exports_external.string())).default({})
8586
+ var BlacklistConfigSchema = objectType({
8587
+ tables: arrayType(stringType()).default([]),
8588
+ columns: recordType(arrayType(stringType())).default({})
9611
8589
  }).passthrough().superRefine((value, ctx) => {
9612
8590
  for (const [wrong, right] of Object.entries(BLACKLIST_KEY_ALIASES)) {
9613
8591
  if (wrong in value) {
9614
8592
  ctx.addIssue({
9615
- code: exports_external.ZodIssueCode.custom,
8593
+ code: ZodIssueCode.custom,
9616
8594
  path: [wrong],
9617
8595
  message: `blacklist.${wrong} is not a setting and would be silently ignored \u2014 did you mean blacklist.${right}?`
9618
8596
  });
9619
8597
  }
9620
8598
  }
9621
8599
  }).transform((value) => ({ tables: value.tables, columns: value.columns })).optional().default({ tables: [], columns: {} });
9622
- var RedisMaskRuleSchema = exports_external.object({
9623
- keyPattern: exports_external.string().min(1),
9624
- fields: exports_external.array(exports_external.string()).optional()
8600
+ var RedisMaskRuleSchema = objectType({
8601
+ keyPattern: stringType().min(1),
8602
+ fields: arrayType(stringType()).optional()
9625
8603
  });
9626
- var RedisConfigSchema = exports_external.object({
9627
- mask: exports_external.array(RedisMaskRuleSchema).default([])
8604
+ var RedisConfigSchema = objectType({
8605
+ mask: arrayType(RedisMaskRuleSchema).default([])
9628
8606
  }).optional();
9629
8607
  var DEFAULT_AUDIT_ROTATION = { max_bytes: 10485760, max_entries: 1e4 };
9630
- var AuditRotationConfigSchema = exports_external.object({
9631
- max_bytes: exports_external.number().int().positive().default(DEFAULT_AUDIT_ROTATION.max_bytes),
9632
- max_entries: exports_external.number().int().positive().default(DEFAULT_AUDIT_ROTATION.max_entries)
8608
+ var AuditRotationConfigSchema = objectType({
8609
+ max_bytes: numberType().int().positive().default(DEFAULT_AUDIT_ROTATION.max_bytes),
8610
+ max_entries: numberType().int().positive().default(DEFAULT_AUDIT_ROTATION.max_entries)
9633
8611
  }).optional().default({ ...DEFAULT_AUDIT_ROTATION });
9634
- var AuditConfigSchema = exports_external.object({
9635
- enabled: exports_external.boolean().default(true),
9636
- strict: exports_external.boolean().default(false),
8612
+ var AuditConfigSchema = objectType({
8613
+ enabled: booleanType().default(true),
8614
+ strict: booleanType().default(false),
9637
8615
  rotation: AuditRotationConfigSchema
9638
8616
  }).refine((audit) => !(audit.strict && !audit.enabled), {
9639
8617
  message: "audit.strict requires audit.enabled: with audit off there is nothing to write, so " + "strict would refuse nothing. Enable audit, or turn strict off.",
@@ -9643,10 +8621,10 @@ var AuditConfigSchema = exports_external.object({
9643
8621
  strict: false,
9644
8622
  rotation: { ...DEFAULT_AUDIT_ROTATION }
9645
8623
  });
9646
- var DbcliConfigSchema = exports_external.object({
8624
+ var DbcliConfigSchema = objectType({
9647
8625
  connection: ConnectionConfigSchema,
9648
8626
  permission: PermissionSchema,
9649
- schema: exports_external.record(exports_external.any()).optional().default({}),
8627
+ schema: recordType(anyType()).optional().default({}),
9650
8628
  metadata: MetadataSchema,
9651
8629
  blacklist: BlacklistConfigSchema,
9652
8630
  audit: AuditConfigSchema,
@@ -9654,41 +8632,41 @@ var DbcliConfigSchema = exports_external.object({
9654
8632
  });
9655
8633
  var SqlNamedConnectionSchema = SqlConnectionConfigSchema.extend({
9656
8634
  permission: PermissionSchema,
9657
- envFile: exports_external.string().optional(),
8635
+ envFile: stringType().optional(),
9658
8636
  environment: EnvironmentLabelSchema
9659
8637
  });
9660
8638
  var SqliteNamedConnectionSchema = SqliteConnectionConfigSchema.extend({
9661
8639
  permission: PermissionSchema,
9662
- envFile: exports_external.string().optional(),
8640
+ envFile: stringType().optional(),
9663
8641
  environment: EnvironmentLabelSchema
9664
8642
  });
9665
8643
  var MongoDBNamedConnectionSchema = MongoDBConnectionConfigSchema.extend({
9666
8644
  permission: PermissionSchema,
9667
- envFile: exports_external.string().optional(),
8645
+ envFile: stringType().optional(),
9668
8646
  environment: EnvironmentLabelSchema
9669
8647
  });
9670
8648
  var RedisNamedConnectionSchema = RedisConnectionConfigSchema.extend({
9671
8649
  permission: PermissionSchema,
9672
- envFile: exports_external.string().optional(),
8650
+ envFile: stringType().optional(),
9673
8651
  environment: EnvironmentLabelSchema
9674
8652
  });
9675
8653
  var ElasticsearchNamedConnectionSchema = ElasticsearchConnectionConfigSchema.extend({
9676
8654
  permission: PermissionSchema,
9677
- envFile: exports_external.string().optional(),
8655
+ envFile: stringType().optional(),
9678
8656
  environment: EnvironmentLabelSchema
9679
8657
  });
9680
- var NamedConnectionUnion = exports_external.union([
8658
+ var NamedConnectionUnion = unionType([
9681
8659
  SqlNamedConnectionSchema,
9682
8660
  SqliteNamedConnectionSchema,
9683
8661
  MongoDBNamedConnectionSchema,
9684
8662
  RedisNamedConnectionSchema,
9685
8663
  ElasticsearchNamedConnectionSchema
9686
8664
  ]);
9687
- var NamedConnectionSchema = exports_external.preprocess((raw, ctx) => {
8665
+ var NamedConnectionSchema = preprocessType((raw, ctx) => {
9688
8666
  if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
9689
8667
  if ("blacklist" in raw) {
9690
8668
  ctx.addIssue({
9691
- code: exports_external.ZodIssueCode.custom,
8669
+ code: ZodIssueCode.custom,
9692
8670
  path: ["blacklist"],
9693
8671
  message: "blacklist is configured once at the top level, not per connection \u2014 a blacklist here " + "would be ignored. Move it to the top-level blacklist."
9694
8672
  });
@@ -9696,14 +8674,14 @@ var NamedConnectionSchema = exports_external.preprocess((raw, ctx) => {
9696
8674
  }
9697
8675
  return raw;
9698
8676
  }, NamedConnectionUnion);
9699
- var DbcliConfigV2Schema = exports_external.object({
9700
- version: exports_external.literal(2),
9701
- default: exports_external.string().min(1),
9702
- connections: exports_external.record(NamedConnectionSchema).refine((conns) => Object.keys(conns).length > 0, {
8677
+ var DbcliConfigV2Schema = objectType({
8678
+ version: literalType(2),
8679
+ default: stringType().min(1),
8680
+ connections: recordType(NamedConnectionSchema).refine((conns) => Object.keys(conns).length > 0, {
9703
8681
  message: "At least one connection is required"
9704
8682
  }),
9705
- schema: exports_external.record(exports_external.any()).optional().default({}),
9706
- schemas: exports_external.record(exports_external.record(exports_external.any())).optional().default({}),
8683
+ schema: recordType(anyType()).optional().default({}),
8684
+ schemas: recordType(recordType(anyType())).optional().default({}),
9707
8685
  metadata: MetadataSchema,
9708
8686
  blacklist: BlacklistConfigSchema,
9709
8687
  audit: AuditConfigSchema,
@@ -9846,16 +8824,16 @@ async function snapshot(path) {
9846
8824
  const file = Bun.file(path);
9847
8825
  return { path, content: await file.exists() ? await file.text() : null };
9848
8826
  }
9849
- async function restore(snapshot2) {
9850
- if (snapshot2.content === null) {
9851
- await unlink(snapshot2.path).catch(() => {
8827
+ async function restore(snapshot) {
8828
+ if (snapshot.content === null) {
8829
+ await unlink(snapshot.path).catch(() => {
9852
8830
  return;
9853
8831
  });
9854
8832
  return;
9855
8833
  }
9856
- const temporary = `${snapshot2.path}.rollback-${process.pid}-${randomUUID()}`;
9857
- await Bun.write(temporary, snapshot2.content);
9858
- await rename(temporary, snapshot2.path);
8834
+ const temporary = `${snapshot.path}.rollback-${process.pid}-${randomUUID()}`;
8835
+ await Bun.write(temporary, snapshot.content);
8836
+ await rename(temporary, snapshot.path);
9859
8837
  }
9860
8838
  async function writeConfigWithIntegrity(storagePath, configContent) {
9861
8839
  await writeProtectedFileWithIntegrity(storagePath, "config.json", configContent, INTEGRITY_FILE);
@@ -9971,8 +8949,8 @@ function isGlobalConfigPath(path) {
9971
8949
  function getProjectStoragePath(projectPath) {
9972
8950
  const normalizedProjectPath = resolve2(projectPath);
9973
8951
  const projectName = basename(normalizedProjectPath) || "project";
9974
- const hash2 = createHash2("sha1").update(normalizedProjectPath).digest("hex").slice(0, 12);
9975
- return join6(getDbcliHomeRoot(), "projects", `${projectName}-${hash2}`);
8952
+ const hash = createHash2("sha1").update(normalizedProjectPath).digest("hex").slice(0, 12);
8953
+ return join6(getDbcliHomeRoot(), "projects", `${projectName}-${hash}`);
9976
8954
  }
9977
8955
  var _bindingCache = new Map;
9978
8956
  function bindingCacheKey(projectPath) {
@@ -10249,8 +9227,8 @@ async function resolvePasswordTarget(projectPath, connectionName) {
10249
9227
  if (connectionName && connectionName !== V1_CONNECTION_NAME) {
10250
9228
  throw new ConfigError(`\u9019\u662F v1 \u8A2D\u5B9A\uFF0C\u53EA\u6709\u4E00\u689D\u9023\u7DDA\uFF0C\u7121\u6CD5\u6307\u5B9A\u9023\u7DDA\u540D\u7A31 '${connectionName}'\u3002` + `\u9700\u8981\u591A\u9023\u7DDA\u8ACB\u5148\u7528 dbcli init --conn-name <name> \u5347\u7D1A\u5230 v2\u3002`);
10251
9229
  }
10252
- const connection2 = raw.connection ?? {};
10253
- const customRef = envRefName(connection2.password);
9230
+ const connection = raw.connection ?? {};
9231
+ const customRef = envRefName(connection.password);
10254
9232
  if (customRef !== undefined && customRef !== V1_VAR_NAME) {
10255
9233
  throw new ConfigError(`\u9019\u500B v1 \u8A2D\u5B9A\u7684\u5BC6\u78BC\u4F86\u81EA\u74B0\u5883\u8B8A\u6578 '${customRef}'\uFF0Cdbcli \u7121\u6CD5\u4EE3\u70BA\u8F2A\u66FF\u3002` + `\u8ACB\u76F4\u63A5\u66F4\u65B0\u8A72\u74B0\u5883\u8B8A\u6578\uFF0C\u6216\u7528 dbcli init --conn-name <name> \u5347\u7D1A\u5230 v2 \u5F8C\u518D\u8F2A\u66FF\u3002`);
10256
9234
  }
@@ -10532,8 +9510,8 @@ var configModule = {
10532
9510
  let schema = (v2Config.schemas ?? {})[resolved.name] ?? v2Config.schema;
10533
9511
  if (options.loadLayeredSchema !== false) {
10534
9512
  try {
10535
- const { SchemaLayeredLoader: SchemaLayeredLoader2 } = await Promise.resolve().then(() => (init_schema_loader(), exports_schema_loader));
10536
- const loader = new SchemaLayeredLoader2(storagePath, {
9513
+ await Promise.resolve().then(() => init_schema_loader());
9514
+ const loader = new SchemaLayeredLoader(storagePath, {
10537
9515
  connectionName: resolved.name
10538
9516
  });
10539
9517
  const { cache, index } = await loader.initialize();
@@ -11341,10 +10319,10 @@ class CapabilityContractError extends Error {
11341
10319
  Object.setPrototypeOf(this, CapabilityContractError.prototype);
11342
10320
  }
11343
10321
  }
11344
- var PermissionSchema2 = exports_external.enum(["query-only", "read-write", "data-admin", "admin"]);
11345
- var EngineSchema = exports_external.enum(DATABASE_SYSTEMS);
11346
- var RiskSchema = exports_external.enum(["readonly", "dry-run", "write", "unknown"]);
11347
- var SideEffectSchema = exports_external.enum([
10322
+ var PermissionSchema2 = enumType(["query-only", "read-write", "data-admin", "admin"]);
10323
+ var EngineSchema = enumType(DATABASE_SYSTEMS);
10324
+ var RiskSchema = enumType(["readonly", "dry-run", "write", "unknown"]);
10325
+ var SideEffectSchema = enumType([
11348
10326
  "readonly",
11349
10327
  "dry-run",
11350
10328
  "local-write",
@@ -11353,42 +10331,42 @@ var SideEffectSchema = exports_external.enum([
11353
10331
  "none"
11354
10332
  ]);
11355
10333
  var CAPABILITY_ID_PATTERN = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/;
11356
- var CapabilityIdSchema = exports_external.string().regex(CAPABILITY_ID_PATTERN, {
10334
+ var CapabilityIdSchema = stringType().regex(CAPABILITY_ID_PATTERN, {
11357
10335
  message: "capability id must be dotted lower-case segments, e.g. schema.read"
11358
10336
  });
11359
10337
  var CAPABILITY_COMMAND_PATTERN = /^[a-z][a-z0-9]*(?: [a-z][a-z0-9]*)*$/;
11360
- var CapabilityCommandSchema = exports_external.string().regex(CAPABILITY_COMMAND_PATTERN, {
10338
+ var CapabilityCommandSchema = stringType().regex(CAPABILITY_COMMAND_PATTERN, {
11361
10339
  message: "capability command must be space-separated lower-case CLI command segments"
11362
10340
  });
11363
- var CapabilitySchema = exports_external.object({
10341
+ var CapabilitySchema = objectType({
11364
10342
  id: CapabilityIdSchema,
11365
- description: exports_external.string().min(1),
10343
+ description: stringType().min(1),
11366
10344
  command: CapabilityCommandSchema,
11367
10345
  risk: RiskSchema,
11368
10346
  sideEffect: SideEffectSchema,
11369
- engines: exports_external.array(EngineSchema),
11370
- limitedEngines: exports_external.array(EngineSchema),
11371
- engineIndependent: exports_external.boolean(),
10347
+ engines: arrayType(EngineSchema),
10348
+ limitedEngines: arrayType(EngineSchema),
10349
+ engineIndependent: booleanType(),
11372
10350
  minimumPermission: PermissionSchema2,
11373
- requiresConnection: exports_external.boolean(),
11374
- mutatesConfiguration: exports_external.boolean(),
11375
- supportsJson: exports_external.boolean(),
11376
- supportsEvidence: exports_external.boolean()
10351
+ requiresConnection: booleanType(),
10352
+ mutatesConfiguration: booleanType(),
10353
+ supportsJson: booleanType(),
10354
+ supportsEvidence: booleanType()
11377
10355
  }).strict();
11378
- var CapabilityCatalogSchema = exports_external.object({
11379
- schemaVersion: exports_external.literal(CAPABILITY_CONTRACT_SCHEMA_VERSION),
11380
- capabilities: exports_external.array(CapabilitySchema)
10356
+ var CapabilityCatalogSchema = objectType({
10357
+ schemaVersion: literalType(CAPABILITY_CONTRACT_SCHEMA_VERSION),
10358
+ capabilities: arrayType(CapabilitySchema)
11381
10359
  }).strict();
11382
- var CheckContextSchema = exports_external.object({
10360
+ var CheckContextSchema = objectType({
11383
10361
  engine: EngineSchema,
11384
10362
  permission: PermissionSchema2,
11385
- connectionName: exports_external.string().max(200).nullable(),
11386
- agentMode: exports_external.boolean()
10363
+ connectionName: stringType().max(200).nullable(),
10364
+ agentMode: booleanType()
11387
10365
  }).strict();
11388
- var CheckResultSchema = exports_external.object({
11389
- id: exports_external.string().min(1),
11390
- status: exports_external.enum(["available", "unavailable", "unknown"]),
11391
- reason: exports_external.enum([
10366
+ var CheckResultSchema = objectType({
10367
+ id: stringType().min(1),
10368
+ status: enumType(["available", "unavailable", "unknown"]),
10369
+ reason: enumType([
11392
10370
  "unknown-capability",
11393
10371
  "context-unavailable",
11394
10372
  "context-unresolvable",
@@ -11397,13 +10375,13 @@ var CheckResultSchema = exports_external.object({
11397
10375
  "permission"
11398
10376
  ]).nullable()
11399
10377
  }).strict();
11400
- var CapabilityCheckReportSchema = exports_external.object({
11401
- schemaVersion: exports_external.literal(CAPABILITY_CONTRACT_SCHEMA_VERSION),
11402
- ok: exports_external.boolean(),
11403
- required: exports_external.array(exports_external.string().min(1)),
10378
+ var CapabilityCheckReportSchema = objectType({
10379
+ schemaVersion: literalType(CAPABILITY_CONTRACT_SCHEMA_VERSION),
10380
+ ok: booleanType(),
10381
+ required: arrayType(stringType().min(1)),
11404
10382
  context: CheckContextSchema.nullable(),
11405
- results: exports_external.array(CheckResultSchema),
11406
- warnings: exports_external.array(exports_external.string())
10383
+ results: arrayType(CheckResultSchema),
10384
+ warnings: arrayType(stringType())
11407
10385
  }).strict();
11408
10386
  function parse(schema, value, what) {
11409
10387
  const result = schema.safeParse(value);
@@ -11438,8 +10416,8 @@ var MAX_BRANCH_STEPS = 6;
11438
10416
  var MAX_BRANCH_COUNT = 8;
11439
10417
 
11440
10418
  // src/core/recovery/envelope-schema.ts
11441
- var recoveryCodeSchema = exports_external.enum(RECOVERY_CODES);
11442
- var recoveryCategorySchema = exports_external.enum([
10419
+ var recoveryCodeSchema = enumType(RECOVERY_CODES);
10420
+ var recoveryCategorySchema = enumType([
11443
10421
  "config",
11444
10422
  "connection",
11445
10423
  "permission",
@@ -11448,30 +10426,30 @@ var recoveryCategorySchema = exports_external.enum([
11448
10426
  "schema-cache",
11449
10427
  "unknown"
11450
10428
  ]);
11451
- var guideRiskSchema = exports_external.enum(["readonly", "dry-run", "write", "unknown"]);
11452
- var branchIdSchema = exports_external.string().min(1).max(64).regex(/^[a-z0-9-]+$/, "branchId must match /^[a-z0-9-]+$/");
11453
- var guideStepSchema = exports_external.object({
11454
- order: exports_external.number().int(),
11455
- command: exports_external.string().min(1),
11456
- rationale: exports_external.string(),
10429
+ var guideRiskSchema = enumType(["readonly", "dry-run", "write", "unknown"]);
10430
+ var branchIdSchema = stringType().min(1).max(64).regex(/^[a-z0-9-]+$/, "branchId must match /^[a-z0-9-]+$/");
10431
+ var guideStepSchema = objectType({
10432
+ order: numberType().int(),
10433
+ command: stringType().min(1),
10434
+ rationale: stringType(),
11457
10435
  risk: guideRiskSchema,
11458
- expects: exports_external.string(),
11459
- snippet: exports_external.string().optional(),
11460
- intent: exports_external.string().optional(),
11461
- interactive: exports_external.boolean().optional(),
11462
- dbWrite: exports_external.boolean().optional(),
11463
- placeholders: exports_external.array(exports_external.string()).optional(),
10436
+ expects: stringType(),
10437
+ snippet: stringType().optional(),
10438
+ intent: stringType().optional(),
10439
+ interactive: booleanType().optional(),
10440
+ dbWrite: booleanType().optional(),
10441
+ placeholders: arrayType(stringType()).optional(),
11464
10442
  branchId: branchIdSchema.optional()
11465
10443
  }).strict();
11466
- var branchPlanSchema = exports_external.object({
11467
- description: exports_external.string().min(1),
11468
- steps: exports_external.array(guideStepSchema).min(1).max(MAX_BRANCH_STEPS)
10444
+ var branchPlanSchema = objectType({
10445
+ description: stringType().min(1),
10446
+ steps: arrayType(guideStepSchema).min(1).max(MAX_BRANCH_STEPS)
11469
10447
  }).strict();
11470
- var branchesSchema = exports_external.record(branchIdSchema, branchPlanSchema).superRefine((map, ctx) => {
10448
+ var branchesSchema = recordType(branchIdSchema, branchPlanSchema).superRefine((map, ctx) => {
11471
10449
  const keys = Object.keys(map);
11472
10450
  if (keys.length > MAX_BRANCH_COUNT) {
11473
10451
  ctx.addIssue({
11474
- code: exports_external.ZodIssueCode.custom,
10452
+ code: ZodIssueCode.custom,
11475
10453
  message: `branches has ${keys.length} entries; cap is ${MAX_BRANCH_COUNT}`
11476
10454
  });
11477
10455
  }
@@ -11479,36 +10457,36 @@ var branchesSchema = exports_external.record(branchIdSchema, branchPlanSchema).s
11479
10457
  for (const step of plan.steps) {
11480
10458
  if (step.branchId !== undefined && step.branchId !== id) {
11481
10459
  ctx.addIssue({
11482
- code: exports_external.ZodIssueCode.custom,
10460
+ code: ZodIssueCode.custom,
11483
10461
  message: `step.branchId '${step.branchId}' does not match enclosing key '${id}'`
11484
10462
  });
11485
10463
  }
11486
10464
  }
11487
10465
  }
11488
10466
  });
11489
- var branchForkSchema = exports_external.object({
11490
- after: exports_external.number().int().min(1),
11491
- branchIds: exports_external.array(branchIdSchema).min(1)
10467
+ var branchForkSchema = objectType({
10468
+ after: numberType().int().min(1),
10469
+ branchIds: arrayType(branchIdSchema).min(1)
11492
10470
  }).strict();
11493
- var recoveryEnvelopeSchema = exports_external.object({
11494
- schemaVersion: exports_external.literal(1),
11495
- generatedAt: exports_external.string().min(1),
11496
- ok: exports_external.literal(false),
11497
- error: exports_external.object({
10471
+ var recoveryEnvelopeSchema = objectType({
10472
+ schemaVersion: literalType(1),
10473
+ generatedAt: stringType().min(1),
10474
+ ok: literalType(false),
10475
+ error: objectType({
11498
10476
  code: recoveryCodeSchema,
11499
10477
  category: recoveryCategorySchema,
11500
- message: exports_external.string(),
11501
- details: exports_external.object({
11502
- table: exports_external.string().optional(),
11503
- columns: exports_external.string().optional(),
11504
- requiredPermission: exports_external.string().optional(),
11505
- connectionCode: exports_external.string().optional(),
11506
- snippet: exports_external.string().optional(),
11507
- intent: exports_external.string().optional(),
11508
- paramName: exports_external.string().optional()
10478
+ message: stringType(),
10479
+ details: objectType({
10480
+ table: stringType().optional(),
10481
+ columns: stringType().optional(),
10482
+ requiredPermission: stringType().optional(),
10483
+ connectionCode: stringType().optional(),
10484
+ snippet: stringType().optional(),
10485
+ intent: stringType().optional(),
10486
+ paramName: stringType().optional()
11509
10487
  }).strict().optional()
11510
10488
  }).strict(),
11511
- recovery: exports_external.array(guideStepSchema),
10489
+ recovery: arrayType(guideStepSchema),
11512
10490
  verify: guideStepSchema.optional(),
11513
10491
  branches: branchesSchema.optional(),
11514
10492
  branchFork: branchForkSchema.optional()
@@ -11517,7 +10495,7 @@ var recoveryEnvelopeSchema = exports_external.object({
11517
10495
  const hasFork = env.branchFork !== undefined;
11518
10496
  if (hasBranches !== hasFork) {
11519
10497
  ctx.addIssue({
11520
- code: exports_external.ZodIssueCode.custom,
10498
+ code: ZodIssueCode.custom,
11521
10499
  message: "branches and branchFork must be set together (or both omitted)"
11522
10500
  });
11523
10501
  return;
@@ -11527,19 +10505,19 @@ var recoveryEnvelopeSchema = exports_external.object({
11527
10505
  const ids = [...env.branchFork.branchIds].sort();
11528
10506
  if (keys.length !== ids.length || keys.some((k, i) => k !== ids[i])) {
11529
10507
  ctx.addIssue({
11530
- code: exports_external.ZodIssueCode.custom,
10508
+ code: ZodIssueCode.custom,
11531
10509
  message: "branchFork.branchIds must equal Object.keys(branches)"
11532
10510
  });
11533
10511
  }
11534
10512
  }
11535
10513
  });
11536
- var savedRecoveryEnvelopeSchema = exports_external.object({
11537
- schemaVersion: exports_external.literal(1),
11538
- id: exports_external.string().optional(),
11539
- audit_ref: exports_external.string().optional(),
11540
- savedAt: exports_external.string().min(1),
11541
- command: exports_external.string(),
11542
- cwd: exports_external.string().min(1),
10514
+ var savedRecoveryEnvelopeSchema = objectType({
10515
+ schemaVersion: literalType(1),
10516
+ id: stringType().optional(),
10517
+ audit_ref: stringType().optional(),
10518
+ savedAt: stringType().min(1),
10519
+ command: stringType(),
10520
+ cwd: stringType().min(1),
11543
10521
  envelope: recoveryEnvelopeSchema
11544
10522
  }).strict();
11545
10523
 
@@ -11557,21 +10535,21 @@ var OPERATION_ID = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/;
11557
10535
  var CODE = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
11558
10536
  var EVIDENCE_ID = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,159}$/;
11559
10537
  var SHA256_DIGEST = /^sha256:[a-f0-9]{64}$/;
11560
- var identifierSchema = exports_external.string().min(1).max(MAX_OPERATION_ENVELOPE_IDENTIFIER_LENGTH);
10538
+ var identifierSchema = stringType().min(1).max(MAX_OPERATION_ENVELOPE_IDENTIFIER_LENGTH);
11561
10539
  var capabilityIdSchema = identifierSchema.regex(CAPABILITY_ID_PATTERN, "capability id must be dotted lower-case segments");
11562
10540
  var codeSchema = identifierSchema.regex(CODE, "code must be an uppercase snake-case identifier");
11563
- var messageSchema = exports_external.string().min(1).max(MAX_MESSAGE_LENGTH);
11564
- var contextSchema = exports_external.object({
11565
- engine: exports_external.enum(DATABASE_SYSTEMS),
11566
- permission: exports_external.enum(["query-only", "read-write", "data-admin", "admin"]),
10541
+ var messageSchema = stringType().min(1).max(MAX_MESSAGE_LENGTH);
10542
+ var contextSchema = objectType({
10543
+ engine: enumType(DATABASE_SYSTEMS),
10544
+ permission: enumType(["query-only", "read-write", "data-admin", "admin"]),
11567
10545
  connectionName: identifierSchema.nullable(),
11568
- agentMode: exports_external.boolean(),
11569
- correlationId: exports_external.string().regex(CORRELATION_ID_PATTERN, "invalid correlation id").optional()
10546
+ agentMode: booleanType(),
10547
+ correlationId: stringType().regex(CORRELATION_ID_PATTERN, "invalid correlation id").optional()
11570
10548
  }).strict();
11571
- var resultSchema = exports_external.object({
10549
+ var resultSchema = objectType({
11572
10550
  id: capabilityIdSchema,
11573
- status: exports_external.enum(["available", "unavailable", "unknown"]),
11574
- reason: exports_external.enum([
10551
+ status: enumType(["available", "unavailable", "unknown"]),
10552
+ reason: enumType([
11575
10553
  "unknown-capability",
11576
10554
  "context-unavailable",
11577
10555
  "context-unresolvable",
@@ -11582,50 +10560,50 @@ var resultSchema = exports_external.object({
11582
10560
  }).strict().superRefine((result, ctx) => {
11583
10561
  if (result.status === "available" && result.reason !== null) {
11584
10562
  ctx.addIssue({
11585
- code: exports_external.ZodIssueCode.custom,
10563
+ code: ZodIssueCode.custom,
11586
10564
  message: "available results require reason null"
11587
10565
  });
11588
10566
  }
11589
10567
  if (result.status === "unknown" && result.reason !== "unknown-capability") {
11590
10568
  ctx.addIssue({
11591
- code: exports_external.ZodIssueCode.custom,
10569
+ code: ZodIssueCode.custom,
11592
10570
  message: "unknown results require reason unknown-capability"
11593
10571
  });
11594
10572
  }
11595
10573
  if (result.status === "unavailable" && (result.reason === null || result.reason === "unknown-capability")) {
11596
10574
  ctx.addIssue({
11597
- code: exports_external.ZodIssueCode.custom,
10575
+ code: ZodIssueCode.custom,
11598
10576
  message: "unavailable results require an availability reason"
11599
10577
  });
11600
10578
  }
11601
10579
  });
11602
- var capabilitiesCheckDataSchema = exports_external.object({
11603
- required: exports_external.array(capabilityIdSchema).min(1).max(MAX_OPERATION_ENVELOPE_ITEMS),
11604
- results: exports_external.array(resultSchema).min(1).max(MAX_OPERATION_ENVELOPE_ITEMS)
10580
+ var capabilitiesCheckDataSchema = objectType({
10581
+ required: arrayType(capabilityIdSchema).min(1).max(MAX_OPERATION_ENVELOPE_ITEMS),
10582
+ results: arrayType(resultSchema).min(1).max(MAX_OPERATION_ENVELOPE_ITEMS)
11605
10583
  }).strict().superRefine((data, ctx) => {
11606
10584
  if (new Set(data.required).size !== data.required.length) {
11607
10585
  ctx.addIssue({
11608
- code: exports_external.ZodIssueCode.custom,
10586
+ code: ZodIssueCode.custom,
11609
10587
  message: "required capability ids must be unique"
11610
10588
  });
11611
10589
  }
11612
10590
  if (data.required.length !== data.results.length || data.required.some((id, index) => data.results[index]?.id !== id)) {
11613
10591
  ctx.addIssue({
11614
- code: exports_external.ZodIssueCode.custom,
10592
+ code: ZodIssueCode.custom,
11615
10593
  message: "results must match required capability ids in order"
11616
10594
  });
11617
10595
  }
11618
10596
  });
11619
- var warningSchema = exports_external.object({
10597
+ var warningSchema = objectType({
11620
10598
  code: codeSchema,
11621
10599
  message: messageSchema
11622
10600
  }).strict();
11623
- var evidenceSchema = exports_external.object({
11624
- kind: exports_external.enum(["receipt", "audit", "verification-artifact"]),
11625
- id: exports_external.string().regex(EVIDENCE_ID, "invalid evidence id"),
11626
- digest: exports_external.string().regex(SHA256_DIGEST, "invalid evidence digest").optional()
10601
+ var evidenceSchema = objectType({
10602
+ kind: enumType(["receipt", "audit", "verification-artifact"]),
10603
+ id: stringType().regex(EVIDENCE_ID, "invalid evidence id"),
10604
+ digest: stringType().regex(SHA256_DIGEST, "invalid evidence digest").optional()
11627
10605
  }).strict();
11628
- var errorSchema = exports_external.object({
10606
+ var errorSchema = objectType({
11629
10607
  code: codeSchema,
11630
10608
  message: messageSchema
11631
10609
  }).strict();
@@ -11638,21 +10616,21 @@ function hasOversizedRecoveryString(value) {
11638
10616
  return false;
11639
10617
  return Object.values(value).some(hasOversizedRecoveryString);
11640
10618
  }
11641
- var operationEnvelopeFieldSchema = exports_external.object({
11642
- schemaVersion: exports_external.literal(OPERATION_ENVELOPE_SCHEMA_VERSION),
11643
- ok: exports_external.boolean(),
11644
- operation: exports_external.enum(["capabilities.check", "capabilities.list"]).refine((value) => value.length <= MAX_OPERATION_ENVELOPE_IDENTIFIER_LENGTH && OPERATION_ID.test(value)),
11645
- status: exports_external.enum(["succeeded", "failed"]),
10619
+ var operationEnvelopeFieldSchema = objectType({
10620
+ schemaVersion: literalType(OPERATION_ENVELOPE_SCHEMA_VERSION),
10621
+ ok: booleanType(),
10622
+ operation: enumType(["capabilities.check", "capabilities.list"]).refine((value) => value.length <= MAX_OPERATION_ENVELOPE_IDENTIFIER_LENGTH && OPERATION_ID.test(value)),
10623
+ status: enumType(["succeeded", "failed"]),
11646
10624
  context: contextSchema.nullable(),
11647
- data: exports_external.union([capabilitiesCheckDataSchema, CapabilityCatalogSchema]).nullable(),
11648
- warnings: exports_external.array(warningSchema).max(MAX_OPERATION_ENVELOPE_ITEMS),
11649
- evidence: exports_external.array(evidenceSchema).max(MAX_EVIDENCE_ITEMS),
10625
+ data: unionType([capabilitiesCheckDataSchema, CapabilityCatalogSchema]).nullable(),
10626
+ warnings: arrayType(warningSchema).max(MAX_OPERATION_ENVELOPE_ITEMS),
10627
+ evidence: arrayType(evidenceSchema).max(MAX_EVIDENCE_ITEMS),
11650
10628
  recovery: recoveryEnvelopeSchema.nullable(),
11651
10629
  error: errorSchema.nullable()
11652
10630
  }).strict().superRefine((envelope, ctx) => {
11653
10631
  if (envelope.ok !== (envelope.status === "succeeded")) {
11654
10632
  ctx.addIssue({
11655
- code: exports_external.ZodIssueCode.custom,
10633
+ code: ZodIssueCode.custom,
11656
10634
  message: 'ok must equal (status === "succeeded")'
11657
10635
  });
11658
10636
  }
@@ -11660,41 +10638,41 @@ var operationEnvelopeFieldSchema = exports_external.object({
11660
10638
  if (envelope.status === "succeeded") {
11661
10639
  if (envelope.error !== null) {
11662
10640
  ctx.addIssue({
11663
- code: exports_external.ZodIssueCode.custom,
10641
+ code: ZodIssueCode.custom,
11664
10642
  message: "successful envelopes require error null"
11665
10643
  });
11666
10644
  }
11667
10645
  if (envelope.data === null) {
11668
10646
  ctx.addIssue({
11669
- code: exports_external.ZodIssueCode.custom,
10647
+ code: ZodIssueCode.custom,
11670
10648
  message: "successful capabilities.check envelopes require data"
11671
10649
  });
11672
10650
  } else if ("results" in envelope.data) {
11673
10651
  if (envelope.data.results.some((result) => result.status !== "available")) {
11674
10652
  ctx.addIssue({
11675
- code: exports_external.ZodIssueCode.custom,
10653
+ code: ZodIssueCode.custom,
11676
10654
  message: "successful capabilities.check results must all be available"
11677
10655
  });
11678
10656
  }
11679
10657
  } else {
11680
10658
  ctx.addIssue({
11681
- code: exports_external.ZodIssueCode.custom,
10659
+ code: ZodIssueCode.custom,
11682
10660
  message: "capabilities.check requires capabilitiesCheckDataSchema shape"
11683
10661
  });
11684
10662
  }
11685
10663
  } else if (envelope.error === null) {
11686
- ctx.addIssue({ code: exports_external.ZodIssueCode.custom, message: "failed envelopes require an error" });
10664
+ ctx.addIssue({ code: ZodIssueCode.custom, message: "failed envelopes require an error" });
11687
10665
  }
11688
10666
  const completedNegative = envelope.error?.code === "CAPABILITY_REQUIREMENTS_UNMET";
11689
10667
  if (envelope.status === "failed" && completedNegative !== (envelope.data !== null)) {
11690
10668
  ctx.addIssue({
11691
- code: exports_external.ZodIssueCode.custom,
10669
+ code: ZodIssueCode.custom,
11692
10670
  message: "only completed negative capability results retain data"
11693
10671
  });
11694
10672
  }
11695
10673
  if (completedNegative && envelope.data !== null && "results" in envelope.data && envelope.data.results.every((result) => result.status === "available")) {
11696
10674
  ctx.addIssue({
11697
- code: exports_external.ZodIssueCode.custom,
10675
+ code: ZodIssueCode.custom,
11698
10676
  message: "completed negative capability results require an unmet result"
11699
10677
  });
11700
10678
  }
@@ -11702,55 +10680,55 @@ var operationEnvelopeFieldSchema = exports_external.object({
11702
10680
  if (envelope.status === "succeeded") {
11703
10681
  if (envelope.context !== null) {
11704
10682
  ctx.addIssue({
11705
- code: exports_external.ZodIssueCode.custom,
10683
+ code: ZodIssueCode.custom,
11706
10684
  message: "successful capabilities.list envelopes require context null"
11707
10685
  });
11708
10686
  }
11709
10687
  if (envelope.warnings.length !== 0) {
11710
10688
  ctx.addIssue({
11711
- code: exports_external.ZodIssueCode.custom,
10689
+ code: ZodIssueCode.custom,
11712
10690
  message: "successful capabilities.list envelopes require warnings empty"
11713
10691
  });
11714
10692
  }
11715
10693
  if (envelope.evidence.length !== 0) {
11716
10694
  ctx.addIssue({
11717
- code: exports_external.ZodIssueCode.custom,
10695
+ code: ZodIssueCode.custom,
11718
10696
  message: "successful capabilities.list envelopes require evidence empty"
11719
10697
  });
11720
10698
  }
11721
10699
  if (envelope.recovery !== null) {
11722
10700
  ctx.addIssue({
11723
- code: exports_external.ZodIssueCode.custom,
10701
+ code: ZodIssueCode.custom,
11724
10702
  message: "successful capabilities.list envelopes require recovery null"
11725
10703
  });
11726
10704
  }
11727
10705
  if (envelope.error !== null) {
11728
10706
  ctx.addIssue({
11729
- code: exports_external.ZodIssueCode.custom,
10707
+ code: ZodIssueCode.custom,
11730
10708
  message: "successful envelopes require error null"
11731
10709
  });
11732
10710
  }
11733
10711
  if (envelope.data === null) {
11734
10712
  ctx.addIssue({
11735
- code: exports_external.ZodIssueCode.custom,
10713
+ code: ZodIssueCode.custom,
11736
10714
  message: "successful capabilities.list envelopes require data"
11737
10715
  });
11738
10716
  } else if (!("capabilities" in envelope.data)) {
11739
10717
  ctx.addIssue({
11740
- code: exports_external.ZodIssueCode.custom,
10718
+ code: ZodIssueCode.custom,
11741
10719
  message: "capabilities.list requires CapabilityCatalogSchema shape"
11742
10720
  });
11743
10721
  }
11744
10722
  } else {
11745
10723
  if (envelope.error === null) {
11746
10724
  ctx.addIssue({
11747
- code: exports_external.ZodIssueCode.custom,
10725
+ code: ZodIssueCode.custom,
11748
10726
  message: "failed envelopes require an error"
11749
10727
  });
11750
10728
  }
11751
10729
  if (envelope.data !== null) {
11752
10730
  ctx.addIssue({
11753
- code: exports_external.ZodIssueCode.custom,
10731
+ code: ZodIssueCode.custom,
11754
10732
  message: "failed capabilities.list envelopes require data null"
11755
10733
  });
11756
10734
  }
@@ -11759,13 +10737,13 @@ var operationEnvelopeFieldSchema = exports_external.object({
11759
10737
  if (envelope.recovery !== null) {
11760
10738
  if (envelope.error === null || envelope.recovery.error.code !== envelope.error.code || envelope.recovery.error.message !== envelope.error.message) {
11761
10739
  ctx.addIssue({
11762
- code: exports_external.ZodIssueCode.custom,
10740
+ code: ZodIssueCode.custom,
11763
10741
  message: "recovery error code and message must match the envelope error"
11764
10742
  });
11765
10743
  }
11766
10744
  if (hasOversizedRecoveryString(envelope.recovery)) {
11767
10745
  ctx.addIssue({
11768
- code: exports_external.ZodIssueCode.custom,
10746
+ code: ZodIssueCode.custom,
11769
10747
  message: `recovery strings must be at most ${MAX_MESSAGE_LENGTH} characters`
11770
10748
  });
11771
10749
  }
@@ -11933,11 +10911,11 @@ class BlacklistValidator {
11933
10911
  return;
11934
10912
  }
11935
10913
  if (this.manager.canOverrideBlacklist()) {
11936
- const message2 = t_vars("warnings.blacklist_override_used", {
10914
+ const message = t_vars("warnings.blacklist_override_used", {
11937
10915
  operation,
11938
10916
  table: tables.join(", ")
11939
10917
  });
11940
- console.error(message2);
10918
+ console.error(message);
11941
10919
  return;
11942
10920
  }
11943
10921
  const blocked = tables.filter((table) => this.manager.isTableBlacklisted(table));
@@ -12203,44 +11181,44 @@ class BlacklistValidator {
12203
11181
  // src/core/public.ts
12204
11182
  var readConfig = (path, connectionName) => configModule.read(path, connectionName);
12205
11183
  export {
12206
- writeV2Config,
12207
- writeProjectBinding,
12208
- upsertConnection,
12209
- setDefaultConnection,
12210
- setConnectionPassword,
12211
- resolvePasswordTarget,
12212
- resolveConnection,
12213
- resolveConfigStoragePath,
12214
- removeConnection,
12215
- readV2Config,
12216
- readConfig,
12217
- parseRequirements,
12218
- parseOperationEnvelope,
12219
- parseCapabilityCheckReport,
12220
- parseCapabilityCatalog,
12221
- migrateV1ToV2,
12222
- loadConnectionEnv,
12223
- listConnections,
12224
- listCapabilityIds,
12225
- isGlobalConfigPath,
12226
- getProjectStoragePath,
12227
- getGlobalConfigPath,
12228
- getDbcliConfigHome,
12229
- findCapability,
12230
- envVarNameFor,
12231
- detectConfigVersion,
12232
- checkCapabilities,
12233
- buildCapabilityCatalog,
12234
- SchemaLayeredLoader,
12235
- QueryExecutor,
12236
- OPERATION_ENVELOPE_SCHEMA_VERSION,
12237
- DataExecutor,
12238
- ConnectionError,
12239
- CapabilityRequirementError,
12240
- CapabilityContractError,
12241
- CAPABILITY_CONTRACT_SCHEMA_VERSION,
12242
- CAPABILITIES,
12243
- BlacklistValidator,
11184
+ BlacklistError,
12244
11185
  BlacklistManager,
12245
- BlacklistError
11186
+ BlacklistValidator,
11187
+ CAPABILITIES,
11188
+ CAPABILITY_CONTRACT_SCHEMA_VERSION,
11189
+ CapabilityContractError,
11190
+ CapabilityRequirementError,
11191
+ ConnectionError,
11192
+ DataExecutor,
11193
+ OPERATION_ENVELOPE_SCHEMA_VERSION,
11194
+ QueryExecutor,
11195
+ SchemaLayeredLoader,
11196
+ buildCapabilityCatalog,
11197
+ checkCapabilities,
11198
+ detectConfigVersion,
11199
+ envVarNameFor,
11200
+ findCapability,
11201
+ getDbcliConfigHome,
11202
+ getGlobalConfigPath,
11203
+ getProjectStoragePath,
11204
+ isGlobalConfigPath,
11205
+ listCapabilityIds,
11206
+ listConnections,
11207
+ loadConnectionEnv,
11208
+ migrateV1ToV2,
11209
+ parseCapabilityCatalog,
11210
+ parseCapabilityCheckReport,
11211
+ parseOperationEnvelope,
11212
+ parseRequirements,
11213
+ readConfig,
11214
+ readV2Config,
11215
+ removeConnection,
11216
+ resolveConfigStoragePath,
11217
+ resolveConnection,
11218
+ resolvePasswordTarget,
11219
+ setConnectionPassword,
11220
+ setDefaultConnection,
11221
+ upsertConnection,
11222
+ writeProjectBinding,
11223
+ writeV2Config
12246
11224
  };