@basestream/cli 0.2.3 → 0.2.4

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +140 -3811
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1,42 +1,13 @@
1
1
  #!/usr/bin/env node
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
4
  var __esm = (fn, res) => function __init() {
15
5
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
6
  };
17
- var __commonJS = (cb, mod) => function __require2() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
- };
20
7
  var __export = (target, all) => {
21
8
  for (var name in all)
22
9
  __defProp(target, name, { get: all[name], enumerable: true });
23
10
  };
24
- var __copyProps = (to, from, except, desc) => {
25
- if (from && typeof from === "object" || typeof from === "function") {
26
- for (let key of __getOwnPropNames(from))
27
- if (!__hasOwnProp.call(to, key) && key !== except)
28
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
- }
30
- return to;
31
- };
32
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
- // If the importer is in node compatibility mode or this is not an ESM
34
- // file that has been converted to a CommonJS file using a Babel-
35
- // compatible transform (i.e. "__esModule" has not been set), then set
36
- // "default" to the CommonJS "module.exports" for node compatibility.
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
- mod
39
- ));
40
11
 
41
12
  // src/cli/config.ts
42
13
  import fs from "node:fs";
@@ -99,649 +70,6 @@ var init_util = __esm({
99
70
  }
100
71
  });
101
72
 
102
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js
103
- var require_u64 = __commonJS({
104
- "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js"(exports) {
105
- "use strict";
106
- Object.defineProperty(exports, "__esModule", { value: true });
107
- exports.toBig = exports.shrSL = exports.shrSH = exports.rotrSL = exports.rotrSH = exports.rotrBL = exports.rotrBH = exports.rotr32L = exports.rotr32H = exports.rotlSL = exports.rotlSH = exports.rotlBL = exports.rotlBH = exports.add5L = exports.add5H = exports.add4L = exports.add4H = exports.add3L = exports.add3H = void 0;
108
- exports.add = add;
109
- exports.fromBig = fromBig;
110
- exports.split = split;
111
- var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
112
- var _32n = /* @__PURE__ */ BigInt(32);
113
- function fromBig(n, le = false) {
114
- if (le)
115
- return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
116
- return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
117
- }
118
- function split(lst, le = false) {
119
- const len = lst.length;
120
- let Ah = new Uint32Array(len);
121
- let Al = new Uint32Array(len);
122
- for (let i = 0; i < len; i++) {
123
- const { h, l } = fromBig(lst[i], le);
124
- [Ah[i], Al[i]] = [h, l];
125
- }
126
- return [Ah, Al];
127
- }
128
- var toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
129
- exports.toBig = toBig;
130
- var shrSH = (h, _l, s) => h >>> s;
131
- exports.shrSH = shrSH;
132
- var shrSL = (h, l, s) => h << 32 - s | l >>> s;
133
- exports.shrSL = shrSL;
134
- var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
135
- exports.rotrSH = rotrSH;
136
- var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
137
- exports.rotrSL = rotrSL;
138
- var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
139
- exports.rotrBH = rotrBH;
140
- var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
141
- exports.rotrBL = rotrBL;
142
- var rotr32H = (_h, l) => l;
143
- exports.rotr32H = rotr32H;
144
- var rotr32L = (h, _l) => h;
145
- exports.rotr32L = rotr32L;
146
- var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
147
- exports.rotlSH = rotlSH;
148
- var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
149
- exports.rotlSL = rotlSL;
150
- var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
151
- exports.rotlBH = rotlBH;
152
- var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
153
- exports.rotlBL = rotlBL;
154
- function add(Ah, Al, Bh, Bl) {
155
- const l = (Al >>> 0) + (Bl >>> 0);
156
- return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
157
- }
158
- var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
159
- exports.add3L = add3L;
160
- var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
161
- exports.add3H = add3H;
162
- var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
163
- exports.add4L = add4L;
164
- var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
165
- exports.add4H = add4H;
166
- var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
167
- exports.add5L = add5L;
168
- var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
169
- exports.add5H = add5H;
170
- var u64 = {
171
- fromBig,
172
- split,
173
- toBig,
174
- shrSH,
175
- shrSL,
176
- rotrSH,
177
- rotrSL,
178
- rotrBH,
179
- rotrBL,
180
- rotr32H,
181
- rotr32L,
182
- rotlSH,
183
- rotlSL,
184
- rotlBH,
185
- rotlBL,
186
- add,
187
- add3L,
188
- add3H,
189
- add4L,
190
- add4H,
191
- add5H,
192
- add5L
193
- };
194
- exports.default = u64;
195
- }
196
- });
197
-
198
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.js
199
- var require_cryptoNode = __commonJS({
200
- "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.js"(exports) {
201
- "use strict";
202
- Object.defineProperty(exports, "__esModule", { value: true });
203
- exports.crypto = void 0;
204
- var nc = __require("node:crypto");
205
- exports.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
206
- }
207
- });
208
-
209
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/utils.js
210
- var require_utils = __commonJS({
211
- "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/utils.js"(exports) {
212
- "use strict";
213
- Object.defineProperty(exports, "__esModule", { value: true });
214
- exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
215
- exports.isBytes = isBytes;
216
- exports.anumber = anumber;
217
- exports.abytes = abytes;
218
- exports.ahash = ahash;
219
- exports.aexists = aexists;
220
- exports.aoutput = aoutput;
221
- exports.u8 = u8;
222
- exports.u32 = u32;
223
- exports.clean = clean;
224
- exports.createView = createView;
225
- exports.rotr = rotr;
226
- exports.rotl = rotl;
227
- exports.byteSwap = byteSwap;
228
- exports.byteSwap32 = byteSwap32;
229
- exports.bytesToHex = bytesToHex;
230
- exports.hexToBytes = hexToBytes2;
231
- exports.asyncLoop = asyncLoop;
232
- exports.utf8ToBytes = utf8ToBytes;
233
- exports.bytesToUtf8 = bytesToUtf8;
234
- exports.toBytes = toBytes;
235
- exports.kdfInputToBytes = kdfInputToBytes;
236
- exports.concatBytes = concatBytes;
237
- exports.checkOpts = checkOpts;
238
- exports.createHasher = createHasher;
239
- exports.createOptHasher = createOptHasher;
240
- exports.createXOFer = createXOFer;
241
- exports.randomBytes = randomBytes;
242
- var crypto_1 = require_cryptoNode();
243
- function isBytes(a) {
244
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
245
- }
246
- function anumber(n) {
247
- if (!Number.isSafeInteger(n) || n < 0)
248
- throw new Error("positive integer expected, got " + n);
249
- }
250
- function abytes(b, ...lengths) {
251
- if (!isBytes(b))
252
- throw new Error("Uint8Array expected");
253
- if (lengths.length > 0 && !lengths.includes(b.length))
254
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
255
- }
256
- function ahash(h) {
257
- if (typeof h !== "function" || typeof h.create !== "function")
258
- throw new Error("Hash should be wrapped by utils.createHasher");
259
- anumber(h.outputLen);
260
- anumber(h.blockLen);
261
- }
262
- function aexists(instance, checkFinished = true) {
263
- if (instance.destroyed)
264
- throw new Error("Hash instance has been destroyed");
265
- if (checkFinished && instance.finished)
266
- throw new Error("Hash#digest() has already been called");
267
- }
268
- function aoutput(out, instance) {
269
- abytes(out);
270
- const min = instance.outputLen;
271
- if (out.length < min) {
272
- throw new Error("digestInto() expects output buffer of length at least " + min);
273
- }
274
- }
275
- function u8(arr) {
276
- return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
277
- }
278
- function u32(arr) {
279
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
280
- }
281
- function clean(...arrays) {
282
- for (let i = 0; i < arrays.length; i++) {
283
- arrays[i].fill(0);
284
- }
285
- }
286
- function createView(arr) {
287
- return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
288
- }
289
- function rotr(word, shift) {
290
- return word << 32 - shift | word >>> shift;
291
- }
292
- function rotl(word, shift) {
293
- return word << shift | word >>> 32 - shift >>> 0;
294
- }
295
- exports.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
296
- function byteSwap(word) {
297
- return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
298
- }
299
- exports.swap8IfBE = exports.isLE ? (n) => n : (n) => byteSwap(n);
300
- exports.byteSwapIfBE = exports.swap8IfBE;
301
- function byteSwap32(arr) {
302
- for (let i = 0; i < arr.length; i++) {
303
- arr[i] = byteSwap(arr[i]);
304
- }
305
- return arr;
306
- }
307
- exports.swap32IfBE = exports.isLE ? (u) => u : byteSwap32;
308
- var hasHexBuiltin = /* @__PURE__ */ (() => (
309
- // @ts-ignore
310
- typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
311
- ))();
312
- var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
313
- function bytesToHex(bytes) {
314
- abytes(bytes);
315
- if (hasHexBuiltin)
316
- return bytes.toHex();
317
- let hex = "";
318
- for (let i = 0; i < bytes.length; i++) {
319
- hex += hexes[bytes[i]];
320
- }
321
- return hex;
322
- }
323
- var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
324
- function asciiToBase16(ch) {
325
- if (ch >= asciis._0 && ch <= asciis._9)
326
- return ch - asciis._0;
327
- if (ch >= asciis.A && ch <= asciis.F)
328
- return ch - (asciis.A - 10);
329
- if (ch >= asciis.a && ch <= asciis.f)
330
- return ch - (asciis.a - 10);
331
- return;
332
- }
333
- function hexToBytes2(hex) {
334
- if (typeof hex !== "string")
335
- throw new Error("hex string expected, got " + typeof hex);
336
- if (hasHexBuiltin)
337
- return Uint8Array.fromHex(hex);
338
- const hl = hex.length;
339
- const al = hl / 2;
340
- if (hl % 2)
341
- throw new Error("hex string expected, got unpadded hex of length " + hl);
342
- const array = new Uint8Array(al);
343
- for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
344
- const n1 = asciiToBase16(hex.charCodeAt(hi));
345
- const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
346
- if (n1 === void 0 || n2 === void 0) {
347
- const char2 = hex[hi] + hex[hi + 1];
348
- throw new Error('hex string expected, got non-hex character "' + char2 + '" at index ' + hi);
349
- }
350
- array[ai] = n1 * 16 + n2;
351
- }
352
- return array;
353
- }
354
- var nextTick = async () => {
355
- };
356
- exports.nextTick = nextTick;
357
- async function asyncLoop(iters, tick, cb) {
358
- let ts = Date.now();
359
- for (let i = 0; i < iters; i++) {
360
- cb(i);
361
- const diff = Date.now() - ts;
362
- if (diff >= 0 && diff < tick)
363
- continue;
364
- await (0, exports.nextTick)();
365
- ts += diff;
366
- }
367
- }
368
- function utf8ToBytes(str) {
369
- if (typeof str !== "string")
370
- throw new Error("string expected");
371
- return new Uint8Array(new TextEncoder().encode(str));
372
- }
373
- function bytesToUtf8(bytes) {
374
- return new TextDecoder().decode(bytes);
375
- }
376
- function toBytes(data) {
377
- if (typeof data === "string")
378
- data = utf8ToBytes(data);
379
- abytes(data);
380
- return data;
381
- }
382
- function kdfInputToBytes(data) {
383
- if (typeof data === "string")
384
- data = utf8ToBytes(data);
385
- abytes(data);
386
- return data;
387
- }
388
- function concatBytes(...arrays) {
389
- let sum = 0;
390
- for (let i = 0; i < arrays.length; i++) {
391
- const a = arrays[i];
392
- abytes(a);
393
- sum += a.length;
394
- }
395
- const res = new Uint8Array(sum);
396
- for (let i = 0, pad = 0; i < arrays.length; i++) {
397
- const a = arrays[i];
398
- res.set(a, pad);
399
- pad += a.length;
400
- }
401
- return res;
402
- }
403
- function checkOpts(defaults, opts) {
404
- if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
405
- throw new Error("options should be object or undefined");
406
- const merged = Object.assign(defaults, opts);
407
- return merged;
408
- }
409
- var Hash = class {
410
- };
411
- exports.Hash = Hash;
412
- function createHasher(hashCons) {
413
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
414
- const tmp = hashCons();
415
- hashC.outputLen = tmp.outputLen;
416
- hashC.blockLen = tmp.blockLen;
417
- hashC.create = () => hashCons();
418
- return hashC;
419
- }
420
- function createOptHasher(hashCons) {
421
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
422
- const tmp = hashCons({});
423
- hashC.outputLen = tmp.outputLen;
424
- hashC.blockLen = tmp.blockLen;
425
- hashC.create = (opts) => hashCons(opts);
426
- return hashC;
427
- }
428
- function createXOFer(hashCons) {
429
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
430
- const tmp = hashCons({});
431
- hashC.outputLen = tmp.outputLen;
432
- hashC.blockLen = tmp.blockLen;
433
- hashC.create = (opts) => hashCons(opts);
434
- return hashC;
435
- }
436
- exports.wrapConstructor = createHasher;
437
- exports.wrapConstructorWithOpts = createOptHasher;
438
- exports.wrapXOFConstructorWithOpts = createXOFer;
439
- function randomBytes(bytesLength = 32) {
440
- if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
441
- return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
442
- }
443
- if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
444
- return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
445
- }
446
- throw new Error("crypto.getRandomValues must be defined");
447
- }
448
- }
449
- });
450
-
451
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/sha3.js
452
- var require_sha3 = __commonJS({
453
- "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/sha3.js"(exports) {
454
- "use strict";
455
- Object.defineProperty(exports, "__esModule", { value: true });
456
- exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0;
457
- exports.keccakP = keccakP;
458
- var _u64_ts_1 = require_u64();
459
- var utils_ts_1 = require_utils();
460
- var _0n = BigInt(0);
461
- var _1n = BigInt(1);
462
- var _2n = BigInt(2);
463
- var _7n = BigInt(7);
464
- var _256n = BigInt(256);
465
- var _0x71n = BigInt(113);
466
- var SHA3_PI = [];
467
- var SHA3_ROTL = [];
468
- var _SHA3_IOTA = [];
469
- for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
470
- [x, y] = [y, (2 * x + 3 * y) % 5];
471
- SHA3_PI.push(2 * (5 * y + x));
472
- SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
473
- let t = _0n;
474
- for (let j = 0; j < 7; j++) {
475
- R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
476
- if (R & _2n)
477
- t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
478
- }
479
- _SHA3_IOTA.push(t);
480
- }
481
- var IOTAS = (0, _u64_ts_1.split)(_SHA3_IOTA, true);
482
- var SHA3_IOTA_H = IOTAS[0];
483
- var SHA3_IOTA_L = IOTAS[1];
484
- var rotlH = (h, l, s) => s > 32 ? (0, _u64_ts_1.rotlBH)(h, l, s) : (0, _u64_ts_1.rotlSH)(h, l, s);
485
- var rotlL = (h, l, s) => s > 32 ? (0, _u64_ts_1.rotlBL)(h, l, s) : (0, _u64_ts_1.rotlSL)(h, l, s);
486
- function keccakP(s, rounds = 24) {
487
- const B = new Uint32Array(5 * 2);
488
- for (let round = 24 - rounds; round < 24; round++) {
489
- for (let x = 0; x < 10; x++)
490
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
491
- for (let x = 0; x < 10; x += 2) {
492
- const idx1 = (x + 8) % 10;
493
- const idx0 = (x + 2) % 10;
494
- const B0 = B[idx0];
495
- const B1 = B[idx0 + 1];
496
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
497
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
498
- for (let y = 0; y < 50; y += 10) {
499
- s[x + y] ^= Th;
500
- s[x + y + 1] ^= Tl;
501
- }
502
- }
503
- let curH = s[2];
504
- let curL = s[3];
505
- for (let t = 0; t < 24; t++) {
506
- const shift = SHA3_ROTL[t];
507
- const Th = rotlH(curH, curL, shift);
508
- const Tl = rotlL(curH, curL, shift);
509
- const PI = SHA3_PI[t];
510
- curH = s[PI];
511
- curL = s[PI + 1];
512
- s[PI] = Th;
513
- s[PI + 1] = Tl;
514
- }
515
- for (let y = 0; y < 50; y += 10) {
516
- for (let x = 0; x < 10; x++)
517
- B[x] = s[y + x];
518
- for (let x = 0; x < 10; x++)
519
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
520
- }
521
- s[0] ^= SHA3_IOTA_H[round];
522
- s[1] ^= SHA3_IOTA_L[round];
523
- }
524
- (0, utils_ts_1.clean)(B);
525
- }
526
- var Keccak = class _Keccak extends utils_ts_1.Hash {
527
- // NOTE: we accept arguments in bytes instead of bits here.
528
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
529
- super();
530
- this.pos = 0;
531
- this.posOut = 0;
532
- this.finished = false;
533
- this.destroyed = false;
534
- this.enableXOF = false;
535
- this.blockLen = blockLen;
536
- this.suffix = suffix;
537
- this.outputLen = outputLen;
538
- this.enableXOF = enableXOF;
539
- this.rounds = rounds;
540
- (0, utils_ts_1.anumber)(outputLen);
541
- if (!(0 < blockLen && blockLen < 200))
542
- throw new Error("only keccak-f1600 function is supported");
543
- this.state = new Uint8Array(200);
544
- this.state32 = (0, utils_ts_1.u32)(this.state);
545
- }
546
- clone() {
547
- return this._cloneInto();
548
- }
549
- keccak() {
550
- (0, utils_ts_1.swap32IfBE)(this.state32);
551
- keccakP(this.state32, this.rounds);
552
- (0, utils_ts_1.swap32IfBE)(this.state32);
553
- this.posOut = 0;
554
- this.pos = 0;
555
- }
556
- update(data) {
557
- (0, utils_ts_1.aexists)(this);
558
- data = (0, utils_ts_1.toBytes)(data);
559
- (0, utils_ts_1.abytes)(data);
560
- const { blockLen, state } = this;
561
- const len = data.length;
562
- for (let pos = 0; pos < len; ) {
563
- const take = Math.min(blockLen - this.pos, len - pos);
564
- for (let i = 0; i < take; i++)
565
- state[this.pos++] ^= data[pos++];
566
- if (this.pos === blockLen)
567
- this.keccak();
568
- }
569
- return this;
570
- }
571
- finish() {
572
- if (this.finished)
573
- return;
574
- this.finished = true;
575
- const { state, suffix, pos, blockLen } = this;
576
- state[pos] ^= suffix;
577
- if ((suffix & 128) !== 0 && pos === blockLen - 1)
578
- this.keccak();
579
- state[blockLen - 1] ^= 128;
580
- this.keccak();
581
- }
582
- writeInto(out) {
583
- (0, utils_ts_1.aexists)(this, false);
584
- (0, utils_ts_1.abytes)(out);
585
- this.finish();
586
- const bufferOut = this.state;
587
- const { blockLen } = this;
588
- for (let pos = 0, len = out.length; pos < len; ) {
589
- if (this.posOut >= blockLen)
590
- this.keccak();
591
- const take = Math.min(blockLen - this.posOut, len - pos);
592
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
593
- this.posOut += take;
594
- pos += take;
595
- }
596
- return out;
597
- }
598
- xofInto(out) {
599
- if (!this.enableXOF)
600
- throw new Error("XOF is not possible for this instance");
601
- return this.writeInto(out);
602
- }
603
- xof(bytes) {
604
- (0, utils_ts_1.anumber)(bytes);
605
- return this.xofInto(new Uint8Array(bytes));
606
- }
607
- digestInto(out) {
608
- (0, utils_ts_1.aoutput)(out, this);
609
- if (this.finished)
610
- throw new Error("digest() was already called");
611
- this.writeInto(out);
612
- this.destroy();
613
- return out;
614
- }
615
- digest() {
616
- return this.digestInto(new Uint8Array(this.outputLen));
617
- }
618
- destroy() {
619
- this.destroyed = true;
620
- (0, utils_ts_1.clean)(this.state);
621
- }
622
- _cloneInto(to) {
623
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
624
- to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
625
- to.state32.set(this.state32);
626
- to.pos = this.pos;
627
- to.posOut = this.posOut;
628
- to.finished = this.finished;
629
- to.rounds = rounds;
630
- to.suffix = suffix;
631
- to.outputLen = outputLen;
632
- to.enableXOF = enableXOF;
633
- to.destroyed = this.destroyed;
634
- return to;
635
- }
636
- };
637
- exports.Keccak = Keccak;
638
- var gen = (suffix, blockLen, outputLen) => (0, utils_ts_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen));
639
- exports.sha3_224 = (() => gen(6, 144, 224 / 8))();
640
- exports.sha3_256 = (() => gen(6, 136, 256 / 8))();
641
- exports.sha3_384 = (() => gen(6, 104, 384 / 8))();
642
- exports.sha3_512 = (() => gen(6, 72, 512 / 8))();
643
- exports.keccak_224 = (() => gen(1, 144, 224 / 8))();
644
- exports.keccak_256 = (() => gen(1, 136, 256 / 8))();
645
- exports.keccak_384 = (() => gen(1, 104, 384 / 8))();
646
- exports.keccak_512 = (() => gen(1, 72, 512 / 8))();
647
- var genShake = (suffix, blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
648
- exports.shake128 = (() => genShake(31, 168, 128 / 8))();
649
- exports.shake256 = (() => genShake(31, 136, 256 / 8))();
650
- }
651
- });
652
-
653
- // ../../node_modules/.pnpm/@paralleldrive+cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.js
654
- var require_src = __commonJS({
655
- "../../node_modules/.pnpm/@paralleldrive+cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.js"(exports, module) {
656
- var { sha3_512: sha3 } = require_sha3();
657
- var defaultLength = 24;
658
- var bigLength = 32;
659
- var createEntropy = (length = 4, random = Math.random) => {
660
- let entropy = "";
661
- while (entropy.length < length) {
662
- entropy = entropy + Math.floor(random() * 36).toString(36);
663
- }
664
- return entropy;
665
- };
666
- function bufToBigInt(buf) {
667
- let bits = 8n;
668
- let value = 0n;
669
- for (const i of buf.values()) {
670
- const bi = BigInt(i);
671
- value = (value << bits) + bi;
672
- }
673
- return value;
674
- }
675
- var hash = (input = "") => {
676
- return bufToBigInt(sha3(input)).toString(36).slice(1);
677
- };
678
- var alphabet = Array.from(
679
- { length: 26 },
680
- (x, i) => String.fromCharCode(i + 97)
681
- );
682
- var randomLetter = (random) => alphabet[Math.floor(random() * alphabet.length)];
683
- var createFingerprint = ({
684
- globalObj = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {},
685
- random = Math.random
686
- } = {}) => {
687
- const globals = Object.keys(globalObj).toString();
688
- const sourceString = globals.length ? globals + createEntropy(bigLength, random) : createEntropy(bigLength, random);
689
- return hash(sourceString).substring(0, bigLength);
690
- };
691
- var createCounter = (count) => () => {
692
- return count++;
693
- };
694
- var initialCountMax = 476782367;
695
- var init2 = ({
696
- // Fallback if the user does not pass in a CSPRNG. This should be OK
697
- // because we don't rely solely on the random number generator for entropy.
698
- // We also use the host fingerprint, current time, and a session counter.
699
- random = Math.random,
700
- counter = createCounter(Math.floor(random() * initialCountMax)),
701
- length = defaultLength,
702
- fingerprint = createFingerprint({ random })
703
- } = {}) => {
704
- return function cuid2() {
705
- const firstLetter = randomLetter(random);
706
- const time2 = Date.now().toString(36);
707
- const count = counter().toString(36);
708
- const salt = createEntropy(length, random);
709
- const hashInput = `${time2 + salt + count + fingerprint}`;
710
- return `${firstLetter + hash(hashInput).substring(1, length)}`;
711
- };
712
- };
713
- var createId6 = init2();
714
- var isCuid = (id, { minLength = 2, maxLength = bigLength } = {}) => {
715
- const length = id.length;
716
- const regex = /^[0-9a-z]+$/;
717
- try {
718
- if (typeof id === "string" && length >= minLength && length <= maxLength && regex.test(id))
719
- return true;
720
- } finally {
721
- }
722
- return false;
723
- };
724
- module.exports.getConstants = () => ({ defaultLength, bigLength });
725
- module.exports.init = init2;
726
- module.exports.createId = createId6;
727
- module.exports.bufToBigInt = bufToBigInt;
728
- module.exports.createCounter = createCounter;
729
- module.exports.createFingerprint = createFingerprint;
730
- module.exports.isCuid = isCuid;
731
- }
732
- });
733
-
734
- // ../../node_modules/.pnpm/@paralleldrive+cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.js
735
- var require_cuid2 = __commonJS({
736
- "../../node_modules/.pnpm/@paralleldrive+cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.js"(exports, module) {
737
- var { createId: createId6, init: init2, getConstants, isCuid } = require_src();
738
- module.exports.createId = createId6;
739
- module.exports.init = init2;
740
- module.exports.getConstants = getConstants;
741
- module.exports.isCuid = isCuid;
742
- }
743
- });
744
-
745
73
  // src/cli/commands/sync.ts
