@kaban-board/core 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ var __export = (target, all) => {
28
28
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
29
29
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
30
 
31
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/entity.js
31
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/entity.js
32
32
  function is(value, type) {
33
33
  if (!value || typeof value !== "object") {
34
34
  return false;
@@ -56,7 +56,7 @@ var init_entity = __esm(() => {
56
56
  hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
57
57
  });
58
58
 
59
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/column.js
59
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/column.js
60
60
  var Column;
61
61
  var init_column = __esm(() => {
62
62
  init_entity();
@@ -110,7 +110,7 @@ var init_column = __esm(() => {
110
110
  };
111
111
  });
112
112
 
113
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/column-builder.js
113
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/column-builder.js
114
114
  var ColumnBuilder;
115
115
  var init_column_builder = __esm(() => {
116
116
  init_entity();
@@ -170,19 +170,19 @@ var init_column_builder = __esm(() => {
170
170
  };
171
171
  });
172
172
 
173
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/table.utils.js
173
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/table.utils.js
174
174
  var TableName;
175
175
  var init_table_utils = __esm(() => {
176
176
  TableName = Symbol.for("drizzle:Name");
177
177
  });
178
178
 
179
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/tracing-utils.js
179
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/tracing-utils.js
180
180
  function iife(fn, ...args) {
181
181
  return fn(...args);
182
182
  }
183
183
  var init_tracing_utils = () => {};
184
184
 
185
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/pg-core/unique-constraint.js
185
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/pg-core/unique-constraint.js
186
186
  function uniqueKeyName(table, columns) {
187
187
  return `${table[TableName]}_${columns.join("_")}_unique`;
188
188
  }
@@ -190,7 +190,7 @@ var init_unique_constraint = __esm(() => {
190
190
  init_table_utils();
191
191
  });
192
192
 
193
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/pg-core/columns/common.js
193
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/pg-core/columns/common.js
194
194
  var PgColumn, ExtraConfigColumn;
195
195
  var init_common = __esm(() => {
196
196
  init_column();
@@ -244,14 +244,26 @@ var init_common = __esm(() => {
244
244
  };
245
245
  });
246
246
 
247
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/pg-core/columns/enum.js
247
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/pg-core/columns/enum.js
248
248
  function isPgEnum(obj) {
249
249
  return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
250
250
  }
251
- var isPgEnumSym, PgEnumColumn;
251
+ var PgEnumObjectColumn, isPgEnumSym, PgEnumColumn;
252
252
  var init_enum = __esm(() => {
253
253
  init_entity();
254
254
  init_common();
255
+ PgEnumObjectColumn = class PgEnumObjectColumn extends PgColumn {
256
+ static [entityKind] = "PgEnumObjectColumn";
257
+ enum;
258
+ enumValues = this.config.enum.enumValues;
259
+ constructor(table, config) {
260
+ super(table, config);
261
+ this.enum = config.enum;
262
+ }
263
+ getSQLType() {
264
+ return this.enum.enumName;
265
+ }
266
+ };
255
267
  isPgEnumSym = Symbol.for("drizzle:isPgEnum");
256
268
  PgEnumColumn = class PgEnumColumn extends PgColumn {
257
269
  static [entityKind] = "PgEnumColumn";
@@ -267,19 +279,20 @@ var init_enum = __esm(() => {
267
279
  };
268
280
  });
269
281
 
270
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/subquery.js
282
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/subquery.js
271
283
  var Subquery, WithSubquery;
272
284
  var init_subquery = __esm(() => {
273
285
  init_entity();
274
286
  Subquery = class Subquery {
275
287
  static [entityKind] = "Subquery";
276
- constructor(sql, selection, alias, isWith = false) {
288
+ constructor(sql, fields, alias, isWith = false, usedTables = []) {
277
289
  this._ = {
278
290
  brand: "Subquery",
279
291
  sql,
280
- selectedFields: selection,
292
+ selectedFields: fields,
281
293
  alias,
282
- isWith
294
+ isWith,
295
+ usedTables
283
296
  };
284
297
  }
285
298
  };
@@ -288,11 +301,11 @@ var init_subquery = __esm(() => {
288
301
  };
289
302
  });
290
303
 
291
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/version.js
292
- var version = "0.38.4";
304
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/version.js
305
+ var version = "0.45.1";
293
306
  var init_version = () => {};
294
307
 
295
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/tracing.js
308
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/tracing.js
296
309
  var otel, rawTracer, tracer;
297
310
  var init_tracing = __esm(() => {
298
311
  init_tracing_utils();
@@ -322,13 +335,13 @@ var init_tracing = __esm(() => {
322
335
  };
323
336
  });
324
337
 
325
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/view-common.js
338
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/view-common.js
326
339
  var ViewBaseConfig;
327
340
  var init_view_common = __esm(() => {
328
341
  ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
329
342
  });
330
343
 
331
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/table.js
344
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/table.js
332
345
  function getTableName(table) {
333
346
  return table[TableName];
334
347
  }
@@ -376,7 +389,7 @@ var init_table = __esm(() => {
376
389
  };
377
390
  });
378
391
 
379
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/sql.js
392
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/sql.js
380
393
  function isSQLWrapper(value) {
381
394
  return value !== null && value !== undefined && typeof value.getSQL === "function";
382
395
  }
@@ -446,10 +459,17 @@ var init_sql = __esm(() => {
446
459
  SQL = class SQL {
447
460
  constructor(queryChunks) {
448
461
  this.queryChunks = queryChunks;
462
+ for (const chunk of queryChunks) {
463
+ if (is(chunk, Table)) {
464
+ const schemaName = chunk[Table.Symbol.Schema];
465
+ this.usedTables.push(schemaName === undefined ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
466
+ }
467
+ }
449
468
  }
450
469
  static [entityKind] = "SQL";
451
470
  decoder = noopDecoder;
452
471
  shouldInlineParams = false;
472
+ usedTables = [];
453
473
  append(query) {
454
474
  this.queryChunks.push(...query.queryChunks);
455
475
  return this;
@@ -508,7 +528,7 @@ var init_sql = __esm(() => {
508
528
  const schemaName = chunk[Table.Symbol.Schema];
509
529
  const tableName = chunk[Table.Symbol.Name];
510
530
  return {
511
- sql: schemaName === undefined ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
531
+ sql: schemaName === undefined || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
512
532
  params: []
513
533
  };
514
534
  }
@@ -527,7 +547,7 @@ var init_sql = __esm(() => {
527
547
  const schemaName = chunk[ViewBaseConfig].schema;
528
548
  const viewName = chunk[ViewBaseConfig].name;
529
549
  return {
530
- sql: schemaName === undefined ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
550
+ sql: schemaName === undefined || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
531
551
  params: []
532
552
  };
533
553
  }
@@ -753,7 +773,7 @@ var init_sql = __esm(() => {
753
773
  };
754
774
  });
755
775
 
756
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/alias.js
776
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/alias.js
757
777
  function aliasedTable(table, tableAlias) {
758
778
  return new Proxy(table, new TableAliasProxyHandler(tableAlias, false));
759
779
  }
@@ -839,13 +859,13 @@ var init_alias = __esm(() => {
839
859
  };
840
860
  });
841
861
 
842
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/alias.js
862
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/alias.js
843
863
  var init_alias2 = () => {};
844
864
 
845
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/checks.js
865
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/checks.js
846
866
  var init_checks = () => {};
847
867
 
848
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/utils.js
868
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/utils.js
849
869
  function mapResultRow(columns, row, joinsNotNullableMap) {
850
870
  const nullifyMap = {};
851
871
  const result = columns.reduce((result2, { path, field }, columnIndex) => {
@@ -854,6 +874,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
854
874
  decoder = field;
855
875
  } else if (is(field, SQL)) {
856
876
  decoder = field.decoder;
877
+ } else if (is(field, Subquery)) {
878
+ decoder = field._.sql.decoder;
857
879
  } else {
858
880
  decoder = field.sql.decoder;
859
881
  }
@@ -894,7 +916,7 @@ function orderSelectedFields(fields, pathPrefix) {
894
916
  return result;
895
917
  }
896
918
  const newPath = pathPrefix ? [...pathPrefix, name] : [name];
897
- if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased)) {
919
+ if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery)) {
898
920
  result.push({ path: newPath, field });
899
921
  } else if (is(field, Table)) {
900
922
  result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));
@@ -963,13 +985,13 @@ function isConfig(data) {
963
985
  return true;
964
986
  }
965
987
  if ("schema" in data) {
966
- const type = typeof data["logger"];
988
+ const type = typeof data["schema"];
967
989
  if (type !== "object" && type !== "undefined")
968
990
  return false;
969
991
  return true;
970
992
  }
971
993
  if ("casing" in data) {
972
- const type = typeof data["logger"];
994
+ const type = typeof data["casing"];
973
995
  if (type !== "string" && type !== "undefined")
974
996
  return false;
975
997
  return true;
@@ -995,6 +1017,7 @@ function isConfig(data) {
995
1017
  return true;
996
1018
  return false;
997
1019
  }
1020
+ var textDecoder;
998
1021
  var init_utils = __esm(() => {
999
1022
  init_column();
1000
1023
  init_entity();
@@ -1002,9 +1025,10 @@ var init_utils = __esm(() => {
1002
1025
  init_subquery();
1003
1026
  init_table();
1004
1027
  init_view_common();
1028
+ textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
1005
1029
  });
1006
1030
 
1007
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
1031
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
1008
1032
  var ForeignKeyBuilder, ForeignKey;
1009
1033
  var init_foreign_keys = __esm(() => {
1010
1034
  init_entity();
@@ -1062,7 +1086,7 @@ var init_foreign_keys = __esm(() => {
1062
1086
  };
1063
1087
  });
1064
1088
 
1065
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
1089
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
1066
1090
  function uniqueKeyName2(table, columns) {
1067
1091
  return `${table[TableName]}_${columns.join("_")}_unique`;
1068
1092
  }
@@ -1070,7 +1094,7 @@ var init_unique_constraint2 = __esm(() => {
1070
1094
  init_table_utils();
1071
1095
  });
1072
1096
 
1073
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/common.js
1097
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/common.js
1074
1098
  var SQLiteColumnBuilder, SQLiteColumn;
1075
1099
  var init_common2 = __esm(() => {
1076
1100
  init_column_builder();
@@ -1128,7 +1152,7 @@ var init_common2 = __esm(() => {
1128
1152
  };
1129
1153
  });
1130
1154
 
1131
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/blob.js
1155
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/blob.js
1132
1156
  function blob(a, b) {
1133
1157
  const { name, config } = getColumnNameAndConfig(a, b);
1134
1158
  if (config?.mode === "json") {
@@ -1159,14 +1183,11 @@ var init_blob = __esm(() => {
1159
1183
  return "blob";
1160
1184
  }
1161
1185
  mapFromDriverValue(value) {
1162
- if (Buffer.isBuffer(value)) {
1163
- return BigInt(value.toString());
1186
+ if (typeof Buffer !== "undefined" && Buffer.from) {
1187
+ const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
1188
+ return BigInt(buf.toString("utf8"));
1164
1189
  }
1165
- if (value instanceof ArrayBuffer) {
1166
- const decoder = new TextDecoder;
1167
- return BigInt(decoder.decode(value));
1168
- }
1169
- return BigInt(String.fromCodePoint(...value));
1190
+ return BigInt(textDecoder.decode(value));
1170
1191
  }
1171
1192
  mapToDriverValue(value) {
1172
1193
  return Buffer.from(value.toString());
@@ -1187,14 +1208,11 @@ var init_blob = __esm(() => {
1187
1208
  return "blob";
1188
1209
  }
1189
1210
  mapFromDriverValue(value) {
1190
- if (Buffer.isBuffer(value)) {
1191
- return JSON.parse(value.toString());
1192
- }
1193
- if (value instanceof ArrayBuffer) {
1194
- const decoder = new TextDecoder;
1195
- return JSON.parse(decoder.decode(value));
1211
+ if (typeof Buffer !== "undefined" && Buffer.from) {
1212
+ const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
1213
+ return JSON.parse(buf.toString("utf8"));
1196
1214
  }
1197
- return JSON.parse(String.fromCodePoint(...value));
1215
+ return JSON.parse(textDecoder.decode(value));
1198
1216
  }
1199
1217
  mapToDriverValue(value) {
1200
1218
  return Buffer.from(JSON.stringify(value));
@@ -1211,13 +1229,19 @@ var init_blob = __esm(() => {
1211
1229
  };
1212
1230
  SQLiteBlobBuffer = class SQLiteBlobBuffer extends SQLiteColumn {
1213
1231
  static [entityKind] = "SQLiteBlobBuffer";
1232
+ mapFromDriverValue(value) {
1233
+ if (Buffer.isBuffer(value)) {
1234
+ return value;
1235
+ }
1236
+ return Buffer.from(value);
1237
+ }
1214
1238
  getSQLType() {
1215
1239
  return "blob";
1216
1240
  }
1217
1241
  };
1218
1242
  });
1219
1243
 
1220
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/custom.js
1244
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/custom.js
1221
1245
  function customType(customTypeParams) {
1222
1246
  return (a, b) => {
1223
1247
  const { name, config } = getColumnNameAndConfig(a, b);
@@ -1263,7 +1287,7 @@ var init_custom = __esm(() => {
1263
1287
  };
1264
1288
  });
1265
1289
 
1266
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/integer.js
1290
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/integer.js
1267
1291
  function integer(a, b) {
1268
1292
  const { name, config } = getColumnNameAndConfig(a, b);
1269
1293
  if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") {
@@ -1365,13 +1389,16 @@ var init_integer = __esm(() => {
1365
1389
  };
1366
1390
  });
1367
1391
 
1368
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
1369
- function numeric(name) {
1370
- return new SQLiteNumericBuilder(name ?? "");
1392
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
1393
+ function numeric(a, b) {
1394
+ const { name, config } = getColumnNameAndConfig(a, b);
1395
+ const mode = config?.mode;
1396
+ return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
1371
1397
  }
1372
- var SQLiteNumericBuilder, SQLiteNumeric;
1398
+ var SQLiteNumericBuilder, SQLiteNumeric, SQLiteNumericNumberBuilder, SQLiteNumericNumber, SQLiteNumericBigIntBuilder, SQLiteNumericBigInt;
1373
1399
  var init_numeric = __esm(() => {
1374
1400
  init_entity();
1401
+ init_utils();
1375
1402
  init_common2();
1376
1403
  SQLiteNumericBuilder = class SQLiteNumericBuilder extends SQLiteColumnBuilder {
1377
1404
  static [entityKind] = "SQLiteNumericBuilder";
@@ -1384,13 +1411,56 @@ var init_numeric = __esm(() => {
1384
1411
  };
1385
1412
  SQLiteNumeric = class SQLiteNumeric extends SQLiteColumn {
1386
1413
  static [entityKind] = "SQLiteNumeric";
1414
+ mapFromDriverValue(value) {
1415
+ if (typeof value === "string")
1416
+ return value;
1417
+ return String(value);
1418
+ }
1419
+ getSQLType() {
1420
+ return "numeric";
1421
+ }
1422
+ };
1423
+ SQLiteNumericNumberBuilder = class SQLiteNumericNumberBuilder extends SQLiteColumnBuilder {
1424
+ static [entityKind] = "SQLiteNumericNumberBuilder";
1425
+ constructor(name) {
1426
+ super(name, "number", "SQLiteNumericNumber");
1427
+ }
1428
+ build(table) {
1429
+ return new SQLiteNumericNumber(table, this.config);
1430
+ }
1431
+ };
1432
+ SQLiteNumericNumber = class SQLiteNumericNumber extends SQLiteColumn {
1433
+ static [entityKind] = "SQLiteNumericNumber";
1434
+ mapFromDriverValue(value) {
1435
+ if (typeof value === "number")
1436
+ return value;
1437
+ return Number(value);
1438
+ }
1439
+ mapToDriverValue = String;
1440
+ getSQLType() {
1441
+ return "numeric";
1442
+ }
1443
+ };
1444
+ SQLiteNumericBigIntBuilder = class SQLiteNumericBigIntBuilder extends SQLiteColumnBuilder {
1445
+ static [entityKind] = "SQLiteNumericBigIntBuilder";
1446
+ constructor(name) {
1447
+ super(name, "bigint", "SQLiteNumericBigInt");
1448
+ }
1449
+ build(table) {
1450
+ return new SQLiteNumericBigInt(table, this.config);
1451
+ }
1452
+ };
1453
+ SQLiteNumericBigInt = class SQLiteNumericBigInt extends SQLiteColumn {
1454
+ static [entityKind] = "SQLiteNumericBigInt";
1455
+ mapFromDriverValue = BigInt;
1456
+ mapToDriverValue = String;
1387
1457
  getSQLType() {
1388
1458
  return "numeric";
1389
1459
  }
1390
1460
  };
1391
1461
  });
1392
1462
 
1393
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/real.js
1463
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/real.js
1394
1464
  function real(name) {
1395
1465
  return new SQLiteRealBuilder(name ?? "");
1396
1466
  }
@@ -1415,7 +1485,7 @@ var init_real = __esm(() => {
1415
1485
  };
1416
1486
  });
1417
1487
 
1418
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/text.js
1488
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/text.js
1419
1489
  function text(a, b = {}) {
1420
1490
  const { name, config } = getColumnNameAndConfig(a, b);
1421
1491
  if (config.mode === "json") {
@@ -1473,7 +1543,7 @@ var init_text = __esm(() => {
1473
1543
  };
1474
1544
  });
1475
1545
 
1476
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/index.js
1546
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/index.js
1477
1547
  var init_columns = __esm(() => {
1478
1548
  init_blob();
1479
1549
  init_common2();
@@ -1484,7 +1554,7 @@ var init_columns = __esm(() => {
1484
1554
  init_text();
1485
1555
  });
1486
1556
 
1487
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/selection-proxy.js
1557
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/selection-proxy.js
1488
1558
  var SelectionProxyHandler;
1489
1559
  var init_selection_proxy = __esm(() => {
1490
1560
  init_alias();
@@ -1545,7 +1615,7 @@ var init_selection_proxy = __esm(() => {
1545
1615
  };
1546
1616
  });
1547
1617
 
1548
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/query-promise.js
1618
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/query-promise.js
1549
1619
  var QueryPromise;
1550
1620
  var init_query_promise = __esm(() => {
1551
1621
  init_entity();
@@ -1570,7 +1640,7 @@ var init_query_promise = __esm(() => {
1570
1640
  };
1571
1641
  });
1572
1642
 
1573
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/columns/all.js
1643
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/columns/all.js
1574
1644
  function getSQLiteColumnBuilders() {
1575
1645
  return {
1576
1646
  blob,
@@ -1590,7 +1660,7 @@ var init_all = __esm(() => {
1590
1660
  init_text();
1591
1661
  });
1592
1662
 
1593
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/table.js
1663
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/table.js
1594
1664
  function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
1595
1665
  const rawTable = new SQLiteTable(name, schema, baseName);
1596
1666
  const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
@@ -1628,7 +1698,34 @@ var init_table2 = __esm(() => {
1628
1698
  };
1629
1699
  });
1630
1700
 
1631
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/delete.js
1701
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/indexes.js
1702
+ var init_indexes = () => {};
1703
+
1704
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/primary-keys.js
1705
+ var init_primary_keys = () => {};
1706
+
1707
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/utils.js
1708
+ function extractUsedTable(table) {
1709
+ if (is(table, SQLiteTable)) {
1710
+ return [`${table[Table.Symbol.BaseName]}`];
1711
+ }
1712
+ if (is(table, Subquery)) {
1713
+ return table._.usedTables ?? [];
1714
+ }
1715
+ if (is(table, SQL)) {
1716
+ return table.usedTables ?? [];
1717
+ }
1718
+ return [];
1719
+ }
1720
+ var init_utils2 = __esm(() => {
1721
+ init_entity();
1722
+ init_sql();
1723
+ init_subquery();
1724
+ init_table();
1725
+ init_table2();
1726
+ });
1727
+
1728
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/delete.js
1632
1729
  var SQLiteDeleteBase;
1633
1730
  var init_delete = __esm(() => {
1634
1731
  init_entity();
@@ -1637,6 +1734,7 @@ var init_delete = __esm(() => {
1637
1734
  init_table2();
1638
1735
  init_table();
1639
1736
  init_utils();
1737
+ init_utils2();
1640
1738
  SQLiteDeleteBase = class SQLiteDeleteBase extends QueryPromise {
1641
1739
  constructor(table, session, dialect, withList) {
1642
1740
  super();
@@ -1678,7 +1776,10 @@ var init_delete = __esm(() => {
1678
1776
  return rest;
1679
1777
  }
1680
1778
  _prepare(isOneTimeQuery = true) {
1681
- return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true);
1779
+ return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true, undefined, {
1780
+ type: "delete",
1781
+ tables: extractUsedTable(this.config.table)
1782
+ });
1682
1783
  }
1683
1784
  prepare() {
1684
1785
  return this._prepare(false);
@@ -1704,7 +1805,7 @@ var init_delete = __esm(() => {
1704
1805
  };
1705
1806
  });
1706
1807
 
1707
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/casing.js
1808
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/casing.js
1708
1809
  function toSnakeCase(input) {
1709
1810
  const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
1710
1811
  return words.map((word) => word.toLowerCase()).join("_");
@@ -1761,8 +1862,8 @@ var init_casing = __esm(() => {
1761
1862
  };
1762
1863
  });
1763
1864
 
1764
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/errors.js
1765
- var DrizzleError, TransactionRollbackError;
1865
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/errors.js
1866
+ var DrizzleError, DrizzleQueryError, TransactionRollbackError;
1766
1867
  var init_errors = __esm(() => {
1767
1868
  init_entity();
1768
1869
  DrizzleError = class DrizzleError extends Error {
@@ -1773,6 +1874,18 @@ var init_errors = __esm(() => {
1773
1874
  this.cause = cause;
1774
1875
  }
1775
1876
  };
1877
+ DrizzleQueryError = class DrizzleQueryError extends Error {
1878
+ constructor(query, params, cause) {
1879
+ super(`Failed query: ${query}
1880
+ params: ${params}`);
1881
+ this.query = query;
1882
+ this.params = params;
1883
+ this.cause = cause;
1884
+ Error.captureStackTrace(this, DrizzleQueryError);
1885
+ if (cause)
1886
+ this.cause = cause;
1887
+ }
1888
+ };
1776
1889
  TransactionRollbackError = class TransactionRollbackError extends DrizzleError {
1777
1890
  static [entityKind] = "TransactionRollbackError";
1778
1891
  constructor() {
@@ -1781,7 +1894,7 @@ var init_errors = __esm(() => {
1781
1894
  };
1782
1895
  });
1783
1896
 
1784
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/pg-core/table.js
1897
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/pg-core/table.js
1785
1898
  var InlineForeignKeys2, EnableRLS, PgTable;
1786
1899
  var init_table3 = __esm(() => {
1787
1900
  init_entity();
@@ -1797,12 +1910,13 @@ var init_table3 = __esm(() => {
1797
1910
  [InlineForeignKeys2] = [];
1798
1911
  [EnableRLS] = false;
1799
1912
  [Table.Symbol.ExtraConfigBuilder] = undefined;
1913
+ [Table.Symbol.ExtraConfigColumns] = {};
1800
1914
  };
1801
1915
  });
1802
1916
 
1803
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/pg-core/primary-keys.js
1917
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/pg-core/primary-keys.js
1804
1918
  var PrimaryKeyBuilder, PrimaryKey;
1805
- var init_primary_keys = __esm(() => {
1919
+ var init_primary_keys2 = __esm(() => {
1806
1920
  init_entity();
1807
1921
  init_table3();
1808
1922
  PrimaryKeyBuilder = class PrimaryKeyBuilder {
@@ -1832,7 +1946,7 @@ var init_primary_keys = __esm(() => {
1832
1946
  };
1833
1947
  });
1834
1948
 
1835
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/expressions/conditions.js
1949
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/expressions/conditions.js
1836
1950
  function bindIfParam(value, column) {
1837
1951
  if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
1838
1952
  return new Param(value, column);
@@ -1938,7 +2052,7 @@ var init_conditions = __esm(() => {
1938
2052
  init_sql();
1939
2053
  });
1940
2054
 
1941
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/expressions/select.js
2055
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/expressions/select.js
1942
2056
  function asc(column) {
1943
2057
  return sql`${column} asc`;
1944
2058
  }
@@ -1949,13 +2063,13 @@ var init_select = __esm(() => {
1949
2063
  init_sql();
1950
2064
  });
1951
2065
 
1952
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/expressions/index.js
2066
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/expressions/index.js
1953
2067
  var init_expressions = __esm(() => {
1954
2068
  init_conditions();
1955
2069
  init_select();
1956
2070
  });
1957
2071
 
1958
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/relations.js
2072
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/relations.js
1959
2073
  function getOperators() {
1960
2074
  return {
1961
2075
  and,
@@ -2133,7 +2247,7 @@ var init_relations = __esm(() => {
2133
2247
  init_table();
2134
2248
  init_column();
2135
2249
  init_entity();
2136
- init_primary_keys();
2250
+ init_primary_keys2();
2137
2251
  init_expressions();
2138
2252
  init_sql();
2139
2253
  Relation = class Relation {
@@ -2181,26 +2295,26 @@ var init_relations = __esm(() => {
2181
2295
  };
2182
2296
  });
2183
2297
 
2184
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/functions/aggregate.js
2298
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/functions/aggregate.js
2185
2299
  var init_aggregate = () => {};
2186
2300
 
2187
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/functions/vector.js
2301
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/functions/vector.js
2188
2302
  var init_vector = () => {};
2189
2303
 
2190
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/functions/index.js
2304
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/functions/index.js
2191
2305
  var init_functions = __esm(() => {
2192
2306
  init_aggregate();
2193
2307
  init_vector();
2194
2308
  });
2195
2309
 
2196
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sql/index.js
2310
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sql/index.js
2197
2311
  var init_sql2 = __esm(() => {
2198
2312
  init_expressions();
2199
2313
  init_functions();
2200
2314
  init_sql();
2201
2315
  });
2202
2316
 
2203
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/view-base.js
2317
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/view-base.js
2204
2318
  var SQLiteViewBase;
2205
2319
  var init_view_base = __esm(() => {
2206
2320
  init_entity();
@@ -2210,7 +2324,7 @@ var init_view_base = __esm(() => {
2210
2324
  };
2211
2325
  });
2212
2326
 
2213
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/dialect.js
2327
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/dialect.js
2214
2328
  var SQLiteDialect, SQLiteSyncDialect, SQLiteAsyncDialect;
2215
2329
  var init_dialect = __esm(() => {
2216
2330
  init_alias();
@@ -2270,7 +2384,8 @@ var init_dialect = __esm(() => {
2270
2384
  const setSize = columnNames.length;
2271
2385
  return sql.join(columnNames.flatMap((colName, i) => {
2272
2386
  const col = tableColumns[colName];
2273
- const value = set[colName] ?? sql.param(col.onUpdateFn(), col);
2387
+ const onUpdateFnResult = col.onUpdateFn?.();
2388
+ const value = set[colName] ?? (is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col));
2274
2389
  const res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
2275
2390
  if (i < setSize - 1) {
2276
2391
  return [res, sql.raw(", ")];
@@ -2312,11 +2427,28 @@ var init_dialect = __esm(() => {
2312
2427
  }
2313
2428
  } else if (is(field, Column)) {
2314
2429
  const tableName = field.table[Table.Symbol.Name];
2315
- if (isSingleTable) {
2316
- chunk.push(sql.identifier(this.casing.getColumnCasing(field)));
2430
+ if (field.columnType === "SQLiteNumericBigInt") {
2431
+ if (isSingleTable) {
2432
+ chunk.push(sql`cast(${sql.identifier(this.casing.getColumnCasing(field))} as text)`);
2433
+ } else {
2434
+ chunk.push(sql`cast(${sql.identifier(tableName)}.${sql.identifier(this.casing.getColumnCasing(field))} as text)`);
2435
+ }
2317
2436
  } else {
2318
- chunk.push(sql`${sql.identifier(tableName)}.${sql.identifier(this.casing.getColumnCasing(field))}`);
2437
+ if (isSingleTable) {
2438
+ chunk.push(sql.identifier(this.casing.getColumnCasing(field)));
2439
+ } else {
2440
+ chunk.push(sql`${sql.identifier(tableName)}.${sql.identifier(this.casing.getColumnCasing(field))}`);
2441
+ }
2319
2442
  }
2443
+ } else if (is(field, Subquery)) {
2444
+ const entries = Object.entries(field._.selectedFields);
2445
+ if (entries.length === 1) {
2446
+ const entry = entries[0][1];
2447
+ const fieldDecoder = is(entry, SQL) ? entry.decoder : is(entry, Column) ? { mapFromDriverValue: (v) => entry.mapFromDriverValue(v) } : entry.sql.decoder;
2448
+ if (fieldDecoder)
2449
+ field._.sql.decoder = fieldDecoder;
2450
+ }
2451
+ chunk.push(field);
2320
2452
  }
2321
2453
  if (i < columnsLen - 1) {
2322
2454
  chunk.push(sql`, `);
@@ -2336,14 +2468,15 @@ var init_dialect = __esm(() => {
2336
2468
  joinsArray.push(sql` `);
2337
2469
  }
2338
2470
  const table = joinMeta.table;
2471
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : undefined;
2339
2472
  if (is(table, SQLiteTable)) {
2340
2473
  const tableName = table[SQLiteTable.Symbol.Name];
2341
2474
  const tableSchema = table[SQLiteTable.Symbol.Schema];
2342
2475
  const origTableName = table[SQLiteTable.Symbol.OriginalName];
2343
2476
  const alias = tableName === origTableName ? undefined : joinMeta.alias;
2344
- joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`);
2477
+ joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`);
2345
2478
  } else {
2346
- joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${table} on ${joinMeta.on}`);
2479
+ joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${table}${onSql}`);
2347
2480
  }
2348
2481
  if (index < joins.length - 1) {
2349
2482
  joinsArray.push(sql` `);
@@ -2368,8 +2501,8 @@ var init_dialect = __esm(() => {
2368
2501
  return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : undefined;
2369
2502
  }
2370
2503
  buildFromTable(table) {
2371
- if (is(table, Table) && table[Table.Symbol.OriginalName] !== table[Table.Symbol.Name]) {
2372
- return sql`${sql.identifier(table[Table.Symbol.OriginalName])} ${sql.identifier(table[Table.Symbol.Name])}`;
2504
+ if (is(table, Table) && table[Table.Symbol.IsAlias]) {
2505
+ return sql`${sql`${sql.identifier(table[Table.Symbol.Schema] ?? "")}.`.if(table[Table.Symbol.Schema])}${sql.identifier(table[Table.Symbol.OriginalName])} ${sql.identifier(table[Table.Symbol.Name])}`;
2373
2506
  }
2374
2507
  return table;
2375
2508
  }
@@ -2509,7 +2642,7 @@ var init_dialect = __esm(() => {
2509
2642
  const withSql = this.buildWithCTE(withList);
2510
2643
  const valuesSql = sql.join(valuesSqlList);
2511
2644
  const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : undefined;
2512
- const onConflictSql = onConflict ? sql` on conflict ${onConflict}` : undefined;
2645
+ const onConflictSql = onConflict?.length ? sql.join(onConflict) : undefined;
2513
2646
  return sql`${withSql}insert into ${table} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
2514
2647
  }
2515
2648
  sqlToQuery(sql22, invokeSource) {
@@ -2784,7 +2917,7 @@ var init_dialect = __esm(() => {
2784
2917
  };
2785
2918
  });
2786
2919
 
2787
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/query-builders/query-builder.js
2920
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/query-builders/query-builder.js
2788
2921
  var TypedQueryBuilder;
2789
2922
  var init_query_builder = __esm(() => {
2790
2923
  init_entity();
@@ -2796,7 +2929,7 @@ var init_query_builder = __esm(() => {
2796
2929
  };
2797
2930
  });
2798
2931
 
2799
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/select.js
2932
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/select.js
2800
2933
  function createSetOperator(type, isAll) {
2801
2934
  return (leftSelect, rightSelect, ...restSelects) => {
2802
2935
  const setOperators = [rightSelect, ...restSelects].map((select2) => ({
@@ -2828,6 +2961,7 @@ var init_select2 = __esm(() => {
2828
2961
  init_table();
2829
2962
  init_utils();
2830
2963
  init_view_common();
2964
+ init_utils2();
2831
2965
  init_view_base();
2832
2966
  SQLiteSelectBuilder = class SQLiteSelectBuilder {
2833
2967
  static [entityKind] = "SQLiteSelectBuilder";
@@ -2877,6 +3011,8 @@ var init_select2 = __esm(() => {
2877
3011
  isPartialSelect;
2878
3012
  session;
2879
3013
  dialect;
3014
+ cacheConfig = undefined;
3015
+ usedTables = /* @__PURE__ */ new Set;
2880
3016
  constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
2881
3017
  super();
2882
3018
  this.config = {
@@ -2890,15 +3026,23 @@ var init_select2 = __esm(() => {
2890
3026
  this.session = session;
2891
3027
  this.dialect = dialect;
2892
3028
  this._ = {
2893
- selectedFields: fields
3029
+ selectedFields: fields,
3030
+ config: this.config
2894
3031
  };
2895
3032
  this.tableName = getTableLikeName(table);
2896
3033
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
3034
+ for (const item of extractUsedTable(table))
3035
+ this.usedTables.add(item);
3036
+ }
3037
+ getUsedTables() {
3038
+ return [...this.usedTables];
2897
3039
  }
2898
3040
  createJoin(joinType) {
2899
3041
  return (table, on) => {
2900
3042
  const baseTableName = this.tableName;
2901
3043
  const tableName = getTableLikeName(table);
3044
+ for (const item of extractUsedTable(table))
3045
+ this.usedTables.add(item);
2902
3046
  if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
2903
3047
  throw new Error(`Alias "${tableName}" is already used in this query`);
2904
3048
  }
@@ -2931,6 +3075,7 @@ var init_select2 = __esm(() => {
2931
3075
  this.joinsNotNullableMap[tableName] = true;
2932
3076
  break;
2933
3077
  }
3078
+ case "cross":
2934
3079
  case "inner": {
2935
3080
  this.joinsNotNullableMap[tableName] = true;
2936
3081
  break;
@@ -2949,6 +3094,7 @@ var init_select2 = __esm(() => {
2949
3094
  rightJoin = this.createJoin("right");
2950
3095
  innerJoin = this.createJoin("inner");
2951
3096
  fullJoin = this.createJoin("full");
3097
+ crossJoin = this.createJoin("cross");
2952
3098
  createSetOperator(type, isAll) {
2953
3099
  return (rightSelection) => {
2954
3100
  const rightSelect = typeof rightSelection === "function" ? rightSelection(getSQLiteSetOperators()) : rightSelection;
@@ -3033,7 +3179,13 @@ var init_select2 = __esm(() => {
3033
3179
  return rest;
3034
3180
  }
3035
3181
  as(alias) {
3036
- return new Proxy(new Subquery(this.getSQL(), this.config.fields, alias), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
3182
+ const usedTables = [];
3183
+ usedTables.push(...extractUsedTable(this.config.table));
3184
+ if (this.config.joins) {
3185
+ for (const it of this.config.joins)
3186
+ usedTables.push(...extractUsedTable(it.table));
3187
+ }
3188
+ return new Proxy(new Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
3037
3189
  }
3038
3190
  getSelectedFields() {
3039
3191
  return new Proxy(this.config.fields, new SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
@@ -3049,10 +3201,17 @@ var init_select2 = __esm(() => {
3049
3201
  throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
3050
3202
  }
3051
3203
  const fieldsList = orderSelectedFields(this.config.fields);
3052
- const query = this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), fieldsList, "all", true);
3204
+ const query = this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), fieldsList, "all", true, undefined, {
3205
+ type: "select",
3206
+ tables: [...this.usedTables]
3207
+ }, this.cacheConfig);
3053
3208
  query.joinsNotNullableMap = this.joinsNotNullableMap;
3054
3209
  return query;
3055
3210
  }
3211
+ $withCache(config) {
3212
+ this.cacheConfig = config === undefined ? { config: {}, enable: true, autoInvalidate: true } : config === false ? { enable: false } : { enable: true, autoInvalidate: true, ...config };
3213
+ return this;
3214
+ }
3056
3215
  prepare() {
3057
3216
  return this._prepare(false);
3058
3217
  }
@@ -3079,7 +3238,7 @@ var init_select2 = __esm(() => {
3079
3238
  except = createSetOperator("except", false);
3080
3239
  });
3081
3240
 
3082
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/query-builder.js
3241
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/query-builder.js
3083
3242
  var QueryBuilder;
3084
3243
  var init_query_builder2 = __esm(() => {
3085
3244
  init_entity();
@@ -3095,17 +3254,16 @@ var init_query_builder2 = __esm(() => {
3095
3254
  this.dialect = is(dialect, SQLiteDialect) ? dialect : undefined;
3096
3255
  this.dialectConfig = is(dialect, SQLiteDialect) ? undefined : dialect;
3097
3256
  }
3098
- $with(alias) {
3257
+ $with = (alias, selection) => {
3099
3258
  const queryBuilder = this;
3100
- return {
3101
- as(qb) {
3102
- if (typeof qb === "function") {
3103
- qb = qb(queryBuilder);
3104
- }
3105
- return new Proxy(new WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
3259
+ const as = (qb) => {
3260
+ if (typeof qb === "function") {
3261
+ qb = qb(queryBuilder);
3106
3262
  }
3263
+ return new Proxy(new WithSubquery(qb.getSQL(), selection ?? ("getSelectedFields" in qb ? qb.getSelectedFields() ?? {} : {}), alias, true), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
3107
3264
  };
3108
- }
3265
+ return { as };
3266
+ };
3109
3267
  with(...queries) {
3110
3268
  const self2 = this;
3111
3269
  function select2(fields) {
@@ -3147,7 +3305,7 @@ var init_query_builder2 = __esm(() => {
3147
3305
  };
3148
3306
  });
3149
3307
 
3150
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js
3308
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js
3151
3309
  var SQLiteInsertBuilder, SQLiteInsertBase;
3152
3310
  var init_insert = __esm(() => {
3153
3311
  init_entity();
@@ -3156,6 +3314,7 @@ var init_insert = __esm(() => {
3156
3314
  init_table2();
3157
3315
  init_table();
3158
3316
  init_utils();
3317
+ init_utils2();
3159
3318
  init_query_builder2();
3160
3319
  SQLiteInsertBuilder = class SQLiteInsertBuilder {
3161
3320
  constructor(table, session, dialect, withList) {
@@ -3203,12 +3362,14 @@ var init_insert = __esm(() => {
3203
3362
  return this;
3204
3363
  }
3205
3364
  onConflictDoNothing(config = {}) {
3365
+ if (!this.config.onConflict)
3366
+ this.config.onConflict = [];
3206
3367
  if (config.target === undefined) {
3207
- this.config.onConflict = sql`do nothing`;
3368
+ this.config.onConflict.push(sql` on conflict do nothing`);
3208
3369
  } else {
3209
3370
  const targetSql = Array.isArray(config.target) ? sql`${config.target}` : sql`${[config.target]}`;
3210
3371
  const whereSql = config.where ? sql` where ${config.where}` : sql``;
3211
- this.config.onConflict = sql`${targetSql} do nothing${whereSql}`;
3372
+ this.config.onConflict.push(sql` on conflict ${targetSql} do nothing${whereSql}`);
3212
3373
  }
3213
3374
  return this;
3214
3375
  }
@@ -3216,12 +3377,14 @@ var init_insert = __esm(() => {
3216
3377
  if (config.where && (config.targetWhere || config.setWhere)) {
3217
3378
  throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');
3218
3379
  }
3380
+ if (!this.config.onConflict)
3381
+ this.config.onConflict = [];
3219
3382
  const whereSql = config.where ? sql` where ${config.where}` : undefined;
3220
3383
  const targetWhereSql = config.targetWhere ? sql` where ${config.targetWhere}` : undefined;
3221
3384
  const setWhereSql = config.setWhere ? sql` where ${config.setWhere}` : undefined;
3222
3385
  const targetSql = Array.isArray(config.target) ? sql`${config.target}` : sql`${[config.target]}`;
3223
3386
  const setSql = this.dialect.buildUpdateSet(this.config.table, mapUpdateSet(this.config.table, config.set));
3224
- this.config.onConflict = sql`${targetSql}${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`;
3387
+ this.config.onConflict.push(sql` on conflict ${targetSql}${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`);
3225
3388
  return this;
3226
3389
  }
3227
3390
  getSQL() {
@@ -3232,7 +3395,10 @@ var init_insert = __esm(() => {
3232
3395
  return rest;
3233
3396
  }
3234
3397
  _prepare(isOneTimeQuery = true) {
3235
- return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true);
3398
+ return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true, undefined, {
3399
+ type: "insert",
3400
+ tables: extractUsedTable(this.config.table)
3401
+ });
3236
3402
  }
3237
3403
  prepare() {
3238
3404
  return this._prepare(false);
@@ -3258,7 +3424,7 @@ var init_insert = __esm(() => {
3258
3424
  };
3259
3425
  });
3260
3426
 
3261
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/update.js
3427
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/update.js
3262
3428
  var SQLiteUpdateBuilder, SQLiteUpdateBase;
3263
3429
  var init_update = __esm(() => {
3264
3430
  init_entity();
@@ -3269,6 +3435,7 @@ var init_update = __esm(() => {
3269
3435
  init_table();
3270
3436
  init_utils();
3271
3437
  init_view_common();
3438
+ init_utils2();
3272
3439
  init_view_base();
3273
3440
  SQLiteUpdateBuilder = class SQLiteUpdateBuilder {
3274
3441
  constructor(table, session, dialect, withList) {
@@ -3344,7 +3511,10 @@ var init_update = __esm(() => {
3344
3511
  return rest;
3345
3512
  }
3346
3513
  _prepare(isOneTimeQuery = true) {
3347
- return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true);
3514
+ return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true, undefined, {
3515
+ type: "insert",
3516
+ tables: extractUsedTable(this.config.table)
3517
+ });
3348
3518
  }
3349
3519
  prepare() {
3350
3520
  return this._prepare(false);
@@ -3370,7 +3540,7 @@ var init_update = __esm(() => {
3370
3540
  };
3371
3541
  });
3372
3542
 
3373
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/index.js
3543
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/index.js
3374
3544
  var init_query_builders = __esm(() => {
3375
3545
  init_delete();
3376
3546
  init_insert();
@@ -3379,7 +3549,7 @@ var init_query_builders = __esm(() => {
3379
3549
  init_update();
3380
3550
  });
3381
3551
 
3382
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/count.js
3552
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/count.js
3383
3553
  var SQLiteCountBuilder;
3384
3554
  var init_count = __esm(() => {
3385
3555
  init_entity();
@@ -3419,7 +3589,7 @@ var init_count = __esm(() => {
3419
3589
  };
3420
3590
  });
3421
3591
 
3422
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/query.js
3592
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/query.js
3423
3593
  var RelationalQueryBuilder, SQLiteRelationalQuery, SQLiteSyncRelationalQuery;
3424
3594
  var init_query = __esm(() => {
3425
3595
  init_entity();
@@ -3517,7 +3687,7 @@ var init_query = __esm(() => {
3517
3687
  };
3518
3688
  });
3519
3689
 
3520
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/query-builders/raw.js
3690
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/query-builders/raw.js
3521
3691
  var SQLiteRaw;
3522
3692
  var init_raw = __esm(() => {
3523
3693
  init_entity();
@@ -3548,7 +3718,7 @@ var init_raw = __esm(() => {
3548
3718
  };
3549
3719
  });
3550
3720
 
3551
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/db.js
3721
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/db.js
3552
3722
  var BaseSQLiteDatabase;
3553
3723
  var init_db = __esm(() => {
3554
3724
  init_entity();
@@ -3580,20 +3750,20 @@ var init_db = __esm(() => {
3580
3750
  query[tableName] = new RelationalQueryBuilder(resultKind, schema.fullSchema, this._.schema, this._.tableNamesMap, schema.fullSchema[tableName], columns, dialect, session);
3581
3751
  }
3582
3752
  }
3753
+ this.$cache = { invalidate: async (_params) => {} };
3583
3754
  }
3584
3755
  static [entityKind] = "BaseSQLiteDatabase";
3585
3756
  query;
3586
- $with(alias) {
3757
+ $with = (alias, selection) => {
3587
3758
  const self2 = this;
3588
- return {
3589
- as(qb) {
3590
- if (typeof qb === "function") {
3591
- qb = qb(new QueryBuilder(self2.dialect));
3592
- }
3593
- return new Proxy(new WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
3759
+ const as = (qb) => {
3760
+ if (typeof qb === "function") {
3761
+ qb = qb(new QueryBuilder(self2.dialect));
3594
3762
  }
3763
+ return new Proxy(new WithSubquery(qb.getSQL(), selection ?? ("getSelectedFields" in qb ? qb.getSelectedFields() ?? {} : {}), alias, true), new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" }));
3595
3764
  };
3596
- }
3765
+ return { as };
3766
+ };
3597
3767
  $count(source, filters) {
3598
3768
  return new SQLiteCountBuilder({ source, filters, session: this.session });
3599
3769
  }
@@ -3641,6 +3811,7 @@ var init_db = __esm(() => {
3641
3811
  update(table) {
3642
3812
  return new SQLiteUpdateBuilder(table, this.session, this.dialect);
3643
3813
  }
3814
+ $cache;
3644
3815
  insert(into) {
3645
3816
  return new SQLiteInsertBuilder(into, this.session, this.dialect);
3646
3817
  }
@@ -3681,15 +3852,39 @@ var init_db = __esm(() => {
3681
3852
  };
3682
3853
  });
3683
3854
 
3684
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/indexes.js
3685
- var init_indexes = () => {};
3686
-
3687
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/primary-keys.js
3688
- var init_primary_keys2 = () => {};
3855
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/cache/core/cache.js
3856
+ async function hashQuery(sql3, params) {
3857
+ const dataToHash = `${sql3}-${JSON.stringify(params)}`;
3858
+ const encoder = new TextEncoder;
3859
+ const data = encoder.encode(dataToHash);
3860
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
3861
+ const hashArray = [...new Uint8Array(hashBuffer)];
3862
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
3863
+ return hashHex;
3864
+ }
3865
+ var Cache, NoopCache;
3866
+ var init_cache = __esm(() => {
3867
+ init_entity();
3868
+ Cache = class Cache {
3869
+ static [entityKind] = "Cache";
3870
+ };
3871
+ NoopCache = class NoopCache extends Cache {
3872
+ strategy() {
3873
+ return "all";
3874
+ }
3875
+ static [entityKind] = "NoopCache";
3876
+ async get(_key) {
3877
+ return;
3878
+ }
3879
+ async put(_hashedQuery, _response, _tables, _config) {}
3880
+ async onMutate(_params) {}
3881
+ };
3882
+ });
3689
3883
 
3690
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/session.js
3884
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/session.js
3691
3885
  var ExecuteResultSync, SQLitePreparedQuery, SQLiteSession, SQLiteTransaction;
3692
3886
  var init_session = __esm(() => {
3887
+ init_cache();
3693
3888
  init_entity();
3694
3889
  init_errors();
3695
3890
  init_query_promise();
@@ -3708,13 +3903,75 @@ var init_session = __esm(() => {
3708
3903
  }
3709
3904
  };
3710
3905
  SQLitePreparedQuery = class SQLitePreparedQuery {
3711
- constructor(mode, executeMethod, query) {
3906
+ constructor(mode, executeMethod, query, cache, queryMetadata, cacheConfig) {
3712
3907
  this.mode = mode;
3713
3908
  this.executeMethod = executeMethod;
3714
3909
  this.query = query;
3910
+ this.cache = cache;
3911
+ this.queryMetadata = queryMetadata;
3912
+ this.cacheConfig = cacheConfig;
3913
+ if (cache && cache.strategy() === "all" && cacheConfig === undefined) {
3914
+ this.cacheConfig = { enable: true, autoInvalidate: true };
3915
+ }
3916
+ if (!this.cacheConfig?.enable) {
3917
+ this.cacheConfig = undefined;
3918
+ }
3715
3919
  }
3716
3920
  static [entityKind] = "PreparedQuery";
3717
3921
  joinsNotNullableMap;
3922
+ async queryWithCache(queryString, params, query) {
3923
+ if (this.cache === undefined || is(this.cache, NoopCache) || this.queryMetadata === undefined) {
3924
+ try {
3925
+ return await query();
3926
+ } catch (e) {
3927
+ throw new DrizzleQueryError(queryString, params, e);
3928
+ }
3929
+ }
3930
+ if (this.cacheConfig && !this.cacheConfig.enable) {
3931
+ try {
3932
+ return await query();
3933
+ } catch (e) {
3934
+ throw new DrizzleQueryError(queryString, params, e);
3935
+ }
3936
+ }
3937
+ if ((this.queryMetadata.type === "insert" || this.queryMetadata.type === "update" || this.queryMetadata.type === "delete") && this.queryMetadata.tables.length > 0) {
3938
+ try {
3939
+ const [res] = await Promise.all([
3940
+ query(),
3941
+ this.cache.onMutate({ tables: this.queryMetadata.tables })
3942
+ ]);
3943
+ return res;
3944
+ } catch (e) {
3945
+ throw new DrizzleQueryError(queryString, params, e);
3946
+ }
3947
+ }
3948
+ if (!this.cacheConfig) {
3949
+ try {
3950
+ return await query();
3951
+ } catch (e) {
3952
+ throw new DrizzleQueryError(queryString, params, e);
3953
+ }
3954
+ }
3955
+ if (this.queryMetadata.type === "select") {
3956
+ const fromCache = await this.cache.get(this.cacheConfig.tag ?? await hashQuery(queryString, params), this.queryMetadata.tables, this.cacheConfig.tag !== undefined, this.cacheConfig.autoInvalidate);
3957
+ if (fromCache === undefined) {
3958
+ let result;
3959
+ try {
3960
+ result = await query();
3961
+ } catch (e) {
3962
+ throw new DrizzleQueryError(queryString, params, e);
3963
+ }
3964
+ await this.cache.put(this.cacheConfig.tag ?? await hashQuery(queryString, params), result, this.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [], this.cacheConfig.tag !== undefined, this.cacheConfig.config);
3965
+ return result;
3966
+ }
3967
+ return fromCache;
3968
+ }
3969
+ try {
3970
+ return await query();
3971
+ } catch (e) {
3972
+ throw new DrizzleQueryError(queryString, params, e);
3973
+ }
3974
+ }
3718
3975
  getQuery() {
3719
3976
  return this.query;
3720
3977
  }
@@ -3752,8 +4009,8 @@ var init_session = __esm(() => {
3752
4009
  this.dialect = dialect;
3753
4010
  }
3754
4011
  static [entityKind] = "SQLiteSession";
3755
- prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode) {
3756
- return this.prepareQuery(query, fields, executeMethod, isResponseInArrayMode);
4012
+ prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
4013
+ return this.prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig);
3757
4014
  }
3758
4015
  run(query) {
3759
4016
  const staticQuery = this.dialect.sqlToQuery(query);
@@ -3802,13 +4059,10 @@ var init_session = __esm(() => {
3802
4059
  };
3803
4060
  });
3804
4061
 
3805
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/utils.js
3806
- var init_utils2 = () => {};
3807
-
3808
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/view.js
4062
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/view.js
3809
4063
  var init_view = () => {};
3810
4064
 
3811
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/sqlite-core/index.js
4065
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/sqlite-core/index.js
3812
4066
  var init_sqlite_core = __esm(() => {
3813
4067
  init_alias2();
3814
4068
  init_checks();
@@ -3817,7 +4071,7 @@ var init_sqlite_core = __esm(() => {
3817
4071
  init_dialect();
3818
4072
  init_foreign_keys();
3819
4073
  init_indexes();
3820
- init_primary_keys2();
4074
+ init_primary_keys();
3821
4075
  init_query_builders();
3822
4076
  init_session();
3823
4077
  init_table2();
@@ -3826,7 +4080,219 @@ var init_sqlite_core = __esm(() => {
3826
4080
  init_view();
3827
4081
  });
3828
4082
 
3829
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/logger.js
4083
+ // drizzle/meta/_journal.json
4084
+ var _journal_default;
4085
+ var init__journal = __esm(() => {
4086
+ _journal_default = {
4087
+ version: "7",
4088
+ dialect: "sqlite",
4089
+ entries: [
4090
+ {
4091
+ idx: 0,
4092
+ version: "6",
4093
+ when: 1769351194943,
4094
+ tag: "0000_init",
4095
+ breakpoints: true
4096
+ },
4097
+ {
4098
+ idx: 1,
4099
+ version: "6",
4100
+ when: 1769351198000,
4101
+ tag: "0001_add_archived",
4102
+ breakpoints: true
4103
+ },
4104
+ {
4105
+ idx: 2,
4106
+ version: "6",
4107
+ when: 1769351200000,
4108
+ tag: "0002_add_fts5",
4109
+ breakpoints: true
4110
+ }
4111
+ ]
4112
+ };
4113
+ });
4114
+
4115
+ // drizzle/0000_init.sql
4116
+ var _0000_init_default = "CREATE TABLE `boards` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`name` text NOT NULL,\n\t`created_at` integer NOT NULL,\n\t`updated_at` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE TABLE `columns` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`board_id` text NOT NULL,\n\t`name` text NOT NULL,\n\t`position` integer NOT NULL,\n\t`wip_limit` integer,\n\t`is_terminal` integer DEFAULT false NOT NULL,\n\tFOREIGN KEY (`board_id`) REFERENCES `boards`(`id`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nCREATE TABLE `tasks` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`title` text NOT NULL,\n\t`description` text,\n\t`column_id` text NOT NULL,\n\t`position` integer NOT NULL,\n\t`created_by` text NOT NULL,\n\t`assigned_to` text,\n\t`parent_id` text,\n\t`depends_on` text DEFAULT '[]' NOT NULL,\n\t`files` text DEFAULT '[]' NOT NULL,\n\t`labels` text DEFAULT '[]' NOT NULL,\n\t`blocked_reason` text,\n\t`version` integer DEFAULT 1 NOT NULL,\n\t`created_at` integer NOT NULL,\n\t`updated_at` integer NOT NULL,\n\t`started_at` integer,\n\t`completed_at` integer,\n\t`archived` integer DEFAULT false NOT NULL,\n\t`archived_at` integer,\n\tFOREIGN KEY (`column_id`) REFERENCES `columns`(`id`) ON UPDATE no action ON DELETE no action,\n\tFOREIGN KEY (`parent_id`) REFERENCES `tasks`(`id`) ON UPDATE no action ON DELETE no action\n);\n--> statement-breakpoint\nCREATE TABLE `undo_log` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`operation` text NOT NULL,\n\t`data` text NOT NULL,\n\t`created_at` integer NOT NULL\n);\n";
4117
+ var init_0000_init = () => {};
4118
+
4119
+ // drizzle/0001_add_archived.sql
4120
+ var _0001_add_archived_default = `-- Add archived columns for task archiving feature
4121
+ -- SQLite doesn't support ADD COLUMN IF NOT EXISTS, so we check manually
4122
+ -- These columns may already exist in newer databases
4123
+
4124
+ ALTER TABLE tasks ADD COLUMN archived INTEGER DEFAULT false NOT NULL;
4125
+ --> statement-breakpoint
4126
+ ALTER TABLE tasks ADD COLUMN archived_at INTEGER;
4127
+ `;
4128
+ var init_0001_add_archived = () => {};
4129
+
4130
+ // drizzle/0002_add_fts5.sql
4131
+ var _0002_add_fts5_default = `-- Add index for archived column
4132
+ CREATE INDEX IF NOT EXISTS idx_tasks_archived ON tasks(archived);
4133
+ --> statement-breakpoint
4134
+ -- Create FTS5 virtual table for full-text search
4135
+ -- Uses unicode61 tokenizer with remove_diacritics for proper Russian language support
4136
+ CREATE VIRTUAL TABLE IF NOT EXISTS tasks_fts USING fts5(
4137
+ id, title, description,
4138
+ content='tasks',
4139
+ content_rowid='rowid',
4140
+ tokenize='unicode61 remove_diacritics 2'
4141
+ );
4142
+ --> statement-breakpoint
4143
+ -- Create trigger to keep FTS in sync on INSERT
4144
+ CREATE TRIGGER IF NOT EXISTS tasks_fts_insert AFTER INSERT ON tasks BEGIN
4145
+ INSERT INTO tasks_fts(rowid, id, title, description)
4146
+ VALUES (NEW.rowid, NEW.id, NEW.title, COALESCE(NEW.description, ''));
4147
+ END;
4148
+ --> statement-breakpoint
4149
+ -- Create trigger to keep FTS in sync on DELETE
4150
+ CREATE TRIGGER IF NOT EXISTS tasks_fts_delete AFTER DELETE ON tasks BEGIN
4151
+ INSERT INTO tasks_fts(tasks_fts, rowid, id, title, description)
4152
+ VALUES('delete', OLD.rowid, OLD.id, OLD.title, COALESCE(OLD.description, ''));
4153
+ END;
4154
+ --> statement-breakpoint
4155
+ -- Create trigger to keep FTS in sync on UPDATE
4156
+ CREATE TRIGGER IF NOT EXISTS tasks_fts_update AFTER UPDATE ON tasks BEGIN
4157
+ INSERT INTO tasks_fts(tasks_fts, rowid, id, title, description)
4158
+ VALUES('delete', OLD.rowid, OLD.id, OLD.title, COALESCE(OLD.description, ''));
4159
+ INSERT INTO tasks_fts(rowid, id, title, description)
4160
+ VALUES (NEW.rowid, NEW.id, NEW.title, COALESCE(NEW.description, ''));
4161
+ END;
4162
+ --> statement-breakpoint
4163
+ -- Populate FTS with existing data (only if FTS table is empty)
4164
+ INSERT INTO tasks_fts(rowid, id, title, description)
4165
+ SELECT rowid, id, title, COALESCE(description, '') FROM tasks
4166
+ WHERE NOT EXISTS (SELECT 1 FROM tasks_fts LIMIT 1);
4167
+ `;
4168
+ var init_0002_add_fts5 = () => {};
4169
+
4170
+ // src/db/migrator.ts
4171
+ var exports_migrator = {};
4172
+ __export(exports_migrator, {
4173
+ runMigrations: () => runMigrations
4174
+ });
4175
+ import { readFileSync } from "node:fs";
4176
+ import { dirname, isAbsolute, join } from "node:path";
4177
+ import { fileURLToPath } from "node:url";
4178
+ function resolveSqlContent(sqlOrPath) {
4179
+ if (sqlOrPath.includes("CREATE") || sqlOrPath.includes("INSERT") || sqlOrPath.includes("--")) {
4180
+ return sqlOrPath;
4181
+ }
4182
+ let filePath = sqlOrPath;
4183
+ if (filePath.startsWith("./")) {
4184
+ filePath = join(drizzleDir, filePath.replace("./", "").replace(/-[a-z0-9]+\.sql$/, ".sql"));
4185
+ }
4186
+ if (!isAbsolute(filePath)) {
4187
+ filePath = join(drizzleDir, filePath);
4188
+ }
4189
+ return readFileSync(filePath, "utf-8");
4190
+ }
4191
+ function getMigrations() {
4192
+ const j = _journal_default;
4193
+ return j.entries.map((entry) => ({
4194
+ tag: entry.tag,
4195
+ sql: resolveSqlContent(migrationSql[entry.tag] ?? "")
4196
+ }));
4197
+ }
4198
+ async function getAppliedMigrations(db2) {
4199
+ try {
4200
+ const results = [];
4201
+ const client = db2.$client;
4202
+ if (client && typeof client.prepare === "function") {
4203
+ const bunClient = client;
4204
+ const rows = bunClient.prepare("SELECT tag FROM __drizzle_migrations").all();
4205
+ return new Set(rows.map((r) => r.tag));
4206
+ }
4207
+ if (client && typeof client.execute === "function") {
4208
+ const libsqlClient = client;
4209
+ const res = await libsqlClient.execute("SELECT tag FROM __drizzle_migrations");
4210
+ return new Set(res.rows.map((r) => String(r.tag)));
4211
+ }
4212
+ return new Set(results.map((r) => r.tag));
4213
+ } catch {
4214
+ return new Set;
4215
+ }
4216
+ }
4217
+ async function createMigrationsTable(db2) {
4218
+ await db2.$runRaw(`
4219
+ CREATE TABLE IF NOT EXISTS __drizzle_migrations (
4220
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
4221
+ tag TEXT NOT NULL UNIQUE,
4222
+ created_at INTEGER NOT NULL
4223
+ )
4224
+ `);
4225
+ }
4226
+ async function recordMigration(db2, tag) {
4227
+ const now = Date.now();
4228
+ await db2.$runRaw(`INSERT INTO __drizzle_migrations (tag, created_at) VALUES ('${tag}', ${now})`);
4229
+ }
4230
+ async function isLegacyDatabase(db2) {
4231
+ try {
4232
+ const client = db2.$client;
4233
+ if (client && typeof client.prepare === "function") {
4234
+ const bunClient = client;
4235
+ const tables = bunClient.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='boards'").all();
4236
+ return tables.length > 0;
4237
+ }
4238
+ if (client && typeof client.execute === "function") {
4239
+ const libsqlClient = client;
4240
+ const res = await libsqlClient.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='boards'");
4241
+ return res.rows.length > 0;
4242
+ }
4243
+ return false;
4244
+ } catch {
4245
+ return false;
4246
+ }
4247
+ }
4248
+ async function runMigrations(db2) {
4249
+ const isLegacy = await isLegacyDatabase(db2);
4250
+ await createMigrationsTable(db2);
4251
+ const applied = await getAppliedMigrations(db2);
4252
+ if (isLegacy && applied.size === 0) {
4253
+ await recordMigration(db2, "0000_init");
4254
+ applied.add("0000_init");
4255
+ }
4256
+ const migrations = getMigrations();
4257
+ const toApply = migrations.filter((m) => !applied.has(m.tag));
4258
+ const newlyApplied = [];
4259
+ for (const migration of toApply) {
4260
+ if (!migration.sql) {
4261
+ throw new Error(`Migration SQL not found for: ${migration.tag}`);
4262
+ }
4263
+ const statements = migration.sql.split("--> statement-breakpoint").map((s) => s.trim()).filter(Boolean);
4264
+ for (const stmt of statements) {
4265
+ try {
4266
+ await db2.$runRaw(stmt);
4267
+ } catch (err) {
4268
+ const msg = String(err);
4269
+ if (stmt.includes("ADD COLUMN") && msg.includes("duplicate column name")) {
4270
+ continue;
4271
+ }
4272
+ throw err;
4273
+ }
4274
+ }
4275
+ await recordMigration(db2, migration.tag);
4276
+ newlyApplied.push(migration.tag);
4277
+ }
4278
+ return { applied: newlyApplied };
4279
+ }
4280
+ var migrationSql, __dirname2, drizzleDir;
4281
+ var init_migrator = __esm(() => {
4282
+ init__journal();
4283
+ init_0000_init();
4284
+ init_0001_add_archived();
4285
+ init_0002_add_fts5();
4286
+ migrationSql = {
4287
+ "0000_init": _0000_init_default,
4288
+ "0001_add_archived": _0001_add_archived_default,
4289
+ "0002_add_fts5": _0002_add_fts5_default
4290
+ };
4291
+ __dirname2 = dirname(fileURLToPath(import.meta.url));
4292
+ drizzleDir = join(__dirname2, "..", "..", "drizzle");
4293
+ });
4294
+
4295
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/logger.js
3830
4296
  var ConsoleLogWriter, DefaultLogger, NoopLogger;
3831
4297
  var init_logger = __esm(() => {
3832
4298
  init_entity();
@@ -3860,7 +4326,7 @@ var init_logger = __esm(() => {
3860
4326
  };
3861
4327
  });
3862
4328
 
3863
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/bun-sqlite/session.js
4329
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/bun-sqlite/session.js
3864
4330
  var SQLiteBunSession, SQLiteBunTransaction, PreparedQuery;
3865
4331
  var init_session2 = __esm(() => {
3866
4332
  init_entity();
@@ -3966,7 +4432,7 @@ var init_session2 = __esm(() => {
3966
4432
  };
3967
4433
  });
3968
4434
 
3969
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/bun-sqlite/driver.js
4435
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/bun-sqlite/driver.js
3970
4436
  import { Database } from "bun:sqlite";
3971
4437
  function construct(client, config = {}) {
3972
4438
  const dialect2 = new SQLiteSyncDialect({ casing: config.casing });
@@ -4030,7 +4496,7 @@ var init_driver = __esm(() => {
4030
4496
  })(drizzle || (drizzle = {}));
4031
4497
  });
4032
4498
 
4033
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/bun-sqlite/index.js
4499
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/bun-sqlite/index.js
4034
4500
  var exports_bun_sqlite = {};
4035
4501
  __export(exports_bun_sqlite, {
4036
4502
  drizzle: () => drizzle,
@@ -4597,8 +5063,8 @@ var require_dist = __commonJS((exports) => {
4597
5063
  const header = report.header;
4598
5064
  return typeof header === "object" && !!header && "glibcVersionRuntime" in header;
4599
5065
  }
4600
- function load(dirname) {
4601
- const m = path.join(dirname, "index.node");
5066
+ function load(dirname2) {
5067
+ const m = path.join(dirname2, "index.node");
4602
5068
  return fs.existsSync(m) ? __require(m) : null;
4603
5069
  }
4604
5070
  exports.load = load;
@@ -4621,7 +5087,7 @@ var require_process = __commonJS((exports, module) => {
4621
5087
  var require_filesystem = __commonJS((exports, module) => {
4622
5088
  var fs = __require("fs");
4623
5089
  var LDD_PATH = "/usr/bin/ldd";
4624
- var readFileSync = (path) => fs.readFileSync(path, "utf-8");
5090
+ var readFileSync2 = (path) => fs.readFileSync(path, "utf-8");
4625
5091
  var readFile = (path) => new Promise((resolve, reject) => {
4626
5092
  fs.readFile(path, "utf-8", (err, data) => {
4627
5093
  if (err) {
@@ -4633,7 +5099,7 @@ var require_filesystem = __commonJS((exports, module) => {
4633
5099
  });
4634
5100
  module.exports = {
4635
5101
  LDD_PATH,
4636
- readFileSync,
5102
+ readFileSync: readFileSync2,
4637
5103
  readFile
4638
5104
  };
4639
5105
  });
@@ -4642,7 +5108,7 @@ var require_filesystem = __commonJS((exports, module) => {
4642
5108
  var require_detect_libc = __commonJS((exports, module) => {
4643
5109
  var childProcess = __require("child_process");
4644
5110
  var { isLinux, getReport } = require_process();
4645
- var { LDD_PATH, readFile, readFileSync } = require_filesystem();
5111
+ var { LDD_PATH, readFile, readFileSync: readFileSync2 } = require_filesystem();
4646
5112
  var cachedFamilyFilesystem;
4647
5113
  var cachedVersionFilesystem;
4648
5114
  var command = "getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";
@@ -4722,7 +5188,7 @@ var require_detect_libc = __commonJS((exports, module) => {
4722
5188
  }
4723
5189
  cachedFamilyFilesystem = null;
4724
5190
  try {
4725
- const lddContent = readFileSync(LDD_PATH);
5191
+ const lddContent = readFileSync2(LDD_PATH);
4726
5192
  cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
4727
5193
  } catch (e) {}
4728
5194
  return cachedFamilyFilesystem;
@@ -4777,7 +5243,7 @@ var require_detect_libc = __commonJS((exports, module) => {
4777
5243
  }
4778
5244
  cachedVersionFilesystem = null;
4779
5245
  try {
4780
- const lddContent = readFileSync(LDD_PATH);
5246
+ const lddContent = readFileSync2(LDD_PATH);
4781
5247
  const versionMatch = lddContent.match(RE_GLIBC_VERSION);
4782
5248
  if (versionMatch) {
4783
5249
  cachedVersionFilesystem = versionMatch[1];
@@ -15704,7 +16170,12 @@ var init_node2 = __esm(() => {
15704
16170
  init_api();
15705
16171
  });
15706
16172
 
15707
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/libsql/session.js
16173
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/cache/core/index.js
16174
+ var init_core = __esm(() => {
16175
+ init_cache();
16176
+ });
16177
+
16178
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/libsql/session.js
15708
16179
  function normalizeRow(obj) {
15709
16180
  return Object.keys(obj).reduce((acc, key) => {
15710
16181
  if (Object.prototype.propertyIsEnumerable.call(obj, key)) {
@@ -15730,6 +16201,7 @@ function normalizeFieldValue(value) {
15730
16201
  }
15731
16202
  var LibSQLSession, LibSQLTransaction, LibSQLPreparedQuery;
15732
16203
  var init_session3 = __esm(() => {
16204
+ init_core();
15733
16205
  init_entity();
15734
16206
  init_logger();
15735
16207
  init_sql();
@@ -15744,11 +16216,13 @@ var init_session3 = __esm(() => {
15744
16216
  this.options = options;
15745
16217
  this.tx = tx;
15746
16218
  this.logger = options.logger ?? new NoopLogger;
16219
+ this.cache = options.cache ?? new NoopCache;
15747
16220
  }
15748
16221
  static [entityKind] = "LibSQLSession";
15749
16222
  logger;
15750
- prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
15751
- return new LibSQLPreparedQuery(this.client, query, this.logger, fields, this.tx, executeMethod, isResponseInArrayMode, customResultMapper);
16223
+ cache;
16224
+ prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
16225
+ return new LibSQLPreparedQuery(this.client, query, this.logger, this.cache, queryMetadata, cacheConfig, fields, this.tx, executeMethod, isResponseInArrayMode, customResultMapper);
15752
16226
  }
15753
16227
  async batch(queries) {
15754
16228
  const preparedQueries = [];
@@ -15814,8 +16288,8 @@ var init_session3 = __esm(() => {
15814
16288
  }
15815
16289
  };
15816
16290
  LibSQLPreparedQuery = class LibSQLPreparedQuery extends SQLitePreparedQuery {
15817
- constructor(client, query, logger, fields, tx, executeMethod, _isResponseInArrayMode, customResultMapper) {
15818
- super("async", executeMethod, query);
16291
+ constructor(client, query, logger, cache2, queryMetadata, cacheConfig, fields, tx, executeMethod, _isResponseInArrayMode, customResultMapper) {
16292
+ super("async", executeMethod, query, cache2, queryMetadata, cacheConfig);
15819
16293
  this.client = client;
15820
16294
  this.logger = logger;
15821
16295
  this.fields = fields;
@@ -15826,19 +16300,23 @@ var init_session3 = __esm(() => {
15826
16300
  this.fields = fields;
15827
16301
  }
15828
16302
  static [entityKind] = "LibSQLPreparedQuery";
15829
- run(placeholderValues) {
16303
+ async run(placeholderValues) {
15830
16304
  const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
15831
16305
  this.logger.logQuery(this.query.sql, params);
15832
- const stmt = { sql: this.query.sql, args: params };
15833
- return this.tx ? this.tx.execute(stmt) : this.client.execute(stmt);
16306
+ return await this.queryWithCache(this.query.sql, params, async () => {
16307
+ const stmt = { sql: this.query.sql, args: params };
16308
+ return this.tx ? this.tx.execute(stmt) : this.client.execute(stmt);
16309
+ });
15834
16310
  }
15835
16311
  async all(placeholderValues) {
15836
16312
  const { fields, logger, query, tx, client, customResultMapper } = this;
15837
16313
  if (!fields && !customResultMapper) {
15838
16314
  const params = fillPlaceholders(query.params, placeholderValues ?? {});
15839
16315
  logger.logQuery(query.sql, params);
15840
- const stmt = { sql: query.sql, args: params };
15841
- return (tx ? tx.execute(stmt) : client.execute(stmt)).then(({ rows: rows2 }) => this.mapAllResult(rows2));
16316
+ return await this.queryWithCache(query.sql, params, async () => {
16317
+ const stmt = { sql: query.sql, args: params };
16318
+ return (tx ? tx.execute(stmt) : client.execute(stmt)).then(({ rows: rows2 }) => this.mapAllResult(rows2));
16319
+ });
15842
16320
  }
15843
16321
  const rows = await this.values(placeholderValues);
15844
16322
  return this.mapAllResult(rows);
@@ -15862,8 +16340,10 @@ var init_session3 = __esm(() => {
15862
16340
  if (!fields && !customResultMapper) {
15863
16341
  const params = fillPlaceholders(query.params, placeholderValues ?? {});
15864
16342
  logger.logQuery(query.sql, params);
15865
- const stmt = { sql: query.sql, args: params };
15866
- return (tx ? tx.execute(stmt) : client.execute(stmt)).then(({ rows: rows2 }) => this.mapGetResult(rows2));
16343
+ return await this.queryWithCache(query.sql, params, async () => {
16344
+ const stmt = { sql: query.sql, args: params };
16345
+ return (tx ? tx.execute(stmt) : client.execute(stmt)).then(({ rows: rows2 }) => this.mapGetResult(rows2));
16346
+ });
15867
16347
  }
15868
16348
  const rows = await this.values(placeholderValues);
15869
16349
  return this.mapGetResult(rows);
@@ -15884,11 +16364,13 @@ var init_session3 = __esm(() => {
15884
16364
  }
15885
16365
  return mapResultRow(this.fields, Array.prototype.slice.call(row).map((v) => normalizeFieldValue(v)), this.joinsNotNullableMap);
15886
16366
  }
15887
- values(placeholderValues) {
16367
+ async values(placeholderValues) {
15888
16368
  const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
15889
16369
  this.logger.logQuery(this.query.sql, params);
15890
- const stmt = { sql: this.query.sql, args: params };
15891
- return (this.tx ? this.tx.execute(stmt) : this.client.execute(stmt)).then(({ rows }) => rows);
16370
+ return await this.queryWithCache(this.query.sql, params, async () => {
16371
+ const stmt = { sql: this.query.sql, args: params };
16372
+ return (this.tx ? this.tx.execute(stmt) : this.client.execute(stmt)).then(({ rows }) => rows);
16373
+ });
15892
16374
  }
15893
16375
  isResponseInArrayMode() {
15894
16376
  return this._isResponseInArrayMode;
@@ -15896,7 +16378,7 @@ var init_session3 = __esm(() => {
15896
16378
  };
15897
16379
  });
15898
16380
 
15899
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/libsql/driver-core.js
16381
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/libsql/driver-core.js
15900
16382
  function construct2(client, config = {}) {
15901
16383
  const dialect2 = new SQLiteAsyncDialect({ casing: config.casing });
15902
16384
  let logger;
@@ -15914,9 +16396,13 @@ function construct2(client, config = {}) {
15914
16396
  tableNamesMap: tablesConfig.tableNamesMap
15915
16397
  };
15916
16398
  }
15917
- const session3 = new LibSQLSession(client, dialect2, schema, { logger }, undefined);
16399
+ const session3 = new LibSQLSession(client, dialect2, schema, { logger, cache: config.cache }, undefined);
15918
16400
  const db2 = new LibSQLDatabase("async", dialect2, session3, schema);
15919
16401
  db2.$client = client;
16402
+ db2.$cache = config.cache;
16403
+ if (db2.$cache) {
16404
+ db2.$cache["invalidate"] = config.cache?.onMutate;
16405
+ }
15920
16406
  return db2;
15921
16407
  }
15922
16408
  var LibSQLDatabase;
@@ -15935,7 +16421,7 @@ var init_driver_core = __esm(() => {
15935
16421
  };
15936
16422
  });
15937
16423
 
15938
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/libsql/driver.js
16424
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/libsql/driver.js
15939
16425
  function drizzle2(...params) {
15940
16426
  if (typeof params[0] === "string") {
15941
16427
  const instance = createClient({
@@ -15965,7 +16451,7 @@ var init_driver2 = __esm(() => {
15965
16451
  })(drizzle2 || (drizzle2 = {}));
15966
16452
  });
15967
16453
 
15968
- // ../../node_modules/.bun/drizzle-orm@0.38.4/node_modules/drizzle-orm/libsql/index.js
16454
+ // ../../node_modules/.bun/drizzle-orm@0.45.1/node_modules/drizzle-orm/libsql/index.js
15969
16455
  var exports_libsql = {};
15970
16456
  __export(exports_libsql, {
15971
16457
  drizzle: () => drizzle2,
@@ -15979,175 +16465,44 @@ var init_libsql = __esm(() => {
15979
16465
  init_session3();
15980
16466
  });
15981
16467
 
15982
- // ../../node_modules/.bun/ulid@2.4.0/node_modules/ulid/dist/index.umd.js
15983
- var require_index_umd = __commonJS((exports, module) => {
15984
- (function(global2, factory) {
15985
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.ULID = {}));
15986
- })(exports, function(exports2) {
15987
- function createError(message) {
15988
- const err = new Error(message);
15989
- err.source = "ulid";
15990
- return err;
15991
- }
15992
- const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
15993
- const ENCODING_LEN = ENCODING.length;
15994
- const TIME_MAX = Math.pow(2, 48) - 1;
15995
- const TIME_LEN = 10;
15996
- const RANDOM_LEN = 16;
15997
- function replaceCharAt(str, index, char) {
15998
- if (index > str.length - 1) {
15999
- return str;
16000
- }
16001
- return str.substr(0, index) + char + str.substr(index + 1);
16002
- }
16003
- function incrementBase32(str) {
16004
- let done = undefined;
16005
- let index = str.length;
16006
- let char;
16007
- let charIndex;
16008
- const maxCharIndex = ENCODING_LEN - 1;
16009
- while (!done && index-- >= 0) {
16010
- char = str[index];
16011
- charIndex = ENCODING.indexOf(char);
16012
- if (charIndex === -1) {
16013
- throw createError("incorrectly encoded string");
16014
- }
16015
- if (charIndex === maxCharIndex) {
16016
- str = replaceCharAt(str, index, ENCODING[0]);
16017
- continue;
16018
- }
16019
- done = replaceCharAt(str, index, ENCODING[charIndex + 1]);
16020
- }
16021
- if (typeof done === "string") {
16022
- return done;
16023
- }
16024
- throw createError("cannot increment this string");
16025
- }
16026
- function randomChar(prng) {
16027
- let rand = Math.floor(prng() * ENCODING_LEN);
16028
- if (rand === ENCODING_LEN) {
16029
- rand = ENCODING_LEN - 1;
16030
- }
16031
- return ENCODING.charAt(rand);
16032
- }
16033
- function encodeTime(now, len) {
16034
- if (isNaN(now)) {
16035
- throw new Error(now + " must be a number");
16036
- }
16037
- if (now > TIME_MAX) {
16038
- throw createError("cannot encode time greater than " + TIME_MAX);
16039
- }
16040
- if (now < 0) {
16041
- throw createError("time must be positive");
16042
- }
16043
- if (Number.isInteger(Number(now)) === false) {
16044
- throw createError("time must be an integer");
16045
- }
16046
- let mod;
16047
- let str = "";
16048
- for (;len > 0; len--) {
16049
- mod = now % ENCODING_LEN;
16050
- str = ENCODING.charAt(mod) + str;
16051
- now = (now - mod) / ENCODING_LEN;
16052
- }
16053
- return str;
16054
- }
16055
- function encodeRandom(len, prng) {
16056
- let str = "";
16057
- for (;len > 0; len--) {
16058
- str = randomChar(prng) + str;
16059
- }
16060
- return str;
16061
- }
16062
- function decodeTime(id) {
16063
- if (id.length !== TIME_LEN + RANDOM_LEN) {
16064
- throw createError("malformed ulid");
16065
- }
16066
- var time3 = id.substr(0, TIME_LEN).split("").reverse().reduce((carry, char, index) => {
16067
- const encodingIndex = ENCODING.indexOf(char);
16068
- if (encodingIndex === -1) {
16069
- throw createError("invalid character found: " + char);
16070
- }
16071
- return carry += encodingIndex * Math.pow(ENCODING_LEN, index);
16072
- }, 0);
16073
- if (time3 > TIME_MAX) {
16074
- throw createError("malformed ulid, timestamp too large");
16075
- }
16076
- return time3;
16077
- }
16078
- function detectPrng(allowInsecure = false, root) {
16079
- if (!root) {
16080
- root = typeof window !== "undefined" ? window : null;
16081
- }
16082
- const browserCrypto = root && (root.crypto || root.msCrypto);
16083
- if (browserCrypto) {
16084
- return () => {
16085
- const buffer = new Uint8Array(1);
16086
- browserCrypto.getRandomValues(buffer);
16087
- return buffer[0] / 255;
16088
- };
16089
- } else {
16090
- try {
16091
- const nodeCrypto = __require("crypto");
16092
- return () => nodeCrypto.randomBytes(1).readUInt8() / 255;
16093
- } catch (e) {}
16094
- }
16095
- if (allowInsecure) {
16096
- try {
16097
- console.error("secure crypto unusable, falling back to insecure Math.random()!");
16098
- } catch (e) {}
16099
- return () => Math.random();
16100
- }
16101
- throw createError("secure crypto unusable, insecure Math.random not allowed");
16102
- }
16103
- function factory(currPrng) {
16104
- if (!currPrng) {
16105
- currPrng = detectPrng();
16106
- }
16107
- return function ulid(seedTime) {
16108
- if (isNaN(seedTime)) {
16109
- seedTime = Date.now();
16110
- }
16111
- return encodeTime(seedTime, TIME_LEN) + encodeRandom(RANDOM_LEN, currPrng);
16112
- };
16113
- }
16114
- function monotonicFactory(currPrng) {
16115
- if (!currPrng) {
16116
- currPrng = detectPrng();
16117
- }
16118
- let lastTime = 0;
16119
- let lastRandom;
16120
- return function ulid(seedTime) {
16121
- if (isNaN(seedTime)) {
16122
- seedTime = Date.now();
16123
- }
16124
- if (seedTime <= lastTime) {
16125
- const incrementedRandom = lastRandom = incrementBase32(lastRandom);
16126
- return encodeTime(lastTime, TIME_LEN) + incrementedRandom;
16127
- }
16128
- lastTime = seedTime;
16129
- const newRandom = lastRandom = encodeRandom(RANDOM_LEN, currPrng);
16130
- return encodeTime(seedTime, TIME_LEN) + newRandom;
16131
- };
16132
- }
16133
- const ulid3 = factory();
16134
- exports2.decodeTime = decodeTime;
16135
- exports2.detectPrng = detectPrng;
16136
- exports2.encodeRandom = encodeRandom;
16137
- exports2.encodeTime = encodeTime;
16138
- exports2.factory = factory;
16139
- exports2.incrementBase32 = incrementBase32;
16140
- exports2.monotonicFactory = monotonicFactory;
16141
- exports2.randomChar = randomChar;
16142
- exports2.replaceCharAt = replaceCharAt;
16143
- exports2.ulid = ulid3;
16144
- });
16145
- });
16146
-
16147
16468
  // src/db/index.ts
16148
16469
  import { existsSync, mkdirSync } from "node:fs";
16149
- import { dirname } from "node:path";
16150
- import { fileURLToPath } from "node:url";
16470
+ import { dirname as dirname2 } from "node:path";
16471
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
16472
+
16473
+ // src/types.ts
16474
+ var DEFAULT_CONFIG = {
16475
+ board: {
16476
+ name: "Kaban Board"
16477
+ },
16478
+ columns: [
16479
+ { id: "backlog", name: "Backlog" },
16480
+ { id: "todo", name: "Todo" },
16481
+ { id: "in_progress", name: "In Progress", wipLimit: 3 },
16482
+ { id: "review", name: "Review", wipLimit: 2 },
16483
+ { id: "done", name: "Done", isTerminal: true }
16484
+ ],
16485
+ defaults: {
16486
+ column: "todo",
16487
+ agent: "user"
16488
+ }
16489
+ };
16490
+
16491
+ class KabanError extends Error {
16492
+ code;
16493
+ constructor(message, code) {
16494
+ super(message);
16495
+ this.code = code;
16496
+ this.name = "KabanError";
16497
+ }
16498
+ }
16499
+ var ExitCode = {
16500
+ SUCCESS: 0,
16501
+ GENERAL_ERROR: 1,
16502
+ NOT_FOUND: 2,
16503
+ CONFLICT: 3,
16504
+ VALIDATION: 4
16505
+ };
16151
16506
 
16152
16507
  // src/db/schema.ts
16153
16508
  init_sqlite_core();
@@ -16189,7 +16544,9 @@ var tasks = sqliteTable("tasks", {
16189
16544
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
16190
16545
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull(),
16191
16546
  startedAt: integer("started_at", { mode: "timestamp" }),
16192
- completedAt: integer("completed_at", { mode: "timestamp" })
16547
+ completedAt: integer("completed_at", { mode: "timestamp" }),
16548
+ archived: integer("archived", { mode: "boolean" }).notNull().default(false),
16549
+ archivedAt: integer("archived_at", { mode: "timestamp" })
16193
16550
  });
16194
16551
  var undoLog = sqliteTable("undo_log", {
16195
16552
  id: integer("id").primaryKey({ autoIncrement: true }),
@@ -16198,54 +16555,21 @@ var undoLog = sqliteTable("undo_log", {
16198
16555
  createdAt: integer("created_at", { mode: "timestamp" }).notNull()
16199
16556
  });
16200
16557
 
16201
- // src/types.ts
16202
- var DEFAULT_CONFIG = {
16203
- board: {
16204
- name: "Kaban Board"
16205
- },
16206
- columns: [
16207
- { id: "backlog", name: "Backlog" },
16208
- { id: "todo", name: "Todo" },
16209
- { id: "in_progress", name: "In Progress", wipLimit: 3 },
16210
- { id: "review", name: "Review", wipLimit: 2 },
16211
- { id: "done", name: "Done", isTerminal: true }
16212
- ],
16213
- defaults: {
16214
- column: "todo",
16215
- agent: "user"
16216
- }
16217
- };
16218
-
16219
- class KabanError extends Error {
16220
- code;
16221
- constructor(message, code) {
16222
- super(message);
16223
- this.code = code;
16224
- this.name = "KabanError";
16225
- }
16226
- }
16227
- var ExitCode = {
16228
- SUCCESS: 0,
16229
- GENERAL_ERROR: 1,
16230
- NOT_FOUND: 2,
16231
- CONFLICT: 3,
16232
- VALIDATION: 4
16233
- };
16234
-
16235
16558
  // src/db/index.ts
16559
+ init_migrator();
16236
16560
  var isBun = typeof globalThis.Bun !== "undefined" && typeof globalThis.Bun.version === "string";
16237
16561
  function fileUrlToPath(urlOrPath) {
16238
16562
  if (!urlOrPath.startsWith("file:"))
16239
16563
  return urlOrPath;
16240
16564
  if (urlOrPath.startsWith("file:///") || urlOrPath.startsWith("file://localhost/")) {
16241
- return fileURLToPath(urlOrPath);
16565
+ return fileURLToPath2(urlOrPath);
16242
16566
  }
16243
16567
  return urlOrPath.replace(/^file:/, "");
16244
16568
  }
16245
16569
  function ensureDbDir(filePath) {
16246
16570
  if (filePath === ":memory:" || filePath.trim() === "")
16247
16571
  return;
16248
- const dir = dirname(filePath);
16572
+ const dir = dirname2(filePath);
16249
16573
  if (!existsSync(dir)) {
16250
16574
  mkdirSync(dir, { recursive: true });
16251
16575
  }
@@ -16333,18 +16657,22 @@ async function createLibsqlDb(config) {
16333
16657
  throw new KabanError(`Failed to create libsql database: ${error instanceof Error ? error.message : String(error)}`, ExitCode.GENERAL_ERROR);
16334
16658
  }
16335
16659
  }
16336
- async function createDb(config) {
16660
+ async function createDb(config, options = {}) {
16661
+ const { migrate = true } = options;
16337
16662
  try {
16663
+ let db2;
16338
16664
  if (typeof config === "string") {
16339
- if (isBun) {
16340
- return await createBunDb(config);
16341
- }
16342
- return await createLibsqlDb({ url: `file:${config}` });
16665
+ db2 = isBun ? await createBunDb(config) : await createLibsqlDb({ url: `file:${config}` });
16666
+ } else if (isBun && config.url.startsWith("file:")) {
16667
+ db2 = await createBunDb(fileUrlToPath(config.url));
16668
+ } else {
16669
+ db2 = await createLibsqlDb(config);
16343
16670
  }
16344
- if (isBun && config.url.startsWith("file:")) {
16345
- return await createBunDb(fileUrlToPath(config.url));
16671
+ if (migrate) {
16672
+ const { runMigrations: runMigrations2 } = await Promise.resolve().then(() => (init_migrator(), exports_migrator));
16673
+ await runMigrations2(db2);
16346
16674
  }
16347
- return await createLibsqlDb(config);
16675
+ return db2;
16348
16676
  } catch (error) {
16349
16677
  if (error instanceof KabanError)
16350
16678
  throw error;
@@ -16387,7 +16715,9 @@ CREATE TABLE IF NOT EXISTS tasks (
16387
16715
  created_at INTEGER NOT NULL,
16388
16716
  updated_at INTEGER NOT NULL,
16389
16717
  started_at INTEGER,
16390
- completed_at INTEGER
16718
+ completed_at INTEGER,
16719
+ archived INTEGER NOT NULL DEFAULT 0,
16720
+ archived_at INTEGER
16391
16721
  );
16392
16722
 
16393
16723
  CREATE TABLE IF NOT EXISTS undo_log (
@@ -16403,7 +16733,7 @@ CREATE INDEX IF NOT EXISTS idx_tasks_parent ON tasks(parent_id);
16403
16733
  async function initializeSchema(db2) {
16404
16734
  await db2.$runRaw(SCHEMA_SQL);
16405
16735
  }
16406
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/external.js
16736
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
16407
16737
  var exports_external = {};
16408
16738
  __export(exports_external, {
16409
16739
  xor: () => xor,
@@ -16644,7 +16974,7 @@ __export(exports_external, {
16644
16974
  $brand: () => $brand
16645
16975
  });
16646
16976
 
16647
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/index.js
16977
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/index.js
16648
16978
  var exports_core2 = {};
16649
16979
  __export(exports_core2, {
16650
16980
  version: () => version3,
@@ -16922,7 +17252,7 @@ __export(exports_core2, {
16922
17252
  $ZodAny: () => $ZodAny
16923
17253
  });
16924
17254
 
16925
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/core.js
17255
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
16926
17256
  var NEVER = Object.freeze({
16927
17257
  status: "aborted"
16928
17258
  });
@@ -16998,7 +17328,7 @@ function config(newConfig) {
16998
17328
  Object.assign(globalConfig, newConfig);
16999
17329
  return globalConfig;
17000
17330
  }
17001
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/util.js
17331
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js
17002
17332
  var exports_util = {};
17003
17333
  __export(exports_util, {
17004
17334
  unwrapMessage: () => unwrapMessage,
@@ -17672,7 +18002,7 @@ class Class {
17672
18002
  constructor(..._args) {}
17673
18003
  }
17674
18004
 
17675
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/errors.js
18005
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js
17676
18006
  var initializer = (inst, def) => {
17677
18007
  inst.name = "$ZodError";
17678
18008
  Object.defineProperty(inst, "_zod", {
@@ -17809,7 +18139,7 @@ function prettifyError(error) {
17809
18139
  `);
17810
18140
  }
17811
18141
 
17812
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/parse.js
18142
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js
17813
18143
  var _parse = (_Err) => (schema2, value, _ctx, _params) => {
17814
18144
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
17815
18145
  const result = schema2._zod.run({ value, issues: [] }, ctx);
@@ -17896,7 +18226,7 @@ var _safeDecodeAsync = (_Err) => async (schema2, value, _ctx) => {
17896
18226
  return _safeParseAsync(_Err)(schema2, value, _ctx);
17897
18227
  };
17898
18228
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
17899
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/regexes.js
18229
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/regexes.js
17900
18230
  var exports_regexes = {};
17901
18231
  __export(exports_regexes, {
17902
18232
  xid: () => xid,
@@ -18053,7 +18383,7 @@ var sha512_hex = /^[0-9a-fA-F]{128}$/;
18053
18383
  var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
18054
18384
  var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
18055
18385
 
18056
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/checks.js
18386
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/checks.js
18057
18387
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
18058
18388
  var _a;
18059
18389
  inst._zod ?? (inst._zod = {});
@@ -18600,7 +18930,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
18600
18930
  };
18601
18931
  });
18602
18932
 
18603
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/doc.js
18933
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/doc.js
18604
18934
  class Doc {
18605
18935
  constructor(args = []) {
18606
18936
  this.content = [];
@@ -18638,14 +18968,14 @@ class Doc {
18638
18968
  }
18639
18969
  }
18640
18970
 
18641
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/versions.js
18971
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/versions.js
18642
18972
  var version3 = {
18643
18973
  major: 4,
18644
18974
  minor: 3,
18645
- patch: 5
18975
+ patch: 6
18646
18976
  };
18647
18977
 
18648
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/schemas.js
18978
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/schemas.js
18649
18979
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
18650
18980
  var _a;
18651
18981
  inst ?? (inst = {});
@@ -19928,7 +20258,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
19928
20258
  if (keyResult instanceof Promise) {
19929
20259
  throw new Error("Async schemas not supported in object keys currently");
19930
20260
  }
19931
- const checkNumericKey = typeof key === "string" && number2.test(key) && keyResult.issues.length && keyResult.issues.some((iss) => iss.code === "invalid_type" && iss.expected === "number");
20261
+ const checkNumericKey = typeof key === "string" && number2.test(key) && keyResult.issues.length;
19932
20262
  if (checkNumericKey) {
19933
20263
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
19934
20264
  if (retryResult instanceof Promise) {
@@ -20607,7 +20937,7 @@ function handleRefineResult(result, payload, input, inst) {
20607
20937
  payload.issues.push(issue(_iss));
20608
20938
  }
20609
20939
  }
20610
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/index.js
20940
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/index.js
20611
20941
  var exports_locales = {};
20612
20942
  __export(exports_locales, {
20613
20943
  zhTW: () => zh_TW_default,
@@ -20661,7 +20991,7 @@ __export(exports_locales, {
20661
20991
  ar: () => ar_default
20662
20992
  });
20663
20993
 
20664
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ar.js
20994
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ar.js
20665
20995
  var error = () => {
20666
20996
  const Sizable = {
20667
20997
  string: { unit: "حرف", verb: "أن يحوي" },
@@ -20767,7 +21097,7 @@ function ar_default() {
20767
21097
  localeError: error()
20768
21098
  };
20769
21099
  }
20770
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/az.js
21100
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/az.js
20771
21101
  var error2 = () => {
20772
21102
  const Sizable = {
20773
21103
  string: { unit: "simvol", verb: "olmalıdır" },
@@ -20872,7 +21202,7 @@ function az_default() {
20872
21202
  localeError: error2()
20873
21203
  };
20874
21204
  }
20875
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/be.js
21205
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/be.js
20876
21206
  function getBelarusianPlural(count, one, few, many) {
20877
21207
  const absCount = Math.abs(count);
20878
21208
  const lastDigit = absCount % 10;
@@ -21028,7 +21358,7 @@ function be_default() {
21028
21358
  localeError: error3()
21029
21359
  };
21030
21360
  }
21031
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/bg.js
21361
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/bg.js
21032
21362
  var error4 = () => {
21033
21363
  const Sizable = {
21034
21364
  string: { unit: "символа", verb: "да съдържа" },
@@ -21148,7 +21478,7 @@ function bg_default() {
21148
21478
  localeError: error4()
21149
21479
  };
21150
21480
  }
21151
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ca.js
21481
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ca.js
21152
21482
  var error5 = () => {
21153
21483
  const Sizable = {
21154
21484
  string: { unit: "caràcters", verb: "contenir" },
@@ -21255,7 +21585,7 @@ function ca_default() {
21255
21585
  localeError: error5()
21256
21586
  };
21257
21587
  }
21258
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/cs.js
21588
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/cs.js
21259
21589
  var error6 = () => {
21260
21590
  const Sizable = {
21261
21591
  string: { unit: "znaků", verb: "mít" },
@@ -21366,7 +21696,7 @@ function cs_default() {
21366
21696
  localeError: error6()
21367
21697
  };
21368
21698
  }
21369
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/da.js
21699
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/da.js
21370
21700
  var error7 = () => {
21371
21701
  const Sizable = {
21372
21702
  string: { unit: "tegn", verb: "havde" },
@@ -21481,7 +21811,7 @@ function da_default() {
21481
21811
  localeError: error7()
21482
21812
  };
21483
21813
  }
21484
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/de.js
21814
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/de.js
21485
21815
  var error8 = () => {
21486
21816
  const Sizable = {
21487
21817
  string: { unit: "Zeichen", verb: "zu haben" },
@@ -21589,7 +21919,7 @@ function de_default() {
21589
21919
  localeError: error8()
21590
21920
  };
21591
21921
  }
21592
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/en.js
21922
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/en.js
21593
21923
  var error9 = () => {
21594
21924
  const Sizable = {
21595
21925
  string: { unit: "characters", verb: "to have" },
@@ -21695,7 +22025,7 @@ function en_default() {
21695
22025
  localeError: error9()
21696
22026
  };
21697
22027
  }
21698
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/eo.js
22028
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/eo.js
21699
22029
  var error10 = () => {
21700
22030
  const Sizable = {
21701
22031
  string: { unit: "karaktrojn", verb: "havi" },
@@ -21804,7 +22134,7 @@ function eo_default() {
21804
22134
  localeError: error10()
21805
22135
  };
21806
22136
  }
21807
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/es.js
22137
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/es.js
21808
22138
  var error11 = () => {
21809
22139
  const Sizable = {
21810
22140
  string: { unit: "caracteres", verb: "tener" },
@@ -21936,7 +22266,7 @@ function es_default() {
21936
22266
  localeError: error11()
21937
22267
  };
21938
22268
  }
21939
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/fa.js
22269
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/fa.js
21940
22270
  var error12 = () => {
21941
22271
  const Sizable = {
21942
22272
  string: { unit: "کاراکتر", verb: "داشته باشد" },
@@ -22050,7 +22380,7 @@ function fa_default() {
22050
22380
  localeError: error12()
22051
22381
  };
22052
22382
  }
22053
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/fi.js
22383
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/fi.js
22054
22384
  var error13 = () => {
22055
22385
  const Sizable = {
22056
22386
  string: { unit: "merkkiä", subject: "merkkijonon" },
@@ -22162,7 +22492,7 @@ function fi_default() {
22162
22492
  localeError: error13()
22163
22493
  };
22164
22494
  }
22165
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/fr.js
22495
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/fr.js
22166
22496
  var error14 = () => {
22167
22497
  const Sizable = {
22168
22498
  string: { unit: "caractères", verb: "avoir" },
@@ -22270,7 +22600,7 @@ function fr_default() {
22270
22600
  localeError: error14()
22271
22601
  };
22272
22602
  }
22273
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/fr-CA.js
22603
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/fr-CA.js
22274
22604
  var error15 = () => {
22275
22605
  const Sizable = {
22276
22606
  string: { unit: "caractères", verb: "avoir" },
@@ -22377,7 +22707,7 @@ function fr_CA_default() {
22377
22707
  localeError: error15()
22378
22708
  };
22379
22709
  }
22380
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/he.js
22710
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/he.js
22381
22711
  var error16 = () => {
22382
22712
  const TypeNames = {
22383
22713
  string: { label: "מחרוזת", gender: "f" },
@@ -22570,7 +22900,7 @@ function he_default() {
22570
22900
  localeError: error16()
22571
22901
  };
22572
22902
  }
22573
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/hu.js
22903
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/hu.js
22574
22904
  var error17 = () => {
22575
22905
  const Sizable = {
22576
22906
  string: { unit: "karakter", verb: "legyen" },
@@ -22678,7 +23008,7 @@ function hu_default() {
22678
23008
  localeError: error17()
22679
23009
  };
22680
23010
  }
22681
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/hy.js
23011
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/hy.js
22682
23012
  function getArmenianPlural(count, one, many) {
22683
23013
  return Math.abs(count) === 1 ? one : many;
22684
23014
  }
@@ -22825,7 +23155,7 @@ function hy_default() {
22825
23155
  localeError: error18()
22826
23156
  };
22827
23157
  }
22828
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/id.js
23158
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/id.js
22829
23159
  var error19 = () => {
22830
23160
  const Sizable = {
22831
23161
  string: { unit: "karakter", verb: "memiliki" },
@@ -22931,7 +23261,7 @@ function id_default() {
22931
23261
  localeError: error19()
22932
23262
  };
22933
23263
  }
22934
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/is.js
23264
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/is.js
22935
23265
  var error20 = () => {
22936
23266
  const Sizable = {
22937
23267
  string: { unit: "stafi", verb: "að hafa" },
@@ -23040,7 +23370,7 @@ function is_default() {
23040
23370
  localeError: error20()
23041
23371
  };
23042
23372
  }
23043
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/it.js
23373
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/it.js
23044
23374
  var error21 = () => {
23045
23375
  const Sizable = {
23046
23376
  string: { unit: "caratteri", verb: "avere" },
@@ -23148,7 +23478,7 @@ function it_default() {
23148
23478
  localeError: error21()
23149
23479
  };
23150
23480
  }
23151
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ja.js
23481
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ja.js
23152
23482
  var error22 = () => {
23153
23483
  const Sizable = {
23154
23484
  string: { unit: "文字", verb: "である" },
@@ -23255,7 +23585,7 @@ function ja_default() {
23255
23585
  localeError: error22()
23256
23586
  };
23257
23587
  }
23258
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ka.js
23588
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ka.js
23259
23589
  var error23 = () => {
23260
23590
  const Sizable = {
23261
23591
  string: { unit: "სიმბოლო", verb: "უნდა შეიცავდეს" },
@@ -23367,7 +23697,7 @@ function ka_default() {
23367
23697
  localeError: error23()
23368
23698
  };
23369
23699
  }
23370
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/km.js
23700
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/km.js
23371
23701
  var error24 = () => {
23372
23702
  const Sizable = {
23373
23703
  string: { unit: "តួអក្សរ", verb: "គួរមាន" },
@@ -23478,11 +23808,11 @@ function km_default() {
23478
23808
  };
23479
23809
  }
23480
23810
 
23481
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/kh.js
23811
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/kh.js
23482
23812
  function kh_default() {
23483
23813
  return km_default();
23484
23814
  }
23485
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ko.js
23815
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ko.js
23486
23816
  var error25 = () => {
23487
23817
  const Sizable = {
23488
23818
  string: { unit: "문자", verb: "to have" },
@@ -23593,7 +23923,7 @@ function ko_default() {
23593
23923
  localeError: error25()
23594
23924
  };
23595
23925
  }
23596
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/lt.js
23926
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/lt.js
23597
23927
  var capitalizeFirstCharacter = (text3) => {
23598
23928
  return text3.charAt(0).toUpperCase() + text3.slice(1);
23599
23929
  };
@@ -23796,7 +24126,7 @@ function lt_default() {
23796
24126
  localeError: error26()
23797
24127
  };
23798
24128
  }
23799
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/mk.js
24129
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/mk.js
23800
24130
  var error27 = () => {
23801
24131
  const Sizable = {
23802
24132
  string: { unit: "знаци", verb: "да имаат" },
@@ -23905,7 +24235,7 @@ function mk_default() {
23905
24235
  localeError: error27()
23906
24236
  };
23907
24237
  }
23908
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ms.js
24238
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ms.js
23909
24239
  var error28 = () => {
23910
24240
  const Sizable = {
23911
24241
  string: { unit: "aksara", verb: "mempunyai" },
@@ -24012,7 +24342,7 @@ function ms_default() {
24012
24342
  localeError: error28()
24013
24343
  };
24014
24344
  }
24015
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/nl.js
24345
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/nl.js
24016
24346
  var error29 = () => {
24017
24347
  const Sizable = {
24018
24348
  string: { unit: "tekens", verb: "heeft" },
@@ -24122,7 +24452,7 @@ function nl_default() {
24122
24452
  localeError: error29()
24123
24453
  };
24124
24454
  }
24125
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/no.js
24455
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/no.js
24126
24456
  var error30 = () => {
24127
24457
  const Sizable = {
24128
24458
  string: { unit: "tegn", verb: "å ha" },
@@ -24230,7 +24560,7 @@ function no_default() {
24230
24560
  localeError: error30()
24231
24561
  };
24232
24562
  }
24233
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ota.js
24563
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ota.js
24234
24564
  var error31 = () => {
24235
24565
  const Sizable = {
24236
24566
  string: { unit: "harf", verb: "olmalıdır" },
@@ -24339,7 +24669,7 @@ function ota_default() {
24339
24669
  localeError: error31()
24340
24670
  };
24341
24671
  }
24342
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ps.js
24672
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ps.js
24343
24673
  var error32 = () => {
24344
24674
  const Sizable = {
24345
24675
  string: { unit: "توکي", verb: "ولري" },
@@ -24453,7 +24783,7 @@ function ps_default() {
24453
24783
  localeError: error32()
24454
24784
  };
24455
24785
  }
24456
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/pl.js
24786
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/pl.js
24457
24787
  var error33 = () => {
24458
24788
  const Sizable = {
24459
24789
  string: { unit: "znaków", verb: "mieć" },
@@ -24562,7 +24892,7 @@ function pl_default() {
24562
24892
  localeError: error33()
24563
24893
  };
24564
24894
  }
24565
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/pt.js
24895
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/pt.js
24566
24896
  var error34 = () => {
24567
24897
  const Sizable = {
24568
24898
  string: { unit: "caracteres", verb: "ter" },
@@ -24670,7 +25000,7 @@ function pt_default() {
24670
25000
  localeError: error34()
24671
25001
  };
24672
25002
  }
24673
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ru.js
25003
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ru.js
24674
25004
  function getRussianPlural(count, one, few, many) {
24675
25005
  const absCount = Math.abs(count);
24676
25006
  const lastDigit = absCount % 10;
@@ -24826,7 +25156,7 @@ function ru_default() {
24826
25156
  localeError: error35()
24827
25157
  };
24828
25158
  }
24829
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/sl.js
25159
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/sl.js
24830
25160
  var error36 = () => {
24831
25161
  const Sizable = {
24832
25162
  string: { unit: "znakov", verb: "imeti" },
@@ -24935,7 +25265,7 @@ function sl_default() {
24935
25265
  localeError: error36()
24936
25266
  };
24937
25267
  }
24938
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/sv.js
25268
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/sv.js
24939
25269
  var error37 = () => {
24940
25270
  const Sizable = {
24941
25271
  string: { unit: "tecken", verb: "att ha" },
@@ -25045,7 +25375,7 @@ function sv_default() {
25045
25375
  localeError: error37()
25046
25376
  };
25047
25377
  }
25048
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ta.js
25378
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ta.js
25049
25379
  var error38 = () => {
25050
25380
  const Sizable = {
25051
25381
  string: { unit: "எழுத்துக்கள்", verb: "கொண்டிருக்க வேண்டும்" },
@@ -25155,7 +25485,7 @@ function ta_default() {
25155
25485
  localeError: error38()
25156
25486
  };
25157
25487
  }
25158
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/th.js
25488
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/th.js
25159
25489
  var error39 = () => {
25160
25490
  const Sizable = {
25161
25491
  string: { unit: "ตัวอักษร", verb: "ควรมี" },
@@ -25265,7 +25595,7 @@ function th_default() {
25265
25595
  localeError: error39()
25266
25596
  };
25267
25597
  }
25268
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/tr.js
25598
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/tr.js
25269
25599
  var error40 = () => {
25270
25600
  const Sizable = {
25271
25601
  string: { unit: "karakter", verb: "olmalı" },
@@ -25370,7 +25700,7 @@ function tr_default() {
25370
25700
  localeError: error40()
25371
25701
  };
25372
25702
  }
25373
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/uk.js
25703
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/uk.js
25374
25704
  var error41 = () => {
25375
25705
  const Sizable = {
25376
25706
  string: { unit: "символів", verb: "матиме" },
@@ -25479,11 +25809,11 @@ function uk_default() {
25479
25809
  };
25480
25810
  }
25481
25811
 
25482
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ua.js
25812
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ua.js
25483
25813
  function ua_default() {
25484
25814
  return uk_default();
25485
25815
  }
25486
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/ur.js
25816
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/ur.js
25487
25817
  var error42 = () => {
25488
25818
  const Sizable = {
25489
25819
  string: { unit: "حروف", verb: "ہونا" },
@@ -25593,7 +25923,7 @@ function ur_default() {
25593
25923
  localeError: error42()
25594
25924
  };
25595
25925
  }
25596
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/uz.js
25926
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/uz.js
25597
25927
  var error43 = () => {
25598
25928
  const Sizable = {
25599
25929
  string: { unit: "belgi", verb: "bo‘lishi kerak" },
@@ -25702,7 +26032,7 @@ function uz_default() {
25702
26032
  localeError: error43()
25703
26033
  };
25704
26034
  }
25705
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/vi.js
26035
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/vi.js
25706
26036
  var error44 = () => {
25707
26037
  const Sizable = {
25708
26038
  string: { unit: "ký tự", verb: "có" },
@@ -25810,7 +26140,7 @@ function vi_default() {
25810
26140
  localeError: error44()
25811
26141
  };
25812
26142
  }
25813
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/zh-CN.js
26143
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/zh-CN.js
25814
26144
  var error45 = () => {
25815
26145
  const Sizable = {
25816
26146
  string: { unit: "字符", verb: "包含" },
@@ -25919,7 +26249,7 @@ function zh_CN_default() {
25919
26249
  localeError: error45()
25920
26250
  };
25921
26251
  }
25922
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/zh-TW.js
26252
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/zh-TW.js
25923
26253
  var error46 = () => {
25924
26254
  const Sizable = {
25925
26255
  string: { unit: "字元", verb: "擁有" },
@@ -26026,7 +26356,7 @@ function zh_TW_default() {
26026
26356
  localeError: error46()
26027
26357
  };
26028
26358
  }
26029
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/locales/yo.js
26359
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/locales/yo.js
26030
26360
  var error47 = () => {
26031
26361
  const Sizable = {
26032
26362
  string: { unit: "àmi", verb: "ní" },
@@ -26133,7 +26463,7 @@ function yo_default() {
26133
26463
  localeError: error47()
26134
26464
  };
26135
26465
  }
26136
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/registries.js
26466
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/registries.js
26137
26467
  var _a;
26138
26468
  var $output = Symbol("ZodOutput");
26139
26469
  var $input = Symbol("ZodInput");
@@ -26183,7 +26513,7 @@ function registry() {
26183
26513
  }
26184
26514
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
26185
26515
  var globalRegistry = globalThis.__zod_globalRegistry;
26186
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/api.js
26516
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/api.js
26187
26517
  function _string(Class2, params) {
26188
26518
  return new Class2({
26189
26519
  type: "string",
@@ -27103,7 +27433,7 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
27103
27433
  const inst = new Class2(def);
27104
27434
  return inst;
27105
27435
  }
27106
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.js
27436
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
27107
27437
  function initializeContext(params) {
27108
27438
  let target = params?.target ?? "draft-2020-12";
27109
27439
  if (target === "draft-4")
@@ -27299,7 +27629,7 @@ function finalize(ctx, schema2) {
27299
27629
  }
27300
27630
  }
27301
27631
  }
27302
- if (refSchema.$ref) {
27632
+ if (refSchema.$ref && refSeen.def) {
27303
27633
  for (const key in schema3) {
27304
27634
  if (key === "$ref" || key === "allOf")
27305
27635
  continue;
@@ -27448,7 +27778,7 @@ var createStandardJSONSchemaMethod = (schema2, io, processors = {}) => (params)
27448
27778
  extractDefs(ctx, schema2);
27449
27779
  return finalize(ctx, schema2);
27450
27780
  };
27451
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/json-schema-processors.js
27781
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
27452
27782
  var formatMap = {
27453
27783
  guid: "uuid",
27454
27784
  url: "uri",
@@ -27993,7 +28323,7 @@ function toJSONSchema(input, params) {
27993
28323
  extractDefs(ctx, input);
27994
28324
  return finalize(ctx, input);
27995
28325
  }
27996
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/json-schema-generator.js
28326
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/json-schema-generator.js
27997
28327
  class JSONSchemaGenerator {
27998
28328
  get metadataRegistry() {
27999
28329
  return this.ctx.metadataRegistry;
@@ -28052,9 +28382,9 @@ class JSONSchemaGenerator {
28052
28382
  return plainResult;
28053
28383
  }
28054
28384
  }
28055
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/core/json-schema.js
28385
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/json-schema.js
28056
28386
  var exports_json_schema = {};
28057
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/schemas.js
28387
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
28058
28388
  var exports_schemas2 = {};
28059
28389
  __export(exports_schemas2, {
28060
28390
  xor: () => xor,
@@ -28223,7 +28553,7 @@ __export(exports_schemas2, {
28223
28553
  ZodAny: () => ZodAny
28224
28554
  });
28225
28555
 
28226
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/checks.js
28556
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/checks.js
28227
28557
  var exports_checks2 = {};
28228
28558
  __export(exports_checks2, {
28229
28559
  uppercase: () => _uppercase,
@@ -28257,7 +28587,7 @@ __export(exports_checks2, {
28257
28587
  endsWith: () => _endsWith
28258
28588
  });
28259
28589
 
28260
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/iso.js
28590
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/iso.js
28261
28591
  var exports_iso = {};
28262
28592
  __export(exports_iso, {
28263
28593
  time: () => time2,
@@ -28298,7 +28628,7 @@ function duration2(params) {
28298
28628
  return _isoDuration(ZodISODuration, params);
28299
28629
  }
28300
28630
 
28301
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/errors.js
28631
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/errors.js
28302
28632
  var initializer2 = (inst, issues) => {
28303
28633
  $ZodError.init(inst, issues);
28304
28634
  inst.name = "ZodError";
@@ -28333,7 +28663,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
28333
28663
  Parent: Error
28334
28664
  });
28335
28665
 
28336
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/parse.js
28666
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/parse.js
28337
28667
  var parse3 = /* @__PURE__ */ _parse(ZodRealError);
28338
28668
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
28339
28669
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -28347,7 +28677,7 @@ var safeDecode2 = /* @__PURE__ */ _safeDecode(ZodRealError);
28347
28677
  var safeEncodeAsync2 = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
28348
28678
  var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
28349
28679
 
28350
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/schemas.js
28680
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
28351
28681
  var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
28352
28682
  $ZodType.init(inst, def);
28353
28683
  Object.assign(inst["~standard"], {
@@ -29423,7 +29753,7 @@ function json(params) {
29423
29753
  function preprocess(fn, schema2) {
29424
29754
  return pipe(transform(fn), schema2);
29425
29755
  }
29426
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/compat.js
29756
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/compat.js
29427
29757
  var ZodIssueCode = {
29428
29758
  invalid_type: "invalid_type",
29429
29759
  too_big: "too_big",
@@ -29447,7 +29777,7 @@ function getErrorMap() {
29447
29777
  }
29448
29778
  var ZodFirstPartyTypeKind;
29449
29779
  (function(ZodFirstPartyTypeKind2) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
29450
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/from-json-schema.js
29780
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/from-json-schema.js
29451
29781
  var z = {
29452
29782
  ...exports_schemas2,
29453
29783
  ...exports_checks2,
@@ -29908,7 +30238,7 @@ function fromJSONSchema(schema2, params) {
29908
30238
  };
29909
30239
  return convertSchema(schema2, ctx);
29910
30240
  }
29911
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/coerce.js
30241
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/coerce.js
29912
30242
  var exports_coerce = {};
29913
30243
  __export(exports_coerce, {
29914
30244
  string: () => string4,
@@ -29933,7 +30263,7 @@ function date4(params) {
29933
30263
  return _coercedDate(ZodDate, params);
29934
30264
  }
29935
30265
 
29936
- // ../../node_modules/.bun/zod@4.3.5/node_modules/zod/v4/classic/external.js
30266
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
29937
30267
  config(en_default());
29938
30268
  // src/schemas.ts
29939
30269
  var ULID_REGEX = /^[0-9A-HJKMNP-TV-Z]{26}$/;
@@ -29960,7 +30290,9 @@ var TaskSchema = exports_external.object({
29960
30290
  createdAt: exports_external.date(),
29961
30291
  updatedAt: exports_external.date(),
29962
30292
  startedAt: exports_external.date().nullable(),
29963
- completedAt: exports_external.date().nullable()
30293
+ completedAt: exports_external.date().nullable(),
30294
+ archived: exports_external.boolean().default(false),
30295
+ archivedAt: exports_external.date().nullable().optional()
29964
30296
  });
29965
30297
  var ColumnSchema = exports_external.object({
29966
30298
  id: exports_external.string(),
@@ -30001,7 +30333,9 @@ var AddTaskInputSchema = exports_external.object({
30001
30333
  title: TitleSchema,
30002
30334
  description: exports_external.string().max(5000).optional(),
30003
30335
  columnId: ColumnIdSchema.optional(),
30336
+ createdBy: AgentNameSchema.optional(),
30004
30337
  agent: AgentNameSchema.optional(),
30338
+ assignedTo: AgentNameSchema.optional(),
30005
30339
  dependsOn: exports_external.array(UlidSchema).optional(),
30006
30340
  files: exports_external.array(exports_external.string()).optional(),
30007
30341
  labels: exports_external.array(exports_external.string().max(50)).optional()
@@ -30020,9 +30354,11 @@ var MoveTaskInputSchema = exports_external.object({
30020
30354
  });
30021
30355
  var ListTasksFilterSchema = exports_external.object({
30022
30356
  columnId: ColumnIdSchema.optional(),
30357
+ createdBy: AgentNameSchema.optional(),
30023
30358
  agent: AgentNameSchema.optional(),
30024
30359
  assignee: AgentNameSchema.optional(),
30025
- blocked: exports_external.boolean().optional()
30360
+ blocked: exports_external.boolean().optional(),
30361
+ includeArchived: exports_external.boolean().optional()
30026
30362
  });
30027
30363
  var GetTaskInputSchema = exports_external.object({
30028
30364
  id: UlidSchema
@@ -30034,7 +30370,8 @@ var TaskResponseSchema = TaskSchema.extend({
30034
30370
  createdAt: exports_external.string().datetime(),
30035
30371
  updatedAt: exports_external.string().datetime(),
30036
30372
  startedAt: exports_external.string().datetime().nullable(),
30037
- completedAt: exports_external.string().datetime().nullable()
30373
+ completedAt: exports_external.string().datetime().nullable(),
30374
+ archivedAt: exports_external.string().datetime().nullable().optional()
30038
30375
  });
30039
30376
  var BoardStatusSchema = exports_external.object({
30040
30377
  board: BoardResponseSchema,
@@ -30055,7 +30392,9 @@ var AddTaskInputJsonSchema = exports_external.object({
30055
30392
  title: TitleBaseSchema,
30056
30393
  description: exports_external.string().max(5000).optional(),
30057
30394
  columnId: ColumnIdSchema.optional(),
30395
+ createdBy: AgentNameBaseSchema.optional(),
30058
30396
  agent: AgentNameBaseSchema.optional(),
30397
+ assignedTo: AgentNameBaseSchema.optional(),
30059
30398
  dependsOn: exports_external.array(UlidSchema).optional(),
30060
30399
  files: exports_external.array(exports_external.string()).optional(),
30061
30400
  labels: exports_external.array(exports_external.string().max(50)).optional()
@@ -30069,8 +30408,11 @@ var UpdateTaskInputJsonSchema = exports_external.object({
30069
30408
  });
30070
30409
  var ListTasksFilterJsonSchema = exports_external.object({
30071
30410
  columnId: ColumnIdSchema.optional(),
30411
+ createdBy: AgentNameBaseSchema.optional(),
30072
30412
  agent: AgentNameBaseSchema.optional(),
30073
- blocked: exports_external.boolean().optional()
30413
+ assignee: AgentNameBaseSchema.optional(),
30414
+ blocked: exports_external.boolean().optional(),
30415
+ includeArchived: exports_external.boolean().optional()
30074
30416
  });
30075
30417
  var ColumnConfigJsonSchema = exports_external.object({
30076
30418
  id: ColumnIdSchema,
@@ -30102,8 +30444,103 @@ var jsonSchemas = {
30102
30444
  function getJsonSchema(name) {
30103
30445
  return jsonSchemas[name];
30104
30446
  }
30447
+ // ../../node_modules/.bun/ulid@3.0.2/node_modules/ulid/dist/node/index.js
30448
+ import crypto2 from "node:crypto";
30449
+ var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
30450
+ var ENCODING_LEN = 32;
30451
+ var RANDOM_LEN = 16;
30452
+ var TIME_LEN = 10;
30453
+ var TIME_MAX = 281474976710655;
30454
+ var ULIDErrorCode;
30455
+ (function(ULIDErrorCode2) {
30456
+ ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
30457
+ ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
30458
+ ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
30459
+ ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
30460
+ ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
30461
+ ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
30462
+ ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
30463
+ ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
30464
+ ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
30465
+ ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
30466
+ })(ULIDErrorCode || (ULIDErrorCode = {}));
30467
+
30468
+ class ULIDError extends Error {
30469
+ constructor(errorCode, message) {
30470
+ super(`${message} (${errorCode})`);
30471
+ this.name = "ULIDError";
30472
+ this.code = errorCode;
30473
+ }
30474
+ }
30475
+ function randomChar(prng) {
30476
+ const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
30477
+ return ENCODING.charAt(randomPosition);
30478
+ }
30479
+ function detectPRNG(root) {
30480
+ const rootLookup = detectRoot();
30481
+ const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof crypto2 !== "undefined" ? crypto2 : null);
30482
+ if (typeof globalCrypto?.getRandomValues === "function") {
30483
+ return () => {
30484
+ const buffer = new Uint8Array(1);
30485
+ globalCrypto.getRandomValues(buffer);
30486
+ return buffer[0] / 256;
30487
+ };
30488
+ } else if (typeof globalCrypto?.randomBytes === "function") {
30489
+ return () => globalCrypto.randomBytes(1).readUInt8() / 256;
30490
+ } else if (crypto2?.randomBytes) {
30491
+ return () => crypto2.randomBytes(1).readUInt8() / 256;
30492
+ }
30493
+ throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
30494
+ }
30495
+ function detectRoot() {
30496
+ if (inWebWorker())
30497
+ return self;
30498
+ if (typeof window !== "undefined") {
30499
+ return window;
30500
+ }
30501
+ if (typeof global !== "undefined") {
30502
+ return global;
30503
+ }
30504
+ if (typeof globalThis !== "undefined") {
30505
+ return globalThis;
30506
+ }
30507
+ return null;
30508
+ }
30509
+ function encodeRandom(len, prng) {
30510
+ let str = "";
30511
+ for (;len > 0; len--) {
30512
+ str = randomChar(prng) + str;
30513
+ }
30514
+ return str;
30515
+ }
30516
+ function encodeTime(now, len = TIME_LEN) {
30517
+ if (isNaN(now)) {
30518
+ throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now}`);
30519
+ } else if (now > TIME_MAX) {
30520
+ throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);
30521
+ } else if (now < 0) {
30522
+ throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now}`);
30523
+ } else if (Number.isInteger(now) === false) {
30524
+ throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now}`);
30525
+ }
30526
+ let mod, str = "";
30527
+ for (let currentLen = len;currentLen > 0; currentLen--) {
30528
+ mod = now % ENCODING_LEN;
30529
+ str = ENCODING.charAt(mod) + str;
30530
+ now = (now - mod) / ENCODING_LEN;
30531
+ }
30532
+ return str;
30533
+ }
30534
+ function inWebWorker() {
30535
+ return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
30536
+ }
30537
+ function ulid3(seedTime, prng) {
30538
+ const currentPRNG = prng || detectPRNG();
30539
+ const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
30540
+ return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
30541
+ }
30542
+
30105
30543
  // src/services/board.ts
30106
- var import_ulid = __toESM(require_index_umd(), 1);
30107
30544
  class BoardService {
30108
30545
  db;
30109
30546
  constructor(db2) {
@@ -30111,7 +30548,7 @@ class BoardService {
30111
30548
  }
30112
30549
  async initializeBoard(config2) {
30113
30550
  const now = new Date;
30114
- const boardId = import_ulid.ulid();
30551
+ const boardId = ulid3();
30115
30552
  await this.db.insert(boards).values({
30116
30553
  id: boardId,
30117
30554
  name: config2.board.name,
@@ -30151,9 +30588,25 @@ class BoardService {
30151
30588
  const rows = await this.db.select().from(columns2).where(eq(columns2.isTerminal, true));
30152
30589
  return rows[0] ?? null;
30153
30590
  }
30591
+ async getTerminalColumns() {
30592
+ return this.db.select().from(columns2).where(eq(columns2.isTerminal, true)).orderBy(columns2.position);
30593
+ }
30594
+ }
30595
+ // src/utils/similarity.ts
30596
+ function tokenize(text3) {
30597
+ const words = text3.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter((word) => word.length > 0);
30598
+ return new Set(words);
30599
+ }
30600
+ function jaccardSimilarity(text1, text22) {
30601
+ const set1 = tokenize(text1);
30602
+ const set2 = tokenize(text22);
30603
+ if (set1.size === 0 || set2.size === 0) {
30604
+ return 0;
30605
+ }
30606
+ const intersection2 = new Set([...set1].filter((word) => set2.has(word)));
30607
+ const union3 = new Set([...set1, ...set2]);
30608
+ return intersection2.size / union3.size;
30154
30609
  }
30155
- // src/services/task.ts
30156
- var import_ulid2 = __toESM(require_index_umd(), 1);
30157
30610
 
30158
30611
  // src/validation.ts
30159
30612
  function wrapZodError(fn, fieldName) {
@@ -30187,6 +30640,11 @@ function validateTaskId(id) {
30187
30640
  class TaskService {
30188
30641
  db;
30189
30642
  boardService;
30643
+ duplicateConfig = {
30644
+ enabled: true,
30645
+ threshold: 0.5,
30646
+ warnThreshold: 0.5
30647
+ };
30190
30648
  constructor(db2, boardService) {
30191
30649
  this.db = db2;
30192
30650
  this.boardService = boardService;
@@ -30200,14 +30658,14 @@ class TaskService {
30200
30658
  }
30201
30659
  async addTask(input) {
30202
30660
  const title = validateTitle(input.title);
30203
- const agent = input.agent ? validateAgentName(input.agent) : "user";
30661
+ const createdBy = input.createdBy ? validateAgentName(input.createdBy) : input.agent ? validateAgentName(input.agent) : "user";
30204
30662
  const columnId = input.columnId ? validateColumnId(input.columnId) : "todo";
30205
30663
  const column = await this.boardService.getColumn(columnId);
30206
30664
  if (!column) {
30207
30665
  throw new KabanError(`Column '${columnId}' does not exist`, ExitCode.VALIDATION);
30208
30666
  }
30209
30667
  const now = new Date;
30210
- const id = import_ulid2.ulid();
30668
+ const id = ulid3();
30211
30669
  const maxPositionResult = await this.db.select({ max: sql`COALESCE(MAX(position), -1)` }).from(tasks).where(eq(tasks.columnId, columnId));
30212
30670
  const position = (maxPositionResult[0]?.max ?? -1) + 1;
30213
30671
  await this.db.insert(tasks).values({
@@ -30216,7 +30674,7 @@ class TaskService {
30216
30674
  description: input.description ?? null,
30217
30675
  columnId,
30218
30676
  position,
30219
- createdBy: agent,
30677
+ createdBy,
30220
30678
  assignedTo: null,
30221
30679
  parentId: null,
30222
30680
  dependsOn: input.dependsOn ?? [],
@@ -30227,7 +30685,9 @@ class TaskService {
30227
30685
  createdAt: now,
30228
30686
  updatedAt: now,
30229
30687
  startedAt: null,
30230
- completedAt: null
30688
+ completedAt: null,
30689
+ archived: false,
30690
+ archivedAt: null
30231
30691
  });
30232
30692
  return this.getTaskOrThrow(id);
30233
30693
  }
@@ -30237,11 +30697,15 @@ class TaskService {
30237
30697
  }
30238
30698
  async listTasks(filter) {
30239
30699
  const conditions2 = [];
30700
+ if (!filter?.includeArchived) {
30701
+ conditions2.push(eq(tasks.archived, false));
30702
+ }
30240
30703
  if (filter?.columnId) {
30241
30704
  conditions2.push(eq(tasks.columnId, filter.columnId));
30242
30705
  }
30243
- if (filter?.agent) {
30244
- conditions2.push(eq(tasks.createdBy, filter.agent));
30706
+ const creatorFilter = filter?.createdBy ?? filter?.agent;
30707
+ if (creatorFilter) {
30708
+ conditions2.push(eq(tasks.createdBy, creatorFilter));
30245
30709
  }
30246
30710
  if (filter?.assignee) {
30247
30711
  conditions2.push(eq(tasks.assignedTo, filter.assignee));
@@ -30277,6 +30741,12 @@ class TaskService {
30277
30741
  throw new KabanError(`Column '${column.name}' at WIP limit (${count}/${column.wipLimit}). Move a task out first.`, ExitCode.VALIDATION);
30278
30742
  }
30279
30743
  }
30744
+ if (column.isTerminal && options?.validateDeps) {
30745
+ const depResult = await this.validateDependencies(id);
30746
+ if (!depResult.valid) {
30747
+ throw new KabanError(`Task '${id}' is blocked by incomplete dependencies: ${depResult.blockedBy.join(", ")}`, ExitCode.VALIDATION);
30748
+ }
30749
+ }
30280
30750
  const now = new Date;
30281
30751
  const isTerminal = column.isTerminal;
30282
30752
  const maxPositionResult = await this.db.select({ max: sql`COALESCE(MAX(position), -1)` }).from(tasks).where(eq(tasks.columnId, columnId));
@@ -30325,6 +30795,229 @@ class TaskService {
30325
30795
  const result = await this.db.select({ count: sql`COUNT(*)` }).from(tasks).where(eq(tasks.columnId, columnId));
30326
30796
  return result[0]?.count ?? 0;
30327
30797
  }
30798
+ async archiveTasks(criteria) {
30799
+ const hasCriteria = criteria.status || criteria.olderThan || criteria.taskIds?.length;
30800
+ if (!hasCriteria) {
30801
+ throw new KabanError("At least one criteria must be provided", ExitCode.VALIDATION);
30802
+ }
30803
+ const conditions2 = [eq(tasks.archived, false)];
30804
+ if (criteria.status) {
30805
+ conditions2.push(eq(tasks.columnId, criteria.status));
30806
+ }
30807
+ if (criteria.olderThan) {
30808
+ conditions2.push(lt(tasks.createdAt, criteria.olderThan));
30809
+ }
30810
+ if (criteria.taskIds?.length) {
30811
+ conditions2.push(inArray(tasks.id, criteria.taskIds));
30812
+ }
30813
+ const matchingTasks = await this.db.select({ id: tasks.id }).from(tasks).where(and(...conditions2));
30814
+ if (matchingTasks.length === 0) {
30815
+ return { archivedCount: 0, taskIds: [] };
30816
+ }
30817
+ const taskIds = matchingTasks.map((t) => t.id);
30818
+ const now = new Date;
30819
+ await this.db.update(tasks).set({
30820
+ archived: true,
30821
+ archivedAt: now,
30822
+ updatedAt: now
30823
+ }).where(inArray(tasks.id, taskIds));
30824
+ return {
30825
+ archivedCount: taskIds.length,
30826
+ taskIds
30827
+ };
30828
+ }
30829
+ async restoreTask(taskId, targetColumnId) {
30830
+ const task = await this.getTask(taskId);
30831
+ if (!task) {
30832
+ throw new KabanError(`Task '${taskId}' not found`, ExitCode.NOT_FOUND);
30833
+ }
30834
+ if (!task.archived) {
30835
+ throw new KabanError(`Task '${taskId}' is not archived`, ExitCode.VALIDATION);
30836
+ }
30837
+ const columnId = targetColumnId ?? task.columnId;
30838
+ if (targetColumnId) {
30839
+ validateColumnId(targetColumnId);
30840
+ const column = await this.boardService.getColumn(targetColumnId);
30841
+ if (!column) {
30842
+ throw new KabanError(`Column '${targetColumnId}' does not exist`, ExitCode.VALIDATION);
30843
+ }
30844
+ }
30845
+ const now = new Date;
30846
+ await this.db.update(tasks).set({
30847
+ archived: false,
30848
+ archivedAt: null,
30849
+ columnId,
30850
+ version: task.version + 1,
30851
+ updatedAt: now
30852
+ }).where(eq(tasks.id, taskId));
30853
+ return this.getTaskOrThrow(taskId);
30854
+ }
30855
+ async searchArchive(query, options) {
30856
+ const limit = options?.limit ?? 50;
30857
+ const offset = options?.offset ?? 0;
30858
+ if (!query.trim()) {
30859
+ const countResult = await this.db.select({ count: sql`COUNT(*)` }).from(tasks).where(eq(tasks.archived, true));
30860
+ const total2 = countResult[0]?.count ?? 0;
30861
+ const archivedTasks = await this.db.select().from(tasks).where(eq(tasks.archived, true)).orderBy(tasks.archivedAt).limit(limit).offset(offset);
30862
+ return { tasks: archivedTasks, total: total2 };
30863
+ }
30864
+ const ftsQuery = query.trim().split(/\s+/).map((term) => `"${term}"`).join(" ");
30865
+ const client = this.db.$client;
30866
+ const countRow = client.prepare(`SELECT COUNT(*) as count FROM tasks t
30867
+ JOIN tasks_fts fts ON t.id = fts.id
30868
+ WHERE tasks_fts MATCH ?
30869
+ AND t.archived = 1`).get(ftsQuery);
30870
+ const total = countRow?.count ?? 0;
30871
+ const rows = client.prepare(`SELECT t.* FROM tasks t
30872
+ JOIN tasks_fts fts ON t.id = fts.id
30873
+ WHERE tasks_fts MATCH ?
30874
+ AND t.archived = 1
30875
+ ORDER BY rank
30876
+ LIMIT ? OFFSET ?`).all(ftsQuery, limit, offset);
30877
+ const searchTasks = rows.map((row) => ({
30878
+ id: row.id,
30879
+ title: row.title,
30880
+ description: row.description,
30881
+ columnId: row.column_id,
30882
+ position: row.position,
30883
+ createdBy: row.created_by,
30884
+ assignedTo: row.assigned_to,
30885
+ parentId: row.parent_id,
30886
+ dependsOn: JSON.parse(row.depends_on || "[]"),
30887
+ files: JSON.parse(row.files || "[]"),
30888
+ labels: JSON.parse(row.labels || "[]"),
30889
+ blockedReason: row.blocked_reason,
30890
+ version: row.version,
30891
+ createdAt: new Date(row.created_at),
30892
+ updatedAt: new Date(row.updated_at),
30893
+ startedAt: row.started_at ? new Date(row.started_at) : null,
30894
+ completedAt: row.completed_at ? new Date(row.completed_at) : null,
30895
+ archived: Boolean(row.archived),
30896
+ archivedAt: row.archived_at ? new Date(row.archived_at) : null
30897
+ }));
30898
+ return { tasks: searchTasks, total };
30899
+ }
30900
+ async purgeArchive(criteria) {
30901
+ const conditions2 = [eq(tasks.archived, true)];
30902
+ if (criteria?.olderThan) {
30903
+ conditions2.push(lt(tasks.archivedAt, criteria.olderThan));
30904
+ }
30905
+ const matchingTasks = await this.db.select({ id: tasks.id }).from(tasks).where(and(...conditions2));
30906
+ if (matchingTasks.length === 0) {
30907
+ return { deletedCount: 0 };
30908
+ }
30909
+ const taskIds = matchingTasks.map((t) => t.id);
30910
+ await this.db.delete(tasks).where(inArray(tasks.id, taskIds));
30911
+ return { deletedCount: taskIds.length };
30912
+ }
30913
+ async resetBoard() {
30914
+ const allTasks = await this.db.select({ id: tasks.id }).from(tasks);
30915
+ if (allTasks.length === 0) {
30916
+ return { deletedCount: 0 };
30917
+ }
30918
+ await this.db.delete(tasks).where(sql`1=1`);
30919
+ return { deletedCount: allTasks.length };
30920
+ }
30921
+ async addDependency(taskId, dependsOnId) {
30922
+ if (taskId === dependsOnId) {
30923
+ throw new KabanError("Task cannot depend on itself", ExitCode.VALIDATION);
30924
+ }
30925
+ const task = await this.getTaskOrThrow(taskId);
30926
+ await this.getTaskOrThrow(dependsOnId);
30927
+ if (task.dependsOn.includes(dependsOnId)) {
30928
+ return task;
30929
+ }
30930
+ const updatedDependsOn = [...task.dependsOn, dependsOnId];
30931
+ const now = new Date;
30932
+ await this.db.update(tasks).set({
30933
+ dependsOn: updatedDependsOn,
30934
+ version: task.version + 1,
30935
+ updatedAt: now
30936
+ }).where(eq(tasks.id, taskId));
30937
+ return this.getTaskOrThrow(taskId);
30938
+ }
30939
+ async removeDependency(taskId, dependsOnId) {
30940
+ const task = await this.getTaskOrThrow(taskId);
30941
+ if (!task.dependsOn.includes(dependsOnId)) {
30942
+ return task;
30943
+ }
30944
+ const updatedDependsOn = task.dependsOn.filter((id) => id !== dependsOnId);
30945
+ const now = new Date;
30946
+ await this.db.update(tasks).set({
30947
+ dependsOn: updatedDependsOn,
30948
+ version: task.version + 1,
30949
+ updatedAt: now
30950
+ }).where(eq(tasks.id, taskId));
30951
+ return this.getTaskOrThrow(taskId);
30952
+ }
30953
+ async validateDependencies(taskId) {
30954
+ const task = await this.getTask(taskId);
30955
+ if (!task) {
30956
+ throw new KabanError(`Task '${taskId}' not found`, ExitCode.NOT_FOUND);
30957
+ }
30958
+ if (!task.dependsOn || task.dependsOn.length === 0) {
30959
+ return { valid: true, blockedBy: [] };
30960
+ }
30961
+ const terminalColumn = await this.boardService.getTerminalColumn();
30962
+ if (!terminalColumn) {
30963
+ return { valid: true, blockedBy: [] };
30964
+ }
30965
+ const blockedBy = [];
30966
+ for (const depId of task.dependsOn) {
30967
+ const depTask = await this.getTask(depId);
30968
+ if (depTask && depTask.columnId !== terminalColumn.id) {
30969
+ blockedBy.push(depId);
30970
+ }
30971
+ }
30972
+ return {
30973
+ valid: blockedBy.length === 0,
30974
+ blockedBy
30975
+ };
30976
+ }
30977
+ async findSimilarTasks(title, threshold = 0.5) {
30978
+ const activeTasks = await this.listTasks({ includeArchived: false });
30979
+ return activeTasks.map((task) => ({
30980
+ task,
30981
+ similarity: jaccardSimilarity(title, task.title)
30982
+ })).filter((result) => result.similarity >= threshold).sort((a, b) => b.similarity - a.similarity).slice(0, 5);
30983
+ }
30984
+ async addTaskChecked(input, options) {
30985
+ const similarTasks = await this.findSimilarTasks(input.title, this.duplicateConfig.threshold);
30986
+ const highSimilarity = similarTasks.filter((s) => s.similarity >= this.duplicateConfig.warnThreshold);
30987
+ if (highSimilarity.length > 0 && !options?.force) {
30988
+ const similar = highSimilarity.map((s) => `"${s.task.title}" (${Math.round(s.similarity * 100)}%)`).join(", ");
30989
+ return {
30990
+ task: null,
30991
+ created: false,
30992
+ similarTasks,
30993
+ rejected: true,
30994
+ rejectionReason: `Found ${highSimilarity.length} very similar task(s): ${similar}. Use force=true to create anyway.`
30995
+ };
30996
+ }
30997
+ const task = await this.addTask(input);
30998
+ return {
30999
+ task,
31000
+ created: true,
31001
+ similarTasks,
31002
+ rejected: false
31003
+ };
31004
+ }
31005
+ async getArchiveStats() {
31006
+ const archived = await this.db.select().from(tasks).where(eq(tasks.archived, true));
31007
+ const byColumn = {};
31008
+ let oldestArchivedAt = null;
31009
+ for (const task of archived) {
31010
+ byColumn[task.columnId] = (byColumn[task.columnId] ?? 0) + 1;
31011
+ if (task.archivedAt && (!oldestArchivedAt || task.archivedAt < oldestArchivedAt)) {
31012
+ oldestArchivedAt = task.archivedAt;
31013
+ }
31014
+ }
31015
+ return {
31016
+ totalArchived: archived.length,
31017
+ byColumn,
31018
+ oldestArchivedAt
31019
+ };
31020
+ }
30328
31021
  }
30329
31022
  export {
30330
31023
  validateTitle,
@@ -30332,8 +31025,11 @@ export {
30332
31025
  validateColumnId,
30333
31026
  validateAgentName,
30334
31027
  undoLog,
31028
+ tokenize,
30335
31029
  tasks,
31030
+ runMigrations,
30336
31031
  jsonSchemas,
31032
+ jaccardSimilarity,
30337
31033
  isValidUlid,
30338
31034
  initializeSchema,
30339
31035
  getJsonSchema,