@elizaos/plugin-goals 2.0.0-alpha.1 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/cancelGoal.d.ts.map +1 -1
- package/dist/actions/completeGoal.d.ts.map +1 -1
- package/dist/actions/confirmGoal.d.ts.map +1 -1
- package/dist/actions/createGoal.d.ts.map +1 -1
- package/dist/actions/updateGoal.d.ts.map +1 -1
- package/dist/generated/prompts/typescript/prompts.d.ts +12 -12
- package/dist/generated/prompts/typescript/prompts.d.ts.map +1 -1
- package/dist/generated/specs/spec-helpers.d.ts +1 -1
- package/dist/generated/specs/spec-helpers.d.ts.map +1 -1
- package/dist/generated/specs/specs.d.ts +46 -4
- package/dist/generated/specs/specs.d.ts.map +1 -1
- package/dist/node/index.node.js +393 -3771
- package/dist/node/index.node.js.map +16 -91
- package/dist/providers/goals.d.ts.map +1 -1
- package/dist/schema.d.ts +6 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/services/goalDataService.d.ts.map +1 -1
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/package.json +56 -9
package/dist/node/index.node.js
CHANGED
|
@@ -1,2782 +1,27 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
get: all[name],
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
set: (newValue) => all[name] = () => newValue
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
-
|
|
13
|
-
// ../../../node_modules/drizzle-orm/entity.js
|
|
14
|
-
function is(value, type) {
|
|
15
|
-
if (!value || typeof value !== "object") {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
if (value instanceof type) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
|
|
22
|
-
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.`);
|
|
23
|
-
}
|
|
24
|
-
let cls = Object.getPrototypeOf(value).constructor;
|
|
25
|
-
if (cls) {
|
|
26
|
-
while (cls) {
|
|
27
|
-
if (entityKind in cls && cls[entityKind] === type[entityKind]) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
cls = Object.getPrototypeOf(cls);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
var entityKind, hasOwnEntityKind;
|
|
36
|
-
var init_entity = __esm(() => {
|
|
37
|
-
entityKind = Symbol.for("drizzle:entityKind");
|
|
38
|
-
hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// ../../../node_modules/drizzle-orm/column.js
|
|
42
|
-
var Column;
|
|
43
|
-
var init_column = __esm(() => {
|
|
44
|
-
init_entity();
|
|
45
|
-
Column = class Column {
|
|
46
|
-
constructor(table, config) {
|
|
47
|
-
this.table = table;
|
|
48
|
-
this.config = config;
|
|
49
|
-
this.name = config.name;
|
|
50
|
-
this.keyAsName = config.keyAsName;
|
|
51
|
-
this.notNull = config.notNull;
|
|
52
|
-
this.default = config.default;
|
|
53
|
-
this.defaultFn = config.defaultFn;
|
|
54
|
-
this.onUpdateFn = config.onUpdateFn;
|
|
55
|
-
this.hasDefault = config.hasDefault;
|
|
56
|
-
this.primary = config.primaryKey;
|
|
57
|
-
this.isUnique = config.isUnique;
|
|
58
|
-
this.uniqueName = config.uniqueName;
|
|
59
|
-
this.uniqueType = config.uniqueType;
|
|
60
|
-
this.dataType = config.dataType;
|
|
61
|
-
this.columnType = config.columnType;
|
|
62
|
-
this.generated = config.generated;
|
|
63
|
-
this.generatedIdentity = config.generatedIdentity;
|
|
64
|
-
}
|
|
65
|
-
static [entityKind] = "Column";
|
|
66
|
-
name;
|
|
67
|
-
keyAsName;
|
|
68
|
-
primary;
|
|
69
|
-
notNull;
|
|
70
|
-
default;
|
|
71
|
-
defaultFn;
|
|
72
|
-
onUpdateFn;
|
|
73
|
-
hasDefault;
|
|
74
|
-
isUnique;
|
|
75
|
-
uniqueName;
|
|
76
|
-
uniqueType;
|
|
77
|
-
dataType;
|
|
78
|
-
columnType;
|
|
79
|
-
enumValues = undefined;
|
|
80
|
-
generated = undefined;
|
|
81
|
-
generatedIdentity = undefined;
|
|
82
|
-
config;
|
|
83
|
-
mapFromDriverValue(value) {
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
mapToDriverValue(value) {
|
|
87
|
-
return value;
|
|
88
|
-
}
|
|
89
|
-
shouldDisableInsert() {
|
|
90
|
-
return this.config.generated !== undefined && this.config.generated.type !== "byDefault";
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// ../../../node_modules/drizzle-orm/column-builder.js
|
|
96
|
-
var ColumnBuilder;
|
|
97
|
-
var init_column_builder = __esm(() => {
|
|
98
|
-
init_entity();
|
|
99
|
-
ColumnBuilder = class ColumnBuilder {
|
|
100
|
-
static [entityKind] = "ColumnBuilder";
|
|
101
|
-
config;
|
|
102
|
-
constructor(name, dataType, columnType) {
|
|
103
|
-
this.config = {
|
|
104
|
-
name,
|
|
105
|
-
keyAsName: name === "",
|
|
106
|
-
notNull: false,
|
|
107
|
-
default: undefined,
|
|
108
|
-
hasDefault: false,
|
|
109
|
-
primaryKey: false,
|
|
110
|
-
isUnique: false,
|
|
111
|
-
uniqueName: undefined,
|
|
112
|
-
uniqueType: undefined,
|
|
113
|
-
dataType,
|
|
114
|
-
columnType,
|
|
115
|
-
generated: undefined
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
$type() {
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
notNull() {
|
|
122
|
-
this.config.notNull = true;
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
default(value) {
|
|
126
|
-
this.config.default = value;
|
|
127
|
-
this.config.hasDefault = true;
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
$defaultFn(fn) {
|
|
131
|
-
this.config.defaultFn = fn;
|
|
132
|
-
this.config.hasDefault = true;
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
$default = this.$defaultFn;
|
|
136
|
-
$onUpdateFn(fn) {
|
|
137
|
-
this.config.onUpdateFn = fn;
|
|
138
|
-
this.config.hasDefault = true;
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
$onUpdate = this.$onUpdateFn;
|
|
142
|
-
primaryKey() {
|
|
143
|
-
this.config.primaryKey = true;
|
|
144
|
-
this.config.notNull = true;
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
setName(name) {
|
|
148
|
-
if (this.config.name !== "")
|
|
149
|
-
return;
|
|
150
|
-
this.config.name = name;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// ../../../node_modules/drizzle-orm/table.utils.js
|
|
156
|
-
var TableName;
|
|
157
|
-
var init_table_utils = __esm(() => {
|
|
158
|
-
TableName = Symbol.for("drizzle:Name");
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// ../../../node_modules/drizzle-orm/pg-core/foreign-keys.js
|
|
162
|
-
var ForeignKeyBuilder, ForeignKey;
|
|
163
|
-
var init_foreign_keys = __esm(() => {
|
|
164
|
-
init_entity();
|
|
165
|
-
init_table_utils();
|
|
166
|
-
ForeignKeyBuilder = class ForeignKeyBuilder {
|
|
167
|
-
static [entityKind] = "PgForeignKeyBuilder";
|
|
168
|
-
reference;
|
|
169
|
-
_onUpdate = "no action";
|
|
170
|
-
_onDelete = "no action";
|
|
171
|
-
constructor(config, actions) {
|
|
172
|
-
this.reference = () => {
|
|
173
|
-
const { name, columns, foreignColumns } = config();
|
|
174
|
-
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
|
|
175
|
-
};
|
|
176
|
-
if (actions) {
|
|
177
|
-
this._onUpdate = actions.onUpdate;
|
|
178
|
-
this._onDelete = actions.onDelete;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
onUpdate(action) {
|
|
182
|
-
this._onUpdate = action === undefined ? "no action" : action;
|
|
183
|
-
return this;
|
|
184
|
-
}
|
|
185
|
-
onDelete(action) {
|
|
186
|
-
this._onDelete = action === undefined ? "no action" : action;
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
build(table) {
|
|
190
|
-
return new ForeignKey(table, this);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
ForeignKey = class ForeignKey {
|
|
194
|
-
constructor(table, builder) {
|
|
195
|
-
this.table = table;
|
|
196
|
-
this.reference = builder.reference;
|
|
197
|
-
this.onUpdate = builder._onUpdate;
|
|
198
|
-
this.onDelete = builder._onDelete;
|
|
199
|
-
}
|
|
200
|
-
static [entityKind] = "PgForeignKey";
|
|
201
|
-
reference;
|
|
202
|
-
onUpdate;
|
|
203
|
-
onDelete;
|
|
204
|
-
getName() {
|
|
205
|
-
const { name, columns, foreignColumns } = this.reference();
|
|
206
|
-
const columnNames = columns.map((column) => column.name);
|
|
207
|
-
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
208
|
-
const chunks = [
|
|
209
|
-
this.table[TableName],
|
|
210
|
-
...columnNames,
|
|
211
|
-
foreignColumns[0].table[TableName],
|
|
212
|
-
...foreignColumnNames
|
|
213
|
-
];
|
|
214
|
-
return name ?? `${chunks.join("_")}_fk`;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
// ../../../node_modules/drizzle-orm/tracing-utils.js
|
|
220
|
-
function iife(fn, ...args) {
|
|
221
|
-
return fn(...args);
|
|
222
|
-
}
|
|
223
|
-
var init_tracing_utils = () => {};
|
|
224
|
-
|
|
225
|
-
// ../../../node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
226
|
-
function uniqueKeyName(table, columns) {
|
|
227
|
-
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
228
|
-
}
|
|
229
|
-
var init_unique_constraint = __esm(() => {
|
|
230
|
-
init_table_utils();
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// ../../../node_modules/drizzle-orm/pg-core/utils/array.js
|
|
234
|
-
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
235
|
-
for (let i = startFrom;i < arrayString.length; i++) {
|
|
236
|
-
const char = arrayString[i];
|
|
237
|
-
if (char === "\\") {
|
|
238
|
-
i++;
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
if (char === '"') {
|
|
242
|
-
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
|
|
243
|
-
}
|
|
244
|
-
if (inQuotes) {
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (char === "," || char === "}") {
|
|
248
|
-
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
|
|
252
|
-
}
|
|
253
|
-
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
254
|
-
const result = [];
|
|
255
|
-
let i = startFrom;
|
|
256
|
-
let lastCharIsComma = false;
|
|
257
|
-
while (i < arrayString.length) {
|
|
258
|
-
const char = arrayString[i];
|
|
259
|
-
if (char === ",") {
|
|
260
|
-
if (lastCharIsComma || i === startFrom) {
|
|
261
|
-
result.push("");
|
|
262
|
-
}
|
|
263
|
-
lastCharIsComma = true;
|
|
264
|
-
i++;
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
lastCharIsComma = false;
|
|
268
|
-
if (char === "\\") {
|
|
269
|
-
i += 2;
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
if (char === '"') {
|
|
273
|
-
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
274
|
-
result.push(value2);
|
|
275
|
-
i = startFrom2;
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
if (char === "}") {
|
|
279
|
-
return [result, i + 1];
|
|
280
|
-
}
|
|
281
|
-
if (char === "{") {
|
|
282
|
-
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
283
|
-
result.push(value2);
|
|
284
|
-
i = startFrom2;
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
288
|
-
result.push(value);
|
|
289
|
-
i = newStartFrom;
|
|
290
|
-
}
|
|
291
|
-
return [result, i];
|
|
292
|
-
}
|
|
293
|
-
function parsePgArray(arrayString) {
|
|
294
|
-
const [result] = parsePgNestedArray(arrayString, 1);
|
|
295
|
-
return result;
|
|
296
|
-
}
|
|
297
|
-
function makePgArray(array) {
|
|
298
|
-
return `{${array.map((item) => {
|
|
299
|
-
if (Array.isArray(item)) {
|
|
300
|
-
return makePgArray(item);
|
|
301
|
-
}
|
|
302
|
-
if (typeof item === "string") {
|
|
303
|
-
return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
304
|
-
}
|
|
305
|
-
return `${item}`;
|
|
306
|
-
}).join(",")}}`;
|
|
307
|
-
}
|
|
308
|
-
var init_array = () => {};
|
|
309
|
-
|
|
310
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/common.js
|
|
311
|
-
var PgColumnBuilder, PgColumn, ExtraConfigColumn, IndexedColumn, PgArrayBuilder, PgArray;
|
|
312
|
-
var init_common = __esm(() => {
|
|
313
|
-
init_column_builder();
|
|
314
|
-
init_column();
|
|
315
|
-
init_entity();
|
|
316
|
-
init_foreign_keys();
|
|
317
|
-
init_tracing_utils();
|
|
318
|
-
init_unique_constraint();
|
|
319
|
-
init_array();
|
|
320
|
-
PgColumnBuilder = class PgColumnBuilder extends ColumnBuilder {
|
|
321
|
-
foreignKeyConfigs = [];
|
|
322
|
-
static [entityKind] = "PgColumnBuilder";
|
|
323
|
-
array(size) {
|
|
324
|
-
return new PgArrayBuilder(this.config.name, this, size);
|
|
325
|
-
}
|
|
326
|
-
references(ref, actions = {}) {
|
|
327
|
-
this.foreignKeyConfigs.push({ ref, actions });
|
|
328
|
-
return this;
|
|
329
|
-
}
|
|
330
|
-
unique(name, config) {
|
|
331
|
-
this.config.isUnique = true;
|
|
332
|
-
this.config.uniqueName = name;
|
|
333
|
-
this.config.uniqueType = config?.nulls;
|
|
334
|
-
return this;
|
|
335
|
-
}
|
|
336
|
-
generatedAlwaysAs(as) {
|
|
337
|
-
this.config.generated = {
|
|
338
|
-
as,
|
|
339
|
-
type: "always",
|
|
340
|
-
mode: "stored"
|
|
341
|
-
};
|
|
342
|
-
return this;
|
|
343
|
-
}
|
|
344
|
-
buildForeignKeys(column, table) {
|
|
345
|
-
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
346
|
-
return iife((ref2, actions2) => {
|
|
347
|
-
const builder = new ForeignKeyBuilder(() => {
|
|
348
|
-
const foreignColumn = ref2();
|
|
349
|
-
return { columns: [column], foreignColumns: [foreignColumn] };
|
|
350
|
-
});
|
|
351
|
-
if (actions2.onUpdate) {
|
|
352
|
-
builder.onUpdate(actions2.onUpdate);
|
|
353
|
-
}
|
|
354
|
-
if (actions2.onDelete) {
|
|
355
|
-
builder.onDelete(actions2.onDelete);
|
|
356
|
-
}
|
|
357
|
-
return builder.build(table);
|
|
358
|
-
}, ref, actions);
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
buildExtraConfigColumn(table) {
|
|
362
|
-
return new ExtraConfigColumn(table, this.config);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
PgColumn = class PgColumn extends Column {
|
|
366
|
-
constructor(table, config) {
|
|
367
|
-
if (!config.uniqueName) {
|
|
368
|
-
config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
369
|
-
}
|
|
370
|
-
super(table, config);
|
|
371
|
-
this.table = table;
|
|
372
|
-
}
|
|
373
|
-
static [entityKind] = "PgColumn";
|
|
374
|
-
};
|
|
375
|
-
ExtraConfigColumn = class ExtraConfigColumn extends PgColumn {
|
|
376
|
-
static [entityKind] = "ExtraConfigColumn";
|
|
377
|
-
getSQLType() {
|
|
378
|
-
return this.getSQLType();
|
|
379
|
-
}
|
|
380
|
-
indexConfig = {
|
|
381
|
-
order: this.config.order ?? "asc",
|
|
382
|
-
nulls: this.config.nulls ?? "last",
|
|
383
|
-
opClass: this.config.opClass
|
|
384
|
-
};
|
|
385
|
-
defaultConfig = {
|
|
386
|
-
order: "asc",
|
|
387
|
-
nulls: "last",
|
|
388
|
-
opClass: undefined
|
|
389
|
-
};
|
|
390
|
-
asc() {
|
|
391
|
-
this.indexConfig.order = "asc";
|
|
392
|
-
return this;
|
|
393
|
-
}
|
|
394
|
-
desc() {
|
|
395
|
-
this.indexConfig.order = "desc";
|
|
396
|
-
return this;
|
|
397
|
-
}
|
|
398
|
-
nullsFirst() {
|
|
399
|
-
this.indexConfig.nulls = "first";
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
nullsLast() {
|
|
403
|
-
this.indexConfig.nulls = "last";
|
|
404
|
-
return this;
|
|
405
|
-
}
|
|
406
|
-
op(opClass) {
|
|
407
|
-
this.indexConfig.opClass = opClass;
|
|
408
|
-
return this;
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
IndexedColumn = class IndexedColumn {
|
|
412
|
-
static [entityKind] = "IndexedColumn";
|
|
413
|
-
constructor(name, keyAsName, type, indexConfig) {
|
|
414
|
-
this.name = name;
|
|
415
|
-
this.keyAsName = keyAsName;
|
|
416
|
-
this.type = type;
|
|
417
|
-
this.indexConfig = indexConfig;
|
|
418
|
-
}
|
|
419
|
-
name;
|
|
420
|
-
keyAsName;
|
|
421
|
-
type;
|
|
422
|
-
indexConfig;
|
|
423
|
-
};
|
|
424
|
-
PgArrayBuilder = class PgArrayBuilder extends PgColumnBuilder {
|
|
425
|
-
static [entityKind] = "PgArrayBuilder";
|
|
426
|
-
constructor(name, baseBuilder, size) {
|
|
427
|
-
super(name, "array", "PgArray");
|
|
428
|
-
this.config.baseBuilder = baseBuilder;
|
|
429
|
-
this.config.size = size;
|
|
430
|
-
}
|
|
431
|
-
build(table) {
|
|
432
|
-
const baseColumn = this.config.baseBuilder.build(table);
|
|
433
|
-
return new PgArray(table, this.config, baseColumn);
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
PgArray = class PgArray extends PgColumn {
|
|
437
|
-
constructor(table, config, baseColumn, range) {
|
|
438
|
-
super(table, config);
|
|
439
|
-
this.baseColumn = baseColumn;
|
|
440
|
-
this.range = range;
|
|
441
|
-
this.size = config.size;
|
|
442
|
-
}
|
|
443
|
-
size;
|
|
444
|
-
static [entityKind] = "PgArray";
|
|
445
|
-
getSQLType() {
|
|
446
|
-
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
447
|
-
}
|
|
448
|
-
mapFromDriverValue(value) {
|
|
449
|
-
if (typeof value === "string") {
|
|
450
|
-
value = parsePgArray(value);
|
|
451
|
-
}
|
|
452
|
-
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
453
|
-
}
|
|
454
|
-
mapToDriverValue(value, isNestedArray = false) {
|
|
455
|
-
const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
|
|
456
|
-
if (isNestedArray)
|
|
457
|
-
return a;
|
|
458
|
-
return makePgArray(a);
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
464
|
-
function isPgEnum(obj) {
|
|
465
|
-
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
466
|
-
}
|
|
467
|
-
var PgEnumObjectColumn, isPgEnumSym, PgEnumColumn;
|
|
468
|
-
var init_enum = __esm(() => {
|
|
469
|
-
init_entity();
|
|
470
|
-
init_common();
|
|
471
|
-
PgEnumObjectColumn = class PgEnumObjectColumn extends PgColumn {
|
|
472
|
-
static [entityKind] = "PgEnumObjectColumn";
|
|
473
|
-
enum;
|
|
474
|
-
enumValues = this.config.enum.enumValues;
|
|
475
|
-
constructor(table, config) {
|
|
476
|
-
super(table, config);
|
|
477
|
-
this.enum = config.enum;
|
|
478
|
-
}
|
|
479
|
-
getSQLType() {
|
|
480
|
-
return this.enum.enumName;
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
484
|
-
PgEnumColumn = class PgEnumColumn extends PgColumn {
|
|
485
|
-
static [entityKind] = "PgEnumColumn";
|
|
486
|
-
enum = this.config.enum;
|
|
487
|
-
enumValues = this.config.enum.enumValues;
|
|
488
|
-
constructor(table, config) {
|
|
489
|
-
super(table, config);
|
|
490
|
-
this.enum = config.enum;
|
|
491
|
-
}
|
|
492
|
-
getSQLType() {
|
|
493
|
-
return this.enum.enumName;
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
// ../../../node_modules/drizzle-orm/subquery.js
|
|
499
|
-
var Subquery;
|
|
500
|
-
var init_subquery = __esm(() => {
|
|
501
|
-
init_entity();
|
|
502
|
-
Subquery = class Subquery {
|
|
503
|
-
static [entityKind] = "Subquery";
|
|
504
|
-
constructor(sql, fields, alias, isWith = false, usedTables = []) {
|
|
505
|
-
this._ = {
|
|
506
|
-
brand: "Subquery",
|
|
507
|
-
sql,
|
|
508
|
-
selectedFields: fields,
|
|
509
|
-
alias,
|
|
510
|
-
isWith,
|
|
511
|
-
usedTables
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
// ../../../node_modules/drizzle-orm/version.js
|
|
518
|
-
var version = "0.45.1";
|
|
519
|
-
var init_version = () => {};
|
|
520
|
-
|
|
521
|
-
// ../../../node_modules/drizzle-orm/tracing.js
|
|
522
|
-
var otel, rawTracer, tracer;
|
|
523
|
-
var init_tracing = __esm(() => {
|
|
524
|
-
init_tracing_utils();
|
|
525
|
-
init_version();
|
|
526
|
-
tracer = {
|
|
527
|
-
startActiveSpan(name, fn) {
|
|
528
|
-
if (!otel) {
|
|
529
|
-
return fn();
|
|
530
|
-
}
|
|
531
|
-
if (!rawTracer) {
|
|
532
|
-
rawTracer = otel.trace.getTracer("drizzle-orm", version);
|
|
533
|
-
}
|
|
534
|
-
return iife((otel2, rawTracer2) => rawTracer2.startActiveSpan(name, (span) => {
|
|
535
|
-
try {
|
|
536
|
-
return fn(span);
|
|
537
|
-
} catch (e) {
|
|
538
|
-
span.setStatus({
|
|
539
|
-
code: otel2.SpanStatusCode.ERROR,
|
|
540
|
-
message: e instanceof Error ? e.message : "Unknown error"
|
|
541
|
-
});
|
|
542
|
-
throw e;
|
|
543
|
-
} finally {
|
|
544
|
-
span.end();
|
|
545
|
-
}
|
|
546
|
-
}), otel, rawTracer);
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// ../../../node_modules/drizzle-orm/view-common.js
|
|
552
|
-
var ViewBaseConfig;
|
|
553
|
-
var init_view_common = __esm(() => {
|
|
554
|
-
ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
// ../../../node_modules/drizzle-orm/table.js
|
|
558
|
-
function getTableName(table) {
|
|
559
|
-
return table[TableName];
|
|
560
|
-
}
|
|
561
|
-
var Schema, Columns, ExtraConfigColumns, OriginalName, BaseName, IsAlias, ExtraConfigBuilder, IsDrizzleTable, Table;
|
|
562
|
-
var init_table = __esm(() => {
|
|
563
|
-
init_entity();
|
|
564
|
-
init_table_utils();
|
|
565
|
-
Schema = Symbol.for("drizzle:Schema");
|
|
566
|
-
Columns = Symbol.for("drizzle:Columns");
|
|
567
|
-
ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
568
|
-
OriginalName = Symbol.for("drizzle:OriginalName");
|
|
569
|
-
BaseName = Symbol.for("drizzle:BaseName");
|
|
570
|
-
IsAlias = Symbol.for("drizzle:IsAlias");
|
|
571
|
-
ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
|
572
|
-
IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
|
573
|
-
Table = class Table {
|
|
574
|
-
static [entityKind] = "Table";
|
|
575
|
-
static Symbol = {
|
|
576
|
-
Name: TableName,
|
|
577
|
-
Schema,
|
|
578
|
-
OriginalName,
|
|
579
|
-
Columns,
|
|
580
|
-
ExtraConfigColumns,
|
|
581
|
-
BaseName,
|
|
582
|
-
IsAlias,
|
|
583
|
-
ExtraConfigBuilder
|
|
584
|
-
};
|
|
585
|
-
[TableName];
|
|
586
|
-
[OriginalName];
|
|
587
|
-
[Schema];
|
|
588
|
-
[Columns];
|
|
589
|
-
[ExtraConfigColumns];
|
|
590
|
-
[BaseName];
|
|
591
|
-
[IsAlias] = false;
|
|
592
|
-
[IsDrizzleTable] = true;
|
|
593
|
-
[ExtraConfigBuilder] = undefined;
|
|
594
|
-
constructor(name, schema, baseName) {
|
|
595
|
-
this[TableName] = this[OriginalName] = name;
|
|
596
|
-
this[Schema] = schema;
|
|
597
|
-
this[BaseName] = baseName;
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
// ../../../node_modules/drizzle-orm/sql/sql.js
|
|
603
|
-
function isSQLWrapper(value) {
|
|
604
|
-
return value !== null && value !== undefined && typeof value.getSQL === "function";
|
|
605
|
-
}
|
|
606
|
-
function mergeQueries(queries) {
|
|
607
|
-
const result = { sql: "", params: [] };
|
|
608
|
-
for (const query of queries) {
|
|
609
|
-
result.sql += query.sql;
|
|
610
|
-
result.params.push(...query.params);
|
|
611
|
-
if (query.typings?.length) {
|
|
612
|
-
if (!result.typings) {
|
|
613
|
-
result.typings = [];
|
|
614
|
-
}
|
|
615
|
-
result.typings.push(...query.typings);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
return result;
|
|
619
|
-
}
|
|
620
|
-
function isDriverValueEncoder(value) {
|
|
621
|
-
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
622
|
-
}
|
|
623
|
-
function sql(strings, ...params) {
|
|
624
|
-
const queryChunks = [];
|
|
625
|
-
if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
|
|
626
|
-
queryChunks.push(new StringChunk(strings[0]));
|
|
627
|
-
}
|
|
628
|
-
for (const [paramIndex, param2] of params.entries()) {
|
|
629
|
-
queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
630
|
-
}
|
|
631
|
-
return new SQL(queryChunks);
|
|
632
|
-
}
|
|
633
|
-
var StringChunk, SQL, Name, noopDecoder, noopEncoder, noopMapper, Param, Placeholder, IsDrizzleView, View;
|
|
634
|
-
var init_sql = __esm(() => {
|
|
635
|
-
init_entity();
|
|
636
|
-
init_enum();
|
|
637
|
-
init_subquery();
|
|
638
|
-
init_tracing();
|
|
639
|
-
init_view_common();
|
|
640
|
-
init_column();
|
|
641
|
-
init_table();
|
|
642
|
-
StringChunk = class StringChunk {
|
|
643
|
-
static [entityKind] = "StringChunk";
|
|
644
|
-
value;
|
|
645
|
-
constructor(value) {
|
|
646
|
-
this.value = Array.isArray(value) ? value : [value];
|
|
647
|
-
}
|
|
648
|
-
getSQL() {
|
|
649
|
-
return new SQL([this]);
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
SQL = class SQL {
|
|
653
|
-
constructor(queryChunks) {
|
|
654
|
-
this.queryChunks = queryChunks;
|
|
655
|
-
for (const chunk of queryChunks) {
|
|
656
|
-
if (is(chunk, Table)) {
|
|
657
|
-
const schemaName = chunk[Table.Symbol.Schema];
|
|
658
|
-
this.usedTables.push(schemaName === undefined ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
static [entityKind] = "SQL";
|
|
663
|
-
decoder = noopDecoder;
|
|
664
|
-
shouldInlineParams = false;
|
|
665
|
-
usedTables = [];
|
|
666
|
-
append(query) {
|
|
667
|
-
this.queryChunks.push(...query.queryChunks);
|
|
668
|
-
return this;
|
|
669
|
-
}
|
|
670
|
-
toQuery(config) {
|
|
671
|
-
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
672
|
-
const query = this.buildQueryFromSourceParams(this.queryChunks, config);
|
|
673
|
-
span?.setAttributes({
|
|
674
|
-
"drizzle.query.text": query.sql,
|
|
675
|
-
"drizzle.query.params": JSON.stringify(query.params)
|
|
676
|
-
});
|
|
677
|
-
return query;
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
buildQueryFromSourceParams(chunks, _config) {
|
|
681
|
-
const config = Object.assign({}, _config, {
|
|
682
|
-
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
683
|
-
paramStartIndex: _config.paramStartIndex || { value: 0 }
|
|
684
|
-
});
|
|
685
|
-
const {
|
|
686
|
-
casing,
|
|
687
|
-
escapeName,
|
|
688
|
-
escapeParam,
|
|
689
|
-
prepareTyping,
|
|
690
|
-
inlineParams,
|
|
691
|
-
paramStartIndex
|
|
692
|
-
} = config;
|
|
693
|
-
return mergeQueries(chunks.map((chunk) => {
|
|
694
|
-
if (is(chunk, StringChunk)) {
|
|
695
|
-
return { sql: chunk.value.join(""), params: [] };
|
|
696
|
-
}
|
|
697
|
-
if (is(chunk, Name)) {
|
|
698
|
-
return { sql: escapeName(chunk.value), params: [] };
|
|
699
|
-
}
|
|
700
|
-
if (chunk === undefined) {
|
|
701
|
-
return { sql: "", params: [] };
|
|
702
|
-
}
|
|
703
|
-
if (Array.isArray(chunk)) {
|
|
704
|
-
const result = [new StringChunk("(")];
|
|
705
|
-
for (const [i, p] of chunk.entries()) {
|
|
706
|
-
result.push(p);
|
|
707
|
-
if (i < chunk.length - 1) {
|
|
708
|
-
result.push(new StringChunk(", "));
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
result.push(new StringChunk(")"));
|
|
712
|
-
return this.buildQueryFromSourceParams(result, config);
|
|
713
|
-
}
|
|
714
|
-
if (is(chunk, SQL)) {
|
|
715
|
-
return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
716
|
-
...config,
|
|
717
|
-
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
if (is(chunk, Table)) {
|
|
721
|
-
const schemaName = chunk[Table.Symbol.Schema];
|
|
722
|
-
const tableName = chunk[Table.Symbol.Name];
|
|
723
|
-
return {
|
|
724
|
-
sql: schemaName === undefined || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
725
|
-
params: []
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
if (is(chunk, Column)) {
|
|
729
|
-
const columnName = casing.getColumnCasing(chunk);
|
|
730
|
-
if (_config.invokeSource === "indexes") {
|
|
731
|
-
return { sql: escapeName(columnName), params: [] };
|
|
732
|
-
}
|
|
733
|
-
const schemaName = chunk.table[Table.Symbol.Schema];
|
|
734
|
-
return {
|
|
735
|
-
sql: chunk.table[IsAlias] || schemaName === undefined ? 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 === undefined || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
744
|
-
params: []
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
if (is(chunk, Param)) {
|
|
748
|
-
if (is(chunk.value, Placeholder)) {
|
|
749
|
-
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
750
|
-
}
|
|
751
|
-
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
752
|
-
if (is(mappedValue, SQL)) {
|
|
753
|
-
return this.buildQueryFromSourceParams([mappedValue], config);
|
|
754
|
-
}
|
|
755
|
-
if (inlineParams) {
|
|
756
|
-
return { sql: this.mapInlineParam(mappedValue, config), params: [] };
|
|
757
|
-
}
|
|
758
|
-
let typings = ["none"];
|
|
759
|
-
if (prepareTyping) {
|
|
760
|
-
typings = [prepareTyping(chunk.encoder)];
|
|
761
|
-
}
|
|
762
|
-
return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
|
|
763
|
-
}
|
|
764
|
-
if (is(chunk, Placeholder)) {
|
|
765
|
-
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
766
|
-
}
|
|
767
|
-
if (is(chunk, SQL.Aliased) && chunk.fieldAlias !== undefined) {
|
|
768
|
-
return { sql: escapeName(chunk.fieldAlias), params: [] };
|
|
769
|
-
}
|
|
770
|
-
if (is(chunk, Subquery)) {
|
|
771
|
-
if (chunk._.isWith) {
|
|
772
|
-
return { sql: escapeName(chunk._.alias), params: [] };
|
|
773
|
-
}
|
|
774
|
-
return this.buildQueryFromSourceParams([
|
|
775
|
-
new StringChunk("("),
|
|
776
|
-
chunk._.sql,
|
|
777
|
-
new StringChunk(") "),
|
|
778
|
-
new Name(chunk._.alias)
|
|
779
|
-
], config);
|
|
780
|
-
}
|
|
781
|
-
if (isPgEnum(chunk)) {
|
|
782
|
-
if (chunk.schema) {
|
|
783
|
-
return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
|
|
784
|
-
}
|
|
785
|
-
return { sql: escapeName(chunk.enumName), params: [] };
|
|
786
|
-
}
|
|
787
|
-
if (isSQLWrapper(chunk)) {
|
|
788
|
-
if (chunk.shouldOmitSQLParens?.()) {
|
|
789
|
-
return this.buildQueryFromSourceParams([chunk.getSQL()], config);
|
|
790
|
-
}
|
|
791
|
-
return this.buildQueryFromSourceParams([
|
|
792
|
-
new StringChunk("("),
|
|
793
|
-
chunk.getSQL(),
|
|
794
|
-
new StringChunk(")")
|
|
795
|
-
], config);
|
|
796
|
-
}
|
|
797
|
-
if (inlineParams) {
|
|
798
|
-
return { sql: this.mapInlineParam(chunk, config), params: [] };
|
|
799
|
-
}
|
|
800
|
-
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
801
|
-
}));
|
|
802
|
-
}
|
|
803
|
-
mapInlineParam(chunk, { escapeString }) {
|
|
804
|
-
if (chunk === null) {
|
|
805
|
-
return "null";
|
|
806
|
-
}
|
|
807
|
-
if (typeof chunk === "number" || typeof chunk === "boolean") {
|
|
808
|
-
return chunk.toString();
|
|
809
|
-
}
|
|
810
|
-
if (typeof chunk === "string") {
|
|
811
|
-
return escapeString(chunk);
|
|
812
|
-
}
|
|
813
|
-
if (typeof chunk === "object") {
|
|
814
|
-
const mappedValueAsString = chunk.toString();
|
|
815
|
-
if (mappedValueAsString === "[object Object]") {
|
|
816
|
-
return escapeString(JSON.stringify(chunk));
|
|
817
|
-
}
|
|
818
|
-
return escapeString(mappedValueAsString);
|
|
819
|
-
}
|
|
820
|
-
throw new Error("Unexpected param value: " + chunk);
|
|
821
|
-
}
|
|
822
|
-
getSQL() {
|
|
823
|
-
return this;
|
|
824
|
-
}
|
|
825
|
-
as(alias) {
|
|
826
|
-
if (alias === undefined) {
|
|
827
|
-
return this;
|
|
828
|
-
}
|
|
829
|
-
return new SQL.Aliased(this, alias);
|
|
830
|
-
}
|
|
831
|
-
mapWith(decoder) {
|
|
832
|
-
this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
|
|
833
|
-
return this;
|
|
834
|
-
}
|
|
835
|
-
inlineParams() {
|
|
836
|
-
this.shouldInlineParams = true;
|
|
837
|
-
return this;
|
|
838
|
-
}
|
|
839
|
-
if(condition) {
|
|
840
|
-
return condition ? this : undefined;
|
|
841
|
-
}
|
|
842
|
-
};
|
|
843
|
-
Name = class Name {
|
|
844
|
-
constructor(value) {
|
|
845
|
-
this.value = value;
|
|
846
|
-
}
|
|
847
|
-
static [entityKind] = "Name";
|
|
848
|
-
brand;
|
|
849
|
-
getSQL() {
|
|
850
|
-
return new SQL([this]);
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
noopDecoder = {
|
|
854
|
-
mapFromDriverValue: (value) => value
|
|
855
|
-
};
|
|
856
|
-
noopEncoder = {
|
|
857
|
-
mapToDriverValue: (value) => value
|
|
858
|
-
};
|
|
859
|
-
noopMapper = {
|
|
860
|
-
...noopDecoder,
|
|
861
|
-
...noopEncoder
|
|
862
|
-
};
|
|
863
|
-
Param = class Param {
|
|
864
|
-
constructor(value, encoder = noopEncoder) {
|
|
865
|
-
this.value = value;
|
|
866
|
-
this.encoder = encoder;
|
|
867
|
-
}
|
|
868
|
-
static [entityKind] = "Param";
|
|
869
|
-
brand;
|
|
870
|
-
getSQL() {
|
|
871
|
-
return new SQL([this]);
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
((sql2) => {
|
|
875
|
-
function empty() {
|
|
876
|
-
return new SQL([]);
|
|
877
|
-
}
|
|
878
|
-
sql2.empty = empty;
|
|
879
|
-
function fromList(list) {
|
|
880
|
-
return new SQL(list);
|
|
881
|
-
}
|
|
882
|
-
sql2.fromList = fromList;
|
|
883
|
-
function raw(str) {
|
|
884
|
-
return new SQL([new StringChunk(str)]);
|
|
885
|
-
}
|
|
886
|
-
sql2.raw = raw;
|
|
887
|
-
function join(chunks, separator) {
|
|
888
|
-
const result = [];
|
|
889
|
-
for (const [i, chunk] of chunks.entries()) {
|
|
890
|
-
if (i > 0 && separator !== undefined) {
|
|
891
|
-
result.push(separator);
|
|
892
|
-
}
|
|
893
|
-
result.push(chunk);
|
|
894
|
-
}
|
|
895
|
-
return new SQL(result);
|
|
896
|
-
}
|
|
897
|
-
sql2.join = join;
|
|
898
|
-
function identifier(value) {
|
|
899
|
-
return new Name(value);
|
|
900
|
-
}
|
|
901
|
-
sql2.identifier = identifier;
|
|
902
|
-
function placeholder2(name2) {
|
|
903
|
-
return new Placeholder(name2);
|
|
904
|
-
}
|
|
905
|
-
sql2.placeholder = placeholder2;
|
|
906
|
-
function param2(value, encoder) {
|
|
907
|
-
return new Param(value, encoder);
|
|
908
|
-
}
|
|
909
|
-
sql2.param = param2;
|
|
910
|
-
})(sql || (sql = {}));
|
|
911
|
-
((SQL2) => {
|
|
912
|
-
|
|
913
|
-
class Aliased {
|
|
914
|
-
constructor(sql2, fieldAlias) {
|
|
915
|
-
this.sql = sql2;
|
|
916
|
-
this.fieldAlias = fieldAlias;
|
|
917
|
-
}
|
|
918
|
-
static [entityKind] = "SQL.Aliased";
|
|
919
|
-
isSelectionField = false;
|
|
920
|
-
getSQL() {
|
|
921
|
-
return this.sql;
|
|
922
|
-
}
|
|
923
|
-
clone() {
|
|
924
|
-
return new Aliased(this.sql, this.fieldAlias);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
SQL2.Aliased = Aliased;
|
|
928
|
-
})(SQL || (SQL = {}));
|
|
929
|
-
Placeholder = class Placeholder {
|
|
930
|
-
constructor(name2) {
|
|
931
|
-
this.name = name2;
|
|
932
|
-
}
|
|
933
|
-
static [entityKind] = "Placeholder";
|
|
934
|
-
getSQL() {
|
|
935
|
-
return new SQL([this]);
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
|
|
939
|
-
View = class View {
|
|
940
|
-
static [entityKind] = "View";
|
|
941
|
-
[ViewBaseConfig];
|
|
942
|
-
[IsDrizzleView] = true;
|
|
943
|
-
constructor({ name: name2, schema, selectedFields, query }) {
|
|
944
|
-
this[ViewBaseConfig] = {
|
|
945
|
-
name: name2,
|
|
946
|
-
originalName: name2,
|
|
947
|
-
schema,
|
|
948
|
-
selectedFields,
|
|
949
|
-
query,
|
|
950
|
-
isExisting: !query,
|
|
951
|
-
isAlias: false
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
getSQL() {
|
|
955
|
-
return new SQL([this]);
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
Column.prototype.getSQL = function() {
|
|
959
|
-
return new SQL([this]);
|
|
960
|
-
};
|
|
961
|
-
Table.prototype.getSQL = function() {
|
|
962
|
-
return new SQL([this]);
|
|
963
|
-
};
|
|
964
|
-
Subquery.prototype.getSQL = function() {
|
|
965
|
-
return new SQL([this]);
|
|
966
|
-
};
|
|
967
|
-
});
|
|
968
|
-
|
|
969
|
-
// ../../../node_modules/drizzle-orm/alias.js
|
|
970
|
-
var ColumnAliasProxyHandler, TableAliasProxyHandler;
|
|
971
|
-
var init_alias = __esm(() => {
|
|
972
|
-
init_column();
|
|
973
|
-
init_entity();
|
|
974
|
-
init_table();
|
|
975
|
-
init_view_common();
|
|
976
|
-
ColumnAliasProxyHandler = class ColumnAliasProxyHandler {
|
|
977
|
-
constructor(table) {
|
|
978
|
-
this.table = table;
|
|
979
|
-
}
|
|
980
|
-
static [entityKind] = "ColumnAliasProxyHandler";
|
|
981
|
-
get(columnObj, prop) {
|
|
982
|
-
if (prop === "table") {
|
|
983
|
-
return this.table;
|
|
984
|
-
}
|
|
985
|
-
return columnObj[prop];
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
TableAliasProxyHandler = class TableAliasProxyHandler {
|
|
989
|
-
constructor(alias, replaceOriginalName) {
|
|
990
|
-
this.alias = alias;
|
|
991
|
-
this.replaceOriginalName = replaceOriginalName;
|
|
992
|
-
}
|
|
993
|
-
static [entityKind] = "TableAliasProxyHandler";
|
|
994
|
-
get(target, prop) {
|
|
995
|
-
if (prop === Table.Symbol.IsAlias) {
|
|
996
|
-
return true;
|
|
997
|
-
}
|
|
998
|
-
if (prop === Table.Symbol.Name) {
|
|
999
|
-
return this.alias;
|
|
1000
|
-
}
|
|
1001
|
-
if (this.replaceOriginalName && prop === Table.Symbol.OriginalName) {
|
|
1002
|
-
return this.alias;
|
|
1003
|
-
}
|
|
1004
|
-
if (prop === ViewBaseConfig) {
|
|
1005
|
-
return {
|
|
1006
|
-
...target[ViewBaseConfig],
|
|
1007
|
-
name: this.alias,
|
|
1008
|
-
isAlias: true
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
if (prop === Table.Symbol.Columns) {
|
|
1012
|
-
const columns = target[Table.Symbol.Columns];
|
|
1013
|
-
if (!columns) {
|
|
1014
|
-
return columns;
|
|
1015
|
-
}
|
|
1016
|
-
const proxiedColumns = {};
|
|
1017
|
-
Object.keys(columns).map((key) => {
|
|
1018
|
-
proxiedColumns[key] = new Proxy(columns[key], new ColumnAliasProxyHandler(new Proxy(target, this)));
|
|
1019
|
-
});
|
|
1020
|
-
return proxiedColumns;
|
|
1021
|
-
}
|
|
1022
|
-
const value = target[prop];
|
|
1023
|
-
if (is(value, Column)) {
|
|
1024
|
-
return new Proxy(value, new ColumnAliasProxyHandler(new Proxy(target, this)));
|
|
1025
|
-
}
|
|
1026
|
-
return value;
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
// ../../../node_modules/drizzle-orm/errors.js
|
|
1032
|
-
var init_errors = () => {};
|
|
1033
|
-
|
|
1034
|
-
// ../../../node_modules/drizzle-orm/logger.js
|
|
1035
|
-
var init_logger = () => {};
|
|
1036
|
-
|
|
1037
|
-
// ../../../node_modules/drizzle-orm/query-promise.js
|
|
1038
|
-
var QueryPromise;
|
|
1039
|
-
var init_query_promise = __esm(() => {
|
|
1040
|
-
init_entity();
|
|
1041
|
-
QueryPromise = class QueryPromise {
|
|
1042
|
-
static [entityKind] = "QueryPromise";
|
|
1043
|
-
[Symbol.toStringTag] = "QueryPromise";
|
|
1044
|
-
catch(onRejected) {
|
|
1045
|
-
return this.then(undefined, onRejected);
|
|
1046
|
-
}
|
|
1047
|
-
finally(onFinally) {
|
|
1048
|
-
return this.then((value) => {
|
|
1049
|
-
onFinally?.();
|
|
1050
|
-
return value;
|
|
1051
|
-
}, (reason) => {
|
|
1052
|
-
onFinally?.();
|
|
1053
|
-
throw reason;
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
then(onFulfilled, onRejected) {
|
|
1057
|
-
return this.execute().then(onFulfilled, onRejected);
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
});
|
|
1061
|
-
|
|
1062
|
-
// ../../../node_modules/drizzle-orm/utils.js
|
|
1063
|
-
function orderSelectedFields(fields, pathPrefix) {
|
|
1064
|
-
return Object.entries(fields).reduce((result, [name, field]) => {
|
|
1065
|
-
if (typeof name !== "string") {
|
|
1066
|
-
return result;
|
|
1067
|
-
}
|
|
1068
|
-
const newPath = pathPrefix ? [...pathPrefix, name] : [name];
|
|
1069
|
-
if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery)) {
|
|
1070
|
-
result.push({ path: newPath, field });
|
|
1071
|
-
} else if (is(field, Table)) {
|
|
1072
|
-
result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));
|
|
1073
|
-
} else {
|
|
1074
|
-
result.push(...orderSelectedFields(field, newPath));
|
|
1075
|
-
}
|
|
1076
|
-
return result;
|
|
1077
|
-
}, []);
|
|
1078
|
-
}
|
|
1079
|
-
function haveSameKeys(left, right) {
|
|
1080
|
-
const leftKeys = Object.keys(left);
|
|
1081
|
-
const rightKeys = Object.keys(right);
|
|
1082
|
-
if (leftKeys.length !== rightKeys.length) {
|
|
1083
|
-
return false;
|
|
1084
|
-
}
|
|
1085
|
-
for (const [index, key] of leftKeys.entries()) {
|
|
1086
|
-
if (key !== rightKeys[index]) {
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
return true;
|
|
1091
|
-
}
|
|
1092
|
-
function applyMixins(baseClass, extendedClasses) {
|
|
1093
|
-
for (const extendedClass of extendedClasses) {
|
|
1094
|
-
for (const name of Object.getOwnPropertyNames(extendedClass.prototype)) {
|
|
1095
|
-
if (name === "constructor")
|
|
1096
|
-
continue;
|
|
1097
|
-
Object.defineProperty(baseClass.prototype, name, Object.getOwnPropertyDescriptor(extendedClass.prototype, name) || /* @__PURE__ */ Object.create(null));
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
function getTableLikeName(table) {
|
|
1102
|
-
return is(table, Subquery) ? table._.alias : is(table, View) ? table[ViewBaseConfig].name : is(table, SQL) ? undefined : table[Table.Symbol.IsAlias] ? table[Table.Symbol.Name] : table[Table.Symbol.BaseName];
|
|
1103
|
-
}
|
|
1104
|
-
function getColumnNameAndConfig(a, b) {
|
|
1105
|
-
return {
|
|
1106
|
-
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
1107
|
-
config: typeof a === "object" ? a : b
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
var textDecoder;
|
|
1111
|
-
var init_utils = __esm(() => {
|
|
1112
|
-
init_column();
|
|
1113
|
-
init_entity();
|
|
1114
|
-
init_sql();
|
|
1115
|
-
init_subquery();
|
|
1116
|
-
init_table();
|
|
1117
|
-
init_view_common();
|
|
1118
|
-
textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
|
|
1119
|
-
});
|
|
1120
|
-
|
|
1121
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/int.common.js
|
|
1122
|
-
var PgIntColumnBaseBuilder;
|
|
1123
|
-
var init_int_common = __esm(() => {
|
|
1124
|
-
init_entity();
|
|
1125
|
-
init_common();
|
|
1126
|
-
PgIntColumnBaseBuilder = class PgIntColumnBaseBuilder extends PgColumnBuilder {
|
|
1127
|
-
static [entityKind] = "PgIntColumnBaseBuilder";
|
|
1128
|
-
generatedAlwaysAsIdentity(sequence) {
|
|
1129
|
-
if (sequence) {
|
|
1130
|
-
const { name, ...options } = sequence;
|
|
1131
|
-
this.config.generatedIdentity = {
|
|
1132
|
-
type: "always",
|
|
1133
|
-
sequenceName: name,
|
|
1134
|
-
sequenceOptions: options
|
|
1135
|
-
};
|
|
1136
|
-
} else {
|
|
1137
|
-
this.config.generatedIdentity = {
|
|
1138
|
-
type: "always"
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
this.config.hasDefault = true;
|
|
1142
|
-
this.config.notNull = true;
|
|
1143
|
-
return this;
|
|
1144
|
-
}
|
|
1145
|
-
generatedByDefaultAsIdentity(sequence) {
|
|
1146
|
-
if (sequence) {
|
|
1147
|
-
const { name, ...options } = sequence;
|
|
1148
|
-
this.config.generatedIdentity = {
|
|
1149
|
-
type: "byDefault",
|
|
1150
|
-
sequenceName: name,
|
|
1151
|
-
sequenceOptions: options
|
|
1152
|
-
};
|
|
1153
|
-
} else {
|
|
1154
|
-
this.config.generatedIdentity = {
|
|
1155
|
-
type: "byDefault"
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
this.config.hasDefault = true;
|
|
1159
|
-
this.config.notNull = true;
|
|
1160
|
-
return this;
|
|
1161
|
-
}
|
|
1162
|
-
};
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/bigint.js
|
|
1166
|
-
function bigint(a, b) {
|
|
1167
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1168
|
-
if (config.mode === "number") {
|
|
1169
|
-
return new PgBigInt53Builder(name);
|
|
1170
|
-
}
|
|
1171
|
-
return new PgBigInt64Builder(name);
|
|
1172
|
-
}
|
|
1173
|
-
var PgBigInt53Builder, PgBigInt53, PgBigInt64Builder, PgBigInt64;
|
|
1174
|
-
var init_bigint = __esm(() => {
|
|
1175
|
-
init_entity();
|
|
1176
|
-
init_utils();
|
|
1177
|
-
init_common();
|
|
1178
|
-
init_int_common();
|
|
1179
|
-
PgBigInt53Builder = class PgBigInt53Builder extends PgIntColumnBaseBuilder {
|
|
1180
|
-
static [entityKind] = "PgBigInt53Builder";
|
|
1181
|
-
constructor(name) {
|
|
1182
|
-
super(name, "number", "PgBigInt53");
|
|
1183
|
-
}
|
|
1184
|
-
build(table) {
|
|
1185
|
-
return new PgBigInt53(table, this.config);
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
PgBigInt53 = class PgBigInt53 extends PgColumn {
|
|
1189
|
-
static [entityKind] = "PgBigInt53";
|
|
1190
|
-
getSQLType() {
|
|
1191
|
-
return "bigint";
|
|
1192
|
-
}
|
|
1193
|
-
mapFromDriverValue(value) {
|
|
1194
|
-
if (typeof value === "number") {
|
|
1195
|
-
return value;
|
|
1196
|
-
}
|
|
1197
|
-
return Number(value);
|
|
1198
|
-
}
|
|
1199
|
-
};
|
|
1200
|
-
PgBigInt64Builder = class PgBigInt64Builder extends PgIntColumnBaseBuilder {
|
|
1201
|
-
static [entityKind] = "PgBigInt64Builder";
|
|
1202
|
-
constructor(name) {
|
|
1203
|
-
super(name, "bigint", "PgBigInt64");
|
|
1204
|
-
}
|
|
1205
|
-
build(table) {
|
|
1206
|
-
return new PgBigInt64(table, this.config);
|
|
1207
|
-
}
|
|
1208
|
-
};
|
|
1209
|
-
PgBigInt64 = class PgBigInt64 extends PgColumn {
|
|
1210
|
-
static [entityKind] = "PgBigInt64";
|
|
1211
|
-
getSQLType() {
|
|
1212
|
-
return "bigint";
|
|
1213
|
-
}
|
|
1214
|
-
mapFromDriverValue(value) {
|
|
1215
|
-
return BigInt(value);
|
|
1216
|
-
}
|
|
1217
|
-
};
|
|
1218
|
-
});
|
|
1219
|
-
|
|
1220
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/bigserial.js
|
|
1221
|
-
function bigserial(a, b) {
|
|
1222
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1223
|
-
if (config.mode === "number") {
|
|
1224
|
-
return new PgBigSerial53Builder(name);
|
|
1225
|
-
}
|
|
1226
|
-
return new PgBigSerial64Builder(name);
|
|
1227
|
-
}
|
|
1228
|
-
var PgBigSerial53Builder, PgBigSerial53, PgBigSerial64Builder, PgBigSerial64;
|
|
1229
|
-
var init_bigserial = __esm(() => {
|
|
1230
|
-
init_entity();
|
|
1231
|
-
init_utils();
|
|
1232
|
-
init_common();
|
|
1233
|
-
PgBigSerial53Builder = class PgBigSerial53Builder extends PgColumnBuilder {
|
|
1234
|
-
static [entityKind] = "PgBigSerial53Builder";
|
|
1235
|
-
constructor(name) {
|
|
1236
|
-
super(name, "number", "PgBigSerial53");
|
|
1237
|
-
this.config.hasDefault = true;
|
|
1238
|
-
this.config.notNull = true;
|
|
1239
|
-
}
|
|
1240
|
-
build(table) {
|
|
1241
|
-
return new PgBigSerial53(table, this.config);
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
PgBigSerial53 = class PgBigSerial53 extends PgColumn {
|
|
1245
|
-
static [entityKind] = "PgBigSerial53";
|
|
1246
|
-
getSQLType() {
|
|
1247
|
-
return "bigserial";
|
|
1248
|
-
}
|
|
1249
|
-
mapFromDriverValue(value) {
|
|
1250
|
-
if (typeof value === "number") {
|
|
1251
|
-
return value;
|
|
1252
|
-
}
|
|
1253
|
-
return Number(value);
|
|
1254
|
-
}
|
|
1255
|
-
};
|
|
1256
|
-
PgBigSerial64Builder = class PgBigSerial64Builder extends PgColumnBuilder {
|
|
1257
|
-
static [entityKind] = "PgBigSerial64Builder";
|
|
1258
|
-
constructor(name) {
|
|
1259
|
-
super(name, "bigint", "PgBigSerial64");
|
|
1260
|
-
this.config.hasDefault = true;
|
|
1261
|
-
}
|
|
1262
|
-
build(table) {
|
|
1263
|
-
return new PgBigSerial64(table, this.config);
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
PgBigSerial64 = class PgBigSerial64 extends PgColumn {
|
|
1267
|
-
static [entityKind] = "PgBigSerial64";
|
|
1268
|
-
getSQLType() {
|
|
1269
|
-
return "bigserial";
|
|
1270
|
-
}
|
|
1271
|
-
mapFromDriverValue(value) {
|
|
1272
|
-
return BigInt(value);
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
});
|
|
1276
|
-
|
|
1277
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/boolean.js
|
|
1278
|
-
function boolean(name) {
|
|
1279
|
-
return new PgBooleanBuilder(name ?? "");
|
|
1280
|
-
}
|
|
1281
|
-
var PgBooleanBuilder, PgBoolean;
|
|
1282
|
-
var init_boolean = __esm(() => {
|
|
1283
|
-
init_entity();
|
|
1284
|
-
init_common();
|
|
1285
|
-
PgBooleanBuilder = class PgBooleanBuilder extends PgColumnBuilder {
|
|
1286
|
-
static [entityKind] = "PgBooleanBuilder";
|
|
1287
|
-
constructor(name) {
|
|
1288
|
-
super(name, "boolean", "PgBoolean");
|
|
1289
|
-
}
|
|
1290
|
-
build(table) {
|
|
1291
|
-
return new PgBoolean(table, this.config);
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
PgBoolean = class PgBoolean extends PgColumn {
|
|
1295
|
-
static [entityKind] = "PgBoolean";
|
|
1296
|
-
getSQLType() {
|
|
1297
|
-
return "boolean";
|
|
1298
|
-
}
|
|
1299
|
-
};
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/char.js
|
|
1303
|
-
function char(a, b = {}) {
|
|
1304
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1305
|
-
return new PgCharBuilder(name, config);
|
|
1306
|
-
}
|
|
1307
|
-
var PgCharBuilder, PgChar;
|
|
1308
|
-
var init_char = __esm(() => {
|
|
1309
|
-
init_entity();
|
|
1310
|
-
init_utils();
|
|
1311
|
-
init_common();
|
|
1312
|
-
PgCharBuilder = class PgCharBuilder extends PgColumnBuilder {
|
|
1313
|
-
static [entityKind] = "PgCharBuilder";
|
|
1314
|
-
constructor(name, config) {
|
|
1315
|
-
super(name, "string", "PgChar");
|
|
1316
|
-
this.config.length = config.length;
|
|
1317
|
-
this.config.enumValues = config.enum;
|
|
1318
|
-
}
|
|
1319
|
-
build(table) {
|
|
1320
|
-
return new PgChar(table, this.config);
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
PgChar = class PgChar extends PgColumn {
|
|
1324
|
-
static [entityKind] = "PgChar";
|
|
1325
|
-
length = this.config.length;
|
|
1326
|
-
enumValues = this.config.enumValues;
|
|
1327
|
-
getSQLType() {
|
|
1328
|
-
return this.length === undefined ? `char` : `char(${this.length})`;
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
});
|
|
1332
|
-
|
|
1333
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/cidr.js
|
|
1334
|
-
function cidr(name) {
|
|
1335
|
-
return new PgCidrBuilder(name ?? "");
|
|
1336
|
-
}
|
|
1337
|
-
var PgCidrBuilder, PgCidr;
|
|
1338
|
-
var init_cidr = __esm(() => {
|
|
1339
|
-
init_entity();
|
|
1340
|
-
init_common();
|
|
1341
|
-
PgCidrBuilder = class PgCidrBuilder extends PgColumnBuilder {
|
|
1342
|
-
static [entityKind] = "PgCidrBuilder";
|
|
1343
|
-
constructor(name) {
|
|
1344
|
-
super(name, "string", "PgCidr");
|
|
1345
|
-
}
|
|
1346
|
-
build(table) {
|
|
1347
|
-
return new PgCidr(table, this.config);
|
|
1348
|
-
}
|
|
1349
|
-
};
|
|
1350
|
-
PgCidr = class PgCidr extends PgColumn {
|
|
1351
|
-
static [entityKind] = "PgCidr";
|
|
1352
|
-
getSQLType() {
|
|
1353
|
-
return "cidr";
|
|
1354
|
-
}
|
|
1355
|
-
};
|
|
1356
|
-
});
|
|
1357
|
-
|
|
1358
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/custom.js
|
|
1359
|
-
function customType(customTypeParams) {
|
|
1360
|
-
return (a, b) => {
|
|
1361
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1362
|
-
return new PgCustomColumnBuilder(name, config, customTypeParams);
|
|
1363
|
-
};
|
|
1364
|
-
}
|
|
1365
|
-
var PgCustomColumnBuilder, PgCustomColumn;
|
|
1366
|
-
var init_custom = __esm(() => {
|
|
1367
|
-
init_entity();
|
|
1368
|
-
init_utils();
|
|
1369
|
-
init_common();
|
|
1370
|
-
PgCustomColumnBuilder = class PgCustomColumnBuilder extends PgColumnBuilder {
|
|
1371
|
-
static [entityKind] = "PgCustomColumnBuilder";
|
|
1372
|
-
constructor(name, fieldConfig, customTypeParams) {
|
|
1373
|
-
super(name, "custom", "PgCustomColumn");
|
|
1374
|
-
this.config.fieldConfig = fieldConfig;
|
|
1375
|
-
this.config.customTypeParams = customTypeParams;
|
|
1376
|
-
}
|
|
1377
|
-
build(table) {
|
|
1378
|
-
return new PgCustomColumn(table, this.config);
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
PgCustomColumn = class PgCustomColumn extends PgColumn {
|
|
1382
|
-
static [entityKind] = "PgCustomColumn";
|
|
1383
|
-
sqlName;
|
|
1384
|
-
mapTo;
|
|
1385
|
-
mapFrom;
|
|
1386
|
-
constructor(table, config) {
|
|
1387
|
-
super(table, config);
|
|
1388
|
-
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
1389
|
-
this.mapTo = config.customTypeParams.toDriver;
|
|
1390
|
-
this.mapFrom = config.customTypeParams.fromDriver;
|
|
1391
|
-
}
|
|
1392
|
-
getSQLType() {
|
|
1393
|
-
return this.sqlName;
|
|
1394
|
-
}
|
|
1395
|
-
mapFromDriverValue(value) {
|
|
1396
|
-
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
1397
|
-
}
|
|
1398
|
-
mapToDriverValue(value) {
|
|
1399
|
-
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
1400
|
-
}
|
|
1401
|
-
};
|
|
1402
|
-
});
|
|
1403
|
-
|
|
1404
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/date.common.js
|
|
1405
|
-
var PgDateColumnBaseBuilder;
|
|
1406
|
-
var init_date_common = __esm(() => {
|
|
1407
|
-
init_entity();
|
|
1408
|
-
init_sql();
|
|
1409
|
-
init_common();
|
|
1410
|
-
PgDateColumnBaseBuilder = class PgDateColumnBaseBuilder extends PgColumnBuilder {
|
|
1411
|
-
static [entityKind] = "PgDateColumnBaseBuilder";
|
|
1412
|
-
defaultNow() {
|
|
1413
|
-
return this.default(sql`now()`);
|
|
1414
|
-
}
|
|
1415
|
-
};
|
|
1416
|
-
});
|
|
1417
|
-
|
|
1418
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/date.js
|
|
1419
|
-
function date(a, b) {
|
|
1420
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1421
|
-
if (config?.mode === "date") {
|
|
1422
|
-
return new PgDateBuilder(name);
|
|
1423
|
-
}
|
|
1424
|
-
return new PgDateStringBuilder(name);
|
|
1425
|
-
}
|
|
1426
|
-
var PgDateBuilder, PgDate, PgDateStringBuilder, PgDateString;
|
|
1427
|
-
var init_date = __esm(() => {
|
|
1428
|
-
init_entity();
|
|
1429
|
-
init_utils();
|
|
1430
|
-
init_common();
|
|
1431
|
-
init_date_common();
|
|
1432
|
-
PgDateBuilder = class PgDateBuilder extends PgDateColumnBaseBuilder {
|
|
1433
|
-
static [entityKind] = "PgDateBuilder";
|
|
1434
|
-
constructor(name) {
|
|
1435
|
-
super(name, "date", "PgDate");
|
|
1436
|
-
}
|
|
1437
|
-
build(table) {
|
|
1438
|
-
return new PgDate(table, this.config);
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
PgDate = class PgDate extends PgColumn {
|
|
1442
|
-
static [entityKind] = "PgDate";
|
|
1443
|
-
getSQLType() {
|
|
1444
|
-
return "date";
|
|
1445
|
-
}
|
|
1446
|
-
mapFromDriverValue(value) {
|
|
1447
|
-
if (typeof value === "string")
|
|
1448
|
-
return new Date(value);
|
|
1449
|
-
return value;
|
|
1450
|
-
}
|
|
1451
|
-
mapToDriverValue(value) {
|
|
1452
|
-
return value.toISOString();
|
|
1453
|
-
}
|
|
1454
|
-
};
|
|
1455
|
-
PgDateStringBuilder = class PgDateStringBuilder extends PgDateColumnBaseBuilder {
|
|
1456
|
-
static [entityKind] = "PgDateStringBuilder";
|
|
1457
|
-
constructor(name) {
|
|
1458
|
-
super(name, "string", "PgDateString");
|
|
1459
|
-
}
|
|
1460
|
-
build(table) {
|
|
1461
|
-
return new PgDateString(table, this.config);
|
|
1462
|
-
}
|
|
1463
|
-
};
|
|
1464
|
-
PgDateString = class PgDateString extends PgColumn {
|
|
1465
|
-
static [entityKind] = "PgDateString";
|
|
1466
|
-
getSQLType() {
|
|
1467
|
-
return "date";
|
|
1468
|
-
}
|
|
1469
|
-
mapFromDriverValue(value) {
|
|
1470
|
-
if (typeof value === "string")
|
|
1471
|
-
return value;
|
|
1472
|
-
return value.toISOString().slice(0, -14);
|
|
1473
|
-
}
|
|
1474
|
-
};
|
|
1475
|
-
});
|
|
1476
|
-
|
|
1477
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/double-precision.js
|
|
1478
|
-
function doublePrecision(name) {
|
|
1479
|
-
return new PgDoublePrecisionBuilder(name ?? "");
|
|
1480
|
-
}
|
|
1481
|
-
var PgDoublePrecisionBuilder, PgDoublePrecision;
|
|
1482
|
-
var init_double_precision = __esm(() => {
|
|
1483
|
-
init_entity();
|
|
1484
|
-
init_common();
|
|
1485
|
-
PgDoublePrecisionBuilder = class PgDoublePrecisionBuilder extends PgColumnBuilder {
|
|
1486
|
-
static [entityKind] = "PgDoublePrecisionBuilder";
|
|
1487
|
-
constructor(name) {
|
|
1488
|
-
super(name, "number", "PgDoublePrecision");
|
|
1489
|
-
}
|
|
1490
|
-
build(table) {
|
|
1491
|
-
return new PgDoublePrecision(table, this.config);
|
|
1492
|
-
}
|
|
1493
|
-
};
|
|
1494
|
-
PgDoublePrecision = class PgDoublePrecision extends PgColumn {
|
|
1495
|
-
static [entityKind] = "PgDoublePrecision";
|
|
1496
|
-
getSQLType() {
|
|
1497
|
-
return "double precision";
|
|
1498
|
-
}
|
|
1499
|
-
mapFromDriverValue(value) {
|
|
1500
|
-
if (typeof value === "string") {
|
|
1501
|
-
return Number.parseFloat(value);
|
|
1502
|
-
}
|
|
1503
|
-
return value;
|
|
1504
|
-
}
|
|
1505
|
-
};
|
|
1506
|
-
});
|
|
1507
|
-
|
|
1508
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/inet.js
|
|
1509
|
-
function inet(name) {
|
|
1510
|
-
return new PgInetBuilder(name ?? "");
|
|
1511
|
-
}
|
|
1512
|
-
var PgInetBuilder, PgInet;
|
|
1513
|
-
var init_inet = __esm(() => {
|
|
1514
|
-
init_entity();
|
|
1515
|
-
init_common();
|
|
1516
|
-
PgInetBuilder = class PgInetBuilder extends PgColumnBuilder {
|
|
1517
|
-
static [entityKind] = "PgInetBuilder";
|
|
1518
|
-
constructor(name) {
|
|
1519
|
-
super(name, "string", "PgInet");
|
|
1520
|
-
}
|
|
1521
|
-
build(table) {
|
|
1522
|
-
return new PgInet(table, this.config);
|
|
1523
|
-
}
|
|
1524
|
-
};
|
|
1525
|
-
PgInet = class PgInet extends PgColumn {
|
|
1526
|
-
static [entityKind] = "PgInet";
|
|
1527
|
-
getSQLType() {
|
|
1528
|
-
return "inet";
|
|
1529
|
-
}
|
|
1530
|
-
};
|
|
1531
|
-
});
|
|
1532
|
-
|
|
1533
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/integer.js
|
|
1534
|
-
function integer(name) {
|
|
1535
|
-
return new PgIntegerBuilder(name ?? "");
|
|
1536
|
-
}
|
|
1537
|
-
var PgIntegerBuilder, PgInteger;
|
|
1538
|
-
var init_integer = __esm(() => {
|
|
1539
|
-
init_entity();
|
|
1540
|
-
init_common();
|
|
1541
|
-
init_int_common();
|
|
1542
|
-
PgIntegerBuilder = class PgIntegerBuilder extends PgIntColumnBaseBuilder {
|
|
1543
|
-
static [entityKind] = "PgIntegerBuilder";
|
|
1544
|
-
constructor(name) {
|
|
1545
|
-
super(name, "number", "PgInteger");
|
|
1546
|
-
}
|
|
1547
|
-
build(table) {
|
|
1548
|
-
return new PgInteger(table, this.config);
|
|
1549
|
-
}
|
|
1550
|
-
};
|
|
1551
|
-
PgInteger = class PgInteger extends PgColumn {
|
|
1552
|
-
static [entityKind] = "PgInteger";
|
|
1553
|
-
getSQLType() {
|
|
1554
|
-
return "integer";
|
|
1555
|
-
}
|
|
1556
|
-
mapFromDriverValue(value) {
|
|
1557
|
-
if (typeof value === "string") {
|
|
1558
|
-
return Number.parseInt(value);
|
|
1559
|
-
}
|
|
1560
|
-
return value;
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
});
|
|
1564
|
-
|
|
1565
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/interval.js
|
|
1566
|
-
function interval(a, b = {}) {
|
|
1567
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1568
|
-
return new PgIntervalBuilder(name, config);
|
|
1569
|
-
}
|
|
1570
|
-
var PgIntervalBuilder, PgInterval;
|
|
1571
|
-
var init_interval = __esm(() => {
|
|
1572
|
-
init_entity();
|
|
1573
|
-
init_utils();
|
|
1574
|
-
init_common();
|
|
1575
|
-
PgIntervalBuilder = class PgIntervalBuilder extends PgColumnBuilder {
|
|
1576
|
-
static [entityKind] = "PgIntervalBuilder";
|
|
1577
|
-
constructor(name, intervalConfig) {
|
|
1578
|
-
super(name, "string", "PgInterval");
|
|
1579
|
-
this.config.intervalConfig = intervalConfig;
|
|
1580
|
-
}
|
|
1581
|
-
build(table) {
|
|
1582
|
-
return new PgInterval(table, this.config);
|
|
1583
|
-
}
|
|
1584
|
-
};
|
|
1585
|
-
PgInterval = class PgInterval extends PgColumn {
|
|
1586
|
-
static [entityKind] = "PgInterval";
|
|
1587
|
-
fields = this.config.intervalConfig.fields;
|
|
1588
|
-
precision = this.config.intervalConfig.precision;
|
|
1589
|
-
getSQLType() {
|
|
1590
|
-
const fields = this.fields ? ` ${this.fields}` : "";
|
|
1591
|
-
const precision = this.precision ? `(${this.precision})` : "";
|
|
1592
|
-
return `interval${fields}${precision}`;
|
|
1593
|
-
}
|
|
1594
|
-
};
|
|
1595
|
-
});
|
|
1596
|
-
|
|
1597
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/json.js
|
|
1598
|
-
function json(name) {
|
|
1599
|
-
return new PgJsonBuilder(name ?? "");
|
|
1600
|
-
}
|
|
1601
|
-
var PgJsonBuilder, PgJson;
|
|
1602
|
-
var init_json = __esm(() => {
|
|
1603
|
-
init_entity();
|
|
1604
|
-
init_common();
|
|
1605
|
-
PgJsonBuilder = class PgJsonBuilder extends PgColumnBuilder {
|
|
1606
|
-
static [entityKind] = "PgJsonBuilder";
|
|
1607
|
-
constructor(name) {
|
|
1608
|
-
super(name, "json", "PgJson");
|
|
1609
|
-
}
|
|
1610
|
-
build(table) {
|
|
1611
|
-
return new PgJson(table, this.config);
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
PgJson = class PgJson extends PgColumn {
|
|
1615
|
-
static [entityKind] = "PgJson";
|
|
1616
|
-
constructor(table, config) {
|
|
1617
|
-
super(table, config);
|
|
1618
|
-
}
|
|
1619
|
-
getSQLType() {
|
|
1620
|
-
return "json";
|
|
1621
|
-
}
|
|
1622
|
-
mapToDriverValue(value) {
|
|
1623
|
-
return JSON.stringify(value);
|
|
1624
|
-
}
|
|
1625
|
-
mapFromDriverValue(value) {
|
|
1626
|
-
if (typeof value === "string") {
|
|
1627
|
-
try {
|
|
1628
|
-
return JSON.parse(value);
|
|
1629
|
-
} catch {
|
|
1630
|
-
return value;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
return value;
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
});
|
|
1637
|
-
|
|
1638
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/jsonb.js
|
|
1639
|
-
function jsonb(name) {
|
|
1640
|
-
return new PgJsonbBuilder(name ?? "");
|
|
1641
|
-
}
|
|
1642
|
-
var PgJsonbBuilder, PgJsonb;
|
|
1643
|
-
var init_jsonb = __esm(() => {
|
|
1644
|
-
init_entity();
|
|
1645
|
-
init_common();
|
|
1646
|
-
PgJsonbBuilder = class PgJsonbBuilder extends PgColumnBuilder {
|
|
1647
|
-
static [entityKind] = "PgJsonbBuilder";
|
|
1648
|
-
constructor(name) {
|
|
1649
|
-
super(name, "json", "PgJsonb");
|
|
1650
|
-
}
|
|
1651
|
-
build(table) {
|
|
1652
|
-
return new PgJsonb(table, this.config);
|
|
1653
|
-
}
|
|
1654
|
-
};
|
|
1655
|
-
PgJsonb = class PgJsonb extends PgColumn {
|
|
1656
|
-
static [entityKind] = "PgJsonb";
|
|
1657
|
-
constructor(table, config) {
|
|
1658
|
-
super(table, config);
|
|
1659
|
-
}
|
|
1660
|
-
getSQLType() {
|
|
1661
|
-
return "jsonb";
|
|
1662
|
-
}
|
|
1663
|
-
mapToDriverValue(value) {
|
|
1664
|
-
return JSON.stringify(value);
|
|
1665
|
-
}
|
|
1666
|
-
mapFromDriverValue(value) {
|
|
1667
|
-
if (typeof value === "string") {
|
|
1668
|
-
try {
|
|
1669
|
-
return JSON.parse(value);
|
|
1670
|
-
} catch {
|
|
1671
|
-
return value;
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
return value;
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
});
|
|
1678
|
-
|
|
1679
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/line.js
|
|
1680
|
-
function line(a, b) {
|
|
1681
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1682
|
-
if (!config?.mode || config.mode === "tuple") {
|
|
1683
|
-
return new PgLineBuilder(name);
|
|
1684
|
-
}
|
|
1685
|
-
return new PgLineABCBuilder(name);
|
|
1686
|
-
}
|
|
1687
|
-
var PgLineBuilder, PgLineTuple, PgLineABCBuilder, PgLineABC;
|
|
1688
|
-
var init_line = __esm(() => {
|
|
1689
|
-
init_entity();
|
|
1690
|
-
init_utils();
|
|
1691
|
-
init_common();
|
|
1692
|
-
PgLineBuilder = class PgLineBuilder extends PgColumnBuilder {
|
|
1693
|
-
static [entityKind] = "PgLineBuilder";
|
|
1694
|
-
constructor(name) {
|
|
1695
|
-
super(name, "array", "PgLine");
|
|
1696
|
-
}
|
|
1697
|
-
build(table) {
|
|
1698
|
-
return new PgLineTuple(table, this.config);
|
|
1699
|
-
}
|
|
1700
|
-
};
|
|
1701
|
-
PgLineTuple = class PgLineTuple extends PgColumn {
|
|
1702
|
-
static [entityKind] = "PgLine";
|
|
1703
|
-
getSQLType() {
|
|
1704
|
-
return "line";
|
|
1705
|
-
}
|
|
1706
|
-
mapFromDriverValue(value) {
|
|
1707
|
-
const [a, b, c] = value.slice(1, -1).split(",");
|
|
1708
|
-
return [Number.parseFloat(a), Number.parseFloat(b), Number.parseFloat(c)];
|
|
1709
|
-
}
|
|
1710
|
-
mapToDriverValue(value) {
|
|
1711
|
-
return `{${value[0]},${value[1]},${value[2]}}`;
|
|
1712
|
-
}
|
|
1713
|
-
};
|
|
1714
|
-
PgLineABCBuilder = class PgLineABCBuilder extends PgColumnBuilder {
|
|
1715
|
-
static [entityKind] = "PgLineABCBuilder";
|
|
1716
|
-
constructor(name) {
|
|
1717
|
-
super(name, "json", "PgLineABC");
|
|
1718
|
-
}
|
|
1719
|
-
build(table) {
|
|
1720
|
-
return new PgLineABC(table, this.config);
|
|
1721
|
-
}
|
|
1722
|
-
};
|
|
1723
|
-
PgLineABC = class PgLineABC extends PgColumn {
|
|
1724
|
-
static [entityKind] = "PgLineABC";
|
|
1725
|
-
getSQLType() {
|
|
1726
|
-
return "line";
|
|
1727
|
-
}
|
|
1728
|
-
mapFromDriverValue(value) {
|
|
1729
|
-
const [a, b, c] = value.slice(1, -1).split(",");
|
|
1730
|
-
return { a: Number.parseFloat(a), b: Number.parseFloat(b), c: Number.parseFloat(c) };
|
|
1731
|
-
}
|
|
1732
|
-
mapToDriverValue(value) {
|
|
1733
|
-
return `{${value.a},${value.b},${value.c}}`;
|
|
1734
|
-
}
|
|
1735
|
-
};
|
|
1736
|
-
});
|
|
1737
|
-
|
|
1738
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/macaddr.js
|
|
1739
|
-
function macaddr(name) {
|
|
1740
|
-
return new PgMacaddrBuilder(name ?? "");
|
|
1741
|
-
}
|
|
1742
|
-
var PgMacaddrBuilder, PgMacaddr;
|
|
1743
|
-
var init_macaddr = __esm(() => {
|
|
1744
|
-
init_entity();
|
|
1745
|
-
init_common();
|
|
1746
|
-
PgMacaddrBuilder = class PgMacaddrBuilder extends PgColumnBuilder {
|
|
1747
|
-
static [entityKind] = "PgMacaddrBuilder";
|
|
1748
|
-
constructor(name) {
|
|
1749
|
-
super(name, "string", "PgMacaddr");
|
|
1750
|
-
}
|
|
1751
|
-
build(table) {
|
|
1752
|
-
return new PgMacaddr(table, this.config);
|
|
1753
|
-
}
|
|
1754
|
-
};
|
|
1755
|
-
PgMacaddr = class PgMacaddr extends PgColumn {
|
|
1756
|
-
static [entityKind] = "PgMacaddr";
|
|
1757
|
-
getSQLType() {
|
|
1758
|
-
return "macaddr";
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1761
|
-
});
|
|
1762
|
-
|
|
1763
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/macaddr8.js
|
|
1764
|
-
function macaddr8(name) {
|
|
1765
|
-
return new PgMacaddr8Builder(name ?? "");
|
|
1766
|
-
}
|
|
1767
|
-
var PgMacaddr8Builder, PgMacaddr8;
|
|
1768
|
-
var init_macaddr8 = __esm(() => {
|
|
1769
|
-
init_entity();
|
|
1770
|
-
init_common();
|
|
1771
|
-
PgMacaddr8Builder = class PgMacaddr8Builder extends PgColumnBuilder {
|
|
1772
|
-
static [entityKind] = "PgMacaddr8Builder";
|
|
1773
|
-
constructor(name) {
|
|
1774
|
-
super(name, "string", "PgMacaddr8");
|
|
1775
|
-
}
|
|
1776
|
-
build(table) {
|
|
1777
|
-
return new PgMacaddr8(table, this.config);
|
|
1778
|
-
}
|
|
1779
|
-
};
|
|
1780
|
-
PgMacaddr8 = class PgMacaddr8 extends PgColumn {
|
|
1781
|
-
static [entityKind] = "PgMacaddr8";
|
|
1782
|
-
getSQLType() {
|
|
1783
|
-
return "macaddr8";
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
});
|
|
1787
|
-
|
|
1788
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/numeric.js
|
|
1789
|
-
function numeric(a, b) {
|
|
1790
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1791
|
-
const mode = config?.mode;
|
|
1792
|
-
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);
|
|
1793
|
-
}
|
|
1794
|
-
var PgNumericBuilder, PgNumeric, PgNumericNumberBuilder, PgNumericNumber, PgNumericBigIntBuilder, PgNumericBigInt;
|
|
1795
|
-
var init_numeric = __esm(() => {
|
|
1796
|
-
init_entity();
|
|
1797
|
-
init_utils();
|
|
1798
|
-
init_common();
|
|
1799
|
-
PgNumericBuilder = class PgNumericBuilder extends PgColumnBuilder {
|
|
1800
|
-
static [entityKind] = "PgNumericBuilder";
|
|
1801
|
-
constructor(name, precision, scale) {
|
|
1802
|
-
super(name, "string", "PgNumeric");
|
|
1803
|
-
this.config.precision = precision;
|
|
1804
|
-
this.config.scale = scale;
|
|
1805
|
-
}
|
|
1806
|
-
build(table) {
|
|
1807
|
-
return new PgNumeric(table, this.config);
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
PgNumeric = class PgNumeric extends PgColumn {
|
|
1811
|
-
static [entityKind] = "PgNumeric";
|
|
1812
|
-
precision;
|
|
1813
|
-
scale;
|
|
1814
|
-
constructor(table, config) {
|
|
1815
|
-
super(table, config);
|
|
1816
|
-
this.precision = config.precision;
|
|
1817
|
-
this.scale = config.scale;
|
|
1818
|
-
}
|
|
1819
|
-
mapFromDriverValue(value) {
|
|
1820
|
-
if (typeof value === "string")
|
|
1821
|
-
return value;
|
|
1822
|
-
return String(value);
|
|
1823
|
-
}
|
|
1824
|
-
getSQLType() {
|
|
1825
|
-
if (this.precision !== undefined && this.scale !== undefined) {
|
|
1826
|
-
return `numeric(${this.precision}, ${this.scale})`;
|
|
1827
|
-
} else if (this.precision === undefined) {
|
|
1828
|
-
return "numeric";
|
|
1829
|
-
} else {
|
|
1830
|
-
return `numeric(${this.precision})`;
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
};
|
|
1834
|
-
PgNumericNumberBuilder = class PgNumericNumberBuilder extends PgColumnBuilder {
|
|
1835
|
-
static [entityKind] = "PgNumericNumberBuilder";
|
|
1836
|
-
constructor(name, precision, scale) {
|
|
1837
|
-
super(name, "number", "PgNumericNumber");
|
|
1838
|
-
this.config.precision = precision;
|
|
1839
|
-
this.config.scale = scale;
|
|
1840
|
-
}
|
|
1841
|
-
build(table) {
|
|
1842
|
-
return new PgNumericNumber(table, this.config);
|
|
1843
|
-
}
|
|
1844
|
-
};
|
|
1845
|
-
PgNumericNumber = class PgNumericNumber extends PgColumn {
|
|
1846
|
-
static [entityKind] = "PgNumericNumber";
|
|
1847
|
-
precision;
|
|
1848
|
-
scale;
|
|
1849
|
-
constructor(table, config) {
|
|
1850
|
-
super(table, config);
|
|
1851
|
-
this.precision = config.precision;
|
|
1852
|
-
this.scale = config.scale;
|
|
1853
|
-
}
|
|
1854
|
-
mapFromDriverValue(value) {
|
|
1855
|
-
if (typeof value === "number")
|
|
1856
|
-
return value;
|
|
1857
|
-
return Number(value);
|
|
1858
|
-
}
|
|
1859
|
-
mapToDriverValue = String;
|
|
1860
|
-
getSQLType() {
|
|
1861
|
-
if (this.precision !== undefined && this.scale !== undefined) {
|
|
1862
|
-
return `numeric(${this.precision}, ${this.scale})`;
|
|
1863
|
-
} else if (this.precision === undefined) {
|
|
1864
|
-
return "numeric";
|
|
1865
|
-
} else {
|
|
1866
|
-
return `numeric(${this.precision})`;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
PgNumericBigIntBuilder = class PgNumericBigIntBuilder extends PgColumnBuilder {
|
|
1871
|
-
static [entityKind] = "PgNumericBigIntBuilder";
|
|
1872
|
-
constructor(name, precision, scale) {
|
|
1873
|
-
super(name, "bigint", "PgNumericBigInt");
|
|
1874
|
-
this.config.precision = precision;
|
|
1875
|
-
this.config.scale = scale;
|
|
1876
|
-
}
|
|
1877
|
-
build(table) {
|
|
1878
|
-
return new PgNumericBigInt(table, this.config);
|
|
1879
|
-
}
|
|
1880
|
-
};
|
|
1881
|
-
PgNumericBigInt = class PgNumericBigInt extends PgColumn {
|
|
1882
|
-
static [entityKind] = "PgNumericBigInt";
|
|
1883
|
-
precision;
|
|
1884
|
-
scale;
|
|
1885
|
-
constructor(table, config) {
|
|
1886
|
-
super(table, config);
|
|
1887
|
-
this.precision = config.precision;
|
|
1888
|
-
this.scale = config.scale;
|
|
1889
|
-
}
|
|
1890
|
-
mapFromDriverValue = BigInt;
|
|
1891
|
-
mapToDriverValue = String;
|
|
1892
|
-
getSQLType() {
|
|
1893
|
-
if (this.precision !== undefined && this.scale !== undefined) {
|
|
1894
|
-
return `numeric(${this.precision}, ${this.scale})`;
|
|
1895
|
-
} else if (this.precision === undefined) {
|
|
1896
|
-
return "numeric";
|
|
1897
|
-
} else {
|
|
1898
|
-
return `numeric(${this.precision})`;
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
};
|
|
1902
|
-
});
|
|
1903
|
-
|
|
1904
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/point.js
|
|
1905
|
-
function point(a, b) {
|
|
1906
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
1907
|
-
if (!config?.mode || config.mode === "tuple") {
|
|
1908
|
-
return new PgPointTupleBuilder(name);
|
|
1909
|
-
}
|
|
1910
|
-
return new PgPointObjectBuilder(name);
|
|
1911
|
-
}
|
|
1912
|
-
var PgPointTupleBuilder, PgPointTuple, PgPointObjectBuilder, PgPointObject;
|
|
1913
|
-
var init_point = __esm(() => {
|
|
1914
|
-
init_entity();
|
|
1915
|
-
init_utils();
|
|
1916
|
-
init_common();
|
|
1917
|
-
PgPointTupleBuilder = class PgPointTupleBuilder extends PgColumnBuilder {
|
|
1918
|
-
static [entityKind] = "PgPointTupleBuilder";
|
|
1919
|
-
constructor(name) {
|
|
1920
|
-
super(name, "array", "PgPointTuple");
|
|
1921
|
-
}
|
|
1922
|
-
build(table) {
|
|
1923
|
-
return new PgPointTuple(table, this.config);
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
PgPointTuple = class PgPointTuple extends PgColumn {
|
|
1927
|
-
static [entityKind] = "PgPointTuple";
|
|
1928
|
-
getSQLType() {
|
|
1929
|
-
return "point";
|
|
1930
|
-
}
|
|
1931
|
-
mapFromDriverValue(value) {
|
|
1932
|
-
if (typeof value === "string") {
|
|
1933
|
-
const [x, y] = value.slice(1, -1).split(",");
|
|
1934
|
-
return [Number.parseFloat(x), Number.parseFloat(y)];
|
|
1935
|
-
}
|
|
1936
|
-
return [value.x, value.y];
|
|
1937
|
-
}
|
|
1938
|
-
mapToDriverValue(value) {
|
|
1939
|
-
return `(${value[0]},${value[1]})`;
|
|
1940
|
-
}
|
|
1941
|
-
};
|
|
1942
|
-
PgPointObjectBuilder = class PgPointObjectBuilder extends PgColumnBuilder {
|
|
1943
|
-
static [entityKind] = "PgPointObjectBuilder";
|
|
1944
|
-
constructor(name) {
|
|
1945
|
-
super(name, "json", "PgPointObject");
|
|
1946
|
-
}
|
|
1947
|
-
build(table) {
|
|
1948
|
-
return new PgPointObject(table, this.config);
|
|
1949
|
-
}
|
|
1950
|
-
};
|
|
1951
|
-
PgPointObject = class PgPointObject extends PgColumn {
|
|
1952
|
-
static [entityKind] = "PgPointObject";
|
|
1953
|
-
getSQLType() {
|
|
1954
|
-
return "point";
|
|
1955
|
-
}
|
|
1956
|
-
mapFromDriverValue(value) {
|
|
1957
|
-
if (typeof value === "string") {
|
|
1958
|
-
const [x, y] = value.slice(1, -1).split(",");
|
|
1959
|
-
return { x: Number.parseFloat(x), y: Number.parseFloat(y) };
|
|
1960
|
-
}
|
|
1961
|
-
return value;
|
|
1962
|
-
}
|
|
1963
|
-
mapToDriverValue(value) {
|
|
1964
|
-
return `(${value.x},${value.y})`;
|
|
1965
|
-
}
|
|
1966
|
-
};
|
|
1967
|
-
});
|
|
1968
|
-
|
|
1969
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
|
|
1970
|
-
function hexToBytes(hex) {
|
|
1971
|
-
const bytes = [];
|
|
1972
|
-
for (let c = 0;c < hex.length; c += 2) {
|
|
1973
|
-
bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
|
|
1974
|
-
}
|
|
1975
|
-
return new Uint8Array(bytes);
|
|
1976
|
-
}
|
|
1977
|
-
function bytesToFloat64(bytes, offset) {
|
|
1978
|
-
const buffer = new ArrayBuffer(8);
|
|
1979
|
-
const view = new DataView(buffer);
|
|
1980
|
-
for (let i = 0;i < 8; i++) {
|
|
1981
|
-
view.setUint8(i, bytes[offset + i]);
|
|
1982
|
-
}
|
|
1983
|
-
return view.getFloat64(0, true);
|
|
1984
|
-
}
|
|
1985
|
-
function parseEWKB(hex) {
|
|
1986
|
-
const bytes = hexToBytes(hex);
|
|
1987
|
-
let offset = 0;
|
|
1988
|
-
const byteOrder = bytes[offset];
|
|
1989
|
-
offset += 1;
|
|
1990
|
-
const view = new DataView(bytes.buffer);
|
|
1991
|
-
const geomType = view.getUint32(offset, byteOrder === 1);
|
|
1992
|
-
offset += 4;
|
|
1993
|
-
let _srid;
|
|
1994
|
-
if (geomType & 536870912) {
|
|
1995
|
-
_srid = view.getUint32(offset, byteOrder === 1);
|
|
1996
|
-
offset += 4;
|
|
1997
|
-
}
|
|
1998
|
-
if ((geomType & 65535) === 1) {
|
|
1999
|
-
const x = bytesToFloat64(bytes, offset);
|
|
2000
|
-
offset += 8;
|
|
2001
|
-
const y = bytesToFloat64(bytes, offset);
|
|
2002
|
-
offset += 8;
|
|
2003
|
-
return [x, y];
|
|
2004
|
-
}
|
|
2005
|
-
throw new Error("Unsupported geometry type");
|
|
2006
|
-
}
|
|
2007
|
-
var init_utils2 = () => {};
|
|
2008
|
-
|
|
2009
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
|
|
2010
|
-
function geometry(a, b) {
|
|
2011
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2012
|
-
if (!config?.mode || config.mode === "tuple") {
|
|
2013
|
-
return new PgGeometryBuilder(name);
|
|
2014
|
-
}
|
|
2015
|
-
return new PgGeometryObjectBuilder(name);
|
|
2016
|
-
}
|
|
2017
|
-
var PgGeometryBuilder, PgGeometry, PgGeometryObjectBuilder, PgGeometryObject;
|
|
2018
|
-
var init_geometry = __esm(() => {
|
|
2019
|
-
init_entity();
|
|
2020
|
-
init_utils();
|
|
2021
|
-
init_common();
|
|
2022
|
-
init_utils2();
|
|
2023
|
-
PgGeometryBuilder = class PgGeometryBuilder extends PgColumnBuilder {
|
|
2024
|
-
static [entityKind] = "PgGeometryBuilder";
|
|
2025
|
-
constructor(name) {
|
|
2026
|
-
super(name, "array", "PgGeometry");
|
|
2027
|
-
}
|
|
2028
|
-
build(table) {
|
|
2029
|
-
return new PgGeometry(table, this.config);
|
|
2030
|
-
}
|
|
2031
|
-
};
|
|
2032
|
-
PgGeometry = class PgGeometry extends PgColumn {
|
|
2033
|
-
static [entityKind] = "PgGeometry";
|
|
2034
|
-
getSQLType() {
|
|
2035
|
-
return "geometry(point)";
|
|
2036
|
-
}
|
|
2037
|
-
mapFromDriverValue(value) {
|
|
2038
|
-
return parseEWKB(value);
|
|
2039
|
-
}
|
|
2040
|
-
mapToDriverValue(value) {
|
|
2041
|
-
return `point(${value[0]} ${value[1]})`;
|
|
2042
|
-
}
|
|
2043
|
-
};
|
|
2044
|
-
PgGeometryObjectBuilder = class PgGeometryObjectBuilder extends PgColumnBuilder {
|
|
2045
|
-
static [entityKind] = "PgGeometryObjectBuilder";
|
|
2046
|
-
constructor(name) {
|
|
2047
|
-
super(name, "json", "PgGeometryObject");
|
|
2048
|
-
}
|
|
2049
|
-
build(table) {
|
|
2050
|
-
return new PgGeometryObject(table, this.config);
|
|
2051
|
-
}
|
|
2052
|
-
};
|
|
2053
|
-
PgGeometryObject = class PgGeometryObject extends PgColumn {
|
|
2054
|
-
static [entityKind] = "PgGeometryObject";
|
|
2055
|
-
getSQLType() {
|
|
2056
|
-
return "geometry(point)";
|
|
2057
|
-
}
|
|
2058
|
-
mapFromDriverValue(value) {
|
|
2059
|
-
const parsed = parseEWKB(value);
|
|
2060
|
-
return { x: parsed[0], y: parsed[1] };
|
|
2061
|
-
}
|
|
2062
|
-
mapToDriverValue(value) {
|
|
2063
|
-
return `point(${value.x} ${value.y})`;
|
|
2064
|
-
}
|
|
2065
|
-
};
|
|
2066
|
-
});
|
|
2067
|
-
|
|
2068
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/real.js
|
|
2069
|
-
function real(name) {
|
|
2070
|
-
return new PgRealBuilder(name ?? "");
|
|
2071
|
-
}
|
|
2072
|
-
var PgRealBuilder, PgReal;
|
|
2073
|
-
var init_real = __esm(() => {
|
|
2074
|
-
init_entity();
|
|
2075
|
-
init_common();
|
|
2076
|
-
PgRealBuilder = class PgRealBuilder extends PgColumnBuilder {
|
|
2077
|
-
static [entityKind] = "PgRealBuilder";
|
|
2078
|
-
constructor(name, length) {
|
|
2079
|
-
super(name, "number", "PgReal");
|
|
2080
|
-
this.config.length = length;
|
|
2081
|
-
}
|
|
2082
|
-
build(table) {
|
|
2083
|
-
return new PgReal(table, this.config);
|
|
2084
|
-
}
|
|
2085
|
-
};
|
|
2086
|
-
PgReal = class PgReal extends PgColumn {
|
|
2087
|
-
static [entityKind] = "PgReal";
|
|
2088
|
-
constructor(table, config) {
|
|
2089
|
-
super(table, config);
|
|
2090
|
-
}
|
|
2091
|
-
getSQLType() {
|
|
2092
|
-
return "real";
|
|
2093
|
-
}
|
|
2094
|
-
mapFromDriverValue = (value) => {
|
|
2095
|
-
if (typeof value === "string") {
|
|
2096
|
-
return Number.parseFloat(value);
|
|
2097
|
-
}
|
|
2098
|
-
return value;
|
|
2099
|
-
};
|
|
2100
|
-
};
|
|
2101
|
-
});
|
|
2102
|
-
|
|
2103
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/serial.js
|
|
2104
|
-
function serial(name) {
|
|
2105
|
-
return new PgSerialBuilder(name ?? "");
|
|
2106
|
-
}
|
|
2107
|
-
var PgSerialBuilder, PgSerial;
|
|
2108
|
-
var init_serial = __esm(() => {
|
|
2109
|
-
init_entity();
|
|
2110
|
-
init_common();
|
|
2111
|
-
PgSerialBuilder = class PgSerialBuilder extends PgColumnBuilder {
|
|
2112
|
-
static [entityKind] = "PgSerialBuilder";
|
|
2113
|
-
constructor(name) {
|
|
2114
|
-
super(name, "number", "PgSerial");
|
|
2115
|
-
this.config.hasDefault = true;
|
|
2116
|
-
this.config.notNull = true;
|
|
2117
|
-
}
|
|
2118
|
-
build(table) {
|
|
2119
|
-
return new PgSerial(table, this.config);
|
|
2120
|
-
}
|
|
2121
|
-
};
|
|
2122
|
-
PgSerial = class PgSerial extends PgColumn {
|
|
2123
|
-
static [entityKind] = "PgSerial";
|
|
2124
|
-
getSQLType() {
|
|
2125
|
-
return "serial";
|
|
2126
|
-
}
|
|
2127
|
-
};
|
|
2128
|
-
});
|
|
2129
|
-
|
|
2130
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/smallint.js
|
|
2131
|
-
function smallint(name) {
|
|
2132
|
-
return new PgSmallIntBuilder(name ?? "");
|
|
2133
|
-
}
|
|
2134
|
-
var PgSmallIntBuilder, PgSmallInt;
|
|
2135
|
-
var init_smallint = __esm(() => {
|
|
2136
|
-
init_entity();
|
|
2137
|
-
init_common();
|
|
2138
|
-
init_int_common();
|
|
2139
|
-
PgSmallIntBuilder = class PgSmallIntBuilder extends PgIntColumnBaseBuilder {
|
|
2140
|
-
static [entityKind] = "PgSmallIntBuilder";
|
|
2141
|
-
constructor(name) {
|
|
2142
|
-
super(name, "number", "PgSmallInt");
|
|
2143
|
-
}
|
|
2144
|
-
build(table) {
|
|
2145
|
-
return new PgSmallInt(table, this.config);
|
|
2146
|
-
}
|
|
2147
|
-
};
|
|
2148
|
-
PgSmallInt = class PgSmallInt extends PgColumn {
|
|
2149
|
-
static [entityKind] = "PgSmallInt";
|
|
2150
|
-
getSQLType() {
|
|
2151
|
-
return "smallint";
|
|
2152
|
-
}
|
|
2153
|
-
mapFromDriverValue = (value) => {
|
|
2154
|
-
if (typeof value === "string") {
|
|
2155
|
-
return Number(value);
|
|
2156
|
-
}
|
|
2157
|
-
return value;
|
|
2158
|
-
};
|
|
2159
|
-
};
|
|
2160
|
-
});
|
|
2161
|
-
|
|
2162
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/smallserial.js
|
|
2163
|
-
function smallserial(name) {
|
|
2164
|
-
return new PgSmallSerialBuilder(name ?? "");
|
|
2165
|
-
}
|
|
2166
|
-
var PgSmallSerialBuilder, PgSmallSerial;
|
|
2167
|
-
var init_smallserial = __esm(() => {
|
|
2168
|
-
init_entity();
|
|
2169
|
-
init_common();
|
|
2170
|
-
PgSmallSerialBuilder = class PgSmallSerialBuilder extends PgColumnBuilder {
|
|
2171
|
-
static [entityKind] = "PgSmallSerialBuilder";
|
|
2172
|
-
constructor(name) {
|
|
2173
|
-
super(name, "number", "PgSmallSerial");
|
|
2174
|
-
this.config.hasDefault = true;
|
|
2175
|
-
this.config.notNull = true;
|
|
2176
|
-
}
|
|
2177
|
-
build(table) {
|
|
2178
|
-
return new PgSmallSerial(table, this.config);
|
|
2179
|
-
}
|
|
2180
|
-
};
|
|
2181
|
-
PgSmallSerial = class PgSmallSerial extends PgColumn {
|
|
2182
|
-
static [entityKind] = "PgSmallSerial";
|
|
2183
|
-
getSQLType() {
|
|
2184
|
-
return "smallserial";
|
|
2185
|
-
}
|
|
2186
|
-
};
|
|
2187
|
-
});
|
|
2188
|
-
|
|
2189
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/text.js
|
|
2190
|
-
function text(a, b = {}) {
|
|
2191
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2192
|
-
return new PgTextBuilder(name, config);
|
|
2193
|
-
}
|
|
2194
|
-
var PgTextBuilder, PgText;
|
|
2195
|
-
var init_text = __esm(() => {
|
|
2196
|
-
init_entity();
|
|
2197
|
-
init_utils();
|
|
2198
|
-
init_common();
|
|
2199
|
-
PgTextBuilder = class PgTextBuilder extends PgColumnBuilder {
|
|
2200
|
-
static [entityKind] = "PgTextBuilder";
|
|
2201
|
-
constructor(name, config) {
|
|
2202
|
-
super(name, "string", "PgText");
|
|
2203
|
-
this.config.enumValues = config.enum;
|
|
2204
|
-
}
|
|
2205
|
-
build(table) {
|
|
2206
|
-
return new PgText(table, this.config);
|
|
2207
|
-
}
|
|
2208
|
-
};
|
|
2209
|
-
PgText = class PgText extends PgColumn {
|
|
2210
|
-
static [entityKind] = "PgText";
|
|
2211
|
-
enumValues = this.config.enumValues;
|
|
2212
|
-
getSQLType() {
|
|
2213
|
-
return "text";
|
|
2214
|
-
}
|
|
2215
|
-
};
|
|
2216
|
-
});
|
|
2217
|
-
|
|
2218
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/time.js
|
|
2219
|
-
function time(a, b = {}) {
|
|
2220
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2221
|
-
return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
|
|
2222
|
-
}
|
|
2223
|
-
var PgTimeBuilder, PgTime;
|
|
2224
|
-
var init_time = __esm(() => {
|
|
2225
|
-
init_entity();
|
|
2226
|
-
init_utils();
|
|
2227
|
-
init_common();
|
|
2228
|
-
init_date_common();
|
|
2229
|
-
PgTimeBuilder = class PgTimeBuilder extends PgDateColumnBaseBuilder {
|
|
2230
|
-
constructor(name, withTimezone, precision) {
|
|
2231
|
-
super(name, "string", "PgTime");
|
|
2232
|
-
this.withTimezone = withTimezone;
|
|
2233
|
-
this.precision = precision;
|
|
2234
|
-
this.config.withTimezone = withTimezone;
|
|
2235
|
-
this.config.precision = precision;
|
|
2236
|
-
}
|
|
2237
|
-
static [entityKind] = "PgTimeBuilder";
|
|
2238
|
-
build(table) {
|
|
2239
|
-
return new PgTime(table, this.config);
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
PgTime = class PgTime extends PgColumn {
|
|
2243
|
-
static [entityKind] = "PgTime";
|
|
2244
|
-
withTimezone;
|
|
2245
|
-
precision;
|
|
2246
|
-
constructor(table, config) {
|
|
2247
|
-
super(table, config);
|
|
2248
|
-
this.withTimezone = config.withTimezone;
|
|
2249
|
-
this.precision = config.precision;
|
|
2250
|
-
}
|
|
2251
|
-
getSQLType() {
|
|
2252
|
-
const precision = this.precision === undefined ? "" : `(${this.precision})`;
|
|
2253
|
-
return `time${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
2254
|
-
}
|
|
2255
|
-
};
|
|
2256
|
-
});
|
|
2257
|
-
|
|
2258
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/timestamp.js
|
|
2259
|
-
function timestamp(a, b = {}) {
|
|
2260
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2261
|
-
if (config?.mode === "string") {
|
|
2262
|
-
return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
|
|
2263
|
-
}
|
|
2264
|
-
return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
|
|
2265
|
-
}
|
|
2266
|
-
var PgTimestampBuilder, PgTimestamp, PgTimestampStringBuilder, PgTimestampString;
|
|
2267
|
-
var init_timestamp = __esm(() => {
|
|
2268
|
-
init_entity();
|
|
2269
|
-
init_utils();
|
|
2270
|
-
init_common();
|
|
2271
|
-
init_date_common();
|
|
2272
|
-
PgTimestampBuilder = class PgTimestampBuilder extends PgDateColumnBaseBuilder {
|
|
2273
|
-
static [entityKind] = "PgTimestampBuilder";
|
|
2274
|
-
constructor(name, withTimezone, precision) {
|
|
2275
|
-
super(name, "date", "PgTimestamp");
|
|
2276
|
-
this.config.withTimezone = withTimezone;
|
|
2277
|
-
this.config.precision = precision;
|
|
2278
|
-
}
|
|
2279
|
-
build(table) {
|
|
2280
|
-
return new PgTimestamp(table, this.config);
|
|
2281
|
-
}
|
|
2282
|
-
};
|
|
2283
|
-
PgTimestamp = class PgTimestamp extends PgColumn {
|
|
2284
|
-
static [entityKind] = "PgTimestamp";
|
|
2285
|
-
withTimezone;
|
|
2286
|
-
precision;
|
|
2287
|
-
constructor(table, config) {
|
|
2288
|
-
super(table, config);
|
|
2289
|
-
this.withTimezone = config.withTimezone;
|
|
2290
|
-
this.precision = config.precision;
|
|
2291
|
-
}
|
|
2292
|
-
getSQLType() {
|
|
2293
|
-
const precision = this.precision === undefined ? "" : ` (${this.precision})`;
|
|
2294
|
-
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
2295
|
-
}
|
|
2296
|
-
mapFromDriverValue(value) {
|
|
2297
|
-
if (typeof value === "string")
|
|
2298
|
-
return new Date(this.withTimezone ? value : value + "+0000");
|
|
2299
|
-
return value;
|
|
2300
|
-
}
|
|
2301
|
-
mapToDriverValue = (value) => {
|
|
2302
|
-
return value.toISOString();
|
|
2303
|
-
};
|
|
2304
|
-
};
|
|
2305
|
-
PgTimestampStringBuilder = class PgTimestampStringBuilder extends PgDateColumnBaseBuilder {
|
|
2306
|
-
static [entityKind] = "PgTimestampStringBuilder";
|
|
2307
|
-
constructor(name, withTimezone, precision) {
|
|
2308
|
-
super(name, "string", "PgTimestampString");
|
|
2309
|
-
this.config.withTimezone = withTimezone;
|
|
2310
|
-
this.config.precision = precision;
|
|
2311
|
-
}
|
|
2312
|
-
build(table) {
|
|
2313
|
-
return new PgTimestampString(table, this.config);
|
|
2314
|
-
}
|
|
2315
|
-
};
|
|
2316
|
-
PgTimestampString = class PgTimestampString extends PgColumn {
|
|
2317
|
-
static [entityKind] = "PgTimestampString";
|
|
2318
|
-
withTimezone;
|
|
2319
|
-
precision;
|
|
2320
|
-
constructor(table, config) {
|
|
2321
|
-
super(table, config);
|
|
2322
|
-
this.withTimezone = config.withTimezone;
|
|
2323
|
-
this.precision = config.precision;
|
|
2324
|
-
}
|
|
2325
|
-
getSQLType() {
|
|
2326
|
-
const precision = this.precision === undefined ? "" : `(${this.precision})`;
|
|
2327
|
-
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
2328
|
-
}
|
|
2329
|
-
mapFromDriverValue(value) {
|
|
2330
|
-
if (typeof value === "string")
|
|
2331
|
-
return value;
|
|
2332
|
-
const shortened = value.toISOString().slice(0, -1).replace("T", " ");
|
|
2333
|
-
if (this.withTimezone) {
|
|
2334
|
-
const offset = value.getTimezoneOffset();
|
|
2335
|
-
const sign = offset <= 0 ? "+" : "-";
|
|
2336
|
-
return `${shortened}${sign}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
|
|
2337
|
-
}
|
|
2338
|
-
return shortened;
|
|
2339
|
-
}
|
|
2340
|
-
};
|
|
2341
|
-
});
|
|
2342
|
-
|
|
2343
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/uuid.js
|
|
2344
|
-
function uuid(name) {
|
|
2345
|
-
return new PgUUIDBuilder(name ?? "");
|
|
2346
|
-
}
|
|
2347
|
-
var PgUUIDBuilder, PgUUID;
|
|
2348
|
-
var init_uuid = __esm(() => {
|
|
2349
|
-
init_entity();
|
|
2350
|
-
init_sql();
|
|
2351
|
-
init_common();
|
|
2352
|
-
PgUUIDBuilder = class PgUUIDBuilder extends PgColumnBuilder {
|
|
2353
|
-
static [entityKind] = "PgUUIDBuilder";
|
|
2354
|
-
constructor(name) {
|
|
2355
|
-
super(name, "string", "PgUUID");
|
|
2356
|
-
}
|
|
2357
|
-
defaultRandom() {
|
|
2358
|
-
return this.default(sql`gen_random_uuid()`);
|
|
2359
|
-
}
|
|
2360
|
-
build(table) {
|
|
2361
|
-
return new PgUUID(table, this.config);
|
|
2362
|
-
}
|
|
2363
|
-
};
|
|
2364
|
-
PgUUID = class PgUUID extends PgColumn {
|
|
2365
|
-
static [entityKind] = "PgUUID";
|
|
2366
|
-
getSQLType() {
|
|
2367
|
-
return "uuid";
|
|
2368
|
-
}
|
|
2369
|
-
};
|
|
2370
|
-
});
|
|
2371
|
-
|
|
2372
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/varchar.js
|
|
2373
|
-
function varchar(a, b = {}) {
|
|
2374
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2375
|
-
return new PgVarcharBuilder(name, config);
|
|
2376
|
-
}
|
|
2377
|
-
var PgVarcharBuilder, PgVarchar;
|
|
2378
|
-
var init_varchar = __esm(() => {
|
|
2379
|
-
init_entity();
|
|
2380
|
-
init_utils();
|
|
2381
|
-
init_common();
|
|
2382
|
-
PgVarcharBuilder = class PgVarcharBuilder extends PgColumnBuilder {
|
|
2383
|
-
static [entityKind] = "PgVarcharBuilder";
|
|
2384
|
-
constructor(name, config) {
|
|
2385
|
-
super(name, "string", "PgVarchar");
|
|
2386
|
-
this.config.length = config.length;
|
|
2387
|
-
this.config.enumValues = config.enum;
|
|
2388
|
-
}
|
|
2389
|
-
build(table) {
|
|
2390
|
-
return new PgVarchar(table, this.config);
|
|
2391
|
-
}
|
|
2392
|
-
};
|
|
2393
|
-
PgVarchar = class PgVarchar extends PgColumn {
|
|
2394
|
-
static [entityKind] = "PgVarchar";
|
|
2395
|
-
length = this.config.length;
|
|
2396
|
-
enumValues = this.config.enumValues;
|
|
2397
|
-
getSQLType() {
|
|
2398
|
-
return this.length === undefined ? `varchar` : `varchar(${this.length})`;
|
|
2399
|
-
}
|
|
2400
|
-
};
|
|
2401
|
-
});
|
|
2402
|
-
|
|
2403
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
|
|
2404
|
-
function bit(a, b) {
|
|
2405
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2406
|
-
return new PgBinaryVectorBuilder(name, config);
|
|
2407
|
-
}
|
|
2408
|
-
var PgBinaryVectorBuilder, PgBinaryVector;
|
|
2409
|
-
var init_bit = __esm(() => {
|
|
2410
|
-
init_entity();
|
|
2411
|
-
init_utils();
|
|
2412
|
-
init_common();
|
|
2413
|
-
PgBinaryVectorBuilder = class PgBinaryVectorBuilder extends PgColumnBuilder {
|
|
2414
|
-
static [entityKind] = "PgBinaryVectorBuilder";
|
|
2415
|
-
constructor(name, config) {
|
|
2416
|
-
super(name, "string", "PgBinaryVector");
|
|
2417
|
-
this.config.dimensions = config.dimensions;
|
|
2418
|
-
}
|
|
2419
|
-
build(table) {
|
|
2420
|
-
return new PgBinaryVector(table, this.config);
|
|
2421
|
-
}
|
|
2422
|
-
};
|
|
2423
|
-
PgBinaryVector = class PgBinaryVector extends PgColumn {
|
|
2424
|
-
static [entityKind] = "PgBinaryVector";
|
|
2425
|
-
dimensions = this.config.dimensions;
|
|
2426
|
-
getSQLType() {
|
|
2427
|
-
return `bit(${this.dimensions})`;
|
|
2428
|
-
}
|
|
2429
|
-
};
|
|
2430
|
-
});
|
|
2431
|
-
|
|
2432
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
|
|
2433
|
-
function halfvec(a, b) {
|
|
2434
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2435
|
-
return new PgHalfVectorBuilder(name, config);
|
|
2436
|
-
}
|
|
2437
|
-
var PgHalfVectorBuilder, PgHalfVector;
|
|
2438
|
-
var init_halfvec = __esm(() => {
|
|
2439
|
-
init_entity();
|
|
2440
|
-
init_utils();
|
|
2441
|
-
init_common();
|
|
2442
|
-
PgHalfVectorBuilder = class PgHalfVectorBuilder extends PgColumnBuilder {
|
|
2443
|
-
static [entityKind] = "PgHalfVectorBuilder";
|
|
2444
|
-
constructor(name, config) {
|
|
2445
|
-
super(name, "array", "PgHalfVector");
|
|
2446
|
-
this.config.dimensions = config.dimensions;
|
|
2447
|
-
}
|
|
2448
|
-
build(table) {
|
|
2449
|
-
return new PgHalfVector(table, this.config);
|
|
2450
|
-
}
|
|
2451
|
-
};
|
|
2452
|
-
PgHalfVector = class PgHalfVector extends PgColumn {
|
|
2453
|
-
static [entityKind] = "PgHalfVector";
|
|
2454
|
-
dimensions = this.config.dimensions;
|
|
2455
|
-
getSQLType() {
|
|
2456
|
-
return `halfvec(${this.dimensions})`;
|
|
2457
|
-
}
|
|
2458
|
-
mapToDriverValue(value) {
|
|
2459
|
-
return JSON.stringify(value);
|
|
2460
|
-
}
|
|
2461
|
-
mapFromDriverValue(value) {
|
|
2462
|
-
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
2463
|
-
}
|
|
2464
|
-
};
|
|
2465
|
-
});
|
|
2466
|
-
|
|
2467
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
|
|
2468
|
-
function sparsevec(a, b) {
|
|
2469
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2470
|
-
return new PgSparseVectorBuilder(name, config);
|
|
2471
|
-
}
|
|
2472
|
-
var PgSparseVectorBuilder, PgSparseVector;
|
|
2473
|
-
var init_sparsevec = __esm(() => {
|
|
2474
|
-
init_entity();
|
|
2475
|
-
init_utils();
|
|
2476
|
-
init_common();
|
|
2477
|
-
PgSparseVectorBuilder = class PgSparseVectorBuilder extends PgColumnBuilder {
|
|
2478
|
-
static [entityKind] = "PgSparseVectorBuilder";
|
|
2479
|
-
constructor(name, config) {
|
|
2480
|
-
super(name, "string", "PgSparseVector");
|
|
2481
|
-
this.config.dimensions = config.dimensions;
|
|
2482
|
-
}
|
|
2483
|
-
build(table) {
|
|
2484
|
-
return new PgSparseVector(table, this.config);
|
|
2485
|
-
}
|
|
2486
|
-
};
|
|
2487
|
-
PgSparseVector = class PgSparseVector extends PgColumn {
|
|
2488
|
-
static [entityKind] = "PgSparseVector";
|
|
2489
|
-
dimensions = this.config.dimensions;
|
|
2490
|
-
getSQLType() {
|
|
2491
|
-
return `sparsevec(${this.dimensions})`;
|
|
2492
|
-
}
|
|
2493
|
-
};
|
|
2494
|
-
});
|
|
2495
|
-
|
|
2496
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
|
|
2497
|
-
function vector(a, b) {
|
|
2498
|
-
const { name, config } = getColumnNameAndConfig(a, b);
|
|
2499
|
-
return new PgVectorBuilder(name, config);
|
|
2500
|
-
}
|
|
2501
|
-
var PgVectorBuilder, PgVector;
|
|
2502
|
-
var init_vector = __esm(() => {
|
|
2503
|
-
init_entity();
|
|
2504
|
-
init_utils();
|
|
2505
|
-
init_common();
|
|
2506
|
-
PgVectorBuilder = class PgVectorBuilder extends PgColumnBuilder {
|
|
2507
|
-
static [entityKind] = "PgVectorBuilder";
|
|
2508
|
-
constructor(name, config) {
|
|
2509
|
-
super(name, "array", "PgVector");
|
|
2510
|
-
this.config.dimensions = config.dimensions;
|
|
2511
|
-
}
|
|
2512
|
-
build(table) {
|
|
2513
|
-
return new PgVector(table, this.config);
|
|
2514
|
-
}
|
|
2515
|
-
};
|
|
2516
|
-
PgVector = class PgVector extends PgColumn {
|
|
2517
|
-
static [entityKind] = "PgVector";
|
|
2518
|
-
dimensions = this.config.dimensions;
|
|
2519
|
-
getSQLType() {
|
|
2520
|
-
return `vector(${this.dimensions})`;
|
|
2521
|
-
}
|
|
2522
|
-
mapToDriverValue(value) {
|
|
2523
|
-
return JSON.stringify(value);
|
|
2524
|
-
}
|
|
2525
|
-
mapFromDriverValue(value) {
|
|
2526
|
-
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
2527
|
-
}
|
|
2528
|
-
};
|
|
2529
|
-
});
|
|
2530
|
-
|
|
2531
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/all.js
|
|
2532
|
-
function getPgColumnBuilders() {
|
|
2533
|
-
return {
|
|
2534
|
-
bigint,
|
|
2535
|
-
bigserial,
|
|
2536
|
-
boolean,
|
|
2537
|
-
char,
|
|
2538
|
-
cidr,
|
|
2539
|
-
customType,
|
|
2540
|
-
date,
|
|
2541
|
-
doublePrecision,
|
|
2542
|
-
inet,
|
|
2543
|
-
integer,
|
|
2544
|
-
interval,
|
|
2545
|
-
json,
|
|
2546
|
-
jsonb,
|
|
2547
|
-
line,
|
|
2548
|
-
macaddr,
|
|
2549
|
-
macaddr8,
|
|
2550
|
-
numeric,
|
|
2551
|
-
point,
|
|
2552
|
-
geometry,
|
|
2553
|
-
real,
|
|
2554
|
-
serial,
|
|
2555
|
-
smallint,
|
|
2556
|
-
smallserial,
|
|
2557
|
-
text,
|
|
2558
|
-
time,
|
|
2559
|
-
timestamp,
|
|
2560
|
-
uuid,
|
|
2561
|
-
varchar,
|
|
2562
|
-
bit,
|
|
2563
|
-
halfvec,
|
|
2564
|
-
sparsevec,
|
|
2565
|
-
vector
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
|
-
var init_all = __esm(() => {
|
|
2569
|
-
init_bigint();
|
|
2570
|
-
init_bigserial();
|
|
2571
|
-
init_boolean();
|
|
2572
|
-
init_char();
|
|
2573
|
-
init_cidr();
|
|
2574
|
-
init_custom();
|
|
2575
|
-
init_date();
|
|
2576
|
-
init_double_precision();
|
|
2577
|
-
init_inet();
|
|
2578
|
-
init_integer();
|
|
2579
|
-
init_interval();
|
|
2580
|
-
init_json();
|
|
2581
|
-
init_jsonb();
|
|
2582
|
-
init_line();
|
|
2583
|
-
init_macaddr();
|
|
2584
|
-
init_macaddr8();
|
|
2585
|
-
init_numeric();
|
|
2586
|
-
init_point();
|
|
2587
|
-
init_geometry();
|
|
2588
|
-
init_real();
|
|
2589
|
-
init_serial();
|
|
2590
|
-
init_smallint();
|
|
2591
|
-
init_smallserial();
|
|
2592
|
-
init_text();
|
|
2593
|
-
init_time();
|
|
2594
|
-
init_timestamp();
|
|
2595
|
-
init_uuid();
|
|
2596
|
-
init_varchar();
|
|
2597
|
-
init_bit();
|
|
2598
|
-
init_halfvec();
|
|
2599
|
-
init_sparsevec();
|
|
2600
|
-
init_vector();
|
|
2601
|
-
});
|
|
2602
|
-
|
|
2603
|
-
// ../../../node_modules/drizzle-orm/pg-core/table.js
|
|
2604
|
-
function pgTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
|
|
2605
|
-
const rawTable = new PgTable(name, schema, baseName);
|
|
2606
|
-
const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
|
|
2607
|
-
const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
2608
|
-
const colBuilder = colBuilderBase;
|
|
2609
|
-
colBuilder.setName(name2);
|
|
2610
|
-
const column = colBuilder.build(rawTable);
|
|
2611
|
-
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
2612
|
-
return [name2, column];
|
|
2613
|
-
}));
|
|
2614
|
-
const builtColumnsForExtraConfig = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
2615
|
-
const colBuilder = colBuilderBase;
|
|
2616
|
-
colBuilder.setName(name2);
|
|
2617
|
-
const column = colBuilder.buildExtraConfigColumn(rawTable);
|
|
2618
|
-
return [name2, column];
|
|
2619
|
-
}));
|
|
2620
|
-
const table = Object.assign(rawTable, builtColumns);
|
|
2621
|
-
table[Table.Symbol.Columns] = builtColumns;
|
|
2622
|
-
table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
|
|
2623
|
-
if (extraConfig) {
|
|
2624
|
-
table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
|
2625
|
-
}
|
|
2626
|
-
return Object.assign(table, {
|
|
2627
|
-
enableRLS: () => {
|
|
2628
|
-
table[PgTable.Symbol.EnableRLS] = true;
|
|
2629
|
-
return table;
|
|
2630
|
-
}
|
|
2631
|
-
});
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
2632
5
|
}
|
|
2633
|
-
var
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
|
|
2641
|
-
EnableRLS = Symbol.for("drizzle:EnableRLS");
|
|
2642
|
-
PgTable = class PgTable extends Table {
|
|
2643
|
-
static [entityKind] = "PgTable";
|
|
2644
|
-
static Symbol = Object.assign({}, Table.Symbol, {
|
|
2645
|
-
InlineForeignKeys,
|
|
2646
|
-
EnableRLS
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
2647
13
|
});
|
|
2648
|
-
[InlineForeignKeys] = [];
|
|
2649
|
-
[EnableRLS] = false;
|
|
2650
|
-
[Table.Symbol.ExtraConfigBuilder] = undefined;
|
|
2651
|
-
[Table.Symbol.ExtraConfigColumns] = {};
|
|
2652
|
-
};
|
|
2653
|
-
});
|
|
2654
|
-
|
|
2655
|
-
// ../../../node_modules/drizzle-orm/pg-core/primary-keys.js
|
|
2656
|
-
var init_primary_keys = () => {};
|
|
2657
|
-
|
|
2658
|
-
// ../../../node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
2659
|
-
function bindIfParam(value, column) {
|
|
2660
|
-
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
|
2661
|
-
return new Param(value, column);
|
|
2662
|
-
}
|
|
2663
|
-
return value;
|
|
2664
|
-
}
|
|
2665
|
-
function and(...unfilteredConditions) {
|
|
2666
|
-
const conditions = unfilteredConditions.filter((c) => c !== undefined);
|
|
2667
|
-
if (conditions.length === 0) {
|
|
2668
|
-
return;
|
|
2669
|
-
}
|
|
2670
|
-
if (conditions.length === 1) {
|
|
2671
|
-
return new SQL(conditions);
|
|
2672
|
-
}
|
|
2673
|
-
return new SQL([
|
|
2674
|
-
new StringChunk("("),
|
|
2675
|
-
sql.join(conditions, new StringChunk(" and ")),
|
|
2676
|
-
new StringChunk(")")
|
|
2677
|
-
]);
|
|
2678
|
-
}
|
|
2679
|
-
function inArray(column, values) {
|
|
2680
|
-
if (Array.isArray(values)) {
|
|
2681
|
-
if (values.length === 0) {
|
|
2682
|
-
return sql`false`;
|
|
2683
|
-
}
|
|
2684
|
-
return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
|
|
2685
|
-
}
|
|
2686
|
-
return sql`${column} in ${bindIfParam(values, column)}`;
|
|
2687
|
-
}
|
|
2688
|
-
var eq = (left, right) => {
|
|
2689
|
-
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
2690
14
|
};
|
|
2691
|
-
var
|
|
2692
|
-
init_column();
|
|
2693
|
-
init_entity();
|
|
2694
|
-
init_table();
|
|
2695
|
-
init_sql();
|
|
2696
|
-
});
|
|
2697
|
-
|
|
2698
|
-
// ../../../node_modules/drizzle-orm/sql/expressions/select.js
|
|
2699
|
-
function asc(column) {
|
|
2700
|
-
return sql`${column} asc`;
|
|
2701
|
-
}
|
|
2702
|
-
var init_select = __esm(() => {
|
|
2703
|
-
init_sql();
|
|
2704
|
-
});
|
|
2705
|
-
|
|
2706
|
-
// ../../../node_modules/drizzle-orm/sql/expressions/index.js
|
|
2707
|
-
var init_expressions = __esm(() => {
|
|
2708
|
-
init_conditions();
|
|
2709
|
-
init_select();
|
|
2710
|
-
});
|
|
2711
|
-
|
|
2712
|
-
// ../../../node_modules/drizzle-orm/relations.js
|
|
2713
|
-
function relations(table, relations2) {
|
|
2714
|
-
return new Relations(table, (helpers) => Object.fromEntries(Object.entries(relations2(helpers)).map(([key, value]) => [
|
|
2715
|
-
key,
|
|
2716
|
-
value.withFieldName(key)
|
|
2717
|
-
])));
|
|
2718
|
-
}
|
|
2719
|
-
var Relations;
|
|
2720
|
-
var init_relations = __esm(() => {
|
|
2721
|
-
init_entity();
|
|
2722
|
-
Relations = class Relations {
|
|
2723
|
-
constructor(table, config) {
|
|
2724
|
-
this.table = table;
|
|
2725
|
-
this.config = config;
|
|
2726
|
-
}
|
|
2727
|
-
static [entityKind] = "Relations";
|
|
2728
|
-
};
|
|
2729
|
-
});
|
|
2730
|
-
|
|
2731
|
-
// ../../../node_modules/drizzle-orm/sql/functions/aggregate.js
|
|
2732
|
-
var init_aggregate = () => {};
|
|
2733
|
-
|
|
2734
|
-
// ../../../node_modules/drizzle-orm/sql/functions/vector.js
|
|
2735
|
-
var init_vector2 = () => {};
|
|
2736
|
-
|
|
2737
|
-
// ../../../node_modules/drizzle-orm/sql/functions/index.js
|
|
2738
|
-
var init_functions = __esm(() => {
|
|
2739
|
-
init_aggregate();
|
|
2740
|
-
init_vector2();
|
|
2741
|
-
});
|
|
2742
|
-
|
|
2743
|
-
// ../../../node_modules/drizzle-orm/sql/index.js
|
|
2744
|
-
var init_sql2 = __esm(() => {
|
|
2745
|
-
init_expressions();
|
|
2746
|
-
init_functions();
|
|
2747
|
-
init_sql();
|
|
2748
|
-
});
|
|
2749
|
-
|
|
2750
|
-
// ../../../node_modules/drizzle-orm/index.js
|
|
2751
|
-
var init_drizzle_orm = __esm(() => {
|
|
2752
|
-
init_alias();
|
|
2753
|
-
init_column_builder();
|
|
2754
|
-
init_column();
|
|
2755
|
-
init_entity();
|
|
2756
|
-
init_errors();
|
|
2757
|
-
init_logger();
|
|
2758
|
-
init_query_promise();
|
|
2759
|
-
init_relations();
|
|
2760
|
-
init_sql2();
|
|
2761
|
-
init_subquery();
|
|
2762
|
-
init_table();
|
|
2763
|
-
init_utils();
|
|
2764
|
-
init_view_common();
|
|
2765
|
-
});
|
|
15
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
2766
16
|
|
|
2767
|
-
// ../../../node_modules/uuid/dist-node/
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
var init_stringify = __esm(() => {
|
|
2773
|
-
byteToHex = [];
|
|
2774
|
-
for (let i = 0;i < 256; ++i) {
|
|
2775
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
2776
|
-
}
|
|
17
|
+
// ../../../node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/native.js
|
|
18
|
+
import { randomUUID } from "node:crypto";
|
|
19
|
+
var native_default;
|
|
20
|
+
var init_native = __esm(() => {
|
|
21
|
+
native_default = { randomUUID };
|
|
2777
22
|
});
|
|
2778
23
|
|
|
2779
|
-
// ../../../node_modules/uuid/dist-node/rng.js
|
|
24
|
+
// ../../../node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/rng.js
|
|
2780
25
|
import { randomFillSync } from "node:crypto";
|
|
2781
26
|
function rng() {
|
|
2782
27
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
@@ -2791,14 +36,19 @@ var init_rng = __esm(() => {
|
|
|
2791
36
|
poolPtr = rnds8Pool.length;
|
|
2792
37
|
});
|
|
2793
38
|
|
|
2794
|
-
// ../../../node_modules/uuid/dist-node/
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
39
|
+
// ../../../node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/stringify.js
|
|
40
|
+
function unsafeStringify(arr, offset = 0) {
|
|
41
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
var byteToHex;
|
|
44
|
+
var init_stringify = __esm(() => {
|
|
45
|
+
byteToHex = [];
|
|
46
|
+
for (let i = 0;i < 256; ++i) {
|
|
47
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
48
|
+
}
|
|
2799
49
|
});
|
|
2800
50
|
|
|
2801
|
-
// ../../../node_modules/uuid/dist-node/v4.js
|
|
51
|
+
// ../../../node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/v4.js
|
|
2802
52
|
function _v4(options, buf, offset) {
|
|
2803
53
|
options = options || {};
|
|
2804
54
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
@@ -2833,761 +83,27 @@ var init_v4 = __esm(() => {
|
|
|
2833
83
|
v4_default = v4;
|
|
2834
84
|
});
|
|
2835
85
|
|
|
2836
|
-
// ../../../node_modules/uuid/dist-node/index.js
|
|
86
|
+
// ../../../node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/index.js
|
|
2837
87
|
var init_dist_node = __esm(() => {
|
|
2838
88
|
init_v4();
|
|
2839
89
|
});
|
|
2840
90
|
|
|
2841
|
-
// ../../../node_modules/drizzle-orm/pg-core/alias.js
|
|
2842
|
-
var init_alias2 = () => {};
|
|
2843
|
-
|
|
2844
|
-
// ../../../node_modules/drizzle-orm/pg-core/checks.js
|
|
2845
|
-
var init_checks = () => {};
|
|
2846
|
-
|
|
2847
|
-
// ../../../node_modules/drizzle-orm/pg-core/columns/index.js
|
|
2848
|
-
var init_columns = __esm(() => {
|
|
2849
|
-
init_bigint();
|
|
2850
|
-
init_bigserial();
|
|
2851
|
-
init_boolean();
|
|
2852
|
-
init_char();
|
|
2853
|
-
init_cidr();
|
|
2854
|
-
init_common();
|
|
2855
|
-
init_custom();
|
|
2856
|
-
init_date();
|
|
2857
|
-
init_double_precision();
|
|
2858
|
-
init_enum();
|
|
2859
|
-
init_inet();
|
|
2860
|
-
init_int_common();
|
|
2861
|
-
init_integer();
|
|
2862
|
-
init_interval();
|
|
2863
|
-
init_json();
|
|
2864
|
-
init_jsonb();
|
|
2865
|
-
init_line();
|
|
2866
|
-
init_macaddr();
|
|
2867
|
-
init_macaddr8();
|
|
2868
|
-
init_numeric();
|
|
2869
|
-
init_point();
|
|
2870
|
-
init_geometry();
|
|
2871
|
-
init_real();
|
|
2872
|
-
init_serial();
|
|
2873
|
-
init_smallint();
|
|
2874
|
-
init_smallserial();
|
|
2875
|
-
init_text();
|
|
2876
|
-
init_time();
|
|
2877
|
-
init_timestamp();
|
|
2878
|
-
init_uuid();
|
|
2879
|
-
init_varchar();
|
|
2880
|
-
init_bit();
|
|
2881
|
-
init_halfvec();
|
|
2882
|
-
init_sparsevec();
|
|
2883
|
-
init_vector();
|
|
2884
|
-
});
|
|
2885
|
-
|
|
2886
|
-
// ../../../node_modules/drizzle-orm/selection-proxy.js
|
|
2887
|
-
var SelectionProxyHandler;
|
|
2888
|
-
var init_selection_proxy = __esm(() => {
|
|
2889
|
-
init_alias();
|
|
2890
|
-
init_column();
|
|
2891
|
-
init_entity();
|
|
2892
|
-
init_sql();
|
|
2893
|
-
init_subquery();
|
|
2894
|
-
init_view_common();
|
|
2895
|
-
SelectionProxyHandler = class SelectionProxyHandler {
|
|
2896
|
-
static [entityKind] = "SelectionProxyHandler";
|
|
2897
|
-
config;
|
|
2898
|
-
constructor(config) {
|
|
2899
|
-
this.config = { ...config };
|
|
2900
|
-
}
|
|
2901
|
-
get(subquery2, prop) {
|
|
2902
|
-
if (prop === "_") {
|
|
2903
|
-
return {
|
|
2904
|
-
...subquery2["_"],
|
|
2905
|
-
selectedFields: new Proxy(subquery2._.selectedFields, this)
|
|
2906
|
-
};
|
|
2907
|
-
}
|
|
2908
|
-
if (prop === ViewBaseConfig) {
|
|
2909
|
-
return {
|
|
2910
|
-
...subquery2[ViewBaseConfig],
|
|
2911
|
-
selectedFields: new Proxy(subquery2[ViewBaseConfig].selectedFields, this)
|
|
2912
|
-
};
|
|
2913
|
-
}
|
|
2914
|
-
if (typeof prop === "symbol") {
|
|
2915
|
-
return subquery2[prop];
|
|
2916
|
-
}
|
|
2917
|
-
const columns = is(subquery2, Subquery) ? subquery2._.selectedFields : is(subquery2, View) ? subquery2[ViewBaseConfig].selectedFields : subquery2;
|
|
2918
|
-
const value = columns[prop];
|
|
2919
|
-
if (is(value, SQL.Aliased)) {
|
|
2920
|
-
if (this.config.sqlAliasedBehavior === "sql" && !value.isSelectionField) {
|
|
2921
|
-
return value.sql;
|
|
2922
|
-
}
|
|
2923
|
-
const newValue = value.clone();
|
|
2924
|
-
newValue.isSelectionField = true;
|
|
2925
|
-
return newValue;
|
|
2926
|
-
}
|
|
2927
|
-
if (is(value, SQL)) {
|
|
2928
|
-
if (this.config.sqlBehavior === "sql") {
|
|
2929
|
-
return value;
|
|
2930
|
-
}
|
|
2931
|
-
throw new Error(`You tried to reference "${prop}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`);
|
|
2932
|
-
}
|
|
2933
|
-
if (is(value, Column)) {
|
|
2934
|
-
if (this.config.alias) {
|
|
2935
|
-
return new Proxy(value, new ColumnAliasProxyHandler(new Proxy(value.table, new TableAliasProxyHandler(this.config.alias, this.config.replaceOriginalName ?? false))));
|
|
2936
|
-
}
|
|
2937
|
-
return value;
|
|
2938
|
-
}
|
|
2939
|
-
if (typeof value !== "object" || value === null) {
|
|
2940
|
-
return value;
|
|
2941
|
-
}
|
|
2942
|
-
return new Proxy(value, new SelectionProxyHandler(this.config));
|
|
2943
|
-
}
|
|
2944
|
-
};
|
|
2945
|
-
});
|
|
2946
|
-
|
|
2947
|
-
// ../../../node_modules/drizzle-orm/pg-core/indexes.js
|
|
2948
|
-
function index(name) {
|
|
2949
|
-
return new IndexBuilderOn(false, name);
|
|
2950
|
-
}
|
|
2951
|
-
function uniqueIndex(name) {
|
|
2952
|
-
return new IndexBuilderOn(true, name);
|
|
2953
|
-
}
|
|
2954
|
-
var IndexBuilderOn, IndexBuilder, Index;
|
|
2955
|
-
var init_indexes = __esm(() => {
|
|
2956
|
-
init_sql();
|
|
2957
|
-
init_entity();
|
|
2958
|
-
init_columns();
|
|
2959
|
-
IndexBuilderOn = class IndexBuilderOn {
|
|
2960
|
-
constructor(unique, name) {
|
|
2961
|
-
this.unique = unique;
|
|
2962
|
-
this.name = name;
|
|
2963
|
-
}
|
|
2964
|
-
static [entityKind] = "PgIndexBuilderOn";
|
|
2965
|
-
on(...columns) {
|
|
2966
|
-
return new IndexBuilder(columns.map((it) => {
|
|
2967
|
-
if (is(it, SQL)) {
|
|
2968
|
-
return it;
|
|
2969
|
-
}
|
|
2970
|
-
it = it;
|
|
2971
|
-
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
2972
|
-
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
2973
|
-
return clonedIndexedColumn;
|
|
2974
|
-
}), this.unique, false, this.name);
|
|
2975
|
-
}
|
|
2976
|
-
onOnly(...columns) {
|
|
2977
|
-
return new IndexBuilder(columns.map((it) => {
|
|
2978
|
-
if (is(it, SQL)) {
|
|
2979
|
-
return it;
|
|
2980
|
-
}
|
|
2981
|
-
it = it;
|
|
2982
|
-
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
2983
|
-
it.indexConfig = it.defaultConfig;
|
|
2984
|
-
return clonedIndexedColumn;
|
|
2985
|
-
}), this.unique, true, this.name);
|
|
2986
|
-
}
|
|
2987
|
-
using(method, ...columns) {
|
|
2988
|
-
return new IndexBuilder(columns.map((it) => {
|
|
2989
|
-
if (is(it, SQL)) {
|
|
2990
|
-
return it;
|
|
2991
|
-
}
|
|
2992
|
-
it = it;
|
|
2993
|
-
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
2994
|
-
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
2995
|
-
return clonedIndexedColumn;
|
|
2996
|
-
}), this.unique, true, this.name, method);
|
|
2997
|
-
}
|
|
2998
|
-
};
|
|
2999
|
-
IndexBuilder = class IndexBuilder {
|
|
3000
|
-
static [entityKind] = "PgIndexBuilder";
|
|
3001
|
-
config;
|
|
3002
|
-
constructor(columns, unique, only, name, method = "btree") {
|
|
3003
|
-
this.config = {
|
|
3004
|
-
name,
|
|
3005
|
-
columns,
|
|
3006
|
-
unique,
|
|
3007
|
-
only,
|
|
3008
|
-
method
|
|
3009
|
-
};
|
|
3010
|
-
}
|
|
3011
|
-
concurrently() {
|
|
3012
|
-
this.config.concurrently = true;
|
|
3013
|
-
return this;
|
|
3014
|
-
}
|
|
3015
|
-
with(obj) {
|
|
3016
|
-
this.config.with = obj;
|
|
3017
|
-
return this;
|
|
3018
|
-
}
|
|
3019
|
-
where(condition) {
|
|
3020
|
-
this.config.where = condition;
|
|
3021
|
-
return this;
|
|
3022
|
-
}
|
|
3023
|
-
build(table2) {
|
|
3024
|
-
return new Index(this.config, table2);
|
|
3025
|
-
}
|
|
3026
|
-
};
|
|
3027
|
-
Index = class Index {
|
|
3028
|
-
static [entityKind] = "PgIndex";
|
|
3029
|
-
config;
|
|
3030
|
-
constructor(config, table2) {
|
|
3031
|
-
this.config = { ...config, table: table2 };
|
|
3032
|
-
}
|
|
3033
|
-
};
|
|
3034
|
-
});
|
|
3035
|
-
|
|
3036
|
-
// ../../../node_modules/drizzle-orm/pg-core/policies.js
|
|
3037
|
-
var init_policies = () => {};
|
|
3038
|
-
|
|
3039
|
-
// ../../../node_modules/drizzle-orm/pg-core/view-common.js
|
|
3040
|
-
var PgViewConfig;
|
|
3041
|
-
var init_view_common2 = __esm(() => {
|
|
3042
|
-
PgViewConfig = Symbol.for("drizzle:PgViewConfig");
|
|
3043
|
-
});
|
|
3044
|
-
|
|
3045
|
-
// ../../../node_modules/drizzle-orm/pg-core/dialect.js
|
|
3046
|
-
var init_dialect = () => {};
|
|
3047
|
-
|
|
3048
|
-
// ../../../node_modules/drizzle-orm/query-builders/query-builder.js
|
|
3049
|
-
var TypedQueryBuilder;
|
|
3050
|
-
var init_query_builder = __esm(() => {
|
|
3051
|
-
init_entity();
|
|
3052
|
-
TypedQueryBuilder = class TypedQueryBuilder {
|
|
3053
|
-
static [entityKind] = "TypedQueryBuilder";
|
|
3054
|
-
getSelectedFields() {
|
|
3055
|
-
return this._.selectedFields;
|
|
3056
|
-
}
|
|
3057
|
-
};
|
|
3058
|
-
});
|
|
3059
|
-
|
|
3060
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/select.js
|
|
3061
|
-
function createSetOperator(type, isAll) {
|
|
3062
|
-
return (leftSelect, rightSelect, ...restSelects) => {
|
|
3063
|
-
const setOperators = [rightSelect, ...restSelects].map((select2) => ({
|
|
3064
|
-
type,
|
|
3065
|
-
isAll,
|
|
3066
|
-
rightSelect: select2
|
|
3067
|
-
}));
|
|
3068
|
-
for (const setOperator of setOperators) {
|
|
3069
|
-
if (!haveSameKeys(leftSelect.getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {
|
|
3070
|
-
throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
return leftSelect.addSetOperators(setOperators);
|
|
3074
|
-
};
|
|
3075
|
-
}
|
|
3076
|
-
var PgSelectQueryBuilderBase, PgSelectBase, getPgSetOperators = () => ({
|
|
3077
|
-
union,
|
|
3078
|
-
unionAll,
|
|
3079
|
-
intersect,
|
|
3080
|
-
intersectAll,
|
|
3081
|
-
except,
|
|
3082
|
-
exceptAll
|
|
3083
|
-
}), union, unionAll, intersect, intersectAll, except, exceptAll;
|
|
3084
|
-
var init_select2 = __esm(() => {
|
|
3085
|
-
init_entity();
|
|
3086
|
-
init_query_builder();
|
|
3087
|
-
init_query_promise();
|
|
3088
|
-
init_selection_proxy();
|
|
3089
|
-
init_sql();
|
|
3090
|
-
init_subquery();
|
|
3091
|
-
init_table();
|
|
3092
|
-
init_tracing();
|
|
3093
|
-
init_utils();
|
|
3094
|
-
init_utils();
|
|
3095
|
-
init_view_common();
|
|
3096
|
-
init_utils3();
|
|
3097
|
-
PgSelectQueryBuilderBase = class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
3098
|
-
static [entityKind] = "PgSelectQueryBuilder";
|
|
3099
|
-
_;
|
|
3100
|
-
config;
|
|
3101
|
-
joinsNotNullableMap;
|
|
3102
|
-
tableName;
|
|
3103
|
-
isPartialSelect;
|
|
3104
|
-
session;
|
|
3105
|
-
dialect;
|
|
3106
|
-
cacheConfig = undefined;
|
|
3107
|
-
usedTables = /* @__PURE__ */ new Set;
|
|
3108
|
-
constructor({ table: table2, fields, isPartialSelect, session, dialect, withList, distinct }) {
|
|
3109
|
-
super();
|
|
3110
|
-
this.config = {
|
|
3111
|
-
withList,
|
|
3112
|
-
table: table2,
|
|
3113
|
-
fields: { ...fields },
|
|
3114
|
-
distinct,
|
|
3115
|
-
setOperators: []
|
|
3116
|
-
};
|
|
3117
|
-
this.isPartialSelect = isPartialSelect;
|
|
3118
|
-
this.session = session;
|
|
3119
|
-
this.dialect = dialect;
|
|
3120
|
-
this._ = {
|
|
3121
|
-
selectedFields: fields,
|
|
3122
|
-
config: this.config
|
|
3123
|
-
};
|
|
3124
|
-
this.tableName = getTableLikeName(table2);
|
|
3125
|
-
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
3126
|
-
for (const item of extractUsedTable(table2))
|
|
3127
|
-
this.usedTables.add(item);
|
|
3128
|
-
}
|
|
3129
|
-
getUsedTables() {
|
|
3130
|
-
return [...this.usedTables];
|
|
3131
|
-
}
|
|
3132
|
-
createJoin(joinType, lateral) {
|
|
3133
|
-
return (table2, on) => {
|
|
3134
|
-
const baseTableName = this.tableName;
|
|
3135
|
-
const tableName = getTableLikeName(table2);
|
|
3136
|
-
for (const item of extractUsedTable(table2))
|
|
3137
|
-
this.usedTables.add(item);
|
|
3138
|
-
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
|
3139
|
-
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
3140
|
-
}
|
|
3141
|
-
if (!this.isPartialSelect) {
|
|
3142
|
-
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") {
|
|
3143
|
-
this.config.fields = {
|
|
3144
|
-
[baseTableName]: this.config.fields
|
|
3145
|
-
};
|
|
3146
|
-
}
|
|
3147
|
-
if (typeof tableName === "string" && !is(table2, SQL)) {
|
|
3148
|
-
const selection = is(table2, Subquery) ? table2._.selectedFields : is(table2, View) ? table2[ViewBaseConfig].selectedFields : table2[Table.Symbol.Columns];
|
|
3149
|
-
this.config.fields[tableName] = selection;
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
if (typeof on === "function") {
|
|
3153
|
-
on = on(new Proxy(this.config.fields, new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })));
|
|
3154
|
-
}
|
|
3155
|
-
if (!this.config.joins) {
|
|
3156
|
-
this.config.joins = [];
|
|
3157
|
-
}
|
|
3158
|
-
this.config.joins.push({ on, table: table2, joinType, alias: tableName, lateral });
|
|
3159
|
-
if (typeof tableName === "string") {
|
|
3160
|
-
switch (joinType) {
|
|
3161
|
-
case "left": {
|
|
3162
|
-
this.joinsNotNullableMap[tableName] = false;
|
|
3163
|
-
break;
|
|
3164
|
-
}
|
|
3165
|
-
case "right": {
|
|
3166
|
-
this.joinsNotNullableMap = Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false]));
|
|
3167
|
-
this.joinsNotNullableMap[tableName] = true;
|
|
3168
|
-
break;
|
|
3169
|
-
}
|
|
3170
|
-
case "cross":
|
|
3171
|
-
case "inner": {
|
|
3172
|
-
this.joinsNotNullableMap[tableName] = true;
|
|
3173
|
-
break;
|
|
3174
|
-
}
|
|
3175
|
-
case "full": {
|
|
3176
|
-
this.joinsNotNullableMap = Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false]));
|
|
3177
|
-
this.joinsNotNullableMap[tableName] = false;
|
|
3178
|
-
break;
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
}
|
|
3182
|
-
return this;
|
|
3183
|
-
};
|
|
3184
|
-
}
|
|
3185
|
-
leftJoin = this.createJoin("left", false);
|
|
3186
|
-
leftJoinLateral = this.createJoin("left", true);
|
|
3187
|
-
rightJoin = this.createJoin("right", false);
|
|
3188
|
-
innerJoin = this.createJoin("inner", false);
|
|
3189
|
-
innerJoinLateral = this.createJoin("inner", true);
|
|
3190
|
-
fullJoin = this.createJoin("full", false);
|
|
3191
|
-
crossJoin = this.createJoin("cross", false);
|
|
3192
|
-
crossJoinLateral = this.createJoin("cross", true);
|
|
3193
|
-
createSetOperator(type, isAll) {
|
|
3194
|
-
return (rightSelection) => {
|
|
3195
|
-
const rightSelect = typeof rightSelection === "function" ? rightSelection(getPgSetOperators()) : rightSelection;
|
|
3196
|
-
if (!haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields())) {
|
|
3197
|
-
throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");
|
|
3198
|
-
}
|
|
3199
|
-
this.config.setOperators.push({ type, isAll, rightSelect });
|
|
3200
|
-
return this;
|
|
3201
|
-
};
|
|
3202
|
-
}
|
|
3203
|
-
union = this.createSetOperator("union", false);
|
|
3204
|
-
unionAll = this.createSetOperator("union", true);
|
|
3205
|
-
intersect = this.createSetOperator("intersect", false);
|
|
3206
|
-
intersectAll = this.createSetOperator("intersect", true);
|
|
3207
|
-
except = this.createSetOperator("except", false);
|
|
3208
|
-
exceptAll = this.createSetOperator("except", true);
|
|
3209
|
-
addSetOperators(setOperators) {
|
|
3210
|
-
this.config.setOperators.push(...setOperators);
|
|
3211
|
-
return this;
|
|
3212
|
-
}
|
|
3213
|
-
where(where) {
|
|
3214
|
-
if (typeof where === "function") {
|
|
3215
|
-
where = where(new Proxy(this.config.fields, new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })));
|
|
3216
|
-
}
|
|
3217
|
-
this.config.where = where;
|
|
3218
|
-
return this;
|
|
3219
|
-
}
|
|
3220
|
-
having(having) {
|
|
3221
|
-
if (typeof having === "function") {
|
|
3222
|
-
having = having(new Proxy(this.config.fields, new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })));
|
|
3223
|
-
}
|
|
3224
|
-
this.config.having = having;
|
|
3225
|
-
return this;
|
|
3226
|
-
}
|
|
3227
|
-
groupBy(...columns) {
|
|
3228
|
-
if (typeof columns[0] === "function") {
|
|
3229
|
-
const groupBy = columns[0](new Proxy(this.config.fields, new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })));
|
|
3230
|
-
this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
|
|
3231
|
-
} else {
|
|
3232
|
-
this.config.groupBy = columns;
|
|
3233
|
-
}
|
|
3234
|
-
return this;
|
|
3235
|
-
}
|
|
3236
|
-
orderBy(...columns) {
|
|
3237
|
-
if (typeof columns[0] === "function") {
|
|
3238
|
-
const orderBy = columns[0](new Proxy(this.config.fields, new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })));
|
|
3239
|
-
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
3240
|
-
if (this.config.setOperators.length > 0) {
|
|
3241
|
-
this.config.setOperators.at(-1).orderBy = orderByArray;
|
|
3242
|
-
} else {
|
|
3243
|
-
this.config.orderBy = orderByArray;
|
|
3244
|
-
}
|
|
3245
|
-
} else {
|
|
3246
|
-
const orderByArray = columns;
|
|
3247
|
-
if (this.config.setOperators.length > 0) {
|
|
3248
|
-
this.config.setOperators.at(-1).orderBy = orderByArray;
|
|
3249
|
-
} else {
|
|
3250
|
-
this.config.orderBy = orderByArray;
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
return this;
|
|
3254
|
-
}
|
|
3255
|
-
limit(limit) {
|
|
3256
|
-
if (this.config.setOperators.length > 0) {
|
|
3257
|
-
this.config.setOperators.at(-1).limit = limit;
|
|
3258
|
-
} else {
|
|
3259
|
-
this.config.limit = limit;
|
|
3260
|
-
}
|
|
3261
|
-
return this;
|
|
3262
|
-
}
|
|
3263
|
-
offset(offset) {
|
|
3264
|
-
if (this.config.setOperators.length > 0) {
|
|
3265
|
-
this.config.setOperators.at(-1).offset = offset;
|
|
3266
|
-
} else {
|
|
3267
|
-
this.config.offset = offset;
|
|
3268
|
-
}
|
|
3269
|
-
return this;
|
|
3270
|
-
}
|
|
3271
|
-
for(strength, config = {}) {
|
|
3272
|
-
this.config.lockingClause = { strength, config };
|
|
3273
|
-
return this;
|
|
3274
|
-
}
|
|
3275
|
-
getSQL() {
|
|
3276
|
-
return this.dialect.buildSelectQuery(this.config);
|
|
3277
|
-
}
|
|
3278
|
-
toSQL() {
|
|
3279
|
-
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
3280
|
-
return rest;
|
|
3281
|
-
}
|
|
3282
|
-
as(alias2) {
|
|
3283
|
-
const usedTables = [];
|
|
3284
|
-
usedTables.push(...extractUsedTable(this.config.table));
|
|
3285
|
-
if (this.config.joins) {
|
|
3286
|
-
for (const it of this.config.joins)
|
|
3287
|
-
usedTables.push(...extractUsedTable(it.table));
|
|
3288
|
-
}
|
|
3289
|
-
return new Proxy(new Subquery(this.getSQL(), this.config.fields, alias2, false, [...new Set(usedTables)]), new SelectionProxyHandler({ alias: alias2, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
|
|
3290
|
-
}
|
|
3291
|
-
getSelectedFields() {
|
|
3292
|
-
return new Proxy(this.config.fields, new SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
|
|
3293
|
-
}
|
|
3294
|
-
$dynamic() {
|
|
3295
|
-
return this;
|
|
3296
|
-
}
|
|
3297
|
-
$withCache(config) {
|
|
3298
|
-
this.cacheConfig = config === undefined ? { config: {}, enable: true, autoInvalidate: true } : config === false ? { enable: false } : { enable: true, autoInvalidate: true, ...config };
|
|
3299
|
-
return this;
|
|
3300
|
-
}
|
|
3301
|
-
};
|
|
3302
|
-
PgSelectBase = class PgSelectBase extends PgSelectQueryBuilderBase {
|
|
3303
|
-
static [entityKind] = "PgSelect";
|
|
3304
|
-
_prepare(name) {
|
|
3305
|
-
const { session, config, dialect, joinsNotNullableMap, authToken, cacheConfig, usedTables } = this;
|
|
3306
|
-
if (!session) {
|
|
3307
|
-
throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
|
3308
|
-
}
|
|
3309
|
-
const { fields } = config;
|
|
3310
|
-
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
|
3311
|
-
const fieldsList = orderSelectedFields(fields);
|
|
3312
|
-
const query = session.prepareQuery(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true, undefined, {
|
|
3313
|
-
type: "select",
|
|
3314
|
-
tables: [...usedTables]
|
|
3315
|
-
}, cacheConfig);
|
|
3316
|
-
query.joinsNotNullableMap = joinsNotNullableMap;
|
|
3317
|
-
return query.setToken(authToken);
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
prepare(name) {
|
|
3321
|
-
return this._prepare(name);
|
|
3322
|
-
}
|
|
3323
|
-
authToken;
|
|
3324
|
-
setToken(token) {
|
|
3325
|
-
this.authToken = token;
|
|
3326
|
-
return this;
|
|
3327
|
-
}
|
|
3328
|
-
execute = (placeholderValues) => {
|
|
3329
|
-
return tracer.startActiveSpan("drizzle.operation", () => {
|
|
3330
|
-
return this._prepare().execute(placeholderValues, this.authToken);
|
|
3331
|
-
});
|
|
3332
|
-
};
|
|
3333
|
-
};
|
|
3334
|
-
applyMixins(PgSelectBase, [QueryPromise]);
|
|
3335
|
-
union = createSetOperator("union", false);
|
|
3336
|
-
unionAll = createSetOperator("union", true);
|
|
3337
|
-
intersect = createSetOperator("intersect", false);
|
|
3338
|
-
intersectAll = createSetOperator("intersect", true);
|
|
3339
|
-
except = createSetOperator("except", false);
|
|
3340
|
-
exceptAll = createSetOperator("except", true);
|
|
3341
|
-
});
|
|
3342
|
-
|
|
3343
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/query-builder.js
|
|
3344
|
-
var init_query_builder2 = () => {};
|
|
3345
|
-
|
|
3346
|
-
// ../../../node_modules/drizzle-orm/pg-core/view.js
|
|
3347
|
-
var PgMaterializedViewConfig;
|
|
3348
|
-
var init_view = __esm(() => {
|
|
3349
|
-
PgMaterializedViewConfig = Symbol.for("drizzle:PgMaterializedViewConfig");
|
|
3350
|
-
});
|
|
3351
|
-
|
|
3352
|
-
// ../../../node_modules/drizzle-orm/pg-core/utils.js
|
|
3353
|
-
function extractUsedTable(table2) {
|
|
3354
|
-
if (is(table2, PgTable)) {
|
|
3355
|
-
return [table2[Schema] ? `${table2[Schema]}.${table2[Table.Symbol.BaseName]}` : table2[Table.Symbol.BaseName]];
|
|
3356
|
-
}
|
|
3357
|
-
if (is(table2, Subquery)) {
|
|
3358
|
-
return table2._.usedTables ?? [];
|
|
3359
|
-
}
|
|
3360
|
-
if (is(table2, SQL)) {
|
|
3361
|
-
return table2.usedTables ?? [];
|
|
3362
|
-
}
|
|
3363
|
-
return [];
|
|
3364
|
-
}
|
|
3365
|
-
var init_utils3 = __esm(() => {
|
|
3366
|
-
init_entity();
|
|
3367
|
-
init_table2();
|
|
3368
|
-
init_sql();
|
|
3369
|
-
init_subquery();
|
|
3370
|
-
init_table();
|
|
3371
|
-
});
|
|
3372
|
-
|
|
3373
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/delete.js
|
|
3374
|
-
var init_delete = () => {};
|
|
3375
|
-
|
|
3376
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/insert.js
|
|
3377
|
-
var init_insert = () => {};
|
|
3378
|
-
|
|
3379
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.js
|
|
3380
|
-
var init_refresh_materialized_view = () => {};
|
|
3381
|
-
|
|
3382
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/update.js
|
|
3383
|
-
var PgUpdateBase;
|
|
3384
|
-
var init_update = __esm(() => {
|
|
3385
|
-
init_entity();
|
|
3386
|
-
init_table2();
|
|
3387
|
-
init_query_promise();
|
|
3388
|
-
init_selection_proxy();
|
|
3389
|
-
init_sql();
|
|
3390
|
-
init_subquery();
|
|
3391
|
-
init_table();
|
|
3392
|
-
init_utils();
|
|
3393
|
-
init_view_common();
|
|
3394
|
-
init_utils3();
|
|
3395
|
-
PgUpdateBase = class PgUpdateBase extends QueryPromise {
|
|
3396
|
-
constructor(table2, set, session, dialect, withList) {
|
|
3397
|
-
super();
|
|
3398
|
-
this.session = session;
|
|
3399
|
-
this.dialect = dialect;
|
|
3400
|
-
this.config = { set, table: table2, withList, joins: [] };
|
|
3401
|
-
this.tableName = getTableLikeName(table2);
|
|
3402
|
-
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
3403
|
-
}
|
|
3404
|
-
static [entityKind] = "PgUpdate";
|
|
3405
|
-
config;
|
|
3406
|
-
tableName;
|
|
3407
|
-
joinsNotNullableMap;
|
|
3408
|
-
cacheConfig;
|
|
3409
|
-
from(source) {
|
|
3410
|
-
const src = source;
|
|
3411
|
-
const tableName = getTableLikeName(src);
|
|
3412
|
-
if (typeof tableName === "string") {
|
|
3413
|
-
this.joinsNotNullableMap[tableName] = true;
|
|
3414
|
-
}
|
|
3415
|
-
this.config.from = src;
|
|
3416
|
-
return this;
|
|
3417
|
-
}
|
|
3418
|
-
getTableLikeFields(table2) {
|
|
3419
|
-
if (is(table2, PgTable)) {
|
|
3420
|
-
return table2[Table.Symbol.Columns];
|
|
3421
|
-
} else if (is(table2, Subquery)) {
|
|
3422
|
-
return table2._.selectedFields;
|
|
3423
|
-
}
|
|
3424
|
-
return table2[ViewBaseConfig].selectedFields;
|
|
3425
|
-
}
|
|
3426
|
-
createJoin(joinType) {
|
|
3427
|
-
return (table2, on) => {
|
|
3428
|
-
const tableName = getTableLikeName(table2);
|
|
3429
|
-
if (typeof tableName === "string" && this.config.joins.some((join) => join.alias === tableName)) {
|
|
3430
|
-
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
3431
|
-
}
|
|
3432
|
-
if (typeof on === "function") {
|
|
3433
|
-
const from = this.config.from && !is(this.config.from, SQL) ? this.getTableLikeFields(this.config.from) : undefined;
|
|
3434
|
-
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })), from && new Proxy(from, new SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })));
|
|
3435
|
-
}
|
|
3436
|
-
this.config.joins.push({ on, table: table2, joinType, alias: tableName });
|
|
3437
|
-
if (typeof tableName === "string") {
|
|
3438
|
-
switch (joinType) {
|
|
3439
|
-
case "left": {
|
|
3440
|
-
this.joinsNotNullableMap[tableName] = false;
|
|
3441
|
-
break;
|
|
3442
|
-
}
|
|
3443
|
-
case "right": {
|
|
3444
|
-
this.joinsNotNullableMap = Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false]));
|
|
3445
|
-
this.joinsNotNullableMap[tableName] = true;
|
|
3446
|
-
break;
|
|
3447
|
-
}
|
|
3448
|
-
case "inner": {
|
|
3449
|
-
this.joinsNotNullableMap[tableName] = true;
|
|
3450
|
-
break;
|
|
3451
|
-
}
|
|
3452
|
-
case "full": {
|
|
3453
|
-
this.joinsNotNullableMap = Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false]));
|
|
3454
|
-
this.joinsNotNullableMap[tableName] = false;
|
|
3455
|
-
break;
|
|
3456
|
-
}
|
|
3457
|
-
}
|
|
3458
|
-
}
|
|
3459
|
-
return this;
|
|
3460
|
-
};
|
|
3461
|
-
}
|
|
3462
|
-
leftJoin = this.createJoin("left");
|
|
3463
|
-
rightJoin = this.createJoin("right");
|
|
3464
|
-
innerJoin = this.createJoin("inner");
|
|
3465
|
-
fullJoin = this.createJoin("full");
|
|
3466
|
-
where(where) {
|
|
3467
|
-
this.config.where = where;
|
|
3468
|
-
return this;
|
|
3469
|
-
}
|
|
3470
|
-
returning(fields) {
|
|
3471
|
-
if (!fields) {
|
|
3472
|
-
fields = Object.assign({}, this.config.table[Table.Symbol.Columns]);
|
|
3473
|
-
if (this.config.from) {
|
|
3474
|
-
const tableName = getTableLikeName(this.config.from);
|
|
3475
|
-
if (typeof tableName === "string" && this.config.from && !is(this.config.from, SQL)) {
|
|
3476
|
-
const fromFields = this.getTableLikeFields(this.config.from);
|
|
3477
|
-
fields[tableName] = fromFields;
|
|
3478
|
-
}
|
|
3479
|
-
for (const join of this.config.joins) {
|
|
3480
|
-
const tableName2 = getTableLikeName(join.table);
|
|
3481
|
-
if (typeof tableName2 === "string" && !is(join.table, SQL)) {
|
|
3482
|
-
const fromFields = this.getTableLikeFields(join.table);
|
|
3483
|
-
fields[tableName2] = fromFields;
|
|
3484
|
-
}
|
|
3485
|
-
}
|
|
3486
|
-
}
|
|
3487
|
-
}
|
|
3488
|
-
this.config.returningFields = fields;
|
|
3489
|
-
this.config.returning = orderSelectedFields(fields);
|
|
3490
|
-
return this;
|
|
3491
|
-
}
|
|
3492
|
-
getSQL() {
|
|
3493
|
-
return this.dialect.buildUpdateQuery(this.config);
|
|
3494
|
-
}
|
|
3495
|
-
toSQL() {
|
|
3496
|
-
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
3497
|
-
return rest;
|
|
3498
|
-
}
|
|
3499
|
-
_prepare(name) {
|
|
3500
|
-
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {
|
|
3501
|
-
type: "insert",
|
|
3502
|
-
tables: extractUsedTable(this.config.table)
|
|
3503
|
-
}, this.cacheConfig);
|
|
3504
|
-
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
|
3505
|
-
return query;
|
|
3506
|
-
}
|
|
3507
|
-
prepare(name) {
|
|
3508
|
-
return this._prepare(name);
|
|
3509
|
-
}
|
|
3510
|
-
authToken;
|
|
3511
|
-
setToken(token) {
|
|
3512
|
-
this.authToken = token;
|
|
3513
|
-
return this;
|
|
3514
|
-
}
|
|
3515
|
-
execute = (placeholderValues) => {
|
|
3516
|
-
return this._prepare().execute(placeholderValues, this.authToken);
|
|
3517
|
-
};
|
|
3518
|
-
getSelectedFields() {
|
|
3519
|
-
return this.config.returningFields ? new Proxy(this.config.returningFields, new SelectionProxyHandler({
|
|
3520
|
-
alias: getTableName(this.config.table),
|
|
3521
|
-
sqlAliasedBehavior: "alias",
|
|
3522
|
-
sqlBehavior: "error"
|
|
3523
|
-
})) : undefined;
|
|
3524
|
-
}
|
|
3525
|
-
$dynamic() {
|
|
3526
|
-
return this;
|
|
3527
|
-
}
|
|
3528
|
-
};
|
|
3529
|
-
});
|
|
3530
|
-
|
|
3531
|
-
// ../../../node_modules/drizzle-orm/pg-core/query-builders/index.js
|
|
3532
|
-
var init_query_builders = __esm(() => {
|
|
3533
|
-
init_delete();
|
|
3534
|
-
init_insert();
|
|
3535
|
-
init_query_builder2();
|
|
3536
|
-
init_refresh_materialized_view();
|
|
3537
|
-
init_select2();
|
|
3538
|
-
init_update();
|
|
3539
|
-
});
|
|
3540
|
-
|
|
3541
|
-
// ../../../node_modules/drizzle-orm/pg-core/db.js
|
|
3542
|
-
var init_db = () => {};
|
|
3543
|
-
|
|
3544
|
-
// ../../../node_modules/drizzle-orm/pg-core/roles.js
|
|
3545
|
-
var init_roles = () => {};
|
|
3546
|
-
|
|
3547
|
-
// ../../../node_modules/drizzle-orm/pg-core/sequence.js
|
|
3548
|
-
var init_sequence = () => {};
|
|
3549
|
-
|
|
3550
|
-
// ../../../node_modules/drizzle-orm/pg-core/schema.js
|
|
3551
|
-
var init_schema = () => {};
|
|
3552
|
-
|
|
3553
|
-
// ../../../node_modules/drizzle-orm/pg-core/session.js
|
|
3554
|
-
var init_session = () => {};
|
|
3555
|
-
|
|
3556
|
-
// ../../../node_modules/drizzle-orm/pg-core/utils/index.js
|
|
3557
|
-
var init_utils4 = __esm(() => {
|
|
3558
|
-
init_array();
|
|
3559
|
-
});
|
|
3560
|
-
|
|
3561
|
-
// ../../../node_modules/drizzle-orm/pg-core/index.js
|
|
3562
|
-
var init_pg_core = __esm(() => {
|
|
3563
|
-
init_alias2();
|
|
3564
|
-
init_checks();
|
|
3565
|
-
init_columns();
|
|
3566
|
-
init_db();
|
|
3567
|
-
init_dialect();
|
|
3568
|
-
init_foreign_keys();
|
|
3569
|
-
init_indexes();
|
|
3570
|
-
init_policies();
|
|
3571
|
-
init_primary_keys();
|
|
3572
|
-
init_query_builders();
|
|
3573
|
-
init_roles();
|
|
3574
|
-
init_schema();
|
|
3575
|
-
init_sequence();
|
|
3576
|
-
init_session();
|
|
3577
|
-
init_table2();
|
|
3578
|
-
init_unique_constraint();
|
|
3579
|
-
init_utils3();
|
|
3580
|
-
init_utils4();
|
|
3581
|
-
init_view_common2();
|
|
3582
|
-
init_view();
|
|
3583
|
-
});
|
|
3584
|
-
|
|
3585
91
|
// schema.ts
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
92
|
+
import { relations } from "drizzle-orm";
|
|
93
|
+
import {
|
|
94
|
+
boolean,
|
|
95
|
+
index,
|
|
96
|
+
jsonb,
|
|
97
|
+
pgSchema,
|
|
98
|
+
text,
|
|
99
|
+
timestamp,
|
|
100
|
+
uniqueIndex,
|
|
101
|
+
uuid
|
|
102
|
+
} from "drizzle-orm/pg-core";
|
|
103
|
+
var goalsSchemaNamespace, goalsTable, goalTagsTable, goalsRelations, goalTagsRelations, goalSchema;
|
|
104
|
+
var init_schema = __esm(() => {
|
|
105
|
+
goalsSchemaNamespace = pgSchema("goals");
|
|
106
|
+
goalsTable = goalsSchemaNamespace.table("goals", {
|
|
3591
107
|
id: uuid("id").notNull().primaryKey(),
|
|
3592
108
|
agentId: uuid("agent_id").notNull(),
|
|
3593
109
|
ownerType: text("owner_type").notNull(),
|
|
@@ -3599,24 +115,24 @@ var init_schema2 = __esm(() => {
|
|
|
3599
115
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
3600
116
|
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
3601
117
|
metadata: jsonb("metadata").$type().default({}).notNull()
|
|
3602
|
-
}, (
|
|
3603
|
-
agentIdIndex: index("idx_goals_agent").on(
|
|
3604
|
-
ownerTypeIndex: index("idx_goals_owner_type").on(
|
|
3605
|
-
ownerIdIndex: index("idx_goals_owner_id").on(
|
|
3606
|
-
completedIndex: index("idx_goals_completed").on(
|
|
3607
|
-
createdAtIndex: index("idx_goals_created_at").on(
|
|
118
|
+
}, (table) => ({
|
|
119
|
+
agentIdIndex: index("idx_goals_agent").on(table.agentId),
|
|
120
|
+
ownerTypeIndex: index("idx_goals_owner_type").on(table.ownerType),
|
|
121
|
+
ownerIdIndex: index("idx_goals_owner_id").on(table.ownerId),
|
|
122
|
+
completedIndex: index("idx_goals_completed").on(table.isCompleted),
|
|
123
|
+
createdAtIndex: index("idx_goals_created_at").on(table.createdAt)
|
|
3608
124
|
}));
|
|
3609
|
-
goalTagsTable =
|
|
125
|
+
goalTagsTable = goalsSchemaNamespace.table("goal_tags", {
|
|
3610
126
|
id: uuid("id").notNull().primaryKey(),
|
|
3611
127
|
goalId: uuid("goal_id").references(() => goalsTable.id, {
|
|
3612
128
|
onDelete: "cascade"
|
|
3613
129
|
}).notNull(),
|
|
3614
130
|
tag: text("tag").notNull(),
|
|
3615
131
|
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
3616
|
-
}, (
|
|
3617
|
-
goalIdIndex: index("idx_goal_tags_goal").on(
|
|
3618
|
-
tagIndex: index("idx_goal_tags_tag").on(
|
|
3619
|
-
uniqueGoalTag: uniqueIndex("unique_goal_tag").on(
|
|
132
|
+
}, (table) => ({
|
|
133
|
+
goalIdIndex: index("idx_goal_tags_goal").on(table.goalId),
|
|
134
|
+
tagIndex: index("idx_goal_tags_tag").on(table.tag),
|
|
135
|
+
uniqueGoalTag: uniqueIndex("unique_goal_tag").on(table.goalId, table.tag)
|
|
3620
136
|
}));
|
|
3621
137
|
goalsRelations = relations(goalsTable, ({ many }) => ({
|
|
3622
138
|
tags: many(goalTagsTable)
|
|
@@ -3644,7 +160,8 @@ __export(exports_goalDataService, {
|
|
|
3644
160
|
GoalDataServiceWrapper: () => GoalDataServiceWrapper,
|
|
3645
161
|
GoalDataService: () => GoalDataService
|
|
3646
162
|
});
|
|
3647
|
-
import { asUUID, logger
|
|
163
|
+
import { asUUID, logger, Service } from "@elizaos/core";
|
|
164
|
+
import { and, asc, eq, inArray } from "drizzle-orm";
|
|
3648
165
|
|
|
3649
166
|
class GoalDataService {
|
|
3650
167
|
runtime;
|
|
@@ -3653,8 +170,8 @@ class GoalDataService {
|
|
|
3653
170
|
}
|
|
3654
171
|
async createGoal(params) {
|
|
3655
172
|
try {
|
|
3656
|
-
const
|
|
3657
|
-
if (!
|
|
173
|
+
const db = this.runtime.db;
|
|
174
|
+
if (!db)
|
|
3658
175
|
throw new Error("Database not available");
|
|
3659
176
|
const goalId = asUUID(v4_default());
|
|
3660
177
|
const values = {
|
|
@@ -3668,7 +185,7 @@ class GoalDataService {
|
|
|
3668
185
|
if (params.description !== undefined) {
|
|
3669
186
|
values.description = params.description;
|
|
3670
187
|
}
|
|
3671
|
-
const [goal] = await
|
|
188
|
+
const [goal] = await db.insert(goalsTable).values(values).returning();
|
|
3672
189
|
if (!goal)
|
|
3673
190
|
return null;
|
|
3674
191
|
if (params.tags && params.tags.length > 0) {
|
|
@@ -3677,34 +194,34 @@ class GoalDataService {
|
|
|
3677
194
|
goalId,
|
|
3678
195
|
tag
|
|
3679
196
|
}));
|
|
3680
|
-
await
|
|
197
|
+
await db.insert(goalTagsTable).values(tagInserts);
|
|
3681
198
|
}
|
|
3682
199
|
return goalId;
|
|
3683
200
|
} catch (error) {
|
|
3684
|
-
|
|
201
|
+
logger.error("Error creating goal:", error instanceof Error ? error.message : String(error));
|
|
3685
202
|
throw error;
|
|
3686
203
|
}
|
|
3687
204
|
}
|
|
3688
205
|
async getGoals(filters) {
|
|
3689
206
|
try {
|
|
3690
|
-
const
|
|
3691
|
-
if (!
|
|
207
|
+
const db = this.runtime.db;
|
|
208
|
+
if (!db)
|
|
3692
209
|
throw new Error("Database not available");
|
|
3693
|
-
const
|
|
210
|
+
const conditions = [];
|
|
3694
211
|
if (filters?.ownerType) {
|
|
3695
|
-
|
|
212
|
+
conditions.push(eq(goalsTable.ownerType, filters.ownerType));
|
|
3696
213
|
}
|
|
3697
214
|
if (filters?.ownerId) {
|
|
3698
|
-
|
|
215
|
+
conditions.push(eq(goalsTable.ownerId, filters.ownerId));
|
|
3699
216
|
}
|
|
3700
217
|
if (filters?.isCompleted !== undefined) {
|
|
3701
|
-
|
|
218
|
+
conditions.push(eq(goalsTable.isCompleted, filters.isCompleted));
|
|
3702
219
|
}
|
|
3703
|
-
const goals = await
|
|
220
|
+
const goals = await db.select().from(goalsTable).where(conditions.length > 0 ? and(...conditions) : undefined).orderBy(asc(goalsTable.createdAt));
|
|
3704
221
|
const goalIds = goals.map((goal) => asUUID(goal.id));
|
|
3705
222
|
if (goalIds.length === 0)
|
|
3706
223
|
return [];
|
|
3707
|
-
const tags = await
|
|
224
|
+
const tags = await db.select().from(goalTagsTable).where(goalIds.length === 1 ? eq(goalTagsTable.goalId, goalIds[0]) : inArray(goalTagsTable.goalId, goalIds));
|
|
3708
225
|
const tagsByGoal = tags.reduce((acc, tag) => {
|
|
3709
226
|
const tagGoalId = asUUID(tag.goalId);
|
|
3710
227
|
if (!acc[tagGoalId])
|
|
@@ -3735,19 +252,19 @@ class GoalDataService {
|
|
|
3735
252
|
};
|
|
3736
253
|
});
|
|
3737
254
|
} catch (error) {
|
|
3738
|
-
|
|
255
|
+
logger.error("Error getting goals:", error instanceof Error ? error.message : String(error));
|
|
3739
256
|
throw error;
|
|
3740
257
|
}
|
|
3741
258
|
}
|
|
3742
259
|
async getGoal(goalId) {
|
|
3743
260
|
try {
|
|
3744
|
-
const
|
|
3745
|
-
if (!
|
|
261
|
+
const db = this.runtime.db;
|
|
262
|
+
if (!db)
|
|
3746
263
|
throw new Error("Database not available");
|
|
3747
|
-
const [goal] = await
|
|
264
|
+
const [goal] = await db.select().from(goalsTable).where(eq(goalsTable.id, goalId));
|
|
3748
265
|
if (!goal)
|
|
3749
266
|
return null;
|
|
3750
|
-
const tags = await
|
|
267
|
+
const tags = await db.select().from(goalTagsTable).where(eq(goalTagsTable.goalId, goalId));
|
|
3751
268
|
return {
|
|
3752
269
|
...goal,
|
|
3753
270
|
id: asUUID(goal.id),
|
|
@@ -3759,14 +276,14 @@ class GoalDataService {
|
|
|
3759
276
|
completedAt: goal.completedAt ? new Date(goal.completedAt) : null
|
|
3760
277
|
};
|
|
3761
278
|
} catch (error) {
|
|
3762
|
-
|
|
279
|
+
logger.error("Error getting goal:", error instanceof Error ? error.message : String(error));
|
|
3763
280
|
throw error;
|
|
3764
281
|
}
|
|
3765
282
|
}
|
|
3766
283
|
async updateGoal(goalId, updates) {
|
|
3767
284
|
try {
|
|
3768
|
-
const
|
|
3769
|
-
if (!
|
|
285
|
+
const db = this.runtime.db;
|
|
286
|
+
if (!db)
|
|
3770
287
|
throw new Error("Database not available");
|
|
3771
288
|
const fieldsToUpdate = {
|
|
3772
289
|
updatedAt: new Date
|
|
@@ -3781,44 +298,44 @@ class GoalDataService {
|
|
|
3781
298
|
fieldsToUpdate.completedAt = updates.completedAt;
|
|
3782
299
|
if (updates.metadata !== undefined)
|
|
3783
300
|
fieldsToUpdate.metadata = updates.metadata;
|
|
3784
|
-
await
|
|
301
|
+
await db.update(goalsTable).set(fieldsToUpdate).where(eq(goalsTable.id, goalId));
|
|
3785
302
|
if (updates.tags !== undefined) {
|
|
3786
|
-
await
|
|
303
|
+
await db.delete(goalTagsTable).where(eq(goalTagsTable.goalId, goalId));
|
|
3787
304
|
if (updates.tags.length > 0) {
|
|
3788
305
|
const tagInserts = updates.tags.map((tag) => ({
|
|
3789
306
|
id: asUUID(v4_default()),
|
|
3790
307
|
goalId,
|
|
3791
308
|
tag
|
|
3792
309
|
}));
|
|
3793
|
-
await
|
|
310
|
+
await db.insert(goalTagsTable).values(tagInserts);
|
|
3794
311
|
}
|
|
3795
312
|
}
|
|
3796
313
|
return true;
|
|
3797
314
|
} catch (error) {
|
|
3798
|
-
|
|
315
|
+
logger.error("Error updating goal:", error instanceof Error ? error.message : String(error));
|
|
3799
316
|
throw error;
|
|
3800
317
|
}
|
|
3801
318
|
}
|
|
3802
319
|
async deleteGoal(goalId) {
|
|
3803
320
|
try {
|
|
3804
|
-
const
|
|
3805
|
-
if (!
|
|
321
|
+
const db = this.runtime.db;
|
|
322
|
+
if (!db)
|
|
3806
323
|
throw new Error("Database not available");
|
|
3807
|
-
await
|
|
324
|
+
await db.delete(goalsTable).where(eq(goalsTable.id, goalId));
|
|
3808
325
|
return true;
|
|
3809
326
|
} catch (error) {
|
|
3810
|
-
|
|
327
|
+
logger.error("Error deleting goal:", error instanceof Error ? error.message : String(error));
|
|
3811
328
|
throw error;
|
|
3812
329
|
}
|
|
3813
330
|
}
|
|
3814
331
|
async getUncompletedGoals(ownerType, ownerId) {
|
|
3815
332
|
try {
|
|
3816
|
-
const
|
|
333
|
+
const conditions = [eq(goalsTable.isCompleted, false)];
|
|
3817
334
|
if (ownerType) {
|
|
3818
|
-
|
|
335
|
+
conditions.push(eq(goalsTable.ownerType, ownerType));
|
|
3819
336
|
}
|
|
3820
337
|
if (ownerId) {
|
|
3821
|
-
|
|
338
|
+
conditions.push(eq(goalsTable.ownerId, ownerId));
|
|
3822
339
|
}
|
|
3823
340
|
return this.getGoals({
|
|
3824
341
|
isCompleted: false,
|
|
@@ -3826,7 +343,7 @@ class GoalDataService {
|
|
|
3826
343
|
ownerId
|
|
3827
344
|
});
|
|
3828
345
|
} catch (error) {
|
|
3829
|
-
|
|
346
|
+
logger.error("Error getting uncompleted goals:", error instanceof Error ? error.message : String(error));
|
|
3830
347
|
throw error;
|
|
3831
348
|
}
|
|
3832
349
|
}
|
|
@@ -3838,7 +355,7 @@ class GoalDataService {
|
|
|
3838
355
|
ownerId
|
|
3839
356
|
});
|
|
3840
357
|
} catch (error) {
|
|
3841
|
-
|
|
358
|
+
logger.error("Error getting completed goals:", error instanceof Error ? error.message : String(error));
|
|
3842
359
|
throw error;
|
|
3843
360
|
}
|
|
3844
361
|
}
|
|
@@ -3851,7 +368,7 @@ class GoalDataService {
|
|
|
3851
368
|
});
|
|
3852
369
|
return goals.length;
|
|
3853
370
|
} catch (error) {
|
|
3854
|
-
|
|
371
|
+
logger.error("Error counting goals:", error instanceof Error ? error.message : String(error));
|
|
3855
372
|
throw error;
|
|
3856
373
|
}
|
|
3857
374
|
}
|
|
@@ -3862,7 +379,7 @@ class GoalDataService {
|
|
|
3862
379
|
ownerId
|
|
3863
380
|
});
|
|
3864
381
|
} catch (error) {
|
|
3865
|
-
|
|
382
|
+
logger.error("Error getting all goals for owner:", error instanceof Error ? error.message : String(error));
|
|
3866
383
|
throw error;
|
|
3867
384
|
}
|
|
3868
385
|
}
|
|
@@ -3875,9 +392,8 @@ function createGoalDataService(runtime) {
|
|
|
3875
392
|
}
|
|
3876
393
|
var GoalDataServiceWrapper;
|
|
3877
394
|
var init_goalDataService = __esm(() => {
|
|
3878
|
-
init_drizzle_orm();
|
|
3879
395
|
init_dist_node();
|
|
3880
|
-
|
|
396
|
+
init_schema();
|
|
3881
397
|
GoalDataServiceWrapper = class GoalDataServiceWrapper extends Service {
|
|
3882
398
|
static serviceName = "goalDataService";
|
|
3883
399
|
static serviceType = "GOAL_DATA";
|
|
@@ -3889,7 +405,7 @@ var init_goalDataService = __esm(() => {
|
|
|
3889
405
|
static async start(runtime) {
|
|
3890
406
|
const service = new GoalDataServiceWrapper;
|
|
3891
407
|
if (!runtime.db) {
|
|
3892
|
-
|
|
408
|
+
logger.warn("Database not available, GoalDataService will be limited");
|
|
3893
409
|
} else {
|
|
3894
410
|
service.goalDataService = new GoalDataService(runtime);
|
|
3895
411
|
}
|
|
@@ -3902,13 +418,13 @@ var init_goalDataService = __esm(() => {
|
|
|
3902
418
|
});
|
|
3903
419
|
|
|
3904
420
|
// index.ts
|
|
3905
|
-
import { logger as
|
|
421
|
+
import { logger as logger10 } from "@elizaos/core";
|
|
3906
422
|
|
|
3907
423
|
// actions/cancelGoal.ts
|
|
3908
424
|
import {
|
|
3909
425
|
composePrompt,
|
|
3910
426
|
formatMessages,
|
|
3911
|
-
logger as
|
|
427
|
+
logger as logger2,
|
|
3912
428
|
ModelType,
|
|
3913
429
|
parseKeyValueXml
|
|
3914
430
|
} from "@elizaos/core";
|
|
@@ -3927,12 +443,12 @@ Description: {{newGoalDescription}}
|
|
|
3927
443
|
Determine if the new goal is similar to any existing goals.
|
|
3928
444
|
Consider goals similar if they have the same objective, even if worded differently.
|
|
3929
445
|
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
446
|
+
Respond using TOON like this:
|
|
447
|
+
hasSimilar: true or false
|
|
448
|
+
similarGoalName: Name of the similar goal if found
|
|
449
|
+
confidence: 0-100 indicating confidence in similarity
|
|
450
|
+
|
|
451
|
+
IMPORTANT: Your response must ONLY contain the TOON document above.
|
|
3936
452
|
|
|
3937
453
|
## Example
|
|
3938
454
|
New Goal: "Get better at public speaking"
|
|
@@ -3954,26 +470,12 @@ Parse the user's message to identify which task they want to cancel or delete.
|
|
|
3954
470
|
Match against the list of available tasks by name or description.
|
|
3955
471
|
If multiple tasks have similar names, choose the closest match.
|
|
3956
472
|
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
<isFound>'true' or 'false' indicating if a matching task was found</isFound>
|
|
3962
|
-
</response>
|
|
3963
|
-
|
|
3964
|
-
## Example Output Format
|
|
3965
|
-
<response>
|
|
3966
|
-
<taskId>123e4567-e89b-12d3-a456-426614174000</taskId>
|
|
3967
|
-
<taskName>Finish report</taskName>
|
|
3968
|
-
<isFound>true</isFound>
|
|
3969
|
-
</response>
|
|
473
|
+
Respond using TOON like this:
|
|
474
|
+
taskId: ID of the goal, or empty if not found
|
|
475
|
+
taskName: Name of the goal, or empty if not found
|
|
476
|
+
isFound: true or false
|
|
3970
477
|
|
|
3971
|
-
|
|
3972
|
-
<response>
|
|
3973
|
-
<taskId>null</taskId>
|
|
3974
|
-
<taskName>null</taskName>
|
|
3975
|
-
<isFound>false</isFound>
|
|
3976
|
-
</response>`;
|
|
478
|
+
IMPORTANT: Your response must ONLY contain the TOON document above.`;
|
|
3977
479
|
var extractConfirmationTemplate = `# Task: Extract Confirmation Intent
|
|
3978
480
|
|
|
3979
481
|
## User Message
|
|
@@ -3992,19 +494,12 @@ Look for:
|
|
|
3992
494
|
- Negative responses (no, cancel, nevermind, stop, etc.)
|
|
3993
495
|
- Modification requests (change X to Y, make it priority 1, etc.)
|
|
3994
496
|
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
<modifications>Any requested changes to the task, or 'none'</modifications>
|
|
4000
|
-
</response>
|
|
497
|
+
Respond using TOON like this:
|
|
498
|
+
isConfirmation: true or false
|
|
499
|
+
shouldProceed: true or false
|
|
500
|
+
modifications: Any requested changes, or none
|
|
4001
501
|
|
|
4002
|
-
|
|
4003
|
-
<response>
|
|
4004
|
-
<isConfirmation>true</isConfirmation>
|
|
4005
|
-
<shouldProceed>true</shouldProceed>
|
|
4006
|
-
<modifications>none</modifications>
|
|
4007
|
-
</response>`;
|
|
502
|
+
IMPORTANT: Your response must ONLY contain the TOON document above.`;
|
|
4008
503
|
var extractGoalSelectionTemplate = `# Task: Extract Goal Selection Information
|
|
4009
504
|
|
|
4010
505
|
## User Message
|
|
@@ -4018,26 +513,12 @@ Parse the user's message to identify which goal they want to update or modify.
|
|
|
4018
513
|
Match against the list of available goals by name or description.
|
|
4019
514
|
If multiple goals have similar names, choose the closest match.
|
|
4020
515
|
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
<isFound>'true' or 'false' indicating if a matching goal was found</isFound>
|
|
4026
|
-
</response>
|
|
516
|
+
Respond using TOON like this:
|
|
517
|
+
goalId: ID of the goal being updated, or empty if not found
|
|
518
|
+
goalName: Name of the goal being updated, or empty if not found
|
|
519
|
+
isFound: true or false
|
|
4027
520
|
|
|
4028
|
-
|
|
4029
|
-
<response>
|
|
4030
|
-
<goalId>123e4567-e89b-12d3-a456-426614174000</goalId>
|
|
4031
|
-
<goalName>Learn French fluently</goalName>
|
|
4032
|
-
<isFound>true</isFound>
|
|
4033
|
-
</response>
|
|
4034
|
-
|
|
4035
|
-
If no matching goal was found:
|
|
4036
|
-
<response>
|
|
4037
|
-
<goalId>null</goalId>
|
|
4038
|
-
<goalName>null</goalName>
|
|
4039
|
-
<isFound>false</isFound>
|
|
4040
|
-
</response>`;
|
|
521
|
+
IMPORTANT: Your response must ONLY contain the TOON document above.`;
|
|
4041
522
|
var extractGoalTemplate = `# Task: Extract Goal Information
|
|
4042
523
|
|
|
4043
524
|
## User Message
|
|
@@ -4052,21 +533,12 @@ Determine if this goal is for the agent itself or for tracking a user's goal.
|
|
|
4052
533
|
|
|
4053
534
|
Goals should be long-term achievable objectives, not short-term tasks.
|
|
4054
535
|
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
<ownerType>Either "agent" (for agent's own goals) or "entity" (for user's goals)</ownerType>
|
|
4060
|
-
</response>
|
|
4061
|
-
|
|
4062
|
-
If the message doesn't clearly indicate a goal to create, return empty response.
|
|
536
|
+
Respond using TOON like this:
|
|
537
|
+
name: Name of the goal
|
|
538
|
+
description: Optional description
|
|
539
|
+
ownerType: agent or entity
|
|
4063
540
|
|
|
4064
|
-
|
|
4065
|
-
<response>
|
|
4066
|
-
<name>Learn Spanish fluently</name>
|
|
4067
|
-
<description>Achieve conversational fluency in Spanish within 6 months</description>
|
|
4068
|
-
<ownerType>entity</ownerType>
|
|
4069
|
-
</response>`;
|
|
541
|
+
IMPORTANT: Your response must ONLY contain the TOON document above.`;
|
|
4070
542
|
var extractGoalUpdateTemplate = `# Task: Extract Goal Update Information
|
|
4071
543
|
|
|
4072
544
|
## User Message
|
|
@@ -4079,25 +551,44 @@ var extractGoalUpdateTemplate = `# Task: Extract Goal Update Information
|
|
|
4079
551
|
Parse the user's message to determine what changes they want to make to the goal.
|
|
4080
552
|
Only name and description can be updated.
|
|
4081
553
|
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
<description>New description for the goal</description>
|
|
4086
|
-
</response>
|
|
554
|
+
Respond using TOON like this (only include fields that should be changed):
|
|
555
|
+
name: New name for the goal
|
|
556
|
+
description: New description for the goal
|
|
4087
557
|
|
|
4088
|
-
|
|
4089
|
-
<response>
|
|
4090
|
-
<name>Learn Spanish fluently</name>
|
|
4091
|
-
<description>Achieve conversational fluency in Spanish within 12 months</description>
|
|
4092
|
-
</response>`;
|
|
558
|
+
IMPORTANT: Your response must ONLY contain the TOON document above.`;
|
|
4093
559
|
|
|
4094
560
|
// generated/specs/specs.ts
|
|
4095
561
|
var coreActionsSpec = {
|
|
4096
562
|
version: "1.0.0",
|
|
4097
563
|
actions: [
|
|
4098
564
|
{
|
|
4099
|
-
name: "
|
|
4100
|
-
description: "",
|
|
565
|
+
name: "CREATE_GOAL",
|
|
566
|
+
description: "Create a new goal or task for the user to track progress on",
|
|
567
|
+
similes: ["ADD_GOAL", "NEW_GOAL", "SET_GOAL", "ADD_TASK", "CREATE_TASK"],
|
|
568
|
+
parameters: []
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
name: "UPDATE_GOAL",
|
|
572
|
+
description: "Update an existing goal's name, description, or progress",
|
|
573
|
+
similes: ["EDIT_GOAL", "MODIFY_GOAL", "CHANGE_GOAL", "UPDATE_TASK"],
|
|
574
|
+
parameters: []
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: "CANCEL_GOAL",
|
|
578
|
+
description: "Cancel or remove an existing goal that is no longer needed",
|
|
579
|
+
similes: ["DELETE_GOAL", "REMOVE_GOAL", "ABANDON_GOAL", "CANCEL_TASK"],
|
|
580
|
+
parameters: []
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: "COMPLETE_GOAL",
|
|
584
|
+
description: "Mark a goal as completed when it has been achieved",
|
|
585
|
+
similes: ["FINISH_GOAL", "DONE_GOAL", "ACHIEVE_GOAL", "COMPLETE_TASK"],
|
|
586
|
+
parameters: []
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
name: "CONFIRM_GOAL",
|
|
590
|
+
description: "Confirm and finalize a pending goal that was proposed",
|
|
591
|
+
similes: ["APPROVE_GOAL", "ACCEPT_GOAL", "VERIFY_GOAL", "CONFIRM_TASK"],
|
|
4101
592
|
parameters: []
|
|
4102
593
|
}
|
|
4103
594
|
]
|
|
@@ -4106,8 +597,33 @@ var allActionsSpec = {
|
|
|
4106
597
|
version: "1.0.0",
|
|
4107
598
|
actions: [
|
|
4108
599
|
{
|
|
4109
|
-
name: "
|
|
4110
|
-
description: "",
|
|
600
|
+
name: "CREATE_GOAL",
|
|
601
|
+
description: "Create a new goal or task for the user to track progress on",
|
|
602
|
+
similes: ["ADD_GOAL", "NEW_GOAL", "SET_GOAL", "ADD_TASK", "CREATE_TASK"],
|
|
603
|
+
parameters: []
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: "UPDATE_GOAL",
|
|
607
|
+
description: "Update an existing goal's name, description, or progress",
|
|
608
|
+
similes: ["EDIT_GOAL", "MODIFY_GOAL", "CHANGE_GOAL", "UPDATE_TASK"],
|
|
609
|
+
parameters: []
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
name: "CANCEL_GOAL",
|
|
613
|
+
description: "Cancel or remove an existing goal that is no longer needed",
|
|
614
|
+
similes: ["DELETE_GOAL", "REMOVE_GOAL", "ABANDON_GOAL", "CANCEL_TASK"],
|
|
615
|
+
parameters: []
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
name: "COMPLETE_GOAL",
|
|
619
|
+
description: "Mark a goal as completed when it has been achieved",
|
|
620
|
+
similes: ["FINISH_GOAL", "DONE_GOAL", "ACHIEVE_GOAL", "COMPLETE_TASK"],
|
|
621
|
+
parameters: []
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: "CONFIRM_GOAL",
|
|
625
|
+
description: "Confirm and finalize a pending goal that was proposed",
|
|
626
|
+
similes: ["APPROVE_GOAL", "ACCEPT_GOAL", "VERIFY_GOAL", "CONFIRM_TASK"],
|
|
4111
627
|
parameters: []
|
|
4112
628
|
}
|
|
4113
629
|
]
|
|
@@ -4205,9 +721,9 @@ Tags: ${task.tags?.join(", ") || "none"}
|
|
|
4205
721
|
stopSequences: []
|
|
4206
722
|
});
|
|
4207
723
|
const parsedResult = parseKeyValueXml(result);
|
|
4208
|
-
|
|
724
|
+
logger2.debug({ parsedResult }, "Parsed structured output result");
|
|
4209
725
|
if (!parsedResult || typeof parsedResult.isFound === "undefined") {
|
|
4210
|
-
|
|
726
|
+
logger2.error("Failed to parse valid task cancellation information from structured output");
|
|
4211
727
|
return { taskId: "", taskName: "", isFound: false };
|
|
4212
728
|
}
|
|
4213
729
|
const finalResult = {
|
|
@@ -4217,7 +733,7 @@ Tags: ${task.tags?.join(", ") || "none"}
|
|
|
4217
733
|
};
|
|
4218
734
|
return finalResult;
|
|
4219
735
|
} catch (error) {
|
|
4220
|
-
|
|
736
|
+
logger2.error("Error extracting task cancellation information:", error);
|
|
4221
737
|
return { taskId: "", taskName: "", isFound: false };
|
|
4222
738
|
}
|
|
4223
739
|
}
|
|
@@ -4226,20 +742,41 @@ var cancelGoalAction = {
|
|
|
4226
742
|
name: spec.name,
|
|
4227
743
|
similes: spec.similes ? [...spec.similes] : [],
|
|
4228
744
|
description: spec.description,
|
|
4229
|
-
validate: async (runtime, message) => {
|
|
4230
|
-
|
|
4231
|
-
|
|
745
|
+
validate: async (runtime, message, state, options) => {
|
|
746
|
+
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
747
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
748
|
+
const __avKeywords = ["cancel", "goal"];
|
|
749
|
+
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
750
|
+
const __avRegex = /\b(?:cancel|goal)\b/i;
|
|
751
|
+
const __avRegexOk = Boolean(__avText.match(__avRegex));
|
|
752
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
753
|
+
const __avExpectedSource = "";
|
|
754
|
+
const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
755
|
+
const __avOptions = options && typeof options === "object" ? options : {};
|
|
756
|
+
const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
|
|
757
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
const __avLegacyValidate = async (runtime2, message2) => {
|
|
761
|
+
try {
|
|
762
|
+
if (!message2.roomId) {
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
const dataService = createGoalDataService(runtime2);
|
|
766
|
+
const goals = await dataService.getGoals({
|
|
767
|
+
ownerType: "entity",
|
|
768
|
+
ownerId: message2.entityId,
|
|
769
|
+
isCompleted: false
|
|
770
|
+
});
|
|
771
|
+
return goals.length > 0;
|
|
772
|
+
} catch (error) {
|
|
773
|
+
logger2.error("Error validating CANCEL_GOAL action:", error);
|
|
4232
774
|
return false;
|
|
4233
775
|
}
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
isCompleted: false
|
|
4239
|
-
});
|
|
4240
|
-
return goals.length > 0;
|
|
4241
|
-
} catch (error) {
|
|
4242
|
-
logger3.error("Error validating CANCEL_GOAL action:", error);
|
|
776
|
+
};
|
|
777
|
+
try {
|
|
778
|
+
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
779
|
+
} catch {
|
|
4243
780
|
return false;
|
|
4244
781
|
}
|
|
4245
782
|
},
|
|
@@ -4323,7 +860,7 @@ Please specify which one you'd like to cancel.`,
|
|
|
4323
860
|
}
|
|
4324
861
|
return { success: true, text: "Goal cancelled" };
|
|
4325
862
|
} catch (error) {
|
|
4326
|
-
|
|
863
|
+
logger2.error("Error in cancelGoal handler:", error);
|
|
4327
864
|
if (callback) {
|
|
4328
865
|
await callback({
|
|
4329
866
|
text: "I encountered an error while trying to cancel your task. Please try again.",
|
|
@@ -4343,7 +880,7 @@ Please specify which one you'd like to cancel.`,
|
|
|
4343
880
|
// actions/completeGoal.ts
|
|
4344
881
|
import {
|
|
4345
882
|
asUUID as asUUID2,
|
|
4346
|
-
logger as
|
|
883
|
+
logger as logger3,
|
|
4347
884
|
ModelType as ModelType2
|
|
4348
885
|
} from "@elizaos/core";
|
|
4349
886
|
init_goalDataService();
|
|
@@ -4352,15 +889,36 @@ var completeGoalAction = {
|
|
|
4352
889
|
name: spec2.name,
|
|
4353
890
|
similes: spec2.similes ? [...spec2.similes] : [],
|
|
4354
891
|
description: spec2.description,
|
|
4355
|
-
validate: async (
|
|
4356
|
-
|
|
4357
|
-
|
|
892
|
+
validate: async (runtime, message, state, options) => {
|
|
893
|
+
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
894
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
895
|
+
const __avKeywords = ["complete", "goal"];
|
|
896
|
+
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
897
|
+
const __avRegex = /\b(?:complete|goal)\b/i;
|
|
898
|
+
const __avRegexOk = Boolean(__avText.match(__avRegex));
|
|
899
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
900
|
+
const __avExpectedSource = "";
|
|
901
|
+
const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
902
|
+
const __avOptions = options && typeof options === "object" ? options : {};
|
|
903
|
+
const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
|
|
904
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
905
|
+
return false;
|
|
906
|
+
}
|
|
907
|
+
const __avLegacyValidate = async (_runtime, message2, _state) => {
|
|
908
|
+
if (!message2.roomId) {
|
|
909
|
+
logger3.warn("No roomId provided for complete goal validation");
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
const messageText = message2.content?.text?.toLowerCase() || "";
|
|
913
|
+
const hasCompleteIntent = messageText.includes("complete") || messageText.includes("achieve") || messageText.includes("finish") || messageText.includes("done") || messageText.includes("accomplished");
|
|
914
|
+
logger3.info({ hasCompleteIntent, messageText: messageText.substring(0, 100) }, "Complete goal validation");
|
|
915
|
+
return hasCompleteIntent;
|
|
916
|
+
};
|
|
917
|
+
try {
|
|
918
|
+
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
919
|
+
} catch {
|
|
4358
920
|
return false;
|
|
4359
921
|
}
|
|
4360
|
-
const messageText = message.content?.text?.toLowerCase() || "";
|
|
4361
|
-
const hasCompleteIntent = messageText.includes("complete") || messageText.includes("achieve") || messageText.includes("finish") || messageText.includes("done") || messageText.includes("accomplished");
|
|
4362
|
-
logger4.info({ hasCompleteIntent, messageText: messageText.substring(0, 100) }, "Complete goal validation");
|
|
4363
|
-
return hasCompleteIntent;
|
|
4364
922
|
},
|
|
4365
923
|
handler: async (runtime, message, _state, _options, callback) => {
|
|
4366
924
|
try {
|
|
@@ -4448,7 +1006,7 @@ Please be more specific.`;
|
|
|
4448
1006
|
}
|
|
4449
1007
|
};
|
|
4450
1008
|
} catch (error) {
|
|
4451
|
-
|
|
1009
|
+
logger3.error("Error completing goal:", error);
|
|
4452
1010
|
const errorMessage = error instanceof Error ? error.message : "Failed to complete goal";
|
|
4453
1011
|
if (callback) {
|
|
4454
1012
|
await callback({
|
|
@@ -4515,7 +1073,7 @@ Please be more specific.`;
|
|
|
4515
1073
|
import {
|
|
4516
1074
|
composePrompt as composePrompt2,
|
|
4517
1075
|
formatMessages as formatMessages2,
|
|
4518
|
-
logger as
|
|
1076
|
+
logger as logger4,
|
|
4519
1077
|
ModelType as ModelType3,
|
|
4520
1078
|
parseKeyValueXml as parseKeyValueXml2
|
|
4521
1079
|
} from "@elizaos/core";
|
|
@@ -4551,7 +1109,7 @@ ${pendingTask.recurring ? `Recurring: ${pendingTask.recurring}` : ""}
|
|
|
4551
1109
|
});
|
|
4552
1110
|
const parsedResult = parseKeyValueXml2(result);
|
|
4553
1111
|
if (!parsedResult) {
|
|
4554
|
-
|
|
1112
|
+
logger4.error("Failed to parse confirmation response");
|
|
4555
1113
|
return { isConfirmation: false, shouldProceed: false };
|
|
4556
1114
|
}
|
|
4557
1115
|
return {
|
|
@@ -4560,7 +1118,7 @@ ${pendingTask.recurring ? `Recurring: ${pendingTask.recurring}` : ""}
|
|
|
4560
1118
|
modifications: parsedResult.modifications === "none" ? undefined : parsedResult.modifications
|
|
4561
1119
|
};
|
|
4562
1120
|
} catch (error) {
|
|
4563
|
-
|
|
1121
|
+
logger4.error("Error extracting confirmation intent:", error);
|
|
4564
1122
|
return { isConfirmation: false, shouldProceed: false };
|
|
4565
1123
|
}
|
|
4566
1124
|
}
|
|
@@ -4569,9 +1127,30 @@ var confirmGoalAction = {
|
|
|
4569
1127
|
name: spec3.name,
|
|
4570
1128
|
similes: spec3.similes ? [...spec3.similes] : [],
|
|
4571
1129
|
description: spec3.description,
|
|
4572
|
-
validate: async (
|
|
4573
|
-
const
|
|
4574
|
-
|
|
1130
|
+
validate: async (runtime, message, state, options) => {
|
|
1131
|
+
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
1132
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
1133
|
+
const __avKeywords = ["confirm", "goal"];
|
|
1134
|
+
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
1135
|
+
const __avRegex = /\b(?:confirm|goal)\b/i;
|
|
1136
|
+
const __avRegexOk = Boolean(__avText.match(__avRegex));
|
|
1137
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
1138
|
+
const __avExpectedSource = "";
|
|
1139
|
+
const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
1140
|
+
const __avOptions = options && typeof options === "object" ? options : {};
|
|
1141
|
+
const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
|
|
1142
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
1143
|
+
return false;
|
|
1144
|
+
}
|
|
1145
|
+
const __avLegacyValidate = async (_runtime, _message, state2) => {
|
|
1146
|
+
const pendingGoal = state2?.data?.pendingGoal;
|
|
1147
|
+
return !!pendingGoal;
|
|
1148
|
+
};
|
|
1149
|
+
try {
|
|
1150
|
+
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
1151
|
+
} catch {
|
|
1152
|
+
return false;
|
|
1153
|
+
}
|
|
4575
1154
|
},
|
|
4576
1155
|
handler: async (runtime, message, state, _options, callback) => {
|
|
4577
1156
|
try {
|
|
@@ -4691,7 +1270,7 @@ I created the task as originally described. The modifications you mentioned ("${
|
|
|
4691
1270
|
}
|
|
4692
1271
|
return { success: true, text: successMessage };
|
|
4693
1272
|
} catch (error) {
|
|
4694
|
-
|
|
1273
|
+
logger4.error("Error in confirmGoal handler:", error);
|
|
4695
1274
|
if (callback) {
|
|
4696
1275
|
await callback({
|
|
4697
1276
|
text: "I encountered an error while confirming your goal. Please try again.",
|
|
@@ -4712,7 +1291,7 @@ I created the task as originally described. The modifications you mentioned ("${
|
|
|
4712
1291
|
import {
|
|
4713
1292
|
composePrompt as composePrompt3,
|
|
4714
1293
|
formatMessages as formatMessages3,
|
|
4715
|
-
logger as
|
|
1294
|
+
logger as logger5,
|
|
4716
1295
|
ModelType as ModelType4,
|
|
4717
1296
|
parseKeyValueXml as parseKeyValueXml3
|
|
4718
1297
|
} from "@elizaos/core";
|
|
@@ -4734,10 +1313,10 @@ async function extractGoalInfo(runtime, message, state) {
|
|
|
4734
1313
|
prompt,
|
|
4735
1314
|
stopSequences: []
|
|
4736
1315
|
});
|
|
4737
|
-
|
|
1316
|
+
logger5.debug("Extract goal result:", result);
|
|
4738
1317
|
const parsedResult = parseKeyValueXml3(result);
|
|
4739
|
-
if (!parsedResult
|
|
4740
|
-
|
|
1318
|
+
if (!parsedResult?.name) {
|
|
1319
|
+
logger5.error("Failed to extract valid goal information from structured output");
|
|
4741
1320
|
return null;
|
|
4742
1321
|
}
|
|
4743
1322
|
return {
|
|
@@ -4746,7 +1325,7 @@ async function extractGoalInfo(runtime, message, state) {
|
|
|
4746
1325
|
ownerType: parsedResult.ownerType === "agent" ? "agent" : "entity"
|
|
4747
1326
|
};
|
|
4748
1327
|
} catch (error) {
|
|
4749
|
-
|
|
1328
|
+
logger5.error("Error extracting goal information:", error);
|
|
4750
1329
|
return null;
|
|
4751
1330
|
}
|
|
4752
1331
|
}
|
|
@@ -4779,7 +1358,7 @@ async function checkForSimilarGoal(runtime, newGoal, existingGoals) {
|
|
|
4779
1358
|
confidence: parseInt(String(parsedResult.confidence || 0), 10)
|
|
4780
1359
|
};
|
|
4781
1360
|
} catch (error) {
|
|
4782
|
-
|
|
1361
|
+
logger5.error("Error checking for similar goals:", error);
|
|
4783
1362
|
return { hasSimilar: false, confidence: 0 };
|
|
4784
1363
|
}
|
|
4785
1364
|
}
|
|
@@ -4788,8 +1367,29 @@ var createGoalAction = {
|
|
|
4788
1367
|
name: spec4.name,
|
|
4789
1368
|
similes: spec4.similes ? [...spec4.similes] : [],
|
|
4790
1369
|
description: spec4.description,
|
|
4791
|
-
validate: async (
|
|
4792
|
-
|
|
1370
|
+
validate: async (runtime, message, state, options) => {
|
|
1371
|
+
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
1372
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
1373
|
+
const __avKeywords = ["create", "goal"];
|
|
1374
|
+
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
1375
|
+
const __avRegex = /\b(?:create|goal)\b/i;
|
|
1376
|
+
const __avRegexOk = Boolean(__avText.match(__avRegex));
|
|
1377
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
1378
|
+
const __avExpectedSource = "";
|
|
1379
|
+
const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
1380
|
+
const __avOptions = options && typeof options === "object" ? options : {};
|
|
1381
|
+
const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
|
|
1382
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
const __avLegacyValidate = async (_runtime, _message) => {
|
|
1386
|
+
return true;
|
|
1387
|
+
};
|
|
1388
|
+
try {
|
|
1389
|
+
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
1390
|
+
} catch {
|
|
1391
|
+
return false;
|
|
1392
|
+
}
|
|
4793
1393
|
},
|
|
4794
1394
|
handler: async (runtime, message, state, _options, callback) => {
|
|
4795
1395
|
try {
|
|
@@ -4869,7 +1469,7 @@ var createGoalAction = {
|
|
|
4869
1469
|
}
|
|
4870
1470
|
return { success: true, text: successMessage };
|
|
4871
1471
|
} catch (error) {
|
|
4872
|
-
|
|
1472
|
+
logger5.error("Error in createGoal handler:", error);
|
|
4873
1473
|
if (callback) {
|
|
4874
1474
|
await callback({
|
|
4875
1475
|
text: "I encountered an error while creating your goal. Please try again.",
|
|
@@ -4889,7 +1489,7 @@ var createGoalAction = {
|
|
|
4889
1489
|
// actions/updateGoal.ts
|
|
4890
1490
|
import {
|
|
4891
1491
|
composePrompt as composePrompt4,
|
|
4892
|
-
logger as
|
|
1492
|
+
logger as logger6,
|
|
4893
1493
|
ModelType as ModelType5,
|
|
4894
1494
|
parseKeyValueXml as parseKeyValueXml4
|
|
4895
1495
|
} from "@elizaos/core";
|
|
@@ -4919,7 +1519,7 @@ Tags: ${goal.tags?.join(", ") || "none"}
|
|
|
4919
1519
|
});
|
|
4920
1520
|
const parsedResult = parseKeyValueXml4(result);
|
|
4921
1521
|
if (!parsedResult || typeof parsedResult.isFound === "undefined") {
|
|
4922
|
-
|
|
1522
|
+
logger6.error("Failed to parse valid goal selection information from structured output");
|
|
4923
1523
|
return { goalId: "", goalName: "", isFound: false };
|
|
4924
1524
|
}
|
|
4925
1525
|
const finalResult = {
|
|
@@ -4929,7 +1529,7 @@ Tags: ${goal.tags?.join(", ") || "none"}
|
|
|
4929
1529
|
};
|
|
4930
1530
|
return finalResult;
|
|
4931
1531
|
} catch (error) {
|
|
4932
|
-
|
|
1532
|
+
logger6.error("Error extracting goal selection information:", error);
|
|
4933
1533
|
return { goalId: "", goalName: "", isFound: false };
|
|
4934
1534
|
}
|
|
4935
1535
|
}
|
|
@@ -4957,7 +1557,7 @@ async function extractGoalUpdate(runtime, message, goal) {
|
|
|
4957
1557
|
});
|
|
4958
1558
|
const parsedUpdate = parseKeyValueXml4(result);
|
|
4959
1559
|
if (!parsedUpdate || Object.keys(parsedUpdate).length === 0) {
|
|
4960
|
-
|
|
1560
|
+
logger6.error("Failed to extract valid goal update information from structured output");
|
|
4961
1561
|
return null;
|
|
4962
1562
|
}
|
|
4963
1563
|
const finalUpdate = {};
|
|
@@ -4966,12 +1566,12 @@ async function extractGoalUpdate(runtime, message, goal) {
|
|
|
4966
1566
|
if (parsedUpdate.description)
|
|
4967
1567
|
finalUpdate.description = String(parsedUpdate.description);
|
|
4968
1568
|
if (Object.keys(finalUpdate).length === 0) {
|
|
4969
|
-
|
|
1569
|
+
logger6.warn("No valid update fields found after parsing structured output.");
|
|
4970
1570
|
return null;
|
|
4971
1571
|
}
|
|
4972
1572
|
return finalUpdate;
|
|
4973
1573
|
} catch (error) {
|
|
4974
|
-
|
|
1574
|
+
logger6.error("Error extracting goal update information:", error);
|
|
4975
1575
|
return null;
|
|
4976
1576
|
}
|
|
4977
1577
|
}
|
|
@@ -4980,14 +1580,35 @@ var updateGoalAction = {
|
|
|
4980
1580
|
name: spec5.name,
|
|
4981
1581
|
similes: spec5.similes ? [...spec5.similes] : [],
|
|
4982
1582
|
description: `${spec5.description} Update a goal name or description.`,
|
|
4983
|
-
validate: async (runtime, message) => {
|
|
1583
|
+
validate: async (runtime, message, state, options) => {
|
|
1584
|
+
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
1585
|
+
const __avText = __avTextRaw.toLowerCase();
|
|
1586
|
+
const __avKeywords = ["update", "goal"];
|
|
1587
|
+
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
1588
|
+
const __avRegex = /\b(?:update|goal)\b/i;
|
|
1589
|
+
const __avRegexOk = Boolean(__avText.match(__avRegex));
|
|
1590
|
+
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
1591
|
+
const __avExpectedSource = "";
|
|
1592
|
+
const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
1593
|
+
const __avOptions = options && typeof options === "object" ? options : {};
|
|
1594
|
+
const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
|
|
1595
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
1596
|
+
return false;
|
|
1597
|
+
}
|
|
1598
|
+
const __avLegacyValidate = async (runtime2, message2) => {
|
|
1599
|
+
try {
|
|
1600
|
+
const dataService = createGoalDataService(runtime2);
|
|
1601
|
+
const agentGoalCount = await dataService.countGoals("agent", runtime2.agentId, false);
|
|
1602
|
+
const entityGoalCount = message2.entityId ? await dataService.countGoals("entity", message2.entityId, false) : 0;
|
|
1603
|
+
return agentGoalCount + entityGoalCount > 0;
|
|
1604
|
+
} catch (error) {
|
|
1605
|
+
logger6.error("Error validating UPDATE_GOAL action:", error);
|
|
1606
|
+
return false;
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
4984
1609
|
try {
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
const entityGoalCount = message.entityId ? await dataService.countGoals("entity", message.entityId, false) : 0;
|
|
4988
|
-
return agentGoalCount + entityGoalCount > 0;
|
|
4989
|
-
} catch (error) {
|
|
4990
|
-
logger7.error("Error validating UPDATE_GOAL action:", error);
|
|
1610
|
+
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
1611
|
+
} catch {
|
|
4991
1612
|
return false;
|
|
4992
1613
|
}
|
|
4993
1614
|
},
|
|
@@ -5050,8 +1671,8 @@ var updateGoalAction = {
|
|
|
5050
1671
|
}
|
|
5051
1672
|
return { success: false, error: "Goal not found" };
|
|
5052
1673
|
}
|
|
5053
|
-
const
|
|
5054
|
-
if (!
|
|
1674
|
+
const update = await extractGoalUpdate(runtime, message, goal);
|
|
1675
|
+
if (!update) {
|
|
5055
1676
|
if (callback) {
|
|
5056
1677
|
await callback({
|
|
5057
1678
|
text: `I couldn't determine what changes you want to make to "${goal.name}". You can update the goal's name or description.`,
|
|
@@ -5061,13 +1682,13 @@ var updateGoalAction = {
|
|
|
5061
1682
|
}
|
|
5062
1683
|
return { success: false, error: "Invalid update" };
|
|
5063
1684
|
}
|
|
5064
|
-
await dataService.updateGoal(goal.id,
|
|
1685
|
+
await dataService.updateGoal(goal.id, update);
|
|
5065
1686
|
const ownerText = goal.ownerType === "agent" ? "Agent" : "User";
|
|
5066
1687
|
const updateText = [];
|
|
5067
|
-
if (
|
|
5068
|
-
updateText.push(`name to "${
|
|
5069
|
-
if (
|
|
5070
|
-
updateText.push(`description to "${
|
|
1688
|
+
if (update.name)
|
|
1689
|
+
updateText.push(`name to "${update.name}"`);
|
|
1690
|
+
if (update.description)
|
|
1691
|
+
updateText.push(`description to "${update.description}"`);
|
|
5071
1692
|
if (callback) {
|
|
5072
1693
|
await callback({
|
|
5073
1694
|
text: `✓ ${ownerText} goal updated: Changed ${updateText.join(" and ")}.`,
|
|
@@ -5080,7 +1701,7 @@ var updateGoalAction = {
|
|
|
5080
1701
|
text: `Updated goal: ${updateText.join(" and ")}`
|
|
5081
1702
|
};
|
|
5082
1703
|
} catch (error) {
|
|
5083
|
-
|
|
1704
|
+
logger6.error("Error in updateGoal handler:", error);
|
|
5084
1705
|
if (callback) {
|
|
5085
1706
|
await callback({
|
|
5086
1707
|
text: "I encountered an error while trying to update your goal. Please try again.",
|
|
@@ -5098,15 +1719,15 @@ var updateGoalAction = {
|
|
|
5098
1719
|
};
|
|
5099
1720
|
|
|
5100
1721
|
// apis.ts
|
|
5101
|
-
init_drizzle_orm();
|
|
5102
1722
|
init_goalDataService();
|
|
5103
1723
|
import fs from "node:fs";
|
|
5104
1724
|
import path from "node:path";
|
|
5105
1725
|
import { fileURLToPath } from "node:url";
|
|
5106
1726
|
import {
|
|
5107
|
-
logger as
|
|
1727
|
+
logger as logger7,
|
|
5108
1728
|
stringToUuid
|
|
5109
1729
|
} from "@elizaos/core";
|
|
1730
|
+
import { sql } from "drizzle-orm";
|
|
5110
1731
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
5111
1732
|
var __dirname2 = path.dirname(__filename2);
|
|
5112
1733
|
var frontendDist = path.resolve(__dirname2, "../dist");
|
|
@@ -5173,10 +1794,10 @@ var routes = [
|
|
|
5173
1794
|
path: "/api/tags",
|
|
5174
1795
|
handler: async (_req, res, runtime) => {
|
|
5175
1796
|
try {
|
|
5176
|
-
|
|
5177
|
-
const
|
|
5178
|
-
if (!
|
|
5179
|
-
|
|
1797
|
+
logger7.debug("[API /api/tags] Fetching all distinct tags");
|
|
1798
|
+
const db = runtime.db;
|
|
1799
|
+
if (!db || typeof db.execute !== "function") {
|
|
1800
|
+
logger7.error("[API /api/tags] runtime.db is not available or not a Drizzle instance.");
|
|
5180
1801
|
res.status(500).json({ error: "Database not available" });
|
|
5181
1802
|
return;
|
|
5182
1803
|
}
|
|
@@ -5187,30 +1808,30 @@ var routes = [
|
|
|
5187
1808
|
dbType = "postgres";
|
|
5188
1809
|
} else {
|
|
5189
1810
|
try {
|
|
5190
|
-
await
|
|
1811
|
+
await db.execute(sql`SELECT sqlite_version()`);
|
|
5191
1812
|
dbType = "sqlite";
|
|
5192
1813
|
} catch {}
|
|
5193
1814
|
}
|
|
5194
1815
|
} catch (error) {
|
|
5195
|
-
|
|
1816
|
+
logger7.warn("Could not determine database type:", error);
|
|
5196
1817
|
}
|
|
5197
1818
|
let result;
|
|
5198
1819
|
if (dbType === "postgres") {
|
|
5199
1820
|
const query = sql`SELECT DISTINCT unnest(tags) as tag FROM goal_tags WHERE tag IS NOT NULL;`;
|
|
5200
|
-
result = await
|
|
1821
|
+
result = await db.execute(query);
|
|
5201
1822
|
} else {
|
|
5202
1823
|
const query = sql`
|
|
5203
1824
|
SELECT DISTINCT tag
|
|
5204
1825
|
FROM goal_tags
|
|
5205
1826
|
WHERE tag IS NOT NULL
|
|
5206
1827
|
`;
|
|
5207
|
-
result = await
|
|
1828
|
+
result = await db.execute(query);
|
|
5208
1829
|
}
|
|
5209
1830
|
const tags = Array.isArray(result) ? result.map((row) => row.tag) : result.rows ? result.rows?.map((row) => row.tag) : [];
|
|
5210
|
-
|
|
1831
|
+
logger7.debug(`[API /api/tags] Found ${tags.length} distinct tags`);
|
|
5211
1832
|
res.json(tags);
|
|
5212
1833
|
} catch (error) {
|
|
5213
|
-
|
|
1834
|
+
logger7.error("[API /api/tags] Error fetching tags:", error);
|
|
5214
1835
|
res.status(500).json({ error: "Failed to fetch tags" });
|
|
5215
1836
|
}
|
|
5216
1837
|
}
|
|
@@ -5289,7 +1910,7 @@ var routes = [
|
|
|
5289
1910
|
} catch (error) {
|
|
5290
1911
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
5291
1912
|
console.error(`Error completing goal ${req.params.id}:`, error);
|
|
5292
|
-
|
|
1913
|
+
logger7.error(`Error completing goal ${req.params.id}:`, error);
|
|
5293
1914
|
res.status(500).send(`Error completing goal: ${errorMessage}`);
|
|
5294
1915
|
}
|
|
5295
1916
|
}
|
|
@@ -5330,7 +1951,7 @@ var routes = [
|
|
|
5330
1951
|
} catch (error) {
|
|
5331
1952
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
5332
1953
|
console.error(`Error uncompleting goal ${req.params.id}:`, error);
|
|
5333
|
-
|
|
1954
|
+
logger7.error(`Error uncompleting goal ${req.params.id}:`, error);
|
|
5334
1955
|
res.status(500).send(`Error uncompleting goal: ${errorMessage}`);
|
|
5335
1956
|
}
|
|
5336
1957
|
}
|
|
@@ -5378,7 +1999,7 @@ var routes = [
|
|
|
5378
1999
|
} catch (error) {
|
|
5379
2000
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
5380
2001
|
console.error(`Error updating goal ${req.params.id}:`, error);
|
|
5381
|
-
|
|
2002
|
+
logger7.error(`Error updating goal ${req.params.id}:`, error);
|
|
5382
2003
|
res.status(500).send(`Error updating goal: ${errorMessage}`);
|
|
5383
2004
|
}
|
|
5384
2005
|
}
|
|
@@ -5406,7 +2027,7 @@ var routes = [
|
|
|
5406
2027
|
});
|
|
5407
2028
|
} catch (error) {
|
|
5408
2029
|
console.error(`Error deleting goal ${req.params.id}:`, error);
|
|
5409
|
-
|
|
2030
|
+
logger7.error(`Error deleting goal ${req.params.id}:`, error);
|
|
5410
2031
|
res.status(500).send("Error deleting goal");
|
|
5411
2032
|
}
|
|
5412
2033
|
}
|
|
@@ -5415,13 +2036,14 @@ var routes = [
|
|
|
5415
2036
|
|
|
5416
2037
|
// providers/goals.ts
|
|
5417
2038
|
import {
|
|
5418
|
-
logger as
|
|
2039
|
+
logger as logger8
|
|
5419
2040
|
} from "@elizaos/core";
|
|
5420
2041
|
init_goalDataService();
|
|
5421
|
-
var spec6 = requireProviderSpec("
|
|
2042
|
+
var spec6 = requireProviderSpec("GOALS");
|
|
5422
2043
|
var goalsProvider = {
|
|
5423
2044
|
name: spec6.name,
|
|
5424
2045
|
description: "Provides information about active goals and recent achievements",
|
|
2046
|
+
dynamic: true,
|
|
5425
2047
|
get: async (runtime, message, _state) => {
|
|
5426
2048
|
try {
|
|
5427
2049
|
const dataService = createGoalDataService(runtime);
|
|
@@ -5492,7 +2114,7 @@ var goalsProvider = {
|
|
|
5492
2114
|
}
|
|
5493
2115
|
};
|
|
5494
2116
|
} catch (error) {
|
|
5495
|
-
|
|
2117
|
+
logger8.error("Error in goals provider:", error);
|
|
5496
2118
|
return {
|
|
5497
2119
|
text: "Unable to retrieve goals information at this time.",
|
|
5498
2120
|
data: {},
|
|
@@ -5503,13 +2125,13 @@ var goalsProvider = {
|
|
|
5503
2125
|
};
|
|
5504
2126
|
|
|
5505
2127
|
// index.ts
|
|
5506
|
-
|
|
2128
|
+
init_schema();
|
|
5507
2129
|
init_goalDataService();
|
|
5508
2130
|
|
|
5509
2131
|
// __tests__/e2e/goals-plugin.ts
|
|
5510
2132
|
import {
|
|
5511
2133
|
createMessageMemory,
|
|
5512
|
-
logger as
|
|
2134
|
+
logger as logger9
|
|
5513
2135
|
} from "@elizaos/core";
|
|
5514
2136
|
var GoalsPluginE2ETestSuite = {
|
|
5515
2137
|
name: "Goals Plugin E2E Tests",
|
|
@@ -5517,7 +2139,7 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5517
2139
|
{
|
|
5518
2140
|
name: "should create and complete a goal successfully",
|
|
5519
2141
|
fn: async (runtime) => {
|
|
5520
|
-
|
|
2142
|
+
logger9.info("Testing goal creation and completion flow...");
|
|
5521
2143
|
const { createGoalDataService: createGoalDataService2 } = await Promise.resolve().then(() => (init_goalDataService(), exports_goalDataService));
|
|
5522
2144
|
const dataService = createGoalDataService2(runtime);
|
|
5523
2145
|
const testEntityId = `test-entity-${Date.now()}`;
|
|
@@ -5534,7 +2156,7 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5534
2156
|
if (!createdGoalId) {
|
|
5535
2157
|
throw new Error("Failed to create goal");
|
|
5536
2158
|
}
|
|
5537
|
-
|
|
2159
|
+
logger9.info(`✓ Goal created with ID: ${createdGoalId}`);
|
|
5538
2160
|
const goal = await dataService.getGoal(createdGoalId);
|
|
5539
2161
|
if (!goal) {
|
|
5540
2162
|
throw new Error("Created goal not found");
|
|
@@ -5545,7 +2167,7 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5545
2167
|
if (goal.isCompleted) {
|
|
5546
2168
|
throw new Error("New goal should not be completed");
|
|
5547
2169
|
}
|
|
5548
|
-
|
|
2170
|
+
logger9.info("✓ Goal retrieved and verified");
|
|
5549
2171
|
await dataService.updateGoal(createdGoalId, {
|
|
5550
2172
|
isCompleted: true,
|
|
5551
2173
|
completedAt: new Date
|
|
@@ -5554,15 +2176,15 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5554
2176
|
if (!completedGoal?.isCompleted) {
|
|
5555
2177
|
throw new Error("Goal should be marked as completed");
|
|
5556
2178
|
}
|
|
5557
|
-
|
|
2179
|
+
logger9.info("✓ Goal marked as completed");
|
|
5558
2180
|
await dataService.deleteGoal(createdGoalId);
|
|
5559
|
-
|
|
2181
|
+
logger9.info("✅ Goal creation and completion flow successful");
|
|
5560
2182
|
}
|
|
5561
2183
|
},
|
|
5562
2184
|
{
|
|
5563
2185
|
name: "should get uncompleted goals correctly",
|
|
5564
2186
|
fn: async (runtime) => {
|
|
5565
|
-
|
|
2187
|
+
logger9.info("Testing uncompleted goals retrieval...");
|
|
5566
2188
|
const { createGoalDataService: createGoalDataService2 } = await Promise.resolve().then(() => (init_goalDataService(), exports_goalDataService));
|
|
5567
2189
|
const dataService = createGoalDataService2(runtime);
|
|
5568
2190
|
const testEntityId = `test-entity-${Date.now()}`;
|
|
@@ -5582,12 +2204,12 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5582
2204
|
metadata: {},
|
|
5583
2205
|
tags: ["test"]
|
|
5584
2206
|
});
|
|
5585
|
-
|
|
2207
|
+
logger9.info("✓ Created two active goals");
|
|
5586
2208
|
const uncompletedGoals = await dataService.getUncompletedGoals("entity", testEntityId);
|
|
5587
2209
|
if (uncompletedGoals.length !== 2) {
|
|
5588
2210
|
throw new Error(`Expected 2 uncompleted goals, got ${uncompletedGoals.length}`);
|
|
5589
2211
|
}
|
|
5590
|
-
|
|
2212
|
+
logger9.info("✓ Retrieved correct number of uncompleted goals");
|
|
5591
2213
|
if (!goal1Id) {
|
|
5592
2214
|
throw new Error("goal1Id is null or undefined");
|
|
5593
2215
|
}
|
|
@@ -5599,18 +2221,18 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5599
2221
|
if (remainingGoals.length !== 1) {
|
|
5600
2222
|
throw new Error(`Expected 1 uncompleted goal, got ${remainingGoals.length}`);
|
|
5601
2223
|
}
|
|
5602
|
-
|
|
2224
|
+
logger9.info("✓ Uncompleted goals updated correctly after completion");
|
|
5603
2225
|
if (goal1Id)
|
|
5604
2226
|
await dataService.deleteGoal(goal1Id);
|
|
5605
2227
|
if (goal2Id)
|
|
5606
2228
|
await dataService.deleteGoal(goal2Id);
|
|
5607
|
-
|
|
2229
|
+
logger9.info("✅ Uncompleted goals retrieval successful");
|
|
5608
2230
|
}
|
|
5609
2231
|
},
|
|
5610
2232
|
{
|
|
5611
2233
|
name: "should filter goals by tags correctly",
|
|
5612
2234
|
fn: async (runtime) => {
|
|
5613
|
-
|
|
2235
|
+
logger9.info("Testing goal tag filtering...");
|
|
5614
2236
|
const { createGoalDataService: createGoalDataService2 } = await Promise.resolve().then(() => (init_goalDataService(), exports_goalDataService));
|
|
5615
2237
|
const dataService = createGoalDataService2(runtime);
|
|
5616
2238
|
const testEntityId = `test-entity-${Date.now()}`;
|
|
@@ -5630,7 +2252,7 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5630
2252
|
metadata: {},
|
|
5631
2253
|
tags: ["personal", "health"]
|
|
5632
2254
|
});
|
|
5633
|
-
|
|
2255
|
+
logger9.info("✓ Created goals with different tags");
|
|
5634
2256
|
const workGoals = await dataService.getGoals({
|
|
5635
2257
|
ownerType: "entity",
|
|
5636
2258
|
ownerId: testEntityId,
|
|
@@ -5642,23 +2264,23 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5642
2264
|
if (workGoals[0].name !== "Work Goal") {
|
|
5643
2265
|
throw new Error("Wrong goal returned for work tag filter");
|
|
5644
2266
|
}
|
|
5645
|
-
|
|
2267
|
+
logger9.info("✓ Tag filtering working correctly");
|
|
5646
2268
|
if (workGoalId)
|
|
5647
2269
|
await dataService.deleteGoal(workGoalId);
|
|
5648
2270
|
if (personalGoalId)
|
|
5649
2271
|
await dataService.deleteGoal(personalGoalId);
|
|
5650
|
-
|
|
2272
|
+
logger9.info("✅ Goal tag filtering successful");
|
|
5651
2273
|
}
|
|
5652
2274
|
},
|
|
5653
2275
|
{
|
|
5654
2276
|
name: "should process CREATE_GOAL action correctly",
|
|
5655
2277
|
fn: async (runtime) => {
|
|
5656
|
-
|
|
2278
|
+
logger9.info("Testing CREATE_GOAL action...");
|
|
5657
2279
|
const createAction = runtime.actions.find((a) => a.name === "CREATE_GOAL");
|
|
5658
2280
|
if (!createAction) {
|
|
5659
2281
|
throw new Error("CREATE_GOAL action not found");
|
|
5660
2282
|
}
|
|
5661
|
-
|
|
2283
|
+
logger9.info("✓ CREATE_GOAL action found");
|
|
5662
2284
|
const testRoomId = `test-room-${Date.now()}`;
|
|
5663
2285
|
const testEntityId = `test-entity-${Date.now()}`;
|
|
5664
2286
|
const testMessage = createMessageMemory({
|
|
@@ -5674,14 +2296,14 @@ var GoalsPluginE2ETestSuite = {
|
|
|
5674
2296
|
if (!isValid) {
|
|
5675
2297
|
throw new Error("CREATE_GOAL action validation failed");
|
|
5676
2298
|
}
|
|
5677
|
-
|
|
5678
|
-
|
|
2299
|
+
logger9.info("✓ CREATE_GOAL action validated");
|
|
2300
|
+
logger9.info("✅ CREATE_GOAL action test completed");
|
|
5679
2301
|
}
|
|
5680
2302
|
}
|
|
5681
2303
|
]
|
|
5682
2304
|
};
|
|
5683
2305
|
// index.ts
|
|
5684
|
-
|
|
2306
|
+
init_schema();
|
|
5685
2307
|
init_goalDataService();
|
|
5686
2308
|
var GoalsPlugin = {
|
|
5687
2309
|
name: "goals",
|
|
@@ -5701,11 +2323,11 @@ var GoalsPlugin = {
|
|
|
5701
2323
|
tests: [GoalsPluginE2ETestSuite],
|
|
5702
2324
|
async init(_config, runtime) {
|
|
5703
2325
|
if (runtime.db) {
|
|
5704
|
-
|
|
2326
|
+
logger10.info("Database available, GoalsPlugin ready for operation");
|
|
5705
2327
|
} else {
|
|
5706
|
-
|
|
2328
|
+
logger10.warn("No database instance available, operations will be limited");
|
|
5707
2329
|
}
|
|
5708
|
-
|
|
2330
|
+
logger10.info("GoalsPlugin initialized successfully");
|
|
5709
2331
|
}
|
|
5710
2332
|
};
|
|
5711
2333
|
var typescript_default = GoalsPlugin;
|
|
@@ -5717,4 +2339,4 @@ export {
|
|
|
5717
2339
|
GoalDataServiceWrapper
|
|
5718
2340
|
};
|
|
5719
2341
|
|
|
5720
|
-
//# debugId=
|
|
2342
|
+
//# debugId=ED617C6FF7C2BF6664756E2164756E21
|