746
74
  var sync_exports = {};
747
75
  __export(sync_exports, {
@@ -892,2896 +220,165 @@ async function login() {
892
220
  baseUrl,
893
221
  orgId: orgId || void 0
894
222
  });
895
- resolve(key);
896
- } else {
897
- res.writeHead(400);
898
- res.end("Missing key parameter");
899
- }
900
- });
901
- server.listen(0, "127.0.0.1", () => {
902
- const addr = server.address();
903
- if (!addr || typeof addr === "string") {
904
- reject(new Error("Failed to start callback server"));
905
- return;
906
- }
907
- const callbackPort = addr.port;
908
- const authUrl = `${baseUrl}/api/auth/cli?callback=http://127.0.0.1:${callbackPort}`;
909
- openBrowser(authUrl);
910
- });
911
- setTimeout(() => {
912
- server.close();
913
- reject(new Error("Authentication timed out"));
914
- }, 12e4);
915
- });
916
- check("Authenticated with Basestream");
917
- return apiKey;
918
- }
919
-
920
- // src/cli/commands/init.ts
921
- var CLAUDE_DIR = path2.join(os2.homedir(), ".claude");
922
- var CLAUDE_SETTINGS_PATH = path2.join(CLAUDE_DIR, "settings.json");
923
- var CLAUDE_SKILLS_PATH = path2.join(CLAUDE_DIR, "skills", "bs-summarize.md");
924
- var CLAUDE_MD_PATH = path2.join(CLAUDE_DIR, "CLAUDE.md");
925
- var HOOK_COMMAND = "npx @basestream/cli _hook-stop";
926
- var HOOK_MARKER = "_hook-stop";
927
- var CLAUDE_MD_MARKER = "<!-- basestream -->";
928
- var CLAUDE_MD_RULE = `${CLAUDE_MD_MARKER}
929
- - Before starting any non-trivial task, if the reason or context behind the work isn't already clear, ask: "What's the context for this?" Skip this for small tasks, typo fixes, or anything self-explanatory.
930
- - After completing any meaningful work (fixing a bug, implementing a feature, making a significant change), invoke /bs-summarize to keep the session summary up to date. Include the "why" if it was provided.
931
- <!-- /basestream -->`;
932
- var SKILL_CONTENT = `---
933
- name: bs-summarize
934
- description: Update the Basestream session summary with what's been accomplished so far
935
- ---
936
-
937
- First, read the existing summary file at \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\` if it exists \u2014 this is the running record of work done so far this session.
938
-
939
- Then write an updated summary that aggregates the previous summary with everything that has happened since. Focus on:
940
- - Why the work was done (if context was provided \u2014 skip if not known)
941
- - What was built, fixed, or changed (be specific about features/bugs)
942
- - Which parts of the codebase were touched
943
- - Any key decisions made
944
-
945
- Do not just append \u2014 synthesize everything into a single cohesive summary. Merge related work together, avoid repeating the same point twice, and drop anything superseded by later changes. Be concise \u2014 let the scope of the work determine the length. A small fix deserves one sentence; a large multi-part session can be a short paragraph. Plain prose, no bullet points.
946
-
947
- Write the result to \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\`, overwriting the file.
948
- `;
949
- function injectClaudeMdRule() {
950
- let existing = "";
951
- if (fs2.existsSync(CLAUDE_MD_PATH)) {
952
- existing = fs2.readFileSync(CLAUDE_MD_PATH, "utf-8");
953
- }
954
- let updated;
955
- if (existing.includes(CLAUDE_MD_MARKER)) {
956
- updated = existing.replace(/<!-- basestream -->[\s\S]*?<!-- \/basestream -->/, CLAUDE_MD_RULE);
957
- fs2.writeFileSync(CLAUDE_MD_PATH, updated);
958
- check("Updated Basestream rules in ~/.claude/CLAUDE.md");
959
- } else {
960
- updated = existing ? `${existing.trimEnd()}
961
-
962
- ${CLAUDE_MD_RULE}
963
- ` : `${CLAUDE_MD_RULE}
964
- `;
965
- fs2.mkdirSync(CLAUDE_DIR, { recursive: true });
966
- fs2.writeFileSync(CLAUDE_MD_PATH, updated);
967
- check("Injected Basestream rules into ~/.claude/CLAUDE.md");
968
- }
969
- }
970
- function installSkill() {
971
- const skillsDir = path2.dirname(CLAUDE_SKILLS_PATH);
972
- fs2.mkdirSync(skillsDir, { recursive: true });
973
- fs2.writeFileSync(CLAUDE_SKILLS_PATH, SKILL_CONTENT);
974
- check("Installed /bs-summarize skill into ~/.claude/skills/");
975
- }
976
- function detectClaudeCode() {
977
- try {
978
- const version2 = execSync2("claude --version 2>/dev/null", {
979
- encoding: "utf-8"
980
- }).trim();
981
- return version2 || null;
982
- } catch {
983
- return null;
984
- }
985
- }
986
- function injectClaudeCodeHook() {
987
- const settingsDir = path2.dirname(CLAUDE_SETTINGS_PATH);
988
- fs2.mkdirSync(settingsDir, { recursive: true });
989
- let settings = {};
990
- if (fs2.existsSync(CLAUDE_SETTINGS_PATH)) {
991
- try {
992
- settings = JSON.parse(fs2.readFileSync(CLAUDE_SETTINGS_PATH, "utf-8"));
993
- } catch {
994
- }
995
- }
996
- if (!settings.hooks || typeof settings.hooks !== "object") {
997
- settings.hooks = {};
998
- }
999
- const hooks = settings.hooks;
1000
- if (Array.isArray(hooks.Stop)) {
1001
- const existing = hooks.Stop;
1002
- const alreadyInstalled = existing.some(
1003
- (entry) => entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER))
1004
- );
1005
- if (alreadyInstalled) {
1006
- check("Claude Code hook already installed");
1007
- return;
1008
- }
1009
- }
1010
- if (!Array.isArray(hooks.Stop)) {
1011
- hooks.Stop = [];
1012
- }
1013
- hooks.Stop.push({
1014
- matcher: "*",
1015
- hooks: [
1016
- {
1017
- type: "command",
1018
- command: HOOK_COMMAND,
1019
- timeout: 30
1020
- }
1021
- ]
1022
- });
1023
- fs2.writeFileSync(CLAUDE_SETTINGS_PATH, JSON.stringify(settings, null, 2));
1024
- check("Injected tracking hook into ~/.claude/settings.json");
1025
- }
1026
- async function init() {
1027
- console.log();
1028
- const ccVersion = detectClaudeCode();
1029
- if (ccVersion) {
1030
- console.log(` ${c.dim(`Detected: Claude Code ${ccVersion}`)}`);
1031
- } else {
1032
- warn("Claude Code not detected \u2014 hook will activate when installed");
1033
- }
1034
- console.log();
1035
- injectClaudeCodeHook();
1036
- installSkill();
1037
- injectClaudeMdRule();
1038
- ensureDirs();
1039
- check(`Created ~/.basestream/buffer/`);
1040
- console.log();
1041
- await login();
1042
- console.log();
1043
- console.log(
1044
- ` ${c.dim("That's it. Work normally \u2014 every session is now tracked.")}`
1045
- );
1046
- console.log();
1047
- }
1048
-
1049
- // src/cli/commands/status.ts
1050
- init_config();
1051
- import fs3 from "node:fs";
1052
- import path3 from "node:path";
1053
-
1054
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/entity.js
1055
- var entityKind = Symbol.for("drizzle:entityKind");
1056
- var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
1057
- function is(value, type) {
1058
- if (!value || typeof value !== "object") {
1059
- return false;
1060
- }
1061
- if (value instanceof type) {
1062
- return true;
1063
- }
1064
- if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
1065
- throw new Error(
1066
- `Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
1067
- );
1068
- }
1069
- let cls = Object.getPrototypeOf(value).constructor;
1070
- if (cls) {
1071
- while (cls) {
1072
- if (entityKind in cls && cls[entityKind] === type[entityKind]) {
1073
- return true;
1074
- }
1075
- cls = Object.getPrototypeOf(cls);
1076
- }
1077
- }
1078
- return false;
1079
- }
1080
-
1081
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/column.js
1082
- var Column = class {
1083
- constructor(table, config) {
1084
- this.table = table;
1085
- this.config = config;
1086
- this.name = config.name;
1087
- this.keyAsName = config.keyAsName;
1088
- this.notNull = config.notNull;
1089
- this.default = config.default;
1090
- this.defaultFn = config.defaultFn;
1091
- this.onUpdateFn = config.onUpdateFn;
1092
- this.hasDefault = config.hasDefault;
1093
- this.primary = config.primaryKey;
1094
- this.isUnique = config.isUnique;
1095
- this.uniqueName = config.uniqueName;
1096
- this.uniqueType = config.uniqueType;
1097
- this.dataType = config.dataType;
1098
- this.columnType = config.columnType;
1099
- this.generated = config.generated;
1100
- this.generatedIdentity = config.generatedIdentity;
1101
- }
1102
- static [entityKind] = "Column";
1103
- name;
1104
- keyAsName;
1105
- primary;
1106
- notNull;
1107
- default;
1108
- defaultFn;
1109
- onUpdateFn;
1110
- hasDefault;
1111
- isUnique;
1112
- uniqueName;
1113
- uniqueType;
1114
- dataType;
1115
- columnType;
1116
- enumValues = void 0;
1117
- generated = void 0;
1118
- generatedIdentity = void 0;
1119
- config;
1120
- mapFromDriverValue(value) {
1121
- return value;
1122
- }
1123
- mapToDriverValue(value) {
1124
- return value;
1125
- }
1126
- // ** @internal */
1127
- shouldDisableInsert() {
1128
- return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
1129
- }
1130
- };
1131
-
1132
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/column-builder.js
1133
- var ColumnBuilder = class {
1134
- static [entityKind] = "ColumnBuilder";
1135
- config;
1136
- constructor(name, dataType, columnType) {
1137
- this.config = {
1138
- name,
1139
- keyAsName: name === "",
1140
- notNull: false,
1141
- default: void 0,
1142
- hasDefault: false,
1143
- primaryKey: false,
1144
- isUnique: false,
1145
- uniqueName: void 0,
1146
- uniqueType: void 0,
1147
- dataType,
1148
- columnType,
1149
- generated: void 0
1150
- };
1151
- }
1152
- /**
1153
- * Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
1154
- *
1155
- * @example
1156
- * ```ts
1157
- * const users = pgTable('users', {
1158
- * id: integer('id').$type<UserId>().primaryKey(),
1159
- * details: json('details').$type<UserDetails>().notNull(),
1160
- * });
1161
- * ```
1162
- */
1163
- $type() {
1164
- return this;
1165
- }
1166
- /**
1167
- * Adds a `not null` clause to the column definition.
1168
- *
1169
- * Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
1170
- */
1171
- notNull() {
1172
- this.config.notNull = true;
1173
- return this;
1174
- }
1175
- /**
1176
- * Adds a `default <value>` clause to the column definition.
1177
- *
1178
- * Affects the `insert` model of the table - columns *with* `default` are optional on insert.
1179
- *
1180
- * If you need to set a dynamic default value, use {@link $defaultFn} instead.
1181
- */
1182
- default(value) {
1183
- this.config.default = value;
1184
- this.config.hasDefault = true;
1185
- return this;
1186
- }
1187
- /**
1188
- * Adds a dynamic default value to the column.
1189
- * The function will be called when the row is inserted, and the returned value will be used as the column value.
1190
- *
1191
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
1192
- */
1193
- $defaultFn(fn) {
1194
- this.config.defaultFn = fn;
1195
- this.config.hasDefault = true;
1196
- return this;
1197
- }
1198
- /**
1199
- * Alias for {@link $defaultFn}.
1200
- */
1201
- $default = this.$defaultFn;
1202
- /**
1203
- * Adds a dynamic update value to the column.
1204
- * The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
1205
- * If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
1206
- *
1207
- * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
1208
- */
1209
- $onUpdateFn(fn) {
1210
- this.config.onUpdateFn = fn;
1211
- this.config.hasDefault = true;
1212
- return this;
1213
- }
1214
- /**
1215
- * Alias for {@link $onUpdateFn}.
1216
- */
1217
- $onUpdate = this.$onUpdateFn;
1218
- /**
1219
- * Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
1220
- *
1221
- * In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
1222
- */
1223
- primaryKey() {
1224
- this.config.primaryKey = true;
1225
- this.config.notNull = true;
1226
- return this;
1227
- }
1228
- /** @internal Sets the name of the column to the key within the table definition if a name was not given. */
1229
- setName(name) {
1230
- if (this.config.name !== "") return;
1231
- this.config.name = name;
1232
- }
1233
- };
1234
-
1235
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/table.utils.js
1236
- var TableName = Symbol.for("drizzle:Name");
1237
-
1238
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/foreign-keys.js
1239
- var ForeignKeyBuilder = class {
1240
- static [entityKind] = "PgForeignKeyBuilder";
1241
- /** @internal */
1242
- reference;
1243
- /** @internal */
1244
- _onUpdate = "no action";
1245
- /** @internal */
1246
- _onDelete = "no action";
1247
- constructor(config, actions) {
1248
- this.reference = () => {
1249
- const { name, columns, foreignColumns } = config();
1250
- return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
1251
- };
1252
- if (actions) {
1253
- this._onUpdate = actions.onUpdate;
1254
- this._onDelete = actions.onDelete;
1255
- }
1256
- }
1257
- onUpdate(action) {
1258
- this._onUpdate = action === void 0 ? "no action" : action;
1259
- return this;
1260
- }
1261
- onDelete(action) {
1262
- this._onDelete = action === void 0 ? "no action" : action;
1263
- return this;
1264
- }
1265
- /** @internal */
1266
- build(table) {
1267
- return new ForeignKey(table, this);
1268
- }
1269
- };
1270
- var ForeignKey = class {
1271
- constructor(table, builder) {
1272
- this.table = table;
1273
- this.reference = builder.reference;
1274
- this.onUpdate = builder._onUpdate;
1275
- this.onDelete = builder._onDelete;
1276
- }
1277
- static [entityKind] = "PgForeignKey";
1278
- reference;
1279
- onUpdate;
1280
- onDelete;
1281
- getName() {
1282
- const { name, columns, foreignColumns } = this.reference();
1283
- const columnNames = columns.map((column) => column.name);
1284
- const foreignColumnNames = foreignColumns.map((column) => column.name);
1285
- const chunks = [
1286
- this.table[TableName],
1287
- ...columnNames,
1288
- foreignColumns[0].table[TableName],
1289
- ...foreignColumnNames
1290
- ];
1291
- return name ?? `${chunks.join("_")}_fk`;
1292
- }
1293
- };
1294
-
1295
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/tracing-utils.js
1296
- function iife(fn, ...args) {
1297
- return fn(...args);
1298
- }
1299
-
1300
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/unique-constraint.js
1301
- function uniqueKeyName(table, columns) {
1302
- return `${table[TableName]}_${columns.join("_")}_unique`;
1303
- }
1304
- var UniqueConstraintBuilder = class {
1305
- constructor(columns, name) {
1306
- this.name = name;
1307
- this.columns = columns;
1308
- }
1309
- static [entityKind] = "PgUniqueConstraintBuilder";
1310
- /** @internal */
1311
- columns;
1312
- /** @internal */
1313
- nullsNotDistinctConfig = false;
1314
- nullsNotDistinct() {
1315
- this.nullsNotDistinctConfig = true;
1316
- return this;
1317
- }
1318
- /** @internal */
1319
- build(table) {
1320
- return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
1321
- }
1322
- };
1323
- var UniqueOnConstraintBuilder = class {
1324
- static [entityKind] = "PgUniqueOnConstraintBuilder";
1325
- /** @internal */
1326
- name;
1327
- constructor(name) {
1328
- this.name = name;
1329
- }
1330
- on(...columns) {
1331
- return new UniqueConstraintBuilder(columns, this.name);
1332
- }
1333
- };
1334
- var UniqueConstraint = class {
1335
- constructor(table, columns, nullsNotDistinct, name) {
1336
- this.table = table;
1337
- this.columns = columns;
1338
- this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
1339
- this.nullsNotDistinct = nullsNotDistinct;
1340
- }
1341
- static [entityKind] = "PgUniqueConstraint";
1342
- columns;
1343
- name;
1344
- nullsNotDistinct = false;
1345
- getName() {
1346
- return this.name;
1347
- }
1348
- };
1349
-
1350
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/utils/array.js
1351
- function parsePgArrayValue(arrayString, startFrom, inQuotes) {
1352
- for (let i = startFrom; i < arrayString.length; i++) {
1353
- const char2 = arrayString[i];
1354
- if (char2 === "\\") {
1355
- i++;
1356
- continue;
1357
- }
1358
- if (char2 === '"') {
1359
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
1360
- }
1361
- if (inQuotes) {
1362
- continue;
1363
- }
1364
- if (char2 === "," || char2 === "}") {
1365
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
1366
- }
1367
- }
1368
- return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
1369
- }
1370
- function parsePgNestedArray(arrayString, startFrom = 0) {
1371
- const result = [];
1372
- let i = startFrom;
1373
- let lastCharIsComma = false;
1374
- while (i < arrayString.length) {
1375
- const char2 = arrayString[i];
1376
- if (char2 === ",") {
1377
- if (lastCharIsComma || i === startFrom) {
1378
- result.push("");
1379
- }
1380
- lastCharIsComma = true;
1381
- i++;
1382
- continue;
1383
- }
1384
- lastCharIsComma = false;
1385
- if (char2 === "\\") {
1386
- i += 2;
1387
- continue;
1388
- }
1389
- if (char2 === '"') {
1390
- const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
1391
- result.push(value2);
1392
- i = startFrom2;
1393
- continue;
1394
- }
1395
- if (char2 === "}") {
1396
- return [result, i + 1];
1397
- }
1398
- if (char2 === "{") {
1399
- const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
1400
- result.push(value2);
1401
- i = startFrom2;
1402
- continue;
1403
- }
1404
- const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
1405
- result.push(value);
1406
- i = newStartFrom;
1407
- }
1408
- return [result, i];
1409
- }
1410
- function parsePgArray(arrayString) {
1411
- const [result] = parsePgNestedArray(arrayString, 1);
1412
- return result;
1413
- }
1414
- function makePgArray(array) {
1415
- return `{${array.map((item) => {
1416
- if (Array.isArray(item)) {
1417
- return makePgArray(item);
1418
- }
1419
- if (typeof item === "string") {
1420
- return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
1421
- }
1422
- return `${item}`;
1423
- }).join(",")}}`;
1424
- }
1425
-
1426
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/common.js
1427
- var PgColumnBuilder = class extends ColumnBuilder {
1428
- foreignKeyConfigs = [];
1429
- static [entityKind] = "PgColumnBuilder";
1430
- array(size) {
1431
- return new PgArrayBuilder(this.config.name, this, size);
1432
- }
1433
- references(ref, actions = {}) {
1434
- this.foreignKeyConfigs.push({ ref, actions });
1435
- return this;
1436
- }
1437
- unique(name, config) {
1438
- this.config.isUnique = true;
1439
- this.config.uniqueName = name;
1440
- this.config.uniqueType = config?.nulls;
1441
- return this;
1442
- }
1443
- generatedAlwaysAs(as) {
1444
- this.config.generated = {
1445
- as,
1446
- type: "always",
1447
- mode: "stored"
1448
- };
1449
- return this;
1450
- }
1451
- /** @internal */
1452
- buildForeignKeys(column, table) {
1453
- return this.foreignKeyConfigs.map(({ ref, actions }) => {
1454
- return iife(
1455
- (ref2, actions2) => {
1456
- const builder = new ForeignKeyBuilder(() => {
1457
- const foreignColumn = ref2();
1458
- return { columns: [column], foreignColumns: [foreignColumn] };
1459
- });
1460
- if (actions2.onUpdate) {
1461
- builder.onUpdate(actions2.onUpdate);
1462
- }
1463
- if (actions2.onDelete) {
1464
- builder.onDelete(actions2.onDelete);
1465
- }
1466
- return builder.build(table);
1467
- },
1468
- ref,
1469
- actions
1470
- );
1471
- });
1472
- }
1473
- /** @internal */
1474
- buildExtraConfigColumn(table) {
1475
- return new ExtraConfigColumn(table, this.config);
1476
- }
1477
- };
1478
- var PgColumn = class extends Column {
1479
- constructor(table, config) {
1480
- if (!config.uniqueName) {
1481
- config.uniqueName = uniqueKeyName(table, [config.name]);
1482
- }
1483
- super(table, config);
1484
- this.table = table;
1485
- }
1486
- static [entityKind] = "PgColumn";
1487
- };
1488
- var ExtraConfigColumn = class extends PgColumn {
1489
- static [entityKind] = "ExtraConfigColumn";
1490
- getSQLType() {
1491
- return this.getSQLType();
1492
- }
1493
- indexConfig = {
1494
- order: this.config.order ?? "asc",
1495
- nulls: this.config.nulls ?? "last",
1496
- opClass: this.config.opClass
1497
- };
1498
- defaultConfig = {
1499
- order: "asc",
1500
- nulls: "last",
1501
- opClass: void 0
1502
- };
1503
- asc() {
1504
- this.indexConfig.order = "asc";
1505
- return this;
1506
- }
1507
- desc() {
1508
- this.indexConfig.order = "desc";
1509
- return this;
1510
- }
1511
- nullsFirst() {
1512
- this.indexConfig.nulls = "first";
1513
- return this;
1514
- }
1515
- nullsLast() {
1516
- this.indexConfig.nulls = "last";
1517
- return this;
1518
- }
1519
- /**
1520
- * ### PostgreSQL documentation quote
1521
- *
1522
- * > An operator class with optional parameters can be specified for each column of an index.
1523
- * The operator class identifies the operators to be used by the index for that column.
1524
- * For example, a B-tree index on four-byte integers would use the int4_ops class;
1525
- * this operator class includes comparison functions for four-byte integers.
1526
- * In practice the default operator class for the column's data type is usually sufficient.
1527
- * The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
1528
- * For example, we might want to sort a complex-number data type either by absolute value or by real part.
1529
- * We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
1530
- * More information about operator classes check:
1531
- *
1532
- * ### Useful links
1533
- * https://www.postgresql.org/docs/current/sql-createindex.html
1534
- *
1535
- * https://www.postgresql.org/docs/current/indexes-opclass.html
1536
- *
1537
- * https://www.postgresql.org/docs/current/xindex.html
1538
- *
1539
- * ### Additional types
1540
- * If you have the `pg_vector` extension installed in your database, you can use the
1541
- * `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types.
1542
- *
1543
- * **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
1544
- *
1545
- * @param opClass
1546
- * @returns
1547
- */
1548
- op(opClass) {
1549
- this.indexConfig.opClass = opClass;
1550
- return this;
1551
- }
1552
- };
1553
- var IndexedColumn = class {
1554
- static [entityKind] = "IndexedColumn";
1555
- constructor(name, keyAsName, type, indexConfig) {
1556
- this.name = name;
1557
- this.keyAsName = keyAsName;
1558
- this.type = type;
1559
- this.indexConfig = indexConfig;
1560
- }
1561
- name;
1562
- keyAsName;
1563
- type;
1564
- indexConfig;
1565
- };
1566
- var PgArrayBuilder = class extends PgColumnBuilder {
1567
- static [entityKind] = "PgArrayBuilder";
1568
- constructor(name, baseBuilder, size) {
1569
- super(name, "array", "PgArray");
1570
- this.config.baseBuilder = baseBuilder;
1571
- this.config.size = size;
1572
- }
1573
- /** @internal */
1574
- build(table) {
1575
- const baseColumn = this.config.baseBuilder.build(table);
1576
- return new PgArray(
1577
- table,
1578
- this.config,
1579
- baseColumn
1580
- );
1581
- }
1582
- };
1583
- var PgArray = class _PgArray extends PgColumn {
1584
- constructor(table, config, baseColumn, range) {
1585
- super(table, config);
1586
- this.baseColumn = baseColumn;
1587
- this.range = range;
1588
- this.size = config.size;
1589
- }
1590
- size;
1591
- static [entityKind] = "PgArray";
1592
- getSQLType() {
1593
- return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
1594
- }
1595
- mapFromDriverValue(value) {
1596
- if (typeof value === "string") {
1597
- value = parsePgArray(value);
1598
- }
1599
- return value.map((v) => this.baseColumn.mapFromDriverValue(v));
1600
- }
1601
- mapToDriverValue(value, isNestedArray = false) {
1602
- const a = value.map(
1603
- (v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v)
1604
- );
1605
- if (isNestedArray) return a;
1606
- return makePgArray(a);
1607
- }
1608
- };
1609
-
1610
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/enum.js
1611
- var PgEnumObjectColumnBuilder = class extends PgColumnBuilder {
1612
- static [entityKind] = "PgEnumObjectColumnBuilder";
1613
- constructor(name, enumInstance) {
1614
- super(name, "string", "PgEnumObjectColumn");
1615
- this.config.enum = enumInstance;
1616
- }
1617
- /** @internal */
1618
- build(table) {
1619
- return new PgEnumObjectColumn(
1620
- table,
1621
- this.config
1622
- );
1623
- }
1624
- };
1625
- var PgEnumObjectColumn = class extends PgColumn {
1626
- static [entityKind] = "PgEnumObjectColumn";
1627
- enum;
1628
- enumValues = this.config.enum.enumValues;
1629
- constructor(table, config) {
1630
- super(table, config);
1631
- this.enum = config.enum;
1632
- }
1633
- getSQLType() {
1634
- return this.enum.enumName;
1635
- }
1636
- };
1637
- var isPgEnumSym = Symbol.for("drizzle:isPgEnum");
1638
- function isPgEnum(obj) {
1639
- return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
1640
- }
1641
- var PgEnumColumnBuilder = class extends PgColumnBuilder {
1642
- static [entityKind] = "PgEnumColumnBuilder";
1643
- constructor(name, enumInstance) {
1644
- super(name, "string", "PgEnumColumn");
1645
- this.config.enum = enumInstance;
1646
- }
1647
- /** @internal */
1648
- build(table) {
1649
- return new PgEnumColumn(
1650
- table,
1651
- this.config
1652
- );
1653
- }
1654
- };
1655
- var PgEnumColumn = class extends PgColumn {
1656
- static [entityKind] = "PgEnumColumn";
1657
- enum = this.config.enum;
1658
- enumValues = this.config.enum.enumValues;
1659
- constructor(table, config) {
1660
- super(table, config);
1661
- this.enum = config.enum;
1662
- }
1663
- getSQLType() {
1664
- return this.enum.enumName;
1665
- }
1666
- };
1667
- function pgEnum(enumName, input) {
1668
- return Array.isArray(input) ? pgEnumWithSchema(enumName, [...input], void 0) : pgEnumObjectWithSchema(enumName, input, void 0);
1669
- }
1670
- function pgEnumWithSchema(enumName, values, schema) {
1671
- const enumInstance = Object.assign(
1672
- (name) => new PgEnumColumnBuilder(name ?? "", enumInstance),
1673
- {
1674
- enumName,
1675
- enumValues: values,
1676
- schema,
1677
- [isPgEnumSym]: true
1678
- }
1679
- );
1680
- return enumInstance;
1681
- }
1682
- function pgEnumObjectWithSchema(enumName, values, schema) {
1683
- const enumInstance = Object.assign(
1684
- (name) => new PgEnumObjectColumnBuilder(name ?? "", enumInstance),
1685
- {
1686
- enumName,
1687
- enumValues: Object.values(values),
1688
- schema,
1689
- [isPgEnumSym]: true
1690
- }
1691
- );
1692
- return enumInstance;
1693
- }
1694
-
1695
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/subquery.js
1696
- var Subquery = class {
1697
- static [entityKind] = "Subquery";
1698
- constructor(sql2, fields, alias, isWith = false, usedTables = []) {
1699
- this._ = {
1700
- brand: "Subquery",
1701
- sql: sql2,
1702
- selectedFields: fields,
1703
- alias,
1704
- isWith,
1705
- usedTables
1706
- };
1707
- }
1708
- // getSQL(): SQL<unknown> {
1709
- // return new SQL([this]);
1710
- // }
1711
- };
1712
- var WithSubquery = class extends Subquery {
1713
- static [entityKind] = "WithSubquery";
1714
- };
1715
-
1716
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/version.js
1717
- var version = "0.45.2";
1718
-
1719
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/tracing.js
1720
- var otel;
1721
- var rawTracer;
1722
- var tracer = {
1723
- startActiveSpan(name, fn) {
1724
- if (!otel) {
1725
- return fn();
1726
- }
1727
- if (!rawTracer) {
1728
- rawTracer = otel.trace.getTracer("drizzle-orm", version);
1729
- }
1730
- return iife(
1731
- (otel2, rawTracer2) => rawTracer2.startActiveSpan(
1732
- name,
1733
- (span) => {
1734
- try {
1735
- return fn(span);
1736
- } catch (e) {
1737
- span.setStatus({
1738
- code: otel2.SpanStatusCode.ERROR,
1739
- message: e instanceof Error ? e.message : "Unknown error"
1740
- // eslint-disable-line no-instanceof/no-instanceof
1741
- });
1742
- throw e;
1743
- } finally {
1744
- span.end();
1745
- }
1746
- }
1747
- ),
1748
- otel,
1749
- rawTracer
1750
- );
1751
- }
1752
- };
1753
-
1754
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/view-common.js
1755
- var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
1756
-
1757
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/table.js
1758
- var Schema = Symbol.for("drizzle:Schema");
1759
- var Columns = Symbol.for("drizzle:Columns");
1760
- var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
1761
- var OriginalName = Symbol.for("drizzle:OriginalName");
1762
- var BaseName = Symbol.for("drizzle:BaseName");
1763
- var IsAlias = Symbol.for("drizzle:IsAlias");
1764
- var ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
1765
- var IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
1766
- var Table = class {
1767
- static [entityKind] = "Table";
1768
- /** @internal */
1769
- static Symbol = {
1770
- Name: TableName,
1771
- Schema,
1772
- OriginalName,
1773
- Columns,
1774
- ExtraConfigColumns,
1775
- BaseName,
1776
- IsAlias,
1777
- ExtraConfigBuilder
1778
- };
1779
- /**
1780
- * @internal
1781
- * Can be changed if the table is aliased.
1782
- */
1783
- [TableName];
1784
- /**
1785
- * @internal
1786
- * Used to store the original name of the table, before any aliasing.
1787
- */
1788
- [OriginalName];
1789
- /** @internal */
1790
- [Schema];
1791
- /** @internal */
1792
- [Columns];
1793
- /** @internal */
1794
- [ExtraConfigColumns];
1795
- /**
1796
- * @internal
1797
- * Used to store the table name before the transformation via the `tableCreator` functions.
1798
- */
1799
- [BaseName];
1800
- /** @internal */
1801
- [IsAlias] = false;
1802
- /** @internal */
1803
- [IsDrizzleTable] = true;
1804
- /** @internal */
1805
- [ExtraConfigBuilder] = void 0;
1806
- constructor(name, schema, baseName) {
1807
- this[TableName] = this[OriginalName] = name;
1808
- this[Schema] = schema;
1809
- this[BaseName] = baseName;
1810
- }
1811
- };
1812
-
1813
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/sql/sql.js
1814
- var FakePrimitiveParam = class {
1815
- static [entityKind] = "FakePrimitiveParam";
1816
- };
1817
- function isSQLWrapper(value) {
1818
- return value !== null && value !== void 0 && typeof value.getSQL === "function";
1819
- }
1820
- function mergeQueries(queries) {
1821
- const result = { sql: "", params: [] };
1822
- for (const query of queries) {
1823
- result.sql += query.sql;
1824
- result.params.push(...query.params);
1825
- if (query.typings?.length) {
1826
- if (!result.typings) {
1827
- result.typings = [];
1828
- }
1829
- result.typings.push(...query.typings);
1830
- }
1831
- }
1832
- return result;
1833
- }
1834
- var StringChunk = class {
1835
- static [entityKind] = "StringChunk";
1836
- value;
1837
- constructor(value) {
1838
- this.value = Array.isArray(value) ? value : [value];
1839
- }
1840
- getSQL() {
1841
- return new SQL([this]);
1842
- }
1843
- };
1844
- var SQL = class _SQL {
1845
- constructor(queryChunks) {
1846
- this.queryChunks = queryChunks;
1847
- for (const chunk of queryChunks) {
1848
- if (is(chunk, Table)) {
1849
- const schemaName = chunk[Table.Symbol.Schema];
1850
- this.usedTables.push(
1851
- schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]
1852
- );
1853
- }
1854
- }
1855
- }
1856
- static [entityKind] = "SQL";
1857
- /** @internal */
1858
- decoder = noopDecoder;
1859
- shouldInlineParams = false;
1860
- /** @internal */
1861
- usedTables = [];
1862
- append(query) {
1863
- this.queryChunks.push(...query.queryChunks);
1864
- return this;
1865
- }
1866
- toQuery(config) {
1867
- return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
1868
- const query = this.buildQueryFromSourceParams(this.queryChunks, config);
1869
- span?.setAttributes({
1870
- "drizzle.query.text": query.sql,
1871
- "drizzle.query.params": JSON.stringify(query.params)
1872
- });
1873
- return query;
1874
- });
1875
- }
1876
- buildQueryFromSourceParams(chunks, _config) {
1877
- const config = Object.assign({}, _config, {
1878
- inlineParams: _config.inlineParams || this.shouldInlineParams,
1879
- paramStartIndex: _config.paramStartIndex || { value: 0 }
1880
- });
1881
- const {
1882
- casing,
1883
- escapeName,
1884
- escapeParam,
1885
- prepareTyping,
1886
- inlineParams,
1887
- paramStartIndex
1888
- } = config;
1889
- return mergeQueries(chunks.map((chunk) => {
1890
- if (is(chunk, StringChunk)) {
1891
- return { sql: chunk.value.join(""), params: [] };
1892
- }
1893
- if (is(chunk, Name)) {
1894
- return { sql: escapeName(chunk.value), params: [] };
1895
- }
1896
- if (chunk === void 0) {
1897
- return { sql: "", params: [] };
1898
- }
1899
- if (Array.isArray(chunk)) {
1900
- const result = [new StringChunk("(")];
1901
- for (const [i, p] of chunk.entries()) {
1902
- result.push(p);
1903
- if (i < chunk.length - 1) {
1904
- result.push(new StringChunk(", "));
1905
- }
1906
- }
1907
- result.push(new StringChunk(")"));
1908
- return this.buildQueryFromSourceParams(result, config);
1909
- }
1910
- if (is(chunk, _SQL)) {
1911
- return this.buildQueryFromSourceParams(chunk.queryChunks, {
1912
- ...config,
1913
- inlineParams: inlineParams || chunk.shouldInlineParams
1914
- });
1915
- }
1916
- if (is(chunk, Table)) {
1917
- const schemaName = chunk[Table.Symbol.Schema];
1918
- const tableName = chunk[Table.Symbol.Name];
1919
- return {
1920
- sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
1921
- params: []
1922
- };
1923
- }
1924
- if (is(chunk, Column)) {
1925
- const columnName = casing.getColumnCasing(chunk);
1926
- if (_config.invokeSource === "indexes") {
1927
- return { sql: escapeName(columnName), params: [] };
1928
- }
1929
- const schemaName = chunk.table[Table.Symbol.Schema];
1930
- return {
1931
- sql: chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
1932
- params: []
1933
- };
1934
- }
1935
- if (is(chunk, View)) {
1936
- const schemaName = chunk[ViewBaseConfig].schema;
1937
- const viewName = chunk[ViewBaseConfig].name;
1938
- return {
1939
- sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
1940
- params: []
1941
- };
1942
- }
1943
- if (is(chunk, Param)) {
1944
- if (is(chunk.value, Placeholder)) {
1945
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
1946
- }
1947
- const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
1948
- if (is(mappedValue, _SQL)) {
1949
- return this.buildQueryFromSourceParams([mappedValue], config);
1950
- }
1951
- if (inlineParams) {
1952
- return { sql: this.mapInlineParam(mappedValue, config), params: [] };
1953
- }
1954
- let typings = ["none"];
1955
- if (prepareTyping) {
1956
- typings = [prepareTyping(chunk.encoder)];
1957
- }
1958
- return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
1959
- }
1960
- if (is(chunk, Placeholder)) {
1961
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
1962
- }
1963
- if (is(chunk, _SQL.Aliased) && chunk.fieldAlias !== void 0) {
1964
- return { sql: escapeName(chunk.fieldAlias), params: [] };
1965
- }
1966
- if (is(chunk, Subquery)) {
1967
- if (chunk._.isWith) {
1968
- return { sql: escapeName(chunk._.alias), params: [] };
1969
- }
1970
- return this.buildQueryFromSourceParams([
1971
- new StringChunk("("),
1972
- chunk._.sql,
1973
- new StringChunk(") "),
1974
- new Name(chunk._.alias)
1975
- ], config);
1976
- }
1977
- if (isPgEnum(chunk)) {
1978
- if (chunk.schema) {
1979
- return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
1980
- }
1981
- return { sql: escapeName(chunk.enumName), params: [] };
1982
- }
1983
- if (isSQLWrapper(chunk)) {
1984
- if (chunk.shouldOmitSQLParens?.()) {
1985
- return this.buildQueryFromSourceParams([chunk.getSQL()], config);
1986
- }
1987
- return this.buildQueryFromSourceParams([
1988
- new StringChunk("("),
1989
- chunk.getSQL(),
1990
- new StringChunk(")")
1991
- ], config);
1992
- }
1993
- if (inlineParams) {
1994
- return { sql: this.mapInlineParam(chunk, config), params: [] };
1995
- }
1996
- return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
1997
- }));
1998
- }
1999
- mapInlineParam(chunk, { escapeString }) {
2000
- if (chunk === null) {
2001
- return "null";
2002
- }
2003
- if (typeof chunk === "number" || typeof chunk === "boolean") {
2004
- return chunk.toString();
2005
- }
2006
- if (typeof chunk === "string") {
2007
- return escapeString(chunk);
2008
- }
2009
- if (typeof chunk === "object") {
2010
- const mappedValueAsString = chunk.toString();
2011
- if (mappedValueAsString === "[object Object]") {
2012
- return escapeString(JSON.stringify(chunk));
2013
- }
2014
- return escapeString(mappedValueAsString);
2015
- }
2016
- throw new Error("Unexpected param value: " + chunk);
2017
- }
2018
- getSQL() {
2019
- return this;
2020
- }
2021
- as(alias) {
2022
- if (alias === void 0) {
2023
- return this;
2024
- }
2025
- return new _SQL.Aliased(this, alias);
2026
- }
2027
- mapWith(decoder) {
2028
- this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
2029
- return this;
2030
- }
2031
- inlineParams() {
2032
- this.shouldInlineParams = true;
2033
- return this;
2034
- }
2035
- /**
2036
- * This method is used to conditionally include a part of the query.
2037
- *
2038
- * @param condition - Condition to check
2039
- * @returns itself if the condition is `true`, otherwise `undefined`
2040
- */
2041
- if(condition) {
2042
- return condition ? this : void 0;
2043
- }
2044
- };
2045
- var Name = class {
2046
- constructor(value) {
2047
- this.value = value;
2048
- }
2049
- static [entityKind] = "Name";
2050
- brand;
2051
- getSQL() {
2052
- return new SQL([this]);
2053
- }
2054
- };
2055
- var noopDecoder = {
2056
- mapFromDriverValue: (value) => value
2057
- };
2058
- var noopEncoder = {
2059
- mapToDriverValue: (value) => value
2060
- };
2061
- var noopMapper = {
2062
- ...noopDecoder,
2063
- ...noopEncoder
2064
- };
2065
- var Param = class {
2066
- /**
2067
- * @param value - Parameter value
2068
- * @param encoder - Encoder to convert the value to a driver parameter
2069
- */
2070
- constructor(value, encoder = noopEncoder) {
2071
- this.value = value;
2072
- this.encoder = encoder;
2073
- }
2074
- static [entityKind] = "Param";
2075
- brand;
2076
- getSQL() {
2077
- return new SQL([this]);
2078
- }
2079
- };
2080
- function sql(strings, ...params) {
2081
- const queryChunks = [];
2082
- if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
2083
- queryChunks.push(new StringChunk(strings[0]));
2084
- }
2085
- for (const [paramIndex, param2] of params.entries()) {
2086
- queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
2087
- }
2088
- return new SQL(queryChunks);
2089
- }
2090
- ((sql2) => {
2091
- function empty() {
2092
- return new SQL([]);
2093
- }
2094
- sql2.empty = empty;
2095
- function fromList(list) {
2096
- return new SQL(list);
2097
- }
2098
- sql2.fromList = fromList;
2099
- function raw(str) {
2100
- return new SQL([new StringChunk(str)]);
2101
- }
2102
- sql2.raw = raw;
2103
- function join(chunks, separator) {
2104
- const result = [];
2105
- for (const [i, chunk] of chunks.entries()) {
2106
- if (i > 0 && separator !== void 0) {
2107
- result.push(separator);
2108
- }
2109
- result.push(chunk);
2110
- }
2111
- return new SQL(result);
2112
- }
2113
- sql2.join = join;
2114
- function identifier(value) {
2115
- return new Name(value);
2116
- }
2117
- sql2.identifier = identifier;
2118
- function placeholder2(name2) {
2119
- return new Placeholder(name2);
2120
- }
2121
- sql2.placeholder = placeholder2;
2122
- function param2(value, encoder) {
2123
- return new Param(value, encoder);
2124
- }
2125
- sql2.param = param2;
2126
- })(sql || (sql = {}));
2127
- ((SQL2) => {
2128
- class Aliased {
2129
- constructor(sql2, fieldAlias) {
2130
- this.sql = sql2;
2131
- this.fieldAlias = fieldAlias;
2132
- }
2133
- static [entityKind] = "SQL.Aliased";
2134
- /** @internal */
2135
- isSelectionField = false;
2136
- getSQL() {
2137
- return this.sql;
2138
- }
2139
- /** @internal */
2140
- clone() {
2141
- return new Aliased(this.sql, this.fieldAlias);
2142
- }
2143
- }
2144
- SQL2.Aliased = Aliased;
2145
- })(SQL || (SQL = {}));
2146
- var Placeholder = class {
2147
- constructor(name2) {
2148
- this.name = name2;
2149
- }
2150
- static [entityKind] = "Placeholder";
2151
- getSQL() {
2152
- return new SQL([this]);
2153
- }
2154
- };
2155
- var IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
2156
- var View = class {
2157
- static [entityKind] = "View";
2158
- /** @internal */
2159
- [ViewBaseConfig];
2160
- /** @internal */
2161
- [IsDrizzleView] = true;
2162
- constructor({ name: name2, schema, selectedFields, query }) {
2163
- this[ViewBaseConfig] = {
2164
- name: name2,
2165
- originalName: name2,
2166
- schema,
2167
- selectedFields,
2168
- query,
2169
- isExisting: !query,
2170
- isAlias: false
2171
- };
2172
- }
2173
- getSQL() {
2174
- return new SQL([this]);
2175
- }
2176
- };
2177
- Column.prototype.getSQL = function() {
2178
- return new SQL([this]);
2179
- };
2180
- Table.prototype.getSQL = function() {
2181
- return new SQL([this]);
2182
- };
2183
- Subquery.prototype.getSQL = function() {
2184
- return new SQL([this]);
2185
- };
2186
-
2187
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/utils.js
2188
- function getColumnNameAndConfig(a, b) {
2189
- return {
2190
- name: typeof a === "string" && a.length > 0 ? a : "",
2191
- config: typeof a === "object" ? a : b
2192
- };
2193
- }
2194
- var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder();
2195
-
2196
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/int.common.js
2197
- var PgIntColumnBaseBuilder = class extends PgColumnBuilder {
2198
- static [entityKind] = "PgIntColumnBaseBuilder";
2199
- generatedAlwaysAsIdentity(sequence) {
2200
- if (sequence) {
2201
- const { name, ...options } = sequence;
2202
- this.config.generatedIdentity = {
2203
- type: "always",
2204
- sequenceName: name,
2205
- sequenceOptions: options
2206
- };
2207
- } else {
2208
- this.config.generatedIdentity = {
2209
- type: "always"
2210
- };
2211
- }
2212
- this.config.hasDefault = true;
2213
- this.config.notNull = true;
2214
- return this;
2215
- }
2216
- generatedByDefaultAsIdentity(sequence) {
2217
- if (sequence) {
2218
- const { name, ...options } = sequence;
2219
- this.config.generatedIdentity = {
2220
- type: "byDefault",
2221
- sequenceName: name,
2222
- sequenceOptions: options
2223
- };
2224
- } else {
2225
- this.config.generatedIdentity = {
2226
- type: "byDefault"
2227
- };
2228
- }
2229
- this.config.hasDefault = true;
2230
- this.config.notNull = true;
2231
- return this;
2232
- }
2233
- };
2234
-
2235
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/bigint.js
2236
- var PgBigInt53Builder = class extends PgIntColumnBaseBuilder {
2237
- static [entityKind] = "PgBigInt53Builder";
2238
- constructor(name) {
2239
- super(name, "number", "PgBigInt53");
2240
- }
2241
- /** @internal */
2242
- build(table) {
2243
- return new PgBigInt53(table, this.config);
2244
- }
2245
- };
2246
- var PgBigInt53 = class extends PgColumn {
2247
- static [entityKind] = "PgBigInt53";
2248
- getSQLType() {
2249
- return "bigint";
2250
- }
2251
- mapFromDriverValue(value) {
2252
- if (typeof value === "number") {
2253
- return value;
2254
- }
2255
- return Number(value);
2256
- }
2257
- };
2258
- var PgBigInt64Builder = class extends PgIntColumnBaseBuilder {
2259
- static [entityKind] = "PgBigInt64Builder";
2260
- constructor(name) {
2261
- super(name, "bigint", "PgBigInt64");
2262
- }
2263
- /** @internal */
2264
- build(table) {
2265
- return new PgBigInt64(
2266
- table,
2267
- this.config
2268
- );
2269
- }
2270
- };
2271
- var PgBigInt64 = class extends PgColumn {
2272
- static [entityKind] = "PgBigInt64";
2273
- getSQLType() {
2274
- return "bigint";
2275
- }
2276
- // eslint-disable-next-line unicorn/prefer-native-coercion-functions
2277
- mapFromDriverValue(value) {
2278
- return BigInt(value);
2279
- }
2280
- };
2281
- function bigint(a, b) {
2282
- const { name, config } = getColumnNameAndConfig(a, b);
2283
- if (config.mode === "number") {
2284
- return new PgBigInt53Builder(name);
2285
- }
2286
- return new PgBigInt64Builder(name);
2287
- }
2288
-
2289
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/bigserial.js
2290
- var PgBigSerial53Builder = class extends PgColumnBuilder {
2291
- static [entityKind] = "PgBigSerial53Builder";
2292
- constructor(name) {
2293
- super(name, "number", "PgBigSerial53");
2294
- this.config.hasDefault = true;
2295
- this.config.notNull = true;
2296
- }
2297
- /** @internal */
2298
- build(table) {
2299
- return new PgBigSerial53(
2300
- table,
2301
- this.config
2302
- );
2303
- }
2304
- };
2305
- var PgBigSerial53 = class extends PgColumn {
2306
- static [entityKind] = "PgBigSerial53";
2307
- getSQLType() {
2308
- return "bigserial";
2309
- }
2310
- mapFromDriverValue(value) {
2311
- if (typeof value === "number") {
2312
- return value;
2313
- }
2314
- return Number(value);
2315
- }
2316
- };
2317
- var PgBigSerial64Builder = class extends PgColumnBuilder {
2318
- static [entityKind] = "PgBigSerial64Builder";
2319
- constructor(name) {
2320
- super(name, "bigint", "PgBigSerial64");
2321
- this.config.hasDefault = true;
2322
- }
2323
- /** @internal */
2324
- build(table) {
2325
- return new PgBigSerial64(
2326
- table,
2327
- this.config
2328
- );
2329
- }
2330
- };
2331
- var PgBigSerial64 = class extends PgColumn {
2332
- static [entityKind] = "PgBigSerial64";
2333
- getSQLType() {
2334
- return "bigserial";
2335
- }
2336
- // eslint-disable-next-line unicorn/prefer-native-coercion-functions
2337
- mapFromDriverValue(value) {
2338
- return BigInt(value);
2339
- }
2340
- };
2341
- function bigserial(a, b) {
2342
- const { name, config } = getColumnNameAndConfig(a, b);
2343
- if (config.mode === "number") {
2344
- return new PgBigSerial53Builder(name);
2345
- }
2346
- return new PgBigSerial64Builder(name);
2347
- }
2348
-
2349
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/boolean.js
2350
- var PgBooleanBuilder = class extends PgColumnBuilder {
2351
- static [entityKind] = "PgBooleanBuilder";
2352
- constructor(name) {
2353
- super(name, "boolean", "PgBoolean");
2354
- }
2355
- /** @internal */
2356
- build(table) {
2357
- return new PgBoolean(table, this.config);
2358
- }
2359
- };
2360
- var PgBoolean = class extends PgColumn {
2361
- static [entityKind] = "PgBoolean";
2362
- getSQLType() {
2363
- return "boolean";
2364
- }
2365
- };
2366
- function boolean(name) {
2367
- return new PgBooleanBuilder(name ?? "");
2368
- }
2369
-
2370
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/char.js
2371
- var PgCharBuilder = class extends PgColumnBuilder {
2372
- static [entityKind] = "PgCharBuilder";
2373
- constructor(name, config) {
2374
- super(name, "string", "PgChar");
2375
- this.config.length = config.length;
2376
- this.config.enumValues = config.enum;
2377
- }
2378
- /** @internal */
2379
- build(table) {
2380
- return new PgChar(
2381
- table,
2382
- this.config
2383
- );
2384
- }
2385
- };
2386
- var PgChar = class extends PgColumn {
2387
- static [entityKind] = "PgChar";
2388
- length = this.config.length;
2389
- enumValues = this.config.enumValues;
2390
- getSQLType() {
2391
- return this.length === void 0 ? `char` : `char(${this.length})`;
2392
- }
2393
- };
2394
- function char(a, b = {}) {
2395
- const { name, config } = getColumnNameAndConfig(a, b);
2396
- return new PgCharBuilder(name, config);
2397
- }
2398
-
2399
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/cidr.js
2400
- var PgCidrBuilder = class extends PgColumnBuilder {
2401
- static [entityKind] = "PgCidrBuilder";
2402
- constructor(name) {
2403
- super(name, "string", "PgCidr");
2404
- }
2405
- /** @internal */
2406
- build(table) {
2407
- return new PgCidr(table, this.config);
2408
- }
2409
- };
2410
- var PgCidr = class extends PgColumn {
2411
- static [entityKind] = "PgCidr";
2412
- getSQLType() {
2413
- return "cidr";
2414
- }
2415
- };
2416
- function cidr(name) {
2417
- return new PgCidrBuilder(name ?? "");
2418
- }
2419
-
2420
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/custom.js
2421
- var PgCustomColumnBuilder = class extends PgColumnBuilder {
2422
- static [entityKind] = "PgCustomColumnBuilder";
2423
- constructor(name, fieldConfig, customTypeParams) {
2424
- super(name, "custom", "PgCustomColumn");
2425
- this.config.fieldConfig = fieldConfig;
2426
- this.config.customTypeParams = customTypeParams;
2427
- }
2428
- /** @internal */
2429
- build(table) {
2430
- return new PgCustomColumn(
2431
- table,
2432
- this.config
2433
- );
2434
- }
2435
- };
2436
- var PgCustomColumn = class extends PgColumn {
2437
- static [entityKind] = "PgCustomColumn";
2438
- sqlName;
2439
- mapTo;
2440
- mapFrom;
2441
- constructor(table, config) {
2442
- super(table, config);
2443
- this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
2444
- this.mapTo = config.customTypeParams.toDriver;
2445
- this.mapFrom = config.customTypeParams.fromDriver;
2446
- }
2447
- getSQLType() {
2448
- return this.sqlName;
2449
- }
2450
- mapFromDriverValue(value) {
2451
- return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
2452
- }
2453
- mapToDriverValue(value) {
2454
- return typeof this.mapTo === "function" ? this.mapTo(value) : value;
2455
- }
2456
- };
2457
- function customType(customTypeParams) {
2458
- return (a, b) => {
2459
- const { name, config } = getColumnNameAndConfig(a, b);
2460
- return new PgCustomColumnBuilder(name, config, customTypeParams);
2461
- };
2462
- }
2463
-
2464
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/date.common.js
2465
- var PgDateColumnBaseBuilder = class extends PgColumnBuilder {
2466
- static [entityKind] = "PgDateColumnBaseBuilder";
2467
- defaultNow() {
2468
- return this.default(sql`now()`);
2469
- }
2470
- };
2471
-
2472
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/date.js
2473
- var PgDateBuilder = class extends PgDateColumnBaseBuilder {
2474
- static [entityKind] = "PgDateBuilder";
2475
- constructor(name) {
2476
- super(name, "date", "PgDate");
2477
- }
2478
- /** @internal */
2479
- build(table) {
2480
- return new PgDate(table, this.config);
2481
- }
2482
- };
2483
- var PgDate = class extends PgColumn {
2484
- static [entityKind] = "PgDate";
2485
- getSQLType() {
2486
- return "date";
2487
- }
2488
- mapFromDriverValue(value) {
2489
- if (typeof value === "string") return new Date(value);
2490
- return value;
2491
- }
2492
- mapToDriverValue(value) {
2493
- return value.toISOString();
2494
- }
2495
- };
2496
- var PgDateStringBuilder = class extends PgDateColumnBaseBuilder {
2497
- static [entityKind] = "PgDateStringBuilder";
2498
- constructor(name) {
2499
- super(name, "string", "PgDateString");
2500
- }
2501
- /** @internal */
2502
- build(table) {
2503
- return new PgDateString(
2504
- table,
2505
- this.config
2506
- );
2507
- }
2508
- };
2509
- var PgDateString = class extends PgColumn {
2510
- static [entityKind] = "PgDateString";
2511
- getSQLType() {
2512
- return "date";
2513
- }
2514
- mapFromDriverValue(value) {
2515
- if (typeof value === "string") return value;
2516
- return value.toISOString().slice(0, -14);
2517
- }
2518
- };
2519
- function date(a, b) {
2520
- const { name, config } = getColumnNameAndConfig(a, b);
2521
- if (config?.mode === "date") {
2522
- return new PgDateBuilder(name);
2523
- }
2524
- return new PgDateStringBuilder(name);
2525
- }
2526
-
2527
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/double-precision.js
2528
- var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
2529
- static [entityKind] = "PgDoublePrecisionBuilder";
2530
- constructor(name) {
2531
- super(name, "number", "PgDoublePrecision");
2532
- }
2533
- /** @internal */
2534
- build(table) {
2535
- return new PgDoublePrecision(
2536
- table,
2537
- this.config
2538
- );
2539
- }
2540
- };
2541
- var PgDoublePrecision = class extends PgColumn {
2542
- static [entityKind] = "PgDoublePrecision";
2543
- getSQLType() {
2544
- return "double precision";
2545
- }
2546
- mapFromDriverValue(value) {
2547
- if (typeof value === "string") {
2548
- return Number.parseFloat(value);
2549
- }
2550
- return value;
2551
- }
2552
- };
2553
- function doublePrecision(name) {
2554
- return new PgDoublePrecisionBuilder(name ?? "");
2555
- }
2556
-
2557
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/inet.js
2558
- var PgInetBuilder = class extends PgColumnBuilder {
2559
- static [entityKind] = "PgInetBuilder";
2560
- constructor(name) {
2561
- super(name, "string", "PgInet");
2562
- }
2563
- /** @internal */
2564
- build(table) {
2565
- return new PgInet(table, this.config);
2566
- }
2567
- };
2568
- var PgInet = class extends PgColumn {
2569
- static [entityKind] = "PgInet";
2570
- getSQLType() {
2571
- return "inet";
2572
- }
2573
- };
2574
- function inet(name) {
2575
- return new PgInetBuilder(name ?? "");
2576
- }
2577
-
2578
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/integer.js
2579
- var PgIntegerBuilder = class extends PgIntColumnBaseBuilder {
2580
- static [entityKind] = "PgIntegerBuilder";
2581
- constructor(name) {
2582
- super(name, "number", "PgInteger");
2583
- }
2584
- /** @internal */
2585
- build(table) {
2586
- return new PgInteger(table, this.config);
2587
- }
2588
- };
2589
- var PgInteger = class extends PgColumn {
2590
- static [entityKind] = "PgInteger";
2591
- getSQLType() {
2592
- return "integer";
2593
- }
2594
- mapFromDriverValue(value) {
2595
- if (typeof value === "string") {
2596
- return Number.parseInt(value);
2597
- }
2598
- return value;
2599
- }
2600
- };
2601
- function integer(name) {
2602
- return new PgIntegerBuilder(name ?? "");
2603
- }
2604
-
2605
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/interval.js
2606
- var PgIntervalBuilder = class extends PgColumnBuilder {
2607
- static [entityKind] = "PgIntervalBuilder";
2608
- constructor(name, intervalConfig) {
2609
- super(name, "string", "PgInterval");
2610
- this.config.intervalConfig = intervalConfig;
2611
- }
2612
- /** @internal */
2613
- build(table) {
2614
- return new PgInterval(table, this.config);
2615
- }
2616
- };
2617
- var PgInterval = class extends PgColumn {
2618
- static [entityKind] = "PgInterval";
2619
- fields = this.config.intervalConfig.fields;
2620
- precision = this.config.intervalConfig.precision;
2621
- getSQLType() {
2622
- const fields = this.fields ? ` ${this.fields}` : "";
2623
- const precision = this.precision ? `(${this.precision})` : "";
2624
- return `interval${fields}${precision}`;
2625
- }
2626
- };
2627
- function interval(a, b = {}) {
2628
- const { name, config } = getColumnNameAndConfig(a, b);
2629
- return new PgIntervalBuilder(name, config);
2630
- }
2631
-
2632
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/json.js
2633
- var PgJsonBuilder = class extends PgColumnBuilder {
2634
- static [entityKind] = "PgJsonBuilder";
2635
- constructor(name) {
2636
- super(name, "json", "PgJson");
2637
- }
2638
- /** @internal */
2639
- build(table) {
2640
- return new PgJson(table, this.config);
2641
- }
2642
- };
2643
- var PgJson = class extends PgColumn {
2644
- static [entityKind] = "PgJson";
2645
- constructor(table, config) {
2646
- super(table, config);
2647
- }
2648
- getSQLType() {
2649
- return "json";
2650
- }
2651
- mapToDriverValue(value) {
2652
- return JSON.stringify(value);
2653
- }
2654
- mapFromDriverValue(value) {
2655
- if (typeof value === "string") {
2656
- try {
2657
- return JSON.parse(value);
2658
- } catch {
2659
- return value;
2660
- }
2661
- }
2662
- return value;
2663
- }
2664
- };
2665
- function json(name) {
2666
- return new PgJsonBuilder(name ?? "");
2667
- }
2668
-
2669
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/jsonb.js
2670
- var PgJsonbBuilder = class extends PgColumnBuilder {
2671
- static [entityKind] = "PgJsonbBuilder";
2672
- constructor(name) {
2673
- super(name, "json", "PgJsonb");
2674
- }
2675
- /** @internal */
2676
- build(table) {
2677
- return new PgJsonb(table, this.config);
2678
- }
2679
- };
2680
- var PgJsonb = class extends PgColumn {
2681
- static [entityKind] = "PgJsonb";
2682
- constructor(table, config) {
2683
- super(table, config);
2684
- }
2685
- getSQLType() {
2686
- return "jsonb";
2687
- }
2688
- mapToDriverValue(value) {
2689
- return JSON.stringify(value);
2690
- }
2691
- mapFromDriverValue(value) {
2692
- if (typeof value === "string") {
2693
- try {
2694
- return JSON.parse(value);
2695
- } catch {
2696
- return value;
2697
- }
2698
- }
2699
- return value;
2700
- }
2701
- };
2702
- function jsonb(name) {
2703
- return new PgJsonbBuilder(name ?? "");
2704
- }
2705
-
2706
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/line.js
2707
- var PgLineBuilder = class extends PgColumnBuilder {
2708
- static [entityKind] = "PgLineBuilder";
2709
- constructor(name) {
2710
- super(name, "array", "PgLine");
2711
- }
2712
- /** @internal */
2713
- build(table) {
2714
- return new PgLineTuple(
2715
- table,
2716
- this.config
2717
- );
2718
- }
2719
- };
2720
- var PgLineTuple = class extends PgColumn {
2721
- static [entityKind] = "PgLine";
2722
- getSQLType() {
2723
- return "line";
2724
- }
2725
- mapFromDriverValue(value) {
2726
- const [a, b, c2] = value.slice(1, -1).split(",");
2727
- return [Number.parseFloat(a), Number.parseFloat(b), Number.parseFloat(c2)];
2728
- }
2729
- mapToDriverValue(value) {
2730
- return `{${value[0]},${value[1]},${value[2]}}`;
2731
- }
2732
- };
2733
- var PgLineABCBuilder = class extends PgColumnBuilder {
2734
- static [entityKind] = "PgLineABCBuilder";
2735
- constructor(name) {
2736
- super(name, "json", "PgLineABC");
2737
- }
2738
- /** @internal */
2739
- build(table) {
2740
- return new PgLineABC(
2741
- table,
2742
- this.config
2743
- );
2744
- }
2745
- };
2746
- var PgLineABC = class extends PgColumn {
2747
- static [entityKind] = "PgLineABC";
2748
- getSQLType() {
2749
- return "line";
2750
- }
2751
- mapFromDriverValue(value) {
2752
- const [a, b, c2] = value.slice(1, -1).split(",");
2753
- return { a: Number.parseFloat(a), b: Number.parseFloat(b), c: Number.parseFloat(c2) };
2754
- }
2755
- mapToDriverValue(value) {
2756
- return `{${value.a},${value.b},${value.c}}`;
2757
- }
2758
- };
2759
- function line(a, b) {
2760
- const { name, config } = getColumnNameAndConfig(a, b);
2761
- if (!config?.mode || config.mode === "tuple") {
2762
- return new PgLineBuilder(name);
2763
- }
2764
- return new PgLineABCBuilder(name);
2765
- }
2766
-
2767
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/macaddr.js
2768
- var PgMacaddrBuilder = class extends PgColumnBuilder {
2769
- static [entityKind] = "PgMacaddrBuilder";
2770
- constructor(name) {
2771
- super(name, "string", "PgMacaddr");
2772
- }
2773
- /** @internal */
2774
- build(table) {
2775
- return new PgMacaddr(table, this.config);
2776
- }
2777
- };
2778
- var PgMacaddr = class extends PgColumn {
2779
- static [entityKind] = "PgMacaddr";
2780
- getSQLType() {
2781
- return "macaddr";
2782
- }
2783
- };
2784
- function macaddr(name) {
2785
- return new PgMacaddrBuilder(name ?? "");
2786
- }
2787
-
2788
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/macaddr8.js
2789
- var PgMacaddr8Builder = class extends PgColumnBuilder {
2790
- static [entityKind] = "PgMacaddr8Builder";
2791
- constructor(name) {
2792
- super(name, "string", "PgMacaddr8");
2793
- }
2794
- /** @internal */
2795
- build(table) {
2796
- return new PgMacaddr8(table, this.config);
2797
- }
2798
- };
2799
- var PgMacaddr8 = class extends PgColumn {
2800
- static [entityKind] = "PgMacaddr8";
2801
- getSQLType() {
2802
- return "macaddr8";
2803
- }
2804
- };
2805
- function macaddr8(name) {
2806
- return new PgMacaddr8Builder(name ?? "");
2807
- }
2808
-
2809
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/numeric.js
2810
- var PgNumericBuilder = class extends PgColumnBuilder {
2811
- static [entityKind] = "PgNumericBuilder";
2812
- constructor(name, precision, scale) {
2813
- super(name, "string", "PgNumeric");
2814
- this.config.precision = precision;
2815
- this.config.scale = scale;
2816
- }
2817
- /** @internal */
2818
- build(table) {
2819
- return new PgNumeric(table, this.config);
2820
- }
2821
- };
2822
- var PgNumeric = class extends PgColumn {
2823
- static [entityKind] = "PgNumeric";
2824
- precision;
2825
- scale;
2826
- constructor(table, config) {
2827
- super(table, config);
2828
- this.precision = config.precision;
2829
- this.scale = config.scale;
2830
- }
2831
- mapFromDriverValue(value) {
2832
- if (typeof value === "string") return value;
2833
- return String(value);
2834
- }
2835
- getSQLType() {
2836
- if (this.precision !== void 0 && this.scale !== void 0) {
2837
- return `numeric(${this.precision}, ${this.scale})`;
2838
- } else if (this.precision === void 0) {
2839
- return "numeric";
2840
- } else {
2841
- return `numeric(${this.precision})`;
2842
- }
2843
- }
2844
- };
2845
- var PgNumericNumberBuilder = class extends PgColumnBuilder {
2846
- static [entityKind] = "PgNumericNumberBuilder";
2847
- constructor(name, precision, scale) {
2848
- super(name, "number", "PgNumericNumber");
2849
- this.config.precision = precision;
2850
- this.config.scale = scale;
2851
- }
2852
- /** @internal */
2853
- build(table) {
2854
- return new PgNumericNumber(
2855
- table,
2856
- this.config
2857
- );
2858
- }
2859
- };
2860
- var PgNumericNumber = class extends PgColumn {
2861
- static [entityKind] = "PgNumericNumber";
2862
- precision;
2863
- scale;
2864
- constructor(table, config) {
2865
- super(table, config);
2866
- this.precision = config.precision;
2867
- this.scale = config.scale;
2868
- }
2869
- mapFromDriverValue(value) {
2870
- if (typeof value === "number") return value;
2871
- return Number(value);
2872
- }
2873
- mapToDriverValue = String;
2874
- getSQLType() {
2875
- if (this.precision !== void 0 && this.scale !== void 0) {
2876
- return `numeric(${this.precision}, ${this.scale})`;
2877
- } else if (this.precision === void 0) {
2878
- return "numeric";
2879
- } else {
2880
- return `numeric(${this.precision})`;
2881
- }
2882
- }
2883
- };
2884
- var PgNumericBigIntBuilder = class extends PgColumnBuilder {
2885
- static [entityKind] = "PgNumericBigIntBuilder";
2886
- constructor(name, precision, scale) {
2887
- super(name, "bigint", "PgNumericBigInt");
2888
- this.config.precision = precision;
2889
- this.config.scale = scale;
2890
- }
2891
- /** @internal */
2892
- build(table) {
2893
- return new PgNumericBigInt(
2894
- table,
2895
- this.config
2896
- );
2897
- }
2898
- };
2899
- var PgNumericBigInt = class extends PgColumn {
2900
- static [entityKind] = "PgNumericBigInt";
2901
- precision;
2902
- scale;
2903
- constructor(table, config) {
2904
- super(table, config);
2905
- this.precision = config.precision;
2906
- this.scale = config.scale;
2907
- }
2908
- mapFromDriverValue = BigInt;
2909
- mapToDriverValue = String;
2910
- getSQLType() {
2911
- if (this.precision !== void 0 && this.scale !== void 0) {
2912
- return `numeric(${this.precision}, ${this.scale})`;
2913
- } else if (this.precision === void 0) {
2914
- return "numeric";
2915
- } else {
2916
- return `numeric(${this.precision})`;
2917
- }
2918
- }
2919
- };
2920
- function numeric(a, b) {
2921
- const { name, config } = getColumnNameAndConfig(a, b);
2922
- const mode = config?.mode;
2923
- return mode === "number" ? new PgNumericNumberBuilder(name, config?.precision, config?.scale) : mode === "bigint" ? new PgNumericBigIntBuilder(name, config?.precision, config?.scale) : new PgNumericBuilder(name, config?.precision, config?.scale);
2924
- }
2925
-
2926
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/point.js
2927
- var PgPointTupleBuilder = class extends PgColumnBuilder {
2928
- static [entityKind] = "PgPointTupleBuilder";
2929
- constructor(name) {
2930
- super(name, "array", "PgPointTuple");
2931
- }
2932
- /** @internal */
2933
- build(table) {
2934
- return new PgPointTuple(
2935
- table,
2936
- this.config
2937
- );
2938
- }
2939
- };
2940
- var PgPointTuple = class extends PgColumn {
2941
- static [entityKind] = "PgPointTuple";
2942
- getSQLType() {
2943
- return "point";
2944
- }
2945
- mapFromDriverValue(value) {
2946
- if (typeof value === "string") {
2947
- const [x, y] = value.slice(1, -1).split(",");
2948
- return [Number.parseFloat(x), Number.parseFloat(y)];
2949
- }
2950
- return [value.x, value.y];
2951
- }
2952
- mapToDriverValue(value) {
2953
- return `(${value[0]},${value[1]})`;
2954
- }
2955
- };
2956
- var PgPointObjectBuilder = class extends PgColumnBuilder {
2957
- static [entityKind] = "PgPointObjectBuilder";
2958
- constructor(name) {
2959
- super(name, "json", "PgPointObject");
2960
- }
2961
- /** @internal */
2962
- build(table) {
2963
- return new PgPointObject(
2964
- table,
2965
- this.config
2966
- );
2967
- }
2968
- };
2969
- var PgPointObject = class extends PgColumn {
2970
- static [entityKind] = "PgPointObject";
2971
- getSQLType() {
2972
- return "point";
2973
- }
2974
- mapFromDriverValue(value) {
2975
- if (typeof value === "string") {
2976
- const [x, y] = value.slice(1, -1).split(",");
2977
- return { x: Number.parseFloat(x), y: Number.parseFloat(y) };
2978
- }
2979
- return value;
2980
- }
2981
- mapToDriverValue(value) {
2982
- return `(${value.x},${value.y})`;
2983
- }
2984
- };
2985
- function point(a, b) {
2986
- const { name, config } = getColumnNameAndConfig(a, b);
2987
- if (!config?.mode || config.mode === "tuple") {
2988
- return new PgPointTupleBuilder(name);
2989
- }
2990
- return new PgPointObjectBuilder(name);
2991
- }
2992
-
2993
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
2994
- function hexToBytes(hex) {
2995
- const bytes = [];
2996
- for (let c2 = 0; c2 < hex.length; c2 += 2) {
2997
- bytes.push(Number.parseInt(hex.slice(c2, c2 + 2), 16));
2998
- }
2999
- return new Uint8Array(bytes);
3000
- }
3001
- function bytesToFloat64(bytes, offset) {
3002
- const buffer = new ArrayBuffer(8);
3003
- const view = new DataView(buffer);
3004
- for (let i = 0; i < 8; i++) {
3005
- view.setUint8(i, bytes[offset + i]);
3006
- }
3007
- return view.getFloat64(0, true);
3008
- }
3009
- function parseEWKB(hex) {
3010
- const bytes = hexToBytes(hex);
3011
- let offset = 0;
3012
- const byteOrder = bytes[offset];
3013
- offset += 1;
3014
- const view = new DataView(bytes.buffer);
3015
- const geomType = view.getUint32(offset, byteOrder === 1);
3016
- offset += 4;
3017
- let _srid;
3018
- if (geomType & 536870912) {
3019
- _srid = view.getUint32(offset, byteOrder === 1);
3020
- offset += 4;
3021
- }
3022
- if ((geomType & 65535) === 1) {
3023
- const x = bytesToFloat64(bytes, offset);
3024
- offset += 8;
3025
- const y = bytesToFloat64(bytes, offset);
3026
- offset += 8;
3027
- return [x, y];
3028
- }
3029
- throw new Error("Unsupported geometry type");
3030
- }
3031
-
3032
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
3033
- var PgGeometryBuilder = class extends PgColumnBuilder {
3034
- static [entityKind] = "PgGeometryBuilder";
3035
- constructor(name) {
3036
- super(name, "array", "PgGeometry");
3037
- }
3038
- /** @internal */
3039
- build(table) {
3040
- return new PgGeometry(
3041
- table,
3042
- this.config
3043
- );
3044
- }
3045
- };
3046
- var PgGeometry = class extends PgColumn {
3047
- static [entityKind] = "PgGeometry";
3048
- getSQLType() {
3049
- return "geometry(point)";
3050
- }
3051
- mapFromDriverValue(value) {
3052
- return parseEWKB(value);
3053
- }
3054
- mapToDriverValue(value) {
3055
- return `point(${value[0]} ${value[1]})`;
3056
- }
3057
- };
3058
- var PgGeometryObjectBuilder = class extends PgColumnBuilder {
3059
- static [entityKind] = "PgGeometryObjectBuilder";
3060
- constructor(name) {
3061
- super(name, "json", "PgGeometryObject");
3062
- }
3063
- /** @internal */
3064
- build(table) {
3065
- return new PgGeometryObject(
3066
- table,
3067
- this.config
3068
- );
3069
- }
3070
- };
3071
- var PgGeometryObject = class extends PgColumn {
3072
- static [entityKind] = "PgGeometryObject";
3073
- getSQLType() {
3074
- return "geometry(point)";
3075
- }
3076
- mapFromDriverValue(value) {
3077
- const parsed = parseEWKB(value);
3078
- return { x: parsed[0], y: parsed[1] };
3079
- }
3080
- mapToDriverValue(value) {
3081
- return `point(${value.x} ${value.y})`;
3082
- }
3083
- };
3084
- function geometry(a, b) {
3085
- const { name, config } = getColumnNameAndConfig(a, b);
3086
- if (!config?.mode || config.mode === "tuple") {
3087
- return new PgGeometryBuilder(name);
3088
- }
3089
- return new PgGeometryObjectBuilder(name);
3090
- }
3091
-
3092
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/real.js
3093
- var PgRealBuilder = class extends PgColumnBuilder {
3094
- static [entityKind] = "PgRealBuilder";
3095
- constructor(name, length) {
3096
- super(name, "number", "PgReal");
3097
- this.config.length = length;
3098
- }
3099
- /** @internal */
3100
- build(table) {
3101
- return new PgReal(table, this.config);
3102
- }
3103
- };
3104
- var PgReal = class extends PgColumn {
3105
- static [entityKind] = "PgReal";
3106
- constructor(table, config) {
3107
- super(table, config);
3108
- }
3109
- getSQLType() {
3110
- return "real";
3111
- }
3112
- mapFromDriverValue = (value) => {
3113
- if (typeof value === "string") {
3114
- return Number.parseFloat(value);
3115
- }
3116
- return value;
3117
- };
3118
- };
3119
- function real(name) {
3120
- return new PgRealBuilder(name ?? "");
3121
- }
3122
-
3123
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/serial.js
3124
- var PgSerialBuilder = class extends PgColumnBuilder {
3125
- static [entityKind] = "PgSerialBuilder";
3126
- constructor(name) {
3127
- super(name, "number", "PgSerial");
3128
- this.config.hasDefault = true;
3129
- this.config.notNull = true;
3130
- }
3131
- /** @internal */
3132
- build(table) {
3133
- return new PgSerial(table, this.config);
3134
- }
3135
- };
3136
- var PgSerial = class extends PgColumn {
3137
- static [entityKind] = "PgSerial";
3138
- getSQLType() {
3139
- return "serial";
3140
- }
3141
- };
3142
- function serial(name) {
3143
- return new PgSerialBuilder(name ?? "");
3144
- }
3145
-
3146
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/smallint.js
3147
- var PgSmallIntBuilder = class extends PgIntColumnBaseBuilder {
3148
- static [entityKind] = "PgSmallIntBuilder";
3149
- constructor(name) {
3150
- super(name, "number", "PgSmallInt");
3151
- }
3152
- /** @internal */
3153
- build(table) {
3154
- return new PgSmallInt(table, this.config);
3155
- }
3156
- };
3157
- var PgSmallInt = class extends PgColumn {
3158
- static [entityKind] = "PgSmallInt";
3159
- getSQLType() {
3160
- return "smallint";
3161
- }
3162
- mapFromDriverValue = (value) => {
3163
- if (typeof value === "string") {
3164
- return Number(value);
3165
- }
3166
- return value;
3167
- };
3168
- };
3169
- function smallint(name) {
3170
- return new PgSmallIntBuilder(name ?? "");
3171
- }
3172
-
3173
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/smallserial.js
3174
- var PgSmallSerialBuilder = class extends PgColumnBuilder {
3175
- static [entityKind] = "PgSmallSerialBuilder";
3176
- constructor(name) {
3177
- super(name, "number", "PgSmallSerial");
3178
- this.config.hasDefault = true;
3179
- this.config.notNull = true;
3180
- }
3181
- /** @internal */
3182
- build(table) {
3183
- return new PgSmallSerial(
3184
- table,
3185
- this.config
3186
- );
3187
- }
3188
- };
3189
- var PgSmallSerial = class extends PgColumn {
3190
- static [entityKind] = "PgSmallSerial";
3191
- getSQLType() {
3192
- return "smallserial";
3193
- }
3194
- };
3195
- function smallserial(name) {
3196
- return new PgSmallSerialBuilder(name ?? "");
3197
- }
3198
-
3199
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/text.js
3200
- var PgTextBuilder = class extends PgColumnBuilder {
3201
- static [entityKind] = "PgTextBuilder";
3202
- constructor(name, config) {
3203
- super(name, "string", "PgText");
3204
- this.config.enumValues = config.enum;
3205
- }
3206
- /** @internal */
3207
- build(table) {
3208
- return new PgText(table, this.config);
3209
- }
3210
- };
3211
- var PgText = class extends PgColumn {
3212
- static [entityKind] = "PgText";
3213
- enumValues = this.config.enumValues;
3214
- getSQLType() {
3215
- return "text";
3216
- }
3217
- };
3218
- function text(a, b = {}) {
3219
- const { name, config } = getColumnNameAndConfig(a, b);
3220
- return new PgTextBuilder(name, config);
223
+ resolve(key);
224
+ } else {
225
+ res.writeHead(400);
226
+ res.end("Missing key parameter");
227
+ }
228
+ });
229
+ server.listen(0, "127.0.0.1", () => {
230
+ const addr = server.address();
231
+ if (!addr || typeof addr === "string") {
232
+ reject(new Error("Failed to start callback server"));
233
+ return;
234
+ }
235
+ const callbackPort = addr.port;
236
+ const authUrl = `${baseUrl}/api/auth/cli?callback=http://127.0.0.1:${callbackPort}`;
237
+ openBrowser(authUrl);
238
+ });
239
+ setTimeout(() => {
240
+ server.close();
241
+ reject(new Error("Authentication timed out"));
242
+ }, 12e4);
243
+ });
244
+ check("Authenticated with Basestream");
245
+ return apiKey;
3221
246
  }
