@pgxsinkit/contracts 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -54,15 +54,4882 @@ function buildRowFilterWhere(filter, claims, params) {
54
54
  }
55
55
  return parts.length > 1 ? `(${parts.join(" ")})` : parts[0];
56
56
  }
57
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/entity.js
58
+ var entityKind = Symbol.for("drizzle:entityKind");
59
+ var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
60
+ function is(value, type) {
61
+ if (!value || typeof value !== "object")
62
+ return false;
63
+ if (value instanceof type)
64
+ return true;
65
+ if (!Object.prototype.hasOwnProperty.call(type, entityKind))
66
+ throw new Error(`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.`);
67
+ let cls = Object.getPrototypeOf(value)?.constructor;
68
+ if (cls)
69
+ while (cls) {
70
+ if (entityKind in cls && cls[entityKind] === type[entityKind])
71
+ return true;
72
+ cls = Object.getPrototypeOf(cls);
73
+ }
74
+ return false;
75
+ }
76
+
77
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/column-common.js
78
+ var OriginalColumn = Symbol.for("drizzle:OriginalColumn");
79
+
80
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/column.js
81
+ var noop = (v) => v;
82
+ noop.isNoop = true;
83
+ var Column = class {
84
+ static [entityKind] = "Column";
85
+ codec;
86
+ name;
87
+ keyAsName;
88
+ primary;
89
+ notNull;
90
+ default;
91
+ defaultFn;
92
+ onUpdateFn;
93
+ hasDefault;
94
+ isUnique;
95
+ uniqueName;
96
+ uniqueType;
97
+ dataType;
98
+ columnType;
99
+ enumValues = undefined;
100
+ generated = undefined;
101
+ generatedIdentity = undefined;
102
+ length;
103
+ isLengthExact;
104
+ isAlias;
105
+ config;
106
+ table;
107
+ onInit() {}
108
+ constructor(table, config) {
109
+ this.config = config;
110
+ this.onInit();
111
+ this.table = table;
112
+ this.name = config.name;
113
+ this.isAlias = false;
114
+ this.keyAsName = config.keyAsName;
115
+ this.notNull = config.notNull;
116
+ this.default = config.default;
117
+ this.defaultFn = config.defaultFn;
118
+ this.onUpdateFn = config.onUpdateFn;
119
+ this.hasDefault = config.hasDefault;
120
+ this.primary = config.primaryKey;
121
+ this.isUnique = config.isUnique;
122
+ this.uniqueName = config.uniqueName;
123
+ this.uniqueType = config.uniqueType;
124
+ this.dataType = config.dataType;
125
+ this.columnType = config.columnType;
126
+ this.generated = config.generated;
127
+ this.generatedIdentity = config.generatedIdentity;
128
+ this.length = config["length"];
129
+ this.isLengthExact = config["isLengthExact"];
130
+ }
131
+ mapFromDriverValue = noop;
132
+ mapToDriverValue = noop;
133
+ postBuild() {
134
+ return this;
135
+ }
136
+ shouldDisableInsert() {
137
+ return this.config.generated !== undefined && this.config.generated.type !== "byDefault";
138
+ }
139
+ [OriginalColumn]() {
140
+ return this;
141
+ }
142
+ };
143
+
144
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/table.utils.js
145
+ var TableName = Symbol.for("drizzle:Name");
146
+
147
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/foreign-keys.js
148
+ var ForeignKeyBuilder = class {
149
+ static [entityKind] = "PgForeignKeyBuilder";
150
+ reference;
151
+ _onUpdate = "no action";
152
+ _onDelete = "no action";
153
+ constructor(config, actions) {
154
+ this.reference = () => {
155
+ const { name, columns, foreignColumns } = config();
156
+ return {
157
+ name,
158
+ columns,
159
+ foreignTable: foreignColumns[0].table,
160
+ foreignColumns
161
+ };
162
+ };
163
+ if (actions) {
164
+ this._onUpdate = actions.onUpdate;
165
+ this._onDelete = actions.onDelete;
166
+ }
167
+ }
168
+ onUpdate(action) {
169
+ this._onUpdate = action === undefined ? "no action" : action;
170
+ return this;
171
+ }
172
+ onDelete(action) {
173
+ this._onDelete = action === undefined ? "no action" : action;
174
+ return this;
175
+ }
176
+ build(table) {
177
+ return new ForeignKey(table, this);
178
+ }
179
+ };
180
+ var ForeignKey = class {
181
+ static [entityKind] = "PgForeignKey";
182
+ reference;
183
+ onUpdate;
184
+ onDelete;
185
+ name;
186
+ constructor(table, builder) {
187
+ this.table = table;
188
+ this.reference = builder.reference;
189
+ this.onUpdate = builder._onUpdate;
190
+ this.onDelete = builder._onDelete;
191
+ }
192
+ getName() {
193
+ const { name, columns, foreignColumns } = this.reference();
194
+ const columnNames = columns.map((column) => column.name);
195
+ const foreignColumnNames = foreignColumns.map((column) => column.name);
196
+ const chunks = [
197
+ this.table[TableName],
198
+ ...columnNames,
199
+ foreignColumns[0].table[TableName],
200
+ ...foreignColumnNames
201
+ ];
202
+ return name ?? `${chunks.join("_")}_fk`;
203
+ }
204
+ isNameExplicit() {
205
+ return !!this.reference().name;
206
+ }
207
+ };
208
+
209
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/tracing-utils.js
210
+ function iife(fn, ...args) {
211
+ return fn(...args);
212
+ }
213
+
214
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/common.js
215
+ var PgColumnBuilder = class {
216
+ static [entityKind] = "PgColumnBuilder";
217
+ foreignKeyConfigs = [];
218
+ config;
219
+ constructor(name, dataType, columnType) {
220
+ this.config = {
221
+ name,
222
+ keyAsName: name === "",
223
+ notNull: false,
224
+ default: undefined,
225
+ hasDefault: false,
226
+ primaryKey: false,
227
+ isUnique: false,
228
+ uniqueName: undefined,
229
+ uniqueType: undefined,
230
+ dataType,
231
+ columnType,
232
+ generated: undefined,
233
+ defaultFn: undefined,
234
+ onUpdateFn: undefined,
235
+ generatedIdentity: undefined
236
+ };
237
+ }
238
+ $type() {
239
+ return this;
240
+ }
241
+ notNull() {
242
+ this.config.notNull = true;
243
+ return this;
244
+ }
245
+ default(value) {
246
+ this.config.default = value;
247
+ this.config.hasDefault = true;
248
+ return this;
249
+ }
250
+ $defaultFn(fn) {
251
+ this.config.defaultFn = fn;
252
+ this.config.hasDefault = true;
253
+ return this;
254
+ }
255
+ $default = this.$defaultFn;
256
+ $onUpdateFn(fn) {
257
+ this.config.onUpdateFn = fn;
258
+ this.config.hasDefault = true;
259
+ return this;
260
+ }
261
+ $onUpdate = this.$onUpdateFn;
262
+ primaryKey() {
263
+ this.config.primaryKey = true;
264
+ this.config.notNull = true;
265
+ return this;
266
+ }
267
+ setName(name, casingFn) {
268
+ if (this.config.name !== "")
269
+ return;
270
+ this.config.name = casingFn(name);
271
+ }
272
+ array(dimensions) {
273
+ const dim = dimensions ?? "[]";
274
+ this.config.dimensions = dim.length / 2;
275
+ return this;
276
+ }
277
+ references(ref, config = {}) {
278
+ this.foreignKeyConfigs.push({
279
+ ref,
280
+ config
281
+ });
282
+ return this;
283
+ }
284
+ unique(name, config) {
285
+ this.config.isUnique = true;
286
+ this.config.uniqueName = name;
287
+ this.config.uniqueType = config?.nulls;
288
+ return this;
289
+ }
290
+ generatedAlwaysAs(as) {
291
+ this.config.generated = {
292
+ as,
293
+ type: "always",
294
+ mode: "stored"
295
+ };
296
+ return this;
297
+ }
298
+ buildForeignKeys(column, table) {
299
+ return this.foreignKeyConfigs.map(({ ref, config }) => {
300
+ return iife((ref2, config2) => {
301
+ const builder = new ForeignKeyBuilder(() => {
302
+ const foreignColumn = ref2();
303
+ return {
304
+ name: config2.name,
305
+ columns: [column],
306
+ foreignColumns: [foreignColumn]
307
+ };
308
+ });
309
+ if (config2.onUpdate)
310
+ builder.onUpdate(config2.onUpdate);
311
+ if (config2.onDelete)
312
+ builder.onDelete(config2.onDelete);
313
+ return builder.build(table);
314
+ }, ref, config);
315
+ });
316
+ }
317
+ buildExtraConfigColumn(table) {
318
+ return new ExtraConfigColumn(table, {
319
+ ...this.config,
320
+ dimensions: this.config.dimensions ?? 0
321
+ });
322
+ }
323
+ };
324
+ var PgColumn = class extends Column {
325
+ static [entityKind] = "PgColumn";
326
+ table;
327
+ dimensions;
328
+ constructor(table, config) {
329
+ super(table, config);
330
+ this.table = table;
331
+ this.dimensions = config.dimensions ?? 0;
332
+ }
333
+ postBuild() {
334
+ if (this.dimensions) {
335
+ const originalFromDriver = this.mapFromDriverValue.bind(this);
336
+ const originalToDriver = this.mapToDriverValue.bind(this);
337
+ this.mapFromDriverValue = this.mapFromDriverValue.isNoop ? this.mapFromDriverValue : (value) => {
338
+ return this.mapArrayElements(value, originalFromDriver, this.dimensions);
339
+ };
340
+ this.mapToDriverValue = this.mapToDriverValue.isNoop ? this.mapToDriverValue : (value) => {
341
+ return this.mapArrayElements(value, originalToDriver, this.dimensions);
342
+ };
343
+ }
344
+ return this;
345
+ }
346
+ mapArrayElements(value, mapper, depth) {
347
+ if (depth > 0 && Array.isArray(value))
348
+ return value.map((v) => v === null ? null : this.mapArrayElements(v, mapper, depth - 1));
349
+ return mapper(value);
350
+ }
351
+ };
352
+ var ExtraConfigColumn = class extends PgColumn {
353
+ static [entityKind] = "ExtraConfigColumn";
354
+ codec = undefined;
355
+ getSQLType() {
356
+ return this.getSQLType();
357
+ }
358
+ indexConfig = {
359
+ order: this.config.order ?? "asc",
360
+ nulls: this.config.nulls ?? "last",
361
+ opClass: this.config.opClass
362
+ };
363
+ defaultConfig = {
364
+ order: "asc",
365
+ nulls: "last",
366
+ opClass: undefined
367
+ };
368
+ asc() {
369
+ this.indexConfig.order = "asc";
370
+ return this;
371
+ }
372
+ desc() {
373
+ this.indexConfig.order = "desc";
374
+ return this;
375
+ }
376
+ nullsFirst() {
377
+ this.indexConfig.nulls = "first";
378
+ return this;
379
+ }
380
+ nullsLast() {
381
+ this.indexConfig.nulls = "last";
382
+ return this;
383
+ }
384
+ op(opClass) {
385
+ this.indexConfig.opClass = opClass;
386
+ return this;
387
+ }
388
+ };
389
+
390
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/int.common.js
391
+ var PgIntColumnBuilder = class extends PgColumnBuilder {
392
+ static [entityKind] = "PgIntColumnBaseBuilder";
393
+ generatedAlwaysAsIdentity(sequence) {
394
+ if (sequence) {
395
+ const { name, ...options } = sequence;
396
+ this.config.generatedIdentity = {
397
+ type: "always",
398
+ sequenceName: name,
399
+ sequenceOptions: options
400
+ };
401
+ } else
402
+ this.config.generatedIdentity = { type: "always" };
403
+ this.config.hasDefault = true;
404
+ this.config.notNull = true;
405
+ return this;
406
+ }
407
+ generatedByDefaultAsIdentity(sequence) {
408
+ if (sequence) {
409
+ const { name, ...options } = sequence;
410
+ this.config.generatedIdentity = {
411
+ type: "byDefault",
412
+ sequenceName: name,
413
+ sequenceOptions: options
414
+ };
415
+ } else
416
+ this.config.generatedIdentity = { type: "byDefault" };
417
+ this.config.hasDefault = true;
418
+ this.config.notNull = true;
419
+ return this;
420
+ }
421
+ };
422
+
423
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/subquery.js
424
+ var Subquery = class {
425
+ static [entityKind] = "Subquery";
426
+ constructor(sql, fields, alias, isWith = false, usedTables = []) {
427
+ this._ = {
428
+ brand: "Subquery",
429
+ sql,
430
+ selectedFields: fields,
431
+ alias,
432
+ isWith,
433
+ usedTables
434
+ };
435
+ }
436
+ };
437
+ var WithSubquery = class extends Subquery {
438
+ static [entityKind] = "WithSubquery";
439
+ };
440
+
441
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/table.js
442
+ var TableSchema = Symbol.for("drizzle:Schema");
443
+ var TableColumns = Symbol.for("drizzle:Columns");
444
+ var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
445
+ var OriginalName = Symbol.for("drizzle:OriginalName");
446
+ var BaseName = Symbol.for("drizzle:BaseName");
447
+ var IsAlias = Symbol.for("drizzle:IsAlias");
448
+ var ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
449
+ var IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
450
+ var Table = class {
451
+ static [entityKind] = "Table";
452
+ static Symbol = {
453
+ Name: TableName,
454
+ Schema: TableSchema,
455
+ OriginalName,
456
+ Columns: TableColumns,
457
+ ExtraConfigColumns,
458
+ BaseName,
459
+ IsAlias,
460
+ ExtraConfigBuilder
461
+ };
462
+ [TableName];
463
+ [OriginalName];
464
+ [TableSchema];
465
+ [TableColumns];
466
+ [ExtraConfigColumns];
467
+ [BaseName];
468
+ [IsAlias] = false;
469
+ [IsDrizzleTable] = true;
470
+ [ExtraConfigBuilder] = undefined;
471
+ constructor(name, schema, baseName) {
472
+ this[TableName] = this[OriginalName] = name;
473
+ this[TableSchema] = schema;
474
+ this[BaseName] = baseName;
475
+ }
476
+ };
477
+ function getTableName(table) {
478
+ return table[TableName];
479
+ }
480
+
481
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/tracing.js
482
+ var tracer = { startActiveSpan(name, fn) {
483
+ return fn();
484
+ } };
485
+
486
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/view-common.js
487
+ var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
488
+
489
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/sql/sql.js
490
+ function isSQLWrapper(value) {
491
+ return value !== null && value !== undefined && typeof value.getSQL === "function";
492
+ }
493
+ function mergeQueries(queries) {
494
+ const result = {
495
+ sql: "",
496
+ params: []
497
+ };
498
+ for (const query of queries) {
499
+ result.sql += query.sql;
500
+ result.params.push(...query.params);
501
+ }
502
+ return result;
503
+ }
504
+ function _mergeQueries(queries) {
505
+ const result = {
506
+ sql: "",
507
+ params: []
508
+ };
509
+ const sqls = [];
510
+ for (const query of queries) {
511
+ sqls.push(query.sql);
512
+ result.params.push(...query.params);
513
+ }
514
+ result._sql = Object.assign(sqls, { raw: sqls });
515
+ return result;
516
+ }
517
+ var StringChunk = class {
518
+ static [entityKind] = "StringChunk";
519
+ value;
520
+ constructor(value) {
521
+ this.value = Array.isArray(value) ? value : [value];
522
+ }
523
+ getSQL() {
524
+ return new SQL([this]);
525
+ }
526
+ };
527
+ var SQL = class SQL2 {
528
+ static [entityKind] = "SQL";
529
+ decoder = noopDecoder;
530
+ shouldInlineParams = false;
531
+ usedTables = [];
532
+ constructor(queryChunks) {
533
+ this.queryChunks = queryChunks;
534
+ for (const chunk of queryChunks)
535
+ if (is(chunk, Table)) {
536
+ const schemaName = chunk[Table.Symbol.Schema];
537
+ this.usedTables.push(schemaName === undefined ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
538
+ }
539
+ }
540
+ append(query) {
541
+ this.queryChunks.push(...query.queryChunks);
542
+ return this;
543
+ }
544
+ toQuery(config) {
545
+ return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
546
+ const query = this.buildQueryFromSourceParams(this.queryChunks, config);
547
+ span?.setAttributes({
548
+ "drizzle.query.text": query.sql,
549
+ "drizzle.query.params": JSON.stringify(query.params)
550
+ });
551
+ return query;
552
+ });
553
+ }
554
+ buildQueryFromSourceParams(chunks, _config) {
555
+ const config = Object.assign({}, _config, {
556
+ inlineParams: _config.inlineParams || this.shouldInlineParams,
557
+ paramStartIndex: _config.paramStartIndex || { value: 0 }
558
+ });
559
+ const { escapeName, escapeParam, codecs, inlineParams, paramStartIndex, invokeSource } = config;
560
+ const mappedChunks = chunks.map((chunk) => {
561
+ if (is(chunk, StringChunk))
562
+ return {
563
+ sql: chunk.value.join(""),
564
+ params: []
565
+ };
566
+ if (is(chunk, Name))
567
+ return {
568
+ sql: escapeName(chunk.value),
569
+ params: []
570
+ };
571
+ if (chunk === undefined)
572
+ return {
573
+ sql: "",
574
+ params: []
575
+ };
576
+ if (Array.isArray(chunk)) {
577
+ const result = [new StringChunk("(")];
578
+ for (const [i, p] of chunk.entries()) {
579
+ result.push(p);
580
+ if (i < chunk.length - 1)
581
+ result.push(new StringChunk(", "));
582
+ }
583
+ result.push(new StringChunk(")"));
584
+ return this.buildQueryFromSourceParams(result, config);
585
+ }
586
+ if (is(chunk, SQL2))
587
+ return this.buildQueryFromSourceParams(chunk.queryChunks, {
588
+ ...config,
589
+ inlineParams: inlineParams || chunk.shouldInlineParams
590
+ });
591
+ if (is(chunk, Table)) {
592
+ const schemaName = chunk[Table.Symbol.Schema];
593
+ const tableName = chunk[Table.Symbol.Name];
594
+ if (invokeSource === "mssql-view-with-schemabinding")
595
+ return {
596
+ sql: (schemaName === undefined ? escapeName("dbo") : escapeName(schemaName)) + "." + escapeName(tableName),
597
+ params: []
598
+ };
599
+ return {
600
+ sql: schemaName === undefined || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
601
+ params: []
602
+ };
603
+ }
604
+ if (is(chunk, Column)) {
605
+ const columnName = chunk.name;
606
+ if (_config.invokeSource === "indexes")
607
+ return {
608
+ sql: escapeName(columnName),
609
+ params: []
610
+ };
611
+ const schemaName = invokeSource === "mssql-check" ? undefined : chunk.table[Table.Symbol.Schema];
612
+ return {
613
+ sql: chunk.isAlias ? escapeName(chunk.name) : chunk.table[IsAlias] || schemaName === undefined ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
614
+ params: []
615
+ };
616
+ }
617
+ if (is(chunk, View)) {
618
+ const schemaName = chunk[ViewBaseConfig].schema;
619
+ const viewName = chunk[ViewBaseConfig].name;
620
+ return {
621
+ sql: schemaName === undefined || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
622
+ params: []
623
+ };
624
+ }
625
+ if (is(chunk, Param)) {
626
+ if (is(chunk.value, SQL2))
627
+ return this.buildQueryFromSourceParams([chunk.value], config);
628
+ const useCodecs = codecs && is(chunk.encoder, Column);
629
+ if (is(chunk.value, Placeholder)) {
630
+ const escaped2 = escapeParam(paramStartIndex.value++, chunk);
631
+ chunk.codec = useCodecs ? (value) => codecs.apply(chunk.encoder, "normalizeParam", value) : undefined;
632
+ return {
633
+ sql: useCodecs ? codecs.apply(chunk.encoder, "castParam", escaped2) : escaped2,
634
+ params: [chunk]
635
+ };
636
+ }
637
+ let mappedValue;
638
+ if (chunk.value === null)
639
+ mappedValue = chunk.value;
640
+ else {
641
+ mappedValue = chunk.encoder.mapToDriverValue.isNoop ? chunk.value : chunk.encoder.mapToDriverValue(chunk.value);
642
+ if (is(mappedValue, SQL2))
643
+ return this.buildQueryFromSourceParams([mappedValue], config);
644
+ if (useCodecs)
645
+ mappedValue = codecs.apply(chunk.encoder, "normalizeParam", mappedValue);
646
+ }
647
+ if (inlineParams)
648
+ return {
649
+ sql: this.mapInlineParam(mappedValue, config),
650
+ params: []
651
+ };
652
+ const escaped = escapeParam(paramStartIndex.value++, mappedValue);
653
+ return {
654
+ sql: useCodecs ? codecs.apply(chunk.encoder, "castParam", escaped) : escaped,
655
+ params: [mappedValue]
656
+ };
657
+ }
658
+ if (is(chunk, Placeholder))
659
+ return {
660
+ sql: escapeParam(paramStartIndex.value++, chunk),
661
+ params: [chunk]
662
+ };
663
+ if (is(chunk, SQL2.Aliased) && chunk.fieldAlias !== undefined)
664
+ return {
665
+ sql: (chunk.origin !== undefined ? escapeName(chunk.origin) + "." : "") + escapeName(chunk.fieldAlias),
666
+ params: []
667
+ };
668
+ if (is(chunk, Subquery)) {
669
+ if (chunk._.isWith)
670
+ return {
671
+ sql: escapeName(chunk._.alias),
672
+ params: []
673
+ };
674
+ return this.buildQueryFromSourceParams([
675
+ new StringChunk("("),
676
+ chunk._.sql,
677
+ new StringChunk(") "),
678
+ new Name(chunk._.alias)
679
+ ], config);
680
+ }
681
+ if (typeof chunk === "function" && "enumName" in chunk) {
682
+ if ("schema" in chunk && chunk.schema)
683
+ return {
684
+ sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
685
+ params: []
686
+ };
687
+ return {
688
+ sql: escapeName(chunk.enumName),
689
+ params: []
690
+ };
691
+ }
692
+ if (isSQLWrapper(chunk)) {
693
+ if (chunk.shouldOmitSQLParens?.())
694
+ return this.buildQueryFromSourceParams([chunk.getSQL()], config);
695
+ return this.buildQueryFromSourceParams([
696
+ new StringChunk("("),
697
+ chunk.getSQL(),
698
+ new StringChunk(")")
699
+ ], config);
700
+ }
701
+ if (inlineParams)
702
+ return {
703
+ sql: this.mapInlineParam(chunk, config),
704
+ params: []
705
+ };
706
+ return {
707
+ sql: escapeParam(paramStartIndex.value++, chunk),
708
+ params: [chunk]
709
+ };
710
+ });
711
+ if (_config.tagged)
712
+ return _mergeQueries(mappedChunks);
713
+ return mergeQueries(mappedChunks);
714
+ }
715
+ mapInlineParam(chunk, { escapeString }) {
716
+ if (chunk === null)
717
+ return "null";
718
+ if (typeof chunk === "number" || typeof chunk === "boolean" || typeof chunk === "bigint")
719
+ return chunk.toString();
720
+ if (typeof chunk === "string")
721
+ return escapeString(chunk);
722
+ if (typeof chunk === "object") {
723
+ const mappedValueAsString = chunk.toString();
724
+ if (mappedValueAsString === "[object Object]")
725
+ return escapeString(JSON.stringify(chunk));
726
+ return escapeString(mappedValueAsString);
727
+ }
728
+ throw new Error("Unexpected param value: " + chunk);
729
+ }
730
+ getSQL() {
731
+ return this;
732
+ }
733
+ as(alias) {
734
+ if (alias === undefined)
735
+ return this;
736
+ return new SQL2.Aliased(this, alias);
737
+ }
738
+ mapWith(decoder) {
739
+ this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
740
+ return this;
741
+ }
742
+ inlineParams() {
743
+ this.shouldInlineParams = true;
744
+ return this;
745
+ }
746
+ if(condition) {
747
+ return condition ? this : undefined;
748
+ }
749
+ };
750
+ var Name = class {
751
+ static [entityKind] = "Name";
752
+ brand;
753
+ constructor(value) {
754
+ this.value = value;
755
+ }
756
+ getSQL() {
757
+ return new SQL([this]);
758
+ }
759
+ };
760
+ function isDriverValueEncoder(value) {
761
+ return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
762
+ }
763
+ var noopDecoder = { mapFromDriverValue: (value) => value };
764
+ noopDecoder.mapFromDriverValue.isNoop = true;
765
+ var noopEncoder = { mapToDriverValue: (value) => value };
766
+ noopEncoder.mapToDriverValue.isNoop = true;
767
+ var noopMapper = {
768
+ ...noopDecoder,
769
+ ...noopEncoder
770
+ };
771
+ var Param = class {
772
+ static [entityKind] = "Param";
773
+ brand;
774
+ constructor(value, encoder = noopEncoder, codec) {
775
+ this.value = value;
776
+ this.encoder = encoder;
777
+ this.codec = codec;
778
+ }
779
+ getSQL() {
780
+ return new SQL([this]);
781
+ }
782
+ };
783
+ function sql(strings, ...params) {
784
+ const queryChunks = [];
785
+ if (params.length > 0 || strings.length > 0 && strings[0] !== "")
786
+ queryChunks.push(new StringChunk(strings[0]));
787
+ for (const [paramIndex, param] of params.entries())
788
+ queryChunks.push(param, new StringChunk(strings[paramIndex + 1]));
789
+ return new SQL(queryChunks);
790
+ }
791
+ (function(_sql) {
792
+ function empty() {
793
+ return new SQL([]);
794
+ }
795
+ _sql.empty = empty;
796
+ function fromList(list) {
797
+ return new SQL(list);
798
+ }
799
+ _sql.fromList = fromList;
800
+ function raw(str) {
801
+ return new SQL([new StringChunk(str)]);
802
+ }
803
+ _sql.raw = raw;
804
+ function join(chunks, separator) {
805
+ const result = [];
806
+ for (const [i, chunk] of chunks.entries()) {
807
+ if (i > 0 && separator !== undefined)
808
+ result.push(separator);
809
+ result.push(chunk);
810
+ }
811
+ return new SQL(result);
812
+ }
813
+ _sql.join = join;
814
+ function identifier(value) {
815
+ return new Name(value);
816
+ }
817
+ _sql.identifier = identifier;
818
+ function placeholder(name) {
819
+ return new Placeholder(name);
820
+ }
821
+ _sql.placeholder = placeholder;
822
+ function param(value, encoder) {
823
+ return new Param(value, encoder);
824
+ }
825
+ _sql.param = param;
826
+ function comment(input) {
827
+ const encoded = sqlCommenter(input);
828
+ if (!encoded.length)
829
+ return;
830
+ return sql.raw(encoded);
831
+ }
832
+ _sql.comment = comment;
833
+ })(sql || (sql = {}));
834
+ function sqlCommenter(input) {
835
+ const encoded = sqlCommenter.encodeInput(input);
836
+ if (!encoded.length)
837
+ return "";
838
+ return `/*${encoded}*/`;
839
+ }
840
+ (function(_sqlCommenter) {
841
+ function merge(input1, input2) {
842
+ let encoded;
843
+ if (typeof input1 === "object" && typeof input2 === "object")
844
+ encoded = encodeInput({
845
+ ...input1,
846
+ ...input2
847
+ });
848
+ else if (input1 && input2)
849
+ encoded = [encodeInput(input1), encodeInput(input2)].filter((i) => i.length).join(",");
850
+ else if (input2)
851
+ encoded = encodeInput(input2);
852
+ else if (input1)
853
+ encoded = encodeInput(input1);
854
+ else
855
+ return "";
856
+ if (!encoded.length)
857
+ return "";
858
+ return `/*${encoded}*/`;
859
+ }
860
+ _sqlCommenter.merge = merge;
861
+ function encodeInput(input) {
862
+ if (typeof input === "string") {
863
+ if (!input.length)
864
+ return input;
865
+ return sanitizeStringInput(input);
866
+ }
867
+ const parts = [];
868
+ for (const [key, value] of Object.entries(input)) {
869
+ if (value === null || value === undefined || value === "")
870
+ continue;
871
+ const encodedKey = sanitizeObjectElement(key);
872
+ const encodedValue = sanitizeObjectElement(String(value));
873
+ parts.push(`${encodedKey}='${encodedValue}'`);
874
+ }
875
+ if (!parts.length)
876
+ return "";
877
+ return parts.sort().join(",");
878
+ }
879
+ _sqlCommenter.encodeInput = encodeInput;
880
+ function sanitizeObjectElement(key) {
881
+ return encodeURIComponent(key).replace(/'/g, `\\'`);
882
+ }
883
+ _sqlCommenter.sanitizeObjectElement = sanitizeObjectElement;
884
+ function sanitizeStringInput(input) {
885
+ return input.replace(/\/\*/g, "/ *").replace(/\*\//g, "* /");
886
+ }
887
+ _sqlCommenter.sanitizeStringInput = sanitizeStringInput;
888
+ })(sqlCommenter || (sqlCommenter = {}));
889
+ (function(_SQL) {
890
+
891
+ class Aliased {
892
+ static [entityKind] = "SQL.Aliased";
893
+ isSelectionField = false;
894
+ origin;
895
+ constructor(sql2, fieldAlias) {
896
+ this.sql = sql2;
897
+ this.fieldAlias = fieldAlias;
898
+ }
899
+ getSQL() {
900
+ return this.sql;
901
+ }
902
+ clone() {
903
+ return new Aliased(this.sql, this.fieldAlias);
904
+ }
905
+ }
906
+ _SQL.Aliased = Aliased;
907
+ })(SQL || (SQL = {}));
908
+ var Placeholder = class {
909
+ static [entityKind] = "Placeholder";
910
+ constructor(name) {
911
+ this.name = name;
912
+ }
913
+ getSQL() {
914
+ return new SQL([this]);
915
+ }
916
+ };
917
+ var IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
918
+ var View = class {
919
+ static [entityKind] = "View";
920
+ [ViewBaseConfig];
921
+ [IsDrizzleView] = true;
922
+ get [TableName]() {
923
+ return this[ViewBaseConfig].name;
924
+ }
925
+ get [TableSchema]() {
926
+ return this[ViewBaseConfig].schema;
927
+ }
928
+ get [IsAlias]() {
929
+ return this[ViewBaseConfig].isAlias;
930
+ }
931
+ get [OriginalName]() {
932
+ return this[ViewBaseConfig].originalName;
933
+ }
934
+ get [TableColumns]() {
935
+ return this[ViewBaseConfig].selectedFields;
936
+ }
937
+ constructor({ name, schema, selectedFields, query }) {
938
+ this[ViewBaseConfig] = {
939
+ name,
940
+ originalName: name,
941
+ schema,
942
+ selectedFields,
943
+ query,
944
+ isExisting: !query,
945
+ isAlias: false
946
+ };
947
+ }
948
+ };
949
+ Column.prototype.getSQL = function() {
950
+ return new SQL([this]);
951
+ };
952
+ Subquery.prototype.getSQL = function() {
953
+ return new SQL([this]);
954
+ };
955
+
956
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/utils.js
957
+ var FnConstructor = Object.getPrototypeOf(() => null).constructor;
958
+ function makeJitQueryMapperInner(columns, joinsNotNullableMap = {}) {
959
+ const preFn = [];
960
+ const fn = [];
961
+ fn.push(`const [ ${columns.map((_, i) => `c${i}`).join(", ")} ] = rows[i];`);
962
+ const nullifyMap = {};
963
+ const objectIds = {};
964
+ const decodes = Array.from({ length: columns.length });
965
+ for (let idx = 0;idx < columns.length; ++idx) {
966
+ const { field, path, codec, arrayDimensions } = columns[idx];
967
+ let decoder;
968
+ let decoderStr;
969
+ let decoderFieldDestructure;
970
+ let isColumn = false;
971
+ if (is(field, Column)) {
972
+ isColumn = true;
973
+ decoder = field;
974
+ decoderFieldDestructure = `field: decoder${idx}`;
975
+ } else if (is(field, SQL)) {
976
+ decoder = field.decoder;
977
+ decoderFieldDestructure = `field: { decoder: decoder${idx} }`;
978
+ } else if (is(field, Subquery)) {
979
+ decoder = field._.sql.decoder;
980
+ decoderFieldDestructure = `field: { _: { sql: { decoder: decoder${idx} } } }`;
981
+ } else {
982
+ decoder = field.sql.decoder;
983
+ decoderFieldDestructure = `field: { sql: { decoder: decoder${idx} } }`;
984
+ }
985
+ decoderStr = `decoder${idx}.mapFromDriverValue`;
986
+ if (decoder.mapFromDriverValue.isNoop)
987
+ decoderStr = "";
988
+ if (decoderStr)
989
+ preFn.push(`const { ${decoderFieldDestructure}${codec ? `, codec: codec${idx}` : ""} } = columns[${idx}];`);
990
+ else if (codec)
991
+ preFn.push(`const { codec: codec${idx} } = columns[${idx}];`);
992
+ const colStr = `c${idx}`;
993
+ let decodedValue = colStr;
994
+ if (codec)
995
+ decodedValue = `codec${idx}(${decodedValue}, ${arrayDimensions})`;
996
+ if (decoderStr)
997
+ decodedValue = `${decoderStr}(${decodedValue})`;
998
+ decodes[idx] = colStr === decodedValue ? `${colStr}` : `${colStr} === null ? ${colStr} : ${decodedValue}`;
999
+ if (path.length !== 2 || !isColumn)
1000
+ continue;
1001
+ if (objectIds[path[0]] === undefined)
1002
+ objectIds[path[0]] = [`c${idx}`];
1003
+ else
1004
+ objectIds[path[0]]?.push(`c${idx}`);
1005
+ const [objectName] = path;
1006
+ const tableName = getTableName(field.table);
1007
+ nullifyMap[objectName] = joinsNotNullableMap[tableName] ? false : typeof nullifyMap[objectName] === "string" ? nullifyMap[objectName] === tableName ? tableName : false : tableName;
1008
+ }
1009
+ fn.push(`mapped[i] = {`);
1010
+ let currentObjectPath = [];
1011
+ for (let idx = 0;idx < columns.length; ++idx) {
1012
+ const { path } = columns[idx];
1013
+ const jsonPath = path.map((e) => JSON.stringify(e));
1014
+ const decodedValue = decodes[idx];
1015
+ const objectPath = path.slice(0, -1);
1016
+ let commonLen = 0;
1017
+ while (commonLen < currentObjectPath.length && commonLen < objectPath.length && currentObjectPath[commonLen] === objectPath[commonLen])
1018
+ commonLen++;
1019
+ for (let d = currentObjectPath.length - 1;d >= commonLen; --d)
1020
+ fn.push(`${"\t".repeat(d + 1)}},`);
1021
+ for (let d = commonLen;d < objectPath.length; ++d)
1022
+ fn.push(`${"\t".repeat(d + 1)}${jsonPath[d]}: ${d === 0 && objectPath.length === 1 && typeof nullifyMap[path[0]] === "string" ? `${objectIds[path[0]]?.map((c) => `${c} === null`).join(" && ")} ? null : {` : "{"}`);
1023
+ currentObjectPath = objectPath;
1024
+ fn.push(`${"\t".repeat(path.length)}${jsonPath[path.length - 1]}: ${decodedValue},`);
1025
+ }
1026
+ for (let d = currentObjectPath.length - 1;d >= 0; --d)
1027
+ fn.push(`${"\t".repeat(d + 1)}},`);
1028
+ fn.push(`};`);
1029
+ return `${preFn.length ? `${preFn.join(`
1030
+ `)}
1031
+ ` : ""}for (let i = 0; i < length; ++i) {
1032
+ ${fn.join(`
1033
+ `)}
1034
+ }`;
1035
+ }
1036
+ function makeJitQueryMapper(columns, joinsNotNullableMap) {
1037
+ const internals = ` "use strict";
1038
+ const { columns } = this;
1039
+ const { length } = rows;
1040
+ const mapped = Array.from({ length });
1041
+ ${makeJitQueryMapperInner(columns, joinsNotNullableMap)}
1042
+ return mapped;
1043
+ //# sourceURL=drizzle:jit-query-mapper`;
1044
+ return Object.assign(new FnConstructor("rows", internals).bind({ columns }), { body: `function jitQueryMapper (rows) {
1045
+ ${internals}
1046
+ }` });
1047
+ }
1048
+ function makeDefaultQueryMapper(columns, joinsNotNullableMap) {
1049
+ const interpretedData = columns.map(({ field, codec, arrayDimensions, path }) => {
1050
+ let processNullifyMap;
1051
+ let decoderSrc;
1052
+ if (is(field, Column)) {
1053
+ decoderSrc = field;
1054
+ if (joinsNotNullableMap && path.length === 2) {
1055
+ const objectName = path[0];
1056
+ processNullifyMap = (nullifyMap, value) => {
1057
+ if (!(objectName in nullifyMap))
1058
+ nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
1059
+ else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table))
1060
+ nullifyMap[objectName] = false;
1061
+ };
1062
+ }
1063
+ } else if (is(field, SQL))
1064
+ decoderSrc = field.decoder;
1065
+ else if (is(field, Subquery))
1066
+ decoderSrc = field._.sql.decoder;
1067
+ else
1068
+ decoderSrc = field.sql.decoder;
1069
+ let decoder;
1070
+ if (decoderSrc.mapFromDriverValue.isNoop)
1071
+ decoder = codec ? (v) => codec(v, arrayDimensions) : undefined;
1072
+ else
1073
+ decoder = codec ? (v) => decoderSrc.mapFromDriverValue(codec(v, arrayDimensions)) : (v) => decoderSrc.mapFromDriverValue(v);
1074
+ return [decoder, processNullifyMap];
1075
+ });
1076
+ return (rows) => rows.map((row) => {
1077
+ const nullifyMap = {};
1078
+ const result = columns.reduce((result2, { path }, columnIndex) => {
1079
+ let node = result2;
1080
+ for (const [pathChunkIndex, pathChunk] of path.entries())
1081
+ if (pathChunkIndex < path.length - 1) {
1082
+ if (!(pathChunk in node))
1083
+ node[pathChunk] = {};
1084
+ node = node[pathChunk];
1085
+ } else {
1086
+ const [decoder, processNullifyMap] = interpretedData[columnIndex];
1087
+ const rawValue = row[columnIndex];
1088
+ const value = node[pathChunk] = rawValue === null ? null : decoder ? decoder(rawValue) : rawValue;
1089
+ processNullifyMap?.(nullifyMap, value);
1090
+ }
1091
+ return result2;
1092
+ }, {});
1093
+ if (joinsNotNullableMap && Object.keys(nullifyMap).length > 0) {
1094
+ for (const [objectName, tableName] of Object.entries(nullifyMap))
1095
+ if (typeof tableName === "string" && !joinsNotNullableMap[tableName])
1096
+ result[objectName] = null;
1097
+ }
1098
+ return result;
1099
+ });
1100
+ }
1101
+ function orderSelectedFields(fields, pathPrefix, codecs) {
1102
+ return Object.entries(fields).reduce((result, [name, field]) => {
1103
+ if (typeof name !== "string")
1104
+ return result;
1105
+ const newPath = pathPrefix ? [...pathPrefix, name] : [name];
1106
+ if (is(field, Column))
1107
+ result.push({
1108
+ path: newPath,
1109
+ field,
1110
+ codec: codecs?.get(field, "normalize"),
1111
+ arrayDimensions: field.dimensions
1112
+ });
1113
+ else if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery))
1114
+ result.push({
1115
+ path: newPath,
1116
+ field
1117
+ });
1118
+ else if (is(field, Table))
1119
+ result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath, codecs));
1120
+ else
1121
+ result.push(...orderSelectedFields(field, newPath, codecs));
1122
+ return result;
1123
+ }, []);
1124
+ }
1125
+ function haveSameKeys(left, right) {
1126
+ const leftKeys = Object.keys(left);
1127
+ const rightKeys = Object.keys(right);
1128
+ if (leftKeys.length !== rightKeys.length)
1129
+ return false;
1130
+ for (const [index, key] of leftKeys.entries())
1131
+ if (key !== rightKeys[index])
1132
+ return false;
1133
+ return true;
1134
+ }
1135
+ function getTableColumns(table) {
1136
+ return table[Table.Symbol.Columns];
1137
+ }
1138
+ function getTableLikeName(table) {
1139
+ return is(table, Subquery) ? table._.alias : is(table, View) ? table[ViewBaseConfig].name : is(table, SQL) ? undefined : table[Table.Symbol.IsAlias] ? table[Table.Symbol.Name] : table[Table.Symbol.BaseName];
1140
+ }
1141
+ function getColumnNameAndConfig(a, b) {
1142
+ return {
1143
+ name: typeof a === "string" && a.length > 0 ? a : "",
1144
+ config: typeof a === "object" ? a : b
1145
+ };
1146
+ }
1147
+ var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
1148
+ var CONSTANTS = {
1149
+ INT8_MIN: -128,
1150
+ INT8_MAX: 127,
1151
+ INT8_UNSIGNED_MAX: 255,
1152
+ INT16_MIN: -32768,
1153
+ INT16_MAX: 32767,
1154
+ INT16_UNSIGNED_MAX: 65535,
1155
+ INT24_MIN: -8388608,
1156
+ INT24_MAX: 8388607,
1157
+ INT24_UNSIGNED_MAX: 16777215,
1158
+ INT32_MIN: -2147483648,
1159
+ INT32_MAX: 2147483647,
1160
+ INT32_UNSIGNED_MAX: 4294967295,
1161
+ INT48_MIN: -140737488355328,
1162
+ INT48_MAX: 140737488355327,
1163
+ INT48_UNSIGNED_MAX: 281474976710655,
1164
+ INT64_MIN: -9223372036854775808n,
1165
+ INT64_MAX: 9223372036854775807n,
1166
+ INT64_UNSIGNED_MAX: 18446744073709551615n
1167
+ };
1168
+
1169
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/bigint.js
1170
+ var PgBigInt53Builder = class extends PgIntColumnBuilder {
1171
+ static [entityKind] = "PgBigInt53Builder";
1172
+ constructor(name) {
1173
+ super(name, "number int53", "PgBigInt53");
1174
+ }
1175
+ build(table) {
1176
+ return new PgBigInt53(table, this.config);
1177
+ }
1178
+ };
1179
+ var PgBigInt53 = class extends PgColumn {
1180
+ static [entityKind] = "PgBigInt53";
1181
+ codec = "bigint:number";
1182
+ getSQLType() {
1183
+ return "bigint";
1184
+ }
1185
+ };
1186
+ var PgBigInt64Builder = class extends PgIntColumnBuilder {
1187
+ static [entityKind] = "PgBigInt64Builder";
1188
+ constructor(name) {
1189
+ super(name, "bigint int64", "PgBigInt64");
1190
+ }
1191
+ build(table) {
1192
+ return new PgBigInt64(table, this.config);
1193
+ }
1194
+ };
1195
+ var PgBigInt64 = class extends PgColumn {
1196
+ static [entityKind] = "PgBigInt64";
1197
+ codec = "bigint";
1198
+ getSQLType() {
1199
+ return "bigint";
1200
+ }
1201
+ };
1202
+ var PgBigIntStringBuilder = class extends PgIntColumnBuilder {
1203
+ static [entityKind] = "PgBigIntStringBuilder";
1204
+ constructor(name) {
1205
+ super(name, "string int64", "PgBigIntString");
1206
+ }
1207
+ build(table) {
1208
+ return new PgBigIntString(table, this.config);
1209
+ }
1210
+ };
1211
+ var PgBigIntString = class extends PgColumn {
1212
+ static [entityKind] = "PgBigIntString";
1213
+ codec = "bigint:string";
1214
+ getSQLType() {
1215
+ return "bigint";
1216
+ }
1217
+ };
1218
+ function bigint(a, b) {
1219
+ const { name, config } = getColumnNameAndConfig(a, b);
1220
+ if (config.mode === "number")
1221
+ return new PgBigInt53Builder(name);
1222
+ if (config.mode === "string")
1223
+ return new PgBigIntStringBuilder(name);
1224
+ return new PgBigInt64Builder(name);
1225
+ }
1226
+
1227
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/bigserial.js
1228
+ var PgBigSerial53Builder = class extends PgColumnBuilder {
1229
+ static [entityKind] = "PgBigSerial53Builder";
1230
+ constructor(name) {
1231
+ super(name, "number int53", "PgBigSerial53");
1232
+ this.config.hasDefault = true;
1233
+ this.config.notNull = true;
1234
+ }
1235
+ build(table) {
1236
+ return new PgBigSerial53(table, this.config);
1237
+ }
1238
+ };
1239
+ var PgBigSerial53 = class extends PgColumn {
1240
+ static [entityKind] = "PgBigSerial53";
1241
+ codec = "bigserial:number";
1242
+ getSQLType() {
1243
+ return "bigserial";
1244
+ }
1245
+ };
1246
+ var PgBigSerial64Builder = class extends PgColumnBuilder {
1247
+ static [entityKind] = "PgBigSerial64Builder";
1248
+ constructor(name) {
1249
+ super(name, "bigint int64", "PgBigSerial64");
1250
+ this.config.hasDefault = true;
1251
+ this.config.notNull = true;
1252
+ }
1253
+ build(table) {
1254
+ return new PgBigSerial64(table, this.config);
1255
+ }
1256
+ };
1257
+ var PgBigSerial64 = class extends PgColumn {
1258
+ static [entityKind] = "PgBigSerial64";
1259
+ codec = "bigserial";
1260
+ getSQLType() {
1261
+ return "bigserial";
1262
+ }
1263
+ };
1264
+ function bigserial(a, b) {
1265
+ const { name, config } = getColumnNameAndConfig(a, b);
1266
+ if (config.mode === "number")
1267
+ return new PgBigSerial53Builder(name);
1268
+ return new PgBigSerial64Builder(name);
1269
+ }
1270
+
1271
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/boolean.js
1272
+ var PgBooleanBuilder = class extends PgColumnBuilder {
1273
+ static [entityKind] = "PgBooleanBuilder";
1274
+ constructor(name) {
1275
+ super(name, "boolean", "PgBoolean");
1276
+ }
1277
+ build(table) {
1278
+ return new PgBoolean(table, this.config);
1279
+ }
1280
+ };
1281
+ var PgBoolean = class extends PgColumn {
1282
+ static [entityKind] = "PgBoolean";
1283
+ codec = "bool";
1284
+ getSQLType() {
1285
+ return "boolean";
1286
+ }
1287
+ };
1288
+ function boolean(name) {
1289
+ return new PgBooleanBuilder(name ?? "");
1290
+ }
1291
+
1292
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/char.js
1293
+ var PgCharBuilder = class extends PgColumnBuilder {
1294
+ static [entityKind] = "PgCharBuilder";
1295
+ constructor(name, config) {
1296
+ super(name, config.enum?.length ? "string enum" : "string", "PgChar");
1297
+ this.config.length = config.length ?? 1;
1298
+ this.config.setLength = config.length !== undefined;
1299
+ this.config.enumValues = config.enum;
1300
+ }
1301
+ build(table) {
1302
+ return new PgChar(table, this.config);
1303
+ }
1304
+ };
1305
+ var PgChar = class extends PgColumn {
1306
+ static [entityKind] = "PgChar";
1307
+ codec = "char";
1308
+ enumValues;
1309
+ setLength;
1310
+ constructor(table, config) {
1311
+ super(table, config);
1312
+ this.enumValues = config.enumValues;
1313
+ this.setLength = config.setLength;
1314
+ }
1315
+ getSQLType() {
1316
+ return this.setLength ? `char(${this.length})` : `char`;
1317
+ }
1318
+ };
1319
+ function char(a, b = {}) {
1320
+ const { name, config } = getColumnNameAndConfig(a, b);
1321
+ return new PgCharBuilder(name, config);
1322
+ }
1323
+
1324
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/cidr.js
1325
+ var PgCidrBuilder = class extends PgColumnBuilder {
1326
+ static [entityKind] = "PgCidrBuilder";
1327
+ constructor(name) {
1328
+ super(name, "string cidr", "PgCidr");
1329
+ }
1330
+ build(table) {
1331
+ return new PgCidr(table, this.config);
1332
+ }
1333
+ };
1334
+ var PgCidr = class extends PgColumn {
1335
+ static [entityKind] = "PgCidr";
1336
+ codec = "cidr";
1337
+ getSQLType() {
1338
+ return "cidr";
1339
+ }
1340
+ };
1341
+ function cidr(name) {
1342
+ return new PgCidrBuilder(name ?? "");
1343
+ }
1344
+
1345
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/array.js
1346
+ function parsePgArrayValue(arrayString, startFrom, inQuotes) {
1347
+ for (let i = startFrom;i < arrayString.length; i++) {
1348
+ const char2 = arrayString[i];
1349
+ if (char2 === "\\") {
1350
+ i++;
1351
+ continue;
1352
+ }
1353
+ if (char2 === '"')
1354
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
1355
+ if (inQuotes)
1356
+ continue;
1357
+ if (char2 === "," || char2 === "}")
1358
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
1359
+ }
1360
+ return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
1361
+ }
1362
+ function parsePgNestedArray(arrayString, startFrom = 0) {
1363
+ const result = [];
1364
+ let i = startFrom;
1365
+ let lastCharIsComma = false;
1366
+ while (i < arrayString.length) {
1367
+ const char2 = arrayString[i];
1368
+ if (char2 === ",") {
1369
+ if (lastCharIsComma || i === startFrom)
1370
+ result.push("");
1371
+ lastCharIsComma = true;
1372
+ i++;
1373
+ continue;
1374
+ }
1375
+ lastCharIsComma = false;
1376
+ if (char2 === "\\") {
1377
+ i += 2;
1378
+ continue;
1379
+ }
1380
+ if (char2 === '"') {
1381
+ const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
1382
+ result.push(value2);
1383
+ i = startFrom2;
1384
+ continue;
1385
+ }
1386
+ if (char2 === "}")
1387
+ return [result, i + 1];
1388
+ if (char2 === "{") {
1389
+ const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
1390
+ result.push(value2);
1391
+ i = startFrom2;
1392
+ continue;
1393
+ }
1394
+ const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
1395
+ result.push(value);
1396
+ i = newStartFrom;
1397
+ }
1398
+ return [result, i];
1399
+ }
1400
+ function parsePgArray(arrayString) {
1401
+ const [result] = parsePgNestedArray(arrayString, 1);
1402
+ return result;
1403
+ }
1404
+ function makePgArray(array) {
1405
+ return `{${array.map((item) => {
1406
+ if (Array.isArray(item))
1407
+ return makePgArray(item);
1408
+ if (typeof item === "string")
1409
+ return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
1410
+ return `${item}`;
1411
+ }).join(",")}}`;
1412
+ }
1413
+
1414
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
1415
+ function hexToBytes(hex) {
1416
+ const bytes = [];
1417
+ for (let c = 0;c < hex.length; c += 2)
1418
+ bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
1419
+ return new Uint8Array(bytes);
1420
+ }
1421
+ function bytesToFloat64(bytes, offset) {
1422
+ const buffer = /* @__PURE__ */ new ArrayBuffer(8);
1423
+ const view = new DataView(buffer);
1424
+ for (let i = 0;i < 8; i++)
1425
+ view.setUint8(i, bytes[offset + i]);
1426
+ return view.getFloat64(0, true);
1427
+ }
1428
+ function parseEWKB(hex) {
1429
+ const bytes = hexToBytes(hex);
1430
+ let offset = 0;
1431
+ const byteOrder = bytes[offset];
1432
+ offset += 1;
1433
+ const view = new DataView(bytes.buffer);
1434
+ const geomType = view.getUint32(offset, byteOrder === 1);
1435
+ offset += 4;
1436
+ let srid;
1437
+ if (geomType & 536870912) {
1438
+ srid = view.getUint32(offset, byteOrder === 1);
1439
+ offset += 4;
1440
+ }
1441
+ if ((geomType & 65535) === 1) {
1442
+ const x = bytesToFloat64(bytes, offset);
1443
+ offset += 8;
1444
+ const y = bytesToFloat64(bytes, offset);
1445
+ offset += 8;
1446
+ return {
1447
+ srid,
1448
+ point: [x, y]
1449
+ };
1450
+ }
1451
+ throw new Error("Unsupported geometry type");
1452
+ }
1453
+
1454
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/codecs.js
1455
+ var noopCodecs = {};
1456
+ var arrayToItemTypeCodecNameMap = {
1457
+ cast: "cast",
1458
+ castArray: "cast",
1459
+ castInJson: "castInJson",
1460
+ castArrayInJson: "castInJson",
1461
+ castParam: "castParam",
1462
+ castArrayParam: "castParam",
1463
+ normalize: "normalize",
1464
+ normalizeArray: "normalize",
1465
+ normalizeInJson: "normalizeInJson",
1466
+ normalizeArrayInJson: "normalizeInJson",
1467
+ normalizeParam: "normalizeParam",
1468
+ normalizeParamArray: "normalizeParam"
1469
+ };
1470
+ var itemToArrayTypeCodecNameMap = {
1471
+ cast: "castArray",
1472
+ castArray: "castArray",
1473
+ castInJson: "castArrayInJson",
1474
+ castArrayInJson: "castArrayInJson",
1475
+ castParam: "castArrayParam",
1476
+ castArrayParam: "castArrayParam",
1477
+ normalize: "normalizeArray",
1478
+ normalizeArray: "normalizeArray",
1479
+ normalizeInJson: "normalizeArrayInJson",
1480
+ normalizeArrayInJson: "normalizeArrayInJson",
1481
+ normalizeParam: "normalizeParamArray",
1482
+ normalizeParamArray: "normalizeParamArray"
1483
+ };
1484
+ var CodecsCollection = class {
1485
+ static [entityKind] = "CodecsCollection";
1486
+ constructor(resolveTypes, codecs = noopCodecs) {
1487
+ this.resolveTypes = resolveTypes;
1488
+ this.codecs = codecs;
1489
+ }
1490
+ get(column, type) {
1491
+ const sqlType = column.codec;
1492
+ if (!sqlType)
1493
+ return;
1494
+ const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
1495
+ return this.codecs[sqlType]?.[codecType];
1496
+ }
1497
+ apply(column, type, value) {
1498
+ const sqlType = column.codec;
1499
+ if (!sqlType)
1500
+ return value;
1501
+ const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
1502
+ const codec = this.codecs[sqlType]?.[codecType];
1503
+ if (!codec)
1504
+ return value;
1505
+ if (codecType === "castParam" || codecType === "castArrayParam")
1506
+ return codec(value, column, column.dimensions);
1507
+ return codec(value, column.dimensions);
1508
+ }
1509
+ };
1510
+
1511
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/codecs.js
1512
+ var PG_ALIAS_TO_TYPE_MAP = {
1513
+ int2: "smallint",
1514
+ integer: "int",
1515
+ int4: "int",
1516
+ int8: "bigint",
1517
+ decimal: "numeric",
1518
+ real: "float4",
1519
+ double: "float8",
1520
+ "double precision": "float8",
1521
+ serial2: "smallserial",
1522
+ serial4: "serial",
1523
+ serial8: "bigserial",
1524
+ character: "char",
1525
+ "character varying": "varchar",
1526
+ "time with time zone": "timetz",
1527
+ "time without time zone": "time",
1528
+ "timestamp with time zone": "timestamptz",
1529
+ "timestamp without time zone": "timestamp",
1530
+ boolean: "bool",
1531
+ "bit varying": "varbit"
1532
+ };
1533
+ function resolvePgTypeAlias(type) {
1534
+ return PG_ALIAS_TO_TYPE_MAP[type] ?? type;
1535
+ }
1536
+ var castToText = (name) => sql`${name}::text`;
1537
+ var castToTextArr = (name, arrayDimensions) => sql`${name}::text${sql.raw("[]".repeat(arrayDimensions))}`;
1538
+ var arrayCompatCast = (cast) => (name, arrayDimensions) => {
1539
+ if (!arrayDimensions)
1540
+ return cast(name);
1541
+ const aliases = [];
1542
+ for (let i = 0;i < arrayDimensions; i++)
1543
+ aliases.push(sql.identifier(`s${i}`));
1544
+ let indexed = name;
1545
+ for (const alias of aliases)
1546
+ indexed = sql`${indexed}[${alias}]`;
1547
+ let expression = sql`array(\
1548
+ select ${cast(indexed)} \
1549
+ from generate_subscripts(${name}, ${sql.raw(arrayDimensions.toString())}) ${aliases[arrayDimensions - 1]} \
1550
+ order by ${aliases[arrayDimensions - 1]})`;
1551
+ for (let dim = arrayDimensions - 1;dim > 0; dim--)
1552
+ expression = sql`array(\
1553
+ select ${expression} \
1554
+ from generate_subscripts(${name}, ${sql.raw(dim.toString())}) ${aliases[dim - 1]} \
1555
+ order by ${aliases[dim - 1]})`;
1556
+ return sql`case when ${name} is null then null else ${expression} end`;
1557
+ };
1558
+ var arrayCompatNormalize = (normalize) => {
1559
+ const loop = (value, arrayDimensions) => {
1560
+ const innerDimensions = arrayDimensions - 1;
1561
+ if (arrayDimensions > 1)
1562
+ for (let i = 0;i < value.length; ++i)
1563
+ loop(value[i], innerDimensions);
1564
+ else
1565
+ for (let i = 0;i < value.length; ++i)
1566
+ value[i] = normalize(value[i]);
1567
+ return value;
1568
+ };
1569
+ return loop;
1570
+ };
1571
+ var arrayCompatNormalizeInput = (normalize, transformToPgArray = false) => {
1572
+ const loop = (value, arrayDimensions) => {
1573
+ const innerDimensions = arrayDimensions - 1;
1574
+ const out = Array.from({ length: value.length });
1575
+ if (arrayDimensions > 1)
1576
+ for (let i = 0;i < value.length; ++i)
1577
+ out[i] = loop(value[i], innerDimensions);
1578
+ else
1579
+ for (let i = 0;i < value.length; ++i)
1580
+ out[i] = normalize(value[i]);
1581
+ return out;
1582
+ };
1583
+ return transformToPgArray ? (v, d) => makePgArray(loop(v, d)) : loop;
1584
+ };
1585
+ var parsePgArrayAndNormalize = (normalize) => {
1586
+ const codec = arrayCompatNormalize(normalize);
1587
+ return (value, arrayDimensions) => codec(parsePgArray(value), arrayDimensions);
1588
+ };
1589
+ var parseLineTuple = (v) => {
1590
+ const [a, b, c] = v.slice(1, -1).split(",");
1591
+ return [
1592
+ Number.parseFloat(a),
1593
+ Number.parseFloat(b),
1594
+ Number.parseFloat(c)
1595
+ ];
1596
+ };
1597
+ var parseLineABC = (v) => {
1598
+ const [a, b, c] = v.slice(1, -1).split(",");
1599
+ return {
1600
+ a: Number.parseFloat(a),
1601
+ b: Number.parseFloat(b),
1602
+ c: Number.parseFloat(c)
1603
+ };
1604
+ };
1605
+ var parsePointTuple = (v) => {
1606
+ const [x, y] = v.slice(1, -1).split(",");
1607
+ return [Number.parseFloat(x), Number.parseFloat(y)];
1608
+ };
1609
+ var parsePointXY = (v) => {
1610
+ const [x, y] = v.slice(1, -1).split(",");
1611
+ return {
1612
+ x: Number.parseFloat(x),
1613
+ y: Number.parseFloat(y)
1614
+ };
1615
+ };
1616
+ var parseGeometryTuple = (v) => parseEWKB(v).point;
1617
+ var parseGeometryXY = (v) => {
1618
+ const parsed = parseEWKB(v);
1619
+ return {
1620
+ x: parsed.point[0],
1621
+ y: parsed.point[1]
1622
+ };
1623
+ };
1624
+ var textToDate = (v) => new Date(v);
1625
+ var textToDateWithTz = (v) => /* @__PURE__ */ new Date(v + "+0000");
1626
+ var parsePgVector = (v) => {
1627
+ const body = v.slice(1, -1);
1628
+ if (body.length === 0)
1629
+ return [];
1630
+ return body.split(",").map(Number.parseFloat);
1631
+ };
1632
+ var genericPgCodecs = {
1633
+ bytea: {
1634
+ castInJson: (name) => sql`encode(${name}, 'base64')`,
1635
+ castArrayInJson: arrayCompatCast((name) => sql`encode(${name}, 'base64')`),
1636
+ normalizeInJson: (v) => Buffer.from(v, "base64"),
1637
+ normalizeArrayInJson: arrayCompatNormalize((v) => Buffer.from(v, "base64"))
1638
+ },
1639
+ bigint: {
1640
+ castInJson: castToText,
1641
+ castArrayInJson: castToTextArr,
1642
+ normalizeInJson: BigInt,
1643
+ normalizeArrayInJson: arrayCompatNormalize(BigInt)
1644
+ },
1645
+ "bigint:number": {
1646
+ castInJson: castToText,
1647
+ castArrayInJson: castToTextArr,
1648
+ normalize: Number,
1649
+ normalizeArray: arrayCompatNormalize(Number),
1650
+ normalizeInJson: Number,
1651
+ normalizeArrayInJson: arrayCompatNormalize(Number)
1652
+ },
1653
+ "bigint:string": {
1654
+ castInJson: castToText,
1655
+ castArrayInJson: castToTextArr
1656
+ },
1657
+ bigserial: {
1658
+ castInJson: castToText,
1659
+ castArrayInJson: castToTextArr,
1660
+ normalizeInJson: BigInt,
1661
+ normalizeArrayInJson: arrayCompatNormalize(BigInt),
1662
+ normalize: BigInt,
1663
+ normalizeArray: arrayCompatNormalize(BigInt)
1664
+ },
1665
+ "bigserial:number": {
1666
+ castInJson: castToText,
1667
+ castArrayInJson: castToTextArr,
1668
+ normalize: Number,
1669
+ normalizeArray: arrayCompatNormalize(Number),
1670
+ normalizeInJson: Number,
1671
+ normalizeArrayInJson: arrayCompatNormalize(Number)
1672
+ },
1673
+ date: {
1674
+ normalizeInJson: textToDate,
1675
+ normalizeArrayInJson: arrayCompatNormalize(textToDate)
1676
+ },
1677
+ "date:string": {},
1678
+ enum: {
1679
+ castArray: castToTextArr,
1680
+ normalizeParamArray: makePgArray
1681
+ },
1682
+ "geometry(point)": {
1683
+ castInJson: castToText,
1684
+ castArrayInJson: castToTextArr,
1685
+ normalize: parseGeometryXY,
1686
+ normalizeArray: arrayCompatNormalize(parseGeometryXY),
1687
+ normalizeInJson: parseGeometryXY,
1688
+ normalizeArrayInJson: arrayCompatNormalize(parseGeometryXY)
1689
+ },
1690
+ "geometry(point):tuple": {
1691
+ castInJson: castToText,
1692
+ castArrayInJson: castToTextArr,
1693
+ normalize: parseGeometryTuple,
1694
+ normalizeArray: arrayCompatNormalize(parseGeometryTuple),
1695
+ normalizeInJson: parseGeometryTuple,
1696
+ normalizeArrayInJson: arrayCompatNormalize(parseGeometryTuple)
1697
+ },
1698
+ interval: { castArrayInJson: castToTextArr },
1699
+ json: { normalizeParamArray: arrayCompatNormalizeInput((v) => JSON.stringify(v), true) },
1700
+ jsonb: { normalizeParamArray: arrayCompatNormalizeInput((v) => JSON.stringify(v), true) },
1701
+ line: {
1702
+ castInJson: castToText,
1703
+ castArrayInJson: castToTextArr,
1704
+ normalize: parseLineABC,
1705
+ normalizeArray: arrayCompatNormalize(parseLineABC),
1706
+ normalizeInJson: parseLineABC,
1707
+ normalizeArrayInJson: arrayCompatNormalize(parseLineABC)
1708
+ },
1709
+ "line:tuple": {
1710
+ castInJson: castToText,
1711
+ castArrayInJson: castToTextArr,
1712
+ normalize: parseLineTuple,
1713
+ normalizeArray: arrayCompatNormalize(parseLineTuple),
1714
+ normalizeInJson: parseLineTuple,
1715
+ normalizeArrayInJson: arrayCompatNormalize(parseLineTuple)
1716
+ },
1717
+ numeric: {
1718
+ castInJson: castToText,
1719
+ castArrayInJson: castToTextArr,
1720
+ castArray: castToTextArr
1721
+ },
1722
+ "numeric:number": {
1723
+ castInJson: castToText,
1724
+ castArrayInJson: castToTextArr,
1725
+ castArray: castToTextArr,
1726
+ normalize: Number,
1727
+ normalizeArray: arrayCompatNormalize(Number),
1728
+ normalizeInJson: Number,
1729
+ normalizeArrayInJson: arrayCompatNormalize(Number)
1730
+ },
1731
+ "numeric:bigint": {
1732
+ castInJson: castToText,
1733
+ castArrayInJson: castToTextArr,
1734
+ castArray: castToTextArr,
1735
+ normalize: BigInt,
1736
+ normalizeArray: arrayCompatNormalize(BigInt),
1737
+ normalizeInJson: BigInt,
1738
+ normalizeArrayInJson: arrayCompatNormalize(BigInt)
1739
+ },
1740
+ point: {
1741
+ castInJson: castToText,
1742
+ castArrayInJson: castToTextArr,
1743
+ normalize: parsePointXY,
1744
+ normalizeArray: arrayCompatNormalize(parsePointXY),
1745
+ normalizeInJson: parsePointXY,
1746
+ normalizeArrayInJson: arrayCompatNormalize(parsePointXY)
1747
+ },
1748
+ "point:tuple": {
1749
+ castInJson: castToText,
1750
+ castArrayInJson: castToTextArr,
1751
+ normalize: parsePointTuple,
1752
+ normalizeArray: arrayCompatNormalize(parsePointTuple),
1753
+ normalizeInJson: parsePointTuple,
1754
+ normalizeArrayInJson: arrayCompatNormalize(parsePointTuple)
1755
+ },
1756
+ timestamp: {
1757
+ castInJson: castToText,
1758
+ castArrayInJson: castToTextArr,
1759
+ normalizeInJson: textToDateWithTz,
1760
+ normalizeArrayInJson: arrayCompatNormalize(textToDateWithTz)
1761
+ },
1762
+ timestamptz: {
1763
+ castInJson: castToText,
1764
+ castArrayInJson: castToTextArr,
1765
+ normalizeInJson: textToDate,
1766
+ normalizeArrayInJson: arrayCompatNormalize(textToDate)
1767
+ },
1768
+ "timestamp:string": {
1769
+ castInJson: castToText,
1770
+ castArrayInJson: castToTextArr
1771
+ },
1772
+ "timestamptz:string": {
1773
+ castInJson: castToText,
1774
+ castArrayInJson: castToTextArr
1775
+ },
1776
+ halfvec: {
1777
+ normalize: parsePgVector,
1778
+ normalizeArray: parsePgArrayAndNormalize(parsePgVector),
1779
+ normalizeInJson: parsePgVector,
1780
+ normalizeArrayInJson: arrayCompatNormalize(parsePgVector)
1781
+ },
1782
+ vector: {
1783
+ normalize: parsePgVector,
1784
+ normalizeArray: parsePgArrayAndNormalize(parsePgVector),
1785
+ normalizeInJson: parsePgVector,
1786
+ normalizeArrayInJson: arrayCompatNormalize(parsePgVector)
1787
+ }
1788
+ };
1789
+
1790
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/custom.js
1791
+ var PgCustomColumnBuilder = class extends PgColumnBuilder {
1792
+ static [entityKind] = "PgCustomColumnBuilder";
1793
+ constructor(name, fieldConfig, customTypeParams) {
1794
+ super(name, "custom", "PgCustomColumn");
1795
+ this.config.fieldConfig = fieldConfig;
1796
+ this.config.customTypeParams = customTypeParams;
1797
+ }
1798
+ build(table) {
1799
+ return new PgCustomColumn(table, this.config);
1800
+ }
1801
+ };
1802
+ var PgCustomColumn = class extends PgColumn {
1803
+ static [entityKind] = "PgCustomColumn";
1804
+ codec;
1805
+ sqlName;
1806
+ mapFromJsonValue;
1807
+ jsonSelectIdentifier;
1808
+ constructor(table, config) {
1809
+ super(table, config);
1810
+ this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
1811
+ this.mapToDriverValue = config.customTypeParams.toDriver ?? this.mapToDriverValue;
1812
+ this.mapFromDriverValue = config.customTypeParams.fromDriver ?? this.mapFromDriverValue;
1813
+ this.mapFromJsonValue = config.customTypeParams.fromJson;
1814
+ this.jsonSelectIdentifier = config.customTypeParams.forJsonSelect;
1815
+ const cfgCodec = typeof config.customTypeParams.codec === "string" || typeof config.customTypeParams.codec === "undefined" ? config.customTypeParams.codec : config.customTypeParams.codec(config.fieldConfig);
1816
+ this.codec = typeof cfgCodec === "string" ? resolvePgTypeAlias(cfgCodec) : undefined;
1817
+ if (this.dimensions && config.customTypeParams.fromJson)
1818
+ this.mapFromJsonValue = (value) => {
1819
+ if (value === null)
1820
+ return value;
1821
+ const arr = typeof value === "string" ? parsePgArray(value) : value;
1822
+ return this.mapJsonArrayElements(arr, config.customTypeParams.fromJson, this.dimensions);
1823
+ };
1824
+ }
1825
+ mapJsonArrayElements(value, mapper, depth) {
1826
+ if (depth > 0 && Array.isArray(value))
1827
+ return value.map((v) => v === null ? null : this.mapJsonArrayElements(v, mapper, depth - 1));
1828
+ return mapper(value);
1829
+ }
1830
+ getSQLType() {
1831
+ return this.sqlName;
1832
+ }
1833
+ };
1834
+ function customType(customTypeParams) {
1835
+ return (a, b) => {
1836
+ const { name, config } = getColumnNameAndConfig(a, b);
1837
+ return new PgCustomColumnBuilder(name, config, customTypeParams);
1838
+ };
1839
+ }
1840
+
1841
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/date.common.js
1842
+ var PgDateColumnBuilder = class extends PgColumnBuilder {
1843
+ static [entityKind] = "PgDateColumnBaseBuilder";
1844
+ defaultNow() {
1845
+ return this.default(sql`now()`);
1846
+ }
1847
+ };
1848
+
1849
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/date.js
1850
+ var PgDateBuilder = class extends PgDateColumnBuilder {
1851
+ static [entityKind] = "PgDateBuilder";
1852
+ constructor(name) {
1853
+ super(name, "object date", "PgDate");
1854
+ }
1855
+ build(table) {
1856
+ return new PgDate(table, this.config);
1857
+ }
1858
+ };
1859
+ var PgDate = class extends PgColumn {
1860
+ static [entityKind] = "PgDate";
1861
+ codec = "date";
1862
+ getSQLType() {
1863
+ return "date";
1864
+ }
1865
+ mapToDriverValue = function(value) {
1866
+ if (typeof value === "string")
1867
+ return value;
1868
+ return value.toISOString();
1869
+ };
1870
+ };
1871
+ var PgDateStringBuilder = class extends PgDateColumnBuilder {
1872
+ static [entityKind] = "PgDateStringBuilder";
1873
+ constructor(name) {
1874
+ super(name, "string date", "PgDateString");
1875
+ }
1876
+ build(table) {
1877
+ return new PgDateString(table, this.config);
1878
+ }
1879
+ };
1880
+ var PgDateString = class extends PgColumn {
1881
+ static [entityKind] = "PgDateString";
1882
+ codec = "date:string";
1883
+ getSQLType() {
1884
+ return "date";
1885
+ }
1886
+ mapToDriverValue = (value) => {
1887
+ if (typeof value === "string")
1888
+ return value;
1889
+ return value.toISOString();
1890
+ };
1891
+ };
1892
+ function date(a, b) {
1893
+ const { name, config } = getColumnNameAndConfig(a, b);
1894
+ if (config?.mode === "date")
1895
+ return new PgDateBuilder(name);
1896
+ return new PgDateStringBuilder(name);
1897
+ }
1898
+
1899
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/double-precision.js
1900
+ var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
1901
+ static [entityKind] = "PgDoublePrecisionBuilder";
1902
+ constructor(name) {
1903
+ super(name, "number double", "PgDoublePrecision");
1904
+ }
1905
+ build(table) {
1906
+ return new PgDoublePrecision(table, this.config);
1907
+ }
1908
+ };
1909
+ var PgDoublePrecision = class extends PgColumn {
1910
+ static [entityKind] = "PgDoublePrecision";
1911
+ codec = "float8";
1912
+ getSQLType() {
1913
+ return "double precision";
1914
+ }
1915
+ };
1916
+ function doublePrecision(name) {
1917
+ return new PgDoublePrecisionBuilder(name ?? "");
1918
+ }
1919
+
1920
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/inet.js
1921
+ var PgInetBuilder = class extends PgColumnBuilder {
1922
+ static [entityKind] = "PgInetBuilder";
1923
+ constructor(name) {
1924
+ super(name, "string inet", "PgInet");
1925
+ }
1926
+ build(table) {
1927
+ return new PgInet(table, this.config);
1928
+ }
1929
+ };
1930
+ var PgInet = class extends PgColumn {
1931
+ static [entityKind] = "PgInet";
1932
+ codec = "inet";
1933
+ getSQLType() {
1934
+ return "inet";
1935
+ }
1936
+ };
1937
+ function inet(name) {
1938
+ return new PgInetBuilder(name ?? "");
1939
+ }
1940
+
1941
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/integer.js
1942
+ var PgIntegerBuilder = class extends PgIntColumnBuilder {
1943
+ static [entityKind] = "PgIntegerBuilder";
1944
+ constructor(name) {
1945
+ super(name, "number int32", "PgInteger");
1946
+ }
1947
+ build(table) {
1948
+ return new PgInteger(table, this.config);
1949
+ }
1950
+ };
1951
+ var PgInteger = class extends PgColumn {
1952
+ static [entityKind] = "PgInteger";
1953
+ codec = "int";
1954
+ getSQLType() {
1955
+ return "integer";
1956
+ }
1957
+ };
1958
+ function integer(name) {
1959
+ return new PgIntegerBuilder(name ?? "");
1960
+ }
1961
+
1962
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/interval.js
1963
+ var PgIntervalBuilder = class extends PgColumnBuilder {
1964
+ static [entityKind] = "PgIntervalBuilder";
1965
+ constructor(name, intervalConfig) {
1966
+ super(name, "string interval", "PgInterval");
1967
+ this.config.intervalConfig = intervalConfig;
1968
+ }
1969
+ build(table) {
1970
+ return new PgInterval(table, this.config);
1971
+ }
1972
+ };
1973
+ var PgInterval = class extends PgColumn {
1974
+ static [entityKind] = "PgInterval";
1975
+ codec = "interval";
1976
+ fields;
1977
+ precision;
1978
+ constructor(table, config) {
1979
+ super(table, config);
1980
+ this.fields = config.intervalConfig.fields;
1981
+ this.precision = config.intervalConfig.precision;
1982
+ }
1983
+ getSQLType() {
1984
+ return `interval${this.fields ? ` ${this.fields}` : ""}${this.precision ? `(${this.precision})` : ""}`;
1985
+ }
1986
+ };
1987
+ function interval(a, b = {}) {
1988
+ const { name, config } = getColumnNameAndConfig(a, b);
1989
+ return new PgIntervalBuilder(name, config);
1990
+ }
1991
+
1992
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/json.js
1993
+ var PgJsonBuilder = class extends PgColumnBuilder {
1994
+ static [entityKind] = "PgJsonBuilder";
1995
+ constructor(name) {
1996
+ super(name, "object json", "PgJson");
1997
+ }
1998
+ build(table) {
1999
+ return new PgJson(table, this.config);
2000
+ }
2001
+ };
2002
+ var PgJson = class extends PgColumn {
2003
+ static [entityKind] = "PgJson";
2004
+ codec = "json";
2005
+ constructor(table, config) {
2006
+ super(table, config);
2007
+ }
2008
+ getSQLType() {
2009
+ return "json";
2010
+ }
2011
+ };
2012
+ function json(name) {
2013
+ return new PgJsonBuilder(name ?? "");
2014
+ }
2015
+
2016
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/jsonb.js
2017
+ var PgJsonbBuilder = class extends PgColumnBuilder {
2018
+ static [entityKind] = "PgJsonbBuilder";
2019
+ constructor(name) {
2020
+ super(name, "object json", "PgJsonb");
2021
+ }
2022
+ build(table) {
2023
+ return new PgJsonb(table, this.config);
2024
+ }
2025
+ };
2026
+ var PgJsonb = class extends PgColumn {
2027
+ static [entityKind] = "PgJsonb";
2028
+ codec = "jsonb";
2029
+ constructor(table, config) {
2030
+ super(table, config);
2031
+ }
2032
+ getSQLType() {
2033
+ return "jsonb";
2034
+ }
2035
+ };
2036
+ function jsonb(name) {
2037
+ return new PgJsonbBuilder(name ?? "");
2038
+ }
2039
+
2040
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/line.js
2041
+ var PgLineBuilder = class extends PgColumnBuilder {
2042
+ static [entityKind] = "PgLineBuilder";
2043
+ constructor(name) {
2044
+ super(name, "array line", "PgLine");
2045
+ }
2046
+ build(table) {
2047
+ return new PgLineTuple(table, this.config);
2048
+ }
2049
+ };
2050
+ var PgLineTuple = class extends PgColumn {
2051
+ static [entityKind] = "PgLine";
2052
+ codec = "line:tuple";
2053
+ mode = "tuple";
2054
+ getSQLType() {
2055
+ return "line";
2056
+ }
2057
+ mapToDriverValue = (value) => {
2058
+ return `{${value[0]},${value[1]},${value[2]}}`;
2059
+ };
2060
+ };
2061
+ var PgLineABCBuilder = class extends PgColumnBuilder {
2062
+ static [entityKind] = "PgLineABCBuilder";
2063
+ constructor(name) {
2064
+ super(name, "object line", "PgLineABC");
2065
+ }
2066
+ build(table) {
2067
+ return new PgLineABC(table, this.config);
2068
+ }
2069
+ };
2070
+ var PgLineABC = class extends PgColumn {
2071
+ static [entityKind] = "PgLineABC";
2072
+ codec = "line";
2073
+ mode = "abc";
2074
+ getSQLType() {
2075
+ return "line";
2076
+ }
2077
+ mapToDriverValue = (value) => {
2078
+ return `{${value.a},${value.b},${value.c}}`;
2079
+ };
2080
+ };
2081
+ function line(a, b) {
2082
+ const { name, config } = getColumnNameAndConfig(a, b);
2083
+ if (!config?.mode || config.mode === "tuple")
2084
+ return new PgLineBuilder(name);
2085
+ return new PgLineABCBuilder(name);
2086
+ }
2087
+
2088
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/macaddr.js
2089
+ var PgMacaddrBuilder = class extends PgColumnBuilder {
2090
+ static [entityKind] = "PgMacaddrBuilder";
2091
+ constructor(name) {
2092
+ super(name, "string macaddr", "PgMacaddr");
2093
+ }
2094
+ build(table) {
2095
+ return new PgMacaddr(table, this.config);
2096
+ }
2097
+ };
2098
+ var PgMacaddr = class extends PgColumn {
2099
+ static [entityKind] = "PgMacaddr";
2100
+ codec = "macaddr";
2101
+ getSQLType() {
2102
+ return "macaddr";
2103
+ }
2104
+ };
2105
+ function macaddr(name) {
2106
+ return new PgMacaddrBuilder(name ?? "");
2107
+ }
2108
+
2109
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/macaddr8.js
2110
+ var PgMacaddr8Builder = class extends PgColumnBuilder {
2111
+ static [entityKind] = "PgMacaddr8Builder";
2112
+ constructor(name) {
2113
+ super(name, "string macaddr8", "PgMacaddr8");
2114
+ }
2115
+ build(table) {
2116
+ return new PgMacaddr8(table, this.config);
2117
+ }
2118
+ };
2119
+ var PgMacaddr8 = class extends PgColumn {
2120
+ static [entityKind] = "PgMacaddr8";
2121
+ codec = "macaddr8";
2122
+ getSQLType() {
2123
+ return "macaddr8";
2124
+ }
2125
+ };
2126
+ function macaddr8(name) {
2127
+ return new PgMacaddr8Builder(name ?? "");
2128
+ }
2129
+
2130
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/numeric.js
2131
+ var PgNumericBuilder = class extends PgColumnBuilder {
2132
+ static [entityKind] = "PgNumericBuilder";
2133
+ constructor(name, precision, scale) {
2134
+ super(name, "string numeric", "PgNumeric");
2135
+ this.config.precision = precision;
2136
+ this.config.scale = scale;
2137
+ }
2138
+ build(table) {
2139
+ return new PgNumeric(table, this.config);
2140
+ }
2141
+ };
2142
+ var PgNumeric = class extends PgColumn {
2143
+ static [entityKind] = "PgNumeric";
2144
+ codec = "numeric";
2145
+ precision;
2146
+ scale;
2147
+ constructor(table, config) {
2148
+ super(table, config);
2149
+ this.precision = config.precision;
2150
+ this.scale = config.scale;
2151
+ }
2152
+ getSQLType() {
2153
+ if (this.precision !== undefined && this.scale !== undefined)
2154
+ return `numeric(${this.precision}, ${this.scale})`;
2155
+ else if (this.precision === undefined)
2156
+ return "numeric";
2157
+ else
2158
+ return `numeric(${this.precision})`;
2159
+ }
2160
+ };
2161
+ var PgNumericNumberBuilder = class extends PgColumnBuilder {
2162
+ static [entityKind] = "PgNumericNumberBuilder";
2163
+ constructor(name, precision, scale) {
2164
+ super(name, "number", "PgNumericNumber");
2165
+ this.config.precision = precision;
2166
+ this.config.scale = scale;
2167
+ }
2168
+ build(table) {
2169
+ return new PgNumericNumber(table, this.config);
2170
+ }
2171
+ };
2172
+ var PgNumericNumber = class extends PgColumn {
2173
+ static [entityKind] = "PgNumericNumber";
2174
+ codec = "numeric:number";
2175
+ precision;
2176
+ scale;
2177
+ constructor(table, config) {
2178
+ super(table, config);
2179
+ this.precision = config.precision;
2180
+ this.scale = config.scale;
2181
+ }
2182
+ mapToDriverValue = String;
2183
+ getSQLType() {
2184
+ if (this.precision !== undefined && this.scale !== undefined)
2185
+ return `numeric(${this.precision}, ${this.scale})`;
2186
+ else if (this.precision === undefined)
2187
+ return "numeric";
2188
+ else
2189
+ return `numeric(${this.precision})`;
2190
+ }
2191
+ };
2192
+ var PgNumericBigIntBuilder = class extends PgColumnBuilder {
2193
+ static [entityKind] = "PgNumericBigIntBuilder";
2194
+ constructor(name, precision, scale) {
2195
+ super(name, "bigint int64", "PgNumericBigInt");
2196
+ this.config.precision = precision;
2197
+ this.config.scale = scale;
2198
+ }
2199
+ build(table) {
2200
+ return new PgNumericBigInt(table, this.config);
2201
+ }
2202
+ };
2203
+ var PgNumericBigInt = class extends PgColumn {
2204
+ static [entityKind] = "PgNumericBigInt";
2205
+ codec = "numeric:bigint";
2206
+ precision;
2207
+ scale;
2208
+ constructor(table, config) {
2209
+ super(table, config);
2210
+ this.precision = config.precision;
2211
+ this.scale = config.scale;
2212
+ }
2213
+ mapToDriverValue = String;
2214
+ getSQLType() {
2215
+ if (this.precision !== undefined && this.scale !== undefined)
2216
+ return `numeric(${this.precision}, ${this.scale})`;
2217
+ else if (this.precision === undefined)
2218
+ return "numeric";
2219
+ else
2220
+ return `numeric(${this.precision})`;
2221
+ }
2222
+ };
2223
+ function numeric(a, b) {
2224
+ const { name, config } = getColumnNameAndConfig(a, b);
2225
+ const mode = config?.mode;
2226
+ 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);
2227
+ }
2228
+
2229
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/point.js
2230
+ var PgPointTupleBuilder = class extends PgColumnBuilder {
2231
+ static [entityKind] = "PgPointTupleBuilder";
2232
+ constructor(name) {
2233
+ super(name, "array point", "PgPointTuple");
2234
+ }
2235
+ build(table) {
2236
+ return new PgPointTuple(table, this.config);
2237
+ }
2238
+ };
2239
+ var PgPointTuple = class extends PgColumn {
2240
+ static [entityKind] = "PgPointTuple";
2241
+ codec = "point:tuple";
2242
+ mode = "tuple";
2243
+ getSQLType() {
2244
+ return "point";
2245
+ }
2246
+ mapToDriverValue = (value) => {
2247
+ return `(${value[0]},${value[1]})`;
2248
+ };
2249
+ };
2250
+ var PgPointObjectBuilder = class extends PgColumnBuilder {
2251
+ static [entityKind] = "PgPointObjectBuilder";
2252
+ constructor(name) {
2253
+ super(name, "object point", "PgPointObject");
2254
+ }
2255
+ build(table) {
2256
+ return new PgPointObject(table, this.config);
2257
+ }
2258
+ };
2259
+ var PgPointObject = class extends PgColumn {
2260
+ static [entityKind] = "PgPointObject";
2261
+ codec = "point";
2262
+ mode = "xy";
2263
+ getSQLType() {
2264
+ return "point";
2265
+ }
2266
+ mapToDriverValue = (value) => {
2267
+ return `(${value.x},${value.y})`;
2268
+ };
2269
+ };
2270
+ function point(a, b) {
2271
+ const { name, config } = getColumnNameAndConfig(a, b);
2272
+ if (!config?.mode || config.mode === "tuple")
2273
+ return new PgPointTupleBuilder(name);
2274
+ return new PgPointObjectBuilder(name);
2275
+ }
2276
+
2277
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
2278
+ var PgGeometryBuilder = class extends PgColumnBuilder {
2279
+ static [entityKind] = "PgGeometryBuilder";
2280
+ constructor(name, srid) {
2281
+ super(name, "array geometry", "PgGeometry");
2282
+ this.config.srid = srid;
2283
+ }
2284
+ build(table) {
2285
+ return new PgGeometry(table, this.config);
2286
+ }
2287
+ };
2288
+ var PgGeometry = class extends PgColumn {
2289
+ static [entityKind] = "PgGeometry";
2290
+ codec = "geometry(point):tuple";
2291
+ srid = this.config.srid;
2292
+ mode = "tuple";
2293
+ getSQLType() {
2294
+ return `geometry(point${this.srid === undefined ? "" : `,${this.srid}`})`;
2295
+ }
2296
+ mapToDriverValue = (value) => {
2297
+ return `point(${value[0]} ${value[1]})`;
2298
+ };
2299
+ };
2300
+ var PgGeometryObjectBuilder = class extends PgColumnBuilder {
2301
+ static [entityKind] = "PgGeometryObjectBuilder";
2302
+ constructor(name, srid) {
2303
+ super(name, "object geometry", "PgGeometryObject");
2304
+ this.config.srid = srid;
2305
+ }
2306
+ build(table) {
2307
+ return new PgGeometryObject(table, this.config);
2308
+ }
2309
+ };
2310
+ var PgGeometryObject = class extends PgColumn {
2311
+ static [entityKind] = "PgGeometryObject";
2312
+ codec = "geometry(point)";
2313
+ srid = this.config.srid;
2314
+ mode = "object";
2315
+ getSQLType() {
2316
+ return `geometry(point${this.srid === undefined ? "" : `,${this.srid}`})`;
2317
+ }
2318
+ mapToDriverValue = (value) => {
2319
+ return `point(${value.x} ${value.y})`;
2320
+ };
2321
+ };
2322
+ function geometry(a, b) {
2323
+ const { name, config } = getColumnNameAndConfig(a, b);
2324
+ if (!config?.mode || config.mode === "tuple")
2325
+ return new PgGeometryBuilder(name, config?.srid);
2326
+ return new PgGeometryObjectBuilder(name, config?.srid);
2327
+ }
2328
+
2329
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/real.js
2330
+ var PgRealBuilder = class extends PgColumnBuilder {
2331
+ static [entityKind] = "PgRealBuilder";
2332
+ constructor(name, length) {
2333
+ super(name, "number float", "PgReal");
2334
+ this.config.length = length;
2335
+ }
2336
+ build(table) {
2337
+ return new PgReal(table, this.config);
2338
+ }
2339
+ };
2340
+ var PgReal = class extends PgColumn {
2341
+ static [entityKind] = "PgReal";
2342
+ codec = "float4";
2343
+ constructor(table, config) {
2344
+ super(table, config);
2345
+ }
2346
+ getSQLType() {
2347
+ return "real";
2348
+ }
2349
+ };
2350
+ function real(name) {
2351
+ return new PgRealBuilder(name ?? "");
2352
+ }
2353
+
2354
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/serial.js
2355
+ var PgSerialBuilder = class extends PgColumnBuilder {
2356
+ static [entityKind] = "PgSerialBuilder";
2357
+ constructor(name) {
2358
+ super(name, "number int32", "PgSerial");
2359
+ this.config.hasDefault = true;
2360
+ this.config.notNull = true;
2361
+ }
2362
+ build(table) {
2363
+ return new PgSerial(table, this.config);
2364
+ }
2365
+ };
2366
+ var PgSerial = class extends PgColumn {
2367
+ static [entityKind] = "PgSerial";
2368
+ codec = "serial";
2369
+ getSQLType() {
2370
+ return "serial";
2371
+ }
2372
+ };
2373
+ function serial(name) {
2374
+ return new PgSerialBuilder(name ?? "");
2375
+ }
2376
+
2377
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/smallint.js
2378
+ var PgSmallIntBuilder = class extends PgIntColumnBuilder {
2379
+ static [entityKind] = "PgSmallIntBuilder";
2380
+ constructor(name) {
2381
+ super(name, "number int16", "PgSmallInt");
2382
+ }
2383
+ build(table) {
2384
+ return new PgSmallInt(table, this.config);
2385
+ }
2386
+ };
2387
+ var PgSmallInt = class extends PgColumn {
2388
+ static [entityKind] = "PgSmallInt";
2389
+ codec = "smallint";
2390
+ getSQLType() {
2391
+ return "smallint";
2392
+ }
2393
+ };
2394
+ function smallint(name) {
2395
+ return new PgSmallIntBuilder(name ?? "");
2396
+ }
2397
+
2398
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/smallserial.js
2399
+ var PgSmallSerialBuilder = class extends PgColumnBuilder {
2400
+ static [entityKind] = "PgSmallSerialBuilder";
2401
+ constructor(name) {
2402
+ super(name, "number int16", "PgSmallSerial");
2403
+ this.config.hasDefault = true;
2404
+ this.config.notNull = true;
2405
+ }
2406
+ build(table) {
2407
+ return new PgSmallSerial(table, this.config);
2408
+ }
2409
+ };
2410
+ var PgSmallSerial = class extends PgColumn {
2411
+ static [entityKind] = "PgSmallSerial";
2412
+ codec = "smallserial";
2413
+ getSQLType() {
2414
+ return "smallserial";
2415
+ }
2416
+ };
2417
+ function smallserial(name) {
2418
+ return new PgSmallSerialBuilder(name ?? "");
2419
+ }
2420
+
2421
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/text.js
2422
+ var PgTextBuilder = class extends PgColumnBuilder {
2423
+ static [entityKind] = "PgTextBuilder";
2424
+ constructor(name, config) {
2425
+ super(name, config.enum?.length ? "string enum" : "string", "PgText");
2426
+ this.config.enumValues = config.enum;
2427
+ }
2428
+ build(table) {
2429
+ return new PgText(table, this.config, this.config.enumValues);
2430
+ }
2431
+ };
2432
+ var PgText = class extends PgColumn {
2433
+ static [entityKind] = "PgText";
2434
+ enumValues;
2435
+ codec = "text";
2436
+ constructor(table, config, enumValues) {
2437
+ super(table, config);
2438
+ this.enumValues = enumValues;
2439
+ }
2440
+ getSQLType() {
2441
+ return "text";
2442
+ }
2443
+ };
2444
+ function text(a, b = {}) {
2445
+ const { name, config } = getColumnNameAndConfig(a, b);
2446
+ return new PgTextBuilder(name, config);
2447
+ }
2448
+
2449
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/time.js
2450
+ var PgTimeBuilder = class extends PgDateColumnBuilder {
2451
+ static [entityKind] = "PgTimeBuilder";
2452
+ constructor(name, withTimezone, precision) {
2453
+ super(name, "string time", "PgTime");
2454
+ this.withTimezone = withTimezone;
2455
+ this.precision = precision;
2456
+ this.config.withTimezone = withTimezone;
2457
+ this.config.precision = precision;
2458
+ }
2459
+ build(table) {
2460
+ return new PgTime(table, this.config);
2461
+ }
2462
+ };
2463
+ var PgTime = class extends PgColumn {
2464
+ static [entityKind] = "PgTime";
2465
+ codec = "time";
2466
+ withTimezone;
2467
+ precision;
2468
+ constructor(table, config) {
2469
+ super(table, config);
2470
+ this.withTimezone = config.withTimezone;
2471
+ this.precision = config.precision;
2472
+ }
2473
+ getSQLType() {
2474
+ return `time${this.precision === undefined ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
2475
+ }
2476
+ };
2477
+ function time(a, b = {}) {
2478
+ const { name, config } = getColumnNameAndConfig(a, b);
2479
+ return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
2480
+ }
2481
+
2482
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/timestamp.js
2483
+ var PgTimestampBuilder = class extends PgDateColumnBuilder {
2484
+ static [entityKind] = "PgTimestampBuilder";
2485
+ constructor(name, withTimezone, precision) {
2486
+ super(name, "object date", "PgTimestamp");
2487
+ this.config.withTimezone = withTimezone;
2488
+ this.config.precision = precision;
2489
+ }
2490
+ build(table) {
2491
+ return new PgTimestamp(table, this.config);
2492
+ }
2493
+ };
2494
+ var PgTimestamp = class extends PgColumn {
2495
+ static [entityKind] = "PgTimestamp";
2496
+ codec;
2497
+ withTimezone;
2498
+ precision;
2499
+ constructor(table, config) {
2500
+ super(table, config);
2501
+ this.withTimezone = config.withTimezone;
2502
+ this.precision = config.precision;
2503
+ this.codec = this.withTimezone ? "timestamptz" : "timestamp";
2504
+ }
2505
+ getSQLType() {
2506
+ return `timestamp${this.precision === undefined ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
2507
+ }
2508
+ mapToDriverValue = (value) => {
2509
+ if (typeof value === "string")
2510
+ return value;
2511
+ return value.toISOString();
2512
+ };
2513
+ };
2514
+ var PgTimestampStringBuilder = class extends PgDateColumnBuilder {
2515
+ static [entityKind] = "PgTimestampStringBuilder";
2516
+ constructor(name, withTimezone, precision) {
2517
+ super(name, "string timestamp", "PgTimestampString");
2518
+ this.config.withTimezone = withTimezone;
2519
+ this.config.precision = precision;
2520
+ }
2521
+ build(table) {
2522
+ return new PgTimestampString(table, this.config);
2523
+ }
2524
+ };
2525
+ var PgTimestampString = class extends PgColumn {
2526
+ static [entityKind] = "PgTimestampString";
2527
+ codec;
2528
+ withTimezone;
2529
+ precision;
2530
+ constructor(table, config) {
2531
+ super(table, config);
2532
+ this.withTimezone = config.withTimezone;
2533
+ this.precision = config.precision;
2534
+ this.codec = this.withTimezone ? "timestamptz:string" : "timestamp:string";
2535
+ }
2536
+ getSQLType() {
2537
+ return `timestamp${this.precision === undefined ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
2538
+ }
2539
+ mapToDriverValue = (value) => {
2540
+ if (typeof value === "string")
2541
+ return value;
2542
+ return value.toISOString();
2543
+ };
2544
+ };
2545
+ function timestamp(a, b = {}) {
2546
+ const { name, config } = getColumnNameAndConfig(a, b);
2547
+ if (config?.mode === "string")
2548
+ return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
2549
+ return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
2550
+ }
2551
+
2552
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/uuid.js
2553
+ var PgUUIDBuilder = class extends PgColumnBuilder {
2554
+ static [entityKind] = "PgUUIDBuilder";
2555
+ constructor(name) {
2556
+ super(name, "string uuid", "PgUUID");
2557
+ }
2558
+ defaultRandom() {
2559
+ return this.default(sql`gen_random_uuid()`);
2560
+ }
2561
+ build(table) {
2562
+ return new PgUUID(table, this.config);
2563
+ }
2564
+ };
2565
+ var PgUUID = class extends PgColumn {
2566
+ static [entityKind] = "PgUUID";
2567
+ codec = "uuid";
2568
+ getSQLType() {
2569
+ return "uuid";
2570
+ }
2571
+ };
2572
+ function uuid(name) {
2573
+ return new PgUUIDBuilder(name ?? "");
2574
+ }
2575
+
2576
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/varchar.js
2577
+ var PgVarcharBuilder = class extends PgColumnBuilder {
2578
+ static [entityKind] = "PgVarcharBuilder";
2579
+ constructor(name, config) {
2580
+ super(name, config.enum?.length ? "string enum" : "string", "PgVarchar");
2581
+ this.config.length = config.length;
2582
+ this.config.enumValues = config.enum;
2583
+ }
2584
+ build(table) {
2585
+ return new PgVarchar(table, this.config);
2586
+ }
2587
+ };
2588
+ var PgVarchar = class extends PgColumn {
2589
+ static [entityKind] = "PgVarchar";
2590
+ codec = "varchar";
2591
+ enumValues;
2592
+ constructor(table, config) {
2593
+ super(table, config);
2594
+ this.enumValues = config.enumValues;
2595
+ }
2596
+ getSQLType() {
2597
+ return this.length === undefined ? `varchar` : `varchar(${this.length})`;
2598
+ }
2599
+ };
2600
+ function varchar(a, b = {}) {
2601
+ const { name, config } = getColumnNameAndConfig(a, b);
2602
+ return new PgVarcharBuilder(name, config);
2603
+ }
2604
+
2605
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
2606
+ var PgBinaryVectorBuilder = class extends PgColumnBuilder {
2607
+ static [entityKind] = "PgBinaryVectorBuilder";
2608
+ constructor(name, config) {
2609
+ super(name, "string binary", "PgBinaryVector");
2610
+ this.config.length = config.dimensions;
2611
+ this.config.isLengthExact = true;
2612
+ }
2613
+ build(table) {
2614
+ return new PgBinaryVector(table, this.config);
2615
+ }
2616
+ };
2617
+ var PgBinaryVector = class extends PgColumn {
2618
+ static [entityKind] = "PgBinaryVector";
2619
+ codec = "bit";
2620
+ getSQLType() {
2621
+ return `bit(${this.length})`;
2622
+ }
2623
+ };
2624
+ function bit(a, b) {
2625
+ const { name, config } = getColumnNameAndConfig(a, b);
2626
+ return new PgBinaryVectorBuilder(name, config);
2627
+ }
2628
+
2629
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
2630
+ var PgHalfVectorBuilder = class extends PgColumnBuilder {
2631
+ static [entityKind] = "PgHalfVectorBuilder";
2632
+ constructor(name, config) {
2633
+ super(name, "array halfvector", "PgHalfVector");
2634
+ this.config.length = config.dimensions;
2635
+ this.config.isLengthExact = true;
2636
+ }
2637
+ build(table) {
2638
+ return new PgHalfVector(table, this.config);
2639
+ }
2640
+ };
2641
+ var PgHalfVector = class extends PgColumn {
2642
+ static [entityKind] = "PgHalfVector";
2643
+ codec = "halfvec";
2644
+ getSQLType() {
2645
+ return `halfvec(${this.length})`;
2646
+ }
2647
+ mapToDriverValue = (value) => {
2648
+ return JSON.stringify(value);
2649
+ };
2650
+ };
2651
+ function halfvec(a, b) {
2652
+ const { name, config } = getColumnNameAndConfig(a, b);
2653
+ return new PgHalfVectorBuilder(name, config);
2654
+ }
2655
+
2656
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
2657
+ var PgSparseVectorBuilder = class extends PgColumnBuilder {
2658
+ static [entityKind] = "PgSparseVectorBuilder";
2659
+ constructor(name, config) {
2660
+ super(name, "string sparsevec", "PgSparseVector");
2661
+ this.config.vectorDimensions = config.dimensions;
2662
+ }
2663
+ build(table) {
2664
+ return new PgSparseVector(table, this.config);
2665
+ }
2666
+ };
2667
+ var PgSparseVector = class extends PgColumn {
2668
+ static [entityKind] = "PgSparseVector";
2669
+ codec = "sparsevec";
2670
+ vectorDimensions = this.config.vectorDimensions;
2671
+ getSQLType() {
2672
+ return `sparsevec(${this.vectorDimensions})`;
2673
+ }
2674
+ };
2675
+ function sparsevec(a, b) {
2676
+ const { name, config } = getColumnNameAndConfig(a, b);
2677
+ return new PgSparseVectorBuilder(name, config);
2678
+ }
2679
+
2680
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
2681
+ var PgVectorBuilder = class extends PgColumnBuilder {
2682
+ static [entityKind] = "PgVectorBuilder";
2683
+ constructor(name, config) {
2684
+ super(name, "array vector", "PgVector");
2685
+ this.config.length = config.dimensions;
2686
+ this.config.isLengthExact = true;
2687
+ }
2688
+ build(table) {
2689
+ return new PgVector(table, this.config);
2690
+ }
2691
+ };
2692
+ var PgVector = class extends PgColumn {
2693
+ static [entityKind] = "PgVector";
2694
+ codec = "vector";
2695
+ getSQLType() {
2696
+ return `vector(${this.length})`;
2697
+ }
2698
+ mapToDriverValue = (value) => {
2699
+ return JSON.stringify(value);
2700
+ };
2701
+ };
2702
+ function vector(a, b) {
2703
+ const { name, config } = getColumnNameAndConfig(a, b);
2704
+ return new PgVectorBuilder(name, config);
2705
+ }
2706
+
2707
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/columns/all.js
2708
+ function getPgColumnBuilders() {
2709
+ return {
2710
+ bigint,
2711
+ bigserial,
2712
+ boolean,
2713
+ char,
2714
+ cidr,
2715
+ customType,
2716
+ date,
2717
+ doublePrecision,
2718
+ inet,
2719
+ integer,
2720
+ interval,
2721
+ json,
2722
+ jsonb,
2723
+ line,
2724
+ macaddr,
2725
+ macaddr8,
2726
+ numeric,
2727
+ point,
2728
+ geometry,
2729
+ real,
2730
+ serial,
2731
+ smallint,
2732
+ smallserial,
2733
+ text,
2734
+ time,
2735
+ timestamp,
2736
+ uuid,
2737
+ varchar,
2738
+ bit,
2739
+ halfvec,
2740
+ sparsevec,
2741
+ vector
2742
+ };
2743
+ }
2744
+
2745
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/casing.js
2746
+ function toSnakeCase(input) {
2747
+ return (input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? []).map((word) => word.toLowerCase()).join("_");
2748
+ }
2749
+ function toCamelCase(input) {
2750
+ return (input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? []).reduce((acc, word, i) => {
2751
+ return acc + (i === 0 ? word.toLowerCase() : `${word[0].toUpperCase()}${word.slice(1)}`);
2752
+ }, "");
2753
+ }
2754
+ function getCasingFn(casing) {
2755
+ if (casing === "snake_case")
2756
+ return toSnakeCase;
2757
+ if (casing === "camelCase")
2758
+ return toCamelCase;
2759
+ return (name) => name;
2760
+ }
2761
+
2762
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/table.js
2763
+ var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
2764
+ var EnableRLS = Symbol.for("drizzle:EnableRLS");
2765
+ var PgTable = class extends Table {
2766
+ static [entityKind] = "PgTable";
2767
+ static Symbol = Object.assign({}, Table.Symbol, {
2768
+ InlineForeignKeys,
2769
+ EnableRLS
2770
+ });
2771
+ [InlineForeignKeys] = [];
2772
+ [EnableRLS] = false;
2773
+ [Table.Symbol.ExtraConfigBuilder] = undefined;
2774
+ [Table.Symbol.ExtraConfigColumns] = {};
2775
+ };
2776
+ function pgTableWithSchema(name, columns, extraConfig, schema, casing, baseName = name) {
2777
+ const casingFn = getCasingFn(casing);
2778
+ const rawTable = new PgTable(name, schema, baseName);
2779
+ const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
2780
+ const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
2781
+ const colBuilder = colBuilderBase;
2782
+ colBuilder.setName(name2, casingFn);
2783
+ const column = colBuilder.build(rawTable).postBuild();
2784
+ rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
2785
+ return [name2, column];
2786
+ }));
2787
+ const builtColumnsForExtraConfig = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
2788
+ const colBuilder = colBuilderBase;
2789
+ colBuilder.setName(name2, casingFn);
2790
+ return [name2, colBuilder.buildExtraConfigColumn(rawTable)];
2791
+ }));
2792
+ const table = Object.assign(rawTable, builtColumns);
2793
+ table[Table.Symbol.Columns] = builtColumns;
2794
+ table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
2795
+ if (extraConfig)
2796
+ table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
2797
+ return Object.assign(table, { enableRLS: () => {
2798
+ table[PgTable.Symbol.EnableRLS] = true;
2799
+ return table;
2800
+ } });
2801
+ }
2802
+ function pgTableWithCasing(casing) {
2803
+ const pgTableInternal = (name, columns, extraConfig) => {
2804
+ return pgTableWithSchema(name, columns, extraConfig, undefined, casing);
2805
+ };
2806
+ const pgTableWithRLS = (name, columns, extraConfig) => {
2807
+ const table = pgTableWithSchema(name, columns, extraConfig, undefined, casing);
2808
+ table[EnableRLS] = true;
2809
+ return table;
2810
+ };
2811
+ return Object.assign(pgTableInternal, { withRLS: pgTableWithRLS });
2812
+ }
2813
+ var pgTable = pgTableWithCasing(undefined);
2814
+
2815
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/primary-keys.js
2816
+ var PrimaryKeyBuilder = class {
2817
+ static [entityKind] = "PgPrimaryKeyBuilder";
2818
+ columns;
2819
+ name;
2820
+ constructor(columns, name) {
2821
+ this.columns = columns;
2822
+ this.name = name;
2823
+ }
2824
+ build(table) {
2825
+ return new PrimaryKey(table, this.columns, this.name);
2826
+ }
2827
+ };
2828
+ var PrimaryKey = class {
2829
+ static [entityKind] = "PgPrimaryKey";
2830
+ columns;
2831
+ name;
2832
+ isNameExplicit;
2833
+ constructor(table, columns, name) {
2834
+ this.table = table;
2835
+ this.columns = columns;
2836
+ this.name = name;
2837
+ this.isNameExplicit = !!name;
2838
+ }
2839
+ getName() {
2840
+ return this.name ?? `${this.table[PgTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
2841
+ }
2842
+ };
2843
+
2844
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/unique-constraint.js
2845
+ function uniqueKeyName(table, columns) {
2846
+ return `${table[TableName]}_${columns.join("_")}_unique`;
2847
+ }
2848
+ var UniqueConstraintBuilder = class {
2849
+ static [entityKind] = "PgUniqueConstraintBuilder";
2850
+ columns;
2851
+ nullsNotDistinctConfig = false;
2852
+ constructor(columns, name) {
2853
+ this.name = name;
2854
+ this.columns = columns;
2855
+ }
2856
+ nullsNotDistinct() {
2857
+ this.nullsNotDistinctConfig = true;
2858
+ return this;
2859
+ }
2860
+ build(table) {
2861
+ return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
2862
+ }
2863
+ };
2864
+ var UniqueConstraint = class {
2865
+ static [entityKind] = "PgUniqueConstraint";
2866
+ columns;
2867
+ name;
2868
+ isNameExplicit;
2869
+ nullsNotDistinct = false;
2870
+ constructor(table, columns, nullsNotDistinct, name) {
2871
+ this.table = table;
2872
+ this.columns = columns;
2873
+ this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
2874
+ this.isNameExplicit = !!name;
2875
+ this.nullsNotDistinct = nullsNotDistinct;
2876
+ }
2877
+ getName() {
2878
+ return this.name;
2879
+ }
2880
+ };
2881
+
2882
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/indexes.js
2883
+ var IndexBuilder = class {
2884
+ static [entityKind] = "PgIndexBuilder";
2885
+ config;
2886
+ constructor(columns, unique, only, name, method = "btree") {
2887
+ this.config = {
2888
+ name,
2889
+ columns,
2890
+ unique,
2891
+ only,
2892
+ method
2893
+ };
2894
+ }
2895
+ concurrently() {
2896
+ this.config.concurrently = true;
2897
+ return this;
2898
+ }
2899
+ with(obj) {
2900
+ this.config.with = obj;
2901
+ return this;
2902
+ }
2903
+ where(condition) {
2904
+ this.config.where = condition;
2905
+ return this;
2906
+ }
2907
+ build(table) {
2908
+ return new Index(this.config, table);
2909
+ }
2910
+ };
2911
+ var Index = class {
2912
+ static [entityKind] = "PgIndex";
2913
+ config;
2914
+ isNameExplicit;
2915
+ constructor(config, table) {
2916
+ this.config = {
2917
+ ...config,
2918
+ table
2919
+ };
2920
+ this.isNameExplicit = !!config.name;
2921
+ }
2922
+ };
2923
+
2924
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/alias.js
2925
+ var ColumnTableAliasProxyHandler = class {
2926
+ static [entityKind] = "ColumnTableAliasProxyHandler";
2927
+ constructor(table, ignoreColumnAlias) {
2928
+ this.table = table;
2929
+ this.ignoreColumnAlias = ignoreColumnAlias;
2930
+ }
2931
+ get(columnObj, prop) {
2932
+ if (prop === "table")
2933
+ return this.table;
2934
+ if (prop === "isAlias" && this.ignoreColumnAlias)
2935
+ return false;
2936
+ return columnObj[prop];
2937
+ }
2938
+ };
2939
+ var ViewSelectionAliasProxyHandler = class {
2940
+ static [entityKind] = "ViewSelectionAliasProxyHandler";
2941
+ constructor(view, selection, ignoreColumnAlias) {
2942
+ this.view = view;
2943
+ this.selection = selection;
2944
+ this.ignoreColumnAlias = ignoreColumnAlias;
2945
+ }
2946
+ get(selection, prop) {
2947
+ const value = selection[prop];
2948
+ if (is(value, Column))
2949
+ return new Proxy(value, new ColumnTableAliasProxyHandler(this.view, this.ignoreColumnAlias));
2950
+ if (is(value, Subquery) || is(value, SQL) || is(value, SQL.Aliased) || isSQLWrapper(value) || typeof value !== "object" || value === null)
2951
+ return value;
2952
+ return new Proxy(value, this);
2953
+ }
2954
+ };
2955
+ var TableAliasProxyHandler = class {
2956
+ static [entityKind] = "TableAliasProxyHandler";
2957
+ constructor(alias, replaceOriginalName, ignoreColumnAlias) {
2958
+ this.alias = alias;
2959
+ this.replaceOriginalName = replaceOriginalName;
2960
+ this.ignoreColumnAlias = ignoreColumnAlias;
2961
+ }
2962
+ get(target, prop) {
2963
+ if (prop === Table.Symbol.IsAlias)
2964
+ return true;
2965
+ if (prop === Table.Symbol.Name)
2966
+ return this.alias;
2967
+ if (this.replaceOriginalName && prop === Table.Symbol.OriginalName)
2968
+ return this.alias;
2969
+ if (prop === ViewBaseConfig)
2970
+ return {
2971
+ ...target[ViewBaseConfig],
2972
+ name: this.alias,
2973
+ isAlias: true,
2974
+ selectedFields: new Proxy(target[ViewBaseConfig].selectedFields, new ViewSelectionAliasProxyHandler(new Proxy(target, this), target[ViewBaseConfig].selectedFields, this.ignoreColumnAlias))
2975
+ };
2976
+ if (prop === Table.Symbol.Columns) {
2977
+ const columns = target[Table.Symbol.Columns];
2978
+ if (!columns)
2979
+ return columns;
2980
+ if (is(target, View))
2981
+ return new Proxy(target[Table.Symbol.Columns], new ViewSelectionAliasProxyHandler(new Proxy(target, this), target[Table.Symbol.Columns], this.ignoreColumnAlias));
2982
+ const proxiedColumns = {};
2983
+ Object.keys(columns).map((key) => {
2984
+ proxiedColumns[key] = new Proxy(columns[key], new ColumnTableAliasProxyHandler(new Proxy(target, this), this.ignoreColumnAlias));
2985
+ });
2986
+ return proxiedColumns;
2987
+ }
2988
+ const value = target[prop];
2989
+ if (is(value, Column))
2990
+ return new Proxy(value, new ColumnTableAliasProxyHandler(new Proxy(target, this), this.ignoreColumnAlias));
2991
+ return value;
2992
+ }
2993
+ };
2994
+ var ColumnAliasProxyHandler = class {
2995
+ static [entityKind] = "ColumnAliasProxyHandler";
2996
+ constructor(alias) {
2997
+ this.alias = alias;
2998
+ }
2999
+ get(target, prop) {
3000
+ if (prop === "isAlias")
3001
+ return true;
3002
+ if (prop === "name")
3003
+ return this.alias;
3004
+ if (prop === "keyAsName")
3005
+ return false;
3006
+ if (prop === OriginalColumn)
3007
+ return () => target;
3008
+ return target[prop];
3009
+ }
3010
+ };
3011
+ function aliasedTable(table, tableAlias) {
3012
+ return new Proxy(table, new TableAliasProxyHandler(tableAlias, false, false));
3013
+ }
3014
+ function aliasedColumn(column, alias) {
3015
+ return new Proxy(column, new ColumnAliasProxyHandler(alias));
3016
+ }
3017
+ Column.prototype.as = function(alias) {
3018
+ return aliasedColumn(this, alias);
3019
+ };
3020
+ function getOriginalColumnFromAlias(column) {
3021
+ return column[OriginalColumn]();
3022
+ }
3023
+
3024
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/selection-proxy.js
3025
+ var SelectionProxyHandler = class SelectionProxyHandler2 {
3026
+ static [entityKind] = "SelectionProxyHandler";
3027
+ config;
3028
+ constructor(config) {
3029
+ this.config = { ...config };
3030
+ }
3031
+ get(subquery, prop) {
3032
+ if (prop === "_")
3033
+ return {
3034
+ ...subquery["_"],
3035
+ selectedFields: new Proxy(subquery._.selectedFields, this)
3036
+ };
3037
+ if (prop === ViewBaseConfig)
3038
+ return {
3039
+ ...subquery[ViewBaseConfig],
3040
+ selectedFields: new Proxy(subquery[ViewBaseConfig].selectedFields, this)
3041
+ };
3042
+ if (typeof prop === "symbol")
3043
+ return subquery[prop];
3044
+ const value = (is(subquery, Subquery) ? subquery._.selectedFields : is(subquery, View) ? subquery[ViewBaseConfig].selectedFields : subquery)[prop];
3045
+ if (is(value, SQL.Aliased)) {
3046
+ if (this.config.sqlAliasedBehavior === "sql" && !value.isSelectionField)
3047
+ return value.sql;
3048
+ const newValue = value.clone();
3049
+ newValue.isSelectionField = true;
3050
+ newValue.origin = this.config.alias;
3051
+ return newValue;
3052
+ }
3053
+ if (is(value, SQL)) {
3054
+ if (this.config.sqlBehavior === "sql")
3055
+ return value;
3056
+ throw new Error(`You tried to reference "${prop}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`);
3057
+ }
3058
+ if (is(value, Column)) {
3059
+ if (this.config.alias)
3060
+ return new Proxy(value, new ColumnTableAliasProxyHandler(new Proxy(value.table, new TableAliasProxyHandler(this.config.alias, this.config.replaceOriginalName ?? false, true)), true));
3061
+ return value;
3062
+ }
3063
+ if (typeof value !== "object" || value === null)
3064
+ return value;
3065
+ return new Proxy(value, new SelectionProxyHandler2(this.config));
3066
+ }
3067
+ };
3068
+
3069
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/checks.js
3070
+ var CheckBuilder = class {
3071
+ static [entityKind] = "PgCheckBuilder";
3072
+ brand;
3073
+ constructor(name, value) {
3074
+ this.name = name;
3075
+ this.value = value;
3076
+ }
3077
+ build(table) {
3078
+ return new Check(table, this);
3079
+ }
3080
+ };
3081
+ var Check = class {
3082
+ static [entityKind] = "PgCheck";
3083
+ name;
3084
+ value;
3085
+ constructor(table, builder) {
3086
+ this.table = table;
3087
+ this.name = builder.name;
3088
+ this.value = builder.value;
3089
+ }
3090
+ };
3091
+
3092
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/policies.js
3093
+ var PgPolicy = class {
3094
+ static [entityKind] = "PgPolicy";
3095
+ as;
3096
+ for;
3097
+ to;
3098
+ using;
3099
+ withCheck;
3100
+ _linkedTable;
3101
+ constructor(name, config) {
3102
+ this.name = name;
3103
+ if (config) {
3104
+ this.as = config.as;
3105
+ this.for = config.for;
3106
+ this.to = config.to;
3107
+ this.using = config.using;
3108
+ this.withCheck = config.withCheck;
3109
+ }
3110
+ }
3111
+ link(table) {
3112
+ this._linkedTable = table;
3113
+ return this;
3114
+ }
3115
+ };
3116
+ function pgPolicy(name, config) {
3117
+ return new PgPolicy(name, config);
3118
+ }
3119
+
3120
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/view-common.js
3121
+ var PgViewConfig = Symbol.for("drizzle:PgViewConfig");
3122
+ var PgMaterializedViewConfig = Symbol.for("drizzle:PgMaterializedViewConfig");
3123
+
3124
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/utils.js
3125
+ function getTableConfig(table) {
3126
+ const columns = Object.values(table[Table.Symbol.Columns]);
3127
+ const indexes = [];
3128
+ const checks = [];
3129
+ const primaryKeys = [];
3130
+ const foreignKeys = Object.values(table[PgTable.Symbol.InlineForeignKeys]);
3131
+ const uniqueConstraints = [];
3132
+ const name = table[Table.Symbol.Name];
3133
+ const schema = table[Table.Symbol.Schema];
3134
+ const policies = [];
3135
+ const enableRLS = table[PgTable.Symbol.EnableRLS];
3136
+ const extraConfigBuilder = table[PgTable.Symbol.ExtraConfigBuilder];
3137
+ if (extraConfigBuilder !== undefined) {
3138
+ const extraConfig = extraConfigBuilder(table[Table.Symbol.ExtraConfigColumns]);
3139
+ const extraValues = Array.isArray(extraConfig) ? extraConfig.flat(1) : Object.values(extraConfig);
3140
+ for (const builder of extraValues)
3141
+ if (is(builder, IndexBuilder))
3142
+ indexes.push(builder.build(table));
3143
+ else if (is(builder, CheckBuilder))
3144
+ checks.push(builder.build(table));
3145
+ else if (is(builder, UniqueConstraintBuilder))
3146
+ uniqueConstraints.push(builder.build(table));
3147
+ else if (is(builder, PrimaryKeyBuilder))
3148
+ primaryKeys.push(builder.build(table));
3149
+ else if (is(builder, ForeignKeyBuilder))
3150
+ foreignKeys.push(builder.build(table));
3151
+ else if (is(builder, PgPolicy))
3152
+ policies.push(builder);
3153
+ }
3154
+ return {
3155
+ columns,
3156
+ indexes,
3157
+ foreignKeys,
3158
+ checks,
3159
+ primaryKeys,
3160
+ uniqueConstraints,
3161
+ name,
3162
+ schema,
3163
+ policies,
3164
+ enableRLS
3165
+ };
3166
+ }
3167
+ function extractUsedTable(table) {
3168
+ if (is(table, PgTable))
3169
+ return [table[TableSchema] ? `${table[TableSchema]}.${table[Table.Symbol.BaseName]}` : table[Table.Symbol.BaseName]];
3170
+ if (is(table, Subquery))
3171
+ return table._.usedTables ?? [];
3172
+ if (is(table, SQL))
3173
+ return table.usedTables ?? [];
3174
+ return [];
3175
+ }
3176
+
3177
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/query-builders/query-builder.js
3178
+ var TypedQueryBuilder = class {
3179
+ static [entityKind] = "TypedQueryBuilder";
3180
+ getSelectedFields() {
3181
+ return this._.selectedFields;
3182
+ }
3183
+ withoutSelectionCastCodecs() {
3184
+ return this;
3185
+ }
3186
+ };
3187
+
3188
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/view-base.js
3189
+ var PgViewBase = class extends View {
3190
+ static [entityKind] = "PgViewBase";
3191
+ };
3192
+
3193
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/query-builders/select.js
3194
+ var PgSelectBase = class extends TypedQueryBuilder {
3195
+ static [entityKind] = "PgSelectQueryBuilder";
3196
+ _;
3197
+ config;
3198
+ joinsNotNullableMap = {};
3199
+ tableName;
3200
+ isPartialSelect;
3201
+ session;
3202
+ dialect;
3203
+ cacheConfig;
3204
+ usedTables = /* @__PURE__ */ new Set;
3205
+ constructor(config) {
3206
+ super();
3207
+ this.session = config.session;
3208
+ this.dialect = config.dialect;
3209
+ this.config = {
3210
+ withList: config.withList ?? [],
3211
+ table: {},
3212
+ fields: config.fields,
3213
+ distinct: config.distinct,
3214
+ setOperators: []
3215
+ };
3216
+ this._ = undefined;
3217
+ }
3218
+ from(source) {
3219
+ const { fields: initFields } = this.config;
3220
+ const isPartialSelect = !!initFields;
3221
+ const src = source;
3222
+ let fields;
3223
+ if (initFields)
3224
+ fields = initFields;
3225
+ else if (is(src, Subquery))
3226
+ fields = Object.fromEntries(Object.keys(src._.selectedFields).map((key) => [key, src[key]]));
3227
+ else if (is(src, PgViewBase))
3228
+ fields = src[ViewBaseConfig].selectedFields;
3229
+ else if (is(src, SQL))
3230
+ fields = {};
3231
+ else
3232
+ fields = getTableColumns(src);
3233
+ this.config.table = src;
3234
+ this.config.fields = { ...fields };
3235
+ this._ = {
3236
+ selectedFields: this.config.fields,
3237
+ config: this.config
3238
+ };
3239
+ this.isPartialSelect = isPartialSelect;
3240
+ this.tableName = getTableLikeName(src);
3241
+ this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
3242
+ for (const item of extractUsedTable(src))
3243
+ this.usedTables.add(item);
3244
+ this.config.withList?.forEach((it) => {
3245
+ const extracted = extractUsedTable(it);
3246
+ for (const el of extracted)
3247
+ this.usedTables.add(el);
3248
+ });
3249
+ return this;
3250
+ }
3251
+ getUsedTables() {
3252
+ return [...this.usedTables];
3253
+ }
3254
+ createJoin(joinType, lateral) {
3255
+ return (table, on) => {
3256
+ const baseTableName = this.tableName;
3257
+ const tableName = getTableLikeName(table);
3258
+ for (const item of extractUsedTable(table))
3259
+ this.usedTables.add(item);
3260
+ if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName))
3261
+ throw new Error(`Alias "${tableName}" is already used in this query`);
3262
+ if (!this.isPartialSelect) {
3263
+ if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string")
3264
+ this.config.fields = { [baseTableName]: this.config.fields };
3265
+ if (typeof tableName === "string" && !is(table, SQL)) {
3266
+ const selection = is(table, Subquery) ? table._.selectedFields : is(table, View) ? table[ViewBaseConfig].selectedFields : table[Table.Symbol.Columns];
3267
+ this.config.fields[tableName] = selection;
3268
+ }
3269
+ }
3270
+ if (typeof on === "function")
3271
+ on = on(new Proxy(this.config.fields, new SelectionProxyHandler({
3272
+ sqlAliasedBehavior: "sql",
3273
+ sqlBehavior: "sql"
3274
+ })));
3275
+ if (!this.config.joins)
3276
+ this.config.joins = [];
3277
+ this.config.joins.push({
3278
+ on,
3279
+ table,
3280
+ joinType,
3281
+ alias: tableName,
3282
+ lateral
3283
+ });
3284
+ if (typeof tableName === "string")
3285
+ switch (joinType) {
3286
+ case "left":
3287
+ this.joinsNotNullableMap[tableName] = false;
3288
+ break;
3289
+ case "right":
3290
+ this.joinsNotNullableMap = Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false]));
3291
+ this.joinsNotNullableMap[tableName] = true;
3292
+ break;
3293
+ case "cross":
3294
+ case "inner":
3295
+ this.joinsNotNullableMap[tableName] = true;
3296
+ break;
3297
+ case "full":
3298
+ this.joinsNotNullableMap = Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false]));
3299
+ this.joinsNotNullableMap[tableName] = false;
3300
+ break;
3301
+ }
3302
+ return this;
3303
+ };
3304
+ }
3305
+ leftJoin = this.createJoin("left", false);
3306
+ leftJoinLateral = this.createJoin("left", true);
3307
+ rightJoin = this.createJoin("right", false);
3308
+ innerJoin = this.createJoin("inner", false);
3309
+ innerJoinLateral = this.createJoin("inner", true);
3310
+ fullJoin = this.createJoin("full", false);
3311
+ crossJoin = this.createJoin("cross", false);
3312
+ crossJoinLateral = this.createJoin("cross", true);
3313
+ createSetOperator(type, isAll) {
3314
+ return (rightSelection) => {
3315
+ const rightSelect = typeof rightSelection === "function" ? rightSelection(getPgSetOperators()) : rightSelection;
3316
+ if (!haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields()))
3317
+ throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");
3318
+ this.config.setOperators.push({
3319
+ type,
3320
+ isAll,
3321
+ rightSelect
3322
+ });
3323
+ return this;
3324
+ };
3325
+ }
3326
+ union = this.createSetOperator("union", false);
3327
+ unionAll = this.createSetOperator("union", true);
3328
+ intersect = this.createSetOperator("intersect", false);
3329
+ intersectAll = this.createSetOperator("intersect", true);
3330
+ except = this.createSetOperator("except", false);
3331
+ exceptAll = this.createSetOperator("except", true);
3332
+ addSetOperators(setOperators) {
3333
+ this.config.setOperators.push(...setOperators);
3334
+ return this;
3335
+ }
3336
+ where(where) {
3337
+ if (typeof where === "function")
3338
+ where = where(new Proxy(this.config.fields, new SelectionProxyHandler({
3339
+ sqlAliasedBehavior: "sql",
3340
+ sqlBehavior: "sql"
3341
+ })));
3342
+ this.config.where = where;
3343
+ return this;
3344
+ }
3345
+ having(having) {
3346
+ if (typeof having === "function")
3347
+ having = having(new Proxy(this.config.fields, new SelectionProxyHandler({
3348
+ sqlAliasedBehavior: "sql",
3349
+ sqlBehavior: "sql"
3350
+ })));
3351
+ this.config.having = having;
3352
+ return this;
3353
+ }
3354
+ groupBy(...columns) {
3355
+ if (typeof columns[0] === "function") {
3356
+ const groupBy = columns[0](new Proxy(this.config.fields, new SelectionProxyHandler({
3357
+ sqlAliasedBehavior: "alias",
3358
+ sqlBehavior: "sql"
3359
+ })));
3360
+ this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
3361
+ } else
3362
+ this.config.groupBy = columns;
3363
+ return this;
3364
+ }
3365
+ orderBy(...columns) {
3366
+ if (typeof columns[0] === "function") {
3367
+ const orderBy = columns[0](new Proxy(this.config.fields, new SelectionProxyHandler({
3368
+ sqlAliasedBehavior: "alias",
3369
+ sqlBehavior: "sql"
3370
+ })));
3371
+ const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
3372
+ if (this.config.setOperators.length > 0)
3373
+ this.config.setOperators.at(-1).orderBy = orderByArray;
3374
+ else
3375
+ this.config.orderBy = orderByArray;
3376
+ } else {
3377
+ const orderByArray = columns;
3378
+ if (this.config.setOperators.length > 0)
3379
+ this.config.setOperators.at(-1).orderBy = orderByArray;
3380
+ else
3381
+ this.config.orderBy = orderByArray;
3382
+ }
3383
+ return this;
3384
+ }
3385
+ limit(limit) {
3386
+ if (this.config.setOperators.length > 0)
3387
+ this.config.setOperators.at(-1).limit = limit;
3388
+ else
3389
+ this.config.limit = limit;
3390
+ return this;
3391
+ }
3392
+ offset(offset) {
3393
+ if (this.config.setOperators.length > 0)
3394
+ this.config.setOperators.at(-1).offset = offset;
3395
+ else
3396
+ this.config.offset = offset;
3397
+ return this;
3398
+ }
3399
+ for(strength, config = {}) {
3400
+ this.config.lockingClause = {
3401
+ strength,
3402
+ config
3403
+ };
3404
+ return this;
3405
+ }
3406
+ comment(comment) {
3407
+ this.config.comment = sql.comment(comment);
3408
+ return this;
3409
+ }
3410
+ getSQL() {
3411
+ return this.dialect.buildSelectQuery(this.config);
3412
+ }
3413
+ toSQL() {
3414
+ return this.dialect.sqlToQuery(this.getSQL());
3415
+ }
3416
+ as(alias) {
3417
+ const usedTables = [];
3418
+ usedTables.push(...extractUsedTable(this.config.table));
3419
+ if (this.config.joins)
3420
+ for (const it of this.config.joins)
3421
+ usedTables.push(...extractUsedTable(it.table));
3422
+ return new Proxy(new Subquery(this.withoutSelectionCastCodecs().getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]), new SelectionProxyHandler({
3423
+ alias,
3424
+ sqlAliasedBehavior: "alias",
3425
+ sqlBehavior: "error"
3426
+ }));
3427
+ }
3428
+ getSelectedFields() {
3429
+ return new Proxy(this.config.fields, new SelectionProxyHandler({
3430
+ alias: this.tableName,
3431
+ sqlAliasedBehavior: "alias",
3432
+ sqlBehavior: "error"
3433
+ }));
3434
+ }
3435
+ withoutSelectionCastCodecs() {
3436
+ this.config.ignoreSelectionCastCodecs = true;
3437
+ return this;
3438
+ }
3439
+ $dynamic() {
3440
+ return this;
3441
+ }
3442
+ $withCache(config) {
3443
+ this.cacheConfig = config === undefined ? {
3444
+ config: {},
3445
+ enabled: true,
3446
+ autoInvalidate: true
3447
+ } : config === false ? { enabled: false } : {
3448
+ enabled: true,
3449
+ autoInvalidate: true,
3450
+ ...config
3451
+ };
3452
+ return this;
3453
+ }
3454
+ };
3455
+ function createSetOperator(type, isAll) {
3456
+ return (leftSelect, rightSelect, ...restSelects) => {
3457
+ const setOperators = [rightSelect, ...restSelects].map((select) => ({
3458
+ type,
3459
+ isAll,
3460
+ rightSelect: select
3461
+ }));
3462
+ for (const setOperator of setOperators)
3463
+ if (!haveSameKeys(leftSelect.getSelectedFields(), setOperator.rightSelect.getSelectedFields()))
3464
+ throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");
3465
+ return leftSelect.addSetOperators(setOperators);
3466
+ };
3467
+ }
3468
+ var getPgSetOperators = () => ({
3469
+ union,
3470
+ unionAll,
3471
+ intersect,
3472
+ intersectAll,
3473
+ except,
3474
+ exceptAll
3475
+ });
3476
+ var union = createSetOperator("union", false);
3477
+ var unionAll = createSetOperator("union", true);
3478
+ var intersect = createSetOperator("intersect", false);
3479
+ var intersectAll = createSetOperator("intersect", true);
3480
+ var except = createSetOperator("except", false);
3481
+ var exceptAll = createSetOperator("except", true);
3482
+
3483
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/errors.js
3484
+ var DrizzleError = class extends Error {
3485
+ static [entityKind] = "DrizzleError";
3486
+ constructor({ message, cause }) {
3487
+ super(message);
3488
+ this.name = "DrizzleError";
3489
+ this.cause = cause;
3490
+ }
3491
+ };
3492
+
3493
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/sql/expressions/conditions.js
3494
+ function bindIfParam(value, column) {
3495
+ if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View))
3496
+ return new Param(value, column);
3497
+ return value;
3498
+ }
3499
+ var eq = (left, right) => {
3500
+ return sql`${left} = ${bindIfParam(right, left)}`;
3501
+ };
3502
+ var ne = (left, right) => {
3503
+ return sql`${left} <> ${bindIfParam(right, left)}`;
3504
+ };
3505
+ function and(...unfilteredConditions) {
3506
+ const conditions = unfilteredConditions.filter((c) => c !== undefined);
3507
+ if (conditions.length === 0)
3508
+ return;
3509
+ if (conditions.length === 1)
3510
+ return new SQL(conditions);
3511
+ return new SQL([
3512
+ new StringChunk("("),
3513
+ sql.join(conditions.map((c) => sql`(${c})`), new StringChunk(" and ")),
3514
+ new StringChunk(")")
3515
+ ]);
3516
+ }
3517
+ function or(...unfilteredConditions) {
3518
+ const conditions = unfilteredConditions.filter((c) => c !== undefined);
3519
+ if (conditions.length === 0)
3520
+ return;
3521
+ if (conditions.length === 1)
3522
+ return new SQL(conditions);
3523
+ return new SQL([
3524
+ new StringChunk("("),
3525
+ sql.join(conditions.map((c) => sql`(${c})`), new StringChunk(" or ")),
3526
+ new StringChunk(")")
3527
+ ]);
3528
+ }
3529
+ function not(condition) {
3530
+ return is(condition, SQL) ? sql`not (${condition})` : sql`not ${condition}`;
3531
+ }
3532
+ var gt = (left, right) => {
3533
+ return sql`${left} > ${bindIfParam(right, left)}`;
3534
+ };
3535
+ var gte = (left, right) => {
3536
+ return sql`${left} >= ${bindIfParam(right, left)}`;
3537
+ };
3538
+ var lt = (left, right) => {
3539
+ return sql`${left} < ${bindIfParam(right, left)}`;
3540
+ };
3541
+ var lte = (left, right) => {
3542
+ return sql`${left} <= ${bindIfParam(right, left)}`;
3543
+ };
3544
+ function inArray(column, values) {
3545
+ if (Array.isArray(values)) {
3546
+ if (values.length === 0)
3547
+ return sql`false`;
3548
+ return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
3549
+ }
3550
+ return sql`${column} in ${bindIfParam(values, column)}`;
3551
+ }
3552
+ function notInArray(column, values) {
3553
+ if (Array.isArray(values)) {
3554
+ if (values.length === 0)
3555
+ return sql`true`;
3556
+ return sql`${column} not in ${values.map((v) => bindIfParam(v, column))}`;
3557
+ }
3558
+ return sql`${column} not in ${bindIfParam(values, column)}`;
3559
+ }
3560
+ function isNull(value) {
3561
+ return sql`(${value} is null)`;
3562
+ }
3563
+ function isNotNull(value) {
3564
+ return sql`(${value} is not null)`;
3565
+ }
3566
+ function exists(subquery) {
3567
+ return sql`exists ${subquery}`;
3568
+ }
3569
+ function notExists(subquery) {
3570
+ return sql`not exists ${subquery}`;
3571
+ }
3572
+ function between(column, min, max) {
3573
+ return sql`${column} between ${bindIfParam(min, column)} and ${bindIfParam(max, column)}`;
3574
+ }
3575
+ function notBetween(column, min, max) {
3576
+ return sql`${column} not between ${bindIfParam(min, column)} and ${bindIfParam(max, column)}`;
3577
+ }
3578
+ function like(column, value) {
3579
+ return sql`${column} like ${value}`;
3580
+ }
3581
+ function notLike(column, value) {
3582
+ return sql`${column} not like ${value}`;
3583
+ }
3584
+ function ilike(column, value) {
3585
+ return sql`${column} ilike ${value}`;
3586
+ }
3587
+ function notIlike(column, value) {
3588
+ return sql`${column} not ilike ${value}`;
3589
+ }
3590
+ function arrayContains(column, values) {
3591
+ if (Array.isArray(values)) {
3592
+ if (values.length === 0)
3593
+ throw new Error("arrayContains requires at least one value");
3594
+ const par = bindIfParam(values, column);
3595
+ return sql`${column} @> ${sql`${Array.isArray(par) ? new Param(par) : par}`}`;
3596
+ }
3597
+ return sql`${column} @> ${bindIfParam(values, column)}`;
3598
+ }
3599
+ function arrayContained(column, values) {
3600
+ if (Array.isArray(values)) {
3601
+ if (values.length === 0)
3602
+ throw new Error("arrayContained requires at least one value");
3603
+ const par = bindIfParam(values, column);
3604
+ return sql`${column} <@ ${sql`${Array.isArray(par) ? new Param(par) : par}`}`;
3605
+ }
3606
+ return sql`${column} <@ ${bindIfParam(values, column)}`;
3607
+ }
3608
+ function arrayOverlaps(column, values) {
3609
+ if (Array.isArray(values)) {
3610
+ if (values.length === 0)
3611
+ throw new Error("arrayOverlaps requires at least one value");
3612
+ const par = bindIfParam(values, column);
3613
+ return sql`${column} && ${sql`${Array.isArray(par) ? new Param(par) : par}`}`;
3614
+ }
3615
+ return sql`${column} && ${bindIfParam(values, column)}`;
3616
+ }
3617
+
3618
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/sql/expressions/select.js
3619
+ function asc(column) {
3620
+ return sql`${column} asc`;
3621
+ }
3622
+ function desc(column) {
3623
+ return sql`${column} desc`;
3624
+ }
3625
+
3626
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/relations.js
3627
+ var Relation = class {
3628
+ static [entityKind] = "RelationV2";
3629
+ fieldName;
3630
+ sourceColumns;
3631
+ targetColumns;
3632
+ alias;
3633
+ where;
3634
+ sourceTable;
3635
+ targetTable;
3636
+ through;
3637
+ throughTable;
3638
+ isReversed;
3639
+ sourceColumnTableNames = [];
3640
+ targetColumnTableNames = [];
3641
+ constructor(targetTable, targetTableName) {
3642
+ this.targetTableName = targetTableName;
3643
+ this.targetTable = targetTable;
3644
+ }
3645
+ };
3646
+ var One = class extends Relation {
3647
+ static [entityKind] = "OneV2";
3648
+ relationType = "one";
3649
+ optional;
3650
+ constructor(tables, targetTable, targetTableName, config) {
3651
+ super(targetTable, targetTableName);
3652
+ this.alias = config?.alias;
3653
+ this.where = config?.where;
3654
+ if (config?.from)
3655
+ this.sourceColumns = (Array.isArray(config.from) ? config.from : [config.from]).map((it) => {
3656
+ this.throughTable ??= it._.through ? tables[it._.through._.tableName] : undefined;
3657
+ this.sourceColumnTableNames.push(it._.tableName);
3658
+ return it._.column;
3659
+ });
3660
+ if (config?.to)
3661
+ this.targetColumns = (Array.isArray(config.to) ? config.to : [config.to]).map((it) => {
3662
+ this.throughTable ??= it._.through ? tables[it._.through._.tableName] : undefined;
3663
+ this.targetColumnTableNames.push(it._.tableName);
3664
+ return it._.column;
3665
+ });
3666
+ if (this.throughTable)
3667
+ this.through = {
3668
+ source: (Array.isArray(config?.from) ? config.from : (config?.from) ? [config.from] : []).map((c) => c._.through),
3669
+ target: (Array.isArray(config?.to) ? config.to : (config?.to) ? [config.to] : []).map((c) => c._.through)
3670
+ };
3671
+ this.optional = config?.optional ?? true;
3672
+ }
3673
+ };
3674
+ var operators = {
3675
+ and,
3676
+ between,
3677
+ eq,
3678
+ exists,
3679
+ gt,
3680
+ gte,
3681
+ ilike,
3682
+ inArray,
3683
+ arrayContains,
3684
+ arrayContained,
3685
+ arrayOverlaps,
3686
+ isNull,
3687
+ isNotNull,
3688
+ like,
3689
+ lt,
3690
+ lte,
3691
+ ne,
3692
+ not,
3693
+ notBetween,
3694
+ notExists,
3695
+ notLike,
3696
+ notIlike,
3697
+ notInArray,
3698
+ or,
3699
+ sql
3700
+ };
3701
+ var orderByOperators = {
3702
+ sql,
3703
+ asc,
3704
+ desc
3705
+ };
3706
+ function mapRelationalRow(rows, isOne, buildQueryResultSelection, mapColumnValue, parseJson = false, parseJsonIfString = false, useJsonMappers = true) {
3707
+ const maxIdx = isOne ? 1 : rows.length;
3708
+ const decoders = buildQueryResultSelection.map(({ field, codec, arrayDimensions }) => {
3709
+ let decoder;
3710
+ if (is(field, Column)) {
3711
+ if (useJsonMappers && field.mapFromJsonValue)
3712
+ return (v) => field.mapFromJsonValue(v);
3713
+ decoder = field;
3714
+ } else if (is(field, SQL))
3715
+ decoder = field.decoder;
3716
+ else if (is(field, SQL.Aliased))
3717
+ decoder = field.sql.decoder;
3718
+ else if (is(field, Table) || is(field, View))
3719
+ decoder = noopDecoder;
3720
+ else
3721
+ decoder = field.getSQL().decoder;
3722
+ return decoder.mapFromDriverValue.isNoop ? codec ? (value) => codec(value, arrayDimensions) : undefined : codec ? (value) => decoder.mapFromDriverValue(codec(value, arrayDimensions)) : (value) => decoder.mapFromDriverValue(value);
3723
+ });
3724
+ for (let i = 0;i < maxIdx; ++i) {
3725
+ const row = isOne ? rows : rows[i];
3726
+ for (let selectionItemIdx = 0;selectionItemIdx < buildQueryResultSelection.length; ++selectionItemIdx) {
3727
+ const selectionItem = buildQueryResultSelection[selectionItemIdx];
3728
+ if (selectionItem.selection) {
3729
+ if (row[selectionItem.key] === null)
3730
+ continue;
3731
+ if (parseJson) {
3732
+ row[selectionItem.key] = JSON.parse(row[selectionItem.key]);
3733
+ if (row[selectionItem.key] === null)
3734
+ continue;
3735
+ } else if (parseJsonIfString && typeof row[selectionItem.key] === "string")
3736
+ row[selectionItem.key] = JSON.parse(row[selectionItem.key]);
3737
+ if (selectionItem.isArray) {
3738
+ mapRelationalRow(row[selectionItem.key], false, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
3739
+ continue;
3740
+ }
3741
+ mapRelationalRow(row[selectionItem.key], true, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
3742
+ continue;
3743
+ }
3744
+ if (mapColumnValue)
3745
+ row[selectionItem.key] = mapColumnValue(row[selectionItem.key]);
3746
+ if (row[selectionItem.key] === null)
3747
+ continue;
3748
+ const decoder = decoders[selectionItemIdx];
3749
+ if (!decoder)
3750
+ continue;
3751
+ row[selectionItem.key] = decoder(row[selectionItem.key]);
3752
+ }
3753
+ }
3754
+ return rows;
3755
+ }
3756
+ function mapRelationalRowFromArrays(rows, isOne, buildQueryResultSelection, mapColumnValue, parseJson = false, parseJsonIfString = false) {
3757
+ const maxIdx = isOne ? 1 : rows.length;
3758
+ const decoders = buildQueryResultSelection.map(({ field, codec, arrayDimensions }) => {
3759
+ let decoder;
3760
+ if (is(field, Column))
3761
+ decoder = field;
3762
+ else if (is(field, SQL))
3763
+ decoder = field.decoder;
3764
+ else if (is(field, SQL.Aliased))
3765
+ decoder = field.sql.decoder;
3766
+ else if (is(field, Table) || is(field, View))
3767
+ decoder = noopDecoder;
3768
+ else
3769
+ decoder = field.getSQL().decoder;
3770
+ return decoder.mapFromDriverValue.isNoop ? codec ? (value) => codec(value, arrayDimensions) : undefined : codec ? (value) => decoder.mapFromDriverValue(codec(value, arrayDimensions)) : (value) => decoder.mapFromDriverValue(value);
3771
+ });
3772
+ const results = Array.from({ length: maxIdx });
3773
+ for (let i = 0;i < maxIdx; ++i) {
3774
+ const row = isOne ? rows : rows[i];
3775
+ const result = {};
3776
+ for (let selectionItemIdx = 0;selectionItemIdx < buildQueryResultSelection.length; ++selectionItemIdx) {
3777
+ const selectionItem = buildQueryResultSelection[selectionItemIdx];
3778
+ let value = row[selectionItemIdx];
3779
+ if (selectionItem.selection) {
3780
+ if (value === null) {
3781
+ result[selectionItem.key] = null;
3782
+ continue;
3783
+ }
3784
+ if (parseJson) {
3785
+ value = JSON.parse(value);
3786
+ if (value === null) {
3787
+ result[selectionItem.key] = null;
3788
+ continue;
3789
+ }
3790
+ } else if (parseJsonIfString && typeof value === "string")
3791
+ value = JSON.parse(value);
3792
+ if (selectionItem.isArray)
3793
+ mapRelationalRow(value, false, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
3794
+ else
3795
+ mapRelationalRow(value, true, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
3796
+ result[selectionItem.key] = value;
3797
+ continue;
3798
+ }
3799
+ if (mapColumnValue)
3800
+ value = mapColumnValue(value);
3801
+ if (value === null) {
3802
+ result[selectionItem.key] = null;
3803
+ continue;
3804
+ }
3805
+ const decoder = decoders[selectionItemIdx];
3806
+ result[selectionItem.key] = decoder ? decoder(value) : value;
3807
+ }
3808
+ results[i] = result;
3809
+ }
3810
+ return isOne ? results[0] : results;
3811
+ }
3812
+ function makeDefaultRqbMapper({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }, mapColumnValue) {
3813
+ return (rows) => {
3814
+ if (isFirst && !rows[0])
3815
+ return rows[0];
3816
+ return arrayModeRoot ? mapRelationalRowFromArrays(isFirst ? rows[0] : rows, isFirst, selection, mapColumnValue, parseJson, parseJsonIfString) : mapRelationalRow(isFirst ? rows[0] : rows, isFirst, selection, mapColumnValue, parseJson, parseJsonIfString, rootJsonMappers);
3817
+ };
3818
+ }
3819
+ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue, parseJson, parseJsonIfString, useJsonMappers, preFn, counter, accessByIdx) {
3820
+ const bodyStmts = [];
3821
+ const literalEntries = [];
3822
+ let hasWork = false;
3823
+ const fieldVars = selection.map(() => `c${counter.n++}`);
3824
+ const destructurePieces = selection.map((item, idx) => accessByIdx ? fieldVars[idx] : `${JSON.stringify(item.key)}: ${fieldVars[idx]}`);
3825
+ bodyStmts.push(accessByIdx ? `let [ ${destructurePieces.join(", ")} ] = ${rowExpr};` : `let { ${destructurePieces.join(", ")} } = ${rowExpr};`);
3826
+ for (const [idx, { field, key, codec, isArray, selection: innerSelection, arrayDimensions }] of selection.entries()) {
3827
+ const sel = `${selectionVar}[${idx}]`;
3828
+ const keyStr = JSON.stringify(key);
3829
+ const slot = fieldVars[idx];
3830
+ if (innerSelection) {
3831
+ if (parseJson) {
3832
+ bodyStmts.push(`if (${slot} !== null) ${slot} = JSON.parse(${slot});`);
3833
+ hasWork = true;
3834
+ } else if (parseJsonIfString) {
3835
+ bodyStmts.push(`if (typeof ${slot} === 'string') ${slot} = JSON.parse(${slot});`);
3836
+ hasWork = true;
3837
+ }
3838
+ const nestedSelVar = `s${counter.n++}`;
3839
+ const savedPreFnLen = preFn.length;
3840
+ preFn.push(`const { selection: ${nestedSelVar} } = ${sel};`);
3841
+ if (isArray) {
3842
+ const j = `j${counter.n++}`;
3843
+ const inner = makeJitRqbMapperInner(innerSelection, `${slot}[${j}]`, nestedSelVar, mapColumnValue, false, parseJsonIfString, true, preFn, counter, false);
3844
+ if (inner.hasWork) {
3845
+ hasWork = true;
3846
+ bodyStmts.push(`if (${slot} !== null) {`);
3847
+ bodyStmts.push(` for (let ${j} = 0; ${j} < ${slot}.length; ++${j}) {`);
3848
+ for (const s of inner.bodyStmts)
3849
+ bodyStmts.push(` ${s}`);
3850
+ bodyStmts.push(` ${slot}[${j}] = ${inner.literal};`);
3851
+ bodyStmts.push(` }`);
3852
+ bodyStmts.push(`}`);
3853
+ } else
3854
+ preFn.splice(savedPreFnLen, 1);
3855
+ } else {
3856
+ const inner = makeJitRqbMapperInner(innerSelection, slot, nestedSelVar, mapColumnValue, false, parseJsonIfString, true, preFn, counter, false);
3857
+ if (inner.hasWork) {
3858
+ hasWork = true;
3859
+ bodyStmts.push(`if (${slot} !== null) {`);
3860
+ for (const s of inner.bodyStmts)
3861
+ bodyStmts.push(` ${s}`);
3862
+ bodyStmts.push(` ${slot} = ${inner.literal};`);
3863
+ bodyStmts.push(`}`);
3864
+ } else
3865
+ preFn.splice(savedPreFnLen, 1);
3866
+ }
3867
+ literalEntries.push(`${keyStr}: ${slot}`);
3868
+ continue;
3869
+ }
3870
+ let decoderExpr = "";
3871
+ let destructure = "";
3872
+ let bypassCodecs = false;
3873
+ if (is(field, Column)) {
3874
+ if (useJsonMappers && field.mapFromJsonValue) {
3875
+ bypassCodecs = true;
3876
+ const id = counter.n++;
3877
+ destructure = `field: dec${id}`;
3878
+ decoderExpr = `dec${id}.mapFromJsonValue`;
3879
+ } else if (!field.mapFromDriverValue.isNoop) {
3880
+ const id = counter.n++;
3881
+ destructure = `field: dec${id}`;
3882
+ decoderExpr = `dec${id}.mapFromDriverValue`;
3883
+ }
3884
+ } else if (is(field, SQL)) {
3885
+ if (!field.decoder.mapFromDriverValue.isNoop) {
3886
+ const id = counter.n++;
3887
+ destructure = `field: { decoder: dec${id} }`;
3888
+ decoderExpr = `dec${id}.mapFromDriverValue`;
3889
+ }
3890
+ } else if (is(field, SQL.Aliased)) {
3891
+ if (!field.sql.decoder.mapFromDriverValue.isNoop) {
3892
+ const id = counter.n++;
3893
+ destructure = `field: { sql: { decoder: dec${id} } }`;
3894
+ decoderExpr = `dec${id}.mapFromDriverValue`;
3895
+ }
3896
+ } else if (is(field, Table) || is(field, View)) {} else if (!field.getSQL().decoder.mapFromDriverValue.isNoop) {
3897
+ const id = counter.n++;
3898
+ preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
3899
+ decoderExpr = `dec${id}.mapFromDriverValue`;
3900
+ }
3901
+ let codecVar = "";
3902
+ if (!bypassCodecs && codec)
3903
+ codecVar = `codec${counter.n++}`;
3904
+ if (destructure || codecVar) {
3905
+ const parts = [];
3906
+ if (destructure)
3907
+ parts.push(destructure);
3908
+ if (codecVar)
3909
+ parts.push(`codec: ${codecVar}`);
3910
+ preFn.push(`const { ${parts.join(", ")} } = ${sel};`);
3911
+ }
3912
+ if (mapColumnValue) {
3913
+ hasWork = true;
3914
+ bodyStmts.push(`${slot} = mapColumnValue(${slot});`);
3915
+ if (decoderExpr || codecVar) {
3916
+ let decoded = slot;
3917
+ if (codecVar)
3918
+ decoded = `${codecVar}(${decoded}, ${arrayDimensions})`;
3919
+ if (decoderExpr)
3920
+ decoded = `${decoderExpr}(${decoded})`;
3921
+ bodyStmts.push(`if (${slot} !== null) ${slot} = ${decoded};`);
3922
+ }
3923
+ literalEntries.push(`${keyStr}: ${slot}`);
3924
+ } else if (decoderExpr || codecVar) {
3925
+ hasWork = true;
3926
+ let decoded = slot;
3927
+ if (codecVar)
3928
+ decoded = `${codecVar}(${decoded}, ${arrayDimensions})`;
3929
+ if (decoderExpr)
3930
+ decoded = `${decoderExpr}(${decoded})`;
3931
+ literalEntries.push(`${keyStr}: ${slot} === null ? null : ${decoded}`);
3932
+ } else
3933
+ literalEntries.push(`${keyStr}: ${slot}`);
3934
+ }
3935
+ return {
3936
+ bodyStmts,
3937
+ literal: `{ ${literalEntries.join(", ")} }`,
3938
+ hasWork
3939
+ };
3940
+ }
3941
+ function makeJitRqbMapper({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }, mapColumnValue) {
3942
+ const preFn = [];
3943
+ const inner = makeJitRqbMapperInner(selection, "row", "selection", mapColumnValue, parseJson, parseJsonIfString, arrayModeRoot ? false : rootJsonMappers, preFn, { n: 0 }, !!arrayModeRoot);
3944
+ const lines = [];
3945
+ lines.push(` "use strict";
3946
+ const { selection${mapColumnValue ? `, mapColumnValue` : ""} } = this;`);
3947
+ for (const p of preFn)
3948
+ lines.push(` ${p}`);
3949
+ if (arrayModeRoot)
3950
+ if (isFirst) {
3951
+ lines.push(` const row = rows[0];`);
3952
+ lines.push(` if (!row) return undefined;`);
3953
+ for (const s of inner.bodyStmts)
3954
+ lines.push(` ${s}`);
3955
+ lines.push(` return ${inner.literal};`);
3956
+ } else {
3957
+ lines.push(` const { length } = rows;`);
3958
+ lines.push(` const mapped = Array.from({ length });`);
3959
+ lines.push(` for (let i = 0; i < length; ++i) {`);
3960
+ lines.push(` const row = rows[i];`);
3961
+ for (const s of inner.bodyStmts)
3962
+ lines.push(` ${s}`);
3963
+ lines.push(` mapped[i] = ${inner.literal};`);
3964
+ lines.push(` }`);
3965
+ lines.push(` return mapped;`);
3966
+ }
3967
+ else if (!inner.hasWork)
3968
+ lines.push(isFirst ? ` return rows[0];` : ` return rows;`);
3969
+ else if (isFirst) {
3970
+ lines.push(` const row = rows[0];`);
3971
+ lines.push(` if (!row) return undefined;`);
3972
+ for (const s of inner.bodyStmts)
3973
+ lines.push(` ${s}`);
3974
+ lines.push(` rows[0] = ${inner.literal};`);
3975
+ lines.push(` return rows[0];`);
3976
+ } else {
3977
+ lines.push(` for (let i = 0; i < rows.length; ++i) {`);
3978
+ lines.push(` const row = rows[i];`);
3979
+ for (const s of inner.bodyStmts)
3980
+ lines.push(` ${s}`);
3981
+ lines.push(` rows[i] = ${inner.literal};`);
3982
+ lines.push(` }`);
3983
+ lines.push(` return rows;`);
3984
+ }
3985
+ lines.push("\t//# sourceURL=drizzle:jit-relational-query-mapper");
3986
+ const compiled = lines.join(`
3987
+ `);
3988
+ return Object.assign(new FnConstructor("rows", compiled).bind({
3989
+ selection,
3990
+ mapColumnValue
3991
+ }), { body: `function jitRqbMapper (rows) {
3992
+ ${compiled}
3993
+ }` });
3994
+ }
3995
+ function fieldSelectionToSQL(table, target) {
3996
+ const field = table[TableColumns][target];
3997
+ return field ? is(field, Column) ? field : is(field, SQL.Aliased) ? sql`${table}.${sql.identifier(field.fieldAlias)}` : sql`${table}.${sql.identifier(target)}` : sql`${table}.${sql.identifier(target)}`;
3998
+ }
3999
+ function relationsFieldFilterToSQL(column, filter) {
4000
+ if (typeof filter !== "object" || is(filter, Placeholder))
4001
+ return eq(column, filter);
4002
+ const entries = Object.entries(filter);
4003
+ if (!entries.length)
4004
+ return;
4005
+ const parts = [];
4006
+ for (const [target, value] of entries) {
4007
+ if (value === undefined)
4008
+ continue;
4009
+ switch (target) {
4010
+ case "NOT": {
4011
+ const res = relationsFieldFilterToSQL(column, value);
4012
+ if (!res)
4013
+ continue;
4014
+ parts.push(not(res));
4015
+ continue;
4016
+ }
4017
+ case "OR":
4018
+ if (!value.length)
4019
+ continue;
4020
+ parts.push(or(...value.map((subFilter) => relationsFieldFilterToSQL(column, subFilter))));
4021
+ continue;
4022
+ case "AND":
4023
+ if (!value.length)
4024
+ continue;
4025
+ parts.push(and(...value.map((subFilter) => relationsFieldFilterToSQL(column, subFilter))));
4026
+ continue;
4027
+ case "isNotNull":
4028
+ case "isNull":
4029
+ if (!value)
4030
+ continue;
4031
+ parts.push(operators[target](column));
4032
+ continue;
4033
+ case "in":
4034
+ parts.push(operators.inArray(column, value));
4035
+ continue;
4036
+ case "notIn":
4037
+ parts.push(operators.notInArray(column, value));
4038
+ continue;
4039
+ default:
4040
+ parts.push(operators[target](column, value));
4041
+ continue;
4042
+ }
4043
+ }
4044
+ if (!parts.length)
4045
+ return;
4046
+ return and(...parts);
4047
+ }
4048
+ function relationsFilterToSQL(table, filter, tableRelations = {}, tablesRelations = {}, depth = 0) {
4049
+ const entries = Object.entries(filter);
4050
+ if (!entries.length)
4051
+ return;
4052
+ const parts = [];
4053
+ for (const [target, value] of entries) {
4054
+ if (value === undefined)
4055
+ continue;
4056
+ switch (target) {
4057
+ case "RAW": {
4058
+ const processed = typeof value === "function" ? value(table, operators) : value.getSQL();
4059
+ parts.push(processed);
4060
+ continue;
4061
+ }
4062
+ case "OR":
4063
+ if (!value?.length)
4064
+ continue;
4065
+ parts.push(or(...value.map((subFilter) => relationsFilterToSQL(table, subFilter, tableRelations, tablesRelations, depth))));
4066
+ continue;
4067
+ case "AND":
4068
+ if (!value?.length)
4069
+ continue;
4070
+ parts.push(and(...value.map((subFilter) => relationsFilterToSQL(table, subFilter, tableRelations, tablesRelations, depth))));
4071
+ continue;
4072
+ case "NOT": {
4073
+ if (value === undefined)
4074
+ continue;
4075
+ const built = relationsFilterToSQL(table, value, tableRelations, tablesRelations, depth);
4076
+ if (!built)
4077
+ continue;
4078
+ parts.push(not(built));
4079
+ continue;
4080
+ }
4081
+ default: {
4082
+ if (table[TableColumns][target]) {
4083
+ const colFilter = relationsFieldFilterToSQL(fieldSelectionToSQL(table, target), value);
4084
+ if (colFilter)
4085
+ parts.push(colFilter);
4086
+ continue;
4087
+ }
4088
+ const relation = tableRelations[target];
4089
+ if (!relation)
4090
+ throw new DrizzleError({ message: `Unknown relational filter field: "${target}"` });
4091
+ const targetTable = aliasedTable(relation.targetTable, `f${depth}`);
4092
+ const throughTable = relation.throughTable ? aliasedTable(relation.throughTable, `ft${depth}`) : undefined;
4093
+ const targetConfig = tablesRelations[relation.targetTableName];
4094
+ const { filter: relationFilter, joinCondition } = relationToSQL(relation, table, targetTable, throughTable);
4095
+ const filter2 = and(relationFilter, typeof value === "boolean" ? undefined : relationsFilterToSQL(targetTable, value, targetConfig.relations, tablesRelations, depth + 1));
4096
+ const subquery = throughTable ? sql`(select * from ${getTableAsAliasSQL(targetTable)} inner join ${getTableAsAliasSQL(throughTable)} on ${joinCondition}${sql` where ${filter2}`.if(filter2)} limit 1)` : sql`(select * from ${getTableAsAliasSQL(targetTable)}${sql` where ${filter2}`.if(filter2)} limit 1)`;
4097
+ if (filter2)
4098
+ parts.push((value ? exists : notExists)(subquery));
4099
+ }
4100
+ }
4101
+ }
4102
+ return and(...parts);
4103
+ }
4104
+ function relationsOrderToSQL(table, orders) {
4105
+ if (typeof orders === "function") {
4106
+ const data = orders(table, orderByOperators);
4107
+ return is(data, SQL) ? data : Array.isArray(data) ? data.length ? sql.join(data.map((o) => is(o, SQL) ? o : asc(o)), sql`, `) : undefined : is(data, Column) ? asc(data) : undefined;
4108
+ }
4109
+ const entries = Object.entries(orders).filter(([_, value]) => value);
4110
+ if (!entries.length)
4111
+ return;
4112
+ return sql.join(entries.map(([target, value]) => (value === "asc" ? asc : desc)(fieldSelectionToSQL(table, target))), sql`, `);
4113
+ }
4114
+ function relationExtrasToSQL(table, extras) {
4115
+ const subqueries = [];
4116
+ const selection = [];
4117
+ for (const [key, field] of Object.entries(extras)) {
4118
+ if (!field)
4119
+ continue;
4120
+ const extra = typeof field === "function" ? field(table, { sql: operators.sql }) : field;
4121
+ const query = sql`(${extra.getSQL()}) as ${sql.identifier(key)}`;
4122
+ query.decoder = extra.getSQL().decoder;
4123
+ subqueries.push(query);
4124
+ selection.push({
4125
+ key,
4126
+ field: query
4127
+ });
4128
+ }
4129
+ return {
4130
+ sql: subqueries.length ? sql.join(subqueries, sql`, `) : undefined,
4131
+ selection
4132
+ };
4133
+ }
4134
+ function relationToSQL(relation, sourceTable, targetTable, throughTable) {
4135
+ if (relation.through) {
4136
+ const outerColumnWhere = relation.sourceColumns.map((s, i) => {
4137
+ const t = relation.through.source[i];
4138
+ return eq(sql`${sourceTable}.${sql.identifier(s.name)}`, sql`${throughTable}.${sql.identifier(is(t._.column, Column) ? t._.column.name : t._.key)}`);
4139
+ });
4140
+ const innerColumnWhere = relation.targetColumns.map((s, i) => {
4141
+ const t = relation.through.target[i];
4142
+ return eq(sql`${throughTable}.${sql.identifier(is(t._.column, Column) ? t._.column.name : t._.key)}`, sql`${targetTable}.${sql.identifier(s.name)}`);
4143
+ });
4144
+ return {
4145
+ filter: and(relation.where ? relationsFilterToSQL(relation.isReversed ? sourceTable : targetTable, relation.where) : undefined, ...outerColumnWhere),
4146
+ joinCondition: and(...innerColumnWhere)
4147
+ };
4148
+ }
4149
+ return { filter: and(...relation.sourceColumns.map((s, i) => {
4150
+ const t = relation.targetColumns[i];
4151
+ return eq(sql`${sourceTable}.${sql.identifier(s.name)}`, sql`${targetTable}.${sql.identifier(t.name)}`);
4152
+ }), relation.where ? relationsFilterToSQL(relation.isReversed ? sourceTable : targetTable, relation.where) : undefined) };
4153
+ }
4154
+ function getTableAsAliasSQL(table) {
4155
+ return sql`${table[IsAlias] ? sql`${sql`${sql.identifier(table[TableSchema] ?? "")}.`.if(table[TableSchema])}${sql.identifier(table[OriginalName])} as ${table}` : table}`;
4156
+ }
4157
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/dialect.js
4158
+ var PgDialect = class {
4159
+ static [entityKind] = "PgDialect";
4160
+ codecs;
4161
+ mapperGenerators;
4162
+ constructor(config) {
4163
+ this.codecs = new CodecsCollection(resolvePgTypeAlias, config?.codecs);
4164
+ this.mapperGenerators = config?.useJitMappers ? {
4165
+ rows: makeJitQueryMapper,
4166
+ relationalRows: makeJitRqbMapper
4167
+ } : {
4168
+ rows: makeDefaultQueryMapper,
4169
+ relationalRows: makeDefaultRqbMapper
4170
+ };
4171
+ }
4172
+ escapeName(name2) {
4173
+ return `"${name2.replace(/"/g, '""')}"`;
4174
+ }
4175
+ escapeParam(num) {
4176
+ return `$${num + 1}`;
4177
+ }
4178
+ escapeString(str) {
4179
+ return `'${str.replace(/'/g, "''")}'`;
4180
+ }
4181
+ buildWithCTE(queries) {
4182
+ if (!queries?.length)
4183
+ return;
4184
+ const withSqlChunks = [sql`with `];
4185
+ for (const [i, w] of queries.entries()) {
4186
+ withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
4187
+ if (i < queries.length - 1)
4188
+ withSqlChunks.push(sql`, `);
4189
+ }
4190
+ withSqlChunks.push(sql` `);
4191
+ return sql.join(withSqlChunks);
4192
+ }
4193
+ buildDeleteQuery({ table, where, returning, withList, comment, ignoreSelectionCastCodecs }) {
4194
+ const withSql = this.buildWithCTE(withList);
4195
+ const returningSql = returning ? sql` returning ${this.buildSelection(returning, {
4196
+ isSingleTable: true,
4197
+ ignoreCastCodecs: ignoreSelectionCastCodecs
4198
+ })}` : undefined;
4199
+ return sql`${withSql}delete from ${table}${where ? sql` where ${where}` : undefined}${returningSql}${comment !== undefined ? sql` ${comment}` : undefined}`;
4200
+ }
4201
+ buildUpdateSet(table, set) {
4202
+ const tableColumns = table[Table.Symbol.Columns];
4203
+ const columnNames = Object.keys(tableColumns).filter((colName) => set[colName] !== undefined || tableColumns[colName]?.onUpdateFn !== undefined);
4204
+ const setLength = columnNames.length;
4205
+ return sql.join(columnNames.flatMap((colName, i) => {
4206
+ const col = tableColumns[colName];
4207
+ const onUpdateFnResult = col.onUpdateFn?.();
4208
+ const value = set[colName] ?? (is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col));
4209
+ const res = sql`${sql.identifier(col.name)} = ${value}`;
4210
+ if (i < setLength - 1)
4211
+ return [res, sql.raw(", ")];
4212
+ return [res];
4213
+ }));
4214
+ }
4215
+ buildUpdateQuery({ table, set, where, returning, withList, from, joins, comment, ignoreSelectionCastCodecs }) {
4216
+ const withSql = this.buildWithCTE(withList);
4217
+ const tableName = table[PgTable.Symbol.Name];
4218
+ const tableSchema = table[PgTable.Symbol.Schema];
4219
+ const origTableName = table[PgTable.Symbol.OriginalName];
4220
+ const alias = tableName === origTableName ? undefined : tableName;
4221
+ const tableSql = sql`${tableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}`;
4222
+ const setSql = this.buildUpdateSet(table, set);
4223
+ const fromSql = from && sql.join([sql.raw(" from "), this.buildFromTable(from)]);
4224
+ const joinsSql = this.buildJoins(joins);
4225
+ const returningSql = returning ? sql` returning ${this.buildSelection(returning, {
4226
+ isSingleTable: !from,
4227
+ ignoreCastCodecs: ignoreSelectionCastCodecs
4228
+ })}` : undefined;
4229
+ return sql`${withSql}update ${tableSql} set ${setSql}${fromSql}${joinsSql}${where ? sql` where ${where}` : undefined}${returningSql}${comment !== undefined ? sql` ${comment}` : undefined}`;
4230
+ }
4231
+ buildSelection(fields, { isSingleTable = false, ignoreCastCodecs = false } = {}) {
4232
+ const columnsLen = fields.length;
4233
+ const chunks = fields.flatMap(({ field }, i) => {
4234
+ const chunk = [];
4235
+ if (is(field, SQL.Aliased) && field.isSelectionField) {
4236
+ if (!isSingleTable && field.origin !== undefined)
4237
+ chunk.push(sql.identifier(field.origin), sql.raw("."));
4238
+ chunk.push(sql.identifier(field.fieldAlias));
4239
+ } else if (is(field, SQL.Aliased) || is(field, SQL)) {
4240
+ const query = is(field, SQL.Aliased) ? field.sql : field;
4241
+ if (isSingleTable) {
4242
+ const newSql = new SQL(query.queryChunks.map((c) => {
4243
+ if (is(c, PgColumn))
4244
+ return sql.identifier(c.name);
4245
+ return c;
4246
+ }));
4247
+ chunk.push(query.shouldInlineParams ? newSql.inlineParams() : newSql);
4248
+ } else
4249
+ chunk.push(query);
4250
+ if (is(field, SQL.Aliased))
4251
+ chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
4252
+ } else if (is(field, Column)) {
4253
+ let name2;
4254
+ if (isSingleTable)
4255
+ name2 = field.isAlias ? sql.identifier(getOriginalColumnFromAlias(field).name) : sql.identifier(field.name);
4256
+ else
4257
+ name2 = field.isAlias ? getOriginalColumnFromAlias(field) : field;
4258
+ const casted = ignoreCastCodecs ? name2 : this.codecs.apply(field, "cast", name2);
4259
+ chunk.push(field.isAlias ? sql`${casted} as ${field}` : casted);
4260
+ } else if (is(field, Subquery)) {
4261
+ const entries = Object.entries(field._.selectedFields);
4262
+ if (entries.length === 1) {
4263
+ const entry = entries[0][1];
4264
+ const fieldDecoder = is(entry, SQL) ? entry.decoder : is(entry, Column) ? { mapFromDriverValue: (v) => entry.mapFromDriverValue(v) } : entry.sql.decoder;
4265
+ if (fieldDecoder)
4266
+ field._.sql.decoder = fieldDecoder;
4267
+ }
4268
+ chunk.push(field);
4269
+ }
4270
+ if (i < columnsLen - 1)
4271
+ chunk.push(sql`, `);
4272
+ return chunk;
4273
+ });
4274
+ return sql.join(chunks);
4275
+ }
4276
+ buildJoins(joins) {
4277
+ if (!joins || joins.length === 0)
4278
+ return;
4279
+ const joinsArray = [];
4280
+ for (const [index, joinMeta] of joins.entries()) {
4281
+ if (index === 0)
4282
+ joinsArray.push(sql` `);
4283
+ const table = joinMeta.table;
4284
+ const lateralSql = joinMeta.lateral ? sql` lateral` : undefined;
4285
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : undefined;
4286
+ if (is(table, PgTable)) {
4287
+ const tableName = table[PgTable.Symbol.Name];
4288
+ const tableSchema = table[PgTable.Symbol.Schema];
4289
+ const origTableName = table[PgTable.Symbol.OriginalName];
4290
+ const alias = tableName === origTableName ? undefined : joinMeta.alias;
4291
+ joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`);
4292
+ } else if (is(table, View)) {
4293
+ const viewName = table[ViewBaseConfig].name;
4294
+ const viewSchema = table[ViewBaseConfig].schema;
4295
+ const origViewName = table[ViewBaseConfig].originalName;
4296
+ const alias = viewName === origViewName ? undefined : joinMeta.alias;
4297
+ joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : undefined}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`);
4298
+ } else
4299
+ joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table}${onSql}`);
4300
+ if (index < joins.length - 1)
4301
+ joinsArray.push(sql` `);
4302
+ }
4303
+ return sql.join(joinsArray);
4304
+ }
4305
+ buildFromTable(table) {
4306
+ if (is(table, Table) && table[Table.Symbol.IsAlias]) {
4307
+ let fullName = sql`${sql.identifier(table[Table.Symbol.OriginalName])}`;
4308
+ if (table[Table.Symbol.Schema])
4309
+ fullName = sql`${sql.identifier(table[Table.Symbol.Schema])}.${fullName}`;
4310
+ return sql`${fullName} ${sql.identifier(table[Table.Symbol.Name])}`;
4311
+ }
4312
+ if (is(table, View) && table[ViewBaseConfig].isAlias) {
4313
+ let fullName = sql`${sql.identifier(table[ViewBaseConfig].originalName)}`;
4314
+ if (table[ViewBaseConfig].schema)
4315
+ fullName = sql`${sql.identifier(table[ViewBaseConfig].schema)}.${fullName}`;
4316
+ return sql`${fullName} ${sql.identifier(table[ViewBaseConfig].name)}`;
4317
+ }
4318
+ return table;
4319
+ }
4320
+ buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, lockingClause, distinct, setOperators, comment, ignoreSelectionCastCodecs }) {
4321
+ const fieldsList = fieldsFlat ?? orderSelectedFields(fields, undefined, this.codecs);
4322
+ for (const f of fieldsList)
4323
+ if (is(f.field, Column) && getTableName(f.field.table) !== (is(table, Subquery) ? table._.alias : is(table, PgViewBase) ? table[ViewBaseConfig].name : is(table, SQL) ? undefined : getTableName(table)) && !((table2) => joins?.some(({ alias }) => alias === (table2[Table.Symbol.IsAlias] ? getTableName(table2) : table2[Table.Symbol.BaseName])))(f.field.table)) {
4324
+ const tableName = getTableName(f.field.table);
4325
+ throw new Error(`Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`);
4326
+ }
4327
+ const isSingleTable = !joins || joins.length === 0;
4328
+ const withSql = this.buildWithCTE(withList);
4329
+ let distinctSql;
4330
+ if (distinct)
4331
+ distinctSql = distinct === true ? sql` distinct` : sql` distinct on (${sql.join(distinct.on, sql`, `)})`;
4332
+ const selection = this.buildSelection(fieldsList, {
4333
+ isSingleTable,
4334
+ ignoreCastCodecs: ignoreSelectionCastCodecs
4335
+ });
4336
+ const tableSql = this.buildFromTable(table);
4337
+ const joinsSql = this.buildJoins(joins);
4338
+ const whereSql = where ? sql` where ${where}` : undefined;
4339
+ const havingSql = having ? sql` having ${having}` : undefined;
4340
+ let orderBySql;
4341
+ if (orderBy && orderBy.length > 0)
4342
+ orderBySql = sql` order by ${sql.join(orderBy, sql`, `)}`;
4343
+ let groupBySql;
4344
+ if (groupBy && groupBy.length > 0)
4345
+ groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`;
4346
+ const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : undefined;
4347
+ const offsetSql = offset ? sql` offset ${offset}` : undefined;
4348
+ const lockingClauseSql = sql.empty();
4349
+ if (lockingClause) {
4350
+ const clauseSql = sql` for ${sql.raw(lockingClause.strength)}`;
4351
+ if (lockingClause.config.of)
4352
+ clauseSql.append(sql` of ${sql.join(Array.isArray(lockingClause.config.of) ? lockingClause.config.of.map((it) => sql.identifier(it[PgTable.Symbol.Name])) : [sql.identifier(lockingClause.config.of[PgTable.Symbol.Name])], sql`, `)}`);
4353
+ if (lockingClause.config.noWait)
4354
+ clauseSql.append(sql` nowait`);
4355
+ else if (lockingClause.config.skipLocked)
4356
+ clauseSql.append(sql` skip locked`);
4357
+ lockingClauseSql.append(clauseSql);
4358
+ }
4359
+ const finalQuery = sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClauseSql}${comment !== undefined ? sql` ${comment}` : undefined}`;
4360
+ if (setOperators.length > 0)
4361
+ return this.buildSetOperations(finalQuery, setOperators);
4362
+ return finalQuery;
4363
+ }
4364
+ buildSetOperations(leftSelect, setOperators) {
4365
+ const [setOperator, ...rest] = setOperators;
4366
+ if (!setOperator)
4367
+ throw new Error("Cannot pass undefined values to any set operator");
4368
+ if (rest.length === 0)
4369
+ return this.buildSetOperationQuery({
4370
+ leftSelect,
4371
+ setOperator
4372
+ });
4373
+ return this.buildSetOperations(this.buildSetOperationQuery({
4374
+ leftSelect,
4375
+ setOperator
4376
+ }), rest);
4377
+ }
4378
+ buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset } }) {
4379
+ const leftChunk = sql`(${leftSelect.getSQL()}) `;
4380
+ const rightChunk = sql`(${rightSelect.getSQL()})`;
4381
+ let orderBySql;
4382
+ if (orderBy && orderBy.length > 0) {
4383
+ const orderByValues = [];
4384
+ for (const singleOrderBy of orderBy)
4385
+ if (is(singleOrderBy, PgColumn))
4386
+ orderByValues.push(sql.identifier(singleOrderBy.name));
4387
+ else if (is(singleOrderBy, SQL)) {
4388
+ for (let i = 0;i < singleOrderBy.queryChunks.length; i++) {
4389
+ const chunk = singleOrderBy.queryChunks[i];
4390
+ if (is(chunk, PgColumn))
4391
+ singleOrderBy.queryChunks[i] = sql.identifier(chunk.name);
4392
+ }
4393
+ orderByValues.push(sql`${singleOrderBy}`);
4394
+ } else
4395
+ orderByValues.push(sql`${singleOrderBy}`);
4396
+ orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;
4397
+ }
4398
+ const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : undefined;
4399
+ const operatorChunk = sql.raw(`${type} ${isAll ? "all " : ""}`);
4400
+ const offsetSql = offset ? sql` offset ${offset}` : undefined;
4401
+ return sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
4402
+ }
4403
+ buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_, comment, ignoreSelectionCastCodecs }) {
4404
+ const valuesSqlList = [];
4405
+ const columns = table[Table.Symbol.Columns];
4406
+ const colEntries = Object.entries(columns).filter(([_, col]) => !col.shouldDisableInsert());
4407
+ const insertOrder = colEntries.map(([, column]) => sql.identifier(column.name));
4408
+ if (select) {
4409
+ const select2 = valuesOrSelect;
4410
+ if (is(select2, SQL))
4411
+ valuesSqlList.push(select2);
4412
+ else
4413
+ valuesSqlList.push(select2.getSQL());
4414
+ } else {
4415
+ const values = valuesOrSelect;
4416
+ valuesSqlList.push(sql.raw("values "));
4417
+ for (const [valueIndex, value] of values.entries()) {
4418
+ const valueList = [];
4419
+ for (const [fieldName, col] of colEntries) {
4420
+ const colValue = value[fieldName];
4421
+ if (colValue === undefined || is(colValue, Param) && colValue.value === undefined)
4422
+ if (col.defaultFn !== undefined) {
4423
+ const defaultFnResult = col.defaultFn();
4424
+ const defaultValue = is(defaultFnResult, SQL) ? defaultFnResult : sql.param(defaultFnResult, col);
4425
+ valueList.push(defaultValue);
4426
+ } else if (!col.default && col.onUpdateFn !== undefined) {
4427
+ const onUpdateFnResult = col.onUpdateFn();
4428
+ const newValue = is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col);
4429
+ valueList.push(newValue);
4430
+ } else
4431
+ valueList.push(sql`default`);
4432
+ else
4433
+ valueList.push(colValue);
4434
+ }
4435
+ valuesSqlList.push(valueList);
4436
+ if (valueIndex < values.length - 1)
4437
+ valuesSqlList.push(sql`, `);
4438
+ }
4439
+ }
4440
+ const withSql = this.buildWithCTE(withList);
4441
+ const valuesSql = sql.join(valuesSqlList);
4442
+ const returningSql = returning ? sql` returning ${this.buildSelection(returning, {
4443
+ isSingleTable: true,
4444
+ ignoreCastCodecs: ignoreSelectionCastCodecs
4445
+ })}` : undefined;
4446
+ const onConflictSql = onConflict ? sql` on conflict ${onConflict}` : undefined;
4447
+ return sql`${withSql}insert into ${table} ${insertOrder} ${overridingSystemValue_ === true ? sql`overriding system value ` : undefined}${valuesSql}${onConflictSql}${returningSql}${comment !== undefined ? sql` ${comment}` : undefined}`;
4448
+ }
4449
+ buildRefreshMaterializedViewQuery({ view, concurrently, withNoData }) {
4450
+ return sql`refresh materialized view${concurrently ? sql` concurrently` : undefined} ${view}${withNoData ? sql` with no data` : undefined}`;
4451
+ }
4452
+ sqlToQuery(sql2, invokeSource) {
4453
+ return sql2.toQuery({
4454
+ escapeName: this.escapeName,
4455
+ escapeParam: this.escapeParam,
4456
+ escapeString: this.escapeString,
4457
+ codecs: this.codecs,
4458
+ invokeSource
4459
+ });
4460
+ }
4461
+ _sqlToQuery(sql2) {
4462
+ return sql2.toQuery({
4463
+ escapeName: this.escapeName,
4464
+ escapeParam: this.escapeParam,
4465
+ escapeString: this.escapeString,
4466
+ codecs: this.codecs,
4467
+ tagged: true
4468
+ });
4469
+ }
4470
+ nestedSelectionerror() {
4471
+ throw new DrizzleError({ message: `Views with nested selections are not supported by the relational query builder` });
4472
+ }
4473
+ buildRqbColumn(table, column, key, inJson) {
4474
+ if (is(column, Column)) {
4475
+ const name2 = sql`${table}.${sql.identifier(column.name)}`;
4476
+ return sql`${inJson && column.jsonSelectIdentifier ? column.jsonSelectIdentifier(name2, sql, column.dimensions) : this.codecs.apply(column, inJson ? "castInJson" : "cast", name2)} as ${sql.identifier(key)}`;
4477
+ }
4478
+ return sql`${table}.${is(column, SQL.Aliased) ? sql.identifier(column.fieldAlias) : isSQLWrapper(column) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
4479
+ }
4480
+ unwrapAllColumns = (table, selection, inJson) => {
4481
+ return sql.join(Object.entries(table[TableColumns]).map(([k, v]) => {
4482
+ selection.push(is(v, Column) ? {
4483
+ key: k,
4484
+ codec: this.codecs.get(v, inJson ? "normalizeInJson" : "normalize"),
4485
+ arrayDimensions: v.dimensions,
4486
+ field: v
4487
+ } : {
4488
+ key: k,
4489
+ field: v
4490
+ });
4491
+ return this.buildRqbColumn(table, v, k, inJson);
4492
+ }), sql`, `);
4493
+ };
4494
+ buildColumns = (table, selection, inJson, config) => config?.columns ? (() => {
4495
+ const entries = Object.entries(config.columns);
4496
+ const columnContainer = table[TableColumns];
4497
+ const columnIdentifiers = [];
4498
+ let colSelectionMode;
4499
+ for (const [k, v] of entries) {
4500
+ if (v === undefined)
4501
+ continue;
4502
+ colSelectionMode = colSelectionMode || v;
4503
+ if (v) {
4504
+ const column = columnContainer[k];
4505
+ columnIdentifiers.push(this.buildRqbColumn(table, column, k, inJson));
4506
+ selection.push(is(column, Column) ? {
4507
+ key: k,
4508
+ codec: this.codecs.get(column, inJson ? "normalizeInJson" : "normalize"),
4509
+ arrayDimensions: column.dimensions,
4510
+ field: column
4511
+ } : {
4512
+ key: k,
4513
+ field: column
4514
+ });
4515
+ }
4516
+ }
4517
+ if (colSelectionMode === false)
4518
+ for (const [k, v] of Object.entries(columnContainer)) {
4519
+ if (config.columns[k] === false)
4520
+ continue;
4521
+ columnIdentifiers.push(this.buildRqbColumn(table, v, k, inJson));
4522
+ selection.push(is(v, Column) ? {
4523
+ key: k,
4524
+ codec: this.codecs.get(v, inJson ? "normalizeInJson" : "normalize"),
4525
+ arrayDimensions: v.dimensions,
4526
+ field: v
4527
+ } : {
4528
+ key: k,
4529
+ field: v
4530
+ });
4531
+ }
4532
+ return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : undefined;
4533
+ })() : this.unwrapAllColumns(table, selection, inJson);
4534
+ buildRelationalQuery({ schema, table, tableConfig, queryConfig: config, relationWhere, mode, errorPath, depth, throughJoin, nested }) {
4535
+ const selection = [];
4536
+ const isSingle = mode === "first";
4537
+ const params = config === true ? undefined : config;
4538
+ const currentPath = errorPath ?? "";
4539
+ const currentDepth = depth ?? 0;
4540
+ if (!currentDepth)
4541
+ table = aliasedTable(table, `d${currentDepth}`);
4542
+ const limit = isSingle ? 1 : params?.limit;
4543
+ const offset = params?.offset;
4544
+ const where = params?.where && relationWhere ? and(relationsFilterToSQL(table, params.where, tableConfig.relations, schema), relationWhere) : params?.where ? relationsFilterToSQL(table, params.where, tableConfig.relations, schema) : relationWhere;
4545
+ const order = params?.orderBy ? relationsOrderToSQL(table, params.orderBy) : undefined;
4546
+ const columns = this.buildColumns(table, selection, !!nested, params);
4547
+ const extras = params?.extras ? relationExtrasToSQL(table, params.extras) : undefined;
4548
+ if (extras)
4549
+ selection.push(...extras.selection);
4550
+ const selectionArr = columns ? [columns] : [];
4551
+ if (extras?.sql)
4552
+ selectionArr.push(extras.sql);
4553
+ const joins = params ? (() => {
4554
+ const { with: joins2 } = params;
4555
+ if (!joins2)
4556
+ return;
4557
+ const withEntries = Object.entries(joins2).filter(([_, v]) => v);
4558
+ if (!withEntries.length)
4559
+ return;
4560
+ return sql.join(withEntries.map(([k, join]) => {
4561
+ const relation = tableConfig.relations[k];
4562
+ const isSingle2 = is(relation, One);
4563
+ const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
4564
+ const throughTable = relation.throughTable ? aliasedTable(relation.throughTable, `tr${currentDepth}`) : undefined;
4565
+ const { filter, joinCondition } = relationToSQL(relation, table, targetTable, throughTable);
4566
+ selectionArr.push(sql`${sql.identifier(k)}.${sql.identifier("r")} as ${sql.identifier(k)}`);
4567
+ const throughJoin2 = throughTable ? sql` inner join ${getTableAsAliasSQL(throughTable)} on ${joinCondition}` : undefined;
4568
+ const innerQuery = this.buildRelationalQuery({
4569
+ table: targetTable,
4570
+ mode: isSingle2 ? "first" : "many",
4571
+ schema,
4572
+ queryConfig: join,
4573
+ tableConfig: schema[relation.targetTableName],
4574
+ relationWhere: filter,
4575
+ errorPath: `${currentPath.length ? `${currentPath}.` : ""}${k}`,
4576
+ depth: currentDepth + 1,
4577
+ throughJoin: throughJoin2,
4578
+ nested: true
4579
+ });
4580
+ selection.push({
4581
+ field: targetTable,
4582
+ key: k,
4583
+ selection: innerQuery.selection,
4584
+ isArray: !isSingle2,
4585
+ isOptional: (relation.optional ?? false) || join !== true && !!join.where
4586
+ });
4587
+ return sql`left join lateral(select ${isSingle2 ? sql`row_to_json(${sql.identifier("t")}.*) ${sql.identifier("r")}` : sql`coalesce(json_agg(row_to_json(${sql.identifier("t")}.*)), '[]') as ${sql.identifier("r")}`} from (${innerQuery.sql}) as ${sql.identifier("t")}) as ${sql.identifier(k)} on true`;
4588
+ }), sql` `);
4589
+ })() : undefined;
4590
+ if (!selectionArr.length)
4591
+ throw new DrizzleError({ message: `No fields selected for table "${tableConfig.name}"${currentPath ? ` ("${currentPath}")` : ""}` });
4592
+ const selectionSet = sql.join(selectionArr.filter((e) => e !== undefined), sql`, `);
4593
+ const comment = config !== true && config?.comment ? sql.comment(config.comment) : undefined;
4594
+ return {
4595
+ sql: sql`select ${selectionSet} from ${getTableAsAliasSQL(table)}${throughJoin}${joins ? sql` ${joins}` : undefined}${where ? sql` where ${where}` : undefined}${order ? sql` order by ${order}` : undefined}${limit !== undefined ? sql` limit ${limit}` : undefined}${offset !== undefined ? sql` offset ${offset}` : undefined}${comment ? sql` ${comment}` : undefined}`,
4596
+ selection
4597
+ };
4598
+ }
4599
+ };
4600
+
4601
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/query-builders/query-builder.js
4602
+ var QueryBuilder = class {
4603
+ static [entityKind] = "PgQueryBuilder";
4604
+ dialect;
4605
+ dialectConfig;
4606
+ constructor(dialect) {
4607
+ this.dialect = is(dialect, PgDialect) ? dialect : undefined;
4608
+ this.dialectConfig = is(dialect, PgDialect) ? undefined : dialect;
4609
+ }
4610
+ $with = (alias, selection) => {
4611
+ const queryBuilder = this;
4612
+ const as = (qb) => {
4613
+ if (typeof qb === "function")
4614
+ qb = qb(queryBuilder);
4615
+ const sql2 = ("withoutSelectionCastCodecs" in qb ? qb.withoutSelectionCastCodecs() : qb).getSQL();
4616
+ return new Proxy(new WithSubquery(sql2, selection ?? ("getSelectedFields" in qb ? qb.getSelectedFields() ?? {} : {}), alias, true, sql2.usedTables ?? []), new SelectionProxyHandler({
4617
+ alias,
4618
+ sqlAliasedBehavior: "alias",
4619
+ sqlBehavior: "error"
4620
+ }));
4621
+ };
4622
+ return { as };
4623
+ };
4624
+ with(...queries) {
4625
+ const self = this;
4626
+ function select(fields) {
4627
+ return new PgSelectBase({
4628
+ fields: fields ?? undefined,
4629
+ session: undefined,
4630
+ dialect: self.getDialect(),
4631
+ withList: queries
4632
+ });
4633
+ }
4634
+ function selectDistinct(fields) {
4635
+ return new PgSelectBase({
4636
+ fields: fields ?? undefined,
4637
+ session: undefined,
4638
+ dialect: self.getDialect(),
4639
+ distinct: true
4640
+ });
4641
+ }
4642
+ function selectDistinctOn(on, fields) {
4643
+ return new PgSelectBase({
4644
+ fields: fields ?? undefined,
4645
+ session: undefined,
4646
+ dialect: self.getDialect(),
4647
+ distinct: { on }
4648
+ });
4649
+ }
4650
+ return {
4651
+ select,
4652
+ selectDistinct,
4653
+ selectDistinctOn
4654
+ };
4655
+ }
4656
+ select(fields) {
4657
+ return new PgSelectBase({
4658
+ fields: fields ?? undefined,
4659
+ session: undefined,
4660
+ dialect: this.getDialect()
4661
+ });
4662
+ }
4663
+ selectDistinct(fields) {
4664
+ return new PgSelectBase({
4665
+ fields: fields ?? undefined,
4666
+ session: undefined,
4667
+ dialect: this.getDialect(),
4668
+ distinct: true
4669
+ });
4670
+ }
4671
+ selectDistinctOn(on, fields) {
4672
+ return new PgSelectBase({
4673
+ fields: fields ?? undefined,
4674
+ session: undefined,
4675
+ dialect: this.getDialect(),
4676
+ distinct: { on }
4677
+ });
4678
+ }
4679
+ getDialect() {
4680
+ if (!this.dialect)
4681
+ this.dialect = new PgDialect(this.dialectConfig);
4682
+ return this.dialect;
4683
+ }
4684
+ };
4685
+
4686
+ // node_modules/.bun/drizzle-orm@1.0.0-rc.2+ce09d0b955e84444/node_modules/drizzle-orm/pg-core/view.js
4687
+ var DefaultViewBuilderCore = class {
4688
+ static [entityKind] = "PgDefaultViewBuilderCore";
4689
+ constructor(name2, schema) {
4690
+ this.name = name2;
4691
+ this.schema = schema;
4692
+ }
4693
+ config = {};
4694
+ with(config) {
4695
+ this.config.with = config;
4696
+ return this;
4697
+ }
4698
+ };
4699
+ var ViewBuilder = class extends DefaultViewBuilderCore {
4700
+ static [entityKind] = "PgViewBuilder";
4701
+ as(qb) {
4702
+ if (typeof qb === "function")
4703
+ qb = qb(new QueryBuilder);
4704
+ const selectionProxy = new SelectionProxyHandler({
4705
+ alias: this.name,
4706
+ sqlBehavior: "error",
4707
+ sqlAliasedBehavior: "alias",
4708
+ replaceOriginalName: true
4709
+ });
4710
+ const aliasedSelection = new Proxy(qb.getSelectedFields(), selectionProxy);
4711
+ return new Proxy(new PgView({
4712
+ pgConfig: this.config,
4713
+ config: {
4714
+ name: this.name,
4715
+ schema: this.schema,
4716
+ selectedFields: aliasedSelection,
4717
+ query: qb.withoutSelectionCastCodecs().getSQL().inlineParams()
4718
+ }
4719
+ }), selectionProxy);
4720
+ }
4721
+ };
4722
+ var ManualViewBuilder = class extends DefaultViewBuilderCore {
4723
+ static [entityKind] = "PgManualViewBuilder";
4724
+ columns;
4725
+ constructor(name2, columns, schema, casing) {
4726
+ super(name2, schema);
4727
+ this.columns = getTableColumns(pgTableWithSchema(name2, columns, undefined, schema, casing));
4728
+ }
4729
+ existing() {
4730
+ return new Proxy(new PgView({
4731
+ pgConfig: undefined,
4732
+ config: {
4733
+ name: this.name,
4734
+ schema: this.schema,
4735
+ selectedFields: this.columns,
4736
+ query: undefined
4737
+ }
4738
+ }), new SelectionProxyHandler({
4739
+ alias: this.name,
4740
+ sqlBehavior: "error",
4741
+ sqlAliasedBehavior: "alias",
4742
+ replaceOriginalName: true
4743
+ }));
4744
+ }
4745
+ as(query) {
4746
+ return new Proxy(new PgView({
4747
+ pgConfig: this.config,
4748
+ config: {
4749
+ name: this.name,
4750
+ schema: this.schema,
4751
+ selectedFields: this.columns,
4752
+ query: query.inlineParams()
4753
+ }
4754
+ }), new SelectionProxyHandler({
4755
+ alias: this.name,
4756
+ sqlBehavior: "error",
4757
+ sqlAliasedBehavior: "alias",
4758
+ replaceOriginalName: true
4759
+ }));
4760
+ }
4761
+ };
4762
+ var MaterializedViewBuilderCore = class {
4763
+ static [entityKind] = "PgMaterializedViewBuilderCore";
4764
+ constructor(name2, schema) {
4765
+ this.name = name2;
4766
+ this.schema = schema;
4767
+ }
4768
+ config = {};
4769
+ using(using) {
4770
+ this.config.using = using;
4771
+ return this;
4772
+ }
4773
+ with(config) {
4774
+ this.config.with = config;
4775
+ return this;
4776
+ }
4777
+ tablespace(tablespace) {
4778
+ this.config.tablespace = tablespace;
4779
+ return this;
4780
+ }
4781
+ withNoData() {
4782
+ this.config.withNoData = true;
4783
+ return this;
4784
+ }
4785
+ };
4786
+ var MaterializedViewBuilder = class extends MaterializedViewBuilderCore {
4787
+ static [entityKind] = "PgMaterializedViewBuilder";
4788
+ as(qb) {
4789
+ if (typeof qb === "function")
4790
+ qb = qb(new QueryBuilder);
4791
+ const selectionProxy = new SelectionProxyHandler({
4792
+ alias: this.name,
4793
+ sqlBehavior: "error",
4794
+ sqlAliasedBehavior: "alias",
4795
+ replaceOriginalName: true
4796
+ });
4797
+ const aliasedSelection = new Proxy(qb.getSelectedFields(), selectionProxy);
4798
+ return new Proxy(new PgMaterializedView({
4799
+ pgConfig: {
4800
+ with: this.config.with,
4801
+ using: this.config.using,
4802
+ tablespace: this.config.tablespace,
4803
+ withNoData: this.config.withNoData
4804
+ },
4805
+ config: {
4806
+ name: this.name,
4807
+ schema: this.schema,
4808
+ selectedFields: aliasedSelection,
4809
+ query: qb.withoutSelectionCastCodecs().getSQL().inlineParams()
4810
+ }
4811
+ }), selectionProxy);
4812
+ }
4813
+ };
4814
+ var ManualMaterializedViewBuilder = class extends MaterializedViewBuilderCore {
4815
+ static [entityKind] = "PgManualMaterializedViewBuilder";
4816
+ columns;
4817
+ constructor(name2, columns, schema, casing) {
4818
+ super(name2, schema);
4819
+ this.columns = getTableColumns(pgTableWithSchema(name2, columns, undefined, schema, casing));
4820
+ }
4821
+ existing() {
4822
+ return new Proxy(new PgMaterializedView({
4823
+ pgConfig: {
4824
+ tablespace: this.config.tablespace,
4825
+ using: this.config.using,
4826
+ with: this.config.with,
4827
+ withNoData: this.config.withNoData
4828
+ },
4829
+ config: {
4830
+ name: this.name,
4831
+ schema: this.schema,
4832
+ selectedFields: this.columns,
4833
+ query: undefined
4834
+ }
4835
+ }), new SelectionProxyHandler({
4836
+ alias: this.name,
4837
+ sqlBehavior: "error",
4838
+ sqlAliasedBehavior: "alias",
4839
+ replaceOriginalName: true
4840
+ }));
4841
+ }
4842
+ as(query) {
4843
+ return new Proxy(new PgMaterializedView({
4844
+ pgConfig: {
4845
+ tablespace: this.config.tablespace,
4846
+ using: this.config.using,
4847
+ with: this.config.with,
4848
+ withNoData: this.config.withNoData
4849
+ },
4850
+ config: {
4851
+ name: this.name,
4852
+ schema: this.schema,
4853
+ selectedFields: this.columns,
4854
+ query: query.inlineParams()
4855
+ }
4856
+ }), new SelectionProxyHandler({
4857
+ alias: this.name,
4858
+ sqlBehavior: "error",
4859
+ sqlAliasedBehavior: "alias",
4860
+ replaceOriginalName: true
4861
+ }));
4862
+ }
4863
+ };
4864
+ var PgView = class extends PgViewBase {
4865
+ static [entityKind] = "PgView";
4866
+ [PgViewConfig];
4867
+ constructor({ pgConfig, config }) {
4868
+ super(config);
4869
+ if (pgConfig)
4870
+ this[PgViewConfig] = { with: pgConfig.with };
4871
+ }
4872
+ };
4873
+ var PgMaterializedView = class extends PgViewBase {
4874
+ static [entityKind] = "PgMaterializedView";
4875
+ [PgMaterializedViewConfig];
4876
+ constructor({ pgConfig, config }) {
4877
+ super(config);
4878
+ this[PgMaterializedViewConfig] = {
4879
+ with: pgConfig?.with,
4880
+ using: pgConfig?.using,
4881
+ tablespace: pgConfig?.tablespace,
4882
+ withNoData: pgConfig?.withNoData
4883
+ };
4884
+ }
4885
+ };
4886
+ function pgViewWithSchema(name2, selection, schema, casing) {
4887
+ if (selection)
4888
+ return new ManualViewBuilder(name2, selection, schema, casing);
4889
+ return new ViewBuilder(name2, schema);
4890
+ }
4891
+ function pgMaterializedViewWithSchema(name2, selection, schema, casing) {
4892
+ if (selection)
4893
+ return new ManualMaterializedViewBuilder(name2, selection, schema, casing);
4894
+ return new MaterializedViewBuilder(name2, schema);
4895
+ }
4896
+ function pgViewWithCasing(casing) {
4897
+ return (name2, columns) => pgViewWithSchema(name2, columns, undefined, casing);
4898
+ }
4899
+ function pgMaterializedViewWithCasing(casing) {
4900
+ return (name2, columns) => pgMaterializedViewWithSchema(name2, columns, undefined, casing);
4901
+ }
4902
+ var pgView = pgViewWithCasing(undefined);
4903
+ var pgMaterializedView = pgMaterializedViewWithCasing(undefined);
4904
+
4905
+ // node_modules/drizzle-orm/utils.js
4906
+ var FnConstructor2 = Object.getPrototypeOf(() => null).constructor;
4907
+ function getColumns(table) {
4908
+ return is(table, Table) ? table[Table.Symbol.Columns] : is(table, View) ? table[ViewBaseConfig].selectedFields : table._.selectedFields;
4909
+ }
4910
+ var textDecoder2 = typeof TextDecoder === "undefined" ? null : new TextDecoder;
4911
+ var CONSTANTS2 = {
4912
+ INT8_MIN: -128,
4913
+ INT8_MAX: 127,
4914
+ INT8_UNSIGNED_MAX: 255,
4915
+ INT16_MIN: -32768,
4916
+ INT16_MAX: 32767,
4917
+ INT16_UNSIGNED_MAX: 65535,
4918
+ INT24_MIN: -8388608,
4919
+ INT24_MAX: 8388607,
4920
+ INT24_UNSIGNED_MAX: 16777215,
4921
+ INT32_MIN: -2147483648,
4922
+ INT32_MAX: 2147483647,
4923
+ INT32_UNSIGNED_MAX: 4294967295,
4924
+ INT48_MIN: -140737488355328,
4925
+ INT48_MAX: 140737488355327,
4926
+ INT48_UNSIGNED_MAX: 281474976710655,
4927
+ INT64_MIN: -9223372036854775808n,
4928
+ INT64_MAX: 9223372036854775807n,
4929
+ INT64_UNSIGNED_MAX: 18446744073709551615n
4930
+ };
4931
+
57
4932
  // packages/contracts/src/registry.ts
58
- import {
59
- bigint,
60
- getTableConfig,
61
- pgTable,
62
- pgView
63
- } from "drizzle-orm/pg-core";
64
- import { varchar } from "drizzle-orm/pg-core";
65
- import { getColumns } from "drizzle-orm/utils";
66
4933
  var syncRegistrySchemaSymbol = Symbol.for("@pgxsinkit/contracts/syncRegistrySchema");
67
4934
  function viewColumnsForProjection(columns, omittedColumns) {
68
4935
  if (omittedColumns.length === 0) {
@@ -309,8 +5176,6 @@ var batchMutationAckSchema = z2.object({
309
5176
  acks: z2.array(mutationAckSchema)
310
5177
  }).strict();
311
5178
  // packages/contracts/src/supabase-rls.ts
312
- import { sql } from "drizzle-orm";
313
- import { pgPolicy } from "drizzle-orm/pg-core";
314
5179
  var defaultOwnerSqlColumn = "owner_id";
315
5180
  var defaultOwnerPropertyKey = "ownerId";
316
5181
  var defaultAuthenticatedRoleName = "authenticated";
@@ -442,4 +5307,4 @@ export {
442
5307
  attachSyncRegistrySchema
443
5308
  };
444
5309
 
445
- //# debugId=99510E79F7B1E4A864756E2164756E21
5310
+ //# debugId=78E5FFF5E5875B6764756E2164756E21