@basestream/cli 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @basestream/cli might be problematic. Click here for more details.
- package/dist/cli.mjs +3986 -193
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
5
|
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
|
+
});
|
|
4
14
|
var __esm = (fn, res) => function __init() {
|
|
5
15
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
16
|
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
7
20
|
var __export = (target, all) => {
|
|
8
21
|
for (var name in all)
|
|
9
22
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
23
|
};
|
|
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
|
+
));
|
|
11
40
|
|
|
12
41
|
// src/cli/config.ts
|
|
13
42
|
import fs from "node:fs";
|
|
@@ -70,6 +99,649 @@ var init_util = __esm({
|
|
|
70
99
|
}
|
|
71
100
|
});
|
|
72
101
|
|
|
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
|
+
|
|
73
745
|
// src/cli/commands/sync.ts
|
|
74
746
|
var sync_exports = {};
|
|
75
747
|
__export(sync_exports, {
|
|
@@ -141,199 +813,3235 @@ async function sync() {
|
|
|
141
813
|
fail(
|
|
142
814
|
`Sync failed: ${err instanceof Error ? err.message : String(err)}`
|
|
143
815
|
);
|
|
144
|
-
process.exit(1);
|
|
816
|
+
process.exit(1);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
var init_sync = __esm({
|
|
820
|
+
"src/cli/commands/sync.ts"() {
|
|
821
|
+
"use strict";
|
|
822
|
+
init_config();
|
|
823
|
+
init_util();
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
// src/cli/commands/init.ts
|
|
828
|
+
init_config();
|
|
829
|
+
init_util();
|
|
830
|
+
import fs2 from "node:fs";
|
|
831
|
+
import path2 from "node:path";
|
|
832
|
+
import os2 from "node:os";
|
|
833
|
+
import { execSync as execSync2 } from "node:child_process";
|
|
834
|
+
|
|
835
|
+
// src/cli/commands/login.ts
|
|
836
|
+
init_config();
|
|
837
|
+
init_util();
|
|
838
|
+
import http from "node:http";
|
|
839
|
+
import { execSync } from "node:child_process";
|
|
840
|
+
var DEFAULT_BASE_URL = "https://www.basestream.ai";
|
|
841
|
+
function openBrowser(url) {
|
|
842
|
+
try {
|
|
843
|
+
const platform = process.platform;
|
|
844
|
+
if (platform === "darwin") execSync(`open "${url}"`);
|
|
845
|
+
else if (platform === "win32") execSync(`start "${url}"`);
|
|
846
|
+
else execSync(`xdg-open "${url}"`);
|
|
847
|
+
} catch {
|
|
848
|
+
console.log(` ${c.dim(`Open this URL in your browser: ${url}`)}`);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
async function login() {
|
|
852
|
+
const existing = readConfig();
|
|
853
|
+
const baseUrl = existing?.baseUrl || process.env.BASESTREAM_URL || DEFAULT_BASE_URL;
|
|
854
|
+
console.log(
|
|
855
|
+
` ${c.dim("Opening browser for authentication...")}`
|
|
856
|
+
);
|
|
857
|
+
const apiKey = await new Promise((resolve, reject) => {
|
|
858
|
+
const server = http.createServer((req, res) => {
|
|
859
|
+
const url = new URL(req.url || "/", `http://localhost`);
|
|
860
|
+
const key = url.searchParams.get("key");
|
|
861
|
+
const orgId = url.searchParams.get("orgId");
|
|
862
|
+
if (key) {
|
|
863
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
864
|
+
res.end(`<!DOCTYPE html>
|
|
865
|
+
<html lang="en">
|
|
866
|
+
<head>
|
|
867
|
+
<meta charset="utf-8">
|
|
868
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
869
|
+
<title>Basestream CLI \u2014 Authenticated</title>
|
|
870
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
871
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
872
|
+
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Newsreader:wght@500;600&display=swap" rel="stylesheet">
|
|
873
|
+
</head>
|
|
874
|
+
<body style="font-family: 'DM Sans', -apple-system, system-ui, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; background: #faf8f4; color: #1a1714;">
|
|
875
|
+
<div style="text-align: center;">
|
|
876
|
+
<div style="display: flex; align-items: center; justify-content: center; gap: 0.625rem; margin-bottom: 2rem;">
|
|
877
|
+
<div style="display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; background: #1a1714; border-radius: 8px;">
|
|
878
|
+
<svg width="16" height="16" viewBox="0 0 22 22" fill="none"><path d="M7.39855 11.2475C10.1937 11.2476 12.4598 13.5124 12.4598 16.3052C12.4596 19.0979 10.1936 21.3616 7.39855 21.3618H0V16.3052C0 15.7395 0.094025 15.1955 0.265523 14.6876C0.304389 14.5726 0.345701 14.4588 0.392462 14.3476C0.602402 13.8482 0.890874 13.39 1.24144 12.9873C1.25986 12.9662 1.27857 12.9453 1.29734 12.9245C1.39051 12.821 1.48832 12.7218 1.58965 12.6263C1.60303 12.6137 1.61572 12.6004 1.62924 12.5879C1.73452 12.4908 1.8444 12.3987 1.95765 12.3107C1.97096 12.3004 1.98383 12.2895 1.99725 12.2793C2.1117 12.1922 2.23063 12.1108 2.35244 12.0336C2.36662 12.0246 2.3801 12.0145 2.39437 12.0056C2.44032 11.9771 2.48719 11.95 2.53412 11.9229C2.56226 11.9067 2.59065 11.8909 2.61913 11.8752C2.64893 11.8587 2.67864 11.8421 2.7088 11.8263C2.75348 11.8028 2.79844 11.7797 2.84389 11.7576C2.88103 11.7394 2.91922 11.7235 2.95686 11.7063C2.98716 11.6925 3.01707 11.6777 3.04769 11.6644C3.09301 11.6447 3.13912 11.6269 3.18511 11.6085C3.21662 11.5959 3.24764 11.582 3.27945 11.5701C3.32936 11.5513 3.38019 11.5349 3.43084 11.5177C3.45418 11.5097 3.47722 11.5008 3.50071 11.4932C3.55658 11.4751 3.61289 11.4581 3.66958 11.442C3.69166 11.4357 3.71376 11.4293 3.73596 11.4233C3.79907 11.4063 3.86289 11.3914 3.92695 11.3767C3.94209 11.3733 3.95718 11.3696 3.97237 11.3663C4.11504 11.335 4.25985 11.3095 4.40675 11.2906C4.43232 11.2873 4.45794 11.2842 4.48362 11.2812C4.54425 11.2744 4.60519 11.2685 4.66645 11.2638C4.67847 11.2629 4.69052 11.2623 4.70256 11.2614L4.80038 11.2545C4.88671 11.2501 4.97383 11.2475 5.06125 11.2475H7.39855ZM16.9388 11.2475C19.734 11.2476 22 13.5124 22 16.3052C21.9998 19.0979 19.7338 21.3616 16.9388 21.3618H13.2832C14.4337 20.2108 15.1709 18.4482 15.1709 16.4718C15.1709 14.2926 14.2749 12.3735 12.9163 11.2475H16.9388ZM7.39855 0.00116458C10.1937 0.0013425 12.4598 2.26497 12.4598 5.05775C12.4597 7.85045 10.1937 10.1142 7.39855 10.1143H0V5.05775C0 4.89236 0.00775963 4.7288 0.0232915 4.56747C0.0274579 4.52418 0.0331791 4.48116 0.038431 4.4382C0.0524815 4.32328 0.0692046 4.20938 0.0908369 4.09698L0.102483 4.03875C0.106227 4.02046 0.110188 4.00223 0.114128 3.98401C0.127164 3.92376 0.142054 3.8641 0.157218 3.80467C0.164069 3.77781 0.1709 3.75099 0.17818 3.72431C0.188513 3.68644 0.199603 3.64886 0.210788 3.61135C0.225482 3.56207 0.241227 3.51324 0.257371 3.46461C0.269763 3.42728 0.281404 3.38975 0.294638 3.35281C0.30559 3.32224 0.318053 3.29227 0.329575 3.26198C0.343044 3.22656 0.356098 3.19103 0.370335 3.156C0.387188 3.11454 0.404827 3.07346 0.422741 3.03256C0.44039 2.99225 0.458814 2.95235 0.477476 2.9126C0.491731 2.88224 0.505727 2.85179 0.520565 2.82177C0.537576 2.78734 0.555205 2.75326 0.572971 2.71928C0.592296 2.68233 0.610995 2.64506 0.6312 2.60865C0.657644 2.56099 0.68596 2.51444 0.713885 2.46774C0.725232 2.44876 0.736069 2.42949 0.747658 2.41067C0.773311 2.36902 0.800032 2.32807 0.826849 2.28723C0.843934 2.26121 0.860541 2.23488 0.87809 2.2092C0.953313 2.0991 1.03336 1.99256 1.11683 1.88894C1.18114 1.80912 1.24702 1.73059 1.31597 1.65486C1.47484 1.48036 1.64557 1.31664 1.82722 1.16574C1.85016 1.14669 1.87382 1.12849 1.89709 1.10984C1.99837 1.02867 2.10292 0.951415 2.21036 0.87809C2.23606 0.86056 2.26236 0.843915 2.28839 0.826849C2.32925 0.800052 2.37017 0.773292 2.41184 0.747658C2.43349 0.734341 2.45518 0.721061 2.47705 0.708062C2.52886 0.677257 2.58129 0.647377 2.63427 0.61839C2.64707 0.61139 2.65984 0.604319 2.6727 0.597427C2.72986 0.566794 2.78777 0.537396 2.84622 0.50892C2.86043 0.502002 2.87503 0.49591 2.88931 0.489122C2.94744 0.461478 3.00584 0.434234 3.06516 0.408766C3.0837 0.400809 3.10241 0.393216 3.12106 0.385475C3.17763 0.361989 3.23467 0.3394 3.29226 0.317929C3.30779 0.31214 3.32324 0.306101 3.33884 0.300461C3.39807 0.279043 3.45795 0.25915 3.51818 0.239903C3.54179 0.232361 3.56547 0.224979 3.58922 0.217776C3.63126 0.205025 3.67367 0.193353 3.71616 0.181674C3.7556 0.170838 3.79513 0.16013 3.83495 0.15023C3.9786 0.114503 4.12462 0.0848882 4.27283 0.0617225C4.28096 0.0604516 4.28914 0.059461 4.29728 0.0582288C4.36902 0.047376 4.44121 0.038089 4.5139 0.030279C4.5248 0.0291076 4.53558 0.0267227 4.5465 0.0256207C4.55542 0.0247215 4.56436 0.0241444 4.57329 0.0232915L4.57096 0.0244561C4.73223 0.00896687 4.89591 0.00117115 5.06125 0.00116458H7.39855ZM16.9388 0C19.734 0.000177881 22 2.26497 22 5.05775C21.9999 7.85045 19.7339 10.1142 16.9388 10.1143H12.9175C14.2754 8.98827 15.1708 7.06961 15.1709 4.89122C15.1709 2.91428 14.433 1.15104 13.282 0H16.9388Z" fill="#FAF8F4"/></svg>
|
|
879
|
+
</div>
|
|
880
|
+
<span style="font-size: 1rem; font-weight: 600;">basestream</span>
|
|
881
|
+
</div>
|
|
882
|
+
<div style="background: #fffdf9; border: 1px solid #e8e4de; border-radius: 16px; padding: 2rem; display: inline-block;">
|
|
883
|
+
<h1 style="font-family: 'Newsreader', Georgia, serif; font-size: 1.25rem; color: #6b7e6b; margin-bottom: 0.5rem;">✓ Authenticated</h1>
|
|
884
|
+
<p style="color: #8a8379; font-size: 0.875rem;">You can close this tab and return to your terminal.</p>
|
|
885
|
+
</div>
|
|
886
|
+
</div>
|
|
887
|
+
</body>
|
|
888
|
+
</html>`);
|
|
889
|
+
server.close();
|
|
890
|
+
writeConfig({
|
|
891
|
+
apiKey: key,
|
|
892
|
+
baseUrl,
|
|
893
|
+
orgId: orgId || void 0
|
|
894
|
+
});
|
|
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 HOOK_COMMAND = "npx @basestream/cli _hook-stop";
|
|
925
|
+
var HOOK_MARKER = "_hook-stop";
|
|
926
|
+
var SKILL_CONTENT = `---
|
|
927
|
+
name: bs-summarize
|
|
928
|
+
description: Update the Basestream session summary with what's been accomplished so far
|
|
929
|
+
---
|
|
930
|
+
|
|
931
|
+
Write a concise summary of what has been accomplished in this coding session so far. Focus on:
|
|
932
|
+
- What was built, fixed, or changed (be specific about features/bugs)
|
|
933
|
+
- Which parts of the codebase were touched
|
|
934
|
+
- Any key decisions made
|
|
935
|
+
|
|
936
|
+
Keep it to 2-4 sentences, plain prose, no bullet points.
|
|
937
|
+
|
|
938
|
+
Write the summary to the file \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\` \u2014 overwrite if it exists.
|
|
939
|
+
`;
|
|
940
|
+
function installSkill() {
|
|
941
|
+
const skillsDir = path2.dirname(CLAUDE_SKILLS_PATH);
|
|
942
|
+
fs2.mkdirSync(skillsDir, { recursive: true });
|
|
943
|
+
if (fs2.existsSync(CLAUDE_SKILLS_PATH)) {
|
|
944
|
+
fs2.writeFileSync(CLAUDE_SKILLS_PATH, SKILL_CONTENT);
|
|
945
|
+
check("Updated /bs-summarize skill");
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
fs2.writeFileSync(CLAUDE_SKILLS_PATH, SKILL_CONTENT);
|
|
949
|
+
check("Installed /bs-summarize skill into ~/.claude/skills/");
|
|
950
|
+
}
|
|
951
|
+
function detectClaudeCode() {
|
|
952
|
+
try {
|
|
953
|
+
const version2 = execSync2("claude --version 2>/dev/null", {
|
|
954
|
+
encoding: "utf-8"
|
|
955
|
+
}).trim();
|
|
956
|
+
return version2 || null;
|
|
957
|
+
} catch {
|
|
958
|
+
return null;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function injectClaudeCodeHook() {
|
|
962
|
+
const settingsDir = path2.dirname(CLAUDE_SETTINGS_PATH);
|
|
963
|
+
fs2.mkdirSync(settingsDir, { recursive: true });
|
|
964
|
+
let settings = {};
|
|
965
|
+
if (fs2.existsSync(CLAUDE_SETTINGS_PATH)) {
|
|
966
|
+
try {
|
|
967
|
+
settings = JSON.parse(fs2.readFileSync(CLAUDE_SETTINGS_PATH, "utf-8"));
|
|
968
|
+
} catch {
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (!settings.hooks || typeof settings.hooks !== "object") {
|
|
972
|
+
settings.hooks = {};
|
|
973
|
+
}
|
|
974
|
+
const hooks = settings.hooks;
|
|
975
|
+
if (Array.isArray(hooks.Stop)) {
|
|
976
|
+
const existing = hooks.Stop;
|
|
977
|
+
const alreadyInstalled = existing.some(
|
|
978
|
+
(entry) => entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER))
|
|
979
|
+
);
|
|
980
|
+
if (alreadyInstalled) {
|
|
981
|
+
check("Claude Code hook already installed");
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (!Array.isArray(hooks.Stop)) {
|
|
986
|
+
hooks.Stop = [];
|
|
987
|
+
}
|
|
988
|
+
hooks.Stop.push({
|
|
989
|
+
matcher: "*",
|
|
990
|
+
hooks: [
|
|
991
|
+
{
|
|
992
|
+
type: "command",
|
|
993
|
+
command: HOOK_COMMAND,
|
|
994
|
+
timeout: 30
|
|
995
|
+
}
|
|
996
|
+
]
|
|
997
|
+
});
|
|
998
|
+
fs2.writeFileSync(CLAUDE_SETTINGS_PATH, JSON.stringify(settings, null, 2));
|
|
999
|
+
check("Injected tracking hook into ~/.claude/settings.json");
|
|
1000
|
+
}
|
|
1001
|
+
async function init() {
|
|
1002
|
+
console.log();
|
|
1003
|
+
const ccVersion = detectClaudeCode();
|
|
1004
|
+
if (ccVersion) {
|
|
1005
|
+
console.log(` ${c.dim(`Detected: Claude Code ${ccVersion}`)}`);
|
|
1006
|
+
} else {
|
|
1007
|
+
warn("Claude Code not detected \u2014 hook will activate when installed");
|
|
1008
|
+
}
|
|
1009
|
+
console.log();
|
|
1010
|
+
injectClaudeCodeHook();
|
|
1011
|
+
installSkill();
|
|
1012
|
+
ensureDirs();
|
|
1013
|
+
check(`Created ~/.basestream/buffer/`);
|
|
1014
|
+
console.log();
|
|
1015
|
+
await login();
|
|
1016
|
+
console.log();
|
|
1017
|
+
console.log(
|
|
1018
|
+
` ${c.dim("That's it. Work normally \u2014 every session is now tracked.")}`
|
|
1019
|
+
);
|
|
1020
|
+
console.log();
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// src/cli/commands/status.ts
|
|
1024
|
+
init_config();
|
|
1025
|
+
import fs3 from "node:fs";
|
|
1026
|
+
import path3 from "node:path";
|
|
1027
|
+
|
|
1028
|
+
// ../../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
|
|
1029
|
+
var entityKind = Symbol.for("drizzle:entityKind");
|
|
1030
|
+
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
1031
|
+
function is(value, type) {
|
|
1032
|
+
if (!value || typeof value !== "object") {
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
if (value instanceof type) {
|
|
1036
|
+
return true;
|
|
1037
|
+
}
|
|
1038
|
+
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
|
|
1039
|
+
throw new Error(
|
|
1040
|
+
`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.`
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
let cls = Object.getPrototypeOf(value).constructor;
|
|
1044
|
+
if (cls) {
|
|
1045
|
+
while (cls) {
|
|
1046
|
+
if (entityKind in cls && cls[entityKind] === type[entityKind]) {
|
|
1047
|
+
return true;
|
|
1048
|
+
}
|
|
1049
|
+
cls = Object.getPrototypeOf(cls);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return false;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// ../../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
|
|
1056
|
+
var Column = class {
|
|
1057
|
+
constructor(table, config) {
|
|
1058
|
+
this.table = table;
|
|
1059
|
+
this.config = config;
|
|
1060
|
+
this.name = config.name;
|
|
1061
|
+
this.keyAsName = config.keyAsName;
|
|
1062
|
+
this.notNull = config.notNull;
|
|
1063
|
+
this.default = config.default;
|
|
1064
|
+
this.defaultFn = config.defaultFn;
|
|
1065
|
+
this.onUpdateFn = config.onUpdateFn;
|
|
1066
|
+
this.hasDefault = config.hasDefault;
|
|
1067
|
+
this.primary = config.primaryKey;
|
|
1068
|
+
this.isUnique = config.isUnique;
|
|
1069
|
+
this.uniqueName = config.uniqueName;
|
|
1070
|
+
this.uniqueType = config.uniqueType;
|
|
1071
|
+
this.dataType = config.dataType;
|
|
1072
|
+
this.columnType = config.columnType;
|
|
1073
|
+
this.generated = config.generated;
|
|
1074
|
+
this.generatedIdentity = config.generatedIdentity;
|
|
1075
|
+
}
|
|
1076
|
+
static [entityKind] = "Column";
|
|
1077
|
+
name;
|
|
1078
|
+
keyAsName;
|
|
1079
|
+
primary;
|
|
1080
|
+
notNull;
|
|
1081
|
+
default;
|
|
1082
|
+
defaultFn;
|
|
1083
|
+
onUpdateFn;
|
|
1084
|
+
hasDefault;
|
|
1085
|
+
isUnique;
|
|
1086
|
+
uniqueName;
|
|
1087
|
+
uniqueType;
|
|
1088
|
+
dataType;
|
|
1089
|
+
columnType;
|
|
1090
|
+
enumValues = void 0;
|
|
1091
|
+
generated = void 0;
|
|
1092
|
+
generatedIdentity = void 0;
|
|
1093
|
+
config;
|
|
1094
|
+
mapFromDriverValue(value) {
|
|
1095
|
+
return value;
|
|
1096
|
+
}
|
|
1097
|
+
mapToDriverValue(value) {
|
|
1098
|
+
return value;
|
|
1099
|
+
}
|
|
1100
|
+
// ** @internal */
|
|
1101
|
+
shouldDisableInsert() {
|
|
1102
|
+
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
// ../../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
|
|
1107
|
+
var ColumnBuilder = class {
|
|
1108
|
+
static [entityKind] = "ColumnBuilder";
|
|
1109
|
+
config;
|
|
1110
|
+
constructor(name, dataType, columnType) {
|
|
1111
|
+
this.config = {
|
|
1112
|
+
name,
|
|
1113
|
+
keyAsName: name === "",
|
|
1114
|
+
notNull: false,
|
|
1115
|
+
default: void 0,
|
|
1116
|
+
hasDefault: false,
|
|
1117
|
+
primaryKey: false,
|
|
1118
|
+
isUnique: false,
|
|
1119
|
+
uniqueName: void 0,
|
|
1120
|
+
uniqueType: void 0,
|
|
1121
|
+
dataType,
|
|
1122
|
+
columnType,
|
|
1123
|
+
generated: void 0
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
|
|
1128
|
+
*
|
|
1129
|
+
* @example
|
|
1130
|
+
* ```ts
|
|
1131
|
+
* const users = pgTable('users', {
|
|
1132
|
+
* id: integer('id').$type<UserId>().primaryKey(),
|
|
1133
|
+
* details: json('details').$type<UserDetails>().notNull(),
|
|
1134
|
+
* });
|
|
1135
|
+
* ```
|
|
1136
|
+
*/
|
|
1137
|
+
$type() {
|
|
1138
|
+
return this;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Adds a `not null` clause to the column definition.
|
|
1142
|
+
*
|
|
1143
|
+
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
|
|
1144
|
+
*/
|
|
1145
|
+
notNull() {
|
|
1146
|
+
this.config.notNull = true;
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Adds a `default <value>` clause to the column definition.
|
|
1151
|
+
*
|
|
1152
|
+
* Affects the `insert` model of the table - columns *with* `default` are optional on insert.
|
|
1153
|
+
*
|
|
1154
|
+
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
1155
|
+
*/
|
|
1156
|
+
default(value) {
|
|
1157
|
+
this.config.default = value;
|
|
1158
|
+
this.config.hasDefault = true;
|
|
1159
|
+
return this;
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Adds a dynamic default value to the column.
|
|
1163
|
+
* The function will be called when the row is inserted, and the returned value will be used as the column value.
|
|
1164
|
+
*
|
|
1165
|
+
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1166
|
+
*/
|
|
1167
|
+
$defaultFn(fn) {
|
|
1168
|
+
this.config.defaultFn = fn;
|
|
1169
|
+
this.config.hasDefault = true;
|
|
1170
|
+
return this;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Alias for {@link $defaultFn}.
|
|
1174
|
+
*/
|
|
1175
|
+
$default = this.$defaultFn;
|
|
1176
|
+
/**
|
|
1177
|
+
* Adds a dynamic update value to the column.
|
|
1178
|
+
* 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.
|
|
1179
|
+
* 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.
|
|
1180
|
+
*
|
|
1181
|
+
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1182
|
+
*/
|
|
1183
|
+
$onUpdateFn(fn) {
|
|
1184
|
+
this.config.onUpdateFn = fn;
|
|
1185
|
+
this.config.hasDefault = true;
|
|
1186
|
+
return this;
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Alias for {@link $onUpdateFn}.
|
|
1190
|
+
*/
|
|
1191
|
+
$onUpdate = this.$onUpdateFn;
|
|
1192
|
+
/**
|
|
1193
|
+
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
1194
|
+
*
|
|
1195
|
+
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
|
|
1196
|
+
*/
|
|
1197
|
+
primaryKey() {
|
|
1198
|
+
this.config.primaryKey = true;
|
|
1199
|
+
this.config.notNull = true;
|
|
1200
|
+
return this;
|
|
1201
|
+
}
|
|
1202
|
+
/** @internal Sets the name of the column to the key within the table definition if a name was not given. */
|
|
1203
|
+
setName(name) {
|
|
1204
|
+
if (this.config.name !== "") return;
|
|
1205
|
+
this.config.name = name;
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
// ../../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
|
|
1210
|
+
var TableName = Symbol.for("drizzle:Name");
|
|
1211
|
+
|
|
1212
|
+
// ../../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
|
|
1213
|
+
var ForeignKeyBuilder = class {
|
|
1214
|
+
static [entityKind] = "PgForeignKeyBuilder";
|
|
1215
|
+
/** @internal */
|
|
1216
|
+
reference;
|
|
1217
|
+
/** @internal */
|
|
1218
|
+
_onUpdate = "no action";
|
|
1219
|
+
/** @internal */
|
|
1220
|
+
_onDelete = "no action";
|
|
1221
|
+
constructor(config, actions) {
|
|
1222
|
+
this.reference = () => {
|
|
1223
|
+
const { name, columns, foreignColumns } = config();
|
|
1224
|
+
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
|
|
1225
|
+
};
|
|
1226
|
+
if (actions) {
|
|
1227
|
+
this._onUpdate = actions.onUpdate;
|
|
1228
|
+
this._onDelete = actions.onDelete;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
onUpdate(action) {
|
|
1232
|
+
this._onUpdate = action === void 0 ? "no action" : action;
|
|
1233
|
+
return this;
|
|
1234
|
+
}
|
|
1235
|
+
onDelete(action) {
|
|
1236
|
+
this._onDelete = action === void 0 ? "no action" : action;
|
|
1237
|
+
return this;
|
|
1238
|
+
}
|
|
1239
|
+
/** @internal */
|
|
1240
|
+
build(table) {
|
|
1241
|
+
return new ForeignKey(table, this);
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
var ForeignKey = class {
|
|
1245
|
+
constructor(table, builder) {
|
|
1246
|
+
this.table = table;
|
|
1247
|
+
this.reference = builder.reference;
|
|
1248
|
+
this.onUpdate = builder._onUpdate;
|
|
1249
|
+
this.onDelete = builder._onDelete;
|
|
1250
|
+
}
|
|
1251
|
+
static [entityKind] = "PgForeignKey";
|
|
1252
|
+
reference;
|
|
1253
|
+
onUpdate;
|
|
1254
|
+
onDelete;
|
|
1255
|
+
getName() {
|
|
1256
|
+
const { name, columns, foreignColumns } = this.reference();
|
|
1257
|
+
const columnNames = columns.map((column) => column.name);
|
|
1258
|
+
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
1259
|
+
const chunks = [
|
|
1260
|
+
this.table[TableName],
|
|
1261
|
+
...columnNames,
|
|
1262
|
+
foreignColumns[0].table[TableName],
|
|
1263
|
+
...foreignColumnNames
|
|
1264
|
+
];
|
|
1265
|
+
return name ?? `${chunks.join("_")}_fk`;
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1269
|
+
// ../../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
|
|
1270
|
+
function iife(fn, ...args) {
|
|
1271
|
+
return fn(...args);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// ../../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
|
|
1275
|
+
function uniqueKeyName(table, columns) {
|
|
1276
|
+
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
1277
|
+
}
|
|
1278
|
+
var UniqueConstraintBuilder = class {
|
|
1279
|
+
constructor(columns, name) {
|
|
1280
|
+
this.name = name;
|
|
1281
|
+
this.columns = columns;
|
|
1282
|
+
}
|
|
1283
|
+
static [entityKind] = "PgUniqueConstraintBuilder";
|
|
1284
|
+
/** @internal */
|
|
1285
|
+
columns;
|
|
1286
|
+
/** @internal */
|
|
1287
|
+
nullsNotDistinctConfig = false;
|
|
1288
|
+
nullsNotDistinct() {
|
|
1289
|
+
this.nullsNotDistinctConfig = true;
|
|
1290
|
+
return this;
|
|
1291
|
+
}
|
|
1292
|
+
/** @internal */
|
|
1293
|
+
build(table) {
|
|
1294
|
+
return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
var UniqueOnConstraintBuilder = class {
|
|
1298
|
+
static [entityKind] = "PgUniqueOnConstraintBuilder";
|
|
1299
|
+
/** @internal */
|
|
1300
|
+
name;
|
|
1301
|
+
constructor(name) {
|
|
1302
|
+
this.name = name;
|
|
1303
|
+
}
|
|
1304
|
+
on(...columns) {
|
|
1305
|
+
return new UniqueConstraintBuilder(columns, this.name);
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
var UniqueConstraint = class {
|
|
1309
|
+
constructor(table, columns, nullsNotDistinct, name) {
|
|
1310
|
+
this.table = table;
|
|
1311
|
+
this.columns = columns;
|
|
1312
|
+
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
|
1313
|
+
this.nullsNotDistinct = nullsNotDistinct;
|
|
1314
|
+
}
|
|
1315
|
+
static [entityKind] = "PgUniqueConstraint";
|
|
1316
|
+
columns;
|
|
1317
|
+
name;
|
|
1318
|
+
nullsNotDistinct = false;
|
|
1319
|
+
getName() {
|
|
1320
|
+
return this.name;
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1324
|
+
// ../../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
|
|
1325
|
+
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
1326
|
+
for (let i = startFrom; i < arrayString.length; i++) {
|
|
1327
|
+
const char2 = arrayString[i];
|
|
1328
|
+
if (char2 === "\\") {
|
|
1329
|
+
i++;
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (char2 === '"') {
|
|
1333
|
+
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
|
|
1334
|
+
}
|
|
1335
|
+
if (inQuotes) {
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1338
|
+
if (char2 === "," || char2 === "}") {
|
|
1339
|
+
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
|
|
1343
|
+
}
|
|
1344
|
+
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
1345
|
+
const result = [];
|
|
1346
|
+
let i = startFrom;
|
|
1347
|
+
let lastCharIsComma = false;
|
|
1348
|
+
while (i < arrayString.length) {
|
|
1349
|
+
const char2 = arrayString[i];
|
|
1350
|
+
if (char2 === ",") {
|
|
1351
|
+
if (lastCharIsComma || i === startFrom) {
|
|
1352
|
+
result.push("");
|
|
1353
|
+
}
|
|
1354
|
+
lastCharIsComma = true;
|
|
1355
|
+
i++;
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
lastCharIsComma = false;
|
|
1359
|
+
if (char2 === "\\") {
|
|
1360
|
+
i += 2;
|
|
1361
|
+
continue;
|
|
1362
|
+
}
|
|
1363
|
+
if (char2 === '"') {
|
|
1364
|
+
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
1365
|
+
result.push(value2);
|
|
1366
|
+
i = startFrom2;
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
if (char2 === "}") {
|
|
1370
|
+
return [result, i + 1];
|
|
1371
|
+
}
|
|
1372
|
+
if (char2 === "{") {
|
|
1373
|
+
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
1374
|
+
result.push(value2);
|
|
1375
|
+
i = startFrom2;
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
1379
|
+
result.push(value);
|
|
1380
|
+
i = newStartFrom;
|
|
1381
|
+
}
|
|
1382
|
+
return [result, i];
|
|
1383
|
+
}
|
|
1384
|
+
function parsePgArray(arrayString) {
|
|
1385
|
+
const [result] = parsePgNestedArray(arrayString, 1);
|
|
1386
|
+
return result;
|
|
1387
|
+
}
|
|
1388
|
+
function makePgArray(array) {
|
|
1389
|
+
return `{${array.map((item) => {
|
|
1390
|
+
if (Array.isArray(item)) {
|
|
1391
|
+
return makePgArray(item);
|
|
1392
|
+
}
|
|
1393
|
+
if (typeof item === "string") {
|
|
1394
|
+
return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1395
|
+
}
|
|
1396
|
+
return `${item}`;
|
|
1397
|
+
}).join(",")}}`;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// ../../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
|
|
1401
|
+
var PgColumnBuilder = class extends ColumnBuilder {
|
|
1402
|
+
foreignKeyConfigs = [];
|
|
1403
|
+
static [entityKind] = "PgColumnBuilder";
|
|
1404
|
+
array(size) {
|
|
1405
|
+
return new PgArrayBuilder(this.config.name, this, size);
|
|
1406
|
+
}
|
|
1407
|
+
references(ref, actions = {}) {
|
|
1408
|
+
this.foreignKeyConfigs.push({ ref, actions });
|
|
1409
|
+
return this;
|
|
1410
|
+
}
|
|
1411
|
+
unique(name, config) {
|
|
1412
|
+
this.config.isUnique = true;
|
|
1413
|
+
this.config.uniqueName = name;
|
|
1414
|
+
this.config.uniqueType = config?.nulls;
|
|
1415
|
+
return this;
|
|
1416
|
+
}
|
|
1417
|
+
generatedAlwaysAs(as) {
|
|
1418
|
+
this.config.generated = {
|
|
1419
|
+
as,
|
|
1420
|
+
type: "always",
|
|
1421
|
+
mode: "stored"
|
|
1422
|
+
};
|
|
1423
|
+
return this;
|
|
1424
|
+
}
|
|
1425
|
+
/** @internal */
|
|
1426
|
+
buildForeignKeys(column, table) {
|
|
1427
|
+
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
1428
|
+
return iife(
|
|
1429
|
+
(ref2, actions2) => {
|
|
1430
|
+
const builder = new ForeignKeyBuilder(() => {
|
|
1431
|
+
const foreignColumn = ref2();
|
|
1432
|
+
return { columns: [column], foreignColumns: [foreignColumn] };
|
|
1433
|
+
});
|
|
1434
|
+
if (actions2.onUpdate) {
|
|
1435
|
+
builder.onUpdate(actions2.onUpdate);
|
|
1436
|
+
}
|
|
1437
|
+
if (actions2.onDelete) {
|
|
1438
|
+
builder.onDelete(actions2.onDelete);
|
|
1439
|
+
}
|
|
1440
|
+
return builder.build(table);
|
|
1441
|
+
},
|
|
1442
|
+
ref,
|
|
1443
|
+
actions
|
|
1444
|
+
);
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
/** @internal */
|
|
1448
|
+
buildExtraConfigColumn(table) {
|
|
1449
|
+
return new ExtraConfigColumn(table, this.config);
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
var PgColumn = class extends Column {
|
|
1453
|
+
constructor(table, config) {
|
|
1454
|
+
if (!config.uniqueName) {
|
|
1455
|
+
config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
1456
|
+
}
|
|
1457
|
+
super(table, config);
|
|
1458
|
+
this.table = table;
|
|
1459
|
+
}
|
|
1460
|
+
static [entityKind] = "PgColumn";
|
|
1461
|
+
};
|
|
1462
|
+
var ExtraConfigColumn = class extends PgColumn {
|
|
1463
|
+
static [entityKind] = "ExtraConfigColumn";
|
|
1464
|
+
getSQLType() {
|
|
1465
|
+
return this.getSQLType();
|
|
1466
|
+
}
|
|
1467
|
+
indexConfig = {
|
|
1468
|
+
order: this.config.order ?? "asc",
|
|
1469
|
+
nulls: this.config.nulls ?? "last",
|
|
1470
|
+
opClass: this.config.opClass
|
|
1471
|
+
};
|
|
1472
|
+
defaultConfig = {
|
|
1473
|
+
order: "asc",
|
|
1474
|
+
nulls: "last",
|
|
1475
|
+
opClass: void 0
|
|
1476
|
+
};
|
|
1477
|
+
asc() {
|
|
1478
|
+
this.indexConfig.order = "asc";
|
|
1479
|
+
return this;
|
|
1480
|
+
}
|
|
1481
|
+
desc() {
|
|
1482
|
+
this.indexConfig.order = "desc";
|
|
1483
|
+
return this;
|
|
1484
|
+
}
|
|
1485
|
+
nullsFirst() {
|
|
1486
|
+
this.indexConfig.nulls = "first";
|
|
1487
|
+
return this;
|
|
1488
|
+
}
|
|
1489
|
+
nullsLast() {
|
|
1490
|
+
this.indexConfig.nulls = "last";
|
|
1491
|
+
return this;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* ### PostgreSQL documentation quote
|
|
1495
|
+
*
|
|
1496
|
+
* > An operator class with optional parameters can be specified for each column of an index.
|
|
1497
|
+
* The operator class identifies the operators to be used by the index for that column.
|
|
1498
|
+
* For example, a B-tree index on four-byte integers would use the int4_ops class;
|
|
1499
|
+
* this operator class includes comparison functions for four-byte integers.
|
|
1500
|
+
* In practice the default operator class for the column's data type is usually sufficient.
|
|
1501
|
+
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
|
|
1502
|
+
* For example, we might want to sort a complex-number data type either by absolute value or by real part.
|
|
1503
|
+
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
|
|
1504
|
+
* More information about operator classes check:
|
|
1505
|
+
*
|
|
1506
|
+
* ### Useful links
|
|
1507
|
+
* https://www.postgresql.org/docs/current/sql-createindex.html
|
|
1508
|
+
*
|
|
1509
|
+
* https://www.postgresql.org/docs/current/indexes-opclass.html
|
|
1510
|
+
*
|
|
1511
|
+
* https://www.postgresql.org/docs/current/xindex.html
|
|
1512
|
+
*
|
|
1513
|
+
* ### Additional types
|
|
1514
|
+
* If you have the `pg_vector` extension installed in your database, you can use the
|
|
1515
|
+
* `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.
|
|
1516
|
+
*
|
|
1517
|
+
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
|
|
1518
|
+
*
|
|
1519
|
+
* @param opClass
|
|
1520
|
+
* @returns
|
|
1521
|
+
*/
|
|
1522
|
+
op(opClass) {
|
|
1523
|
+
this.indexConfig.opClass = opClass;
|
|
1524
|
+
return this;
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
var IndexedColumn = class {
|
|
1528
|
+
static [entityKind] = "IndexedColumn";
|
|
1529
|
+
constructor(name, keyAsName, type, indexConfig) {
|
|
1530
|
+
this.name = name;
|
|
1531
|
+
this.keyAsName = keyAsName;
|
|
1532
|
+
this.type = type;
|
|
1533
|
+
this.indexConfig = indexConfig;
|
|
1534
|
+
}
|
|
1535
|
+
name;
|
|
1536
|
+
keyAsName;
|
|
1537
|
+
type;
|
|
1538
|
+
indexConfig;
|
|
1539
|
+
};
|
|
1540
|
+
var PgArrayBuilder = class extends PgColumnBuilder {
|
|
1541
|
+
static [entityKind] = "PgArrayBuilder";
|
|
1542
|
+
constructor(name, baseBuilder, size) {
|
|
1543
|
+
super(name, "array", "PgArray");
|
|
1544
|
+
this.config.baseBuilder = baseBuilder;
|
|
1545
|
+
this.config.size = size;
|
|
1546
|
+
}
|
|
1547
|
+
/** @internal */
|
|
1548
|
+
build(table) {
|
|
1549
|
+
const baseColumn = this.config.baseBuilder.build(table);
|
|
1550
|
+
return new PgArray(
|
|
1551
|
+
table,
|
|
1552
|
+
this.config,
|
|
1553
|
+
baseColumn
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
var PgArray = class _PgArray extends PgColumn {
|
|
1558
|
+
constructor(table, config, baseColumn, range) {
|
|
1559
|
+
super(table, config);
|
|
1560
|
+
this.baseColumn = baseColumn;
|
|
1561
|
+
this.range = range;
|
|
1562
|
+
this.size = config.size;
|
|
1563
|
+
}
|
|
1564
|
+
size;
|
|
1565
|
+
static [entityKind] = "PgArray";
|
|
1566
|
+
getSQLType() {
|
|
1567
|
+
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
1568
|
+
}
|
|
1569
|
+
mapFromDriverValue(value) {
|
|
1570
|
+
if (typeof value === "string") {
|
|
1571
|
+
value = parsePgArray(value);
|
|
1572
|
+
}
|
|
1573
|
+
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
1574
|
+
}
|
|
1575
|
+
mapToDriverValue(value, isNestedArray = false) {
|
|
1576
|
+
const a = value.map(
|
|
1577
|
+
(v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v)
|
|
1578
|
+
);
|
|
1579
|
+
if (isNestedArray) return a;
|
|
1580
|
+
return makePgArray(a);
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
// ../../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
|
|
1585
|
+
var PgEnumObjectColumnBuilder = class extends PgColumnBuilder {
|
|
1586
|
+
static [entityKind] = "PgEnumObjectColumnBuilder";
|
|
1587
|
+
constructor(name, enumInstance) {
|
|
1588
|
+
super(name, "string", "PgEnumObjectColumn");
|
|
1589
|
+
this.config.enum = enumInstance;
|
|
1590
|
+
}
|
|
1591
|
+
/** @internal */
|
|
1592
|
+
build(table) {
|
|
1593
|
+
return new PgEnumObjectColumn(
|
|
1594
|
+
table,
|
|
1595
|
+
this.config
|
|
1596
|
+
);
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
var PgEnumObjectColumn = class extends PgColumn {
|
|
1600
|
+
static [entityKind] = "PgEnumObjectColumn";
|
|
1601
|
+
enum;
|
|
1602
|
+
enumValues = this.config.enum.enumValues;
|
|
1603
|
+
constructor(table, config) {
|
|
1604
|
+
super(table, config);
|
|
1605
|
+
this.enum = config.enum;
|
|
1606
|
+
}
|
|
1607
|
+
getSQLType() {
|
|
1608
|
+
return this.enum.enumName;
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
var isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
1612
|
+
function isPgEnum(obj) {
|
|
1613
|
+
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
1614
|
+
}
|
|
1615
|
+
var PgEnumColumnBuilder = class extends PgColumnBuilder {
|
|
1616
|
+
static [entityKind] = "PgEnumColumnBuilder";
|
|
1617
|
+
constructor(name, enumInstance) {
|
|
1618
|
+
super(name, "string", "PgEnumColumn");
|
|
1619
|
+
this.config.enum = enumInstance;
|
|
1620
|
+
}
|
|
1621
|
+
/** @internal */
|
|
1622
|
+
build(table) {
|
|
1623
|
+
return new PgEnumColumn(
|
|
1624
|
+
table,
|
|
1625
|
+
this.config
|
|
1626
|
+
);
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
var PgEnumColumn = class extends PgColumn {
|
|
1630
|
+
static [entityKind] = "PgEnumColumn";
|
|
1631
|
+
enum = this.config.enum;
|
|
1632
|
+
enumValues = this.config.enum.enumValues;
|
|
1633
|
+
constructor(table, config) {
|
|
1634
|
+
super(table, config);
|
|
1635
|
+
this.enum = config.enum;
|
|
1636
|
+
}
|
|
1637
|
+
getSQLType() {
|
|
1638
|
+
return this.enum.enumName;
|
|
1639
|
+
}
|
|
1640
|
+
};
|
|
1641
|
+
function pgEnum(enumName, input) {
|
|
1642
|
+
return Array.isArray(input) ? pgEnumWithSchema(enumName, [...input], void 0) : pgEnumObjectWithSchema(enumName, input, void 0);
|
|
1643
|
+
}
|
|
1644
|
+
function pgEnumWithSchema(enumName, values, schema) {
|
|
1645
|
+
const enumInstance = Object.assign(
|
|
1646
|
+
(name) => new PgEnumColumnBuilder(name ?? "", enumInstance),
|
|
1647
|
+
{
|
|
1648
|
+
enumName,
|
|
1649
|
+
enumValues: values,
|
|
1650
|
+
schema,
|
|
1651
|
+
[isPgEnumSym]: true
|
|
1652
|
+
}
|
|
1653
|
+
);
|
|
1654
|
+
return enumInstance;
|
|
1655
|
+
}
|
|
1656
|
+
function pgEnumObjectWithSchema(enumName, values, schema) {
|
|
1657
|
+
const enumInstance = Object.assign(
|
|
1658
|
+
(name) => new PgEnumObjectColumnBuilder(name ?? "", enumInstance),
|
|
1659
|
+
{
|
|
1660
|
+
enumName,
|
|
1661
|
+
enumValues: Object.values(values),
|
|
1662
|
+
schema,
|
|
1663
|
+
[isPgEnumSym]: true
|
|
1664
|
+
}
|
|
1665
|
+
);
|
|
1666
|
+
return enumInstance;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
// ../../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
|
|
1670
|
+
var Subquery = class {
|
|
1671
|
+
static [entityKind] = "Subquery";
|
|
1672
|
+
constructor(sql2, fields, alias, isWith = false, usedTables = []) {
|
|
1673
|
+
this._ = {
|
|
1674
|
+
brand: "Subquery",
|
|
1675
|
+
sql: sql2,
|
|
1676
|
+
selectedFields: fields,
|
|
1677
|
+
alias,
|
|
1678
|
+
isWith,
|
|
1679
|
+
usedTables
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
// getSQL(): SQL<unknown> {
|
|
1683
|
+
// return new SQL([this]);
|
|
1684
|
+
// }
|
|
1685
|
+
};
|
|
1686
|
+
var WithSubquery = class extends Subquery {
|
|
1687
|
+
static [entityKind] = "WithSubquery";
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
// ../../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
|
|
1691
|
+
var version = "0.45.2";
|
|
1692
|
+
|
|
1693
|
+
// ../../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
|
|
1694
|
+
var otel;
|
|
1695
|
+
var rawTracer;
|
|
1696
|
+
var tracer = {
|
|
1697
|
+
startActiveSpan(name, fn) {
|
|
1698
|
+
if (!otel) {
|
|
1699
|
+
return fn();
|
|
1700
|
+
}
|
|
1701
|
+
if (!rawTracer) {
|
|
1702
|
+
rawTracer = otel.trace.getTracer("drizzle-orm", version);
|
|
1703
|
+
}
|
|
1704
|
+
return iife(
|
|
1705
|
+
(otel2, rawTracer2) => rawTracer2.startActiveSpan(
|
|
1706
|
+
name,
|
|
1707
|
+
(span) => {
|
|
1708
|
+
try {
|
|
1709
|
+
return fn(span);
|
|
1710
|
+
} catch (e) {
|
|
1711
|
+
span.setStatus({
|
|
1712
|
+
code: otel2.SpanStatusCode.ERROR,
|
|
1713
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
|
1714
|
+
// eslint-disable-line no-instanceof/no-instanceof
|
|
1715
|
+
});
|
|
1716
|
+
throw e;
|
|
1717
|
+
} finally {
|
|
1718
|
+
span.end();
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
),
|
|
1722
|
+
otel,
|
|
1723
|
+
rawTracer
|
|
1724
|
+
);
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
// ../../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
|
|
1729
|
+
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
1730
|
+
|
|
1731
|
+
// ../../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
|
|
1732
|
+
var Schema = Symbol.for("drizzle:Schema");
|
|
1733
|
+
var Columns = Symbol.for("drizzle:Columns");
|
|
1734
|
+
var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
1735
|
+
var OriginalName = Symbol.for("drizzle:OriginalName");
|
|
1736
|
+
var BaseName = Symbol.for("drizzle:BaseName");
|
|
1737
|
+
var IsAlias = Symbol.for("drizzle:IsAlias");
|
|
1738
|
+
var ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
|
1739
|
+
var IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
|
1740
|
+
var Table = class {
|
|
1741
|
+
static [entityKind] = "Table";
|
|
1742
|
+
/** @internal */
|
|
1743
|
+
static Symbol = {
|
|
1744
|
+
Name: TableName,
|
|
1745
|
+
Schema,
|
|
1746
|
+
OriginalName,
|
|
1747
|
+
Columns,
|
|
1748
|
+
ExtraConfigColumns,
|
|
1749
|
+
BaseName,
|
|
1750
|
+
IsAlias,
|
|
1751
|
+
ExtraConfigBuilder
|
|
1752
|
+
};
|
|
1753
|
+
/**
|
|
1754
|
+
* @internal
|
|
1755
|
+
* Can be changed if the table is aliased.
|
|
1756
|
+
*/
|
|
1757
|
+
[TableName];
|
|
1758
|
+
/**
|
|
1759
|
+
* @internal
|
|
1760
|
+
* Used to store the original name of the table, before any aliasing.
|
|
1761
|
+
*/
|
|
1762
|
+
[OriginalName];
|
|
1763
|
+
/** @internal */
|
|
1764
|
+
[Schema];
|
|
1765
|
+
/** @internal */
|
|
1766
|
+
[Columns];
|
|
1767
|
+
/** @internal */
|
|
1768
|
+
[ExtraConfigColumns];
|
|
1769
|
+
/**
|
|
1770
|
+
* @internal
|
|
1771
|
+
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
1772
|
+
*/
|
|
1773
|
+
[BaseName];
|
|
1774
|
+
/** @internal */
|
|
1775
|
+
[IsAlias] = false;
|
|
1776
|
+
/** @internal */
|
|
1777
|
+
[IsDrizzleTable] = true;
|
|
1778
|
+
/** @internal */
|
|
1779
|
+
[ExtraConfigBuilder] = void 0;
|
|
1780
|
+
constructor(name, schema, baseName) {
|
|
1781
|
+
this[TableName] = this[OriginalName] = name;
|
|
1782
|
+
this[Schema] = schema;
|
|
1783
|
+
this[BaseName] = baseName;
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1787
|
+
// ../../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
|
|
1788
|
+
var FakePrimitiveParam = class {
|
|
1789
|
+
static [entityKind] = "FakePrimitiveParam";
|
|
1790
|
+
};
|
|
1791
|
+
function isSQLWrapper(value) {
|
|
1792
|
+
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
1793
|
+
}
|
|
1794
|
+
function mergeQueries(queries) {
|
|
1795
|
+
const result = { sql: "", params: [] };
|
|
1796
|
+
for (const query of queries) {
|
|
1797
|
+
result.sql += query.sql;
|
|
1798
|
+
result.params.push(...query.params);
|
|
1799
|
+
if (query.typings?.length) {
|
|
1800
|
+
if (!result.typings) {
|
|
1801
|
+
result.typings = [];
|
|
1802
|
+
}
|
|
1803
|
+
result.typings.push(...query.typings);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return result;
|
|
1807
|
+
}
|
|
1808
|
+
var StringChunk = class {
|
|
1809
|
+
static [entityKind] = "StringChunk";
|
|
1810
|
+
value;
|
|
1811
|
+
constructor(value) {
|
|
1812
|
+
this.value = Array.isArray(value) ? value : [value];
|
|
1813
|
+
}
|
|
1814
|
+
getSQL() {
|
|
1815
|
+
return new SQL([this]);
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
var SQL = class _SQL {
|
|
1819
|
+
constructor(queryChunks) {
|
|
1820
|
+
this.queryChunks = queryChunks;
|
|
1821
|
+
for (const chunk of queryChunks) {
|
|
1822
|
+
if (is(chunk, Table)) {
|
|
1823
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
1824
|
+
this.usedTables.push(
|
|
1825
|
+
schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
static [entityKind] = "SQL";
|
|
1831
|
+
/** @internal */
|
|
1832
|
+
decoder = noopDecoder;
|
|
1833
|
+
shouldInlineParams = false;
|
|
1834
|
+
/** @internal */
|
|
1835
|
+
usedTables = [];
|
|
1836
|
+
append(query) {
|
|
1837
|
+
this.queryChunks.push(...query.queryChunks);
|
|
1838
|
+
return this;
|
|
1839
|
+
}
|
|
1840
|
+
toQuery(config) {
|
|
1841
|
+
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
1842
|
+
const query = this.buildQueryFromSourceParams(this.queryChunks, config);
|
|
1843
|
+
span?.setAttributes({
|
|
1844
|
+
"drizzle.query.text": query.sql,
|
|
1845
|
+
"drizzle.query.params": JSON.stringify(query.params)
|
|
1846
|
+
});
|
|
1847
|
+
return query;
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
buildQueryFromSourceParams(chunks, _config) {
|
|
1851
|
+
const config = Object.assign({}, _config, {
|
|
1852
|
+
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
1853
|
+
paramStartIndex: _config.paramStartIndex || { value: 0 }
|
|
1854
|
+
});
|
|
1855
|
+
const {
|
|
1856
|
+
casing,
|
|
1857
|
+
escapeName,
|
|
1858
|
+
escapeParam,
|
|
1859
|
+
prepareTyping,
|
|
1860
|
+
inlineParams,
|
|
1861
|
+
paramStartIndex
|
|
1862
|
+
} = config;
|
|
1863
|
+
return mergeQueries(chunks.map((chunk) => {
|
|
1864
|
+
if (is(chunk, StringChunk)) {
|
|
1865
|
+
return { sql: chunk.value.join(""), params: [] };
|
|
1866
|
+
}
|
|
1867
|
+
if (is(chunk, Name)) {
|
|
1868
|
+
return { sql: escapeName(chunk.value), params: [] };
|
|
1869
|
+
}
|
|
1870
|
+
if (chunk === void 0) {
|
|
1871
|
+
return { sql: "", params: [] };
|
|
1872
|
+
}
|
|
1873
|
+
if (Array.isArray(chunk)) {
|
|
1874
|
+
const result = [new StringChunk("(")];
|
|
1875
|
+
for (const [i, p] of chunk.entries()) {
|
|
1876
|
+
result.push(p);
|
|
1877
|
+
if (i < chunk.length - 1) {
|
|
1878
|
+
result.push(new StringChunk(", "));
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
result.push(new StringChunk(")"));
|
|
1882
|
+
return this.buildQueryFromSourceParams(result, config);
|
|
1883
|
+
}
|
|
1884
|
+
if (is(chunk, _SQL)) {
|
|
1885
|
+
return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
1886
|
+
...config,
|
|
1887
|
+
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
if (is(chunk, Table)) {
|
|
1891
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
1892
|
+
const tableName = chunk[Table.Symbol.Name];
|
|
1893
|
+
return {
|
|
1894
|
+
sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
1895
|
+
params: []
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
if (is(chunk, Column)) {
|
|
1899
|
+
const columnName = casing.getColumnCasing(chunk);
|
|
1900
|
+
if (_config.invokeSource === "indexes") {
|
|
1901
|
+
return { sql: escapeName(columnName), params: [] };
|
|
1902
|
+
}
|
|
1903
|
+
const schemaName = chunk.table[Table.Symbol.Schema];
|
|
1904
|
+
return {
|
|
1905
|
+
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),
|
|
1906
|
+
params: []
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
if (is(chunk, View)) {
|
|
1910
|
+
const schemaName = chunk[ViewBaseConfig].schema;
|
|
1911
|
+
const viewName = chunk[ViewBaseConfig].name;
|
|
1912
|
+
return {
|
|
1913
|
+
sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
1914
|
+
params: []
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
if (is(chunk, Param)) {
|
|
1918
|
+
if (is(chunk.value, Placeholder)) {
|
|
1919
|
+
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
1920
|
+
}
|
|
1921
|
+
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
1922
|
+
if (is(mappedValue, _SQL)) {
|
|
1923
|
+
return this.buildQueryFromSourceParams([mappedValue], config);
|
|
1924
|
+
}
|
|
1925
|
+
if (inlineParams) {
|
|
1926
|
+
return { sql: this.mapInlineParam(mappedValue, config), params: [] };
|
|
1927
|
+
}
|
|
1928
|
+
let typings = ["none"];
|
|
1929
|
+
if (prepareTyping) {
|
|
1930
|
+
typings = [prepareTyping(chunk.encoder)];
|
|
1931
|
+
}
|
|
1932
|
+
return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
|
|
1933
|
+
}
|
|
1934
|
+
if (is(chunk, Placeholder)) {
|
|
1935
|
+
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
1936
|
+
}
|
|
1937
|
+
if (is(chunk, _SQL.Aliased) && chunk.fieldAlias !== void 0) {
|
|
1938
|
+
return { sql: escapeName(chunk.fieldAlias), params: [] };
|
|
1939
|
+
}
|
|
1940
|
+
if (is(chunk, Subquery)) {
|
|
1941
|
+
if (chunk._.isWith) {
|
|
1942
|
+
return { sql: escapeName(chunk._.alias), params: [] };
|
|
1943
|
+
}
|
|
1944
|
+
return this.buildQueryFromSourceParams([
|
|
1945
|
+
new StringChunk("("),
|
|
1946
|
+
chunk._.sql,
|
|
1947
|
+
new StringChunk(") "),
|
|
1948
|
+
new Name(chunk._.alias)
|
|
1949
|
+
], config);
|
|
1950
|
+
}
|
|
1951
|
+
if (isPgEnum(chunk)) {
|
|
1952
|
+
if (chunk.schema) {
|
|
1953
|
+
return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
|
|
1954
|
+
}
|
|
1955
|
+
return { sql: escapeName(chunk.enumName), params: [] };
|
|
1956
|
+
}
|
|
1957
|
+
if (isSQLWrapper(chunk)) {
|
|
1958
|
+
if (chunk.shouldOmitSQLParens?.()) {
|
|
1959
|
+
return this.buildQueryFromSourceParams([chunk.getSQL()], config);
|
|
1960
|
+
}
|
|
1961
|
+
return this.buildQueryFromSourceParams([
|
|
1962
|
+
new StringChunk("("),
|
|
1963
|
+
chunk.getSQL(),
|
|
1964
|
+
new StringChunk(")")
|
|
1965
|
+
], config);
|
|
1966
|
+
}
|
|
1967
|
+
if (inlineParams) {
|
|
1968
|
+
return { sql: this.mapInlineParam(chunk, config), params: [] };
|
|
1969
|
+
}
|
|
1970
|
+
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
1971
|
+
}));
|
|
1972
|
+
}
|
|
1973
|
+
mapInlineParam(chunk, { escapeString }) {
|
|
1974
|
+
if (chunk === null) {
|
|
1975
|
+
return "null";
|
|
1976
|
+
}
|
|
1977
|
+
if (typeof chunk === "number" || typeof chunk === "boolean") {
|
|
1978
|
+
return chunk.toString();
|
|
1979
|
+
}
|
|
1980
|
+
if (typeof chunk === "string") {
|
|
1981
|
+
return escapeString(chunk);
|
|
1982
|
+
}
|
|
1983
|
+
if (typeof chunk === "object") {
|
|
1984
|
+
const mappedValueAsString = chunk.toString();
|
|
1985
|
+
if (mappedValueAsString === "[object Object]") {
|
|
1986
|
+
return escapeString(JSON.stringify(chunk));
|
|
1987
|
+
}
|
|
1988
|
+
return escapeString(mappedValueAsString);
|
|
1989
|
+
}
|
|
1990
|
+
throw new Error("Unexpected param value: " + chunk);
|
|
1991
|
+
}
|
|
1992
|
+
getSQL() {
|
|
1993
|
+
return this;
|
|
1994
|
+
}
|
|
1995
|
+
as(alias) {
|
|
1996
|
+
if (alias === void 0) {
|
|
1997
|
+
return this;
|
|
1998
|
+
}
|
|
1999
|
+
return new _SQL.Aliased(this, alias);
|
|
2000
|
+
}
|
|
2001
|
+
mapWith(decoder) {
|
|
2002
|
+
this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
|
|
2003
|
+
return this;
|
|
2004
|
+
}
|
|
2005
|
+
inlineParams() {
|
|
2006
|
+
this.shouldInlineParams = true;
|
|
2007
|
+
return this;
|
|
2008
|
+
}
|
|
2009
|
+
/**
|
|
2010
|
+
* This method is used to conditionally include a part of the query.
|
|
2011
|
+
*
|
|
2012
|
+
* @param condition - Condition to check
|
|
2013
|
+
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
2014
|
+
*/
|
|
2015
|
+
if(condition) {
|
|
2016
|
+
return condition ? this : void 0;
|
|
2017
|
+
}
|
|
2018
|
+
};
|
|
2019
|
+
var Name = class {
|
|
2020
|
+
constructor(value) {
|
|
2021
|
+
this.value = value;
|
|
2022
|
+
}
|
|
2023
|
+
static [entityKind] = "Name";
|
|
2024
|
+
brand;
|
|
2025
|
+
getSQL() {
|
|
2026
|
+
return new SQL([this]);
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
var noopDecoder = {
|
|
2030
|
+
mapFromDriverValue: (value) => value
|
|
2031
|
+
};
|
|
2032
|
+
var noopEncoder = {
|
|
2033
|
+
mapToDriverValue: (value) => value
|
|
2034
|
+
};
|
|
2035
|
+
var noopMapper = {
|
|
2036
|
+
...noopDecoder,
|
|
2037
|
+
...noopEncoder
|
|
2038
|
+
};
|
|
2039
|
+
var Param = class {
|
|
2040
|
+
/**
|
|
2041
|
+
* @param value - Parameter value
|
|
2042
|
+
* @param encoder - Encoder to convert the value to a driver parameter
|
|
2043
|
+
*/
|
|
2044
|
+
constructor(value, encoder = noopEncoder) {
|
|
2045
|
+
this.value = value;
|
|
2046
|
+
this.encoder = encoder;
|
|
2047
|
+
}
|
|
2048
|
+
static [entityKind] = "Param";
|
|
2049
|
+
brand;
|
|
2050
|
+
getSQL() {
|
|
2051
|
+
return new SQL([this]);
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
function sql(strings, ...params) {
|
|
2055
|
+
const queryChunks = [];
|
|
2056
|
+
if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
|
|
2057
|
+
queryChunks.push(new StringChunk(strings[0]));
|
|
2058
|
+
}
|
|
2059
|
+
for (const [paramIndex, param2] of params.entries()) {
|
|
2060
|
+
queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
2061
|
+
}
|
|
2062
|
+
return new SQL(queryChunks);
|
|
2063
|
+
}
|
|
2064
|
+
((sql2) => {
|
|
2065
|
+
function empty() {
|
|
2066
|
+
return new SQL([]);
|
|
2067
|
+
}
|
|
2068
|
+
sql2.empty = empty;
|
|
2069
|
+
function fromList(list) {
|
|
2070
|
+
return new SQL(list);
|
|
2071
|
+
}
|
|
2072
|
+
sql2.fromList = fromList;
|
|
2073
|
+
function raw(str) {
|
|
2074
|
+
return new SQL([new StringChunk(str)]);
|
|
2075
|
+
}
|
|
2076
|
+
sql2.raw = raw;
|
|
2077
|
+
function join(chunks, separator) {
|
|
2078
|
+
const result = [];
|
|
2079
|
+
for (const [i, chunk] of chunks.entries()) {
|
|
2080
|
+
if (i > 0 && separator !== void 0) {
|
|
2081
|
+
result.push(separator);
|
|
2082
|
+
}
|
|
2083
|
+
result.push(chunk);
|
|
2084
|
+
}
|
|
2085
|
+
return new SQL(result);
|
|
2086
|
+
}
|
|
2087
|
+
sql2.join = join;
|
|
2088
|
+
function identifier(value) {
|
|
2089
|
+
return new Name(value);
|
|
2090
|
+
}
|
|
2091
|
+
sql2.identifier = identifier;
|
|
2092
|
+
function placeholder2(name2) {
|
|
2093
|
+
return new Placeholder(name2);
|
|
2094
|
+
}
|
|
2095
|
+
sql2.placeholder = placeholder2;
|
|
2096
|
+
function param2(value, encoder) {
|
|
2097
|
+
return new Param(value, encoder);
|
|
2098
|
+
}
|
|
2099
|
+
sql2.param = param2;
|
|
2100
|
+
})(sql || (sql = {}));
|
|
2101
|
+
((SQL2) => {
|
|
2102
|
+
class Aliased {
|
|
2103
|
+
constructor(sql2, fieldAlias) {
|
|
2104
|
+
this.sql = sql2;
|
|
2105
|
+
this.fieldAlias = fieldAlias;
|
|
2106
|
+
}
|
|
2107
|
+
static [entityKind] = "SQL.Aliased";
|
|
2108
|
+
/** @internal */
|
|
2109
|
+
isSelectionField = false;
|
|
2110
|
+
getSQL() {
|
|
2111
|
+
return this.sql;
|
|
2112
|
+
}
|
|
2113
|
+
/** @internal */
|
|
2114
|
+
clone() {
|
|
2115
|
+
return new Aliased(this.sql, this.fieldAlias);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
SQL2.Aliased = Aliased;
|
|
2119
|
+
})(SQL || (SQL = {}));
|
|
2120
|
+
var Placeholder = class {
|
|
2121
|
+
constructor(name2) {
|
|
2122
|
+
this.name = name2;
|
|
2123
|
+
}
|
|
2124
|
+
static [entityKind] = "Placeholder";
|
|
2125
|
+
getSQL() {
|
|
2126
|
+
return new SQL([this]);
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
var IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
|
|
2130
|
+
var View = class {
|
|
2131
|
+
static [entityKind] = "View";
|
|
2132
|
+
/** @internal */
|
|
2133
|
+
[ViewBaseConfig];
|
|
2134
|
+
/** @internal */
|
|
2135
|
+
[IsDrizzleView] = true;
|
|
2136
|
+
constructor({ name: name2, schema, selectedFields, query }) {
|
|
2137
|
+
this[ViewBaseConfig] = {
|
|
2138
|
+
name: name2,
|
|
2139
|
+
originalName: name2,
|
|
2140
|
+
schema,
|
|
2141
|
+
selectedFields,
|
|
2142
|
+
query,
|
|
2143
|
+
isExisting: !query,
|
|
2144
|
+
isAlias: false
|
|
2145
|
+
};
|
|
2146
|
+
}
|
|
2147
|
+
getSQL() {
|
|
2148
|
+
return new SQL([this]);
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
Column.prototype.getSQL = function() {
|
|
2152
|
+
return new SQL([this]);
|
|
2153
|
+
};
|
|
2154
|
+
Table.prototype.getSQL = function() {
|
|
2155
|
+
return new SQL([this]);
|
|
2156
|
+
};
|
|
2157
|
+
Subquery.prototype.getSQL = function() {
|
|
2158
|
+
return new SQL([this]);
|
|
2159
|
+
};
|
|
2160
|
+
|
|
2161
|
+
// ../../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
|
|
2162
|
+
function getColumnNameAndConfig(a, b) {
|
|
2163
|
+
return {
|
|
2164
|
+
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
2165
|
+
config: typeof a === "object" ? a : b
|
|
2166
|
+
};
|
|
2167
|
+
}
|
|
2168
|
+
var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder();
|
|
2169
|
+
|
|
2170
|
+
// ../../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
|
|
2171
|
+
var PgIntColumnBaseBuilder = class extends PgColumnBuilder {
|
|
2172
|
+
static [entityKind] = "PgIntColumnBaseBuilder";
|
|
2173
|
+
generatedAlwaysAsIdentity(sequence) {
|
|
2174
|
+
if (sequence) {
|
|
2175
|
+
const { name, ...options } = sequence;
|
|
2176
|
+
this.config.generatedIdentity = {
|
|
2177
|
+
type: "always",
|
|
2178
|
+
sequenceName: name,
|
|
2179
|
+
sequenceOptions: options
|
|
2180
|
+
};
|
|
2181
|
+
} else {
|
|
2182
|
+
this.config.generatedIdentity = {
|
|
2183
|
+
type: "always"
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
this.config.hasDefault = true;
|
|
2187
|
+
this.config.notNull = true;
|
|
2188
|
+
return this;
|
|
2189
|
+
}
|
|
2190
|
+
generatedByDefaultAsIdentity(sequence) {
|
|
2191
|
+
if (sequence) {
|
|
2192
|
+
const { name, ...options } = sequence;
|
|
2193
|
+
this.config.generatedIdentity = {
|
|
2194
|
+
type: "byDefault",
|
|
2195
|
+
sequenceName: name,
|
|
2196
|
+
sequenceOptions: options
|
|
2197
|
+
};
|
|
2198
|
+
} else {
|
|
2199
|
+
this.config.generatedIdentity = {
|
|
2200
|
+
type: "byDefault"
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
this.config.hasDefault = true;
|
|
2204
|
+
this.config.notNull = true;
|
|
2205
|
+
return this;
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2209
|
+
// ../../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
|
|
2210
|
+
var PgBigInt53Builder = class extends PgIntColumnBaseBuilder {
|
|
2211
|
+
static [entityKind] = "PgBigInt53Builder";
|
|
2212
|
+
constructor(name) {
|
|
2213
|
+
super(name, "number", "PgBigInt53");
|
|
2214
|
+
}
|
|
2215
|
+
/** @internal */
|
|
2216
|
+
build(table) {
|
|
2217
|
+
return new PgBigInt53(table, this.config);
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
var PgBigInt53 = class extends PgColumn {
|
|
2221
|
+
static [entityKind] = "PgBigInt53";
|
|
2222
|
+
getSQLType() {
|
|
2223
|
+
return "bigint";
|
|
2224
|
+
}
|
|
2225
|
+
mapFromDriverValue(value) {
|
|
2226
|
+
if (typeof value === "number") {
|
|
2227
|
+
return value;
|
|
2228
|
+
}
|
|
2229
|
+
return Number(value);
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
var PgBigInt64Builder = class extends PgIntColumnBaseBuilder {
|
|
2233
|
+
static [entityKind] = "PgBigInt64Builder";
|
|
2234
|
+
constructor(name) {
|
|
2235
|
+
super(name, "bigint", "PgBigInt64");
|
|
2236
|
+
}
|
|
2237
|
+
/** @internal */
|
|
2238
|
+
build(table) {
|
|
2239
|
+
return new PgBigInt64(
|
|
2240
|
+
table,
|
|
2241
|
+
this.config
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
var PgBigInt64 = class extends PgColumn {
|
|
2246
|
+
static [entityKind] = "PgBigInt64";
|
|
2247
|
+
getSQLType() {
|
|
2248
|
+
return "bigint";
|
|
2249
|
+
}
|
|
2250
|
+
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
|
|
2251
|
+
mapFromDriverValue(value) {
|
|
2252
|
+
return BigInt(value);
|
|
2253
|
+
}
|
|
2254
|
+
};
|
|
2255
|
+
function bigint(a, b) {
|
|
2256
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2257
|
+
if (config.mode === "number") {
|
|
2258
|
+
return new PgBigInt53Builder(name);
|
|
2259
|
+
}
|
|
2260
|
+
return new PgBigInt64Builder(name);
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
// ../../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
|
|
2264
|
+
var PgBigSerial53Builder = class extends PgColumnBuilder {
|
|
2265
|
+
static [entityKind] = "PgBigSerial53Builder";
|
|
2266
|
+
constructor(name) {
|
|
2267
|
+
super(name, "number", "PgBigSerial53");
|
|
2268
|
+
this.config.hasDefault = true;
|
|
2269
|
+
this.config.notNull = true;
|
|
2270
|
+
}
|
|
2271
|
+
/** @internal */
|
|
2272
|
+
build(table) {
|
|
2273
|
+
return new PgBigSerial53(
|
|
2274
|
+
table,
|
|
2275
|
+
this.config
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
var PgBigSerial53 = class extends PgColumn {
|
|
2280
|
+
static [entityKind] = "PgBigSerial53";
|
|
2281
|
+
getSQLType() {
|
|
2282
|
+
return "bigserial";
|
|
2283
|
+
}
|
|
2284
|
+
mapFromDriverValue(value) {
|
|
2285
|
+
if (typeof value === "number") {
|
|
2286
|
+
return value;
|
|
2287
|
+
}
|
|
2288
|
+
return Number(value);
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2291
|
+
var PgBigSerial64Builder = class extends PgColumnBuilder {
|
|
2292
|
+
static [entityKind] = "PgBigSerial64Builder";
|
|
2293
|
+
constructor(name) {
|
|
2294
|
+
super(name, "bigint", "PgBigSerial64");
|
|
2295
|
+
this.config.hasDefault = true;
|
|
2296
|
+
}
|
|
2297
|
+
/** @internal */
|
|
2298
|
+
build(table) {
|
|
2299
|
+
return new PgBigSerial64(
|
|
2300
|
+
table,
|
|
2301
|
+
this.config
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
var PgBigSerial64 = class extends PgColumn {
|
|
2306
|
+
static [entityKind] = "PgBigSerial64";
|
|
2307
|
+
getSQLType() {
|
|
2308
|
+
return "bigserial";
|
|
2309
|
+
}
|
|
2310
|
+
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
|
|
2311
|
+
mapFromDriverValue(value) {
|
|
2312
|
+
return BigInt(value);
|
|
2313
|
+
}
|
|
2314
|
+
};
|
|
2315
|
+
function bigserial(a, b) {
|
|
2316
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2317
|
+
if (config.mode === "number") {
|
|
2318
|
+
return new PgBigSerial53Builder(name);
|
|
2319
|
+
}
|
|
2320
|
+
return new PgBigSerial64Builder(name);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
// ../../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
|
|
2324
|
+
var PgBooleanBuilder = class extends PgColumnBuilder {
|
|
2325
|
+
static [entityKind] = "PgBooleanBuilder";
|
|
2326
|
+
constructor(name) {
|
|
2327
|
+
super(name, "boolean", "PgBoolean");
|
|
2328
|
+
}
|
|
2329
|
+
/** @internal */
|
|
2330
|
+
build(table) {
|
|
2331
|
+
return new PgBoolean(table, this.config);
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
var PgBoolean = class extends PgColumn {
|
|
2335
|
+
static [entityKind] = "PgBoolean";
|
|
2336
|
+
getSQLType() {
|
|
2337
|
+
return "boolean";
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2340
|
+
function boolean(name) {
|
|
2341
|
+
return new PgBooleanBuilder(name ?? "");
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
// ../../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
|
|
2345
|
+
var PgCharBuilder = class extends PgColumnBuilder {
|
|
2346
|
+
static [entityKind] = "PgCharBuilder";
|
|
2347
|
+
constructor(name, config) {
|
|
2348
|
+
super(name, "string", "PgChar");
|
|
2349
|
+
this.config.length = config.length;
|
|
2350
|
+
this.config.enumValues = config.enum;
|
|
2351
|
+
}
|
|
2352
|
+
/** @internal */
|
|
2353
|
+
build(table) {
|
|
2354
|
+
return new PgChar(
|
|
2355
|
+
table,
|
|
2356
|
+
this.config
|
|
2357
|
+
);
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
var PgChar = class extends PgColumn {
|
|
2361
|
+
static [entityKind] = "PgChar";
|
|
2362
|
+
length = this.config.length;
|
|
2363
|
+
enumValues = this.config.enumValues;
|
|
2364
|
+
getSQLType() {
|
|
2365
|
+
return this.length === void 0 ? `char` : `char(${this.length})`;
|
|
2366
|
+
}
|
|
2367
|
+
};
|
|
2368
|
+
function char(a, b = {}) {
|
|
2369
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2370
|
+
return new PgCharBuilder(name, config);
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
// ../../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
|
|
2374
|
+
var PgCidrBuilder = class extends PgColumnBuilder {
|
|
2375
|
+
static [entityKind] = "PgCidrBuilder";
|
|
2376
|
+
constructor(name) {
|
|
2377
|
+
super(name, "string", "PgCidr");
|
|
2378
|
+
}
|
|
2379
|
+
/** @internal */
|
|
2380
|
+
build(table) {
|
|
2381
|
+
return new PgCidr(table, this.config);
|
|
2382
|
+
}
|
|
2383
|
+
};
|
|
2384
|
+
var PgCidr = class extends PgColumn {
|
|
2385
|
+
static [entityKind] = "PgCidr";
|
|
2386
|
+
getSQLType() {
|
|
2387
|
+
return "cidr";
|
|
2388
|
+
}
|
|
2389
|
+
};
|
|
2390
|
+
function cidr(name) {
|
|
2391
|
+
return new PgCidrBuilder(name ?? "");
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
// ../../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
|
|
2395
|
+
var PgCustomColumnBuilder = class extends PgColumnBuilder {
|
|
2396
|
+
static [entityKind] = "PgCustomColumnBuilder";
|
|
2397
|
+
constructor(name, fieldConfig, customTypeParams) {
|
|
2398
|
+
super(name, "custom", "PgCustomColumn");
|
|
2399
|
+
this.config.fieldConfig = fieldConfig;
|
|
2400
|
+
this.config.customTypeParams = customTypeParams;
|
|
2401
|
+
}
|
|
2402
|
+
/** @internal */
|
|
2403
|
+
build(table) {
|
|
2404
|
+
return new PgCustomColumn(
|
|
2405
|
+
table,
|
|
2406
|
+
this.config
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
var PgCustomColumn = class extends PgColumn {
|
|
2411
|
+
static [entityKind] = "PgCustomColumn";
|
|
2412
|
+
sqlName;
|
|
2413
|
+
mapTo;
|
|
2414
|
+
mapFrom;
|
|
2415
|
+
constructor(table, config) {
|
|
2416
|
+
super(table, config);
|
|
2417
|
+
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
2418
|
+
this.mapTo = config.customTypeParams.toDriver;
|
|
2419
|
+
this.mapFrom = config.customTypeParams.fromDriver;
|
|
2420
|
+
}
|
|
2421
|
+
getSQLType() {
|
|
2422
|
+
return this.sqlName;
|
|
2423
|
+
}
|
|
2424
|
+
mapFromDriverValue(value) {
|
|
2425
|
+
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
2426
|
+
}
|
|
2427
|
+
mapToDriverValue(value) {
|
|
2428
|
+
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
function customType(customTypeParams) {
|
|
2432
|
+
return (a, b) => {
|
|
2433
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2434
|
+
return new PgCustomColumnBuilder(name, config, customTypeParams);
|
|
2435
|
+
};
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
// ../../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
|
|
2439
|
+
var PgDateColumnBaseBuilder = class extends PgColumnBuilder {
|
|
2440
|
+
static [entityKind] = "PgDateColumnBaseBuilder";
|
|
2441
|
+
defaultNow() {
|
|
2442
|
+
return this.default(sql`now()`);
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
|
|
2446
|
+
// ../../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
|
|
2447
|
+
var PgDateBuilder = class extends PgDateColumnBaseBuilder {
|
|
2448
|
+
static [entityKind] = "PgDateBuilder";
|
|
2449
|
+
constructor(name) {
|
|
2450
|
+
super(name, "date", "PgDate");
|
|
2451
|
+
}
|
|
2452
|
+
/** @internal */
|
|
2453
|
+
build(table) {
|
|
2454
|
+
return new PgDate(table, this.config);
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
var PgDate = class extends PgColumn {
|
|
2458
|
+
static [entityKind] = "PgDate";
|
|
2459
|
+
getSQLType() {
|
|
2460
|
+
return "date";
|
|
2461
|
+
}
|
|
2462
|
+
mapFromDriverValue(value) {
|
|
2463
|
+
if (typeof value === "string") return new Date(value);
|
|
2464
|
+
return value;
|
|
2465
|
+
}
|
|
2466
|
+
mapToDriverValue(value) {
|
|
2467
|
+
return value.toISOString();
|
|
2468
|
+
}
|
|
2469
|
+
};
|
|
2470
|
+
var PgDateStringBuilder = class extends PgDateColumnBaseBuilder {
|
|
2471
|
+
static [entityKind] = "PgDateStringBuilder";
|
|
2472
|
+
constructor(name) {
|
|
2473
|
+
super(name, "string", "PgDateString");
|
|
2474
|
+
}
|
|
2475
|
+
/** @internal */
|
|
2476
|
+
build(table) {
|
|
2477
|
+
return new PgDateString(
|
|
2478
|
+
table,
|
|
2479
|
+
this.config
|
|
2480
|
+
);
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
var PgDateString = class extends PgColumn {
|
|
2484
|
+
static [entityKind] = "PgDateString";
|
|
2485
|
+
getSQLType() {
|
|
2486
|
+
return "date";
|
|
2487
|
+
}
|
|
2488
|
+
mapFromDriverValue(value) {
|
|
2489
|
+
if (typeof value === "string") return value;
|
|
2490
|
+
return value.toISOString().slice(0, -14);
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
function date(a, b) {
|
|
2494
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2495
|
+
if (config?.mode === "date") {
|
|
2496
|
+
return new PgDateBuilder(name);
|
|
2497
|
+
}
|
|
2498
|
+
return new PgDateStringBuilder(name);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
// ../../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
|
|
2502
|
+
var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
|
|
2503
|
+
static [entityKind] = "PgDoublePrecisionBuilder";
|
|
2504
|
+
constructor(name) {
|
|
2505
|
+
super(name, "number", "PgDoublePrecision");
|
|
2506
|
+
}
|
|
2507
|
+
/** @internal */
|
|
2508
|
+
build(table) {
|
|
2509
|
+
return new PgDoublePrecision(
|
|
2510
|
+
table,
|
|
2511
|
+
this.config
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
var PgDoublePrecision = class extends PgColumn {
|
|
2516
|
+
static [entityKind] = "PgDoublePrecision";
|
|
2517
|
+
getSQLType() {
|
|
2518
|
+
return "double precision";
|
|
2519
|
+
}
|
|
2520
|
+
mapFromDriverValue(value) {
|
|
2521
|
+
if (typeof value === "string") {
|
|
2522
|
+
return Number.parseFloat(value);
|
|
2523
|
+
}
|
|
2524
|
+
return value;
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
function doublePrecision(name) {
|
|
2528
|
+
return new PgDoublePrecisionBuilder(name ?? "");
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
// ../../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
|
|
2532
|
+
var PgInetBuilder = class extends PgColumnBuilder {
|
|
2533
|
+
static [entityKind] = "PgInetBuilder";
|
|
2534
|
+
constructor(name) {
|
|
2535
|
+
super(name, "string", "PgInet");
|
|
2536
|
+
}
|
|
2537
|
+
/** @internal */
|
|
2538
|
+
build(table) {
|
|
2539
|
+
return new PgInet(table, this.config);
|
|
2540
|
+
}
|
|
2541
|
+
};
|
|
2542
|
+
var PgInet = class extends PgColumn {
|
|
2543
|
+
static [entityKind] = "PgInet";
|
|
2544
|
+
getSQLType() {
|
|
2545
|
+
return "inet";
|
|
2546
|
+
}
|
|
2547
|
+
};
|
|
2548
|
+
function inet(name) {
|
|
2549
|
+
return new PgInetBuilder(name ?? "");
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
// ../../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
|
|
2553
|
+
var PgIntegerBuilder = class extends PgIntColumnBaseBuilder {
|
|
2554
|
+
static [entityKind] = "PgIntegerBuilder";
|
|
2555
|
+
constructor(name) {
|
|
2556
|
+
super(name, "number", "PgInteger");
|
|
2557
|
+
}
|
|
2558
|
+
/** @internal */
|
|
2559
|
+
build(table) {
|
|
2560
|
+
return new PgInteger(table, this.config);
|
|
2561
|
+
}
|
|
2562
|
+
};
|
|
2563
|
+
var PgInteger = class extends PgColumn {
|
|
2564
|
+
static [entityKind] = "PgInteger";
|
|
2565
|
+
getSQLType() {
|
|
2566
|
+
return "integer";
|
|
2567
|
+
}
|
|
2568
|
+
mapFromDriverValue(value) {
|
|
2569
|
+
if (typeof value === "string") {
|
|
2570
|
+
return Number.parseInt(value);
|
|
2571
|
+
}
|
|
2572
|
+
return value;
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
2575
|
+
function integer(name) {
|
|
2576
|
+
return new PgIntegerBuilder(name ?? "");
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
// ../../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
|
|
2580
|
+
var PgIntervalBuilder = class extends PgColumnBuilder {
|
|
2581
|
+
static [entityKind] = "PgIntervalBuilder";
|
|
2582
|
+
constructor(name, intervalConfig) {
|
|
2583
|
+
super(name, "string", "PgInterval");
|
|
2584
|
+
this.config.intervalConfig = intervalConfig;
|
|
2585
|
+
}
|
|
2586
|
+
/** @internal */
|
|
2587
|
+
build(table) {
|
|
2588
|
+
return new PgInterval(table, this.config);
|
|
2589
|
+
}
|
|
2590
|
+
};
|
|
2591
|
+
var PgInterval = class extends PgColumn {
|
|
2592
|
+
static [entityKind] = "PgInterval";
|
|
2593
|
+
fields = this.config.intervalConfig.fields;
|
|
2594
|
+
precision = this.config.intervalConfig.precision;
|
|
2595
|
+
getSQLType() {
|
|
2596
|
+
const fields = this.fields ? ` ${this.fields}` : "";
|
|
2597
|
+
const precision = this.precision ? `(${this.precision})` : "";
|
|
2598
|
+
return `interval${fields}${precision}`;
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
function interval(a, b = {}) {
|
|
2602
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2603
|
+
return new PgIntervalBuilder(name, config);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
// ../../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
|
|
2607
|
+
var PgJsonBuilder = class extends PgColumnBuilder {
|
|
2608
|
+
static [entityKind] = "PgJsonBuilder";
|
|
2609
|
+
constructor(name) {
|
|
2610
|
+
super(name, "json", "PgJson");
|
|
2611
|
+
}
|
|
2612
|
+
/** @internal */
|
|
2613
|
+
build(table) {
|
|
2614
|
+
return new PgJson(table, this.config);
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
var PgJson = class extends PgColumn {
|
|
2618
|
+
static [entityKind] = "PgJson";
|
|
2619
|
+
constructor(table, config) {
|
|
2620
|
+
super(table, config);
|
|
2621
|
+
}
|
|
2622
|
+
getSQLType() {
|
|
2623
|
+
return "json";
|
|
2624
|
+
}
|
|
2625
|
+
mapToDriverValue(value) {
|
|
2626
|
+
return JSON.stringify(value);
|
|
2627
|
+
}
|
|
2628
|
+
mapFromDriverValue(value) {
|
|
2629
|
+
if (typeof value === "string") {
|
|
2630
|
+
try {
|
|
2631
|
+
return JSON.parse(value);
|
|
2632
|
+
} catch {
|
|
2633
|
+
return value;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
return value;
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2639
|
+
function json(name) {
|
|
2640
|
+
return new PgJsonBuilder(name ?? "");
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
// ../../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
|
|
2644
|
+
var PgJsonbBuilder = class extends PgColumnBuilder {
|
|
2645
|
+
static [entityKind] = "PgJsonbBuilder";
|
|
2646
|
+
constructor(name) {
|
|
2647
|
+
super(name, "json", "PgJsonb");
|
|
2648
|
+
}
|
|
2649
|
+
/** @internal */
|
|
2650
|
+
build(table) {
|
|
2651
|
+
return new PgJsonb(table, this.config);
|
|
2652
|
+
}
|
|
2653
|
+
};
|
|
2654
|
+
var PgJsonb = class extends PgColumn {
|
|
2655
|
+
static [entityKind] = "PgJsonb";
|
|
2656
|
+
constructor(table, config) {
|
|
2657
|
+
super(table, config);
|
|
2658
|
+
}
|
|
2659
|
+
getSQLType() {
|
|
2660
|
+
return "jsonb";
|
|
2661
|
+
}
|
|
2662
|
+
mapToDriverValue(value) {
|
|
2663
|
+
return JSON.stringify(value);
|
|
2664
|
+
}
|
|
2665
|
+
mapFromDriverValue(value) {
|
|
2666
|
+
if (typeof value === "string") {
|
|
2667
|
+
try {
|
|
2668
|
+
return JSON.parse(value);
|
|
2669
|
+
} catch {
|
|
2670
|
+
return value;
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
return value;
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
function jsonb(name) {
|
|
2677
|
+
return new PgJsonbBuilder(name ?? "");
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
// ../../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
|
|
2681
|
+
var PgLineBuilder = class extends PgColumnBuilder {
|
|
2682
|
+
static [entityKind] = "PgLineBuilder";
|
|
2683
|
+
constructor(name) {
|
|
2684
|
+
super(name, "array", "PgLine");
|
|
2685
|
+
}
|
|
2686
|
+
/** @internal */
|
|
2687
|
+
build(table) {
|
|
2688
|
+
return new PgLineTuple(
|
|
2689
|
+
table,
|
|
2690
|
+
this.config
|
|
2691
|
+
);
|
|
2692
|
+
}
|
|
2693
|
+
};
|
|
2694
|
+
var PgLineTuple = class extends PgColumn {
|
|
2695
|
+
static [entityKind] = "PgLine";
|
|
2696
|
+
getSQLType() {
|
|
2697
|
+
return "line";
|
|
2698
|
+
}
|
|
2699
|
+
mapFromDriverValue(value) {
|
|
2700
|
+
const [a, b, c2] = value.slice(1, -1).split(",");
|
|
2701
|
+
return [Number.parseFloat(a), Number.parseFloat(b), Number.parseFloat(c2)];
|
|
2702
|
+
}
|
|
2703
|
+
mapToDriverValue(value) {
|
|
2704
|
+
return `{${value[0]},${value[1]},${value[2]}}`;
|
|
2705
|
+
}
|
|
2706
|
+
};
|
|
2707
|
+
var PgLineABCBuilder = class extends PgColumnBuilder {
|
|
2708
|
+
static [entityKind] = "PgLineABCBuilder";
|
|
2709
|
+
constructor(name) {
|
|
2710
|
+
super(name, "json", "PgLineABC");
|
|
2711
|
+
}
|
|
2712
|
+
/** @internal */
|
|
2713
|
+
build(table) {
|
|
2714
|
+
return new PgLineABC(
|
|
2715
|
+
table,
|
|
2716
|
+
this.config
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
};
|
|
2720
|
+
var PgLineABC = class extends PgColumn {
|
|
2721
|
+
static [entityKind] = "PgLineABC";
|
|
2722
|
+
getSQLType() {
|
|
2723
|
+
return "line";
|
|
2724
|
+
}
|
|
2725
|
+
mapFromDriverValue(value) {
|
|
2726
|
+
const [a, b, c2] = value.slice(1, -1).split(",");
|
|
2727
|
+
return { a: Number.parseFloat(a), b: Number.parseFloat(b), c: Number.parseFloat(c2) };
|
|
2728
|
+
}
|
|
2729
|
+
mapToDriverValue(value) {
|
|
2730
|
+
return `{${value.a},${value.b},${value.c}}`;
|
|
2731
|
+
}
|
|
2732
|
+
};
|
|
2733
|
+
function line(a, b) {
|
|
2734
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2735
|
+
if (!config?.mode || config.mode === "tuple") {
|
|
2736
|
+
return new PgLineBuilder(name);
|
|
2737
|
+
}
|
|
2738
|
+
return new PgLineABCBuilder(name);
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
// ../../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
|
|
2742
|
+
var PgMacaddrBuilder = class extends PgColumnBuilder {
|
|
2743
|
+
static [entityKind] = "PgMacaddrBuilder";
|
|
2744
|
+
constructor(name) {
|
|
2745
|
+
super(name, "string", "PgMacaddr");
|
|
2746
|
+
}
|
|
2747
|
+
/** @internal */
|
|
2748
|
+
build(table) {
|
|
2749
|
+
return new PgMacaddr(table, this.config);
|
|
2750
|
+
}
|
|
2751
|
+
};
|
|
2752
|
+
var PgMacaddr = class extends PgColumn {
|
|
2753
|
+
static [entityKind] = "PgMacaddr";
|
|
2754
|
+
getSQLType() {
|
|
2755
|
+
return "macaddr";
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
function macaddr(name) {
|
|
2759
|
+
return new PgMacaddrBuilder(name ?? "");
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
// ../../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
|
|
2763
|
+
var PgMacaddr8Builder = class extends PgColumnBuilder {
|
|
2764
|
+
static [entityKind] = "PgMacaddr8Builder";
|
|
2765
|
+
constructor(name) {
|
|
2766
|
+
super(name, "string", "PgMacaddr8");
|
|
2767
|
+
}
|
|
2768
|
+
/** @internal */
|
|
2769
|
+
build(table) {
|
|
2770
|
+
return new PgMacaddr8(table, this.config);
|
|
2771
|
+
}
|
|
2772
|
+
};
|
|
2773
|
+
var PgMacaddr8 = class extends PgColumn {
|
|
2774
|
+
static [entityKind] = "PgMacaddr8";
|
|
2775
|
+
getSQLType() {
|
|
2776
|
+
return "macaddr8";
|
|
2777
|
+
}
|
|
2778
|
+
};
|
|
2779
|
+
function macaddr8(name) {
|
|
2780
|
+
return new PgMacaddr8Builder(name ?? "");
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
// ../../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
|
|
2784
|
+
var PgNumericBuilder = class extends PgColumnBuilder {
|
|
2785
|
+
static [entityKind] = "PgNumericBuilder";
|
|
2786
|
+
constructor(name, precision, scale) {
|
|
2787
|
+
super(name, "string", "PgNumeric");
|
|
2788
|
+
this.config.precision = precision;
|
|
2789
|
+
this.config.scale = scale;
|
|
2790
|
+
}
|
|
2791
|
+
/** @internal */
|
|
2792
|
+
build(table) {
|
|
2793
|
+
return new PgNumeric(table, this.config);
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2796
|
+
var PgNumeric = class extends PgColumn {
|
|
2797
|
+
static [entityKind] = "PgNumeric";
|
|
2798
|
+
precision;
|
|
2799
|
+
scale;
|
|
2800
|
+
constructor(table, config) {
|
|
2801
|
+
super(table, config);
|
|
2802
|
+
this.precision = config.precision;
|
|
2803
|
+
this.scale = config.scale;
|
|
2804
|
+
}
|
|
2805
|
+
mapFromDriverValue(value) {
|
|
2806
|
+
if (typeof value === "string") return value;
|
|
2807
|
+
return String(value);
|
|
2808
|
+
}
|
|
2809
|
+
getSQLType() {
|
|
2810
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
2811
|
+
return `numeric(${this.precision}, ${this.scale})`;
|
|
2812
|
+
} else if (this.precision === void 0) {
|
|
2813
|
+
return "numeric";
|
|
2814
|
+
} else {
|
|
2815
|
+
return `numeric(${this.precision})`;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
};
|
|
2819
|
+
var PgNumericNumberBuilder = class extends PgColumnBuilder {
|
|
2820
|
+
static [entityKind] = "PgNumericNumberBuilder";
|
|
2821
|
+
constructor(name, precision, scale) {
|
|
2822
|
+
super(name, "number", "PgNumericNumber");
|
|
2823
|
+
this.config.precision = precision;
|
|
2824
|
+
this.config.scale = scale;
|
|
2825
|
+
}
|
|
2826
|
+
/** @internal */
|
|
2827
|
+
build(table) {
|
|
2828
|
+
return new PgNumericNumber(
|
|
2829
|
+
table,
|
|
2830
|
+
this.config
|
|
2831
|
+
);
|
|
2832
|
+
}
|
|
2833
|
+
};
|
|
2834
|
+
var PgNumericNumber = class extends PgColumn {
|
|
2835
|
+
static [entityKind] = "PgNumericNumber";
|
|
2836
|
+
precision;
|
|
2837
|
+
scale;
|
|
2838
|
+
constructor(table, config) {
|
|
2839
|
+
super(table, config);
|
|
2840
|
+
this.precision = config.precision;
|
|
2841
|
+
this.scale = config.scale;
|
|
2842
|
+
}
|
|
2843
|
+
mapFromDriverValue(value) {
|
|
2844
|
+
if (typeof value === "number") return value;
|
|
2845
|
+
return Number(value);
|
|
2846
|
+
}
|
|
2847
|
+
mapToDriverValue = String;
|
|
2848
|
+
getSQLType() {
|
|
2849
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
2850
|
+
return `numeric(${this.precision}, ${this.scale})`;
|
|
2851
|
+
} else if (this.precision === void 0) {
|
|
2852
|
+
return "numeric";
|
|
2853
|
+
} else {
|
|
2854
|
+
return `numeric(${this.precision})`;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
var PgNumericBigIntBuilder = class extends PgColumnBuilder {
|
|
2859
|
+
static [entityKind] = "PgNumericBigIntBuilder";
|
|
2860
|
+
constructor(name, precision, scale) {
|
|
2861
|
+
super(name, "bigint", "PgNumericBigInt");
|
|
2862
|
+
this.config.precision = precision;
|
|
2863
|
+
this.config.scale = scale;
|
|
2864
|
+
}
|
|
2865
|
+
/** @internal */
|
|
2866
|
+
build(table) {
|
|
2867
|
+
return new PgNumericBigInt(
|
|
2868
|
+
table,
|
|
2869
|
+
this.config
|
|
2870
|
+
);
|
|
2871
|
+
}
|
|
2872
|
+
};
|
|
2873
|
+
var PgNumericBigInt = class extends PgColumn {
|
|
2874
|
+
static [entityKind] = "PgNumericBigInt";
|
|
2875
|
+
precision;
|
|
2876
|
+
scale;
|
|
2877
|
+
constructor(table, config) {
|
|
2878
|
+
super(table, config);
|
|
2879
|
+
this.precision = config.precision;
|
|
2880
|
+
this.scale = config.scale;
|
|
2881
|
+
}
|
|
2882
|
+
mapFromDriverValue = BigInt;
|
|
2883
|
+
mapToDriverValue = String;
|
|
2884
|
+
getSQLType() {
|
|
2885
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
|
2886
|
+
return `numeric(${this.precision}, ${this.scale})`;
|
|
2887
|
+
} else if (this.precision === void 0) {
|
|
2888
|
+
return "numeric";
|
|
2889
|
+
} else {
|
|
2890
|
+
return `numeric(${this.precision})`;
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
};
|
|
2894
|
+
function numeric(a, b) {
|
|
2895
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2896
|
+
const mode = config?.mode;
|
|
2897
|
+
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);
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
// ../../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
|
|
2901
|
+
var PgPointTupleBuilder = class extends PgColumnBuilder {
|
|
2902
|
+
static [entityKind] = "PgPointTupleBuilder";
|
|
2903
|
+
constructor(name) {
|
|
2904
|
+
super(name, "array", "PgPointTuple");
|
|
2905
|
+
}
|
|
2906
|
+
/** @internal */
|
|
2907
|
+
build(table) {
|
|
2908
|
+
return new PgPointTuple(
|
|
2909
|
+
table,
|
|
2910
|
+
this.config
|
|
2911
|
+
);
|
|
2912
|
+
}
|
|
2913
|
+
};
|
|
2914
|
+
var PgPointTuple = class extends PgColumn {
|
|
2915
|
+
static [entityKind] = "PgPointTuple";
|
|
2916
|
+
getSQLType() {
|
|
2917
|
+
return "point";
|
|
2918
|
+
}
|
|
2919
|
+
mapFromDriverValue(value) {
|
|
2920
|
+
if (typeof value === "string") {
|
|
2921
|
+
const [x, y] = value.slice(1, -1).split(",");
|
|
2922
|
+
return [Number.parseFloat(x), Number.parseFloat(y)];
|
|
2923
|
+
}
|
|
2924
|
+
return [value.x, value.y];
|
|
2925
|
+
}
|
|
2926
|
+
mapToDriverValue(value) {
|
|
2927
|
+
return `(${value[0]},${value[1]})`;
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
var PgPointObjectBuilder = class extends PgColumnBuilder {
|
|
2931
|
+
static [entityKind] = "PgPointObjectBuilder";
|
|
2932
|
+
constructor(name) {
|
|
2933
|
+
super(name, "json", "PgPointObject");
|
|
2934
|
+
}
|
|
2935
|
+
/** @internal */
|
|
2936
|
+
build(table) {
|
|
2937
|
+
return new PgPointObject(
|
|
2938
|
+
table,
|
|
2939
|
+
this.config
|
|
2940
|
+
);
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
var PgPointObject = class extends PgColumn {
|
|
2944
|
+
static [entityKind] = "PgPointObject";
|
|
2945
|
+
getSQLType() {
|
|
2946
|
+
return "point";
|
|
2947
|
+
}
|
|
2948
|
+
mapFromDriverValue(value) {
|
|
2949
|
+
if (typeof value === "string") {
|
|
2950
|
+
const [x, y] = value.slice(1, -1).split(",");
|
|
2951
|
+
return { x: Number.parseFloat(x), y: Number.parseFloat(y) };
|
|
2952
|
+
}
|
|
2953
|
+
return value;
|
|
2954
|
+
}
|
|
2955
|
+
mapToDriverValue(value) {
|
|
2956
|
+
return `(${value.x},${value.y})`;
|
|
2957
|
+
}
|
|
2958
|
+
};
|
|
2959
|
+
function point(a, b) {
|
|
2960
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2961
|
+
if (!config?.mode || config.mode === "tuple") {
|
|
2962
|
+
return new PgPointTupleBuilder(name);
|
|
2963
|
+
}
|
|
2964
|
+
return new PgPointObjectBuilder(name);
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
// ../../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
|
|
2968
|
+
function hexToBytes(hex) {
|
|
2969
|
+
const bytes = [];
|
|
2970
|
+
for (let c2 = 0; c2 < hex.length; c2 += 2) {
|
|
2971
|
+
bytes.push(Number.parseInt(hex.slice(c2, c2 + 2), 16));
|
|
2972
|
+
}
|
|
2973
|
+
return new Uint8Array(bytes);
|
|
2974
|
+
}
|
|
2975
|
+
function bytesToFloat64(bytes, offset) {
|
|
2976
|
+
const buffer = new ArrayBuffer(8);
|
|
2977
|
+
const view = new DataView(buffer);
|
|
2978
|
+
for (let i = 0; i < 8; i++) {
|
|
2979
|
+
view.setUint8(i, bytes[offset + i]);
|
|
2980
|
+
}
|
|
2981
|
+
return view.getFloat64(0, true);
|
|
2982
|
+
}
|
|
2983
|
+
function parseEWKB(hex) {
|
|
2984
|
+
const bytes = hexToBytes(hex);
|
|
2985
|
+
let offset = 0;
|
|
2986
|
+
const byteOrder = bytes[offset];
|
|
2987
|
+
offset += 1;
|
|
2988
|
+
const view = new DataView(bytes.buffer);
|
|
2989
|
+
const geomType = view.getUint32(offset, byteOrder === 1);
|
|
2990
|
+
offset += 4;
|
|
2991
|
+
let _srid;
|
|
2992
|
+
if (geomType & 536870912) {
|
|
2993
|
+
_srid = view.getUint32(offset, byteOrder === 1);
|
|
2994
|
+
offset += 4;
|
|
2995
|
+
}
|
|
2996
|
+
if ((geomType & 65535) === 1) {
|
|
2997
|
+
const x = bytesToFloat64(bytes, offset);
|
|
2998
|
+
offset += 8;
|
|
2999
|
+
const y = bytesToFloat64(bytes, offset);
|
|
3000
|
+
offset += 8;
|
|
3001
|
+
return [x, y];
|
|
3002
|
+
}
|
|
3003
|
+
throw new Error("Unsupported geometry type");
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
// ../../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
|
|
3007
|
+
var PgGeometryBuilder = class extends PgColumnBuilder {
|
|
3008
|
+
static [entityKind] = "PgGeometryBuilder";
|
|
3009
|
+
constructor(name) {
|
|
3010
|
+
super(name, "array", "PgGeometry");
|
|
3011
|
+
}
|
|
3012
|
+
/** @internal */
|
|
3013
|
+
build(table) {
|
|
3014
|
+
return new PgGeometry(
|
|
3015
|
+
table,
|
|
3016
|
+
this.config
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
};
|
|
3020
|
+
var PgGeometry = class extends PgColumn {
|
|
3021
|
+
static [entityKind] = "PgGeometry";
|
|
3022
|
+
getSQLType() {
|
|
3023
|
+
return "geometry(point)";
|
|
3024
|
+
}
|
|
3025
|
+
mapFromDriverValue(value) {
|
|
3026
|
+
return parseEWKB(value);
|
|
3027
|
+
}
|
|
3028
|
+
mapToDriverValue(value) {
|
|
3029
|
+
return `point(${value[0]} ${value[1]})`;
|
|
3030
|
+
}
|
|
3031
|
+
};
|
|
3032
|
+
var PgGeometryObjectBuilder = class extends PgColumnBuilder {
|
|
3033
|
+
static [entityKind] = "PgGeometryObjectBuilder";
|
|
3034
|
+
constructor(name) {
|
|
3035
|
+
super(name, "json", "PgGeometryObject");
|
|
3036
|
+
}
|
|
3037
|
+
/** @internal */
|
|
3038
|
+
build(table) {
|
|
3039
|
+
return new PgGeometryObject(
|
|
3040
|
+
table,
|
|
3041
|
+
this.config
|
|
3042
|
+
);
|
|
3043
|
+
}
|
|
3044
|
+
};
|
|
3045
|
+
var PgGeometryObject = class extends PgColumn {
|
|
3046
|
+
static [entityKind] = "PgGeometryObject";
|
|
3047
|
+
getSQLType() {
|
|
3048
|
+
return "geometry(point)";
|
|
3049
|
+
}
|
|
3050
|
+
mapFromDriverValue(value) {
|
|
3051
|
+
const parsed = parseEWKB(value);
|
|
3052
|
+
return { x: parsed[0], y: parsed[1] };
|
|
3053
|
+
}
|
|
3054
|
+
mapToDriverValue(value) {
|
|
3055
|
+
return `point(${value.x} ${value.y})`;
|
|
3056
|
+
}
|
|
3057
|
+
};
|
|
3058
|
+
function geometry(a, b) {
|
|
3059
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3060
|
+
if (!config?.mode || config.mode === "tuple") {
|
|
3061
|
+
return new PgGeometryBuilder(name);
|
|
3062
|
+
}
|
|
3063
|
+
return new PgGeometryObjectBuilder(name);
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
// ../../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
|
|
3067
|
+
var PgRealBuilder = class extends PgColumnBuilder {
|
|
3068
|
+
static [entityKind] = "PgRealBuilder";
|
|
3069
|
+
constructor(name, length) {
|
|
3070
|
+
super(name, "number", "PgReal");
|
|
3071
|
+
this.config.length = length;
|
|
3072
|
+
}
|
|
3073
|
+
/** @internal */
|
|
3074
|
+
build(table) {
|
|
3075
|
+
return new PgReal(table, this.config);
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
var PgReal = class extends PgColumn {
|
|
3079
|
+
static [entityKind] = "PgReal";
|
|
3080
|
+
constructor(table, config) {
|
|
3081
|
+
super(table, config);
|
|
3082
|
+
}
|
|
3083
|
+
getSQLType() {
|
|
3084
|
+
return "real";
|
|
3085
|
+
}
|
|
3086
|
+
mapFromDriverValue = (value) => {
|
|
3087
|
+
if (typeof value === "string") {
|
|
3088
|
+
return Number.parseFloat(value);
|
|
3089
|
+
}
|
|
3090
|
+
return value;
|
|
3091
|
+
};
|
|
3092
|
+
};
|
|
3093
|
+
function real(name) {
|
|
3094
|
+
return new PgRealBuilder(name ?? "");
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
// ../../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
|
|
3098
|
+
var PgSerialBuilder = class extends PgColumnBuilder {
|
|
3099
|
+
static [entityKind] = "PgSerialBuilder";
|
|
3100
|
+
constructor(name) {
|
|
3101
|
+
super(name, "number", "PgSerial");
|
|
3102
|
+
this.config.hasDefault = true;
|
|
3103
|
+
this.config.notNull = true;
|
|
3104
|
+
}
|
|
3105
|
+
/** @internal */
|
|
3106
|
+
build(table) {
|
|
3107
|
+
return new PgSerial(table, this.config);
|
|
3108
|
+
}
|
|
3109
|
+
};
|
|
3110
|
+
var PgSerial = class extends PgColumn {
|
|
3111
|
+
static [entityKind] = "PgSerial";
|
|
3112
|
+
getSQLType() {
|
|
3113
|
+
return "serial";
|
|
3114
|
+
}
|
|
3115
|
+
};
|
|
3116
|
+
function serial(name) {
|
|
3117
|
+
return new PgSerialBuilder(name ?? "");
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// ../../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
|
|
3121
|
+
var PgSmallIntBuilder = class extends PgIntColumnBaseBuilder {
|
|
3122
|
+
static [entityKind] = "PgSmallIntBuilder";
|
|
3123
|
+
constructor(name) {
|
|
3124
|
+
super(name, "number", "PgSmallInt");
|
|
3125
|
+
}
|
|
3126
|
+
/** @internal */
|
|
3127
|
+
build(table) {
|
|
3128
|
+
return new PgSmallInt(table, this.config);
|
|
3129
|
+
}
|
|
3130
|
+
};
|
|
3131
|
+
var PgSmallInt = class extends PgColumn {
|
|
3132
|
+
static [entityKind] = "PgSmallInt";
|
|
3133
|
+
getSQLType() {
|
|
3134
|
+
return "smallint";
|
|
3135
|
+
}
|
|
3136
|
+
mapFromDriverValue = (value) => {
|
|
3137
|
+
if (typeof value === "string") {
|
|
3138
|
+
return Number(value);
|
|
3139
|
+
}
|
|
3140
|
+
return value;
|
|
3141
|
+
};
|
|
3142
|
+
};
|
|
3143
|
+
function smallint(name) {
|
|
3144
|
+
return new PgSmallIntBuilder(name ?? "");
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3147
|
+
// ../../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
|
|
3148
|
+
var PgSmallSerialBuilder = class extends PgColumnBuilder {
|
|
3149
|
+
static [entityKind] = "PgSmallSerialBuilder";
|
|
3150
|
+
constructor(name) {
|
|
3151
|
+
super(name, "number", "PgSmallSerial");
|
|
3152
|
+
this.config.hasDefault = true;
|
|
3153
|
+
this.config.notNull = true;
|
|
3154
|
+
}
|
|
3155
|
+
/** @internal */
|
|
3156
|
+
build(table) {
|
|
3157
|
+
return new PgSmallSerial(
|
|
3158
|
+
table,
|
|
3159
|
+
this.config
|
|
3160
|
+
);
|
|
3161
|
+
}
|
|
3162
|
+
};
|
|
3163
|
+
var PgSmallSerial = class extends PgColumn {
|
|
3164
|
+
static [entityKind] = "PgSmallSerial";
|
|
3165
|
+
getSQLType() {
|
|
3166
|
+
return "smallserial";
|
|
3167
|
+
}
|
|
3168
|
+
};
|
|
3169
|
+
function smallserial(name) {
|
|
3170
|
+
return new PgSmallSerialBuilder(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/text.js
|
|
3174
|
+
var PgTextBuilder = class extends PgColumnBuilder {
|
|
3175
|
+
static [entityKind] = "PgTextBuilder";
|
|
3176
|
+
constructor(name, config) {
|
|
3177
|
+
super(name, "string", "PgText");
|
|
3178
|
+
this.config.enumValues = config.enum;
|
|
3179
|
+
}
|
|
3180
|
+
/** @internal */
|
|
3181
|
+
build(table) {
|
|
3182
|
+
return new PgText(table, this.config);
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
var PgText = class extends PgColumn {
|
|
3186
|
+
static [entityKind] = "PgText";
|
|
3187
|
+
enumValues = this.config.enumValues;
|
|
3188
|
+
getSQLType() {
|
|
3189
|
+
return "text";
|
|
3190
|
+
}
|
|
3191
|
+
};
|
|
3192
|
+
function text(a, b = {}) {
|
|
3193
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3194
|
+
return new PgTextBuilder(name, config);
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
// ../../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
|
|
3198
|
+
var PgTimeBuilder = class extends PgDateColumnBaseBuilder {
|
|
3199
|
+
constructor(name, withTimezone, precision) {
|
|
3200
|
+
super(name, "string", "PgTime");
|
|
3201
|
+
this.withTimezone = withTimezone;
|
|
3202
|
+
this.precision = precision;
|
|
3203
|
+
this.config.withTimezone = withTimezone;
|
|
3204
|
+
this.config.precision = precision;
|
|
3205
|
+
}
|
|
3206
|
+
static [entityKind] = "PgTimeBuilder";
|
|
3207
|
+
/** @internal */
|
|
3208
|
+
build(table) {
|
|
3209
|
+
return new PgTime(table, this.config);
|
|
3210
|
+
}
|
|
3211
|
+
};
|
|
3212
|
+
var PgTime = class extends PgColumn {
|
|
3213
|
+
static [entityKind] = "PgTime";
|
|
3214
|
+
withTimezone;
|
|
3215
|
+
precision;
|
|
3216
|
+
constructor(table, config) {
|
|
3217
|
+
super(table, config);
|
|
3218
|
+
this.withTimezone = config.withTimezone;
|
|
3219
|
+
this.precision = config.precision;
|
|
3220
|
+
}
|
|
3221
|
+
getSQLType() {
|
|
3222
|
+
const precision = this.precision === void 0 ? "" : `(${this.precision})`;
|
|
3223
|
+
return `time${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
function time(a, b = {}) {
|
|
3227
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3228
|
+
return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
// ../../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
|
|
3232
|
+
var PgTimestampBuilder = class extends PgDateColumnBaseBuilder {
|
|
3233
|
+
static [entityKind] = "PgTimestampBuilder";
|
|
3234
|
+
constructor(name, withTimezone, precision) {
|
|
3235
|
+
super(name, "date", "PgTimestamp");
|
|
3236
|
+
this.config.withTimezone = withTimezone;
|
|
3237
|
+
this.config.precision = precision;
|
|
3238
|
+
}
|
|
3239
|
+
/** @internal */
|
|
3240
|
+
build(table) {
|
|
3241
|
+
return new PgTimestamp(table, this.config);
|
|
3242
|
+
}
|
|
3243
|
+
};
|
|
3244
|
+
var PgTimestamp = class extends PgColumn {
|
|
3245
|
+
static [entityKind] = "PgTimestamp";
|
|
3246
|
+
withTimezone;
|
|
3247
|
+
precision;
|
|
3248
|
+
constructor(table, config) {
|
|
3249
|
+
super(table, config);
|
|
3250
|
+
this.withTimezone = config.withTimezone;
|
|
3251
|
+
this.precision = config.precision;
|
|
3252
|
+
}
|
|
3253
|
+
getSQLType() {
|
|
3254
|
+
const precision = this.precision === void 0 ? "" : ` (${this.precision})`;
|
|
3255
|
+
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
3256
|
+
}
|
|
3257
|
+
mapFromDriverValue(value) {
|
|
3258
|
+
if (typeof value === "string") return new Date(this.withTimezone ? value : value + "+0000");
|
|
3259
|
+
return value;
|
|
3260
|
+
}
|
|
3261
|
+
mapToDriverValue = (value) => {
|
|
3262
|
+
return value.toISOString();
|
|
3263
|
+
};
|
|
3264
|
+
};
|
|
3265
|
+
var PgTimestampStringBuilder = class extends PgDateColumnBaseBuilder {
|
|
3266
|
+
static [entityKind] = "PgTimestampStringBuilder";
|
|
3267
|
+
constructor(name, withTimezone, precision) {
|
|
3268
|
+
super(name, "string", "PgTimestampString");
|
|
3269
|
+
this.config.withTimezone = withTimezone;
|
|
3270
|
+
this.config.precision = precision;
|
|
3271
|
+
}
|
|
3272
|
+
/** @internal */
|
|
3273
|
+
build(table) {
|
|
3274
|
+
return new PgTimestampString(
|
|
3275
|
+
table,
|
|
3276
|
+
this.config
|
|
3277
|
+
);
|
|
3278
|
+
}
|
|
3279
|
+
};
|
|
3280
|
+
var PgTimestampString = class extends PgColumn {
|
|
3281
|
+
static [entityKind] = "PgTimestampString";
|
|
3282
|
+
withTimezone;
|
|
3283
|
+
precision;
|
|
3284
|
+
constructor(table, config) {
|
|
3285
|
+
super(table, config);
|
|
3286
|
+
this.withTimezone = config.withTimezone;
|
|
3287
|
+
this.precision = config.precision;
|
|
3288
|
+
}
|
|
3289
|
+
getSQLType() {
|
|
3290
|
+
const precision = this.precision === void 0 ? "" : `(${this.precision})`;
|
|
3291
|
+
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
3292
|
+
}
|
|
3293
|
+
mapFromDriverValue(value) {
|
|
3294
|
+
if (typeof value === "string") return value;
|
|
3295
|
+
const shortened = value.toISOString().slice(0, -1).replace("T", " ");
|
|
3296
|
+
if (this.withTimezone) {
|
|
3297
|
+
const offset = value.getTimezoneOffset();
|
|
3298
|
+
const sign = offset <= 0 ? "+" : "-";
|
|
3299
|
+
return `${shortened}${sign}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
|
|
3300
|
+
}
|
|
3301
|
+
return shortened;
|
|
3302
|
+
}
|
|
3303
|
+
};
|
|
3304
|
+
function timestamp(a, b = {}) {
|
|
3305
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3306
|
+
if (config?.mode === "string") {
|
|
3307
|
+
return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
|
|
3308
|
+
}
|
|
3309
|
+
return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
// ../../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
|
|
3313
|
+
var PgUUIDBuilder = class extends PgColumnBuilder {
|
|
3314
|
+
static [entityKind] = "PgUUIDBuilder";
|
|
3315
|
+
constructor(name) {
|
|
3316
|
+
super(name, "string", "PgUUID");
|
|
3317
|
+
}
|
|
3318
|
+
/**
|
|
3319
|
+
* Adds `default gen_random_uuid()` to the column definition.
|
|
3320
|
+
*/
|
|
3321
|
+
defaultRandom() {
|
|
3322
|
+
return this.default(sql`gen_random_uuid()`);
|
|
3323
|
+
}
|
|
3324
|
+
/** @internal */
|
|
3325
|
+
build(table) {
|
|
3326
|
+
return new PgUUID(table, this.config);
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
var PgUUID = class extends PgColumn {
|
|
3330
|
+
static [entityKind] = "PgUUID";
|
|
3331
|
+
getSQLType() {
|
|
3332
|
+
return "uuid";
|
|
3333
|
+
}
|
|
3334
|
+
};
|
|
3335
|
+
function uuid(name) {
|
|
3336
|
+
return new PgUUIDBuilder(name ?? "");
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
// ../../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
|
|
3340
|
+
var PgVarcharBuilder = class extends PgColumnBuilder {
|
|
3341
|
+
static [entityKind] = "PgVarcharBuilder";
|
|
3342
|
+
constructor(name, config) {
|
|
3343
|
+
super(name, "string", "PgVarchar");
|
|
3344
|
+
this.config.length = config.length;
|
|
3345
|
+
this.config.enumValues = config.enum;
|
|
3346
|
+
}
|
|
3347
|
+
/** @internal */
|
|
3348
|
+
build(table) {
|
|
3349
|
+
return new PgVarchar(
|
|
3350
|
+
table,
|
|
3351
|
+
this.config
|
|
3352
|
+
);
|
|
3353
|
+
}
|
|
3354
|
+
};
|
|
3355
|
+
var PgVarchar = class extends PgColumn {
|
|
3356
|
+
static [entityKind] = "PgVarchar";
|
|
3357
|
+
length = this.config.length;
|
|
3358
|
+
enumValues = this.config.enumValues;
|
|
3359
|
+
getSQLType() {
|
|
3360
|
+
return this.length === void 0 ? `varchar` : `varchar(${this.length})`;
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
function varchar(a, b = {}) {
|
|
3364
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3365
|
+
return new PgVarcharBuilder(name, config);
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
// ../../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
|
|
3369
|
+
var PgBinaryVectorBuilder = class extends PgColumnBuilder {
|
|
3370
|
+
static [entityKind] = "PgBinaryVectorBuilder";
|
|
3371
|
+
constructor(name, config) {
|
|
3372
|
+
super(name, "string", "PgBinaryVector");
|
|
3373
|
+
this.config.dimensions = config.dimensions;
|
|
3374
|
+
}
|
|
3375
|
+
/** @internal */
|
|
3376
|
+
build(table) {
|
|
3377
|
+
return new PgBinaryVector(
|
|
3378
|
+
table,
|
|
3379
|
+
this.config
|
|
3380
|
+
);
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
var PgBinaryVector = class extends PgColumn {
|
|
3384
|
+
static [entityKind] = "PgBinaryVector";
|
|
3385
|
+
dimensions = this.config.dimensions;
|
|
3386
|
+
getSQLType() {
|
|
3387
|
+
return `bit(${this.dimensions})`;
|
|
3388
|
+
}
|
|
3389
|
+
};
|
|
3390
|
+
function bit(a, b) {
|
|
3391
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3392
|
+
return new PgBinaryVectorBuilder(name, config);
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
// ../../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
|
|
3396
|
+
var PgHalfVectorBuilder = class extends PgColumnBuilder {
|
|
3397
|
+
static [entityKind] = "PgHalfVectorBuilder";
|
|
3398
|
+
constructor(name, config) {
|
|
3399
|
+
super(name, "array", "PgHalfVector");
|
|
3400
|
+
this.config.dimensions = config.dimensions;
|
|
3401
|
+
}
|
|
3402
|
+
/** @internal */
|
|
3403
|
+
build(table) {
|
|
3404
|
+
return new PgHalfVector(
|
|
3405
|
+
table,
|
|
3406
|
+
this.config
|
|
3407
|
+
);
|
|
3408
|
+
}
|
|
3409
|
+
};
|
|
3410
|
+
var PgHalfVector = class extends PgColumn {
|
|
3411
|
+
static [entityKind] = "PgHalfVector";
|
|
3412
|
+
dimensions = this.config.dimensions;
|
|
3413
|
+
getSQLType() {
|
|
3414
|
+
return `halfvec(${this.dimensions})`;
|
|
3415
|
+
}
|
|
3416
|
+
mapToDriverValue(value) {
|
|
3417
|
+
return JSON.stringify(value);
|
|
3418
|
+
}
|
|
3419
|
+
mapFromDriverValue(value) {
|
|
3420
|
+
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
3421
|
+
}
|
|
3422
|
+
};
|
|
3423
|
+
function halfvec(a, b) {
|
|
3424
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3425
|
+
return new PgHalfVectorBuilder(name, config);
|
|
3426
|
+
}
|
|
3427
|
+
|
|
3428
|
+
// ../../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
|
|
3429
|
+
var PgSparseVectorBuilder = class extends PgColumnBuilder {
|
|
3430
|
+
static [entityKind] = "PgSparseVectorBuilder";
|
|
3431
|
+
constructor(name, config) {
|
|
3432
|
+
super(name, "string", "PgSparseVector");
|
|
3433
|
+
this.config.dimensions = config.dimensions;
|
|
3434
|
+
}
|
|
3435
|
+
/** @internal */
|
|
3436
|
+
build(table) {
|
|
3437
|
+
return new PgSparseVector(
|
|
3438
|
+
table,
|
|
3439
|
+
this.config
|
|
3440
|
+
);
|
|
145
3441
|
}
|
|
146
|
-
}
|
|
147
|
-
var
|
|
148
|
-
"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
3442
|
+
};
|
|
3443
|
+
var PgSparseVector = class extends PgColumn {
|
|
3444
|
+
static [entityKind] = "PgSparseVector";
|
|
3445
|
+
dimensions = this.config.dimensions;
|
|
3446
|
+
getSQLType() {
|
|
3447
|
+
return `sparsevec(${this.dimensions})`;
|
|
152
3448
|
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
import fs2 from "node:fs";
|
|
159
|
-
import path2 from "node:path";
|
|
160
|
-
import os2 from "node:os";
|
|
161
|
-
import { execSync as execSync2 } from "node:child_process";
|
|
3449
|
+
};
|
|
3450
|
+
function sparsevec(a, b) {
|
|
3451
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3452
|
+
return new PgSparseVectorBuilder(name, config);
|
|
3453
|
+
}
|
|
162
3454
|
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
3455
|
+
// ../../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
|
|
3456
|
+
var PgVectorBuilder = class extends PgColumnBuilder {
|
|
3457
|
+
static [entityKind] = "PgVectorBuilder";
|
|
3458
|
+
constructor(name, config) {
|
|
3459
|
+
super(name, "array", "PgVector");
|
|
3460
|
+
this.config.dimensions = config.dimensions;
|
|
3461
|
+
}
|
|
3462
|
+
/** @internal */
|
|
3463
|
+
build(table) {
|
|
3464
|
+
return new PgVector(
|
|
3465
|
+
table,
|
|
3466
|
+
this.config
|
|
3467
|
+
);
|
|
3468
|
+
}
|
|
3469
|
+
};
|
|
3470
|
+
var PgVector = class extends PgColumn {
|
|
3471
|
+
static [entityKind] = "PgVector";
|
|
3472
|
+
dimensions = this.config.dimensions;
|
|
3473
|
+
getSQLType() {
|
|
3474
|
+
return `vector(${this.dimensions})`;
|
|
3475
|
+
}
|
|
3476
|
+
mapToDriverValue(value) {
|
|
3477
|
+
return JSON.stringify(value);
|
|
177
3478
|
}
|
|
3479
|
+
mapFromDriverValue(value) {
|
|
3480
|
+
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
function vector(a, b) {
|
|
3484
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
3485
|
+
return new PgVectorBuilder(name, config);
|
|
178
3486
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
3487
|
+
|
|
3488
|
+
// ../../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
|
|
3489
|
+
function getPgColumnBuilders() {
|
|
3490
|
+
return {
|
|
3491
|
+
bigint,
|
|
3492
|
+
bigserial,
|
|
3493
|
+
boolean,
|
|
3494
|
+
char,
|
|
3495
|
+
cidr,
|
|
3496
|
+
customType,
|
|
3497
|
+
date,
|
|
3498
|
+
doublePrecision,
|
|
3499
|
+
inet,
|
|
3500
|
+
integer,
|
|
3501
|
+
interval,
|
|
3502
|
+
json,
|
|
3503
|
+
jsonb,
|
|
3504
|
+
line,
|
|
3505
|
+
macaddr,
|
|
3506
|
+
macaddr8,
|
|
3507
|
+
numeric,
|
|
3508
|
+
point,
|
|
3509
|
+
geometry,
|
|
3510
|
+
real,
|
|
3511
|
+
serial,
|
|
3512
|
+
smallint,
|
|
3513
|
+
smallserial,
|
|
3514
|
+
text,
|
|
3515
|
+
time,
|
|
3516
|
+
timestamp,
|
|
3517
|
+
uuid,
|
|
3518
|
+
varchar,
|
|
3519
|
+
bit,
|
|
3520
|
+
halfvec,
|
|
3521
|
+
sparsevec,
|
|
3522
|
+
vector
|
|
3523
|
+
};
|
|
3524
|
+
}
|
|
3525
|
+
|
|
3526
|
+
// ../../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
|
|
3527
|
+
var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
|
|
3528
|
+
var EnableRLS = Symbol.for("drizzle:EnableRLS");
|
|
3529
|
+
var PgTable = class extends Table {
|
|
3530
|
+
static [entityKind] = "PgTable";
|
|
3531
|
+
/** @internal */
|
|
3532
|
+
static Symbol = Object.assign({}, Table.Symbol, {
|
|
3533
|
+
InlineForeignKeys,
|
|
3534
|
+
EnableRLS
|
|
3535
|
+
});
|
|
3536
|
+
/**@internal */
|
|
3537
|
+
[InlineForeignKeys] = [];
|
|
3538
|
+
/** @internal */
|
|
3539
|
+
[EnableRLS] = false;
|
|
3540
|
+
/** @internal */
|
|
3541
|
+
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
|
3542
|
+
/** @internal */
|
|
3543
|
+
[Table.Symbol.ExtraConfigColumns] = {};
|
|
3544
|
+
};
|
|
3545
|
+
function pgTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
|
|
3546
|
+
const rawTable = new PgTable(name, schema, baseName);
|
|
3547
|
+
const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
|
|
3548
|
+
const builtColumns = Object.fromEntries(
|
|
3549
|
+
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
3550
|
+
const colBuilder = colBuilderBase;
|
|
3551
|
+
colBuilder.setName(name2);
|
|
3552
|
+
const column = colBuilder.build(rawTable);
|
|
3553
|
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
3554
|
+
return [name2, column];
|
|
3555
|
+
})
|
|
184
3556
|
);
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<div style="display: flex; align-items: center; justify-content: center; gap: 0.625rem; margin-bottom: 2rem;">
|
|
205
|
-
<div style="display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; background: #1a1714; border-radius: 8px;">
|
|
206
|
-
<svg width="16" height="16" viewBox="0 0 22 22" fill="none"><path d="M7.39855 11.2475C10.1937 11.2476 12.4598 13.5124 12.4598 16.3052C12.4596 19.0979 10.1936 21.3616 7.39855 21.3618H0V16.3052C0 15.7395 0.094025 15.1955 0.265523 14.6876C0.304389 14.5726 0.345701 14.4588 0.392462 14.3476C0.602402 13.8482 0.890874 13.39 1.24144 12.9873C1.25986 12.9662 1.27857 12.9453 1.29734 12.9245C1.39051 12.821 1.48832 12.7218 1.58965 12.6263C1.60303 12.6137 1.61572 12.6004 1.62924 12.5879C1.73452 12.4908 1.8444 12.3987 1.95765 12.3107C1.97096 12.3004 1.98383 12.2895 1.99725 12.2793C2.1117 12.1922 2.23063 12.1108 2.35244 12.0336C2.36662 12.0246 2.3801 12.0145 2.39437 12.0056C2.44032 11.9771 2.48719 11.95 2.53412 11.9229C2.56226 11.9067 2.59065 11.8909 2.61913 11.8752C2.64893 11.8587 2.67864 11.8421 2.7088 11.8263C2.75348 11.8028 2.79844 11.7797 2.84389 11.7576C2.88103 11.7394 2.91922 11.7235 2.95686 11.7063C2.98716 11.6925 3.01707 11.6777 3.04769 11.6644C3.09301 11.6447 3.13912 11.6269 3.18511 11.6085C3.21662 11.5959 3.24764 11.582 3.27945 11.5701C3.32936 11.5513 3.38019 11.5349 3.43084 11.5177C3.45418 11.5097 3.47722 11.5008 3.50071 11.4932C3.55658 11.4751 3.61289 11.4581 3.66958 11.442C3.69166 11.4357 3.71376 11.4293 3.73596 11.4233C3.79907 11.4063 3.86289 11.3914 3.92695 11.3767C3.94209 11.3733 3.95718 11.3696 3.97237 11.3663C4.11504 11.335 4.25985 11.3095 4.40675 11.2906C4.43232 11.2873 4.45794 11.2842 4.48362 11.2812C4.54425 11.2744 4.60519 11.2685 4.66645 11.2638C4.67847 11.2629 4.69052 11.2623 4.70256 11.2614L4.80038 11.2545C4.88671 11.2501 4.97383 11.2475 5.06125 11.2475H7.39855ZM16.9388 11.2475C19.734 11.2476 22 13.5124 22 16.3052C21.9998 19.0979 19.7338 21.3616 16.9388 21.3618H13.2832C14.4337 20.2108 15.1709 18.4482 15.1709 16.4718C15.1709 14.2926 14.2749 12.3735 12.9163 11.2475H16.9388ZM7.39855 0.00116458C10.1937 0.0013425 12.4598 2.26497 12.4598 5.05775C12.4597 7.85045 10.1937 10.1142 7.39855 10.1143H0V5.05775C0 4.89236 0.00775963 4.7288 0.0232915 4.56747C0.0274579 4.52418 0.0331791 4.48116 0.038431 4.4382C0.0524815 4.32328 0.0692046 4.20938 0.0908369 4.09698L0.102483 4.03875C0.106227 4.02046 0.110188 4.00223 0.114128 3.98401C0.127164 3.92376 0.142054 3.8641 0.157218 3.80467C0.164069 3.77781 0.1709 3.75099 0.17818 3.72431C0.188513 3.68644 0.199603 3.64886 0.210788 3.61135C0.225482 3.56207 0.241227 3.51324 0.257371 3.46461C0.269763 3.42728 0.281404 3.38975 0.294638 3.35281C0.30559 3.32224 0.318053 3.29227 0.329575 3.26198C0.343044 3.22656 0.356098 3.19103 0.370335 3.156C0.387188 3.11454 0.404827 3.07346 0.422741 3.03256C0.44039 2.99225 0.458814 2.95235 0.477476 2.9126C0.491731 2.88224 0.505727 2.85179 0.520565 2.82177C0.537576 2.78734 0.555205 2.75326 0.572971 2.71928C0.592296 2.68233 0.610995 2.64506 0.6312 2.60865C0.657644 2.56099 0.68596 2.51444 0.713885 2.46774C0.725232 2.44876 0.736069 2.42949 0.747658 2.41067C0.773311 2.36902 0.800032 2.32807 0.826849 2.28723C0.843934 2.26121 0.860541 2.23488 0.87809 2.2092C0.953313 2.0991 1.03336 1.99256 1.11683 1.88894C1.18114 1.80912 1.24702 1.73059 1.31597 1.65486C1.47484 1.48036 1.64557 1.31664 1.82722 1.16574C1.85016 1.14669 1.87382 1.12849 1.89709 1.10984C1.99837 1.02867 2.10292 0.951415 2.21036 0.87809C2.23606 0.86056 2.26236 0.843915 2.28839 0.826849C2.32925 0.800052 2.37017 0.773292 2.41184 0.747658C2.43349 0.734341 2.45518 0.721061 2.47705 0.708062C2.52886 0.677257 2.58129 0.647377 2.63427 0.61839C2.64707 0.61139 2.65984 0.604319 2.6727 0.597427C2.72986 0.566794 2.78777 0.537396 2.84622 0.50892C2.86043 0.502002 2.87503 0.49591 2.88931 0.489122C2.94744 0.461478 3.00584 0.434234 3.06516 0.408766C3.0837 0.400809 3.10241 0.393216 3.12106 0.385475C3.17763 0.361989 3.23467 0.3394 3.29226 0.317929C3.30779 0.31214 3.32324 0.306101 3.33884 0.300461C3.39807 0.279043 3.45795 0.25915 3.51818 0.239903C3.54179 0.232361 3.56547 0.224979 3.58922 0.217776C3.63126 0.205025 3.67367 0.193353 3.71616 0.181674C3.7556 0.170838 3.79513 0.16013 3.83495 0.15023C3.9786 0.114503 4.12462 0.0848882 4.27283 0.0617225C4.28096 0.0604516 4.28914 0.059461 4.29728 0.0582288C4.36902 0.047376 4.44121 0.038089 4.5139 0.030279C4.5248 0.0291076 4.53558 0.0267227 4.5465 0.0256207C4.55542 0.0247215 4.56436 0.0241444 4.57329 0.0232915L4.57096 0.0244561C4.73223 0.00896687 4.89591 0.00117115 5.06125 0.00116458H7.39855ZM16.9388 0C19.734 0.000177881 22 2.26497 22 5.05775C21.9999 7.85045 19.7339 10.1142 16.9388 10.1143H12.9175C14.2754 8.98827 15.1708 7.06961 15.1709 4.89122C15.1709 2.91428 14.433 1.15104 13.282 0H16.9388Z" fill="#FAF8F4"/></svg>
|
|
207
|
-
</div>
|
|
208
|
-
<span style="font-size: 1rem; font-weight: 600;">basestream</span>
|
|
209
|
-
</div>
|
|
210
|
-
<div style="background: #fffdf9; border: 1px solid #e8e4de; border-radius: 16px; padding: 2rem; display: inline-block;">
|
|
211
|
-
<h1 style="font-family: 'Newsreader', Georgia, serif; font-size: 1.25rem; color: #6b7e6b; margin-bottom: 0.5rem;">✓ Authenticated</h1>
|
|
212
|
-
<p style="color: #8a8379; font-size: 0.875rem;">You can close this tab and return to your terminal.</p>
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
</body>
|
|
216
|
-
</html>`);
|
|
217
|
-
server.close();
|
|
218
|
-
writeConfig({
|
|
219
|
-
apiKey: key,
|
|
220
|
-
baseUrl,
|
|
221
|
-
orgId: orgId || void 0
|
|
222
|
-
});
|
|
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);
|
|
3557
|
+
const builtColumnsForExtraConfig = Object.fromEntries(
|
|
3558
|
+
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
3559
|
+
const colBuilder = colBuilderBase;
|
|
3560
|
+
colBuilder.setName(name2);
|
|
3561
|
+
const column = colBuilder.buildExtraConfigColumn(rawTable);
|
|
3562
|
+
return [name2, column];
|
|
3563
|
+
})
|
|
3564
|
+
);
|
|
3565
|
+
const table = Object.assign(rawTable, builtColumns);
|
|
3566
|
+
table[Table.Symbol.Columns] = builtColumns;
|
|
3567
|
+
table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
|
|
3568
|
+
if (extraConfig) {
|
|
3569
|
+
table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
|
3570
|
+
}
|
|
3571
|
+
return Object.assign(table, {
|
|
3572
|
+
enableRLS: () => {
|
|
3573
|
+
table[PgTable.Symbol.EnableRLS] = true;
|
|
3574
|
+
return table;
|
|
3575
|
+
}
|
|
243
3576
|
});
|
|
244
|
-
check("Authenticated with Basestream");
|
|
245
|
-
return apiKey;
|
|
246
3577
|
}
|
|
3578
|
+
var pgTable = (name, columns, extraConfig) => {
|
|
3579
|
+
return pgTableWithSchema(name, columns, extraConfig, void 0);
|
|
3580
|
+
};
|
|
247
3581
|
|
|
248
|
-
//
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
);
|
|
254
|
-
var HOOK_COMMAND = "npx @basestream/cli _hook-stop";
|
|
255
|
-
var HOOK_MARKER = "_hook-stop";
|
|
256
|
-
function detectClaudeCode() {
|
|
257
|
-
try {
|
|
258
|
-
const version = execSync2("claude --version 2>/dev/null", {
|
|
259
|
-
encoding: "utf-8"
|
|
260
|
-
}).trim();
|
|
261
|
-
return version || null;
|
|
262
|
-
} catch {
|
|
263
|
-
return null;
|
|
3582
|
+
// ../../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
|
|
3583
|
+
var IndexBuilderOn = class {
|
|
3584
|
+
constructor(unique, name) {
|
|
3585
|
+
this.unique = unique;
|
|
3586
|
+
this.name = name;
|
|
264
3587
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
3588
|
+
static [entityKind] = "PgIndexBuilderOn";
|
|
3589
|
+
on(...columns) {
|
|
3590
|
+
return new IndexBuilder(
|
|
3591
|
+
columns.map((it) => {
|
|
3592
|
+
if (is(it, SQL)) {
|
|
3593
|
+
return it;
|
|
3594
|
+
}
|
|
3595
|
+
it = it;
|
|
3596
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
3597
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
3598
|
+
return clonedIndexedColumn;
|
|
3599
|
+
}),
|
|
3600
|
+
this.unique,
|
|
3601
|
+
false,
|
|
3602
|
+
this.name
|
|
3603
|
+
);
|
|
275
3604
|
}
|
|
276
|
-
|
|
277
|
-
|
|
3605
|
+
onOnly(...columns) {
|
|
3606
|
+
return new IndexBuilder(
|
|
3607
|
+
columns.map((it) => {
|
|
3608
|
+
if (is(it, SQL)) {
|
|
3609
|
+
return it;
|
|
3610
|
+
}
|
|
3611
|
+
it = it;
|
|
3612
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
3613
|
+
it.indexConfig = it.defaultConfig;
|
|
3614
|
+
return clonedIndexedColumn;
|
|
3615
|
+
}),
|
|
3616
|
+
this.unique,
|
|
3617
|
+
true,
|
|
3618
|
+
this.name
|
|
3619
|
+
);
|
|
278
3620
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
3621
|
+
/**
|
|
3622
|
+
* 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.
|
|
3623
|
+
*
|
|
3624
|
+
* If you have the `pg_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
|
3625
|
+
*
|
|
3626
|
+
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
|
3627
|
+
*
|
|
3628
|
+
* @param method The name of the index method to be used
|
|
3629
|
+
* @param columns
|
|
3630
|
+
* @returns
|
|
3631
|
+
*/
|
|
3632
|
+
using(method, ...columns) {
|
|
3633
|
+
return new IndexBuilder(
|
|
3634
|
+
columns.map((it) => {
|
|
3635
|
+
if (is(it, SQL)) {
|
|
3636
|
+
return it;
|
|
3637
|
+
}
|
|
3638
|
+
it = it;
|
|
3639
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
3640
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
3641
|
+
return clonedIndexedColumn;
|
|
3642
|
+
}),
|
|
3643
|
+
this.unique,
|
|
3644
|
+
true,
|
|
3645
|
+
this.name,
|
|
3646
|
+
method
|
|
284
3647
|
);
|
|
285
|
-
if (alreadyInstalled) {
|
|
286
|
-
check("Claude Code hook already installed");
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
3648
|
}
|
|
290
|
-
|
|
291
|
-
|
|
3649
|
+
};
|
|
3650
|
+
var IndexBuilder = class {
|
|
3651
|
+
static [entityKind] = "PgIndexBuilder";
|
|
3652
|
+
/** @internal */
|
|
3653
|
+
config;
|
|
3654
|
+
constructor(columns, unique, only, name, method = "btree") {
|
|
3655
|
+
this.config = {
|
|
3656
|
+
name,
|
|
3657
|
+
columns,
|
|
3658
|
+
unique,
|
|
3659
|
+
only,
|
|
3660
|
+
method
|
|
3661
|
+
};
|
|
292
3662
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
3663
|
+
concurrently() {
|
|
3664
|
+
this.config.concurrently = true;
|
|
3665
|
+
return this;
|
|
3666
|
+
}
|
|
3667
|
+
with(obj) {
|
|
3668
|
+
this.config.with = obj;
|
|
3669
|
+
return this;
|
|
3670
|
+
}
|
|
3671
|
+
where(condition) {
|
|
3672
|
+
this.config.where = condition;
|
|
3673
|
+
return this;
|
|
3674
|
+
}
|
|
3675
|
+
/** @internal */
|
|
3676
|
+
build(table) {
|
|
3677
|
+
return new Index(this.config, table);
|
|
3678
|
+
}
|
|
3679
|
+
};
|
|
3680
|
+
var Index = class {
|
|
3681
|
+
static [entityKind] = "PgIndex";
|
|
3682
|
+
config;
|
|
3683
|
+
constructor(config, table) {
|
|
3684
|
+
this.config = { ...config, table };
|
|
3685
|
+
}
|
|
3686
|
+
};
|
|
3687
|
+
function index(name) {
|
|
3688
|
+
return new IndexBuilderOn(false, name);
|
|
305
3689
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
3690
|
+
function uniqueIndex(name) {
|
|
3691
|
+
return new IndexBuilderOn(true, name);
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
// ../../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
|
|
3695
|
+
var Relation = class {
|
|
3696
|
+
constructor(sourceTable, referencedTable, relationName) {
|
|
3697
|
+
this.sourceTable = sourceTable;
|
|
3698
|
+
this.referencedTable = referencedTable;
|
|
3699
|
+
this.relationName = relationName;
|
|
3700
|
+
this.referencedTableName = referencedTable[Table.Symbol.Name];
|
|
313
3701
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
console.log();
|
|
323
|
-
await login();
|
|
3702
|
+
static [entityKind] = "Relation";
|
|
3703
|
+
referencedTableName;
|
|
3704
|
+
fieldName;
|
|
3705
|
+
};
|
|
3706
|
+
var Relations = class {
|
|
3707
|
+
constructor(table, config) {
|
|
3708
|
+
this.table = table;
|
|
3709
|
+
this.config = config;
|
|
324
3710
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
3711
|
+
static [entityKind] = "Relations";
|
|
3712
|
+
};
|
|
3713
|
+
var One = class _One extends Relation {
|
|
3714
|
+
constructor(sourceTable, referencedTable, config, isNullable) {
|
|
3715
|
+
super(sourceTable, referencedTable, config?.relationName);
|
|
3716
|
+
this.config = config;
|
|
3717
|
+
this.isNullable = isNullable;
|
|
3718
|
+
}
|
|
3719
|
+
static [entityKind] = "One";
|
|
3720
|
+
withFieldName(fieldName) {
|
|
3721
|
+
const relation = new _One(
|
|
3722
|
+
this.sourceTable,
|
|
3723
|
+
this.referencedTable,
|
|
3724
|
+
this.config,
|
|
3725
|
+
this.isNullable
|
|
3726
|
+
);
|
|
3727
|
+
relation.fieldName = fieldName;
|
|
3728
|
+
return relation;
|
|
3729
|
+
}
|
|
3730
|
+
};
|
|
3731
|
+
var Many = class _Many extends Relation {
|
|
3732
|
+
constructor(sourceTable, referencedTable, config) {
|
|
3733
|
+
super(sourceTable, referencedTable, config?.relationName);
|
|
3734
|
+
this.config = config;
|
|
3735
|
+
}
|
|
3736
|
+
static [entityKind] = "Many";
|
|
3737
|
+
withFieldName(fieldName) {
|
|
3738
|
+
const relation = new _Many(
|
|
3739
|
+
this.sourceTable,
|
|
3740
|
+
this.referencedTable,
|
|
3741
|
+
this.config
|
|
3742
|
+
);
|
|
3743
|
+
relation.fieldName = fieldName;
|
|
3744
|
+
return relation;
|
|
3745
|
+
}
|
|
3746
|
+
};
|
|
3747
|
+
function relations(table, relations2) {
|
|
3748
|
+
return new Relations(
|
|
3749
|
+
table,
|
|
3750
|
+
(helpers) => Object.fromEntries(
|
|
3751
|
+
Object.entries(relations2(helpers)).map(([key, value]) => [
|
|
3752
|
+
key,
|
|
3753
|
+
value.withFieldName(key)
|
|
3754
|
+
])
|
|
3755
|
+
)
|
|
328
3756
|
);
|
|
329
|
-
console.log();
|
|
330
3757
|
}
|
|
331
3758
|
|
|
3759
|
+
// src/db/models/enums.ts
|
|
3760
|
+
function makeEnum(values) {
|
|
3761
|
+
return Object.fromEntries(values.map((v) => [v, v]));
|
|
3762
|
+
}
|
|
3763
|
+
var planValues = ["FREE", "TEAM", "ENTERPRISE"];
|
|
3764
|
+
var bsPlanEnum = pgEnum("bs_plan", planValues);
|
|
3765
|
+
var Plan = makeEnum(planValues);
|
|
3766
|
+
var orgRoleValues = ["ADMIN", "MANAGER", "USER"];
|
|
3767
|
+
var bsOrgRoleEnum = pgEnum("bs_org_role", orgRoleValues);
|
|
3768
|
+
var OrgRole = makeEnum(orgRoleValues);
|
|
3769
|
+
var artifactPeriodValues = ["QUARTER", "HALF", "YEAR", "CUSTOM"];
|
|
3770
|
+
var bsArtifactPeriodEnum = pgEnum("bs_artifact_period", artifactPeriodValues);
|
|
3771
|
+
var ArtifactPeriod = makeEnum(artifactPeriodValues);
|
|
3772
|
+
var artifactStatusValues = ["GENERATING", "READY", "FAILED"];
|
|
3773
|
+
var bsArtifactStatusEnum = pgEnum("bs_artifact_status", artifactStatusValues);
|
|
3774
|
+
var ArtifactStatus = makeEnum(artifactStatusValues);
|
|
3775
|
+
var workCategoryValues = ["FEATURE", "BUGFIX", "REFACTOR", "DOCS", "TESTING", "DEVOPS", "OTHER"];
|
|
3776
|
+
var bsWorkCategoryEnum = pgEnum("bs_work_category", workCategoryValues);
|
|
3777
|
+
var WorkCategory = makeEnum(workCategoryValues);
|
|
3778
|
+
var workOutcomeValues = ["COMPLETED", "IN_PROGRESS", "BLOCKED", "ABANDONED"];
|
|
3779
|
+
var bsWorkOutcomeEnum = pgEnum("bs_work_outcome", workOutcomeValues);
|
|
3780
|
+
var WorkOutcome = makeEnum(workOutcomeValues);
|
|
3781
|
+
var complexityValues = ["LOW", "MEDIUM", "HIGH"];
|
|
3782
|
+
var bsComplexityEnum = pgEnum("bs_complexity", complexityValues);
|
|
3783
|
+
var Complexity = makeEnum(complexityValues);
|
|
3784
|
+
var visibilityValues = ["PRIVATE", "TEAM", "PUBLIC"];
|
|
3785
|
+
var bsVisibilityEnum = pgEnum("bs_visibility", visibilityValues);
|
|
3786
|
+
var Visibility = makeEnum(visibilityValues);
|
|
3787
|
+
var integrationTypeValues = ["GITHUB", "HUBSPOT", "JIRA", "GOOGLE_CALENDAR", "FIREFLIES", "CLAUDE_CODE", "NOTION"];
|
|
3788
|
+
var bsIntegrationTypeEnum = pgEnum("bs_integration_type", integrationTypeValues);
|
|
3789
|
+
var IntegrationType = makeEnum(integrationTypeValues);
|
|
3790
|
+
|
|
3791
|
+
// src/db/models/auth.ts
|
|
3792
|
+
var import_cuid2 = __toESM(require_cuid2(), 1);
|
|
3793
|
+
var bsUsers = pgTable("bs_users", {
|
|
3794
|
+
id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
|
|
3795
|
+
name: text("name"),
|
|
3796
|
+
email: text("email").notNull().unique(),
|
|
3797
|
+
emailVerified: boolean("email_verified").default(false).notNull(),
|
|
3798
|
+
image: text("image"),
|
|
3799
|
+
stripeCustomerId: text("stripe_customer_id").unique(),
|
|
3800
|
+
stripePriceId: text("stripe_price_id"),
|
|
3801
|
+
stripeSubscriptionId: text("stripe_subscription_id").unique(),
|
|
3802
|
+
stripeCurrentPeriodEnd: timestamp("stripe_current_period_end"),
|
|
3803
|
+
plan: bsPlanEnum("plan").default("FREE").notNull(),
|
|
3804
|
+
firefliesApiKey: text("fireflies_api_key"),
|
|
3805
|
+
firefliesWebhookSecret: text("fireflies_webhook_secret"),
|
|
3806
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3807
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3808
|
+
});
|
|
3809
|
+
var bsAccounts = pgTable("bs_accounts", {
|
|
3810
|
+
id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
|
|
3811
|
+
userId: text("user_id").notNull(),
|
|
3812
|
+
accountId: text("account_id").notNull(),
|
|
3813
|
+
providerId: text("provider_id").notNull(),
|
|
3814
|
+
accessToken: text("access_token"),
|
|
3815
|
+
refreshToken: text("refresh_token"),
|
|
3816
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
|
3817
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
|
3818
|
+
scope: text("scope"),
|
|
3819
|
+
idToken: text("id_token"),
|
|
3820
|
+
password: text("password"),
|
|
3821
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3822
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3823
|
+
}, (table) => [
|
|
3824
|
+
uniqueIndex("bs_accounts_provider_account_id_idx").on(table.providerId, table.accountId)
|
|
3825
|
+
]);
|
|
3826
|
+
var bsSessions = pgTable("bs_sessions", {
|
|
3827
|
+
id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
|
|
3828
|
+
token: text("token").notNull().unique(),
|
|
3829
|
+
userId: text("user_id").notNull(),
|
|
3830
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
3831
|
+
ipAddress: text("ip_address"),
|
|
3832
|
+
userAgent: text("user_agent"),
|
|
3833
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3834
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3835
|
+
});
|
|
3836
|
+
var bsVerifications = pgTable("bs_verifications", {
|
|
3837
|
+
id: text("id").$defaultFn(() => (0, import_cuid2.createId)()).primaryKey(),
|
|
3838
|
+
identifier: text("identifier").notNull(),
|
|
3839
|
+
value: text("value").notNull(),
|
|
3840
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
3841
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3842
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3843
|
+
});
|
|
3844
|
+
|
|
3845
|
+
// src/db/models/org.ts
|
|
3846
|
+
var import_cuid22 = __toESM(require_cuid2(), 1);
|
|
3847
|
+
var bsOrgs = pgTable("bs_orgs", {
|
|
3848
|
+
id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
|
|
3849
|
+
name: text("name").notNull(),
|
|
3850
|
+
slug: text("slug").notNull().unique(),
|
|
3851
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3852
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3853
|
+
});
|
|
3854
|
+
var bsOrgMembers = pgTable("bs_org_members", {
|
|
3855
|
+
id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
|
|
3856
|
+
userId: text("user_id").notNull(),
|
|
3857
|
+
orgId: text("org_id").notNull(),
|
|
3858
|
+
role: bsOrgRoleEnum("role").default("USER").notNull(),
|
|
3859
|
+
teamId: text("team_id"),
|
|
3860
|
+
githubLogin: text("github_login")
|
|
3861
|
+
}, (table) => [
|
|
3862
|
+
uniqueIndex("bs_org_members_user_id_org_id_idx").on(table.userId, table.orgId),
|
|
3863
|
+
index("bs_org_members_team_id_idx").on(table.teamId)
|
|
3864
|
+
]);
|
|
3865
|
+
var bsTeams = pgTable("bs_teams", {
|
|
3866
|
+
id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
|
|
3867
|
+
orgId: text("org_id").notNull(),
|
|
3868
|
+
name: text("name").notNull(),
|
|
3869
|
+
// Parent team for nested tree structure (null = top-level).
|
|
3870
|
+
parentTeamId: text("parent_team_id"),
|
|
3871
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3872
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3873
|
+
}, (table) => [
|
|
3874
|
+
index("bs_teams_org_id_idx").on(table.orgId),
|
|
3875
|
+
index("bs_teams_parent_team_id_idx").on(table.parentTeamId)
|
|
3876
|
+
]);
|
|
3877
|
+
var bsOrgInvites = pgTable("bs_org_invites", {
|
|
3878
|
+
id: text("id").$defaultFn(() => (0, import_cuid22.createId)()).primaryKey(),
|
|
3879
|
+
email: text("email").notNull(),
|
|
3880
|
+
orgId: text("org_id").notNull(),
|
|
3881
|
+
role: bsOrgRoleEnum("role").default("USER").notNull(),
|
|
3882
|
+
token: text("token").$defaultFn(() => (0, import_cuid22.createId)()).notNull().unique(),
|
|
3883
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
3884
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
3885
|
+
});
|
|
3886
|
+
|
|
3887
|
+
// src/db/models/work.ts
|
|
3888
|
+
var import_cuid23 = __toESM(require_cuid2(), 1);
|
|
3889
|
+
var bsWorkEntries = pgTable("bs_work_entries", {
|
|
3890
|
+
id: text("id").$defaultFn(() => (0, import_cuid23.createId)()).primaryKey(),
|
|
3891
|
+
userId: text("user_id").notNull(),
|
|
3892
|
+
orgId: text("org_id"),
|
|
3893
|
+
tool: text("tool").notNull(),
|
|
3894
|
+
sessionId: text("session_id"),
|
|
3895
|
+
projectName: text("project_name"),
|
|
3896
|
+
repo: text("repo"),
|
|
3897
|
+
branch: text("branch"),
|
|
3898
|
+
summary: text("summary").notNull(),
|
|
3899
|
+
category: bsWorkCategoryEnum("category").default("OTHER").notNull(),
|
|
3900
|
+
why: text("why"),
|
|
3901
|
+
whatChanged: json("what_changed"),
|
|
3902
|
+
outcome: bsWorkOutcomeEnum("outcome").default("IN_PROGRESS").notNull(),
|
|
3903
|
+
filesTouched: integer("files_touched"),
|
|
3904
|
+
complexity: bsComplexityEnum("complexity"),
|
|
3905
|
+
toolVersion: text("tool_version"),
|
|
3906
|
+
model: text("model"),
|
|
3907
|
+
sessionDurationMin: integer("session_duration_min"),
|
|
3908
|
+
turns: integer("turns"),
|
|
3909
|
+
prUrl: text("pr_url"),
|
|
3910
|
+
ticketUrl: text("ticket_url"),
|
|
3911
|
+
commitShas: json("commit_shas"),
|
|
3912
|
+
visibility: bsVisibilityEnum("visibility").default("TEAM").notNull(),
|
|
3913
|
+
notionPageId: text("notion_page_id"),
|
|
3914
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3915
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3916
|
+
}, (table) => [
|
|
3917
|
+
index("bs_work_entries_user_id_idx").on(table.userId),
|
|
3918
|
+
index("bs_work_entries_org_id_idx").on(table.orgId),
|
|
3919
|
+
index("bs_work_entries_created_at_idx").on(table.createdAt),
|
|
3920
|
+
index("bs_work_entries_category_idx").on(table.category)
|
|
3921
|
+
]);
|
|
3922
|
+
var bsApiKeys = pgTable("bs_api_keys", {
|
|
3923
|
+
id: text("id").$defaultFn(() => (0, import_cuid23.createId)()).primaryKey(),
|
|
3924
|
+
userId: text("user_id").notNull(),
|
|
3925
|
+
name: text("name").notNull(),
|
|
3926
|
+
key: text("key").notNull().unique(),
|
|
3927
|
+
lastUsed: timestamp("last_used"),
|
|
3928
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
3929
|
+
});
|
|
3930
|
+
|
|
3931
|
+
// src/db/models/integrations.ts
|
|
3932
|
+
var import_cuid24 = __toESM(require_cuid2(), 1);
|
|
3933
|
+
var bsIntegrations = pgTable("bs_integrations", {
|
|
3934
|
+
id: text("id").$defaultFn(() => (0, import_cuid24.createId)()).primaryKey(),
|
|
3935
|
+
orgId: text("org_id").notNull(),
|
|
3936
|
+
type: bsIntegrationTypeEnum("type").notNull(),
|
|
3937
|
+
config: json("config").notNull(),
|
|
3938
|
+
enabled: boolean("enabled").default(true).notNull(),
|
|
3939
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3940
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3941
|
+
}, (table) => [
|
|
3942
|
+
uniqueIndex("bs_integrations_org_id_type_idx").on(table.orgId, table.type)
|
|
3943
|
+
]);
|
|
3944
|
+
var bsMemberOauthCredentials = pgTable("bs_member_oauth_credentials", {
|
|
3945
|
+
id: text("id").$defaultFn(() => (0, import_cuid24.createId)()).primaryKey(),
|
|
3946
|
+
userId: text("user_id").notNull(),
|
|
3947
|
+
orgId: text("org_id").notNull(),
|
|
3948
|
+
provider: text("provider").notNull(),
|
|
3949
|
+
// e.g. 'google-calendar'
|
|
3950
|
+
accessToken: text("access_token").notNull(),
|
|
3951
|
+
refreshToken: text("refresh_token"),
|
|
3952
|
+
scope: text("scope"),
|
|
3953
|
+
email: text("email"),
|
|
3954
|
+
expiresAt: timestamp("expires_at"),
|
|
3955
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3956
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3957
|
+
}, (table) => [
|
|
3958
|
+
uniqueIndex("bs_member_oauth_user_org_provider_idx").on(table.userId, table.orgId, table.provider)
|
|
3959
|
+
]);
|
|
3960
|
+
|
|
3961
|
+
// src/db/models/artifacts.ts
|
|
3962
|
+
var import_cuid25 = __toESM(require_cuid2(), 1);
|
|
3963
|
+
var bsArtifacts = pgTable("bs_artifacts", {
|
|
3964
|
+
id: text("id").$defaultFn(() => (0, import_cuid25.createId)()).primaryKey(),
|
|
3965
|
+
orgId: text("org_id").notNull(),
|
|
3966
|
+
// null = team rollup, otherwise per-person
|
|
3967
|
+
subjectUserId: text("subject_user_id"),
|
|
3968
|
+
// reserved for future sub-team support; null in v1
|
|
3969
|
+
subjectTeamId: text("subject_team_id"),
|
|
3970
|
+
generatedBy: text("generated_by"),
|
|
3971
|
+
// userId of creator; null = system/cron
|
|
3972
|
+
periodType: bsArtifactPeriodEnum("period_type").notNull(),
|
|
3973
|
+
periodStart: timestamp("period_start").notNull(),
|
|
3974
|
+
periodEnd: timestamp("period_end").notNull(),
|
|
3975
|
+
title: text("title").notNull(),
|
|
3976
|
+
narrative: text("narrative"),
|
|
3977
|
+
// markdown, LLM-generated
|
|
3978
|
+
stats: json("stats"),
|
|
3979
|
+
// raw metrics
|
|
3980
|
+
status: bsArtifactStatusEnum("status").default("GENERATING").notNull(),
|
|
3981
|
+
errorMessage: text("error_message"),
|
|
3982
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3983
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
3984
|
+
}, (table) => [
|
|
3985
|
+
index("bs_artifacts_org_id_idx").on(table.orgId),
|
|
3986
|
+
index("bs_artifacts_subject_user_id_idx").on(table.subjectUserId),
|
|
3987
|
+
index("bs_artifacts_period_idx").on(table.periodStart, table.periodEnd)
|
|
3988
|
+
]);
|
|
3989
|
+
|
|
3990
|
+
// src/db/models/relations.ts
|
|
3991
|
+
var bsUsersRelations = relations(bsUsers, ({ many }) => ({
|
|
3992
|
+
accounts: many(bsAccounts),
|
|
3993
|
+
sessions: many(bsSessions),
|
|
3994
|
+
orgMemberships: many(bsOrgMembers),
|
|
3995
|
+
workEntries: many(bsWorkEntries),
|
|
3996
|
+
apiKeys: many(bsApiKeys)
|
|
3997
|
+
}));
|
|
3998
|
+
var bsAccountsRelations = relations(bsAccounts, ({ one }) => ({
|
|
3999
|
+
user: one(bsUsers, { fields: [bsAccounts.userId], references: [bsUsers.id] })
|
|
4000
|
+
}));
|
|
4001
|
+
var bsSessionsRelations = relations(bsSessions, ({ one }) => ({
|
|
4002
|
+
user: one(bsUsers, { fields: [bsSessions.userId], references: [bsUsers.id] })
|
|
4003
|
+
}));
|
|
4004
|
+
var bsVerificationsRelations = relations(bsVerifications, ({ one }) => ({
|
|
4005
|
+
user: one(bsUsers, { fields: [bsVerifications.identifier], references: [bsUsers.email] })
|
|
4006
|
+
}));
|
|
4007
|
+
var bsOrgsRelations = relations(bsOrgs, ({ many }) => ({
|
|
4008
|
+
members: many(bsOrgMembers),
|
|
4009
|
+
invites: many(bsOrgInvites),
|
|
4010
|
+
integrations: many(bsIntegrations)
|
|
4011
|
+
}));
|
|
4012
|
+
var bsOrgMembersRelations = relations(bsOrgMembers, ({ one }) => ({
|
|
4013
|
+
user: one(bsUsers, { fields: [bsOrgMembers.userId], references: [bsUsers.id] }),
|
|
4014
|
+
org: one(bsOrgs, { fields: [bsOrgMembers.orgId], references: [bsOrgs.id] }),
|
|
4015
|
+
team: one(bsTeams, { fields: [bsOrgMembers.teamId], references: [bsTeams.id] })
|
|
4016
|
+
}));
|
|
4017
|
+
var bsTeamsRelations = relations(bsTeams, ({ one, many }) => ({
|
|
4018
|
+
org: one(bsOrgs, { fields: [bsTeams.orgId], references: [bsOrgs.id] }),
|
|
4019
|
+
parent: one(bsTeams, { fields: [bsTeams.parentTeamId], references: [bsTeams.id], relationName: "parentTeam" }),
|
|
4020
|
+
members: many(bsOrgMembers)
|
|
4021
|
+
}));
|
|
4022
|
+
var bsOrgInvitesRelations = relations(bsOrgInvites, ({ one }) => ({
|
|
4023
|
+
org: one(bsOrgs, { fields: [bsOrgInvites.orgId], references: [bsOrgs.id] })
|
|
4024
|
+
}));
|
|
4025
|
+
var bsWorkEntriesRelations = relations(bsWorkEntries, ({ one }) => ({
|
|
4026
|
+
user: one(bsUsers, { fields: [bsWorkEntries.userId], references: [bsUsers.id] })
|
|
4027
|
+
}));
|
|
4028
|
+
var bsApiKeysRelations = relations(bsApiKeys, ({ one }) => ({
|
|
4029
|
+
user: one(bsUsers, { fields: [bsApiKeys.userId], references: [bsUsers.id] })
|
|
4030
|
+
}));
|
|
4031
|
+
var bsIntegrationsRelations = relations(bsIntegrations, ({ one }) => ({
|
|
4032
|
+
org: one(bsOrgs, { fields: [bsIntegrations.orgId], references: [bsOrgs.id] })
|
|
4033
|
+
}));
|
|
4034
|
+
var bsArtifactsRelations = relations(bsArtifacts, ({ one }) => ({
|
|
4035
|
+
org: one(bsOrgs, { fields: [bsArtifacts.orgId], references: [bsOrgs.id] }),
|
|
4036
|
+
subjectUser: one(bsUsers, { fields: [bsArtifacts.subjectUserId], references: [bsUsers.id] })
|
|
4037
|
+
}));
|
|
4038
|
+
var bsMemberOauthCredentialsRelations = relations(bsMemberOauthCredentials, ({ one }) => ({
|
|
4039
|
+
user: one(bsUsers, { fields: [bsMemberOauthCredentials.userId], references: [bsUsers.id] }),
|
|
4040
|
+
org: one(bsOrgs, { fields: [bsMemberOauthCredentials.orgId], references: [bsOrgs.id] })
|
|
4041
|
+
}));
|
|
4042
|
+
|
|
332
4043
|
// src/cli/commands/status.ts
|
|
333
|
-
init_config();
|
|
334
4044
|
init_util();
|
|
335
|
-
import fs3 from "node:fs";
|
|
336
|
-
import path3 from "node:path";
|
|
337
4045
|
function groupBy(arr, fn) {
|
|
338
4046
|
const result = {};
|
|
339
4047
|
for (const item of arr) {
|
|
@@ -344,11 +4052,11 @@ function groupBy(arr, fn) {
|
|
|
344
4052
|
}
|
|
345
4053
|
function formatOutcome(outcome) {
|
|
346
4054
|
switch (outcome) {
|
|
347
|
-
case
|
|
4055
|
+
case WorkOutcome.COMPLETED:
|
|
348
4056
|
return c.green("completed");
|
|
349
|
-
case
|
|
4057
|
+
case WorkOutcome.IN_PROGRESS:
|
|
350
4058
|
return c.yellow("in progress");
|
|
351
|
-
case
|
|
4059
|
+
case WorkOutcome.BLOCKED:
|
|
352
4060
|
return c.red("blocked");
|
|
353
4061
|
default:
|
|
354
4062
|
return c.dim(outcome.toLowerCase());
|
|
@@ -415,7 +4123,7 @@ async function status() {
|
|
|
415
4123
|
(sum, e) => sum + (e.commitShas?.length || 0),
|
|
416
4124
|
0
|
|
417
4125
|
);
|
|
418
|
-
const latestOutcome = projectEntries[0]?.outcome ||
|
|
4126
|
+
const latestOutcome = projectEntries[0]?.outcome || WorkOutcome.IN_PROGRESS;
|
|
419
4127
|
const outcomeStr = formatOutcome(latestOutcome);
|
|
420
4128
|
const parts = [`${projectEntries.length} sessions`];
|
|
421
4129
|
if (commits > 0) {
|
|
@@ -443,10 +4151,11 @@ init_sync();
|
|
|
443
4151
|
init_config();
|
|
444
4152
|
import fs5 from "node:fs";
|
|
445
4153
|
import path5 from "node:path";
|
|
4154
|
+
import os3 from "node:os";
|
|
446
4155
|
import { execSync as execSync3 } from "node:child_process";
|
|
447
|
-
function parseTranscriptLine(
|
|
4156
|
+
function parseTranscriptLine(line2) {
|
|
448
4157
|
try {
|
|
449
|
-
return JSON.parse(
|
|
4158
|
+
return JSON.parse(line2);
|
|
450
4159
|
} catch {
|
|
451
4160
|
return null;
|
|
452
4161
|
}
|
|
@@ -497,8 +4206,8 @@ function analyzeTranscript(transcriptPath, acc) {
|
|
|
497
4206
|
if (!fs5.existsSync(transcriptPath)) return acc;
|
|
498
4207
|
const content = fs5.readFileSync(transcriptPath, "utf-8");
|
|
499
4208
|
const lines = content.split("\n").filter(Boolean);
|
|
500
|
-
for (const
|
|
501
|
-
const entry = parseTranscriptLine(
|
|
4209
|
+
for (const line2 of lines) {
|
|
4210
|
+
const entry = parseTranscriptLine(line2);
|
|
502
4211
|
if (!entry) continue;
|
|
503
4212
|
const message = entry.message;
|
|
504
4213
|
const contentBlocks = Array.isArray(message?.content) ? message.content : [];
|
|
@@ -541,7 +4250,7 @@ function analyzeTranscript(transcriptPath, acc) {
|
|
|
541
4250
|
function categorizeWork(acc) {
|
|
542
4251
|
const files = Array.from(acc.filesWritten);
|
|
543
4252
|
const fileCount = files.length;
|
|
544
|
-
let category =
|
|
4253
|
+
let category = WorkCategory.OTHER;
|
|
545
4254
|
const testFiles = files.filter(
|
|
546
4255
|
(f) => f.includes(".test.") || f.includes(".spec.") || f.includes("__tests__")
|
|
547
4256
|
);
|
|
@@ -551,17 +4260,31 @@ function categorizeWork(acc) {
|
|
|
551
4260
|
const configFiles = files.filter(
|
|
552
4261
|
(f) => f.includes("Dockerfile") || f.includes(".yml") || f.includes(".yaml") || f.includes("ci")
|
|
553
4262
|
);
|
|
554
|
-
if (testFiles.length > fileCount / 2) category =
|
|
555
|
-
else if (docFiles.length > fileCount / 2) category =
|
|
556
|
-
else if (configFiles.length > fileCount / 2) category =
|
|
557
|
-
else if (fileCount > 0) category =
|
|
558
|
-
let complexity =
|
|
559
|
-
if (fileCount === 0) complexity =
|
|
560
|
-
else if (fileCount <= 2) complexity =
|
|
561
|
-
else if (fileCount <= 6) complexity =
|
|
562
|
-
else complexity =
|
|
4263
|
+
if (testFiles.length > fileCount / 2) category = WorkCategory.TESTING;
|
|
4264
|
+
else if (docFiles.length > fileCount / 2) category = WorkCategory.DOCS;
|
|
4265
|
+
else if (configFiles.length > fileCount / 2) category = WorkCategory.DEVOPS;
|
|
4266
|
+
else if (fileCount > 0) category = WorkCategory.FEATURE;
|
|
4267
|
+
let complexity = Complexity.LOW;
|
|
4268
|
+
if (fileCount === 0) complexity = Complexity.LOW;
|
|
4269
|
+
else if (fileCount <= 2) complexity = Complexity.LOW;
|
|
4270
|
+
else if (fileCount <= 6) complexity = Complexity.MEDIUM;
|
|
4271
|
+
else complexity = Complexity.HIGH;
|
|
563
4272
|
return { category, complexity };
|
|
564
4273
|
}
|
|
4274
|
+
function readSkillSummary(sessionId) {
|
|
4275
|
+
const summaryFile = path5.join(
|
|
4276
|
+
os3.homedir(),
|
|
4277
|
+
".basestream",
|
|
4278
|
+
"sessions",
|
|
4279
|
+
`${sessionId}-summary.md`
|
|
4280
|
+
);
|
|
4281
|
+
if (!fs5.existsSync(summaryFile)) return null;
|
|
4282
|
+
try {
|
|
4283
|
+
return fs5.readFileSync(summaryFile, "utf-8").trim() || null;
|
|
4284
|
+
} catch {
|
|
4285
|
+
return null;
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
565
4288
|
function flushToBuffer(acc) {
|
|
566
4289
|
const { category, complexity } = categorizeWork(acc);
|
|
567
4290
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -575,14 +4298,14 @@ function flushToBuffer(acc) {
|
|
|
575
4298
|
projectName: acc.projectName || path5.basename(acc.cwd),
|
|
576
4299
|
repo: acc.gitRepo || null,
|
|
577
4300
|
branch: acc.gitBranch || null,
|
|
578
|
-
summary: buildSummary(acc, category),
|
|
4301
|
+
summary: readSkillSummary(acc.sessionId) ?? buildSummary(acc, category),
|
|
579
4302
|
category,
|
|
580
4303
|
why: null,
|
|
581
4304
|
// Hook-based: no "why" available (CLAUDE.md rules would provide this)
|
|
582
4305
|
whatChanged: Array.from(acc.filesWritten).map(
|
|
583
4306
|
(f) => path5.relative(acc.cwd, f) || f
|
|
584
4307
|
),
|
|
585
|
-
outcome:
|
|
4308
|
+
outcome: WorkOutcome.COMPLETED,
|
|
586
4309
|
filesTouched: acc.filesWritten.size,
|
|
587
4310
|
complexity,
|
|
588
4311
|
toolVersion: null,
|
|
@@ -592,7 +4315,7 @@ function flushToBuffer(acc) {
|
|
|
592
4315
|
prUrl: null,
|
|
593
4316
|
ticketUrl: null,
|
|
594
4317
|
commitShas: Array.from(acc.commitShas),
|
|
595
|
-
visibility:
|
|
4318
|
+
visibility: Visibility.TEAM,
|
|
596
4319
|
bufferedAt: now.toISOString()
|
|
597
4320
|
};
|
|
598
4321
|
ensureDirs();
|
|
@@ -606,7 +4329,7 @@ function buildSummary(acc, category) {
|
|
|
606
4329
|
const fileCount = acc.filesWritten.size;
|
|
607
4330
|
const commitCount = acc.commitShas.size;
|
|
608
4331
|
const parts = [];
|
|
609
|
-
if (category !==
|
|
4332
|
+
if (category !== WorkCategory.OTHER) {
|
|
610
4333
|
parts.push(category.toLowerCase());
|
|
611
4334
|
}
|
|
612
4335
|
if (fileCount > 0) {
|
|
@@ -673,6 +4396,66 @@ async function hookStop() {
|
|
|
673
4396
|
}
|
|
674
4397
|
}
|
|
675
4398
|
|
|
4399
|
+
// src/cli/commands/uninstall.ts
|
|
4400
|
+
init_util();
|
|
4401
|
+
import fs6 from "node:fs";
|
|
4402
|
+
import path6 from "node:path";
|
|
4403
|
+
import os4 from "node:os";
|
|
4404
|
+
var CLAUDE_SETTINGS_PATH2 = path6.join(
|
|
4405
|
+
os4.homedir(),
|
|
4406
|
+
".claude",
|
|
4407
|
+
"settings.json"
|
|
4408
|
+
);
|
|
4409
|
+
var HOOK_MARKER2 = "_hook-stop";
|
|
4410
|
+
function removeClaudeCodeHook() {
|
|
4411
|
+
if (!fs6.existsSync(CLAUDE_SETTINGS_PATH2)) {
|
|
4412
|
+
warn("No Claude Code settings found \u2014 nothing to remove");
|
|
4413
|
+
return false;
|
|
4414
|
+
}
|
|
4415
|
+
let settings;
|
|
4416
|
+
try {
|
|
4417
|
+
settings = JSON.parse(fs6.readFileSync(CLAUDE_SETTINGS_PATH2, "utf-8"));
|
|
4418
|
+
} catch {
|
|
4419
|
+
warn("Could not parse ~/.claude/settings.json");
|
|
4420
|
+
return false;
|
|
4421
|
+
}
|
|
4422
|
+
const hooks = settings.hooks;
|
|
4423
|
+
if (!hooks || !Array.isArray(hooks.Stop)) {
|
|
4424
|
+
warn("No Basestream hook installed");
|
|
4425
|
+
return false;
|
|
4426
|
+
}
|
|
4427
|
+
const before = hooks.Stop.length;
|
|
4428
|
+
hooks.Stop = hooks.Stop.filter(
|
|
4429
|
+
(entry) => !entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER2))
|
|
4430
|
+
);
|
|
4431
|
+
const after = hooks.Stop.length;
|
|
4432
|
+
if (before === after) {
|
|
4433
|
+
warn("No Basestream hook installed");
|
|
4434
|
+
return false;
|
|
4435
|
+
}
|
|
4436
|
+
if (hooks.Stop.length === 0) {
|
|
4437
|
+
delete hooks.Stop;
|
|
4438
|
+
}
|
|
4439
|
+
if (Object.keys(hooks).length === 0) {
|
|
4440
|
+
delete settings.hooks;
|
|
4441
|
+
}
|
|
4442
|
+
fs6.writeFileSync(CLAUDE_SETTINGS_PATH2, JSON.stringify(settings, null, 2));
|
|
4443
|
+
check("Removed tracking hook from ~/.claude/settings.json");
|
|
4444
|
+
return true;
|
|
4445
|
+
}
|
|
4446
|
+
async function uninstall() {
|
|
4447
|
+
console.log();
|
|
4448
|
+
removeClaudeCodeHook();
|
|
4449
|
+
console.log();
|
|
4450
|
+
console.log(
|
|
4451
|
+
` ${c.dim("Basestream will no longer track new Claude Code sessions.")}`
|
|
4452
|
+
);
|
|
4453
|
+
console.log(
|
|
4454
|
+
` ${c.dim("Your ~/.basestream/ buffer and credentials are preserved.")}`
|
|
4455
|
+
);
|
|
4456
|
+
console.log();
|
|
4457
|
+
}
|
|
4458
|
+
|
|
676
4459
|
// src/cli/index.ts
|
|
677
4460
|
var HELP = `
|
|
678
4461
|
basestream \u2014 AI work intelligence for teams
|
|
@@ -685,6 +4468,7 @@ Commands:
|
|
|
685
4468
|
basestream login Authenticate with your Basestream account
|
|
686
4469
|
basestream status Show this week's logged sessions
|
|
687
4470
|
basestream sync Manually sync buffered entries to Basestream
|
|
4471
|
+
basestream uninstall Remove the Claude Code tracking hook
|
|
688
4472
|
|
|
689
4473
|
Options:
|
|
690
4474
|
--help, -h Show this help message
|
|
@@ -697,7 +4481,7 @@ async function main() {
|
|
|
697
4481
|
process.exit(0);
|
|
698
4482
|
}
|
|
699
4483
|
if (command === "--version" || command === "-v") {
|
|
700
|
-
console.log(true ? "0.1
|
|
4484
|
+
console.log(true ? "0.2.1" : "dev");
|
|
701
4485
|
process.exit(0);
|
|
702
4486
|
}
|
|
703
4487
|
switch (command || "init") {
|
|
@@ -715,6 +4499,10 @@ async function main() {
|
|
|
715
4499
|
case "sync":
|
|
716
4500
|
await sync();
|
|
717
4501
|
break;
|
|
4502
|
+
case "uninstall":
|
|
4503
|
+
await uninstall();
|
|
4504
|
+
process.exit(0);
|
|
4505
|
+
break;
|
|
718
4506
|
case "_hook-stop":
|
|
719
4507
|
await hookStop();
|
|
720
4508
|
break;
|
|
@@ -728,3 +4516,8 @@ main().catch((err) => {
|
|
|
728
4516
|
console.error(err.message || err);
|
|
729
4517
|
process.exit(1);
|
|
730
4518
|
});
|
|
4519
|
+
/*! Bundled license information:
|
|
4520
|
+
|
|
4521
|
+
@noble/hashes/utils.js:
|
|
4522
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4523
|
+
*/
|