3222
247
 
3223
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/time.js
3224
- var PgTimeBuilder = class extends PgDateColumnBaseBuilder {
3225
- constructor(name, withTimezone, precision) {
3226
- super(name, "string", "PgTime");
3227
- this.withTimezone = withTimezone;
3228
- this.precision = precision;
3229
- this.config.withTimezone = withTimezone;
3230
- this.config.precision = precision;
3231
- }
3232
- static [entityKind] = "PgTimeBuilder";
3233
- /** @internal */
3234
- build(table) {
3235
- return new PgTime(table, this.config);
3236
- }
3237
- };
3238
- var PgTime = class extends PgColumn {
3239
- static [entityKind] = "PgTime";
3240
- withTimezone;
3241
- precision;
3242
- constructor(table, config) {
3243
- super(table, config);
3244
- this.withTimezone = config.withTimezone;
3245
- this.precision = config.precision;
3246
- }
3247
- getSQLType() {
3248
- const precision = this.precision === void 0 ? "" : `(${this.precision})`;
3249
- return `time${precision}${this.withTimezone ? " with time zone" : ""}`;
3250
- }
3251
- };
3252
- function time(a, b = {}) {
3253
- const { name, config } = getColumnNameAndConfig(a, b);
3254
- return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
3255
- }
248
+ // src/cli/commands/init.ts
249
+ var CLAUDE_DIR = path2.join(os2.homedir(), ".claude");
250
+ var CLAUDE_SETTINGS_PATH = path2.join(CLAUDE_DIR, "settings.json");
251
+ var CLAUDE_SKILLS_PATH = path2.join(CLAUDE_DIR, "skills", "bs-summarize.md");
252
+ var CLAUDE_MD_PATH = path2.join(CLAUDE_DIR, "CLAUDE.md");
253
+ var HOOK_COMMAND = "npx @basestream/cli _hook-stop";
254
+ var HOOK_MARKER = "_hook-stop";
255
+ var CLAUDE_MD_MARKER = "<!-- basestream -->";
256
+ var CLAUDE_MD_RULE = `${CLAUDE_MD_MARKER}
257
+ - Before starting any non-trivial task, if the reason or context behind the work isn't already clear, ask: "What's the context for this?" Skip this for small tasks, typo fixes, or anything self-explanatory.
258
+ - After completing any meaningful work (fixing a bug, implementing a feature, making a significant change), invoke /bs-summarize to keep the session summary up to date. Include the "why" if it was provided.
259
+ <!-- /basestream -->`;
260
+ var SKILL_CONTENT = `---
261
+ name: bs-summarize
262
+ description: Update the Basestream session summary with what's been accomplished so far
263
+ ---
3256
264
 
3257
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/timestamp.js
3258
- var PgTimestampBuilder = class extends PgDateColumnBaseBuilder {
3259
- static [entityKind] = "PgTimestampBuilder";
3260
- constructor(name, withTimezone, precision) {
3261
- super(name, "date", "PgTimestamp");
3262
- this.config.withTimezone = withTimezone;
3263
- this.config.precision = precision;
3264
- }
3265
- /** @internal */
3266
- build(table) {
3267
- return new PgTimestamp(table, this.config);
3268
- }
3269
- };
3270
- var PgTimestamp = class extends PgColumn {
3271
- static [entityKind] = "PgTimestamp";
3272
- withTimezone;
3273
- precision;
3274
- constructor(table, config) {
3275
- super(table, config);
3276
- this.withTimezone = config.withTimezone;
3277
- this.precision = config.precision;
3278
- }
3279
- getSQLType() {
3280
- const precision = this.precision === void 0 ? "" : ` (${this.precision})`;
3281
- return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
3282
- }
3283
- mapFromDriverValue(value) {
3284
- if (typeof value === "string") return new Date(this.withTimezone ? value : value + "+0000");
3285
- return value;
3286
- }
3287
- mapToDriverValue = (value) => {
3288
- return value.toISOString();
3289
- };
3290
- };
3291
- var PgTimestampStringBuilder = class extends PgDateColumnBaseBuilder {
3292
- static [entityKind] = "PgTimestampStringBuilder";
3293
- constructor(name, withTimezone, precision) {
3294
- super(name, "string", "PgTimestampString");
3295
- this.config.withTimezone = withTimezone;
3296
- this.config.precision = precision;
3297
- }
3298
- /** @internal */
3299
- build(table) {
3300
- return new PgTimestampString(
3301
- table,
3302
- this.config
3303
- );
3304
- }
3305
- };
3306
- var PgTimestampString = class extends PgColumn {
3307
- static [entityKind] = "PgTimestampString";
3308
- withTimezone;
3309
- precision;
3310
- constructor(table, config) {
3311
- super(table, config);
3312
- this.withTimezone = config.withTimezone;
3313
- this.precision = config.precision;
3314
- }
3315
- getSQLType() {
3316
- const precision = this.precision === void 0 ? "" : `(${this.precision})`;
3317
- return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
3318
- }
3319
- mapFromDriverValue(value) {
3320
- if (typeof value === "string") return value;
3321
- const shortened = value.toISOString().slice(0, -1).replace("T", " ");
3322
- if (this.withTimezone) {
3323
- const offset = value.getTimezoneOffset();
3324
- const sign = offset <= 0 ? "+" : "-";
3325
- return `${shortened}${sign}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
3326
- }
3327
- return shortened;
3328
- }
3329
- };
3330
- function timestamp(a, b = {}) {
3331
- const { name, config } = getColumnNameAndConfig(a, b);
3332
- if (config?.mode === "string") {
3333
- return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
3334
- }
3335
- return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
3336
- }
265
+ First, read the existing summary file at \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\` if it exists \u2014 this is the running record of work done so far this session.
3337
266
 
3338
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/uuid.js
3339
- var PgUUIDBuilder = class extends PgColumnBuilder {
3340
- static [entityKind] = "PgUUIDBuilder";
3341
- constructor(name) {
3342
- super(name, "string", "PgUUID");
3343
- }
3344
- /**
3345
- * Adds `default gen_random_uuid()` to the column definition.
3346
- */
3347
- defaultRandom() {
3348
- return this.default(sql`gen_random_uuid()`);
3349
- }
3350
- /** @internal */
3351
- build(table) {
3352
- return new PgUUID(table, this.config);
3353
- }
3354
- };
3355
- var PgUUID = class extends PgColumn {
3356
- static [entityKind] = "PgUUID";
3357
- getSQLType() {
3358
- return "uuid";
3359
- }
3360
- };
3361
- function uuid(name) {
3362
- return new PgUUIDBuilder(name ?? "");
3363
- }
267
+ Then write an updated summary that aggregates the previous summary with everything that has happened since. Focus on:
268
+ - Why the work was done (if context was provided \u2014 skip if not known)
269
+ - What was built, fixed, or changed (be specific about features/bugs)
270
+ - Which parts of the codebase were touched
271
+ - Any key decisions made
3364
272
 
3365
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/varchar.js
3366
- var PgVarcharBuilder = class extends PgColumnBuilder {
3367
- static [entityKind] = "PgVarcharBuilder";
3368
- constructor(name, config) {
3369
- super(name, "string", "PgVarchar");
3370
- this.config.length = config.length;
3371
- this.config.enumValues = config.enum;
3372
- }
3373
- /** @internal */
3374
- build(table) {
3375
- return new PgVarchar(
3376
- table,
3377
- this.config
3378
- );
3379
- }
3380
- };
3381
- var PgVarchar = class extends PgColumn {
3382
- static [entityKind] = "PgVarchar";
3383
- length = this.config.length;
3384
- enumValues = this.config.enumValues;
3385
- getSQLType() {
3386
- return this.length === void 0 ? `varchar` : `varchar(${this.length})`;
3387
- }
3388
- };
3389
- function varchar(a, b = {}) {
3390
- const { name, config } = getColumnNameAndConfig(a, b);
3391
- return new PgVarcharBuilder(name, config);
3392
- }
273
+ Do not just append \u2014 synthesize everything into a single cohesive summary. Merge related work together, avoid repeating the same point twice, and drop anything superseded by later changes. Be concise \u2014 let the scope of the work determine the length. A small fix deserves one sentence; a large multi-part session can be a short paragraph. Plain prose, no bullet points.
3393
274
 
3394
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
3395
- var PgBinaryVectorBuilder = class extends PgColumnBuilder {
3396
- static [entityKind] = "PgBinaryVectorBuilder";
3397
- constructor(name, config) {
3398
- super(name, "string", "PgBinaryVector");
3399
- this.config.dimensions = config.dimensions;
3400
- }
3401
- /** @internal */
3402
- build(table) {
3403
- return new PgBinaryVector(
3404
- table,
3405
- this.config
3406
- );
3407
- }
3408
- };
3409
- var PgBinaryVector = class extends PgColumn {
3410
- static [entityKind] = "PgBinaryVector";
3411
- dimensions = this.config.dimensions;
3412
- getSQLType() {
3413
- return `bit(${this.dimensions})`;
275
+ Write the result to \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\`, overwriting the file.
276
+ `;
277
+ function injectClaudeMdRule() {
278
+ let existing = "";
279
+ if (fs2.existsSync(CLAUDE_MD_PATH)) {
280
+ existing = fs2.readFileSync(CLAUDE_MD_PATH, "utf-8");
3414
281
  }
3415
- };
3416
- function bit(a, b) {
3417
- const { name, config } = getColumnNameAndConfig(a, b);
3418
- return new PgBinaryVectorBuilder(name, config);
3419
- }
282
+ let updated;
283
+ if (existing.includes(CLAUDE_MD_MARKER)) {
284
+ updated = existing.replace(/<!-- basestream -->[\s\S]*?<!-- \/basestream -->/, CLAUDE_MD_RULE);
285
+ fs2.writeFileSync(CLAUDE_MD_PATH, updated);
286
+ check("Updated Basestream rules in ~/.claude/CLAUDE.md");
287
+ } else {
288
+ updated = existing ? `${existing.trimEnd()}
3420
289
 
3421
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
3422
- var PgHalfVectorBuilder = class extends PgColumnBuilder {
3423
- static [entityKind] = "PgHalfVectorBuilder";
3424
- constructor(name, config) {
3425
- super(name, "array", "PgHalfVector");
3426
- this.config.dimensions = config.dimensions;
3427
- }
3428
- /** @internal */
3429
- build(table) {
3430
- return new PgHalfVector(
3431
- table,
3432
- this.config
3433
- );
3434
- }
3435
- };
3436
- var PgHalfVector = class extends PgColumn {
3437
- static [entityKind] = "PgHalfVector";
3438
- dimensions = this.config.dimensions;
3439
- getSQLType() {
3440
- return `halfvec(${this.dimensions})`;
3441
- }
3442
- mapToDriverValue(value) {
3443
- return JSON.stringify(value);
3444
- }
3445
- mapFromDriverValue(value) {
3446
- return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
290
+ ${CLAUDE_MD_RULE}
291
+ ` : `${CLAUDE_MD_RULE}
292
+ `;
293
+ fs2.mkdirSync(CLAUDE_DIR, { recursive: true });
294
+ fs2.writeFileSync(CLAUDE_MD_PATH, updated);
295
+ check("Injected Basestream rules into ~/.claude/CLAUDE.md");
3447
296
  }
