jukebox-media-server 0.3.0 → 0.5.0
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 +2 -2
- package/dist/client/assets/{Watch-DNFM488K.js → Watch-Ja4PAA8Y.js} +32 -32
- package/dist/client/assets/index-AENKhh_8.css +1 -0
- package/dist/client/assets/index-Cm9WIhoR.js +58 -0
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +1 -1
- package/dist/server/better-sqlite3-Dy_YhTFe.js +2709 -0
- package/dist/server/index.js +455 -4547
- package/dist/server/indexes-VMR6QVVl.js +1409 -0
- package/dist/server/migrator-CWPnMvx5.js +37 -0
- package/drizzle/0010_metadata_rename.sql +49 -0
- package/drizzle/meta/0009_snapshot.json +1 -1
- package/drizzle/meta/0010_snapshot.json +1059 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +2 -1
- package/dist/client/assets/index-BYBYJ0kS.css +0 -1
- package/dist/client/assets/index-COFfIwFC.js +0 -58
|
@@ -0,0 +1,1409 @@
|
|
|
1
|
+
//#region 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/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/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/drizzle-orm/table.utils.js
|
|
169
|
+
const TableName = Symbol.for("drizzle:Name");
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
172
|
+
const isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
173
|
+
function isPgEnum(obj) {
|
|
174
|
+
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region node_modules/drizzle-orm/subquery.js
|
|
178
|
+
var Subquery = class {
|
|
179
|
+
static [entityKind] = "Subquery";
|
|
180
|
+
constructor(sql, fields, alias, isWith = false, usedTables = []) {
|
|
181
|
+
this._ = {
|
|
182
|
+
brand: "Subquery",
|
|
183
|
+
sql,
|
|
184
|
+
selectedFields: fields,
|
|
185
|
+
alias,
|
|
186
|
+
isWith,
|
|
187
|
+
usedTables
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var WithSubquery = class extends Subquery {
|
|
192
|
+
static [entityKind] = "WithSubquery";
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region node_modules/drizzle-orm/tracing.js
|
|
196
|
+
const tracer = { startActiveSpan(name, fn) {
|
|
197
|
+
return fn();
|
|
198
|
+
} };
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region node_modules/drizzle-orm/view-common.js
|
|
201
|
+
const ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region node_modules/drizzle-orm/table.js
|
|
204
|
+
const Schema = Symbol.for("drizzle:Schema");
|
|
205
|
+
const Columns = Symbol.for("drizzle:Columns");
|
|
206
|
+
const ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
207
|
+
const OriginalName = Symbol.for("drizzle:OriginalName");
|
|
208
|
+
const BaseName = Symbol.for("drizzle:BaseName");
|
|
209
|
+
const IsAlias = Symbol.for("drizzle:IsAlias");
|
|
210
|
+
const ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
|
211
|
+
const IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
|
212
|
+
var Table = class {
|
|
213
|
+
static [entityKind] = "Table";
|
|
214
|
+
/** @internal */
|
|
215
|
+
static Symbol = {
|
|
216
|
+
Name: TableName,
|
|
217
|
+
Schema,
|
|
218
|
+
OriginalName,
|
|
219
|
+
Columns,
|
|
220
|
+
ExtraConfigColumns,
|
|
221
|
+
BaseName,
|
|
222
|
+
IsAlias,
|
|
223
|
+
ExtraConfigBuilder
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
* Can be changed if the table is aliased.
|
|
228
|
+
*/
|
|
229
|
+
[TableName];
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
* Used to store the original name of the table, before any aliasing.
|
|
233
|
+
*/
|
|
234
|
+
[OriginalName];
|
|
235
|
+
/** @internal */
|
|
236
|
+
[Schema];
|
|
237
|
+
/** @internal */
|
|
238
|
+
[Columns];
|
|
239
|
+
/** @internal */
|
|
240
|
+
[ExtraConfigColumns];
|
|
241
|
+
/**
|
|
242
|
+
* @internal
|
|
243
|
+
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
244
|
+
*/
|
|
245
|
+
[BaseName];
|
|
246
|
+
/** @internal */
|
|
247
|
+
[IsAlias] = false;
|
|
248
|
+
/** @internal */
|
|
249
|
+
[IsDrizzleTable] = true;
|
|
250
|
+
/** @internal */
|
|
251
|
+
[ExtraConfigBuilder] = void 0;
|
|
252
|
+
constructor(name, schema, baseName) {
|
|
253
|
+
this[TableName] = this[OriginalName] = name;
|
|
254
|
+
this[Schema] = schema;
|
|
255
|
+
this[BaseName] = baseName;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
function getTableName(table) {
|
|
259
|
+
return table[TableName];
|
|
260
|
+
}
|
|
261
|
+
function getTableUniqueName(table) {
|
|
262
|
+
return `${table[Schema] ?? "public"}.${table[TableName]}`;
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region node_modules/drizzle-orm/sql/sql.js
|
|
266
|
+
function isSQLWrapper(value) {
|
|
267
|
+
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
268
|
+
}
|
|
269
|
+
function mergeQueries(queries) {
|
|
270
|
+
const result = {
|
|
271
|
+
sql: "",
|
|
272
|
+
params: []
|
|
273
|
+
};
|
|
274
|
+
for (const query of queries) {
|
|
275
|
+
result.sql += query.sql;
|
|
276
|
+
result.params.push(...query.params);
|
|
277
|
+
if (query.typings?.length) {
|
|
278
|
+
if (!result.typings) result.typings = [];
|
|
279
|
+
result.typings.push(...query.typings);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
var StringChunk = class {
|
|
285
|
+
static [entityKind] = "StringChunk";
|
|
286
|
+
value;
|
|
287
|
+
constructor(value) {
|
|
288
|
+
this.value = Array.isArray(value) ? value : [value];
|
|
289
|
+
}
|
|
290
|
+
getSQL() {
|
|
291
|
+
return new SQL([this]);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
var SQL = class SQL {
|
|
295
|
+
constructor(queryChunks) {
|
|
296
|
+
this.queryChunks = queryChunks;
|
|
297
|
+
for (const chunk of queryChunks) if (is(chunk, Table)) {
|
|
298
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
299
|
+
this.usedTables.push(schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
static [entityKind] = "SQL";
|
|
303
|
+
/** @internal */
|
|
304
|
+
decoder = noopDecoder;
|
|
305
|
+
shouldInlineParams = false;
|
|
306
|
+
/** @internal */
|
|
307
|
+
usedTables = [];
|
|
308
|
+
append(query) {
|
|
309
|
+
this.queryChunks.push(...query.queryChunks);
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
toQuery(config) {
|
|
313
|
+
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
314
|
+
const query = this.buildQueryFromSourceParams(this.queryChunks, config);
|
|
315
|
+
span?.setAttributes({
|
|
316
|
+
"drizzle.query.text": query.sql,
|
|
317
|
+
"drizzle.query.params": JSON.stringify(query.params)
|
|
318
|
+
});
|
|
319
|
+
return query;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
buildQueryFromSourceParams(chunks, _config) {
|
|
323
|
+
const config = Object.assign({}, _config, {
|
|
324
|
+
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
325
|
+
paramStartIndex: _config.paramStartIndex || { value: 0 }
|
|
326
|
+
});
|
|
327
|
+
const { casing, escapeName, escapeParam, prepareTyping, inlineParams, paramStartIndex } = config;
|
|
328
|
+
return mergeQueries(chunks.map((chunk) => {
|
|
329
|
+
if (is(chunk, StringChunk)) return {
|
|
330
|
+
sql: chunk.value.join(""),
|
|
331
|
+
params: []
|
|
332
|
+
};
|
|
333
|
+
if (is(chunk, Name)) return {
|
|
334
|
+
sql: escapeName(chunk.value),
|
|
335
|
+
params: []
|
|
336
|
+
};
|
|
337
|
+
if (chunk === void 0) return {
|
|
338
|
+
sql: "",
|
|
339
|
+
params: []
|
|
340
|
+
};
|
|
341
|
+
if (Array.isArray(chunk)) {
|
|
342
|
+
const result = [new StringChunk("(")];
|
|
343
|
+
for (const [i, p] of chunk.entries()) {
|
|
344
|
+
result.push(p);
|
|
345
|
+
if (i < chunk.length - 1) result.push(new StringChunk(", "));
|
|
346
|
+
}
|
|
347
|
+
result.push(new StringChunk(")"));
|
|
348
|
+
return this.buildQueryFromSourceParams(result, config);
|
|
349
|
+
}
|
|
350
|
+
if (is(chunk, SQL)) return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
351
|
+
...config,
|
|
352
|
+
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
353
|
+
});
|
|
354
|
+
if (is(chunk, Table)) {
|
|
355
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
356
|
+
const tableName = chunk[Table.Symbol.Name];
|
|
357
|
+
return {
|
|
358
|
+
sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
359
|
+
params: []
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (is(chunk, Column)) {
|
|
363
|
+
const columnName = casing.getColumnCasing(chunk);
|
|
364
|
+
if (_config.invokeSource === "indexes") return {
|
|
365
|
+
sql: escapeName(columnName),
|
|
366
|
+
params: []
|
|
367
|
+
};
|
|
368
|
+
const schemaName = chunk.table[Table.Symbol.Schema];
|
|
369
|
+
return {
|
|
370
|
+
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),
|
|
371
|
+
params: []
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
if (is(chunk, View)) {
|
|
375
|
+
const schemaName = chunk[ViewBaseConfig].schema;
|
|
376
|
+
const viewName = chunk[ViewBaseConfig].name;
|
|
377
|
+
return {
|
|
378
|
+
sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
379
|
+
params: []
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
if (is(chunk, Param)) {
|
|
383
|
+
if (is(chunk.value, Placeholder)) return {
|
|
384
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
385
|
+
params: [chunk],
|
|
386
|
+
typings: ["none"]
|
|
387
|
+
};
|
|
388
|
+
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
389
|
+
if (is(mappedValue, SQL)) return this.buildQueryFromSourceParams([mappedValue], config);
|
|
390
|
+
if (inlineParams) return {
|
|
391
|
+
sql: this.mapInlineParam(mappedValue, config),
|
|
392
|
+
params: []
|
|
393
|
+
};
|
|
394
|
+
let typings = ["none"];
|
|
395
|
+
if (prepareTyping) typings = [prepareTyping(chunk.encoder)];
|
|
396
|
+
return {
|
|
397
|
+
sql: escapeParam(paramStartIndex.value++, mappedValue),
|
|
398
|
+
params: [mappedValue],
|
|
399
|
+
typings
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
if (is(chunk, Placeholder)) return {
|
|
403
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
404
|
+
params: [chunk],
|
|
405
|
+
typings: ["none"]
|
|
406
|
+
};
|
|
407
|
+
if (is(chunk, SQL.Aliased) && chunk.fieldAlias !== void 0) return {
|
|
408
|
+
sql: escapeName(chunk.fieldAlias),
|
|
409
|
+
params: []
|
|
410
|
+
};
|
|
411
|
+
if (is(chunk, Subquery)) {
|
|
412
|
+
if (chunk._.isWith) return {
|
|
413
|
+
sql: escapeName(chunk._.alias),
|
|
414
|
+
params: []
|
|
415
|
+
};
|
|
416
|
+
return this.buildQueryFromSourceParams([
|
|
417
|
+
new StringChunk("("),
|
|
418
|
+
chunk._.sql,
|
|
419
|
+
new StringChunk(") "),
|
|
420
|
+
new Name(chunk._.alias)
|
|
421
|
+
], config);
|
|
422
|
+
}
|
|
423
|
+
if (isPgEnum(chunk)) {
|
|
424
|
+
if (chunk.schema) return {
|
|
425
|
+
sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
|
|
426
|
+
params: []
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
sql: escapeName(chunk.enumName),
|
|
430
|
+
params: []
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
if (isSQLWrapper(chunk)) {
|
|
434
|
+
if (chunk.shouldOmitSQLParens?.()) return this.buildQueryFromSourceParams([chunk.getSQL()], config);
|
|
435
|
+
return this.buildQueryFromSourceParams([
|
|
436
|
+
new StringChunk("("),
|
|
437
|
+
chunk.getSQL(),
|
|
438
|
+
new StringChunk(")")
|
|
439
|
+
], config);
|
|
440
|
+
}
|
|
441
|
+
if (inlineParams) return {
|
|
442
|
+
sql: this.mapInlineParam(chunk, config),
|
|
443
|
+
params: []
|
|
444
|
+
};
|
|
445
|
+
return {
|
|
446
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
447
|
+
params: [chunk],
|
|
448
|
+
typings: ["none"]
|
|
449
|
+
};
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
mapInlineParam(chunk, { escapeString }) {
|
|
453
|
+
if (chunk === null) return "null";
|
|
454
|
+
if (typeof chunk === "number" || typeof chunk === "boolean") return chunk.toString();
|
|
455
|
+
if (typeof chunk === "string") return escapeString(chunk);
|
|
456
|
+
if (typeof chunk === "object") {
|
|
457
|
+
const mappedValueAsString = chunk.toString();
|
|
458
|
+
if (mappedValueAsString === "[object Object]") return escapeString(JSON.stringify(chunk));
|
|
459
|
+
return escapeString(mappedValueAsString);
|
|
460
|
+
}
|
|
461
|
+
throw new Error("Unexpected param value: " + chunk);
|
|
462
|
+
}
|
|
463
|
+
getSQL() {
|
|
464
|
+
return this;
|
|
465
|
+
}
|
|
466
|
+
as(alias) {
|
|
467
|
+
if (alias === void 0) return this;
|
|
468
|
+
return new SQL.Aliased(this, alias);
|
|
469
|
+
}
|
|
470
|
+
mapWith(decoder) {
|
|
471
|
+
this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
inlineParams() {
|
|
475
|
+
this.shouldInlineParams = true;
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* This method is used to conditionally include a part of the query.
|
|
480
|
+
*
|
|
481
|
+
* @param condition - Condition to check
|
|
482
|
+
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
483
|
+
*/
|
|
484
|
+
if(condition) {
|
|
485
|
+
return condition ? this : void 0;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
var Name = class {
|
|
489
|
+
constructor(value) {
|
|
490
|
+
this.value = value;
|
|
491
|
+
}
|
|
492
|
+
static [entityKind] = "Name";
|
|
493
|
+
brand;
|
|
494
|
+
getSQL() {
|
|
495
|
+
return new SQL([this]);
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
function isDriverValueEncoder(value) {
|
|
499
|
+
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
500
|
+
}
|
|
501
|
+
const noopDecoder = { mapFromDriverValue: (value) => value };
|
|
502
|
+
const noopEncoder = { mapToDriverValue: (value) => value };
|
|
503
|
+
({
|
|
504
|
+
...noopDecoder,
|
|
505
|
+
...noopEncoder
|
|
506
|
+
});
|
|
507
|
+
var Param = class {
|
|
508
|
+
/**
|
|
509
|
+
* @param value - Parameter value
|
|
510
|
+
* @param encoder - Encoder to convert the value to a driver parameter
|
|
511
|
+
*/
|
|
512
|
+
constructor(value, encoder = noopEncoder) {
|
|
513
|
+
this.value = value;
|
|
514
|
+
this.encoder = encoder;
|
|
515
|
+
}
|
|
516
|
+
static [entityKind] = "Param";
|
|
517
|
+
brand;
|
|
518
|
+
getSQL() {
|
|
519
|
+
return new SQL([this]);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
function sql(strings, ...params) {
|
|
523
|
+
const queryChunks = [];
|
|
524
|
+
if (params.length > 0 || strings.length > 0 && strings[0] !== "") queryChunks.push(new StringChunk(strings[0]));
|
|
525
|
+
for (const [paramIndex, param2] of params.entries()) queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
526
|
+
return new SQL(queryChunks);
|
|
527
|
+
}
|
|
528
|
+
((sql2) => {
|
|
529
|
+
function empty() {
|
|
530
|
+
return new SQL([]);
|
|
531
|
+
}
|
|
532
|
+
sql2.empty = empty;
|
|
533
|
+
function fromList(list) {
|
|
534
|
+
return new SQL(list);
|
|
535
|
+
}
|
|
536
|
+
sql2.fromList = fromList;
|
|
537
|
+
function raw(str) {
|
|
538
|
+
return new SQL([new StringChunk(str)]);
|
|
539
|
+
}
|
|
540
|
+
sql2.raw = raw;
|
|
541
|
+
function join(chunks, separator) {
|
|
542
|
+
const result = [];
|
|
543
|
+
for (const [i, chunk] of chunks.entries()) {
|
|
544
|
+
if (i > 0 && separator !== void 0) result.push(separator);
|
|
545
|
+
result.push(chunk);
|
|
546
|
+
}
|
|
547
|
+
return new SQL(result);
|
|
548
|
+
}
|
|
549
|
+
sql2.join = join;
|
|
550
|
+
function identifier(value) {
|
|
551
|
+
return new Name(value);
|
|
552
|
+
}
|
|
553
|
+
sql2.identifier = identifier;
|
|
554
|
+
function placeholder2(name2) {
|
|
555
|
+
return new Placeholder(name2);
|
|
556
|
+
}
|
|
557
|
+
sql2.placeholder = placeholder2;
|
|
558
|
+
function param2(value, encoder) {
|
|
559
|
+
return new Param(value, encoder);
|
|
560
|
+
}
|
|
561
|
+
sql2.param = param2;
|
|
562
|
+
})(sql || (sql = {}));
|
|
563
|
+
((SQL2) => {
|
|
564
|
+
class Aliased {
|
|
565
|
+
constructor(sql2, fieldAlias) {
|
|
566
|
+
this.sql = sql2;
|
|
567
|
+
this.fieldAlias = fieldAlias;
|
|
568
|
+
}
|
|
569
|
+
static [entityKind] = "SQL.Aliased";
|
|
570
|
+
/** @internal */
|
|
571
|
+
isSelectionField = false;
|
|
572
|
+
getSQL() {
|
|
573
|
+
return this.sql;
|
|
574
|
+
}
|
|
575
|
+
/** @internal */
|
|
576
|
+
clone() {
|
|
577
|
+
return new Aliased(this.sql, this.fieldAlias);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
SQL2.Aliased = Aliased;
|
|
581
|
+
})(SQL || (SQL = {}));
|
|
582
|
+
var Placeholder = class {
|
|
583
|
+
constructor(name2) {
|
|
584
|
+
this.name = name2;
|
|
585
|
+
}
|
|
586
|
+
static [entityKind] = "Placeholder";
|
|
587
|
+
getSQL() {
|
|
588
|
+
return new SQL([this]);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
function fillPlaceholders(params, values) {
|
|
592
|
+
return params.map((p) => {
|
|
593
|
+
if (is(p, Placeholder)) {
|
|
594
|
+
if (!(p.name in values)) throw new Error(`No value for placeholder "${p.name}" was provided`);
|
|
595
|
+
return values[p.name];
|
|
596
|
+
}
|
|
597
|
+
if (is(p, Param) && is(p.value, Placeholder)) {
|
|
598
|
+
if (!(p.value.name in values)) throw new Error(`No value for placeholder "${p.value.name}" was provided`);
|
|
599
|
+
return p.encoder.mapToDriverValue(values[p.value.name]);
|
|
600
|
+
}
|
|
601
|
+
return p;
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
const IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
|
|
605
|
+
var View = class {
|
|
606
|
+
static [entityKind] = "View";
|
|
607
|
+
/** @internal */
|
|
608
|
+
[ViewBaseConfig];
|
|
609
|
+
/** @internal */
|
|
610
|
+
[IsDrizzleView] = true;
|
|
611
|
+
constructor({ name: name2, schema, selectedFields, query }) {
|
|
612
|
+
this[ViewBaseConfig] = {
|
|
613
|
+
name: name2,
|
|
614
|
+
originalName: name2,
|
|
615
|
+
schema,
|
|
616
|
+
selectedFields,
|
|
617
|
+
query,
|
|
618
|
+
isExisting: !query,
|
|
619
|
+
isAlias: false
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
getSQL() {
|
|
623
|
+
return new SQL([this]);
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
Column.prototype.getSQL = function() {
|
|
627
|
+
return new SQL([this]);
|
|
628
|
+
};
|
|
629
|
+
Table.prototype.getSQL = function() {
|
|
630
|
+
return new SQL([this]);
|
|
631
|
+
};
|
|
632
|
+
Subquery.prototype.getSQL = function() {
|
|
633
|
+
return new SQL([this]);
|
|
634
|
+
};
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region node_modules/drizzle-orm/utils.js
|
|
637
|
+
function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
638
|
+
const nullifyMap = {};
|
|
639
|
+
const result = columns.reduce((result2, { path, field }, columnIndex) => {
|
|
640
|
+
let decoder;
|
|
641
|
+
if (is(field, Column)) decoder = field;
|
|
642
|
+
else if (is(field, SQL)) decoder = field.decoder;
|
|
643
|
+
else if (is(field, Subquery)) decoder = field._.sql.decoder;
|
|
644
|
+
else decoder = field.sql.decoder;
|
|
645
|
+
let node = result2;
|
|
646
|
+
for (const [pathChunkIndex, pathChunk] of path.entries()) if (pathChunkIndex < path.length - 1) {
|
|
647
|
+
if (!(pathChunk in node)) node[pathChunk] = {};
|
|
648
|
+
node = node[pathChunk];
|
|
649
|
+
} else {
|
|
650
|
+
const rawValue = row[columnIndex];
|
|
651
|
+
const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
|
|
652
|
+
if (joinsNotNullableMap && is(field, Column) && path.length === 2) {
|
|
653
|
+
const objectName = path[0];
|
|
654
|
+
if (!(objectName in nullifyMap)) nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
|
|
655
|
+
else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) nullifyMap[objectName] = false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return result2;
|
|
659
|
+
}, {});
|
|
660
|
+
if (joinsNotNullableMap && Object.keys(nullifyMap).length > 0) {
|
|
661
|
+
for (const [objectName, tableName] of Object.entries(nullifyMap)) if (typeof tableName === "string" && !joinsNotNullableMap[tableName]) result[objectName] = null;
|
|
662
|
+
}
|
|
663
|
+
return result;
|
|
664
|
+
}
|
|
665
|
+
function orderSelectedFields(fields, pathPrefix) {
|
|
666
|
+
return Object.entries(fields).reduce((result, [name, field]) => {
|
|
667
|
+
if (typeof name !== "string") return result;
|
|
668
|
+
const newPath = pathPrefix ? [...pathPrefix, name] : [name];
|
|
669
|
+
if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery)) result.push({
|
|
670
|
+
path: newPath,
|
|
671
|
+
field
|
|
672
|
+
});
|
|
673
|
+
else if (is(field, Table)) result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));
|
|
674
|
+
else result.push(...orderSelectedFields(field, newPath));
|
|
675
|
+
return result;
|
|
676
|
+
}, []);
|
|
677
|
+
}
|
|
678
|
+
function haveSameKeys(left, right) {
|
|
679
|
+
const leftKeys = Object.keys(left);
|
|
680
|
+
const rightKeys = Object.keys(right);
|
|
681
|
+
if (leftKeys.length !== rightKeys.length) return false;
|
|
682
|
+
for (const [index, key] of leftKeys.entries()) if (key !== rightKeys[index]) return false;
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
function mapUpdateSet(table, values) {
|
|
686
|
+
const entries = Object.entries(values).filter(([, value]) => value !== void 0).map(([key, value]) => {
|
|
687
|
+
if (is(value, SQL) || is(value, Column)) return [key, value];
|
|
688
|
+
else return [key, new Param(value, table[Table.Symbol.Columns][key])];
|
|
689
|
+
});
|
|
690
|
+
if (entries.length === 0) throw new Error("No values to set");
|
|
691
|
+
return Object.fromEntries(entries);
|
|
692
|
+
}
|
|
693
|
+
function applyMixins(baseClass, extendedClasses) {
|
|
694
|
+
for (const extendedClass of extendedClasses) for (const name of Object.getOwnPropertyNames(extendedClass.prototype)) {
|
|
695
|
+
if (name === "constructor") continue;
|
|
696
|
+
Object.defineProperty(baseClass.prototype, name, Object.getOwnPropertyDescriptor(extendedClass.prototype, name) || /* @__PURE__ */ Object.create(null));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function getTableColumns(table) {
|
|
700
|
+
return table[Table.Symbol.Columns];
|
|
701
|
+
}
|
|
702
|
+
function getTableLikeName(table) {
|
|
703
|
+
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];
|
|
704
|
+
}
|
|
705
|
+
function getColumnNameAndConfig(a, b) {
|
|
706
|
+
return {
|
|
707
|
+
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
708
|
+
config: typeof a === "object" ? a : b
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function isConfig(data) {
|
|
712
|
+
if (typeof data !== "object" || data === null) return false;
|
|
713
|
+
if (data.constructor.name !== "Object") return false;
|
|
714
|
+
if ("logger" in data) {
|
|
715
|
+
const type = typeof data["logger"];
|
|
716
|
+
if (type !== "boolean" && (type !== "object" || typeof data["logger"]["logQuery"] !== "function") && type !== "undefined") return false;
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
719
|
+
if ("schema" in data) {
|
|
720
|
+
const type = typeof data["schema"];
|
|
721
|
+
if (type !== "object" && type !== "undefined") return false;
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
if ("casing" in data) {
|
|
725
|
+
const type = typeof data["casing"];
|
|
726
|
+
if (type !== "string" && type !== "undefined") return false;
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
if ("mode" in data) {
|
|
730
|
+
if (data["mode"] !== "default" || data["mode"] !== "planetscale" || data["mode"] !== void 0) return false;
|
|
731
|
+
return true;
|
|
732
|
+
}
|
|
733
|
+
if ("connection" in data) {
|
|
734
|
+
const type = typeof data["connection"];
|
|
735
|
+
if (type !== "string" && type !== "object" && type !== "undefined") return false;
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
if ("client" in data) {
|
|
739
|
+
const type = typeof data["client"];
|
|
740
|
+
if (type !== "object" && type !== "function" && type !== "undefined") return false;
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
if (Object.keys(data).length === 0) return true;
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
const textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder();
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
749
|
+
function bindIfParam(value, column) {
|
|
750
|
+
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);
|
|
751
|
+
return value;
|
|
752
|
+
}
|
|
753
|
+
const eq = (left, right) => {
|
|
754
|
+
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
755
|
+
};
|
|
756
|
+
const ne = (left, right) => {
|
|
757
|
+
return sql`${left} <> ${bindIfParam(right, left)}`;
|
|
758
|
+
};
|
|
759
|
+
function and(...unfilteredConditions) {
|
|
760
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
761
|
+
if (conditions.length === 0) return;
|
|
762
|
+
if (conditions.length === 1) return new SQL(conditions);
|
|
763
|
+
return new SQL([
|
|
764
|
+
new StringChunk("("),
|
|
765
|
+
sql.join(conditions, new StringChunk(" and ")),
|
|
766
|
+
new StringChunk(")")
|
|
767
|
+
]);
|
|
768
|
+
}
|
|
769
|
+
function or(...unfilteredConditions) {
|
|
770
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
771
|
+
if (conditions.length === 0) return;
|
|
772
|
+
if (conditions.length === 1) return new SQL(conditions);
|
|
773
|
+
return new SQL([
|
|
774
|
+
new StringChunk("("),
|
|
775
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
776
|
+
new StringChunk(")")
|
|
777
|
+
]);
|
|
778
|
+
}
|
|
779
|
+
function not(condition) {
|
|
780
|
+
return sql`not ${condition}`;
|
|
781
|
+
}
|
|
782
|
+
const gt = (left, right) => {
|
|
783
|
+
return sql`${left} > ${bindIfParam(right, left)}`;
|
|
784
|
+
};
|
|
785
|
+
const gte = (left, right) => {
|
|
786
|
+
return sql`${left} >= ${bindIfParam(right, left)}`;
|
|
787
|
+
};
|
|
788
|
+
const lt = (left, right) => {
|
|
789
|
+
return sql`${left} < ${bindIfParam(right, left)}`;
|
|
790
|
+
};
|
|
791
|
+
const lte = (left, right) => {
|
|
792
|
+
return sql`${left} <= ${bindIfParam(right, left)}`;
|
|
793
|
+
};
|
|
794
|
+
function inArray(column, values) {
|
|
795
|
+
if (Array.isArray(values)) {
|
|
796
|
+
if (values.length === 0) return sql`false`;
|
|
797
|
+
return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
|
|
798
|
+
}
|
|
799
|
+
return sql`${column} in ${bindIfParam(values, column)}`;
|
|
800
|
+
}
|
|
801
|
+
function notInArray(column, values) {
|
|
802
|
+
if (Array.isArray(values)) {
|
|
803
|
+
if (values.length === 0) return sql`true`;
|
|
804
|
+
return sql`${column} not in ${values.map((v) => bindIfParam(v, column))}`;
|
|
805
|
+
}
|
|
806
|
+
return sql`${column} not in ${bindIfParam(values, column)}`;
|
|
807
|
+
}
|
|
808
|
+
function isNull(value) {
|
|
809
|
+
return sql`${value} is null`;
|
|
810
|
+
}
|
|
811
|
+
function isNotNull(value) {
|
|
812
|
+
return sql`${value} is not null`;
|
|
813
|
+
}
|
|
814
|
+
function exists(subquery) {
|
|
815
|
+
return sql`exists ${subquery}`;
|
|
816
|
+
}
|
|
817
|
+
function notExists(subquery) {
|
|
818
|
+
return sql`not exists ${subquery}`;
|
|
819
|
+
}
|
|
820
|
+
function between(column, min, max) {
|
|
821
|
+
return sql`${column} between ${bindIfParam(min, column)} and ${bindIfParam(max, column)}`;
|
|
822
|
+
}
|
|
823
|
+
function notBetween(column, min, max) {
|
|
824
|
+
return sql`${column} not between ${bindIfParam(min, column)} and ${bindIfParam(max, column)}`;
|
|
825
|
+
}
|
|
826
|
+
function like(column, value) {
|
|
827
|
+
return sql`${column} like ${value}`;
|
|
828
|
+
}
|
|
829
|
+
function notLike(column, value) {
|
|
830
|
+
return sql`${column} not like ${value}`;
|
|
831
|
+
}
|
|
832
|
+
function ilike(column, value) {
|
|
833
|
+
return sql`${column} ilike ${value}`;
|
|
834
|
+
}
|
|
835
|
+
function notIlike(column, value) {
|
|
836
|
+
return sql`${column} not ilike ${value}`;
|
|
837
|
+
}
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region node_modules/drizzle-orm/sql/expressions/select.js
|
|
840
|
+
function asc(column) {
|
|
841
|
+
return sql`${column} asc`;
|
|
842
|
+
}
|
|
843
|
+
function desc(column) {
|
|
844
|
+
return sql`${column} desc`;
|
|
845
|
+
}
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region node_modules/drizzle-orm/sqlite-core/foreign-keys.js
|
|
848
|
+
var ForeignKeyBuilder = class {
|
|
849
|
+
static [entityKind] = "SQLiteForeignKeyBuilder";
|
|
850
|
+
/** @internal */
|
|
851
|
+
reference;
|
|
852
|
+
/** @internal */
|
|
853
|
+
_onUpdate;
|
|
854
|
+
/** @internal */
|
|
855
|
+
_onDelete;
|
|
856
|
+
constructor(config, actions) {
|
|
857
|
+
this.reference = () => {
|
|
858
|
+
const { name, columns, foreignColumns } = config();
|
|
859
|
+
return {
|
|
860
|
+
name,
|
|
861
|
+
columns,
|
|
862
|
+
foreignTable: foreignColumns[0].table,
|
|
863
|
+
foreignColumns
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
if (actions) {
|
|
867
|
+
this._onUpdate = actions.onUpdate;
|
|
868
|
+
this._onDelete = actions.onDelete;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
onUpdate(action) {
|
|
872
|
+
this._onUpdate = action;
|
|
873
|
+
return this;
|
|
874
|
+
}
|
|
875
|
+
onDelete(action) {
|
|
876
|
+
this._onDelete = action;
|
|
877
|
+
return this;
|
|
878
|
+
}
|
|
879
|
+
/** @internal */
|
|
880
|
+
build(table) {
|
|
881
|
+
return new ForeignKey(table, this);
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
var ForeignKey = class {
|
|
885
|
+
constructor(table, builder) {
|
|
886
|
+
this.table = table;
|
|
887
|
+
this.reference = builder.reference;
|
|
888
|
+
this.onUpdate = builder._onUpdate;
|
|
889
|
+
this.onDelete = builder._onDelete;
|
|
890
|
+
}
|
|
891
|
+
static [entityKind] = "SQLiteForeignKey";
|
|
892
|
+
reference;
|
|
893
|
+
onUpdate;
|
|
894
|
+
onDelete;
|
|
895
|
+
getName() {
|
|
896
|
+
const { name, columns, foreignColumns } = this.reference();
|
|
897
|
+
const columnNames = columns.map((column) => column.name);
|
|
898
|
+
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
899
|
+
const chunks = [
|
|
900
|
+
this.table[TableName],
|
|
901
|
+
...columnNames,
|
|
902
|
+
foreignColumns[0].table[TableName],
|
|
903
|
+
...foreignColumnNames
|
|
904
|
+
];
|
|
905
|
+
return name ?? `${chunks.join("_")}_fk`;
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region node_modules/drizzle-orm/sqlite-core/unique-constraint.js
|
|
910
|
+
function uniqueKeyName(table, columns) {
|
|
911
|
+
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
912
|
+
}
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/common.js
|
|
915
|
+
var SQLiteColumnBuilder = class extends ColumnBuilder {
|
|
916
|
+
static [entityKind] = "SQLiteColumnBuilder";
|
|
917
|
+
foreignKeyConfigs = [];
|
|
918
|
+
references(ref, actions = {}) {
|
|
919
|
+
this.foreignKeyConfigs.push({
|
|
920
|
+
ref,
|
|
921
|
+
actions
|
|
922
|
+
});
|
|
923
|
+
return this;
|
|
924
|
+
}
|
|
925
|
+
unique(name) {
|
|
926
|
+
this.config.isUnique = true;
|
|
927
|
+
this.config.uniqueName = name;
|
|
928
|
+
return this;
|
|
929
|
+
}
|
|
930
|
+
generatedAlwaysAs(as, config) {
|
|
931
|
+
this.config.generated = {
|
|
932
|
+
as,
|
|
933
|
+
type: "always",
|
|
934
|
+
mode: config?.mode ?? "virtual"
|
|
935
|
+
};
|
|
936
|
+
return this;
|
|
937
|
+
}
|
|
938
|
+
/** @internal */
|
|
939
|
+
buildForeignKeys(column, table) {
|
|
940
|
+
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
941
|
+
return ((ref2, actions2) => {
|
|
942
|
+
const builder = new ForeignKeyBuilder(() => {
|
|
943
|
+
const foreignColumn = ref2();
|
|
944
|
+
return {
|
|
945
|
+
columns: [column],
|
|
946
|
+
foreignColumns: [foreignColumn]
|
|
947
|
+
};
|
|
948
|
+
});
|
|
949
|
+
if (actions2.onUpdate) builder.onUpdate(actions2.onUpdate);
|
|
950
|
+
if (actions2.onDelete) builder.onDelete(actions2.onDelete);
|
|
951
|
+
return builder.build(table);
|
|
952
|
+
})(ref, actions);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
var SQLiteColumn = class extends Column {
|
|
957
|
+
constructor(table, config) {
|
|
958
|
+
if (!config.uniqueName) config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
959
|
+
super(table, config);
|
|
960
|
+
this.table = table;
|
|
961
|
+
}
|
|
962
|
+
static [entityKind] = "SQLiteColumn";
|
|
963
|
+
};
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/blob.js
|
|
966
|
+
var SQLiteBigIntBuilder = class extends SQLiteColumnBuilder {
|
|
967
|
+
static [entityKind] = "SQLiteBigIntBuilder";
|
|
968
|
+
constructor(name) {
|
|
969
|
+
super(name, "bigint", "SQLiteBigInt");
|
|
970
|
+
}
|
|
971
|
+
/** @internal */
|
|
972
|
+
build(table) {
|
|
973
|
+
return new SQLiteBigInt(table, this.config);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
var SQLiteBigInt = class extends SQLiteColumn {
|
|
977
|
+
static [entityKind] = "SQLiteBigInt";
|
|
978
|
+
getSQLType() {
|
|
979
|
+
return "blob";
|
|
980
|
+
}
|
|
981
|
+
mapFromDriverValue(value) {
|
|
982
|
+
if (typeof Buffer !== "undefined" && Buffer.from) {
|
|
983
|
+
const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
|
|
984
|
+
return BigInt(buf.toString("utf8"));
|
|
985
|
+
}
|
|
986
|
+
return BigInt(textDecoder.decode(value));
|
|
987
|
+
}
|
|
988
|
+
mapToDriverValue(value) {
|
|
989
|
+
return Buffer.from(value.toString());
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
var SQLiteBlobJsonBuilder = class extends SQLiteColumnBuilder {
|
|
993
|
+
static [entityKind] = "SQLiteBlobJsonBuilder";
|
|
994
|
+
constructor(name) {
|
|
995
|
+
super(name, "json", "SQLiteBlobJson");
|
|
996
|
+
}
|
|
997
|
+
/** @internal */
|
|
998
|
+
build(table) {
|
|
999
|
+
return new SQLiteBlobJson(table, this.config);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
var SQLiteBlobJson = class extends SQLiteColumn {
|
|
1003
|
+
static [entityKind] = "SQLiteBlobJson";
|
|
1004
|
+
getSQLType() {
|
|
1005
|
+
return "blob";
|
|
1006
|
+
}
|
|
1007
|
+
mapFromDriverValue(value) {
|
|
1008
|
+
if (typeof Buffer !== "undefined" && Buffer.from) {
|
|
1009
|
+
const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
|
|
1010
|
+
return JSON.parse(buf.toString("utf8"));
|
|
1011
|
+
}
|
|
1012
|
+
return JSON.parse(textDecoder.decode(value));
|
|
1013
|
+
}
|
|
1014
|
+
mapToDriverValue(value) {
|
|
1015
|
+
return Buffer.from(JSON.stringify(value));
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var SQLiteBlobBufferBuilder = class extends SQLiteColumnBuilder {
|
|
1019
|
+
static [entityKind] = "SQLiteBlobBufferBuilder";
|
|
1020
|
+
constructor(name) {
|
|
1021
|
+
super(name, "buffer", "SQLiteBlobBuffer");
|
|
1022
|
+
}
|
|
1023
|
+
/** @internal */
|
|
1024
|
+
build(table) {
|
|
1025
|
+
return new SQLiteBlobBuffer(table, this.config);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
var SQLiteBlobBuffer = class extends SQLiteColumn {
|
|
1029
|
+
static [entityKind] = "SQLiteBlobBuffer";
|
|
1030
|
+
mapFromDriverValue(value) {
|
|
1031
|
+
if (Buffer.isBuffer(value)) return value;
|
|
1032
|
+
return Buffer.from(value);
|
|
1033
|
+
}
|
|
1034
|
+
getSQLType() {
|
|
1035
|
+
return "blob";
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
function blob(a, b) {
|
|
1039
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1040
|
+
if (config?.mode === "json") return new SQLiteBlobJsonBuilder(name);
|
|
1041
|
+
if (config?.mode === "bigint") return new SQLiteBigIntBuilder(name);
|
|
1042
|
+
return new SQLiteBlobBufferBuilder(name);
|
|
1043
|
+
}
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/custom.js
|
|
1046
|
+
var SQLiteCustomColumnBuilder = class extends SQLiteColumnBuilder {
|
|
1047
|
+
static [entityKind] = "SQLiteCustomColumnBuilder";
|
|
1048
|
+
constructor(name, fieldConfig, customTypeParams) {
|
|
1049
|
+
super(name, "custom", "SQLiteCustomColumn");
|
|
1050
|
+
this.config.fieldConfig = fieldConfig;
|
|
1051
|
+
this.config.customTypeParams = customTypeParams;
|
|
1052
|
+
}
|
|
1053
|
+
/** @internal */
|
|
1054
|
+
build(table) {
|
|
1055
|
+
return new SQLiteCustomColumn(table, this.config);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
var SQLiteCustomColumn = class extends SQLiteColumn {
|
|
1059
|
+
static [entityKind] = "SQLiteCustomColumn";
|
|
1060
|
+
sqlName;
|
|
1061
|
+
mapTo;
|
|
1062
|
+
mapFrom;
|
|
1063
|
+
constructor(table, config) {
|
|
1064
|
+
super(table, config);
|
|
1065
|
+
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
1066
|
+
this.mapTo = config.customTypeParams.toDriver;
|
|
1067
|
+
this.mapFrom = config.customTypeParams.fromDriver;
|
|
1068
|
+
}
|
|
1069
|
+
getSQLType() {
|
|
1070
|
+
return this.sqlName;
|
|
1071
|
+
}
|
|
1072
|
+
mapFromDriverValue(value) {
|
|
1073
|
+
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
1074
|
+
}
|
|
1075
|
+
mapToDriverValue(value) {
|
|
1076
|
+
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
function customType(customTypeParams) {
|
|
1080
|
+
return (a, b) => {
|
|
1081
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1082
|
+
return new SQLiteCustomColumnBuilder(name, config, customTypeParams);
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/integer.js
|
|
1087
|
+
var SQLiteBaseIntegerBuilder = class extends SQLiteColumnBuilder {
|
|
1088
|
+
static [entityKind] = "SQLiteBaseIntegerBuilder";
|
|
1089
|
+
constructor(name, dataType, columnType) {
|
|
1090
|
+
super(name, dataType, columnType);
|
|
1091
|
+
this.config.autoIncrement = false;
|
|
1092
|
+
}
|
|
1093
|
+
primaryKey(config) {
|
|
1094
|
+
if (config?.autoIncrement) this.config.autoIncrement = true;
|
|
1095
|
+
this.config.hasDefault = true;
|
|
1096
|
+
return super.primaryKey();
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
var SQLiteBaseInteger = class extends SQLiteColumn {
|
|
1100
|
+
static [entityKind] = "SQLiteBaseInteger";
|
|
1101
|
+
autoIncrement = this.config.autoIncrement;
|
|
1102
|
+
getSQLType() {
|
|
1103
|
+
return "integer";
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
var SQLiteIntegerBuilder = class extends SQLiteBaseIntegerBuilder {
|
|
1107
|
+
static [entityKind] = "SQLiteIntegerBuilder";
|
|
1108
|
+
constructor(name) {
|
|
1109
|
+
super(name, "number", "SQLiteInteger");
|
|
1110
|
+
}
|
|
1111
|
+
build(table) {
|
|
1112
|
+
return new SQLiteInteger(table, this.config);
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var SQLiteInteger = class extends SQLiteBaseInteger {
|
|
1116
|
+
static [entityKind] = "SQLiteInteger";
|
|
1117
|
+
};
|
|
1118
|
+
var SQLiteTimestampBuilder = class extends SQLiteBaseIntegerBuilder {
|
|
1119
|
+
static [entityKind] = "SQLiteTimestampBuilder";
|
|
1120
|
+
constructor(name, mode) {
|
|
1121
|
+
super(name, "date", "SQLiteTimestamp");
|
|
1122
|
+
this.config.mode = mode;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* @deprecated Use `default()` with your own expression instead.
|
|
1126
|
+
*
|
|
1127
|
+
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
|
|
1128
|
+
*/
|
|
1129
|
+
defaultNow() {
|
|
1130
|
+
return this.default(sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
|
|
1131
|
+
}
|
|
1132
|
+
build(table) {
|
|
1133
|
+
return new SQLiteTimestamp(table, this.config);
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
var SQLiteTimestamp = class extends SQLiteBaseInteger {
|
|
1137
|
+
static [entityKind] = "SQLiteTimestamp";
|
|
1138
|
+
mode = this.config.mode;
|
|
1139
|
+
mapFromDriverValue(value) {
|
|
1140
|
+
if (this.config.mode === "timestamp") return /* @__PURE__ */ new Date(value * 1e3);
|
|
1141
|
+
return new Date(value);
|
|
1142
|
+
}
|
|
1143
|
+
mapToDriverValue(value) {
|
|
1144
|
+
const unix = value.getTime();
|
|
1145
|
+
if (this.config.mode === "timestamp") return Math.floor(unix / 1e3);
|
|
1146
|
+
return unix;
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
var SQLiteBooleanBuilder = class extends SQLiteBaseIntegerBuilder {
|
|
1150
|
+
static [entityKind] = "SQLiteBooleanBuilder";
|
|
1151
|
+
constructor(name, mode) {
|
|
1152
|
+
super(name, "boolean", "SQLiteBoolean");
|
|
1153
|
+
this.config.mode = mode;
|
|
1154
|
+
}
|
|
1155
|
+
build(table) {
|
|
1156
|
+
return new SQLiteBoolean(table, this.config);
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
var SQLiteBoolean = class extends SQLiteBaseInteger {
|
|
1160
|
+
static [entityKind] = "SQLiteBoolean";
|
|
1161
|
+
mode = this.config.mode;
|
|
1162
|
+
mapFromDriverValue(value) {
|
|
1163
|
+
return Number(value) === 1;
|
|
1164
|
+
}
|
|
1165
|
+
mapToDriverValue(value) {
|
|
1166
|
+
return value ? 1 : 0;
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
function integer(a, b) {
|
|
1170
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1171
|
+
if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") return new SQLiteTimestampBuilder(name, config.mode);
|
|
1172
|
+
if (config?.mode === "boolean") return new SQLiteBooleanBuilder(name, config.mode);
|
|
1173
|
+
return new SQLiteIntegerBuilder(name);
|
|
1174
|
+
}
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/numeric.js
|
|
1177
|
+
var SQLiteNumericBuilder = class extends SQLiteColumnBuilder {
|
|
1178
|
+
static [entityKind] = "SQLiteNumericBuilder";
|
|
1179
|
+
constructor(name) {
|
|
1180
|
+
super(name, "string", "SQLiteNumeric");
|
|
1181
|
+
}
|
|
1182
|
+
/** @internal */
|
|
1183
|
+
build(table) {
|
|
1184
|
+
return new SQLiteNumeric(table, this.config);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
var SQLiteNumeric = class extends SQLiteColumn {
|
|
1188
|
+
static [entityKind] = "SQLiteNumeric";
|
|
1189
|
+
mapFromDriverValue(value) {
|
|
1190
|
+
if (typeof value === "string") return value;
|
|
1191
|
+
return String(value);
|
|
1192
|
+
}
|
|
1193
|
+
getSQLType() {
|
|
1194
|
+
return "numeric";
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
var SQLiteNumericNumberBuilder = class extends SQLiteColumnBuilder {
|
|
1198
|
+
static [entityKind] = "SQLiteNumericNumberBuilder";
|
|
1199
|
+
constructor(name) {
|
|
1200
|
+
super(name, "number", "SQLiteNumericNumber");
|
|
1201
|
+
}
|
|
1202
|
+
/** @internal */
|
|
1203
|
+
build(table) {
|
|
1204
|
+
return new SQLiteNumericNumber(table, this.config);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
var SQLiteNumericNumber = class extends SQLiteColumn {
|
|
1208
|
+
static [entityKind] = "SQLiteNumericNumber";
|
|
1209
|
+
mapFromDriverValue(value) {
|
|
1210
|
+
if (typeof value === "number") return value;
|
|
1211
|
+
return Number(value);
|
|
1212
|
+
}
|
|
1213
|
+
mapToDriverValue = String;
|
|
1214
|
+
getSQLType() {
|
|
1215
|
+
return "numeric";
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
var SQLiteNumericBigIntBuilder = class extends SQLiteColumnBuilder {
|
|
1219
|
+
static [entityKind] = "SQLiteNumericBigIntBuilder";
|
|
1220
|
+
constructor(name) {
|
|
1221
|
+
super(name, "bigint", "SQLiteNumericBigInt");
|
|
1222
|
+
}
|
|
1223
|
+
/** @internal */
|
|
1224
|
+
build(table) {
|
|
1225
|
+
return new SQLiteNumericBigInt(table, this.config);
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
var SQLiteNumericBigInt = class extends SQLiteColumn {
|
|
1229
|
+
static [entityKind] = "SQLiteNumericBigInt";
|
|
1230
|
+
mapFromDriverValue = BigInt;
|
|
1231
|
+
mapToDriverValue = String;
|
|
1232
|
+
getSQLType() {
|
|
1233
|
+
return "numeric";
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
function numeric(a, b) {
|
|
1237
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1238
|
+
const mode = config?.mode;
|
|
1239
|
+
return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
|
|
1240
|
+
}
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/real.js
|
|
1243
|
+
var SQLiteRealBuilder = class extends SQLiteColumnBuilder {
|
|
1244
|
+
static [entityKind] = "SQLiteRealBuilder";
|
|
1245
|
+
constructor(name) {
|
|
1246
|
+
super(name, "number", "SQLiteReal");
|
|
1247
|
+
}
|
|
1248
|
+
/** @internal */
|
|
1249
|
+
build(table) {
|
|
1250
|
+
return new SQLiteReal(table, this.config);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
var SQLiteReal = class extends SQLiteColumn {
|
|
1254
|
+
static [entityKind] = "SQLiteReal";
|
|
1255
|
+
getSQLType() {
|
|
1256
|
+
return "real";
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
function real(name) {
|
|
1260
|
+
return new SQLiteRealBuilder(name ?? "");
|
|
1261
|
+
}
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/text.js
|
|
1264
|
+
var SQLiteTextBuilder = class extends SQLiteColumnBuilder {
|
|
1265
|
+
static [entityKind] = "SQLiteTextBuilder";
|
|
1266
|
+
constructor(name, config) {
|
|
1267
|
+
super(name, "string", "SQLiteText");
|
|
1268
|
+
this.config.enumValues = config.enum;
|
|
1269
|
+
this.config.length = config.length;
|
|
1270
|
+
}
|
|
1271
|
+
/** @internal */
|
|
1272
|
+
build(table) {
|
|
1273
|
+
return new SQLiteText(table, this.config);
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
var SQLiteText = class extends SQLiteColumn {
|
|
1277
|
+
static [entityKind] = "SQLiteText";
|
|
1278
|
+
enumValues = this.config.enumValues;
|
|
1279
|
+
length = this.config.length;
|
|
1280
|
+
constructor(table, config) {
|
|
1281
|
+
super(table, config);
|
|
1282
|
+
}
|
|
1283
|
+
getSQLType() {
|
|
1284
|
+
return `text${this.config.length ? `(${this.config.length})` : ""}`;
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
var SQLiteTextJsonBuilder = class extends SQLiteColumnBuilder {
|
|
1288
|
+
static [entityKind] = "SQLiteTextJsonBuilder";
|
|
1289
|
+
constructor(name) {
|
|
1290
|
+
super(name, "json", "SQLiteTextJson");
|
|
1291
|
+
}
|
|
1292
|
+
/** @internal */
|
|
1293
|
+
build(table) {
|
|
1294
|
+
return new SQLiteTextJson(table, this.config);
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
var SQLiteTextJson = class extends SQLiteColumn {
|
|
1298
|
+
static [entityKind] = "SQLiteTextJson";
|
|
1299
|
+
getSQLType() {
|
|
1300
|
+
return "text";
|
|
1301
|
+
}
|
|
1302
|
+
mapFromDriverValue(value) {
|
|
1303
|
+
return JSON.parse(value);
|
|
1304
|
+
}
|
|
1305
|
+
mapToDriverValue(value) {
|
|
1306
|
+
return JSON.stringify(value);
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
function text(a, b = {}) {
|
|
1310
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1311
|
+
if (config.mode === "json") return new SQLiteTextJsonBuilder(name);
|
|
1312
|
+
return new SQLiteTextBuilder(name, config);
|
|
1313
|
+
}
|
|
1314
|
+
//#endregion
|
|
1315
|
+
//#region node_modules/drizzle-orm/sqlite-core/columns/all.js
|
|
1316
|
+
function getSQLiteColumnBuilders() {
|
|
1317
|
+
return {
|
|
1318
|
+
blob,
|
|
1319
|
+
customType,
|
|
1320
|
+
integer,
|
|
1321
|
+
numeric,
|
|
1322
|
+
real,
|
|
1323
|
+
text
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
//#endregion
|
|
1327
|
+
//#region node_modules/drizzle-orm/sqlite-core/table.js
|
|
1328
|
+
const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
|
1329
|
+
var SQLiteTable = class extends Table {
|
|
1330
|
+
static [entityKind] = "SQLiteTable";
|
|
1331
|
+
/** @internal */
|
|
1332
|
+
static Symbol = Object.assign({}, Table.Symbol, { InlineForeignKeys });
|
|
1333
|
+
/** @internal */
|
|
1334
|
+
[Table.Symbol.Columns];
|
|
1335
|
+
/** @internal */
|
|
1336
|
+
[InlineForeignKeys] = [];
|
|
1337
|
+
/** @internal */
|
|
1338
|
+
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
|
1339
|
+
};
|
|
1340
|
+
function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
|
|
1341
|
+
const rawTable = new SQLiteTable(name, schema, baseName);
|
|
1342
|
+
const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
|
|
1343
|
+
const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
1344
|
+
const colBuilder = colBuilderBase;
|
|
1345
|
+
colBuilder.setName(name2);
|
|
1346
|
+
const column = colBuilder.build(rawTable);
|
|
1347
|
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
1348
|
+
return [name2, column];
|
|
1349
|
+
}));
|
|
1350
|
+
const table = Object.assign(rawTable, builtColumns);
|
|
1351
|
+
table[Table.Symbol.Columns] = builtColumns;
|
|
1352
|
+
table[Table.Symbol.ExtraConfigColumns] = builtColumns;
|
|
1353
|
+
if (extraConfig) table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
|
1354
|
+
return table;
|
|
1355
|
+
}
|
|
1356
|
+
const sqliteTable = (name, columns, extraConfig) => {
|
|
1357
|
+
return sqliteTableBase(name, columns, extraConfig);
|
|
1358
|
+
};
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region node_modules/drizzle-orm/sqlite-core/indexes.js
|
|
1361
|
+
var IndexBuilderOn = class {
|
|
1362
|
+
constructor(name, unique) {
|
|
1363
|
+
this.name = name;
|
|
1364
|
+
this.unique = unique;
|
|
1365
|
+
}
|
|
1366
|
+
static [entityKind] = "SQLiteIndexBuilderOn";
|
|
1367
|
+
on(...columns) {
|
|
1368
|
+
return new IndexBuilder(this.name, columns, this.unique);
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
var IndexBuilder = class {
|
|
1372
|
+
static [entityKind] = "SQLiteIndexBuilder";
|
|
1373
|
+
/** @internal */
|
|
1374
|
+
config;
|
|
1375
|
+
constructor(name, columns, unique) {
|
|
1376
|
+
this.config = {
|
|
1377
|
+
name,
|
|
1378
|
+
columns,
|
|
1379
|
+
unique,
|
|
1380
|
+
where: void 0
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Condition for partial index.
|
|
1385
|
+
*/
|
|
1386
|
+
where(condition) {
|
|
1387
|
+
this.config.where = condition;
|
|
1388
|
+
return this;
|
|
1389
|
+
}
|
|
1390
|
+
/** @internal */
|
|
1391
|
+
build(table) {
|
|
1392
|
+
return new Index(this.config, table);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
var Index = class {
|
|
1396
|
+
static [entityKind] = "SQLiteIndex";
|
|
1397
|
+
config;
|
|
1398
|
+
constructor(config, table) {
|
|
1399
|
+
this.config = {
|
|
1400
|
+
...config,
|
|
1401
|
+
table
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
function uniqueIndex(name) {
|
|
1406
|
+
return new IndexBuilderOn(name, true);
|
|
1407
|
+
}
|
|
1408
|
+
//#endregion
|
|
1409
|
+
export { is as $, or as A, SQL as B, ne as C, notIlike as D, notExists as E, isConfig as F, Table as G, fillPlaceholders as H, mapResultRow as I, ViewBaseConfig as J, getTableName as K, mapUpdateSet as L, getTableColumns as M, getTableLikeName as N, notInArray as O, haveSameKeys as P, entityKind as Q, orderSelectedFields as R, lte as S, notBetween as T, sql as U, View as V, Columns as W, WithSubquery as X, Subquery as Y, Column as Z, inArray as _, real as a, like as b, asc as c, between as d, eq as f, ilike as g, gte as h, text as i, applyMixins as j, notLike as k, desc as l, gt as m, SQLiteTable as n, integer as o, exists as p, getTableUniqueName as q, sqliteTable as r, SQLiteColumn as s, uniqueIndex as t, and as u, isNotNull as v, not as w, lt as x, isNull as y, Param as z };
|