@coffre/cli 0.1.1 → 0.1.3
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/README.md +4 -1
- package/dist/access-CO1kGjWW.js +74 -0
- package/dist/connect-BONR52al.js +770 -0
- package/dist/connect-BZdPYNbZ.js +2 -0
- package/dist/esm-B69mMLcR.js +2 -0
- package/dist/esm-Bts-esAl.js +4202 -0
- package/dist/keys-RhB7ayOY.js +726 -0
- package/dist/main.js +10 -137
- package/dist/migrations/postgres/0000_baseline.sql +505 -0
- package/dist/migrations/postgres/meta/0000_snapshot.json +1939 -0
- package/dist/migrations/postgres/meta/_journal.json +13 -0
- package/dist/migrator-W1a-ooWi.js +37 -0
- package/dist/node-postgres-BlNvYfq_.js +2 -0
- package/dist/node-postgres-_y-EeSHQ.js +2831 -0
- package/dist/portable-CPh2thNN.js +87 -0
- package/dist/relations-CJCGPRst.js +2712 -0
- package/dist/schema-sqlite-Byp7B3yI.js +1078 -0
- package/dist/setup-3OJc_VCA.js +756 -0
- package/dist/templates/node/README.md +41 -48
- package/dist/templates/node/package.json +3 -3
- package/dist/templates/node/server.env.example +5 -4
- package/dist/templates/node/src/server.ts +3 -3
- package/dist/templates/node/src/vault.ts +7 -5
- package/dist/templates/node/vault.env.example +7 -7
- package/dist/templates/workers/README.md +47 -57
- package/dist/templates/workers/app/src/worker.ts +2 -2
- package/dist/templates/workers/app/wrangler.jsonc +4 -4
- package/dist/templates/workers/package.json +4 -4
- package/dist/templates/workers/vault/src/worker.ts +8 -7
- package/dist/templates/workers/vault/wrangler.jsonc +8 -6
- package/package.json +7 -4
|
@@ -0,0 +1,2712 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/entity.js
|
|
2
|
+
const entityKind = Symbol.for("drizzle:entityKind");
|
|
3
|
+
function is(value, type) {
|
|
4
|
+
if (!value || typeof value !== "object") return false;
|
|
5
|
+
if (value instanceof type) return true;
|
|
6
|
+
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) 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.`);
|
|
7
|
+
let cls = Object.getPrototypeOf(value).constructor;
|
|
8
|
+
if (cls) while (cls) {
|
|
9
|
+
if (entityKind in cls && cls[entityKind] === type[entityKind]) return true;
|
|
10
|
+
cls = Object.getPrototypeOf(cls);
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/column.js
|
|
16
|
+
var Column = class {
|
|
17
|
+
constructor(table, config) {
|
|
18
|
+
this.table = table;
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.name = config.name;
|
|
21
|
+
this.keyAsName = config.keyAsName;
|
|
22
|
+
this.notNull = config.notNull;
|
|
23
|
+
this.default = config.default;
|
|
24
|
+
this.defaultFn = config.defaultFn;
|
|
25
|
+
this.onUpdateFn = config.onUpdateFn;
|
|
26
|
+
this.hasDefault = config.hasDefault;
|
|
27
|
+
this.primary = config.primaryKey;
|
|
28
|
+
this.isUnique = config.isUnique;
|
|
29
|
+
this.uniqueName = config.uniqueName;
|
|
30
|
+
this.uniqueType = config.uniqueType;
|
|
31
|
+
this.dataType = config.dataType;
|
|
32
|
+
this.columnType = config.columnType;
|
|
33
|
+
this.generated = config.generated;
|
|
34
|
+
this.generatedIdentity = config.generatedIdentity;
|
|
35
|
+
}
|
|
36
|
+
static [entityKind] = "Column";
|
|
37
|
+
name;
|
|
38
|
+
keyAsName;
|
|
39
|
+
primary;
|
|
40
|
+
notNull;
|
|
41
|
+
default;
|
|
42
|
+
defaultFn;
|
|
43
|
+
onUpdateFn;
|
|
44
|
+
hasDefault;
|
|
45
|
+
isUnique;
|
|
46
|
+
uniqueName;
|
|
47
|
+
uniqueType;
|
|
48
|
+
dataType;
|
|
49
|
+
columnType;
|
|
50
|
+
enumValues = void 0;
|
|
51
|
+
generated = void 0;
|
|
52
|
+
generatedIdentity = void 0;
|
|
53
|
+
config;
|
|
54
|
+
mapFromDriverValue(value) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
mapToDriverValue(value) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
shouldDisableInsert() {
|
|
61
|
+
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/column-builder.js
|
|
66
|
+
var ColumnBuilder = class {
|
|
67
|
+
static [entityKind] = "ColumnBuilder";
|
|
68
|
+
config;
|
|
69
|
+
constructor(name, dataType, columnType) {
|
|
70
|
+
this.config = {
|
|
71
|
+
name,
|
|
72
|
+
keyAsName: name === "",
|
|
73
|
+
notNull: false,
|
|
74
|
+
default: void 0,
|
|
75
|
+
hasDefault: false,
|
|
76
|
+
primaryKey: false,
|
|
77
|
+
isUnique: false,
|
|
78
|
+
uniqueName: void 0,
|
|
79
|
+
uniqueType: void 0,
|
|
80
|
+
dataType,
|
|
81
|
+
columnType,
|
|
82
|
+
generated: void 0
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const users = pgTable('users', {
|
|
91
|
+
* id: integer('id').$type<UserId>().primaryKey(),
|
|
92
|
+
* details: json('details').$type<UserDetails>().notNull(),
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
$type() {
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Adds a `not null` clause to the column definition.
|
|
101
|
+
*
|
|
102
|
+
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
|
|
103
|
+
*/
|
|
104
|
+
notNull() {
|
|
105
|
+
this.config.notNull = true;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Adds a `default <value>` clause to the column definition.
|
|
110
|
+
*
|
|
111
|
+
* Affects the `insert` model of the table - columns *with* `default` are optional on insert.
|
|
112
|
+
*
|
|
113
|
+
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
114
|
+
*/
|
|
115
|
+
default(value) {
|
|
116
|
+
this.config.default = value;
|
|
117
|
+
this.config.hasDefault = true;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Adds a dynamic default value to the column.
|
|
122
|
+
* The function will be called when the row is inserted, and the returned value will be used as the column value.
|
|
123
|
+
*
|
|
124
|
+
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
125
|
+
*/
|
|
126
|
+
$defaultFn(fn) {
|
|
127
|
+
this.config.defaultFn = fn;
|
|
128
|
+
this.config.hasDefault = true;
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Alias for {@link $defaultFn}.
|
|
133
|
+
*/
|
|
134
|
+
$default = this.$defaultFn;
|
|
135
|
+
/**
|
|
136
|
+
* Adds a dynamic update value to the column.
|
|
137
|
+
* The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
|
|
138
|
+
* If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
|
|
139
|
+
*
|
|
140
|
+
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
141
|
+
*/
|
|
142
|
+
$onUpdateFn(fn) {
|
|
143
|
+
this.config.onUpdateFn = fn;
|
|
144
|
+
this.config.hasDefault = true;
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Alias for {@link $onUpdateFn}.
|
|
149
|
+
*/
|
|
150
|
+
$onUpdate = this.$onUpdateFn;
|
|
151
|
+
/**
|
|
152
|
+
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
153
|
+
*
|
|
154
|
+
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
|
|
155
|
+
*/
|
|
156
|
+
primaryKey() {
|
|
157
|
+
this.config.primaryKey = true;
|
|
158
|
+
this.config.notNull = true;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/** @internal Sets the name of the column to the key within the table definition if a name was not given. */
|
|
162
|
+
setName(name) {
|
|
163
|
+
if (this.config.name !== "") return;
|
|
164
|
+
this.config.name = name;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/table.utils.js
|
|
169
|
+
const TableName = Symbol.for("drizzle:Name");
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/foreign-keys.js
|
|
172
|
+
var ForeignKeyBuilder = class {
|
|
173
|
+
static [entityKind] = "PgForeignKeyBuilder";
|
|
174
|
+
/** @internal */
|
|
175
|
+
reference;
|
|
176
|
+
/** @internal */
|
|
177
|
+
_onUpdate = "no action";
|
|
178
|
+
/** @internal */
|
|
179
|
+
_onDelete = "no action";
|
|
180
|
+
constructor(config, actions) {
|
|
181
|
+
this.reference = () => {
|
|
182
|
+
const { name, columns, foreignColumns } = config();
|
|
183
|
+
return {
|
|
184
|
+
name,
|
|
185
|
+
columns,
|
|
186
|
+
foreignTable: foreignColumns[0].table,
|
|
187
|
+
foreignColumns
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
if (actions) {
|
|
191
|
+
this._onUpdate = actions.onUpdate;
|
|
192
|
+
this._onDelete = actions.onDelete;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
onUpdate(action) {
|
|
196
|
+
this._onUpdate = action === void 0 ? "no action" : action;
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
onDelete(action) {
|
|
200
|
+
this._onDelete = action === void 0 ? "no action" : action;
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
/** @internal */
|
|
204
|
+
build(table) {
|
|
205
|
+
return new ForeignKey(table, this);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var ForeignKey = class {
|
|
209
|
+
constructor(table, builder) {
|
|
210
|
+
this.table = table;
|
|
211
|
+
this.reference = builder.reference;
|
|
212
|
+
this.onUpdate = builder._onUpdate;
|
|
213
|
+
this.onDelete = builder._onDelete;
|
|
214
|
+
}
|
|
215
|
+
static [entityKind] = "PgForeignKey";
|
|
216
|
+
reference;
|
|
217
|
+
onUpdate;
|
|
218
|
+
onDelete;
|
|
219
|
+
getName() {
|
|
220
|
+
const { name, columns, foreignColumns } = this.reference();
|
|
221
|
+
const columnNames = columns.map((column) => column.name);
|
|
222
|
+
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
223
|
+
const chunks = [
|
|
224
|
+
this.table[TableName],
|
|
225
|
+
...columnNames,
|
|
226
|
+
foreignColumns[0].table[TableName],
|
|
227
|
+
...foreignColumnNames
|
|
228
|
+
];
|
|
229
|
+
return name ?? `${chunks.join("_")}_fk`;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
function foreignKey(config) {
|
|
233
|
+
function mappedConfig() {
|
|
234
|
+
const { name, columns, foreignColumns } = config;
|
|
235
|
+
return {
|
|
236
|
+
name,
|
|
237
|
+
columns,
|
|
238
|
+
foreignColumns
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return new ForeignKeyBuilder(mappedConfig);
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/tracing-utils.js
|
|
245
|
+
function iife(fn, ...args) {
|
|
246
|
+
return fn(...args);
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
250
|
+
function unique(name) {
|
|
251
|
+
return new UniqueOnConstraintBuilder(name);
|
|
252
|
+
}
|
|
253
|
+
function uniqueKeyName(table, columns) {
|
|
254
|
+
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
255
|
+
}
|
|
256
|
+
var UniqueConstraintBuilder = class {
|
|
257
|
+
constructor(columns, name) {
|
|
258
|
+
this.name = name;
|
|
259
|
+
this.columns = columns;
|
|
260
|
+
}
|
|
261
|
+
static [entityKind] = "PgUniqueConstraintBuilder";
|
|
262
|
+
/** @internal */
|
|
263
|
+
columns;
|
|
264
|
+
/** @internal */
|
|
265
|
+
nullsNotDistinctConfig = false;
|
|
266
|
+
nullsNotDistinct() {
|
|
267
|
+
this.nullsNotDistinctConfig = true;
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
/** @internal */
|
|
271
|
+
build(table) {
|
|
272
|
+
return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
var UniqueOnConstraintBuilder = class {
|
|
276
|
+
static [entityKind] = "PgUniqueOnConstraintBuilder";
|
|
277
|
+
/** @internal */
|
|
278
|
+
name;
|
|
279
|
+
constructor(name) {
|
|
280
|
+
this.name = name;
|
|
281
|
+
}
|
|
282
|
+
on(...columns) {
|
|
283
|
+
return new UniqueConstraintBuilder(columns, this.name);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
var UniqueConstraint = class {
|
|
287
|
+
constructor(table, columns, nullsNotDistinct, name) {
|
|
288
|
+
this.table = table;
|
|
289
|
+
this.columns = columns;
|
|
290
|
+
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
|
291
|
+
this.nullsNotDistinct = nullsNotDistinct;
|
|
292
|
+
}
|
|
293
|
+
static [entityKind] = "PgUniqueConstraint";
|
|
294
|
+
columns;
|
|
295
|
+
name;
|
|
296
|
+
nullsNotDistinct = false;
|
|
297
|
+
getName() {
|
|
298
|
+
return this.name;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/utils/array.js
|
|
303
|
+
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
304
|
+
for (let i = startFrom; i < arrayString.length; i++) {
|
|
305
|
+
const char = arrayString[i];
|
|
306
|
+
if (char === "\\") {
|
|
307
|
+
i++;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (char === "\"") return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
|
|
311
|
+
if (inQuotes) continue;
|
|
312
|
+
if (char === "," || char === "}") return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
|
|
313
|
+
}
|
|
314
|
+
return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
|
|
315
|
+
}
|
|
316
|
+
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
317
|
+
const result = [];
|
|
318
|
+
let i = startFrom;
|
|
319
|
+
let lastCharIsComma = false;
|
|
320
|
+
while (i < arrayString.length) {
|
|
321
|
+
const char = arrayString[i];
|
|
322
|
+
if (char === ",") {
|
|
323
|
+
if (lastCharIsComma || i === startFrom) result.push("");
|
|
324
|
+
lastCharIsComma = true;
|
|
325
|
+
i++;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
lastCharIsComma = false;
|
|
329
|
+
if (char === "\\") {
|
|
330
|
+
i += 2;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (char === "\"") {
|
|
334
|
+
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
335
|
+
result.push(value2);
|
|
336
|
+
i = startFrom2;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (char === "}") return [result, i + 1];
|
|
340
|
+
if (char === "{") {
|
|
341
|
+
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
342
|
+
result.push(value2);
|
|
343
|
+
i = startFrom2;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
347
|
+
result.push(value);
|
|
348
|
+
i = newStartFrom;
|
|
349
|
+
}
|
|
350
|
+
return [result, i];
|
|
351
|
+
}
|
|
352
|
+
function parsePgArray(arrayString) {
|
|
353
|
+
const [result] = parsePgNestedArray(arrayString, 1);
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
function makePgArray(array) {
|
|
357
|
+
return `{${array.map((item) => {
|
|
358
|
+
if (Array.isArray(item)) return makePgArray(item);
|
|
359
|
+
if (typeof item === "string") return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
360
|
+
return `${item}`;
|
|
361
|
+
}).join(",")}}`;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/common.js
|
|
365
|
+
var PgColumnBuilder = class extends ColumnBuilder {
|
|
366
|
+
foreignKeyConfigs = [];
|
|
367
|
+
static [entityKind] = "PgColumnBuilder";
|
|
368
|
+
array(size) {
|
|
369
|
+
return new PgArrayBuilder(this.config.name, this, size);
|
|
370
|
+
}
|
|
371
|
+
references(ref, actions = {}) {
|
|
372
|
+
this.foreignKeyConfigs.push({
|
|
373
|
+
ref,
|
|
374
|
+
actions
|
|
375
|
+
});
|
|
376
|
+
return this;
|
|
377
|
+
}
|
|
378
|
+
unique(name, config) {
|
|
379
|
+
this.config.isUnique = true;
|
|
380
|
+
this.config.uniqueName = name;
|
|
381
|
+
this.config.uniqueType = config?.nulls;
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
generatedAlwaysAs(as) {
|
|
385
|
+
this.config.generated = {
|
|
386
|
+
as,
|
|
387
|
+
type: "always",
|
|
388
|
+
mode: "stored"
|
|
389
|
+
};
|
|
390
|
+
return this;
|
|
391
|
+
}
|
|
392
|
+
/** @internal */
|
|
393
|
+
buildForeignKeys(column, table) {
|
|
394
|
+
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
395
|
+
return iife((ref2, actions2) => {
|
|
396
|
+
const builder = new ForeignKeyBuilder(() => {
|
|
397
|
+
const foreignColumn = ref2();
|
|
398
|
+
return {
|
|
399
|
+
columns: [column],
|
|
400
|
+
foreignColumns: [foreignColumn]
|
|
401
|
+
};
|
|
402
|
+
});
|
|
403
|
+
if (actions2.onUpdate) builder.onUpdate(actions2.onUpdate);
|
|
404
|
+
if (actions2.onDelete) builder.onDelete(actions2.onDelete);
|
|
405
|
+
return builder.build(table);
|
|
406
|
+
}, ref, actions);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
/** @internal */
|
|
410
|
+
buildExtraConfigColumn(table) {
|
|
411
|
+
return new ExtraConfigColumn(table, this.config);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var PgColumn = class extends Column {
|
|
415
|
+
constructor(table, config) {
|
|
416
|
+
if (!config.uniqueName) config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
417
|
+
super(table, config);
|
|
418
|
+
this.table = table;
|
|
419
|
+
}
|
|
420
|
+
static [entityKind] = "PgColumn";
|
|
421
|
+
};
|
|
422
|
+
var ExtraConfigColumn = class extends PgColumn {
|
|
423
|
+
static [entityKind] = "ExtraConfigColumn";
|
|
424
|
+
getSQLType() {
|
|
425
|
+
return this.getSQLType();
|
|
426
|
+
}
|
|
427
|
+
indexConfig = {
|
|
428
|
+
order: this.config.order ?? "asc",
|
|
429
|
+
nulls: this.config.nulls ?? "last",
|
|
430
|
+
opClass: this.config.opClass
|
|
431
|
+
};
|
|
432
|
+
defaultConfig = {
|
|
433
|
+
order: "asc",
|
|
434
|
+
nulls: "last",
|
|
435
|
+
opClass: void 0
|
|
436
|
+
};
|
|
437
|
+
asc() {
|
|
438
|
+
this.indexConfig.order = "asc";
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
desc() {
|
|
442
|
+
this.indexConfig.order = "desc";
|
|
443
|
+
return this;
|
|
444
|
+
}
|
|
445
|
+
nullsFirst() {
|
|
446
|
+
this.indexConfig.nulls = "first";
|
|
447
|
+
return this;
|
|
448
|
+
}
|
|
449
|
+
nullsLast() {
|
|
450
|
+
this.indexConfig.nulls = "last";
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* ### PostgreSQL documentation quote
|
|
455
|
+
*
|
|
456
|
+
* > An operator class with optional parameters can be specified for each column of an index.
|
|
457
|
+
* The operator class identifies the operators to be used by the index for that column.
|
|
458
|
+
* For example, a B-tree index on four-byte integers would use the int4_ops class;
|
|
459
|
+
* this operator class includes comparison functions for four-byte integers.
|
|
460
|
+
* In practice the default operator class for the column's data type is usually sufficient.
|
|
461
|
+
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
|
|
462
|
+
* For example, we might want to sort a complex-number data type either by absolute value or by real part.
|
|
463
|
+
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
|
|
464
|
+
* More information about operator classes check:
|
|
465
|
+
*
|
|
466
|
+
* ### Useful links
|
|
467
|
+
* https://www.postgresql.org/docs/current/sql-createindex.html
|
|
468
|
+
*
|
|
469
|
+
* https://www.postgresql.org/docs/current/indexes-opclass.html
|
|
470
|
+
*
|
|
471
|
+
* https://www.postgresql.org/docs/current/xindex.html
|
|
472
|
+
*
|
|
473
|
+
* ### Additional types
|
|
474
|
+
* If you have the `pg_vector` extension installed in your database, you can use the
|
|
475
|
+
* `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types.
|
|
476
|
+
*
|
|
477
|
+
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
|
|
478
|
+
*
|
|
479
|
+
* @param opClass
|
|
480
|
+
* @returns
|
|
481
|
+
*/
|
|
482
|
+
op(opClass) {
|
|
483
|
+
this.indexConfig.opClass = opClass;
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
var IndexedColumn = class {
|
|
488
|
+
static [entityKind] = "IndexedColumn";
|
|
489
|
+
constructor(name, keyAsName, type, indexConfig) {
|
|
490
|
+
this.name = name;
|
|
491
|
+
this.keyAsName = keyAsName;
|
|
492
|
+
this.type = type;
|
|
493
|
+
this.indexConfig = indexConfig;
|
|
494
|
+
}
|
|
495
|
+
name;
|
|
496
|
+
keyAsName;
|
|
497
|
+
type;
|
|
498
|
+
indexConfig;
|
|
499
|
+
};
|
|
500
|
+
var PgArrayBuilder = class extends PgColumnBuilder {
|
|
501
|
+
static [entityKind] = "PgArrayBuilder";
|
|
502
|
+
constructor(name, baseBuilder, size) {
|
|
503
|
+
super(name, "array", "PgArray");
|
|
504
|
+
this.config.baseBuilder = baseBuilder;
|
|
505
|
+
this.config.size = size;
|
|
506
|
+
}
|
|
507
|
+
/** @internal */
|
|
508
|
+
build(table) {
|
|
509
|
+
const baseColumn = this.config.baseBuilder.build(table);
|
|
510
|
+
return new PgArray(table, this.config, baseColumn);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
var PgArray = class PgArray extends PgColumn {
|
|
514
|
+
constructor(table, config, baseColumn, range) {
|
|
515
|
+
super(table, config);
|
|
516
|
+
this.baseColumn = baseColumn;
|
|
517
|
+
this.range = range;
|
|
518
|
+
this.size = config.size;
|
|
519
|
+
}
|
|
520
|
+
size;
|
|
521
|
+
static [entityKind] = "PgArray";
|
|
522
|
+
getSQLType() {
|
|
523
|
+
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
524
|
+
}
|
|
525
|
+
mapFromDriverValue(value) {
|
|
526
|
+
if (typeof value === "string") value = parsePgArray(value);
|
|
527
|
+
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
528
|
+
}
|
|
529
|
+
mapToDriverValue(value, isNestedArray = false) {
|
|
530
|
+
const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
|
|
531
|
+
if (isNestedArray) return a;
|
|
532
|
+
return makePgArray(a);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
537
|
+
const isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
538
|
+
function isPgEnum(obj) {
|
|
539
|
+
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/subquery.js
|
|
543
|
+
var Subquery = class {
|
|
544
|
+
static [entityKind] = "Subquery";
|
|
545
|
+
constructor(sql, fields, alias, isWith = false, usedTables = []) {
|
|
546
|
+
this._ = {
|
|
547
|
+
brand: "Subquery",
|
|
548
|
+
sql,
|
|
549
|
+
selectedFields: fields,
|
|
550
|
+
alias,
|
|
551
|
+
isWith,
|
|
552
|
+
usedTables
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
var WithSubquery = class extends Subquery {
|
|
557
|
+
static [entityKind] = "WithSubquery";
|
|
558
|
+
};
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/tracing.js
|
|
561
|
+
const tracer = { startActiveSpan(name, fn) {
|
|
562
|
+
return fn();
|
|
563
|
+
} };
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/view-common.js
|
|
566
|
+
const ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/table.js
|
|
569
|
+
const Schema = Symbol.for("drizzle:Schema");
|
|
570
|
+
const Columns = Symbol.for("drizzle:Columns");
|
|
571
|
+
const ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
572
|
+
const OriginalName = Symbol.for("drizzle:OriginalName");
|
|
573
|
+
const BaseName = Symbol.for("drizzle:BaseName");
|
|
574
|
+
const IsAlias = Symbol.for("drizzle:IsAlias");
|
|
575
|
+
const ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
|
576
|
+
const IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
|
577
|
+
var Table = class {
|
|
578
|
+
static [entityKind] = "Table";
|
|
579
|
+
/** @internal */
|
|
580
|
+
static Symbol = {
|
|
581
|
+
Name: TableName,
|
|
582
|
+
Schema,
|
|
583
|
+
OriginalName,
|
|
584
|
+
Columns,
|
|
585
|
+
ExtraConfigColumns,
|
|
586
|
+
BaseName,
|
|
587
|
+
IsAlias,
|
|
588
|
+
ExtraConfigBuilder
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* @internal
|
|
592
|
+
* Can be changed if the table is aliased.
|
|
593
|
+
*/
|
|
594
|
+
[TableName];
|
|
595
|
+
/**
|
|
596
|
+
* @internal
|
|
597
|
+
* Used to store the original name of the table, before any aliasing.
|
|
598
|
+
*/
|
|
599
|
+
[OriginalName];
|
|
600
|
+
/** @internal */
|
|
601
|
+
[Schema];
|
|
602
|
+
/** @internal */
|
|
603
|
+
[Columns];
|
|
604
|
+
/** @internal */
|
|
605
|
+
[ExtraConfigColumns];
|
|
606
|
+
/**
|
|
607
|
+
* @internal
|
|
608
|
+
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
609
|
+
*/
|
|
610
|
+
[BaseName];
|
|
611
|
+
/** @internal */
|
|
612
|
+
[IsAlias] = false;
|
|
613
|
+
/** @internal */
|
|
614
|
+
[IsDrizzleTable] = true;
|
|
615
|
+
/** @internal */
|
|
616
|
+
[ExtraConfigBuilder] = void 0;
|
|
617
|
+
constructor(name, schema, baseName) {
|
|
618
|
+
this[TableName] = this[OriginalName] = name;
|
|
619
|
+
this[Schema] = schema;
|
|
620
|
+
this[BaseName] = baseName;
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
function getTableName(table) {
|
|
624
|
+
return table[TableName];
|
|
625
|
+
}
|
|
626
|
+
function getTableUniqueName(table) {
|
|
627
|
+
return `${table[Schema] ?? "public"}.${table[TableName]}`;
|
|
628
|
+
}
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/sql/sql.js
|
|
631
|
+
function isSQLWrapper(value) {
|
|
632
|
+
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
633
|
+
}
|
|
634
|
+
function mergeQueries(queries) {
|
|
635
|
+
const result = {
|
|
636
|
+
sql: "",
|
|
637
|
+
params: []
|
|
638
|
+
};
|
|
639
|
+
for (const query of queries) {
|
|
640
|
+
result.sql += query.sql;
|
|
641
|
+
result.params.push(...query.params);
|
|
642
|
+
if (query.typings?.length) {
|
|
643
|
+
if (!result.typings) result.typings = [];
|
|
644
|
+
result.typings.push(...query.typings);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return result;
|
|
648
|
+
}
|
|
649
|
+
var StringChunk = class {
|
|
650
|
+
static [entityKind] = "StringChunk";
|
|
651
|
+
value;
|
|
652
|
+
constructor(value) {
|
|
653
|
+
this.value = Array.isArray(value) ? value : [value];
|
|
654
|
+
}
|
|
655
|
+
getSQL() {
|
|
656
|
+
return new SQL([this]);
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
var SQL = class SQL {
|
|
660
|
+
constructor(queryChunks) {
|
|
661
|
+
this.queryChunks = queryChunks;
|
|
662
|
+
for (const chunk of queryChunks) if (is(chunk, Table)) {
|
|
663
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
664
|
+
this.usedTables.push(schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
static [entityKind] = "SQL";
|
|
668
|
+
/** @internal */
|
|
669
|
+
decoder = noopDecoder;
|
|
670
|
+
shouldInlineParams = false;
|
|
671
|
+
/** @internal */
|
|
672
|
+
usedTables = [];
|
|
673
|
+
append(query) {
|
|
674
|
+
this.queryChunks.push(...query.queryChunks);
|
|
675
|
+
return this;
|
|
676
|
+
}
|
|
677
|
+
toQuery(config) {
|
|
678
|
+
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
679
|
+
const query = this.buildQueryFromSourceParams(this.queryChunks, config);
|
|
680
|
+
span?.setAttributes({
|
|
681
|
+
"drizzle.query.text": query.sql,
|
|
682
|
+
"drizzle.query.params": JSON.stringify(query.params)
|
|
683
|
+
});
|
|
684
|
+
return query;
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
buildQueryFromSourceParams(chunks, _config) {
|
|
688
|
+
const config = Object.assign({}, _config, {
|
|
689
|
+
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
690
|
+
paramStartIndex: _config.paramStartIndex || { value: 0 }
|
|
691
|
+
});
|
|
692
|
+
const { casing, escapeName, escapeParam, prepareTyping, inlineParams, paramStartIndex } = config;
|
|
693
|
+
return mergeQueries(chunks.map((chunk) => {
|
|
694
|
+
if (is(chunk, StringChunk)) return {
|
|
695
|
+
sql: chunk.value.join(""),
|
|
696
|
+
params: []
|
|
697
|
+
};
|
|
698
|
+
if (is(chunk, Name)) return {
|
|
699
|
+
sql: escapeName(chunk.value),
|
|
700
|
+
params: []
|
|
701
|
+
};
|
|
702
|
+
if (chunk === void 0) return {
|
|
703
|
+
sql: "",
|
|
704
|
+
params: []
|
|
705
|
+
};
|
|
706
|
+
if (Array.isArray(chunk)) {
|
|
707
|
+
const result = [new StringChunk("(")];
|
|
708
|
+
for (const [i, p] of chunk.entries()) {
|
|
709
|
+
result.push(p);
|
|
710
|
+
if (i < chunk.length - 1) result.push(new StringChunk(", "));
|
|
711
|
+
}
|
|
712
|
+
result.push(new StringChunk(")"));
|
|
713
|
+
return this.buildQueryFromSourceParams(result, config);
|
|
714
|
+
}
|
|
715
|
+
if (is(chunk, SQL)) return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
716
|
+
...config,
|
|
717
|
+
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
718
|
+
});
|
|
719
|
+
if (is(chunk, Table)) {
|
|
720
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
721
|
+
const tableName = chunk[Table.Symbol.Name];
|
|
722
|
+
return {
|
|
723
|
+
sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
724
|
+
params: []
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
if (is(chunk, Column)) {
|
|
728
|
+
const columnName = casing.getColumnCasing(chunk);
|
|
729
|
+
if (_config.invokeSource === "indexes") return {
|
|
730
|
+
sql: escapeName(columnName),
|
|
731
|
+
params: []
|
|
732
|
+
};
|
|
733
|
+
const schemaName = chunk.table[Table.Symbol.Schema];
|
|
734
|
+
return {
|
|
735
|
+
sql: chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
|
|
736
|
+
params: []
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
if (is(chunk, View)) {
|
|
740
|
+
const schemaName = chunk[ViewBaseConfig].schema;
|
|
741
|
+
const viewName = chunk[ViewBaseConfig].name;
|
|
742
|
+
return {
|
|
743
|
+
sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
744
|
+
params: []
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
if (is(chunk, Param)) {
|
|
748
|
+
if (is(chunk.value, Placeholder)) return {
|
|
749
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
750
|
+
params: [chunk],
|
|
751
|
+
typings: ["none"]
|
|
752
|
+
};
|
|
753
|
+
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
754
|
+
if (is(mappedValue, SQL)) return this.buildQueryFromSourceParams([mappedValue], config);
|
|
755
|
+
if (inlineParams) return {
|
|
756
|
+
sql: this.mapInlineParam(mappedValue, config),
|
|
757
|
+
params: []
|
|
758
|
+
};
|
|
759
|
+
let typings = ["none"];
|
|
760
|
+
if (prepareTyping) typings = [prepareTyping(chunk.encoder)];
|
|
761
|
+
return {
|
|
762
|
+
sql: escapeParam(paramStartIndex.value++, mappedValue),
|
|
763
|
+
params: [mappedValue],
|
|
764
|
+
typings
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
if (is(chunk, Placeholder)) return {
|
|
768
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
769
|
+
params: [chunk],
|
|
770
|
+
typings: ["none"]
|
|
771
|
+
};
|
|
772
|
+
if (is(chunk, SQL.Aliased) && chunk.fieldAlias !== void 0) return {
|
|
773
|
+
sql: escapeName(chunk.fieldAlias),
|
|
774
|
+
params: []
|
|
775
|
+
};
|
|
776
|
+
if (is(chunk, Subquery)) {
|
|
777
|
+
if (chunk._.isWith) return {
|
|
778
|
+
sql: escapeName(chunk._.alias),
|
|
779
|
+
params: []
|
|
780
|
+
};
|
|
781
|
+
return this.buildQueryFromSourceParams([
|
|
782
|
+
new StringChunk("("),
|
|
783
|
+
chunk._.sql,
|
|
784
|
+
new StringChunk(") "),
|
|
785
|
+
new Name(chunk._.alias)
|
|
786
|
+
], config);
|
|
787
|
+
}
|
|
788
|
+
if (isPgEnum(chunk)) {
|
|
789
|
+
if (chunk.schema) return {
|
|
790
|
+
sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
|
|
791
|
+
params: []
|
|
792
|
+
};
|
|
793
|
+
return {
|
|
794
|
+
sql: escapeName(chunk.enumName),
|
|
795
|
+
params: []
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
if (isSQLWrapper(chunk)) {
|
|
799
|
+
if (chunk.shouldOmitSQLParens?.()) return this.buildQueryFromSourceParams([chunk.getSQL()], config);
|
|
800
|
+
return this.buildQueryFromSourceParams([
|
|
801
|
+
new StringChunk("("),
|
|
802
|
+
chunk.getSQL(),
|
|
803
|
+
new StringChunk(")")
|
|
804
|
+
], config);
|
|
805
|
+
}
|
|
806
|
+
if (inlineParams) return {
|
|
807
|
+
sql: this.mapInlineParam(chunk, config),
|
|
808
|
+
params: []
|
|
809
|
+
};
|
|
810
|
+
return {
|
|
811
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
812
|
+
params: [chunk],
|
|
813
|
+
typings: ["none"]
|
|
814
|
+
};
|
|
815
|
+
}));
|
|
816
|
+
}
|
|
817
|
+
mapInlineParam(chunk, { escapeString }) {
|
|
818
|
+
if (chunk === null) return "null";
|
|
819
|
+
if (typeof chunk === "number" || typeof chunk === "boolean") return chunk.toString();
|
|
820
|
+
if (typeof chunk === "string") return escapeString(chunk);
|
|
821
|
+
if (typeof chunk === "object") {
|
|
822
|
+
const mappedValueAsString = chunk.toString();
|
|
823
|
+
if (mappedValueAsString === "[object Object]") return escapeString(JSON.stringify(chunk));
|
|
824
|
+
return escapeString(mappedValueAsString);
|
|
825
|
+
}
|
|
826
|
+
throw new Error("Unexpected param value: " + chunk);
|
|
827
|
+
}
|
|
828
|
+
getSQL() {
|
|
829
|
+
return this;
|
|
830
|
+
}
|
|
831
|
+
as(alias) {
|
|
832
|
+
if (alias === void 0) return this;
|
|
833
|
+
return new SQL.Aliased(this, alias);
|
|
834
|
+
}
|
|
835
|
+
mapWith(decoder) {
|
|
836
|
+
this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
|
|
837
|
+
return this;
|
|
838
|
+
}
|
|
839
|
+
inlineParams() {
|
|
840
|
+
this.shouldInlineParams = true;
|
|
841
|
+
return this;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* This method is used to conditionally include a part of the query.
|
|
845
|
+
*
|
|
846
|
+
* @param condition - Condition to check
|
|
847
|
+
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
848
|
+
*/
|
|
849
|
+
if(condition) {
|
|
850
|
+
return condition ? this : void 0;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
var Name = class {
|
|
854
|
+
constructor(value) {
|
|
855
|
+
this.value = value;
|
|
856
|
+
}
|
|
857
|
+
static [entityKind] = "Name";
|
|
858
|
+
brand;
|
|
859
|
+
getSQL() {
|
|
860
|
+
return new SQL([this]);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
function isDriverValueEncoder(value) {
|
|
864
|
+
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
865
|
+
}
|
|
866
|
+
const noopDecoder = { mapFromDriverValue: (value) => value };
|
|
867
|
+
const noopEncoder = { mapToDriverValue: (value) => value };
|
|
868
|
+
({
|
|
869
|
+
...noopDecoder,
|
|
870
|
+
...noopEncoder
|
|
871
|
+
});
|
|
872
|
+
var Param = class {
|
|
873
|
+
/**
|
|
874
|
+
* @param value - Parameter value
|
|
875
|
+
* @param encoder - Encoder to convert the value to a driver parameter
|
|
876
|
+
*/
|
|
877
|
+
constructor(value, encoder = noopEncoder) {
|
|
878
|
+
this.value = value;
|
|
879
|
+
this.encoder = encoder;
|
|
880
|
+
}
|
|
881
|
+
static [entityKind] = "Param";
|
|
882
|
+
brand;
|
|
883
|
+
getSQL() {
|
|
884
|
+
return new SQL([this]);
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
function sql(strings, ...params) {
|
|
888
|
+
const queryChunks = [];
|
|
889
|
+
if (params.length > 0 || strings.length > 0 && strings[0] !== "") queryChunks.push(new StringChunk(strings[0]));
|
|
890
|
+
for (const [paramIndex, param2] of params.entries()) queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
891
|
+
return new SQL(queryChunks);
|
|
892
|
+
}
|
|
893
|
+
((sql2) => {
|
|
894
|
+
function empty() {
|
|
895
|
+
return new SQL([]);
|
|
896
|
+
}
|
|
897
|
+
sql2.empty = empty;
|
|
898
|
+
function fromList(list) {
|
|
899
|
+
return new SQL(list);
|
|
900
|
+
}
|
|
901
|
+
sql2.fromList = fromList;
|
|
902
|
+
function raw(str) {
|
|
903
|
+
return new SQL([new StringChunk(str)]);
|
|
904
|
+
}
|
|
905
|
+
sql2.raw = raw;
|
|
906
|
+
function join(chunks, separator) {
|
|
907
|
+
const result = [];
|
|
908
|
+
for (const [i, chunk] of chunks.entries()) {
|
|
909
|
+
if (i > 0 && separator !== void 0) result.push(separator);
|
|
910
|
+
result.push(chunk);
|
|
911
|
+
}
|
|
912
|
+
return new SQL(result);
|
|
913
|
+
}
|
|
914
|
+
sql2.join = join;
|
|
915
|
+
function identifier(value) {
|
|
916
|
+
return new Name(value);
|
|
917
|
+
}
|
|
918
|
+
sql2.identifier = identifier;
|
|
919
|
+
function placeholder2(name2) {
|
|
920
|
+
return new Placeholder(name2);
|
|
921
|
+
}
|
|
922
|
+
sql2.placeholder = placeholder2;
|
|
923
|
+
function param2(value, encoder) {
|
|
924
|
+
return new Param(value, encoder);
|
|
925
|
+
}
|
|
926
|
+
sql2.param = param2;
|
|
927
|
+
})(sql || (sql = {}));
|
|
928
|
+
((SQL2) => {
|
|
929
|
+
class Aliased {
|
|
930
|
+
constructor(sql2, fieldAlias) {
|
|
931
|
+
this.sql = sql2;
|
|
932
|
+
this.fieldAlias = fieldAlias;
|
|
933
|
+
}
|
|
934
|
+
static [entityKind] = "SQL.Aliased";
|
|
935
|
+
/** @internal */
|
|
936
|
+
isSelectionField = false;
|
|
937
|
+
getSQL() {
|
|
938
|
+
return this.sql;
|
|
939
|
+
}
|
|
940
|
+
/** @internal */
|
|
941
|
+
clone() {
|
|
942
|
+
return new Aliased(this.sql, this.fieldAlias);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
SQL2.Aliased = Aliased;
|
|
946
|
+
})(SQL || (SQL = {}));
|
|
947
|
+
var Placeholder = class {
|
|
948
|
+
constructor(name2) {
|
|
949
|
+
this.name = name2;
|
|
950
|
+
}
|
|
951
|
+
static [entityKind] = "Placeholder";
|
|
952
|
+
getSQL() {
|
|
953
|
+
return new SQL([this]);
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
function fillPlaceholders(params, values) {
|
|
957
|
+
return params.map((p) => {
|
|
958
|
+
if (is(p, Placeholder)) {
|
|
959
|
+
if (!(p.name in values)) throw new Error(`No value for placeholder "${p.name}" was provided`);
|
|
960
|
+
return values[p.name];
|
|
961
|
+
}
|
|
962
|
+
if (is(p, Param) && is(p.value, Placeholder)) {
|
|
963
|
+
if (!(p.value.name in values)) throw new Error(`No value for placeholder "${p.value.name}" was provided`);
|
|
964
|
+
return p.encoder.mapToDriverValue(values[p.value.name]);
|
|
965
|
+
}
|
|
966
|
+
return p;
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
const IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
|
|
970
|
+
var View = class {
|
|
971
|
+
static [entityKind] = "View";
|
|
972
|
+
/** @internal */
|
|
973
|
+
[ViewBaseConfig];
|
|
974
|
+
/** @internal */
|
|
975
|
+
[IsDrizzleView] = true;
|
|
976
|
+
constructor({ name: name2, schema, selectedFields, query }) {
|
|
977
|
+
this[ViewBaseConfig] = {
|
|
978
|
+
name: name2,
|
|
979
|
+
originalName: name2,
|
|
980
|
+
schema,
|
|
981
|
+
selectedFields,
|
|
982
|
+
query,
|
|
983
|
+
isExisting: !query,
|
|
984
|
+
isAlias: false
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
getSQL() {
|
|
988
|
+
return new SQL([this]);
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
Column.prototype.getSQL = function() {
|
|
992
|
+
return new SQL([this]);
|
|
993
|
+
};
|
|
994
|
+
Table.prototype.getSQL = function() {
|
|
995
|
+
return new SQL([this]);
|
|
996
|
+
};
|
|
997
|
+
Subquery.prototype.getSQL = function() {
|
|
998
|
+
return new SQL([this]);
|
|
999
|
+
};
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/utils.js
|
|
1002
|
+
function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
1003
|
+
const nullifyMap = {};
|
|
1004
|
+
const result = columns.reduce((result2, { path, field }, columnIndex) => {
|
|
1005
|
+
let decoder;
|
|
1006
|
+
if (is(field, Column)) decoder = field;
|
|
1007
|
+
else if (is(field, SQL)) decoder = field.decoder;
|
|
1008
|
+
else if (is(field, Subquery)) decoder = field._.sql.decoder;
|
|
1009
|
+
else decoder = field.sql.decoder;
|
|
1010
|
+
let node = result2;
|
|
1011
|
+
for (const [pathChunkIndex, pathChunk] of path.entries()) if (pathChunkIndex < path.length - 1) {
|
|
1012
|
+
if (!(pathChunk in node)) node[pathChunk] = {};
|
|
1013
|
+
node = node[pathChunk];
|
|
1014
|
+
} else {
|
|
1015
|
+
const rawValue = row[columnIndex];
|
|
1016
|
+
const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
|
|
1017
|
+
if (joinsNotNullableMap && is(field, Column) && path.length === 2) {
|
|
1018
|
+
const objectName = path[0];
|
|
1019
|
+
if (!(objectName in nullifyMap)) nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
|
|
1020
|
+
else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) nullifyMap[objectName] = false;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return result2;
|
|
1024
|
+
}, {});
|
|
1025
|
+
if (joinsNotNullableMap && Object.keys(nullifyMap).length > 0) {
|
|
1026
|
+
for (const [objectName, tableName] of Object.entries(nullifyMap)) if (typeof tableName === "string" && !joinsNotNullableMap[tableName]) result[objectName] = null;
|
|
1027
|
+
}
|
|
1028
|
+
return result;
|
|
1029
|
+
}
|
|
1030
|
+
function orderSelectedFields(fields, pathPrefix) {
|
|
1031
|
+
return Object.entries(fields).reduce((result, [name, field]) => {
|
|
1032
|
+
if (typeof name !== "string") return result;
|
|
1033
|
+
const newPath = pathPrefix ? [...pathPrefix, name] : [name];
|
|
1034
|
+
if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery)) result.push({
|
|
1035
|
+
path: newPath,
|
|
1036
|
+
field
|
|
1037
|
+
});
|
|
1038
|
+
else if (is(field, Table)) result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));
|
|
1039
|
+
else result.push(...orderSelectedFields(field, newPath));
|
|
1040
|
+
return result;
|
|
1041
|
+
}, []);
|
|
1042
|
+
}
|
|
1043
|
+
function haveSameKeys(left, right) {
|
|
1044
|
+
const leftKeys = Object.keys(left);
|
|
1045
|
+
const rightKeys = Object.keys(right);
|
|
1046
|
+
if (leftKeys.length !== rightKeys.length) return false;
|
|
1047
|
+
for (const [index, key] of leftKeys.entries()) if (key !== rightKeys[index]) return false;
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
function mapUpdateSet(table, values) {
|
|
1051
|
+
const entries = Object.entries(values).filter(([, value]) => value !== void 0).map(([key, value]) => {
|
|
1052
|
+
if (is(value, SQL) || is(value, Column)) return [key, value];
|
|
1053
|
+
else return [key, new Param(value, table[Table.Symbol.Columns][key])];
|
|
1054
|
+
});
|
|
1055
|
+
if (entries.length === 0) throw new Error("No values to set");
|
|
1056
|
+
return Object.fromEntries(entries);
|
|
1057
|
+
}
|
|
1058
|
+
function applyMixins(baseClass, extendedClasses) {
|
|
1059
|
+
for (const extendedClass of extendedClasses) for (const name of Object.getOwnPropertyNames(extendedClass.prototype)) {
|
|
1060
|
+
if (name === "constructor") continue;
|
|
1061
|
+
Object.defineProperty(baseClass.prototype, name, Object.getOwnPropertyDescriptor(extendedClass.prototype, name) || /* @__PURE__ */ Object.create(null));
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
function getTableColumns(table) {
|
|
1065
|
+
return table[Table.Symbol.Columns];
|
|
1066
|
+
}
|
|
1067
|
+
function getTableLikeName(table) {
|
|
1068
|
+
return is(table, Subquery) ? table._.alias : is(table, View) ? table[ViewBaseConfig].name : is(table, SQL) ? void 0 : table[Table.Symbol.IsAlias] ? table[Table.Symbol.Name] : table[Table.Symbol.BaseName];
|
|
1069
|
+
}
|
|
1070
|
+
function getColumnNameAndConfig(a, b) {
|
|
1071
|
+
return {
|
|
1072
|
+
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
1073
|
+
config: typeof a === "object" ? a : b
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
function isConfig(data) {
|
|
1077
|
+
if (typeof data !== "object" || data === null) return false;
|
|
1078
|
+
if (data.constructor.name !== "Object") return false;
|
|
1079
|
+
if ("logger" in data) {
|
|
1080
|
+
const type = typeof data["logger"];
|
|
1081
|
+
if (type !== "boolean" && (type !== "object" || typeof data["logger"]["logQuery"] !== "function") && type !== "undefined") return false;
|
|
1082
|
+
return true;
|
|
1083
|
+
}
|
|
1084
|
+
if ("schema" in data) {
|
|
1085
|
+
const type = typeof data["schema"];
|
|
1086
|
+
if (type !== "object" && type !== "undefined") return false;
|
|
1087
|
+
return true;
|
|
1088
|
+
}
|
|
1089
|
+
if ("casing" in data) {
|
|
1090
|
+
const type = typeof data["casing"];
|
|
1091
|
+
if (type !== "string" && type !== "undefined") return false;
|
|
1092
|
+
return true;
|
|
1093
|
+
}
|
|
1094
|
+
if ("mode" in data) {
|
|
1095
|
+
if (data["mode"] !== "default" || data["mode"] !== "planetscale" || data["mode"] !== void 0) return false;
|
|
1096
|
+
return true;
|
|
1097
|
+
}
|
|
1098
|
+
if ("connection" in data) {
|
|
1099
|
+
const type = typeof data["connection"];
|
|
1100
|
+
if (type !== "string" && type !== "object" && type !== "undefined") return false;
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
if ("client" in data) {
|
|
1104
|
+
const type = typeof data["client"];
|
|
1105
|
+
if (type !== "object" && type !== "function" && type !== "undefined") return false;
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
if (Object.keys(data).length === 0) return true;
|
|
1109
|
+
return false;
|
|
1110
|
+
}
|
|
1111
|
+
const textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder();
|
|
1112
|
+
//#endregion
|
|
1113
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/int.common.js
|
|
1114
|
+
var PgIntColumnBaseBuilder = class extends PgColumnBuilder {
|
|
1115
|
+
static [entityKind] = "PgIntColumnBaseBuilder";
|
|
1116
|
+
generatedAlwaysAsIdentity(sequence) {
|
|
1117
|
+
if (sequence) {
|
|
1118
|
+
const { name, ...options } = sequence;
|
|
1119
|
+
this.config.generatedIdentity = {
|
|
1120
|
+
type: "always",
|
|
1121
|
+
sequenceName: name,
|
|
1122
|
+
sequenceOptions: options
|
|
1123
|
+
};
|
|
1124
|
+
} else this.config.generatedIdentity = { type: "always" };
|
|
1125
|
+
this.config.hasDefault = true;
|
|
1126
|
+
this.config.notNull = true;
|
|
1127
|
+
return this;
|
|
1128
|
+
}
|
|
1129
|
+
generatedByDefaultAsIdentity(sequence) {
|
|
1130
|
+
if (sequence) {
|
|
1131
|
+
const { name, ...options } = sequence;
|
|
1132
|
+
this.config.generatedIdentity = {
|
|
1133
|
+
type: "byDefault",
|
|
1134
|
+
sequenceName: name,
|
|
1135
|
+
sequenceOptions: options
|
|
1136
|
+
};
|
|
1137
|
+
} else this.config.generatedIdentity = { type: "byDefault" };
|
|
1138
|
+
this.config.hasDefault = true;
|
|
1139
|
+
this.config.notNull = true;
|
|
1140
|
+
return this;
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/bigint.js
|
|
1145
|
+
var PgBigInt53Builder = class extends PgIntColumnBaseBuilder {
|
|
1146
|
+
static [entityKind] = "PgBigInt53Builder";
|
|
1147
|
+
constructor(name) {
|
|
1148
|
+
super(name, "number", "PgBigInt53");
|
|
1149
|
+
}
|
|
1150
|
+
/** @internal */
|
|
1151
|
+
build(table) {
|
|
1152
|
+
return new PgBigInt53(table, this.config);
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
var PgBigInt53 = class extends PgColumn {
|
|
1156
|
+
static [entityKind] = "PgBigInt53";
|
|
1157
|
+
getSQLType() {
|
|
1158
|
+
return "bigint";
|
|
1159
|
+
}
|
|
1160
|
+
mapFromDriverValue(value) {
|
|
1161
|
+
if (typeof value === "number") return value;
|
|
1162
|
+
return Number(value);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
var PgBigInt64Builder = class extends PgIntColumnBaseBuilder {
|
|
1166
|
+
static [entityKind] = "PgBigInt64Builder";
|
|
1167
|
+
constructor(name) {
|
|
1168
|
+
super(name, "bigint", "PgBigInt64");
|
|
1169
|
+
}
|
|
1170
|
+
/** @internal */
|
|
1171
|
+
build(table) {
|
|
1172
|
+
return new PgBigInt64(table, this.config);
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
var PgBigInt64 = class extends PgColumn {
|
|
1176
|
+
static [entityKind] = "PgBigInt64";
|
|
1177
|
+
getSQLType() {
|
|
1178
|
+
return "bigint";
|
|
1179
|
+
}
|
|
1180
|
+
mapFromDriverValue(value) {
|
|
1181
|
+
return BigInt(value);
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
function bigint(a, b) {
|
|
1185
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1186
|
+
if (config.mode === "number") return new PgBigInt53Builder(name);
|
|
1187
|
+
return new PgBigInt64Builder(name);
|
|
1188
|
+
}
|
|
1189
|
+
//#endregion
|
|
1190
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/bigserial.js
|
|
1191
|
+
var PgBigSerial53Builder = class extends PgColumnBuilder {
|
|
1192
|
+
static [entityKind] = "PgBigSerial53Builder";
|
|
1193
|
+
constructor(name) {
|
|
1194
|
+
super(name, "number", "PgBigSerial53");
|
|
1195
|
+
this.config.hasDefault = true;
|
|
1196
|
+
this.config.notNull = true;
|
|
1197
|
+
}
|
|
1198
|
+
/** @internal */
|
|
1199
|
+
build(table) {
|
|
1200
|
+
return new PgBigSerial53(table, this.config);
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
var PgBigSerial53 = class extends PgColumn {
|
|
1204
|
+
static [entityKind] = "PgBigSerial53";
|
|
1205
|
+
getSQLType() {
|
|
1206
|
+
return "bigserial";
|
|
1207
|
+
}
|
|
1208
|
+
mapFromDriverValue(value) {
|
|
1209
|
+
if (typeof value === "number") return value;
|
|
1210
|
+
return Number(value);
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
var PgBigSerial64Builder = class extends PgColumnBuilder {
|
|
1214
|
+
static [entityKind] = "PgBigSerial64Builder";
|
|
1215
|
+
constructor(name) {
|
|
1216
|
+
super(name, "bigint", "PgBigSerial64");
|
|
1217
|
+
this.config.hasDefault = true;
|
|
1218
|
+
}
|
|
1219
|
+
/** @internal */
|
|
1220
|
+
build(table) {
|
|
1221
|
+
return new PgBigSerial64(table, this.config);
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
var PgBigSerial64 = class extends PgColumn {
|
|
1225
|
+
static [entityKind] = "PgBigSerial64";
|
|
1226
|
+
getSQLType() {
|
|
1227
|
+
return "bigserial";
|
|
1228
|
+
}
|
|
1229
|
+
mapFromDriverValue(value) {
|
|
1230
|
+
return BigInt(value);
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
function bigserial(a, b) {
|
|
1234
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1235
|
+
if (config.mode === "number") return new PgBigSerial53Builder(name);
|
|
1236
|
+
return new PgBigSerial64Builder(name);
|
|
1237
|
+
}
|
|
1238
|
+
//#endregion
|
|
1239
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/boolean.js
|
|
1240
|
+
var PgBooleanBuilder = class extends PgColumnBuilder {
|
|
1241
|
+
static [entityKind] = "PgBooleanBuilder";
|
|
1242
|
+
constructor(name) {
|
|
1243
|
+
super(name, "boolean", "PgBoolean");
|
|
1244
|
+
}
|
|
1245
|
+
/** @internal */
|
|
1246
|
+
build(table) {
|
|
1247
|
+
return new PgBoolean(table, this.config);
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
var PgBoolean = class extends PgColumn {
|
|
1251
|
+
static [entityKind] = "PgBoolean";
|
|
1252
|
+
getSQLType() {
|
|
1253
|
+
return "boolean";
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
function boolean(name) {
|
|
1257
|
+
return new PgBooleanBuilder(name ?? "");
|
|
1258
|
+
}
|
|
1259
|
+
//#endregion
|
|
1260
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/char.js
|
|
1261
|
+
var PgCharBuilder = class extends PgColumnBuilder {
|
|
1262
|
+
static [entityKind] = "PgCharBuilder";
|
|
1263
|
+
constructor(name, config) {
|
|
1264
|
+
super(name, "string", "PgChar");
|
|
1265
|
+
this.config.length = config.length;
|
|
1266
|
+
this.config.enumValues = config.enum;
|
|
1267
|
+
}
|
|
1268
|
+
/** @internal */
|
|
1269
|
+
build(table) {
|
|
1270
|
+
return new PgChar(table, this.config);
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
var PgChar = class extends PgColumn {
|
|
1274
|
+
static [entityKind] = "PgChar";
|
|
1275
|
+
length = this.config.length;
|
|
1276
|
+
enumValues = this.config.enumValues;
|
|
1277
|
+
getSQLType() {
|
|
1278
|
+
return this.length === void 0 ? `char` : `char(${this.length})`;
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
function char(a, b = {}) {
|
|
1282
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1283
|
+
return new PgCharBuilder(name, config);
|
|
1284
|
+
}
|
|
1285
|
+
//#endregion
|
|
1286
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/cidr.js
|
|
1287
|
+
var PgCidrBuilder = class extends PgColumnBuilder {
|
|
1288
|
+
static [entityKind] = "PgCidrBuilder";
|
|
1289
|
+
constructor(name) {
|
|
1290
|
+
super(name, "string", "PgCidr");
|
|
1291
|
+
}
|
|
1292
|
+
/** @internal */
|
|
1293
|
+
build(table) {
|
|
1294
|
+
return new PgCidr(table, this.config);
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
var PgCidr = class extends PgColumn {
|
|
1298
|
+
static [entityKind] = "PgCidr";
|
|
1299
|
+
getSQLType() {
|
|
1300
|
+
return "cidr";
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
function cidr(name) {
|
|
1304
|
+
return new PgCidrBuilder(name ?? "");
|
|
1305
|
+
}
|
|
1306
|
+
//#endregion
|
|
1307
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/custom.js
|
|
1308
|
+
var PgCustomColumnBuilder = class extends PgColumnBuilder {
|
|
1309
|
+
static [entityKind] = "PgCustomColumnBuilder";
|
|
1310
|
+
constructor(name, fieldConfig, customTypeParams) {
|
|
1311
|
+
super(name, "custom", "PgCustomColumn");
|
|
1312
|
+
this.config.fieldConfig = fieldConfig;
|
|
1313
|
+
this.config.customTypeParams = customTypeParams;
|
|
1314
|
+
}
|
|
1315
|
+
/** @internal */
|
|
1316
|
+
build(table) {
|
|
1317
|
+
return new PgCustomColumn(table, this.config);
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
var PgCustomColumn = class extends PgColumn {
|
|
1321
|
+
static [entityKind] = "PgCustomColumn";
|
|
1322
|
+
sqlName;
|
|
1323
|
+
mapTo;
|
|
1324
|
+
mapFrom;
|
|
1325
|
+
constructor(table, config) {
|
|
1326
|
+
super(table, config);
|
|
1327
|
+
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
1328
|
+
this.mapTo = config.customTypeParams.toDriver;
|
|
1329
|
+
this.mapFrom = config.customTypeParams.fromDriver;
|
|
1330
|
+
}
|
|
1331
|
+
getSQLType() {
|
|
1332
|
+
return this.sqlName;
|
|
1333
|
+
}
|
|
1334
|
+
mapFromDriverValue(value) {
|
|
1335
|
+
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
1336
|
+
}
|
|
1337
|
+
mapToDriverValue(value) {
|
|
1338
|
+
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
function customType(customTypeParams) {
|
|
1342
|
+
return (a, b) => {
|
|
1343
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1344
|
+
return new PgCustomColumnBuilder(name, config, customTypeParams);
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/date.common.js
|
|
1349
|
+
var PgDateColumnBaseBuilder = class extends PgColumnBuilder {
|
|
1350
|
+
static [entityKind] = "PgDateColumnBaseBuilder";
|
|
1351
|
+
defaultNow() {
|
|
1352
|
+
return this.default(sql`now()`);
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
//#endregion
|
|
1356
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/date.js
|
|
1357
|
+
var PgDateBuilder = class extends PgDateColumnBaseBuilder {
|
|
1358
|
+
static [entityKind] = "PgDateBuilder";
|
|
1359
|
+
constructor(name) {
|
|
1360
|
+
super(name, "date", "PgDate");
|
|
1361
|
+
}
|
|
1362
|
+
/** @internal */
|
|
1363
|
+
build(table) {
|
|
1364
|
+
return new PgDate(table, this.config);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
var PgDate = class extends PgColumn {
|
|
1368
|
+
static [entityKind] = "PgDate";
|
|
1369
|
+
getSQLType() {
|
|
1370
|
+
return "date";
|
|
1371
|
+
}
|
|
1372
|
+
mapFromDriverValue(value) {
|
|
1373
|
+
if (typeof value === "string") return new Date(value);
|
|
1374
|
+
return value;
|
|
1375
|
+
}
|
|
1376
|
+
mapToDriverValue(value) {
|
|
1377
|
+
return value.toISOString();
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
var PgDateStringBuilder = class extends PgDateColumnBaseBuilder {
|
|
1381
|
+
static [entityKind] = "PgDateStringBuilder";
|
|
1382
|
+
constructor(name) {
|
|
1383
|
+
super(name, "string", "PgDateString");
|
|
1384
|
+
}
|
|
1385
|
+
/** @internal */
|
|
1386
|
+
build(table) {
|
|
1387
|
+
return new PgDateString(table, this.config);
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
var PgDateString = class extends PgColumn {
|
|
1391
|
+
static [entityKind] = "PgDateString";
|
|
1392
|
+
getSQLType() {
|
|
1393
|
+
return "date";
|
|
1394
|
+
}
|
|
1395
|
+
mapFromDriverValue(value) {
|
|
1396
|
+
if (typeof value === "string") return value;
|
|
1397
|
+
return value.toISOString().slice(0, -14);
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
function date(a, b) {
|
|
1401
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1402
|
+
if (config?.mode === "date") return new PgDateBuilder(name);
|
|
1403
|
+
return new PgDateStringBuilder(name);
|
|
1404
|
+
}
|
|
1405
|
+
//#endregion
|
|
1406
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/double-precision.js
|
|
1407
|
+
var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
|
|
1408
|
+
static [entityKind] = "PgDoublePrecisionBuilder";
|
|
1409
|
+
constructor(name) {
|
|
1410
|
+
super(name, "number", "PgDoublePrecision");
|
|
1411
|
+
}
|
|
1412
|
+
/** @internal */
|
|
1413
|
+
build(table) {
|
|
1414
|
+
return new PgDoublePrecision(table, this.config);
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
var PgDoublePrecision = class extends PgColumn {
|
|
1418
|
+
static [entityKind] = "PgDoublePrecision";
|
|
1419
|
+
getSQLType() {
|
|
1420
|
+
return "double precision";
|
|
1421
|
+
}
|
|
1422
|
+
mapFromDriverValue(value) {
|
|
1423
|
+
if (typeof value === "string") return Number.parseFloat(value);
|
|
1424
|
+
return value;
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
function doublePrecision(name) {
|
|
1428
|
+
return new PgDoublePrecisionBuilder(name ?? "");
|
|
1429
|
+
}
|
|
1430
|
+
//#endregion
|
|
1431
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/inet.js
|
|
1432
|
+
var PgInetBuilder = class extends PgColumnBuilder {
|
|
1433
|
+
static [entityKind] = "PgInetBuilder";
|
|
1434
|
+
constructor(name) {
|
|
1435
|
+
super(name, "string", "PgInet");
|
|
1436
|
+
}
|
|
1437
|
+
/** @internal */
|
|
1438
|
+
build(table) {
|
|
1439
|
+
return new PgInet(table, this.config);
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
var PgInet = class extends PgColumn {
|
|
1443
|
+
static [entityKind] = "PgInet";
|
|
1444
|
+
getSQLType() {
|
|
1445
|
+
return "inet";
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
function inet(name) {
|
|
1449
|
+
return new PgInetBuilder(name ?? "");
|
|
1450
|
+
}
|
|
1451
|
+
//#endregion
|
|
1452
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/integer.js
|
|
1453
|
+
var PgIntegerBuilder = class extends PgIntColumnBaseBuilder {
|
|
1454
|
+
static [entityKind] = "PgIntegerBuilder";
|
|
1455
|
+
constructor(name) {
|
|
1456
|
+
super(name, "number", "PgInteger");
|
|
1457
|
+
}
|
|
1458
|
+
/** @internal */
|
|
1459
|
+
build(table) {
|
|
1460
|
+
return new PgInteger(table, this.config);
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
var PgInteger = class extends PgColumn {
|
|
1464
|
+
static [entityKind] = "PgInteger";
|
|
1465
|
+
getSQLType() {
|
|
1466
|
+
return "integer";
|
|
1467
|
+
}
|
|
1468
|
+
mapFromDriverValue(value) {
|
|
1469
|
+
if (typeof value === "string") return Number.parseInt(value);
|
|
1470
|
+
return value;
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
function integer(name) {
|
|
1474
|
+
return new PgIntegerBuilder(name ?? "");
|
|
1475
|
+
}
|
|
1476
|
+
//#endregion
|
|
1477
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/interval.js
|
|
1478
|
+
var PgIntervalBuilder = class extends PgColumnBuilder {
|
|
1479
|
+
static [entityKind] = "PgIntervalBuilder";
|
|
1480
|
+
constructor(name, intervalConfig) {
|
|
1481
|
+
super(name, "string", "PgInterval");
|
|
1482
|
+
this.config.intervalConfig = intervalConfig;
|
|
1483
|
+
}
|
|
1484
|
+
/** @internal */
|
|
1485
|
+
build(table) {
|
|
1486
|
+
return new PgInterval(table, this.config);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
var PgInterval = class extends PgColumn {
|
|
1490
|
+
static [entityKind] = "PgInterval";
|
|
1491
|
+
fields = this.config.intervalConfig.fields;
|
|
1492
|
+
precision = this.config.intervalConfig.precision;
|
|
1493
|
+
getSQLType() {
|
|
1494
|
+
return `interval${this.fields ? ` ${this.fields}` : ""}${this.precision ? `(${this.precision})` : ""}`;
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
function interval(a, b = {}) {
|
|
1498
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1499
|
+
return new PgIntervalBuilder(name, config);
|
|
1500
|
+
}
|
|
1501
|
+
//#endregion
|
|
1502
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/json.js
|
|
1503
|
+
var PgJsonBuilder = class extends PgColumnBuilder {
|
|
1504
|
+
static [entityKind] = "PgJsonBuilder";
|
|
1505
|
+
constructor(name) {
|
|
1506
|
+
super(name, "json", "PgJson");
|
|
1507
|
+
}
|
|
1508
|
+
/** @internal */
|
|
1509
|
+
build(table) {
|
|
1510
|
+
return new PgJson(table, this.config);
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
var PgJson = class extends PgColumn {
|
|
1514
|
+
static [entityKind] = "PgJson";
|
|
1515
|
+
constructor(table, config) {
|
|
1516
|
+
super(table, config);
|
|
1517
|
+
}
|
|
1518
|
+
getSQLType() {
|
|
1519
|
+
return "json";
|
|
1520
|
+
}
|
|
1521
|
+
mapToDriverValue(value) {
|
|
1522
|
+
return JSON.stringify(value);
|
|
1523
|
+
}
|
|
1524
|
+
mapFromDriverValue(value) {
|
|
1525
|
+
if (typeof value === "string") try {
|
|
1526
|
+
return JSON.parse(value);
|
|
1527
|
+
} catch {
|
|
1528
|
+
return value;
|
|
1529
|
+
}
|
|
1530
|
+
return value;
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
function json(name) {
|
|
1534
|
+
return new PgJsonBuilder(name ?? "");
|
|
1535
|
+
}
|
|
1536
|
+
//#endregion
|
|
1537
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/jsonb.js
|
|
1538
|
+
var PgJsonbBuilder = class extends PgColumnBuilder {
|
|
1539
|
+
static [entityKind] = "PgJsonbBuilder";
|
|
1540
|
+
constructor(name) {
|
|
1541
|
+
super(name, "json", "PgJsonb");
|
|
1542
|
+
}
|
|
1543
|
+
/** @internal */
|
|
1544
|
+
build(table) {
|
|
1545
|
+
return new PgJsonb(table, this.config);
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
var PgJsonb = class extends PgColumn {
|
|
1549
|
+
static [entityKind] = "PgJsonb";
|
|
1550
|
+
constructor(table, config) {
|
|
1551
|
+
super(table, config);
|
|
1552
|
+
}
|
|
1553
|
+
getSQLType() {
|
|
1554
|
+
return "jsonb";
|
|
1555
|
+
}
|
|
1556
|
+
mapToDriverValue(value) {
|
|
1557
|
+
return JSON.stringify(value);
|
|
1558
|
+
}
|
|
1559
|
+
mapFromDriverValue(value) {
|
|
1560
|
+
if (typeof value === "string") try {
|
|
1561
|
+
return JSON.parse(value);
|
|
1562
|
+
} catch {
|
|
1563
|
+
return value;
|
|
1564
|
+
}
|
|
1565
|
+
return value;
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
function jsonb(name) {
|
|
1569
|
+
return new PgJsonbBuilder(name ?? "");
|
|
1570
|
+
}
|
|
1571
|
+
//#endregion
|
|
1572
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/line.js
|
|
1573
|
+
var PgLineBuilder = class extends PgColumnBuilder {
|
|
1574
|
+
static [entityKind] = "PgLineBuilder";
|
|
1575
|
+
constructor(name) {
|
|
1576
|
+
super(name, "array", "PgLine");
|
|
1577
|
+
}
|
|
1578
|
+
/** @internal */
|
|
1579
|
+
build(table) {
|
|
1580
|
+
return new PgLineTuple(table, this.config);
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
var PgLineTuple = class extends PgColumn {
|
|
1584
|
+
static [entityKind] = "PgLine";
|
|
1585
|
+
getSQLType() {
|
|
1586
|
+
return "line";
|
|
1587
|
+
}
|
|
1588
|
+
mapFromDriverValue(value) {
|
|
1589
|
+
const [a, b, c] = value.slice(1, -1).split(",");
|
|
1590
|
+
return [
|
|
1591
|
+
Number.parseFloat(a),
|
|
1592
|
+
Number.parseFloat(b),
|
|
1593
|
+
Number.parseFloat(c)
|
|
1594
|
+
];
|
|
1595
|
+
}
|
|
1596
|
+
mapToDriverValue(value) {
|
|
1597
|
+
return `{${value[0]},${value[1]},${value[2]}}`;
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
var PgLineABCBuilder = class extends PgColumnBuilder {
|
|
1601
|
+
static [entityKind] = "PgLineABCBuilder";
|
|
1602
|
+
constructor(name) {
|
|
1603
|
+
super(name, "json", "PgLineABC");
|
|
1604
|
+
}
|
|
1605
|
+
/** @internal */
|
|
1606
|
+
build(table) {
|
|
1607
|
+
return new PgLineABC(table, this.config);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
var PgLineABC = class extends PgColumn {
|
|
1611
|
+
static [entityKind] = "PgLineABC";
|
|
1612
|
+
getSQLType() {
|
|
1613
|
+
return "line";
|
|
1614
|
+
}
|
|
1615
|
+
mapFromDriverValue(value) {
|
|
1616
|
+
const [a, b, c] = value.slice(1, -1).split(",");
|
|
1617
|
+
return {
|
|
1618
|
+
a: Number.parseFloat(a),
|
|
1619
|
+
b: Number.parseFloat(b),
|
|
1620
|
+
c: Number.parseFloat(c)
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
mapToDriverValue(value) {
|
|
1624
|
+
return `{${value.a},${value.b},${value.c}}`;
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
function line(a, b) {
|
|
1628
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1629
|
+
if (!config?.mode || config.mode === "tuple") return new PgLineBuilder(name);
|
|
1630
|
+
return new PgLineABCBuilder(name);
|
|
1631
|
+
}
|
|
1632
|
+
//#endregion
|
|
1633
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/macaddr.js
|
|
1634
|
+
var PgMacaddrBuilder = class extends PgColumnBuilder {
|
|
1635
|
+
static [entityKind] = "PgMacaddrBuilder";
|
|
1636
|
+
constructor(name) {
|
|
1637
|
+
super(name, "string", "PgMacaddr");
|
|
1638
|
+
}
|
|
1639
|
+
/** @internal */
|
|
1640
|
+
build(table) {
|
|
1641
|
+
return new PgMacaddr(table, this.config);
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
var PgMacaddr = class extends PgColumn {
|
|
1645
|
+
static [entityKind] = "PgMacaddr";
|
|
1646
|
+
getSQLType() {
|
|
1647
|
+
return "macaddr";
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
function macaddr(name) {
|
|
1651
|
+
return new PgMacaddrBuilder(name ?? "");
|
|
1652
|
+
}
|
|
1653
|
+
//#endregion
|
|
1654
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/macaddr8.js
|
|
1655
|
+
var PgMacaddr8Builder = class extends PgColumnBuilder {
|
|
1656
|
+
static [entityKind] = "PgMacaddr8Builder";
|
|
1657
|
+
constructor(name) {
|
|
1658
|
+
super(name, "string", "PgMacaddr8");
|
|
1659
|
+
}
|
|
1660
|
+
/** @internal */
|
|
1661
|
+
build(table) {
|
|
1662
|
+
return new PgMacaddr8(table, this.config);
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
var PgMacaddr8 = class extends PgColumn {
|
|
1666
|
+
static [entityKind] = "PgMacaddr8";
|
|
1667
|
+
getSQLType() {
|
|
1668
|
+
return "macaddr8";
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
function macaddr8(name) {
|
|
1672
|
+
return new PgMacaddr8Builder(name ?? "");
|
|
1673
|
+
}
|
|
1674
|
+
//#endregion
|
|
1675
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/numeric.js
|
|
1676
|
+
var PgNumericBuilder = class extends PgColumnBuilder {
|
|
1677
|
+
static [entityKind] = "PgNumericBuilder";
|
|
1678
|
+
constructor(name, precision, scale) {
|
|
1679
|
+
super(name, "string", "PgNumeric");
|
|
1680
|
+
this.config.precision = precision;
|
|
1681
|
+
this.config.scale = scale;
|
|
1682
|
+
}
|
|
1683
|
+
/** @internal */
|
|
1684
|
+
build(table) {
|
|
1685
|
+
return new PgNumeric(table, this.config);
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
var PgNumeric = class extends PgColumn {
|
|
1689
|
+
static [entityKind] = "PgNumeric";
|
|
1690
|
+
precision;
|
|
1691
|
+
scale;
|
|
1692
|
+
constructor(table, config) {
|
|
1693
|
+
super(table, config);
|
|
1694
|
+
this.precision = config.precision;
|
|
1695
|
+
this.scale = config.scale;
|
|
1696
|
+
}
|
|
1697
|
+
mapFromDriverValue(value) {
|
|
1698
|
+
if (typeof value === "string") return value;
|
|
1699
|
+
return String(value);
|
|
1700
|
+
}
|
|
1701
|
+
getSQLType() {
|
|
1702
|
+
if (this.precision !== void 0 && this.scale !== void 0) return `numeric(${this.precision}, ${this.scale})`;
|
|
1703
|
+
else if (this.precision === void 0) return "numeric";
|
|
1704
|
+
else return `numeric(${this.precision})`;
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
var PgNumericNumberBuilder = class extends PgColumnBuilder {
|
|
1708
|
+
static [entityKind] = "PgNumericNumberBuilder";
|
|
1709
|
+
constructor(name, precision, scale) {
|
|
1710
|
+
super(name, "number", "PgNumericNumber");
|
|
1711
|
+
this.config.precision = precision;
|
|
1712
|
+
this.config.scale = scale;
|
|
1713
|
+
}
|
|
1714
|
+
/** @internal */
|
|
1715
|
+
build(table) {
|
|
1716
|
+
return new PgNumericNumber(table, this.config);
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
var PgNumericNumber = class extends PgColumn {
|
|
1720
|
+
static [entityKind] = "PgNumericNumber";
|
|
1721
|
+
precision;
|
|
1722
|
+
scale;
|
|
1723
|
+
constructor(table, config) {
|
|
1724
|
+
super(table, config);
|
|
1725
|
+
this.precision = config.precision;
|
|
1726
|
+
this.scale = config.scale;
|
|
1727
|
+
}
|
|
1728
|
+
mapFromDriverValue(value) {
|
|
1729
|
+
if (typeof value === "number") return value;
|
|
1730
|
+
return Number(value);
|
|
1731
|
+
}
|
|
1732
|
+
mapToDriverValue = String;
|
|
1733
|
+
getSQLType() {
|
|
1734
|
+
if (this.precision !== void 0 && this.scale !== void 0) return `numeric(${this.precision}, ${this.scale})`;
|
|
1735
|
+
else if (this.precision === void 0) return "numeric";
|
|
1736
|
+
else return `numeric(${this.precision})`;
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
var PgNumericBigIntBuilder = class extends PgColumnBuilder {
|
|
1740
|
+
static [entityKind] = "PgNumericBigIntBuilder";
|
|
1741
|
+
constructor(name, precision, scale) {
|
|
1742
|
+
super(name, "bigint", "PgNumericBigInt");
|
|
1743
|
+
this.config.precision = precision;
|
|
1744
|
+
this.config.scale = scale;
|
|
1745
|
+
}
|
|
1746
|
+
/** @internal */
|
|
1747
|
+
build(table) {
|
|
1748
|
+
return new PgNumericBigInt(table, this.config);
|
|
1749
|
+
}
|
|
1750
|
+
};
|
|
1751
|
+
var PgNumericBigInt = class extends PgColumn {
|
|
1752
|
+
static [entityKind] = "PgNumericBigInt";
|
|
1753
|
+
precision;
|
|
1754
|
+
scale;
|
|
1755
|
+
constructor(table, config) {
|
|
1756
|
+
super(table, config);
|
|
1757
|
+
this.precision = config.precision;
|
|
1758
|
+
this.scale = config.scale;
|
|
1759
|
+
}
|
|
1760
|
+
mapFromDriverValue = BigInt;
|
|
1761
|
+
mapToDriverValue = String;
|
|
1762
|
+
getSQLType() {
|
|
1763
|
+
if (this.precision !== void 0 && this.scale !== void 0) return `numeric(${this.precision}, ${this.scale})`;
|
|
1764
|
+
else if (this.precision === void 0) return "numeric";
|
|
1765
|
+
else return `numeric(${this.precision})`;
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
function numeric(a, b) {
|
|
1769
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1770
|
+
const mode = config?.mode;
|
|
1771
|
+
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);
|
|
1772
|
+
}
|
|
1773
|
+
//#endregion
|
|
1774
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/point.js
|
|
1775
|
+
var PgPointTupleBuilder = class extends PgColumnBuilder {
|
|
1776
|
+
static [entityKind] = "PgPointTupleBuilder";
|
|
1777
|
+
constructor(name) {
|
|
1778
|
+
super(name, "array", "PgPointTuple");
|
|
1779
|
+
}
|
|
1780
|
+
/** @internal */
|
|
1781
|
+
build(table) {
|
|
1782
|
+
return new PgPointTuple(table, this.config);
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
var PgPointTuple = class extends PgColumn {
|
|
1786
|
+
static [entityKind] = "PgPointTuple";
|
|
1787
|
+
getSQLType() {
|
|
1788
|
+
return "point";
|
|
1789
|
+
}
|
|
1790
|
+
mapFromDriverValue(value) {
|
|
1791
|
+
if (typeof value === "string") {
|
|
1792
|
+
const [x, y] = value.slice(1, -1).split(",");
|
|
1793
|
+
return [Number.parseFloat(x), Number.parseFloat(y)];
|
|
1794
|
+
}
|
|
1795
|
+
return [value.x, value.y];
|
|
1796
|
+
}
|
|
1797
|
+
mapToDriverValue(value) {
|
|
1798
|
+
return `(${value[0]},${value[1]})`;
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
var PgPointObjectBuilder = class extends PgColumnBuilder {
|
|
1802
|
+
static [entityKind] = "PgPointObjectBuilder";
|
|
1803
|
+
constructor(name) {
|
|
1804
|
+
super(name, "json", "PgPointObject");
|
|
1805
|
+
}
|
|
1806
|
+
/** @internal */
|
|
1807
|
+
build(table) {
|
|
1808
|
+
return new PgPointObject(table, this.config);
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1811
|
+
var PgPointObject = class extends PgColumn {
|
|
1812
|
+
static [entityKind] = "PgPointObject";
|
|
1813
|
+
getSQLType() {
|
|
1814
|
+
return "point";
|
|
1815
|
+
}
|
|
1816
|
+
mapFromDriverValue(value) {
|
|
1817
|
+
if (typeof value === "string") {
|
|
1818
|
+
const [x, y] = value.slice(1, -1).split(",");
|
|
1819
|
+
return {
|
|
1820
|
+
x: Number.parseFloat(x),
|
|
1821
|
+
y: Number.parseFloat(y)
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
return value;
|
|
1825
|
+
}
|
|
1826
|
+
mapToDriverValue(value) {
|
|
1827
|
+
return `(${value.x},${value.y})`;
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
function point(a, b) {
|
|
1831
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1832
|
+
if (!config?.mode || config.mode === "tuple") return new PgPointTupleBuilder(name);
|
|
1833
|
+
return new PgPointObjectBuilder(name);
|
|
1834
|
+
}
|
|
1835
|
+
//#endregion
|
|
1836
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
|
|
1837
|
+
function hexToBytes(hex) {
|
|
1838
|
+
const bytes = [];
|
|
1839
|
+
for (let c = 0; c < hex.length; c += 2) bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
|
|
1840
|
+
return new Uint8Array(bytes);
|
|
1841
|
+
}
|
|
1842
|
+
function bytesToFloat64(bytes, offset) {
|
|
1843
|
+
const view = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
1844
|
+
for (let i = 0; i < 8; i++) view.setUint8(i, bytes[offset + i]);
|
|
1845
|
+
return view.getFloat64(0, true);
|
|
1846
|
+
}
|
|
1847
|
+
function parseEWKB(hex) {
|
|
1848
|
+
const bytes = hexToBytes(hex);
|
|
1849
|
+
let offset = 0;
|
|
1850
|
+
const byteOrder = bytes[offset];
|
|
1851
|
+
offset += 1;
|
|
1852
|
+
const view = new DataView(bytes.buffer);
|
|
1853
|
+
const geomType = view.getUint32(offset, byteOrder === 1);
|
|
1854
|
+
offset += 4;
|
|
1855
|
+
if (geomType & 536870912) {
|
|
1856
|
+
view.getUint32(offset, byteOrder === 1);
|
|
1857
|
+
offset += 4;
|
|
1858
|
+
}
|
|
1859
|
+
if ((geomType & 65535) === 1) {
|
|
1860
|
+
const x = bytesToFloat64(bytes, offset);
|
|
1861
|
+
offset += 8;
|
|
1862
|
+
const y = bytesToFloat64(bytes, offset);
|
|
1863
|
+
offset += 8;
|
|
1864
|
+
return [x, y];
|
|
1865
|
+
}
|
|
1866
|
+
throw new Error("Unsupported geometry type");
|
|
1867
|
+
}
|
|
1868
|
+
//#endregion
|
|
1869
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
|
|
1870
|
+
var PgGeometryBuilder = class extends PgColumnBuilder {
|
|
1871
|
+
static [entityKind] = "PgGeometryBuilder";
|
|
1872
|
+
constructor(name) {
|
|
1873
|
+
super(name, "array", "PgGeometry");
|
|
1874
|
+
}
|
|
1875
|
+
/** @internal */
|
|
1876
|
+
build(table) {
|
|
1877
|
+
return new PgGeometry(table, this.config);
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
var PgGeometry = class extends PgColumn {
|
|
1881
|
+
static [entityKind] = "PgGeometry";
|
|
1882
|
+
getSQLType() {
|
|
1883
|
+
return "geometry(point)";
|
|
1884
|
+
}
|
|
1885
|
+
mapFromDriverValue(value) {
|
|
1886
|
+
return parseEWKB(value);
|
|
1887
|
+
}
|
|
1888
|
+
mapToDriverValue(value) {
|
|
1889
|
+
return `point(${value[0]} ${value[1]})`;
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
var PgGeometryObjectBuilder = class extends PgColumnBuilder {
|
|
1893
|
+
static [entityKind] = "PgGeometryObjectBuilder";
|
|
1894
|
+
constructor(name) {
|
|
1895
|
+
super(name, "json", "PgGeometryObject");
|
|
1896
|
+
}
|
|
1897
|
+
/** @internal */
|
|
1898
|
+
build(table) {
|
|
1899
|
+
return new PgGeometryObject(table, this.config);
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
var PgGeometryObject = class extends PgColumn {
|
|
1903
|
+
static [entityKind] = "PgGeometryObject";
|
|
1904
|
+
getSQLType() {
|
|
1905
|
+
return "geometry(point)";
|
|
1906
|
+
}
|
|
1907
|
+
mapFromDriverValue(value) {
|
|
1908
|
+
const parsed = parseEWKB(value);
|
|
1909
|
+
return {
|
|
1910
|
+
x: parsed[0],
|
|
1911
|
+
y: parsed[1]
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
mapToDriverValue(value) {
|
|
1915
|
+
return `point(${value.x} ${value.y})`;
|
|
1916
|
+
}
|
|
1917
|
+
};
|
|
1918
|
+
function geometry(a, b) {
|
|
1919
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1920
|
+
if (!config?.mode || config.mode === "tuple") return new PgGeometryBuilder(name);
|
|
1921
|
+
return new PgGeometryObjectBuilder(name);
|
|
1922
|
+
}
|
|
1923
|
+
//#endregion
|
|
1924
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/real.js
|
|
1925
|
+
var PgRealBuilder = class extends PgColumnBuilder {
|
|
1926
|
+
static [entityKind] = "PgRealBuilder";
|
|
1927
|
+
constructor(name, length) {
|
|
1928
|
+
super(name, "number", "PgReal");
|
|
1929
|
+
this.config.length = length;
|
|
1930
|
+
}
|
|
1931
|
+
/** @internal */
|
|
1932
|
+
build(table) {
|
|
1933
|
+
return new PgReal(table, this.config);
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
var PgReal = class extends PgColumn {
|
|
1937
|
+
static [entityKind] = "PgReal";
|
|
1938
|
+
constructor(table, config) {
|
|
1939
|
+
super(table, config);
|
|
1940
|
+
}
|
|
1941
|
+
getSQLType() {
|
|
1942
|
+
return "real";
|
|
1943
|
+
}
|
|
1944
|
+
mapFromDriverValue = (value) => {
|
|
1945
|
+
if (typeof value === "string") return Number.parseFloat(value);
|
|
1946
|
+
return value;
|
|
1947
|
+
};
|
|
1948
|
+
};
|
|
1949
|
+
function real(name) {
|
|
1950
|
+
return new PgRealBuilder(name ?? "");
|
|
1951
|
+
}
|
|
1952
|
+
//#endregion
|
|
1953
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/serial.js
|
|
1954
|
+
var PgSerialBuilder = class extends PgColumnBuilder {
|
|
1955
|
+
static [entityKind] = "PgSerialBuilder";
|
|
1956
|
+
constructor(name) {
|
|
1957
|
+
super(name, "number", "PgSerial");
|
|
1958
|
+
this.config.hasDefault = true;
|
|
1959
|
+
this.config.notNull = true;
|
|
1960
|
+
}
|
|
1961
|
+
/** @internal */
|
|
1962
|
+
build(table) {
|
|
1963
|
+
return new PgSerial(table, this.config);
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
var PgSerial = class extends PgColumn {
|
|
1967
|
+
static [entityKind] = "PgSerial";
|
|
1968
|
+
getSQLType() {
|
|
1969
|
+
return "serial";
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
function serial(name) {
|
|
1973
|
+
return new PgSerialBuilder(name ?? "");
|
|
1974
|
+
}
|
|
1975
|
+
//#endregion
|
|
1976
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/smallint.js
|
|
1977
|
+
var PgSmallIntBuilder = class extends PgIntColumnBaseBuilder {
|
|
1978
|
+
static [entityKind] = "PgSmallIntBuilder";
|
|
1979
|
+
constructor(name) {
|
|
1980
|
+
super(name, "number", "PgSmallInt");
|
|
1981
|
+
}
|
|
1982
|
+
/** @internal */
|
|
1983
|
+
build(table) {
|
|
1984
|
+
return new PgSmallInt(table, this.config);
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
var PgSmallInt = class extends PgColumn {
|
|
1988
|
+
static [entityKind] = "PgSmallInt";
|
|
1989
|
+
getSQLType() {
|
|
1990
|
+
return "smallint";
|
|
1991
|
+
}
|
|
1992
|
+
mapFromDriverValue = (value) => {
|
|
1993
|
+
if (typeof value === "string") return Number(value);
|
|
1994
|
+
return value;
|
|
1995
|
+
};
|
|
1996
|
+
};
|
|
1997
|
+
function smallint(name) {
|
|
1998
|
+
return new PgSmallIntBuilder(name ?? "");
|
|
1999
|
+
}
|
|
2000
|
+
//#endregion
|
|
2001
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/smallserial.js
|
|
2002
|
+
var PgSmallSerialBuilder = class extends PgColumnBuilder {
|
|
2003
|
+
static [entityKind] = "PgSmallSerialBuilder";
|
|
2004
|
+
constructor(name) {
|
|
2005
|
+
super(name, "number", "PgSmallSerial");
|
|
2006
|
+
this.config.hasDefault = true;
|
|
2007
|
+
this.config.notNull = true;
|
|
2008
|
+
}
|
|
2009
|
+
/** @internal */
|
|
2010
|
+
build(table) {
|
|
2011
|
+
return new PgSmallSerial(table, this.config);
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
var PgSmallSerial = class extends PgColumn {
|
|
2015
|
+
static [entityKind] = "PgSmallSerial";
|
|
2016
|
+
getSQLType() {
|
|
2017
|
+
return "smallserial";
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
function smallserial(name) {
|
|
2021
|
+
return new PgSmallSerialBuilder(name ?? "");
|
|
2022
|
+
}
|
|
2023
|
+
//#endregion
|
|
2024
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/text.js
|
|
2025
|
+
var PgTextBuilder = class extends PgColumnBuilder {
|
|
2026
|
+
static [entityKind] = "PgTextBuilder";
|
|
2027
|
+
constructor(name, config) {
|
|
2028
|
+
super(name, "string", "PgText");
|
|
2029
|
+
this.config.enumValues = config.enum;
|
|
2030
|
+
}
|
|
2031
|
+
/** @internal */
|
|
2032
|
+
build(table) {
|
|
2033
|
+
return new PgText(table, this.config);
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
var PgText = class extends PgColumn {
|
|
2037
|
+
static [entityKind] = "PgText";
|
|
2038
|
+
enumValues = this.config.enumValues;
|
|
2039
|
+
getSQLType() {
|
|
2040
|
+
return "text";
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
function text(a, b = {}) {
|
|
2044
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2045
|
+
return new PgTextBuilder(name, config);
|
|
2046
|
+
}
|
|
2047
|
+
//#endregion
|
|
2048
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/time.js
|
|
2049
|
+
var PgTimeBuilder = class extends PgDateColumnBaseBuilder {
|
|
2050
|
+
constructor(name, withTimezone, precision) {
|
|
2051
|
+
super(name, "string", "PgTime");
|
|
2052
|
+
this.withTimezone = withTimezone;
|
|
2053
|
+
this.precision = precision;
|
|
2054
|
+
this.config.withTimezone = withTimezone;
|
|
2055
|
+
this.config.precision = precision;
|
|
2056
|
+
}
|
|
2057
|
+
static [entityKind] = "PgTimeBuilder";
|
|
2058
|
+
/** @internal */
|
|
2059
|
+
build(table) {
|
|
2060
|
+
return new PgTime(table, this.config);
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
var PgTime = class extends PgColumn {
|
|
2064
|
+
static [entityKind] = "PgTime";
|
|
2065
|
+
withTimezone;
|
|
2066
|
+
precision;
|
|
2067
|
+
constructor(table, config) {
|
|
2068
|
+
super(table, config);
|
|
2069
|
+
this.withTimezone = config.withTimezone;
|
|
2070
|
+
this.precision = config.precision;
|
|
2071
|
+
}
|
|
2072
|
+
getSQLType() {
|
|
2073
|
+
return `time${this.precision === void 0 ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
function time(a, b = {}) {
|
|
2077
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2078
|
+
return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
|
|
2079
|
+
}
|
|
2080
|
+
//#endregion
|
|
2081
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/timestamp.js
|
|
2082
|
+
var PgTimestampBuilder = class extends PgDateColumnBaseBuilder {
|
|
2083
|
+
static [entityKind] = "PgTimestampBuilder";
|
|
2084
|
+
constructor(name, withTimezone, precision) {
|
|
2085
|
+
super(name, "date", "PgTimestamp");
|
|
2086
|
+
this.config.withTimezone = withTimezone;
|
|
2087
|
+
this.config.precision = precision;
|
|
2088
|
+
}
|
|
2089
|
+
/** @internal */
|
|
2090
|
+
build(table) {
|
|
2091
|
+
return new PgTimestamp(table, this.config);
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2094
|
+
var PgTimestamp = class extends PgColumn {
|
|
2095
|
+
static [entityKind] = "PgTimestamp";
|
|
2096
|
+
withTimezone;
|
|
2097
|
+
precision;
|
|
2098
|
+
constructor(table, config) {
|
|
2099
|
+
super(table, config);
|
|
2100
|
+
this.withTimezone = config.withTimezone;
|
|
2101
|
+
this.precision = config.precision;
|
|
2102
|
+
}
|
|
2103
|
+
getSQLType() {
|
|
2104
|
+
return `timestamp${this.precision === void 0 ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
|
|
2105
|
+
}
|
|
2106
|
+
mapFromDriverValue(value) {
|
|
2107
|
+
if (typeof value === "string") return new Date(this.withTimezone ? value : value + "+0000");
|
|
2108
|
+
return value;
|
|
2109
|
+
}
|
|
2110
|
+
mapToDriverValue = (value) => {
|
|
2111
|
+
return value.toISOString();
|
|
2112
|
+
};
|
|
2113
|
+
};
|
|
2114
|
+
var PgTimestampStringBuilder = class extends PgDateColumnBaseBuilder {
|
|
2115
|
+
static [entityKind] = "PgTimestampStringBuilder";
|
|
2116
|
+
constructor(name, withTimezone, precision) {
|
|
2117
|
+
super(name, "string", "PgTimestampString");
|
|
2118
|
+
this.config.withTimezone = withTimezone;
|
|
2119
|
+
this.config.precision = precision;
|
|
2120
|
+
}
|
|
2121
|
+
/** @internal */
|
|
2122
|
+
build(table) {
|
|
2123
|
+
return new PgTimestampString(table, this.config);
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
var PgTimestampString = class extends PgColumn {
|
|
2127
|
+
static [entityKind] = "PgTimestampString";
|
|
2128
|
+
withTimezone;
|
|
2129
|
+
precision;
|
|
2130
|
+
constructor(table, config) {
|
|
2131
|
+
super(table, config);
|
|
2132
|
+
this.withTimezone = config.withTimezone;
|
|
2133
|
+
this.precision = config.precision;
|
|
2134
|
+
}
|
|
2135
|
+
getSQLType() {
|
|
2136
|
+
return `timestamp${this.precision === void 0 ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
|
|
2137
|
+
}
|
|
2138
|
+
mapFromDriverValue(value) {
|
|
2139
|
+
if (typeof value === "string") return value;
|
|
2140
|
+
const shortened = value.toISOString().slice(0, -1).replace("T", " ");
|
|
2141
|
+
if (this.withTimezone) {
|
|
2142
|
+
const offset = value.getTimezoneOffset();
|
|
2143
|
+
return `${shortened}${offset <= 0 ? "+" : "-"}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
|
|
2144
|
+
}
|
|
2145
|
+
return shortened;
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
function timestamp(a, b = {}) {
|
|
2149
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2150
|
+
if (config?.mode === "string") return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
|
|
2151
|
+
return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
|
|
2152
|
+
}
|
|
2153
|
+
//#endregion
|
|
2154
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/uuid.js
|
|
2155
|
+
var PgUUIDBuilder = class extends PgColumnBuilder {
|
|
2156
|
+
static [entityKind] = "PgUUIDBuilder";
|
|
2157
|
+
constructor(name) {
|
|
2158
|
+
super(name, "string", "PgUUID");
|
|
2159
|
+
}
|
|
2160
|
+
/**
|
|
2161
|
+
* Adds `default gen_random_uuid()` to the column definition.
|
|
2162
|
+
*/
|
|
2163
|
+
defaultRandom() {
|
|
2164
|
+
return this.default(sql`gen_random_uuid()`);
|
|
2165
|
+
}
|
|
2166
|
+
/** @internal */
|
|
2167
|
+
build(table) {
|
|
2168
|
+
return new PgUUID(table, this.config);
|
|
2169
|
+
}
|
|
2170
|
+
};
|
|
2171
|
+
var PgUUID = class extends PgColumn {
|
|
2172
|
+
static [entityKind] = "PgUUID";
|
|
2173
|
+
getSQLType() {
|
|
2174
|
+
return "uuid";
|
|
2175
|
+
}
|
|
2176
|
+
};
|
|
2177
|
+
function uuid(name) {
|
|
2178
|
+
return new PgUUIDBuilder(name ?? "");
|
|
2179
|
+
}
|
|
2180
|
+
//#endregion
|
|
2181
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/varchar.js
|
|
2182
|
+
var PgVarcharBuilder = class extends PgColumnBuilder {
|
|
2183
|
+
static [entityKind] = "PgVarcharBuilder";
|
|
2184
|
+
constructor(name, config) {
|
|
2185
|
+
super(name, "string", "PgVarchar");
|
|
2186
|
+
this.config.length = config.length;
|
|
2187
|
+
this.config.enumValues = config.enum;
|
|
2188
|
+
}
|
|
2189
|
+
/** @internal */
|
|
2190
|
+
build(table) {
|
|
2191
|
+
return new PgVarchar(table, this.config);
|
|
2192
|
+
}
|
|
2193
|
+
};
|
|
2194
|
+
var PgVarchar = class extends PgColumn {
|
|
2195
|
+
static [entityKind] = "PgVarchar";
|
|
2196
|
+
length = this.config.length;
|
|
2197
|
+
enumValues = this.config.enumValues;
|
|
2198
|
+
getSQLType() {
|
|
2199
|
+
return this.length === void 0 ? `varchar` : `varchar(${this.length})`;
|
|
2200
|
+
}
|
|
2201
|
+
};
|
|
2202
|
+
function varchar(a, b = {}) {
|
|
2203
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2204
|
+
return new PgVarcharBuilder(name, config);
|
|
2205
|
+
}
|
|
2206
|
+
//#endregion
|
|
2207
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
|
|
2208
|
+
var PgBinaryVectorBuilder = class extends PgColumnBuilder {
|
|
2209
|
+
static [entityKind] = "PgBinaryVectorBuilder";
|
|
2210
|
+
constructor(name, config) {
|
|
2211
|
+
super(name, "string", "PgBinaryVector");
|
|
2212
|
+
this.config.dimensions = config.dimensions;
|
|
2213
|
+
}
|
|
2214
|
+
/** @internal */
|
|
2215
|
+
build(table) {
|
|
2216
|
+
return new PgBinaryVector(table, this.config);
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
var PgBinaryVector = class extends PgColumn {
|
|
2220
|
+
static [entityKind] = "PgBinaryVector";
|
|
2221
|
+
dimensions = this.config.dimensions;
|
|
2222
|
+
getSQLType() {
|
|
2223
|
+
return `bit(${this.dimensions})`;
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
function bit(a, b) {
|
|
2227
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2228
|
+
return new PgBinaryVectorBuilder(name, config);
|
|
2229
|
+
}
|
|
2230
|
+
//#endregion
|
|
2231
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
|
|
2232
|
+
var PgHalfVectorBuilder = class extends PgColumnBuilder {
|
|
2233
|
+
static [entityKind] = "PgHalfVectorBuilder";
|
|
2234
|
+
constructor(name, config) {
|
|
2235
|
+
super(name, "array", "PgHalfVector");
|
|
2236
|
+
this.config.dimensions = config.dimensions;
|
|
2237
|
+
}
|
|
2238
|
+
/** @internal */
|
|
2239
|
+
build(table) {
|
|
2240
|
+
return new PgHalfVector(table, this.config);
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
var PgHalfVector = class extends PgColumn {
|
|
2244
|
+
static [entityKind] = "PgHalfVector";
|
|
2245
|
+
dimensions = this.config.dimensions;
|
|
2246
|
+
getSQLType() {
|
|
2247
|
+
return `halfvec(${this.dimensions})`;
|
|
2248
|
+
}
|
|
2249
|
+
mapToDriverValue(value) {
|
|
2250
|
+
return JSON.stringify(value);
|
|
2251
|
+
}
|
|
2252
|
+
mapFromDriverValue(value) {
|
|
2253
|
+
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
function halfvec(a, b) {
|
|
2257
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2258
|
+
return new PgHalfVectorBuilder(name, config);
|
|
2259
|
+
}
|
|
2260
|
+
//#endregion
|
|
2261
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
|
|
2262
|
+
var PgSparseVectorBuilder = class extends PgColumnBuilder {
|
|
2263
|
+
static [entityKind] = "PgSparseVectorBuilder";
|
|
2264
|
+
constructor(name, config) {
|
|
2265
|
+
super(name, "string", "PgSparseVector");
|
|
2266
|
+
this.config.dimensions = config.dimensions;
|
|
2267
|
+
}
|
|
2268
|
+
/** @internal */
|
|
2269
|
+
build(table) {
|
|
2270
|
+
return new PgSparseVector(table, this.config);
|
|
2271
|
+
}
|
|
2272
|
+
};
|
|
2273
|
+
var PgSparseVector = class extends PgColumn {
|
|
2274
|
+
static [entityKind] = "PgSparseVector";
|
|
2275
|
+
dimensions = this.config.dimensions;
|
|
2276
|
+
getSQLType() {
|
|
2277
|
+
return `sparsevec(${this.dimensions})`;
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
2280
|
+
function sparsevec(a, b) {
|
|
2281
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2282
|
+
return new PgSparseVectorBuilder(name, config);
|
|
2283
|
+
}
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
|
|
2286
|
+
var PgVectorBuilder = class extends PgColumnBuilder {
|
|
2287
|
+
static [entityKind] = "PgVectorBuilder";
|
|
2288
|
+
constructor(name, config) {
|
|
2289
|
+
super(name, "array", "PgVector");
|
|
2290
|
+
this.config.dimensions = config.dimensions;
|
|
2291
|
+
}
|
|
2292
|
+
/** @internal */
|
|
2293
|
+
build(table) {
|
|
2294
|
+
return new PgVector(table, this.config);
|
|
2295
|
+
}
|
|
2296
|
+
};
|
|
2297
|
+
var PgVector = class extends PgColumn {
|
|
2298
|
+
static [entityKind] = "PgVector";
|
|
2299
|
+
dimensions = this.config.dimensions;
|
|
2300
|
+
getSQLType() {
|
|
2301
|
+
return `vector(${this.dimensions})`;
|
|
2302
|
+
}
|
|
2303
|
+
mapToDriverValue(value) {
|
|
2304
|
+
return JSON.stringify(value);
|
|
2305
|
+
}
|
|
2306
|
+
mapFromDriverValue(value) {
|
|
2307
|
+
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
function vector(a, b) {
|
|
2311
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2312
|
+
return new PgVectorBuilder(name, config);
|
|
2313
|
+
}
|
|
2314
|
+
//#endregion
|
|
2315
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/columns/all.js
|
|
2316
|
+
function getPgColumnBuilders() {
|
|
2317
|
+
return {
|
|
2318
|
+
bigint,
|
|
2319
|
+
bigserial,
|
|
2320
|
+
boolean,
|
|
2321
|
+
char,
|
|
2322
|
+
cidr,
|
|
2323
|
+
customType,
|
|
2324
|
+
date,
|
|
2325
|
+
doublePrecision,
|
|
2326
|
+
inet,
|
|
2327
|
+
integer,
|
|
2328
|
+
interval,
|
|
2329
|
+
json,
|
|
2330
|
+
jsonb,
|
|
2331
|
+
line,
|
|
2332
|
+
macaddr,
|
|
2333
|
+
macaddr8,
|
|
2334
|
+
numeric,
|
|
2335
|
+
point,
|
|
2336
|
+
geometry,
|
|
2337
|
+
real,
|
|
2338
|
+
serial,
|
|
2339
|
+
smallint,
|
|
2340
|
+
smallserial,
|
|
2341
|
+
text,
|
|
2342
|
+
time,
|
|
2343
|
+
timestamp,
|
|
2344
|
+
uuid,
|
|
2345
|
+
varchar,
|
|
2346
|
+
bit,
|
|
2347
|
+
halfvec,
|
|
2348
|
+
sparsevec,
|
|
2349
|
+
vector
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
//#endregion
|
|
2353
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/table.js
|
|
2354
|
+
const InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
|
|
2355
|
+
const EnableRLS = Symbol.for("drizzle:EnableRLS");
|
|
2356
|
+
var PgTable = class extends Table {
|
|
2357
|
+
static [entityKind] = "PgTable";
|
|
2358
|
+
/** @internal */
|
|
2359
|
+
static Symbol = Object.assign({}, Table.Symbol, {
|
|
2360
|
+
InlineForeignKeys,
|
|
2361
|
+
EnableRLS
|
|
2362
|
+
});
|
|
2363
|
+
/**@internal */
|
|
2364
|
+
[InlineForeignKeys] = [];
|
|
2365
|
+
/** @internal */
|
|
2366
|
+
[EnableRLS] = false;
|
|
2367
|
+
/** @internal */
|
|
2368
|
+
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
|
2369
|
+
/** @internal */
|
|
2370
|
+
[Table.Symbol.ExtraConfigColumns] = {};
|
|
2371
|
+
};
|
|
2372
|
+
function pgTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
|
|
2373
|
+
const rawTable = new PgTable(name, schema, baseName);
|
|
2374
|
+
const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
|
|
2375
|
+
const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
2376
|
+
const colBuilder = colBuilderBase;
|
|
2377
|
+
colBuilder.setName(name2);
|
|
2378
|
+
const column = colBuilder.build(rawTable);
|
|
2379
|
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
2380
|
+
return [name2, column];
|
|
2381
|
+
}));
|
|
2382
|
+
const builtColumnsForExtraConfig = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
2383
|
+
const colBuilder = colBuilderBase;
|
|
2384
|
+
colBuilder.setName(name2);
|
|
2385
|
+
return [name2, colBuilder.buildExtraConfigColumn(rawTable)];
|
|
2386
|
+
}));
|
|
2387
|
+
const table = Object.assign(rawTable, builtColumns);
|
|
2388
|
+
table[Table.Symbol.Columns] = builtColumns;
|
|
2389
|
+
table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
|
|
2390
|
+
if (extraConfig) table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
|
2391
|
+
return Object.assign(table, { enableRLS: () => {
|
|
2392
|
+
table[PgTable.Symbol.EnableRLS] = true;
|
|
2393
|
+
return table;
|
|
2394
|
+
} });
|
|
2395
|
+
}
|
|
2396
|
+
const pgTable = (name, columns, extraConfig) => {
|
|
2397
|
+
return pgTableWithSchema(name, columns, extraConfig, void 0);
|
|
2398
|
+
};
|
|
2399
|
+
//#endregion
|
|
2400
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/pg-core/primary-keys.js
|
|
2401
|
+
function primaryKey(...config) {
|
|
2402
|
+
if (config[0].columns) return new PrimaryKeyBuilder(config[0].columns, config[0].name);
|
|
2403
|
+
return new PrimaryKeyBuilder(config);
|
|
2404
|
+
}
|
|
2405
|
+
var PrimaryKeyBuilder = class {
|
|
2406
|
+
static [entityKind] = "PgPrimaryKeyBuilder";
|
|
2407
|
+
/** @internal */
|
|
2408
|
+
columns;
|
|
2409
|
+
/** @internal */
|
|
2410
|
+
name;
|
|
2411
|
+
constructor(columns, name) {
|
|
2412
|
+
this.columns = columns;
|
|
2413
|
+
this.name = name;
|
|
2414
|
+
}
|
|
2415
|
+
/** @internal */
|
|
2416
|
+
build(table) {
|
|
2417
|
+
return new PrimaryKey(table, this.columns, this.name);
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
var PrimaryKey = class {
|
|
2421
|
+
constructor(table, columns, name) {
|
|
2422
|
+
this.table = table;
|
|
2423
|
+
this.columns = columns;
|
|
2424
|
+
this.name = name;
|
|
2425
|
+
}
|
|
2426
|
+
static [entityKind] = "PgPrimaryKey";
|
|
2427
|
+
columns;
|
|
2428
|
+
name;
|
|
2429
|
+
getName() {
|
|
2430
|
+
return this.name ?? `${this.table[PgTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
|
|
2431
|
+
}
|
|
2432
|
+
};
|
|
2433
|
+
//#endregion
|
|
2434
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
2435
|
+
function bindIfParam(value, column) {
|
|
2436
|
+
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) return new Param(value, column);
|
|
2437
|
+
return value;
|
|
2438
|
+
}
|
|
2439
|
+
const eq = (left, right) => {
|
|
2440
|
+
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
2441
|
+
};
|
|
2442
|
+
const ne = (left, right) => {
|
|
2443
|
+
return sql`${left} <> ${bindIfParam(right, left)}`;
|
|
2444
|
+
};
|
|
2445
|
+
function and(...unfilteredConditions) {
|
|
2446
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2447
|
+
if (conditions.length === 0) return;
|
|
2448
|
+
if (conditions.length === 1) return new SQL(conditions);
|
|
2449
|
+
return new SQL([
|
|
2450
|
+
new StringChunk("("),
|
|
2451
|
+
sql.join(conditions, new StringChunk(" and ")),
|
|
2452
|
+
new StringChunk(")")
|
|
2453
|
+
]);
|
|
2454
|
+
}
|
|
2455
|
+
function or(...unfilteredConditions) {
|
|
2456
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2457
|
+
if (conditions.length === 0) return;
|
|
2458
|
+
if (conditions.length === 1) return new SQL(conditions);
|
|
2459
|
+
return new SQL([
|
|
2460
|
+
new StringChunk("("),
|
|
2461
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
2462
|
+
new StringChunk(")")
|
|
2463
|
+
]);
|
|
2464
|
+
}
|
|
2465
|
+
function not(condition) {
|
|
2466
|
+
return sql`not ${condition}`;
|
|
2467
|
+
}
|
|
2468
|
+
const gt = (left, right) => {
|
|
2469
|
+
return sql`${left} > ${bindIfParam(right, left)}`;
|
|
2470
|
+
};
|
|
2471
|
+
const gte = (left, right) => {
|
|
2472
|
+
return sql`${left} >= ${bindIfParam(right, left)}`;
|
|
2473
|
+
};
|
|
2474
|
+
const lt = (left, right) => {
|
|
2475
|
+
return sql`${left} < ${bindIfParam(right, left)}`;
|
|
2476
|
+
};
|
|
2477
|
+
const lte = (left, right) => {
|
|
2478
|
+
return sql`${left} <= ${bindIfParam(right, left)}`;
|
|
2479
|
+
};
|
|
2480
|
+
function inArray(column, values) {
|
|
2481
|
+
if (Array.isArray(values)) {
|
|
2482
|
+
if (values.length === 0) return sql`false`;
|
|
2483
|
+
return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
|
|
2484
|
+
}
|
|
2485
|
+
return sql`${column} in ${bindIfParam(values, column)}`;
|
|
2486
|
+
}
|
|
2487
|
+
function notInArray(column, values) {
|
|
2488
|
+
if (Array.isArray(values)) {
|
|
2489
|
+
if (values.length === 0) return sql`true`;
|
|
2490
|
+
return sql`${column} not in ${values.map((v) => bindIfParam(v, column))}`;
|
|
2491
|
+
}
|
|
2492
|
+
return sql`${column} not in ${bindIfParam(values, column)}`;
|
|
2493
|
+
}
|
|
2494
|
+
function isNull(value) {
|
|
2495
|
+
return sql`${value} is null`;
|
|
2496
|
+
}
|
|
2497
|
+
function isNotNull(value) {
|
|
2498
|
+
return sql`${value} is not null`;
|
|
2499
|
+
}
|
|
2500
|
+
function exists(subquery) {
|
|
2501
|
+
return sql`exists ${subquery}`;
|
|
2502
|
+
}
|
|
2503
|
+
function notExists(subquery) {
|
|
2504
|
+
return sql`not exists ${subquery}`;
|
|
2505
|
+
}
|
|
2506
|
+
function between(column, min, max) {
|
|
2507
|
+
return sql`${column} between ${bindIfParam(min, column)} and ${bindIfParam(max, column)}`;
|
|
2508
|
+
}
|
|
2509
|
+
function notBetween(column, min, max) {
|
|
2510
|
+
return sql`${column} not between ${bindIfParam(min, column)} and ${bindIfParam(max, column)}`;
|
|
2511
|
+
}
|
|
2512
|
+
function like(column, value) {
|
|
2513
|
+
return sql`${column} like ${value}`;
|
|
2514
|
+
}
|
|
2515
|
+
function notLike(column, value) {
|
|
2516
|
+
return sql`${column} not like ${value}`;
|
|
2517
|
+
}
|
|
2518
|
+
function ilike(column, value) {
|
|
2519
|
+
return sql`${column} ilike ${value}`;
|
|
2520
|
+
}
|
|
2521
|
+
function notIlike(column, value) {
|
|
2522
|
+
return sql`${column} not ilike ${value}`;
|
|
2523
|
+
}
|
|
2524
|
+
//#endregion
|
|
2525
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/sql/expressions/select.js
|
|
2526
|
+
function asc(column) {
|
|
2527
|
+
return sql`${column} asc`;
|
|
2528
|
+
}
|
|
2529
|
+
function desc(column) {
|
|
2530
|
+
return sql`${column} desc`;
|
|
2531
|
+
}
|
|
2532
|
+
//#endregion
|
|
2533
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/relations.js
|
|
2534
|
+
var Relation = class {
|
|
2535
|
+
constructor(sourceTable, referencedTable, relationName) {
|
|
2536
|
+
this.sourceTable = sourceTable;
|
|
2537
|
+
this.referencedTable = referencedTable;
|
|
2538
|
+
this.relationName = relationName;
|
|
2539
|
+
this.referencedTableName = referencedTable[Table.Symbol.Name];
|
|
2540
|
+
}
|
|
2541
|
+
static [entityKind] = "Relation";
|
|
2542
|
+
referencedTableName;
|
|
2543
|
+
fieldName;
|
|
2544
|
+
};
|
|
2545
|
+
var Relations = class {
|
|
2546
|
+
constructor(table, config) {
|
|
2547
|
+
this.table = table;
|
|
2548
|
+
this.config = config;
|
|
2549
|
+
}
|
|
2550
|
+
static [entityKind] = "Relations";
|
|
2551
|
+
};
|
|
2552
|
+
var One = class One extends Relation {
|
|
2553
|
+
constructor(sourceTable, referencedTable, config, isNullable) {
|
|
2554
|
+
super(sourceTable, referencedTable, config?.relationName);
|
|
2555
|
+
this.config = config;
|
|
2556
|
+
this.isNullable = isNullable;
|
|
2557
|
+
}
|
|
2558
|
+
static [entityKind] = "One";
|
|
2559
|
+
withFieldName(fieldName) {
|
|
2560
|
+
const relation = new One(this.sourceTable, this.referencedTable, this.config, this.isNullable);
|
|
2561
|
+
relation.fieldName = fieldName;
|
|
2562
|
+
return relation;
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
var Many = class Many extends Relation {
|
|
2566
|
+
constructor(sourceTable, referencedTable, config) {
|
|
2567
|
+
super(sourceTable, referencedTable, config?.relationName);
|
|
2568
|
+
this.config = config;
|
|
2569
|
+
}
|
|
2570
|
+
static [entityKind] = "Many";
|
|
2571
|
+
withFieldName(fieldName) {
|
|
2572
|
+
const relation = new Many(this.sourceTable, this.referencedTable, this.config);
|
|
2573
|
+
relation.fieldName = fieldName;
|
|
2574
|
+
return relation;
|
|
2575
|
+
}
|
|
2576
|
+
};
|
|
2577
|
+
function getOperators() {
|
|
2578
|
+
return {
|
|
2579
|
+
and,
|
|
2580
|
+
between,
|
|
2581
|
+
eq,
|
|
2582
|
+
exists,
|
|
2583
|
+
gt,
|
|
2584
|
+
gte,
|
|
2585
|
+
ilike,
|
|
2586
|
+
inArray,
|
|
2587
|
+
isNull,
|
|
2588
|
+
isNotNull,
|
|
2589
|
+
like,
|
|
2590
|
+
lt,
|
|
2591
|
+
lte,
|
|
2592
|
+
ne,
|
|
2593
|
+
not,
|
|
2594
|
+
notBetween,
|
|
2595
|
+
notExists,
|
|
2596
|
+
notLike,
|
|
2597
|
+
notIlike,
|
|
2598
|
+
notInArray,
|
|
2599
|
+
or,
|
|
2600
|
+
sql
|
|
2601
|
+
};
|
|
2602
|
+
}
|
|
2603
|
+
function getOrderByOperators() {
|
|
2604
|
+
return {
|
|
2605
|
+
sql,
|
|
2606
|
+
asc,
|
|
2607
|
+
desc
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
function extractTablesRelationalConfig(schema, configHelpers) {
|
|
2611
|
+
if (Object.keys(schema).length === 1 && "default" in schema && !is(schema["default"], Table)) schema = schema["default"];
|
|
2612
|
+
const tableNamesMap = {};
|
|
2613
|
+
const relationsBuffer = {};
|
|
2614
|
+
const tablesConfig = {};
|
|
2615
|
+
for (const [key, value] of Object.entries(schema)) if (is(value, Table)) {
|
|
2616
|
+
const dbName = getTableUniqueName(value);
|
|
2617
|
+
const bufferedRelations = relationsBuffer[dbName];
|
|
2618
|
+
tableNamesMap[dbName] = key;
|
|
2619
|
+
tablesConfig[key] = {
|
|
2620
|
+
tsName: key,
|
|
2621
|
+
dbName: value[Table.Symbol.Name],
|
|
2622
|
+
schema: value[Table.Symbol.Schema],
|
|
2623
|
+
columns: value[Table.Symbol.Columns],
|
|
2624
|
+
relations: bufferedRelations?.relations ?? {},
|
|
2625
|
+
primaryKey: bufferedRelations?.primaryKey ?? []
|
|
2626
|
+
};
|
|
2627
|
+
for (const column of Object.values(value[Table.Symbol.Columns])) if (column.primary) tablesConfig[key].primaryKey.push(column);
|
|
2628
|
+
const extraConfig = value[Table.Symbol.ExtraConfigBuilder]?.(value[Table.Symbol.ExtraConfigColumns]);
|
|
2629
|
+
if (extraConfig) {
|
|
2630
|
+
for (const configEntry of Object.values(extraConfig)) if (is(configEntry, PrimaryKeyBuilder)) tablesConfig[key].primaryKey.push(...configEntry.columns);
|
|
2631
|
+
}
|
|
2632
|
+
} else if (is(value, Relations)) {
|
|
2633
|
+
const dbName = getTableUniqueName(value.table);
|
|
2634
|
+
const tableName = tableNamesMap[dbName];
|
|
2635
|
+
const relations2 = value.config(configHelpers(value.table));
|
|
2636
|
+
let primaryKey;
|
|
2637
|
+
for (const [relationName, relation] of Object.entries(relations2)) if (tableName) {
|
|
2638
|
+
const tableConfig = tablesConfig[tableName];
|
|
2639
|
+
tableConfig.relations[relationName] = relation;
|
|
2640
|
+
} else {
|
|
2641
|
+
if (!(dbName in relationsBuffer)) relationsBuffer[dbName] = {
|
|
2642
|
+
relations: {},
|
|
2643
|
+
primaryKey
|
|
2644
|
+
};
|
|
2645
|
+
relationsBuffer[dbName].relations[relationName] = relation;
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
return {
|
|
2649
|
+
tables: tablesConfig,
|
|
2650
|
+
tableNamesMap
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
function relations(table, relations2) {
|
|
2654
|
+
return new Relations(table, (helpers) => Object.fromEntries(Object.entries(relations2(helpers)).map(([key, value]) => [key, value.withFieldName(key)])));
|
|
2655
|
+
}
|
|
2656
|
+
function createOne(sourceTable) {
|
|
2657
|
+
return function one(table, config) {
|
|
2658
|
+
return new One(sourceTable, table, config, config?.fields.reduce((res, f) => res && f.notNull, true) ?? false);
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
function createMany(sourceTable) {
|
|
2662
|
+
return function many(referencedTable, config) {
|
|
2663
|
+
return new Many(sourceTable, referencedTable, config);
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
function normalizeRelation(schema, tableNamesMap, relation) {
|
|
2667
|
+
if (is(relation, One) && relation.config) return {
|
|
2668
|
+
fields: relation.config.fields,
|
|
2669
|
+
references: relation.config.references
|
|
2670
|
+
};
|
|
2671
|
+
const referencedTableTsName = tableNamesMap[getTableUniqueName(relation.referencedTable)];
|
|
2672
|
+
if (!referencedTableTsName) throw new Error(`Table "${relation.referencedTable[Table.Symbol.Name]}" not found in schema`);
|
|
2673
|
+
const referencedTableConfig = schema[referencedTableTsName];
|
|
2674
|
+
if (!referencedTableConfig) throw new Error(`Table "${referencedTableTsName}" not found in schema`);
|
|
2675
|
+
const sourceTable = relation.sourceTable;
|
|
2676
|
+
const sourceTableTsName = tableNamesMap[getTableUniqueName(sourceTable)];
|
|
2677
|
+
if (!sourceTableTsName) throw new Error(`Table "${sourceTable[Table.Symbol.Name]}" not found in schema`);
|
|
2678
|
+
const reverseRelations = [];
|
|
2679
|
+
for (const referencedTableRelation of Object.values(referencedTableConfig.relations)) if (relation.relationName && relation !== referencedTableRelation && referencedTableRelation.relationName === relation.relationName || !relation.relationName && referencedTableRelation.referencedTable === relation.sourceTable) reverseRelations.push(referencedTableRelation);
|
|
2680
|
+
if (reverseRelations.length > 1) throw relation.relationName ? /* @__PURE__ */ new Error(`There are multiple relations with name "${relation.relationName}" in table "${referencedTableTsName}"`) : /* @__PURE__ */ new Error(`There are multiple relations between "${referencedTableTsName}" and "${relation.sourceTable[Table.Symbol.Name]}". Please specify relation name`);
|
|
2681
|
+
if (reverseRelations[0] && is(reverseRelations[0], One) && reverseRelations[0].config) return {
|
|
2682
|
+
fields: reverseRelations[0].config.references,
|
|
2683
|
+
references: reverseRelations[0].config.fields
|
|
2684
|
+
};
|
|
2685
|
+
throw new Error(`There is not enough information to infer relation "${sourceTableTsName}.${relation.fieldName}"`);
|
|
2686
|
+
}
|
|
2687
|
+
function createTableRelationsHelpers(sourceTable) {
|
|
2688
|
+
return {
|
|
2689
|
+
one: createOne(sourceTable),
|
|
2690
|
+
many: createMany(sourceTable)
|
|
2691
|
+
};
|
|
2692
|
+
}
|
|
2693
|
+
function mapRelationalRow(tablesConfig, tableConfig, row, buildQueryResultSelection, mapColumnValue = (value) => value) {
|
|
2694
|
+
const result = {};
|
|
2695
|
+
for (const [selectionItemIndex, selectionItem] of buildQueryResultSelection.entries()) if (selectionItem.isJson) {
|
|
2696
|
+
const relation = tableConfig.relations[selectionItem.tsKey];
|
|
2697
|
+
const rawSubRows = row[selectionItemIndex];
|
|
2698
|
+
const subRows = typeof rawSubRows === "string" ? JSON.parse(rawSubRows) : rawSubRows;
|
|
2699
|
+
result[selectionItem.tsKey] = is(relation, One) ? subRows && mapRelationalRow(tablesConfig, tablesConfig[selectionItem.relationTableTsKey], subRows, selectionItem.selection, mapColumnValue) : subRows.map((subRow) => mapRelationalRow(tablesConfig, tablesConfig[selectionItem.relationTableTsKey], subRow, selectionItem.selection, mapColumnValue));
|
|
2700
|
+
} else {
|
|
2701
|
+
const value = mapColumnValue(row[selectionItemIndex]);
|
|
2702
|
+
const field = selectionItem.field;
|
|
2703
|
+
let decoder;
|
|
2704
|
+
if (is(field, Column)) decoder = field;
|
|
2705
|
+
else if (is(field, SQL)) decoder = field.decoder;
|
|
2706
|
+
else decoder = field.sql.decoder;
|
|
2707
|
+
result[selectionItem.tsKey] = value === null ? null : decoder.mapFromDriverValue(value);
|
|
2708
|
+
}
|
|
2709
|
+
return result;
|
|
2710
|
+
}
|
|
2711
|
+
//#endregion
|
|
2712
|
+
export { Subquery as $, bigint as A, textDecoder as B, PgJsonb as C, PgDateString as D, PgDate as E, haveSameKeys as F, sql as G, SQL as H, isConfig as I, Table as J, Columns as K, mapResultRow as L, getColumnNameAndConfig as M, getTableColumns as N, customType as O, getTableLikeName as P, tracer as Q, mapUpdateSet as R, PgNumeric as S, integer as T, View as U, Param as V, fillPlaceholders as W, getTableUniqueName as X, getTableName as Y, ViewBaseConfig as Z, PgTimestamp as _, getOperators as a, TableName as at, PgTime as b, normalizeRelation as c, entityKind as ct, eq as d, WithSubquery as et, primaryKey as f, uuid as g, PgUUID as h, extractTablesRelationalConfig as i, foreignKey as it, applyMixins as j, boolean as k, relations as l, is as lt, pgTable as m, One as n, PgColumn as nt, getOrderByOperators as o, ColumnBuilder as ot, PgTable as p, Schema as q, createTableRelationsHelpers as r, unique as rt, mapRelationalRow as s, Column as st, Many as t, IndexedColumn as tt, and as u, PgTimestampString as v, PgJson as w, text as x, timestamp as y, orderSelectedFields as z };
|