3448
- };
3449
- function halfvec(a, b) {
3450
- const { name, config } = getColumnNameAndConfig(a, b);
3451
- return new PgHalfVectorBuilder(name, config);
3452
297
  }
3453
-
3454
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
3455
- var PgSparseVectorBuilder = class extends PgColumnBuilder {
3456
- static [entityKind] = "PgSparseVectorBuilder";
3457
- constructor(name, config) {
3458
- super(name, "string", "PgSparseVector");
3459
- this.config.dimensions = config.dimensions;
3460
- }
3461
- /** @internal */
3462
- build(table) {
3463
- return new PgSparseVector(
3464
- table,
3465
- this.config
3466
- );
3467
- }
3468
- };
3469
- var PgSparseVector = class extends PgColumn {
3470
- static [entityKind] = "PgSparseVector";
3471
- dimensions = this.config.dimensions;
3472
- getSQLType() {
3473
- return `sparsevec(${this.dimensions})`;
3474
- }
3475
- };
3476
- function sparsevec(a, b) {
3477
- const { name, config } = getColumnNameAndConfig(a, b);
3478
- return new PgSparseVectorBuilder(name, config);
298
+ function installSkill() {
299
+ const skillsDir = path2.dirname(CLAUDE_SKILLS_PATH);
300
+ fs2.mkdirSync(skillsDir, { recursive: true });
301
+ fs2.writeFileSync(CLAUDE_SKILLS_PATH, SKILL_CONTENT);
302
+ check("Installed /bs-summarize skill into ~/.claude/skills/");
3479
303
  }
3480
-
3481
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
3482
- var PgVectorBuilder = class extends PgColumnBuilder {
3483
- static [entityKind] = "PgVectorBuilder";
3484
- constructor(name, config) {
3485
- super(name, "array", "PgVector");
3486
- this.config.dimensions = config.dimensions;
3487
- }
3488
- /** @internal */
3489
- build(table) {
3490
- return new PgVector(
3491
- table,
3492
- this.config
3493
- );
3494
- }
3495
- };
3496
- var PgVector = class extends PgColumn {
3497
- static [entityKind] = "PgVector";
3498
- dimensions = this.config.dimensions;
3499
- getSQLType() {
3500
- return `vector(${this.dimensions})`;
3501
- }
3502
- mapToDriverValue(value) {
3503
- return JSON.stringify(value);
3504
- }
3505
- mapFromDriverValue(value) {
3506
- return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
304
+ function detectClaudeCode() {
305
+ try {
306
+ const version = execSync2("claude --version 2>/dev/null", {
307
+ encoding: "utf-8"
308
+ }).trim();
309
+ return version || null;
310
+ } catch {
311
+ return null;
3507
312
  }
3508
- };
3509
- function vector(a, b) {
3510
- const { name, config } = getColumnNameAndConfig(a, b);
3511
- return new PgVectorBuilder(name, config);
3512
313
  }
3513
-
3514
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/columns/all.js
3515
- function getPgColumnBuilders() {
3516
- return {
3517
- bigint,
3518
- bigserial,
3519
- boolean,
3520
- char,
3521
- cidr,
3522
- customType,
3523
- date,
3524
- doublePrecision,
3525
- inet,
3526
- integer,
3527
- interval,
3528
- json,
3529
- jsonb,
3530
- line,
3531
- macaddr,
3532
- macaddr8,
3533
- numeric,
3534
- point,
3535
- geometry,
3536
- real,
3537
- serial,
3538
- smallint,
3539
- smallserial,
3540
- text,
3541
- time,
3542
- timestamp,
3543
- uuid,
3544
- varchar,
3545
- bit,
3546
- halfvec,
3547
- sparsevec,
3548
- vector
3549
- };
3550
- }
3551
-
3552
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/table.js
3553
- var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
3554
- var EnableRLS = Symbol.for("drizzle:EnableRLS");
3555
- var PgTable = class extends Table {
3556
- static [entityKind] = "PgTable";
3557
- /** @internal */
3558
- static Symbol = Object.assign({}, Table.Symbol, {
3559
- InlineForeignKeys,
3560
- EnableRLS
3561
- });
3562
- /**@internal */
3563
- [InlineForeignKeys] = [];
3564
- /** @internal */
3565
- [EnableRLS] = false;
3566
- /** @internal */
3567
- [Table.Symbol.ExtraConfigBuilder] = void 0;
3568
- /** @internal */
3569
- [Table.Symbol.ExtraConfigColumns] = {};
3570
- };
3571
- function pgTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
3572
- const rawTable = new PgTable(name, schema, baseName);
3573
- const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
3574
- const builtColumns = Object.fromEntries(
3575
- Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
3576
- const colBuilder = colBuilderBase;
3577
- colBuilder.setName(name2);
3578
- const column = colBuilder.build(rawTable);
3579
- rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
3580
- return [name2, column];
3581
- })
3582
- );
3583
- const builtColumnsForExtraConfig = Object.fromEntries(
3584
- Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
3585
- const colBuilder = colBuilderBase;
3586
- colBuilder.setName(name2);
3587
- const column = colBuilder.buildExtraConfigColumn(rawTable);
3588
- return [name2, column];
3589
- })
3590
- );
3591
- const table = Object.assign(rawTable, builtColumns);
3592
- table[Table.Symbol.Columns] = builtColumns;
3593
- table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
3594
- if (extraConfig) {
3595
- table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
3596
- }
3597
- return Object.assign(table, {
3598
- enableRLS: () => {
3599
- table[PgTable.Symbol.EnableRLS] = true;
3600
- return table;
314
+ function injectClaudeCodeHook() {
315
+ const settingsDir = path2.dirname(CLAUDE_SETTINGS_PATH);
316
+ fs2.mkdirSync(settingsDir, { recursive: true });
317
+ let settings = {};
318
+ if (fs2.existsSync(CLAUDE_SETTINGS_PATH)) {
319
+ try {
320
+ settings = JSON.parse(fs2.readFileSync(CLAUDE_SETTINGS_PATH, "utf-8"));
321
+ } catch {
3601
322
  }
3602
- });
3603
- }
3604
- var pgTable = (name, columns, extraConfig) => {
3605
- return pgTableWithSchema(name, columns, extraConfig, void 0);
3606
- };
3607
-
3608
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/pg-core/indexes.js
3609
- var IndexBuilderOn = class {
3610
- constructor(unique, name) {
3611
- this.unique = unique;
3612
- this.name = name;
3613
- }
3614
- static [entityKind] = "PgIndexBuilderOn";
3615
- on(...columns) {
3616
- return new IndexBuilder(
3617
- columns.map((it) => {
3618
- if (is(it, SQL)) {
3619
- return it;
3620
- }
3621
- it = it;
3622
- const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
3623
- it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
3624
- return clonedIndexedColumn;
3625
- }),
3626
- this.unique,
3627
- false,
3628
- this.name
3629
- );
3630
323
  }
3631
- onOnly(...columns) {
3632
- return new IndexBuilder(
3633
- columns.map((it) => {
3634
- if (is(it, SQL)) {
3635
- return it;
3636
- }
3637
- it = it;
3638
- const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
3639
- it.indexConfig = it.defaultConfig;
3640
- return clonedIndexedColumn;
3641
- }),
3642
- this.unique,
3643
- true,
3644
- this.name
3645
- );
324
+ if (!settings.hooks || typeof settings.hooks !== "object") {
325
+ settings.hooks = {};
3646
326
  }
3647
- /**
3648
- * Specify what index method to use. Choices are `btree`, `hash`, `gist`, `spgist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
3649
- *
3650
- * If you have the `pg_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
3651
- *
3652
- * **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
3653
- *
3654
- * @param method The name of the index method to be used
3655
- * @param columns
3656
- * @returns
3657
- */
3658
- using(method, ...columns) {
3659
- return new IndexBuilder(
3660
- columns.map((it) => {
3661
- if (is(it, SQL)) {
3662
- return it;
3663
- }
3664
- it = it;
3665
- const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
3666
- it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
3667
- return clonedIndexedColumn;
3668
- }),
3669
- this.unique,
3670
- true,
3671
- this.name,
3672
- method
327
+ const hooks = settings.hooks;
328
+ if (Array.isArray(hooks.Stop)) {
329
+ const existing = hooks.Stop;
330
+ const alreadyInstalled = existing.some(
331
+ (entry) => entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER))
3673
332
  );
333
+ if (alreadyInstalled) {
334
+ check("Claude Code hook already installed");
335
+ return;
336
+ }
3674
337
  }
3675
- };
3676
- var IndexBuilder = class {
3677
- static [entityKind] = "PgIndexBuilder";
3678
- /** @internal */
3679
- config;
3680
- constructor(columns, unique, only, name, method = "btree") {
3681
- this.config = {
3682
- name,
3683
- columns,
3684
- unique,
3685
- only,
3686
- method
3687
- };
3688
- }
3689
- concurrently() {
3690
- this.config.concurrently = true;
3691
- return this;
3692
- }
3693
- with(obj) {
3694
- this.config.with = obj;
3695
- return this;
3696
- }
3697
- where(condition) {
3698
- this.config.where = condition;
3699
- return this;
3700
- }
3701
- /** @internal */
3702
- build(table) {
3703
- return new Index(this.config, table);
3704
- }
3705
- };
3706
- var Index = class {
3707
- static [entityKind] = "PgIndex";
3708
- config;
3709
- constructor(config, table) {
3710
- this.config = { ...config, table };
338
+ if (!Array.isArray(hooks.Stop)) {
339
+ hooks.Stop = [];
3711
340
  }
3712
- };
3713
- function index(name) {
3714
- return new IndexBuilderOn(false, name);
3715
- }
3716
- function uniqueIndex(name) {
3717
- return new IndexBuilderOn(true, name);
341
+ hooks.Stop.push({
342
+ matcher: "*",
343
+ hooks: [
344
+ {
345
+ type: "command",
346
+ command: HOOK_COMMAND,
347
+ timeout: 30
348
+ }
349
+ ]
350
+ });
351
+ fs2.writeFileSync(CLAUDE_SETTINGS_PATH, JSON.stringify(settings, null, 2));
352
+ check("Injected tracking hook into ~/.claude/settings.json");
3718
353
  }
3719
-
3720
- // ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260113.0_@neondatabase+serverless@1.0._9595fca13b02117f1a82e47fffcab042/node_modules/drizzle-orm/relations.js
3721
- var Relation = class {
3722
- constructor(sourceTable, referencedTable, relationName) {
3723
- this.sourceTable = sourceTable;
3724
- this.referencedTable = referencedTable;
3725
- this.relationName = relationName;
3726
- this.referencedTableName = referencedTable[Table.Symbol.Name];
3727
- }
3728
- static [entityKind] = "Relation";
3729
- referencedTableName;
3730
- fieldName;
3731
- };
3732
- var Relations = class {
3733
- constructor(table, config) {
3734
- this.table = table;
3735
- this.config = config;
3736
- }
3737
- static [entityKind] = "Relations";
3738
- };
3739
- var One = class _One extends Relation {
3740
- constructor(sourceTable, referencedTable, config, isNullable) {
3741
- super(sourceTable, referencedTable, config?.relationName);
3742
- this.config = config;
3743
- this.isNullable = isNullable;
3744
- }
3745
- static [entityKind] = "One";
3746
- withFieldName(fieldName) {
3747
- const relation = new _One(
3748
- this.sourceTable,
3749
- this.referencedTable,
3750
- this.config,
3751
- this.isNullable
3752
- );
3753
- relation.fieldName = fieldName;
3754
- return relation;
3755
- }
3756
- };
3757
- var Many = class _Many extends Relation {
3758
- constructor(sourceTable, referencedTable, config) {
3759
- super(sourceTable, referencedTable, config?.relationName);
3760
- this.config = config;
3761
- }
3762
- static [entityKind] = "Many";
3763
- withFieldName(fieldName) {
3764
- const relation = new _Many(
3765
- this.sourceTable,
3766
- this.referencedTable,
3767
- this.config
3768
- );
3769
- relation.fieldName = fieldName;
3770
- return relation;
354
+ async function init() {
355
+ console.log();
356
+ const ccVersion = detectClaudeCode();
357
+ if (ccVersion) {
358
+ console.log(` ${c.dim(`Detected: Claude Code ${ccVersion}`)}`);
359
+ } else {
360
+ warn("Claude Code not detected \u2014 hook will activate when installed");
3771
361
  }
3772
- };
3773
- function relations(table, relations2) {
3774
- return new Relations(
3775
- table,
3776
- (helpers) => Object.fromEntries(
3777
- Object.entries(relations2(helpers)).map(([key, value]) => [
3778
- key,
3779
- value.withFieldName(key)
3780
- ])
3781
- )
362
+ console.log();
363
+ injectClaudeCodeHook();
364
+ installSkill();
365
+ injectClaudeMdRule();
366
+ ensureDirs();
367
+ check(`Created ~/.basestream/buffer/`);
368
+ console.log();
369
+ await login();
370
+ console.log();
371
+ console.log(
372
+ ` ${c.dim("That's it. Work normally \u2014 every session is now tracked.")}`
3782
373
  );
374
+ console.log();
3783
375
  }
3784
376
 
377
+ // src/cli/commands/status.ts
378
+ init_config();
379
+ import fs3 from "node:fs";
380
+ import path3 from "node:path";
381
+
3785
382
  // src/db/models/enum-constants.ts
3786
383
  function makeEnum(values) {
3787
384
  return Object.fromEntries(values.map((v) => [v, v]));
@@ -3796,269 +393,6 @@ var ArtifactStatus = makeEnum(["GENERATING", "READY", "FAILED"]);
3796
393
  var ArtifactPeriod = makeEnum(["QUARTER", "HALF", "YEAR", "CUSTOM"]);
3797
394
  var IntegrationType = makeEnum(["GITHUB", "HUBSPOT", "JIRA", "GOOGLE_CALENDAR", "FIREFLIES", "CLAUDE_CODE", "NOTION"]);
3798
395
 
3799
- // src/db/models/enums.ts
3800
- var bsPlanEnum = pgEnum("bs_plan", ["FREE", "TEAM", "ENTERPRISE"]);
3801
- var bsOrgRoleEnum = pgEnum("bs_org_role", ["ADMIN", "MANAGER", "USER"]);
3802
- var bsArtifactPeriodEnum = pgEnum("bs_artifact_period", ["QUARTER", "HALF", "YEAR", "CUSTOM"]);
3803
- var bsArtifactStatusEnum = pgEnum("bs_artifact_status", ["GENERATING", "READY", "FAILED"]);
3804
- var bsWorkCategoryEnum = pgEnum("bs_work_category", ["FEATURE", "BUGFIX", "REFACTOR", "DOCS", "TESTING", "DEVOPS", "OTHER"]);
3805
- var bsWorkOutcomeEnum = pgEnum("bs_work_outcome", ["COMPLETED", "IN_PROGRESS", "BLOCKED", "ABANDONED"]);
3806
- var bsComplexityEnum = pgEnum("bs_complexity", ["LOW", "MEDIUM", "HIGH"]);
3807
- var bsVisibilityEnum = pgEnum("bs_visibility", ["PRIVATE", "TEAM", "PUBLIC"]);
3808
- var bsIntegrationTypeEnum = pgEnum("bs_integration_type", ["GITHUB", "HUBSPOT", "JIRA", "GOOGLE_CALENDAR", "FIREFLIES", "CLAUDE_CODE", "NOTION"]);
3809
-
3810
- // src/db/models/auth.ts
3811
- var import_cuid2 = __toESM(require_cuid2(), 1);
3812
- var bsUsers = pgTable("bs_users", {
3813
- id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
3814
- name: text("name"),
3815
- email: text("email").notNull().unique(),
3816
- emailVerified: boolean("email_verified").default(false).notNull(),
3817
- image: text("image"),
3818
- stripeCustomerId: text("stripe_customer_id").unique(),
3819
- stripePriceId: text("stripe_price_id"),
3820
- stripeSubscriptionId: text("stripe_subscription_id").unique(),
3821
- stripeCurrentPeriodEnd: timestamp("stripe_current_period_end"),
3822
- plan: bsPlanEnum("plan").default("FREE").notNull(),
3823
- firefliesApiKey: text("fireflies_api_key"),
3824
- firefliesWebhookSecret: text("fireflies_webhook_secret"),
3825
- createdAt: timestamp("created_at").defaultNow().notNull(),
3826
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3827
- });
3828
- var bsAccounts = pgTable("bs_accounts", {
3829
- id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
3830
- userId: text("user_id").notNull(),
3831
- accountId: text("account_id").notNull(),
3832
- providerId: text("provider_id").notNull(),
3833
- accessToken: text("access_token"),
3834
- refreshToken: text("refresh_token"),
3835
- accessTokenExpiresAt: timestamp("access_token_expires_at"),
3836
- refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
3837
- scope: text("scope"),
3838
- idToken: text("id_token"),
3839
- password: text("password"),
3840
- createdAt: timestamp("created_at").defaultNow().notNull(),
3841
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3842
- }, (table) => [
3843
- uniqueIndex("bs_accounts_provider_account_id_idx").on(table.providerId, table.accountId)
3844
- ]);
3845
- var bsSessions = pgTable("bs_sessions", {
3846
- id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
3847
- token: text("token").notNull().unique(),
3848
- userId: text("user_id").notNull(),
3849
- expiresAt: timestamp("expires_at").notNull(),
3850
- ipAddress: text("ip_address"),
3851
- userAgent: text("user_agent"),
3852
- createdAt: timestamp("created_at").defaultNow().notNull(),
3853
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3854
- });
3855
- var bsVerifications = pgTable("bs_verifications", {
3856
- id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
3857
- identifier: text("identifier").notNull(),
3858
- value: text("value").notNull(),
3859
- expiresAt: timestamp("expires_at").notNull(),
3860
- createdAt: timestamp("created_at").defaultNow().notNull(),
3861
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3862
- });
3863
-
3864
- // src/db/models/org.ts
3865
- var import_cuid22 = __toESM(require_cuid2(), 1);
3866
- var bsOrgs = pgTable("bs_orgs", {
3867
- id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
3868
- name: text("name").notNull(),
3869
- slug: text("slug").notNull().unique(),
3870
- createdAt: timestamp("created_at").defaultNow().notNull(),
3871
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3872
- });
3873
- var bsOrgMembers = pgTable("bs_org_members", {
3874
- id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
3875
- userId: text("user_id").notNull(),
3876
- orgId: text("org_id").notNull(),
3877
- role: bsOrgRoleEnum("role").default("USER").notNull(),
3878
- teamId: text("team_id"),
3879
- githubLogin: text("github_login")
3880
- }, (table) => [
3881
- uniqueIndex("bs_org_members_user_id_org_id_idx").on(table.userId, table.orgId),
3882
- index("bs_org_members_team_id_idx").on(table.teamId)
3883
- ]);
3884
- var bsTeams = pgTable("bs_teams", {
3885
- id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
3886
- orgId: text("org_id").notNull(),
3887
- name: text("name").notNull(),
3888
- // Parent team for nested tree structure (null = top-level).
3889
- parentTeamId: text("parent_team_id"),
3890
- createdAt: timestamp("created_at").defaultNow().notNull(),
3891
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3892
- }, (table) => [
3893
- index("bs_teams_org_id_idx").on(table.orgId),
3894
- index("bs_teams_parent_team_id_idx").on(table.parentTeamId)
3895
- ]);
3896
- var bsOrgInvites = pgTable("bs_org_invites", {
3897
- id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
3898
- email: text("email").notNull(),
3899
- orgId: text("org_id").notNull(),
3900
- role: bsOrgRoleEnum("role").default("USER").notNull(),
3901
- token: text("token").$defaultFn(() => (0, import_cuid22.createId)()).notNull().unique(),
3902
- expiresAt: timestamp("expires_at").notNull(),
3903
- createdAt: timestamp("created_at").defaultNow().notNull()
3904
- });
3905
-
3906
- // src/db/models/work.ts
3907
- var import_cuid23 = __toESM(require_cuid2(), 1);
3908
- var bsWorkEntries = pgTable("bs_work_entries", {
3909
- id: text("id").$defaultFn(() => (0, import_cuid23.createId)()).primaryKey(),
3910
- userId: text("user_id").notNull(),
3911
- orgId: text("org_id"),
3912
- tool: text("tool").notNull(),
3913
- sessionId: text("session_id"),
3914
- projectName: text("project_name"),
3915
- repo: text("repo"),
3916
- branch: text("branch"),
3917
- summary: text("summary").notNull(),
3918
- category: bsWorkCategoryEnum("category").default("OTHER").notNull(),
3919
- why: text("why"),
3920
- whatChanged: json("what_changed"),
3921
- outcome: bsWorkOutcomeEnum("outcome").default("IN_PROGRESS").notNull(),
3922
- filesTouched: integer("files_touched"),
3923
- complexity: bsComplexityEnum("complexity"),
3924
- toolVersion: text("tool_version"),
3925
- model: text("model"),
3926
- sessionDurationMin: integer("session_duration_min"),
3927
- turns: integer("turns"),
3928
- prUrl: text("pr_url"),
3929
- ticketUrl: text("ticket_url"),
3930
- commitShas: json("commit_shas"),
3931
- visibility: bsVisibilityEnum("visibility").default("TEAM").notNull(),
3932
- notionPageId: text("notion_page_id"),
3933
- createdAt: timestamp("created_at").defaultNow().notNull(),
3934
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3935
- }, (table) => [
3936
- index("bs_work_entries_user_id_idx").on(table.userId),
3937
- index("bs_work_entries_org_id_idx").on(table.orgId),
3938
- index("bs_work_entries_created_at_idx").on(table.createdAt),
3939
- index("bs_work_entries_category_idx").on(table.category)
3940
- ]);
3941
- var bsApiKeys = pgTable("bs_api_keys", {
3942
- id: text("id").$defaultFn(() => (0, import_cuid23.createId)()).primaryKey(),
3943
- userId: text("user_id").notNull(),
3944
- name: text("name").notNull(),
3945
- key: text("key").notNull().unique(),
3946
- lastUsed: timestamp("last_used"),
3947
- createdAt: timestamp("created_at").defaultNow().notNull()
3948
- });
3949
-
3950
- // src/db/models/integrations.ts
3951
- var import_cuid24 = __toESM(require_cuid2(), 1);
3952
- var bsIntegrations = pgTable("bs_integrations", {
3953
- id: text("id").$defaultFn(() => (0, import_cuid24.createId)()).primaryKey(),
3954
- orgId: text("org_id").notNull(),
3955
- type: bsIntegrationTypeEnum("type").notNull(),
3956
- config: json("config").notNull(),
3957
- enabled: boolean("enabled").default(true).notNull(),
3958
- createdAt: timestamp("created_at").defaultNow().notNull(),
3959
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3960
- }, (table) => [
3961
- uniqueIndex("bs_integrations_org_id_type_idx").on(table.orgId, table.type)
3962
- ]);
3963
- var bsMemberOauthCredentials = pgTable("bs_member_oauth_credentials", {
3964
- id: text("id").$defaultFn(() => (0, import_cuid24.createId)()).primaryKey(),
3965
- userId: text("user_id").notNull(),
3966
- orgId: text("org_id").notNull(),
3967
- provider: text("provider").notNull(),
3968
- // e.g. 'google-calendar'
3969
- accessToken: text("access_token").notNull(),
3970
- refreshToken: text("refresh_token"),
3971
- scope: text("scope"),
3972
- email: text("email"),
3973
- expiresAt: timestamp("expires_at"),
3974
- createdAt: timestamp("created_at").defaultNow().notNull(),
3975
- updatedAt: timestamp("updated_at").defaultNow().notNull()
3976
- }, (table) => [
3977
- uniqueIndex("bs_member_oauth_user_org_provider_idx").on(table.userId, table.orgId, table.provider)
3978
- ]);
3979
-
3980
- // src/db/models/artifacts.ts
3981
- var import_cuid25 = __toESM(require_cuid2(), 1);
3982
- var bsArtifacts = pgTable("bs_artifacts", {
3983
- id: text("id").$defaultFn(() => (0, import_cuid25.createId)()).primaryKey(),
3984
- orgId: text("org_id").notNull(),
3985
- // null = team rollup, otherwise per-person
3986
- subjectUserId: text("subject_user_id"),
3987
- // reserved for future sub-team support; null in v1
3988
- subjectTeamId: text("subject_team_id"),
3989
- generatedBy: text("generated_by"),
3990
- // userId of creator; null = system/cron
3991
- periodType: bsArtifactPeriodEnum("period_type").notNull(),
3992
- periodStart: timestamp("period_start").notNull(),
3993
- periodEnd: timestamp("period_end").notNull(),
3994
- title: text("title").notNull(),
3995
- narrative: text("narrative"),
3996
- // markdown, LLM-generated
3997
- stats: json("stats"),
3998
- // raw metrics
3999
- status: bsArtifactStatusEnum("status").default("GENERATING").notNull(),
4000
- errorMessage: text("error_message"),
4001
- createdAt: timestamp("created_at").defaultNow().notNull(),
4002
- updatedAt: timestamp("updated_at").defaultNow().notNull()
4003
- }, (table) => [
4004
- index("bs_artifacts_org_id_idx").on(table.orgId),
4005
- index("bs_artifacts_subject_user_id_idx").on(table.subjectUserId),
4006
- index("bs_artifacts_period_idx").on(table.periodStart, table.periodEnd)
4007
- ]);
4008
-
4009
- // src/db/models/relations.ts
4010
- var bsUsersRelations = relations(bsUsers, ({ many }) => ({
4011
- accounts: many(bsAccounts),
4012
- sessions: many(bsSessions),
4013
- orgMemberships: many(bsOrgMembers),
4014
- workEntries: many(bsWorkEntries),
4015
- apiKeys: many(bsApiKeys)
4016
- }));
4017
- var bsAccountsRelations = relations(bsAccounts, ({ one }) => ({
4018
- user: one(bsUsers, { fields: [bsAccounts.userId], references: [bsUsers.id] })
4019
- }));
4020
- var bsSessionsRelations = relations(bsSessions, ({ one }) => ({
4021
- user: one(bsUsers, { fields: [bsSessions.userId], references: [bsUsers.id] })
4022
- }));
4023
- var bsVerificationsRelations = relations(bsVerifications, ({ one }) => ({
4024
- user: one(bsUsers, { fields: [bsVerifications.identifier], references: [bsUsers.email] })
4025
- }));
4026
- var bsOrgsRelations = relations(bsOrgs, ({ many }) => ({
4027
- members: many(bsOrgMembers),
4028
- invites: many(bsOrgInvites),
4029
- integrations: many(bsIntegrations)
4030
- }));
4031
- var bsOrgMembersRelations = relations(bsOrgMembers, ({ one }) => ({
4032
- user: one(bsUsers, { fields: [bsOrgMembers.userId], references: [bsUsers.id] }),
4033
- org: one(bsOrgs, { fields: [bsOrgMembers.orgId], references: [bsOrgs.id] }),
4034
- team: one(bsTeams, { fields: [bsOrgMembers.teamId], references: [bsTeams.id] })
4035
- }));
4036
- var bsTeamsRelations = relations(bsTeams, ({ one, many }) => ({
4037
- org: one(bsOrgs, { fields: [bsTeams.orgId], references: [bsOrgs.id] }),
4038
- parent: one(bsTeams, { fields: [bsTeams.parentTeamId], references: [bsTeams.id], relationName: "parentTeam" }),
4039
- members: many(bsOrgMembers)
4040
- }));
4041
- var bsOrgInvitesRelations = relations(bsOrgInvites, ({ one }) => ({
4042
- org: one(bsOrgs, { fields: [bsOrgInvites.orgId], references: [bsOrgs.id] })
4043
- }));
4044
- var bsWorkEntriesRelations = relations(bsWorkEntries, ({ one }) => ({
4045
- user: one(bsUsers, { fields: [bsWorkEntries.userId], references: [bsUsers.id] })
4046
- }));
4047
- var bsApiKeysRelations = relations(bsApiKeys, ({ one }) => ({
4048
- user: one(bsUsers, { fields: [bsApiKeys.userId], references: [bsUsers.id] })
4049
- }));
4050
- var bsIntegrationsRelations = relations(bsIntegrations, ({ one }) => ({
4051
- org: one(bsOrgs, { fields: [bsIntegrations.orgId], references: [bsOrgs.id] })
4052
- }));
4053
- var bsArtifactsRelations = relations(bsArtifacts, ({ one }) => ({
4054
- org: one(bsOrgs, { fields: [bsArtifacts.orgId], references: [bsOrgs.id] }),
4055
- subjectUser: one(bsUsers, { fields: [bsArtifacts.subjectUserId], references: [bsUsers.id] })
4056
- }));
4057
- var bsMemberOauthCredentialsRelations = relations(bsMemberOauthCredentials, ({ one }) => ({
4058
- user: one(bsUsers, { fields: [bsMemberOauthCredentials.userId], references: [bsUsers.id] }),
4059
- org: one(bsOrgs, { fields: [bsMemberOauthCredentials.orgId], references: [bsOrgs.id] })
4060
- }));
4061
-
4062
396
  // src/cli/commands/status.ts
4063
397
  init_util();
4064
398
  function groupBy(arr, fn) {
@@ -4172,9 +506,9 @@ import fs5 from "node:fs";
4172
506
  import path5 from "node:path";
4173
507
  import os3 from "node:os";
4174
508
  import { execSync as execSync3 } from "node:child_process";
4175
- function parseTranscriptLine(line2) {
509
+ function parseTranscriptLine(line) {
4176
510
  try {
4177
- return JSON.parse(line2);
511
+ return JSON.parse(line);
4178
512
  } catch {
4179
513
  return null;
4180
514
  }
@@ -4225,8 +559,8 @@ function analyzeTranscript(transcriptPath, acc) {
4225
559
  if (!fs5.existsSync(transcriptPath)) return acc;
4226
560
  const content = fs5.readFileSync(transcriptPath, "utf-8");
4227
561
  const lines = content.split("\n").filter(Boolean);
4228
- for (const line2 of lines) {
4229
- const entry = parseTranscriptLine(line2);
562
+ for (const line of lines) {
563
+ const entry = parseTranscriptLine(line);
4230
564
  if (!entry) continue;
4231
565
  const message = entry.message;
4232
566
  const contentBlocks = Array.isArray(message?.content) ? message.content : [];
@@ -4500,7 +834,7 @@ async function main() {
4500
834
  process.exit(0);
4501
835
  }
4502
836
  if (command === "--version" || command === "-v") {
4503
- console.log(true ? "0.2.3" : "dev");
837
+ console.log(true ? "0.2.4" : "dev");
4504
838
  process.exit(0);
4505
839
  }
4506
840
  switch (command || "init") {
@@ -4535,8 +869,3 @@ main().catch((err) => {
4535
869
  console.error(err.message || err);
4536
870
  process.exit(1);
4537
871
  });
4538
- /*! Bundled license information:
4539
-
4540
- @noble/hashes/utils.js:
4541
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
4542
- */