@korajs/store 1.0.0-beta.0 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/adapters/better-sqlite3.cjs.map +1 -1
  2. package/dist/adapters/better-sqlite3.d.cts +1 -1
  3. package/dist/adapters/better-sqlite3.d.ts +1 -1
  4. package/dist/adapters/better-sqlite3.js +1 -1
  5. package/dist/adapters/indexeddb.cjs +523 -148
  6. package/dist/adapters/indexeddb.cjs.map +1 -1
  7. package/dist/adapters/indexeddb.d.cts +4 -2
  8. package/dist/adapters/indexeddb.d.ts +4 -2
  9. package/dist/adapters/indexeddb.js +55 -11
  10. package/dist/adapters/indexeddb.js.map +1 -1
  11. package/dist/adapters/sqlite-wasm-worker.cjs +207 -187
  12. package/dist/adapters/sqlite-wasm-worker.cjs.map +1 -1
  13. package/dist/adapters/sqlite-wasm-worker.js +208 -188
  14. package/dist/adapters/sqlite-wasm-worker.js.map +1 -1
  15. package/dist/adapters/sqlite-wasm.cjs +474 -140
  16. package/dist/adapters/sqlite-wasm.cjs.map +1 -1
  17. package/dist/adapters/sqlite-wasm.d.cts +45 -8
  18. package/dist/adapters/sqlite-wasm.d.ts +45 -8
  19. package/dist/adapters/sqlite-wasm.js +3 -3
  20. package/dist/{backup-5XZ7THNJ.js → backup-5S7K2Z35.js} +3 -3
  21. package/dist/blob-fs.cjs +166 -0
  22. package/dist/blob-fs.cjs.map +1 -0
  23. package/dist/blob-fs.d.cts +29 -0
  24. package/dist/blob-fs.d.ts +29 -0
  25. package/dist/blob-fs.js +128 -0
  26. package/dist/blob-fs.js.map +1 -0
  27. package/dist/{chunk-EIVXWF4B.js → chunk-CYO3YKFL.js} +4 -3
  28. package/dist/chunk-CYO3YKFL.js.map +1 -0
  29. package/dist/{chunk-ETDJEH2I.js → chunk-GSJ7EEUC.js} +12 -1
  30. package/dist/chunk-GSJ7EEUC.js.map +1 -0
  31. package/dist/{chunk-5R4QMY3Z.js → chunk-HS6DBMST.js} +13 -10
  32. package/dist/chunk-HS6DBMST.js.map +1 -0
  33. package/dist/chunk-RJIEKEN4.js +751 -0
  34. package/dist/chunk-RJIEKEN4.js.map +1 -0
  35. package/dist/{chunk-QL2XVZRN.js → chunk-TUR7RGEP.js} +12 -1
  36. package/dist/{chunk-QL2XVZRN.js.map → chunk-TUR7RGEP.js.map} +1 -1
  37. package/dist/{chunk-IOEFNHHP.js → chunk-VDBJQ75K.js} +2 -2
  38. package/dist/chunk-VDBJQ75K.js.map +1 -0
  39. package/dist/chunk-W4MTTNEZ.js +55 -0
  40. package/dist/chunk-W4MTTNEZ.js.map +1 -0
  41. package/dist/{chunk-OUQDC5Z6.js → chunk-YT7MRFCP.js} +55 -35
  42. package/dist/chunk-YT7MRFCP.js.map +1 -0
  43. package/dist/content-addressed-blob-store-Dcj3SB9r.d.cts +60 -0
  44. package/dist/content-addressed-blob-store-Dcj3SB9r.d.ts +60 -0
  45. package/dist/{export-audit-VPGQWNR6.js → export-audit-ODGQTQIK.js} +3 -3
  46. package/dist/index.cjs +923 -131
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +443 -6
  49. package/dist/index.d.ts +443 -6
  50. package/dist/index.js +737 -49
  51. package/dist/index.js.map +1 -1
  52. package/dist/internal.cjs +69 -43
  53. package/dist/internal.cjs.map +1 -1
  54. package/dist/internal.d.cts +3 -3
  55. package/dist/internal.d.ts +3 -3
  56. package/dist/internal.js +3 -3
  57. package/dist/sqlite-wasm-channel-GGHA2BXU.js +12 -0
  58. package/dist/{sqlite-wasm-channel-DUDPclTE.d.cts → sqlite-wasm-channel-L6o3bWQK.d.cts} +1 -1
  59. package/dist/{sqlite-wasm-channel-DUDPclTE.d.ts → sqlite-wasm-channel-L6o3bWQK.d.ts} +1 -1
  60. package/dist/{types-CyjXwrjW.d.cts → types-BOO9EPt1.d.ts} +10 -3
  61. package/dist/{types-CJOVKxLw.d.ts → types-BslDOTk0.d.cts} +32 -2
  62. package/dist/{types-CJOVKxLw.d.cts → types-BslDOTk0.d.ts} +32 -2
  63. package/dist/{types-DAxCladl.d.ts → types-C_GDavG-.d.cts} +10 -3
  64. package/package.json +13 -12
  65. package/dist/adapters/sqlite-wasm-shared-host.cjs +0 -68
  66. package/dist/adapters/sqlite-wasm-shared-host.cjs.map +0 -1
  67. package/dist/adapters/sqlite-wasm-shared-host.d.cts +0 -2
  68. package/dist/adapters/sqlite-wasm-shared-host.d.ts +0 -2
  69. package/dist/adapters/sqlite-wasm-shared-host.js +0 -66
  70. package/dist/adapters/sqlite-wasm-shared-host.js.map +0 -1
  71. package/dist/chunk-5R4QMY3Z.js.map +0 -1
  72. package/dist/chunk-EIVXWF4B.js.map +0 -1
  73. package/dist/chunk-ETDJEH2I.js.map +0 -1
  74. package/dist/chunk-IOEFNHHP.js.map +0 -1
  75. package/dist/chunk-OUQDC5Z6.js.map +0 -1
  76. package/dist/chunk-RBPVEAVM.js +0 -425
  77. package/dist/chunk-RBPVEAVM.js.map +0 -1
  78. package/dist/sqlite-wasm-channel-H43KEZLM.js +0 -12
  79. /package/dist/{backup-5XZ7THNJ.js.map → backup-5S7K2Z35.js.map} +0 -0
  80. /package/dist/{export-audit-VPGQWNR6.js.map → export-audit-ODGQTQIK.js.map} +0 -0
  81. /package/dist/{sqlite-wasm-channel-H43KEZLM.js.map → sqlite-wasm-channel-GGHA2BXU.js.map} +0 -0
package/dist/internal.cjs CHANGED
@@ -83,6 +83,7 @@ function encodeRichtext(value) {
83
83
  }
84
84
  if (typeof value === "string") {
85
85
  const doc = new Y.Doc();
86
+ doc.clientID = 0;
86
87
  doc.getText(TEXT_KEY).insert(0, value);
87
88
  return Y.encodeStateAsUpdate(doc);
88
89
  }
@@ -233,6 +234,9 @@ function serializeValue(value, descriptor) {
233
234
  case "boolean":
234
235
  return value ? 1 : 0;
235
236
  case "array":
237
+ case "object":
238
+ case "json":
239
+ case "blob":
236
240
  return JSON.stringify(value);
237
241
  case "richtext":
238
242
  return encodeRichtext(value);
@@ -249,6 +253,13 @@ function deserializeValue(value, descriptor) {
249
253
  return JSON.parse(value);
250
254
  }
251
255
  return value;
256
+ case "object":
257
+ case "json":
258
+ case "blob":
259
+ if (typeof value === "string") {
260
+ return JSON.parse(value);
261
+ }
262
+ return value;
252
263
  case "richtext":
253
264
  return decodeRichtext(value);
254
265
  default:
@@ -256,6 +267,9 @@ function deserializeValue(value, descriptor) {
256
267
  }
257
268
  }
258
269
 
270
+ // src/query/sql-builder.ts
271
+ var import_core5 = require("@korajs/core");
272
+
259
273
  // src/errors.ts
260
274
  var import_core3 = require("@korajs/core");
261
275
  var QueryError = class extends import_core3.KoraError {
@@ -300,7 +314,7 @@ function lwwVersionWhereClause(remoteVersion) {
300
314
  // src/query/sql-builder.ts
301
315
  function buildSelectQuery(descriptor, fields) {
302
316
  const params = [];
303
- const parts = [`SELECT * FROM ${descriptor.collection}`];
317
+ const parts = [`SELECT * FROM ${(0, import_core5.quoteIdent)(descriptor.collection)}`];
304
318
  const whereClause = buildWhereClauseParts(descriptor.where, fields, params);
305
319
  const deletedFilter = "_deleted = 0";
306
320
  if (whereClause) {
@@ -311,7 +325,7 @@ function buildSelectQuery(descriptor, fields) {
311
325
  if (descriptor.orderBy.length > 0) {
312
326
  const orderParts = descriptor.orderBy.map((o) => {
313
327
  validateFieldName(o.field, fields);
314
- return `${o.field} ${o.direction.toUpperCase()}`;
328
+ return `${(0, import_core5.quoteIdent)(o.field)} ${o.direction.toUpperCase()}`;
315
329
  });
316
330
  parts.push(`ORDER BY ${orderParts.join(", ")}`);
317
331
  }
@@ -325,7 +339,7 @@ function buildSelectQuery(descriptor, fields) {
325
339
  }
326
340
  function buildCountQuery(descriptor, fields) {
327
341
  const params = [];
328
- const parts = [`SELECT COUNT(*) as count FROM ${descriptor.collection}`];
342
+ const parts = [`SELECT COUNT(*) as count FROM ${(0, import_core5.quoteIdent)(descriptor.collection)}`];
329
343
  const whereClause = buildWhereClauseParts(descriptor.where, fields, params);
330
344
  const deletedFilter = "_deleted = 0";
331
345
  if (whereClause) {
@@ -339,38 +353,39 @@ function buildInsertQuery(collection, record) {
339
353
  const columns = Object.keys(record);
340
354
  const placeholders = columns.map(() => "?");
341
355
  const params = Object.values(record);
342
- const sql = `INSERT INTO ${collection} (${columns.join(", ")}) VALUES (${placeholders.join(", ")})`;
356
+ const quotedColumns = columns.map((col) => (0, import_core5.quoteIdent)(col));
357
+ const sql = `INSERT INTO ${(0, import_core5.quoteIdent)(collection)} (${quotedColumns.join(", ")}) VALUES (${placeholders.join(", ")})`;
343
358
  return { sql, params };
344
359
  }
345
360
  function buildUpdateQuery(collection, id, changes) {
346
- const setClauses = Object.keys(changes).map((col) => `${col} = ?`);
361
+ const setClauses = Object.keys(changes).map((col) => `${(0, import_core5.quoteIdent)(col)} = ?`);
347
362
  const params = [...Object.values(changes), id];
348
- const sql = `UPDATE ${collection} SET ${setClauses.join(", ")} WHERE id = ?`;
363
+ const sql = `UPDATE ${(0, import_core5.quoteIdent)(collection)} SET ${setClauses.join(", ")} WHERE id = ?`;
349
364
  return { sql, params };
350
365
  }
351
366
  function buildSoftDeleteQuery(collection, id, updatedAt, version) {
352
367
  if (version !== void 0) {
353
368
  return {
354
- sql: `UPDATE ${collection} SET _deleted = 1, _updated_at = ?, _version = ? WHERE id = ?`,
369
+ sql: `UPDATE ${(0, import_core5.quoteIdent)(collection)} SET _deleted = 1, _updated_at = ?, _version = ? WHERE id = ?`,
355
370
  params: [updatedAt, version, id]
356
371
  };
357
372
  }
358
373
  return {
359
- sql: `UPDATE ${collection} SET _deleted = 1, _updated_at = ? WHERE id = ?`,
374
+ sql: `UPDATE ${(0, import_core5.quoteIdent)(collection)} SET _deleted = 1, _updated_at = ? WHERE id = ?`,
360
375
  params: [updatedAt, id]
361
376
  };
362
377
  }
363
378
  function buildLwwUpdateQuery(collection, id, changes, remoteVersion) {
364
- const setClauses = Object.keys(changes).map((col) => `${col} = ?`);
379
+ const setClauses = Object.keys(changes).map((col) => `${(0, import_core5.quoteIdent)(col)} = ?`);
365
380
  const lww = lwwVersionWhereClause(remoteVersion);
366
- const sql = `UPDATE ${collection} SET ${setClauses.join(", ")} WHERE id = ? AND ${lww.sql}`;
381
+ const sql = `UPDATE ${(0, import_core5.quoteIdent)(collection)} SET ${setClauses.join(", ")} WHERE id = ? AND ${lww.sql}`;
367
382
  const params = [...Object.values(changes), id, ...lww.params];
368
383
  return { sql, params };
369
384
  }
370
385
  function buildLwwSoftDeleteQuery(collection, id, updatedAt, version) {
371
386
  const lww = lwwVersionWhereClause(version);
372
387
  return {
373
- sql: `UPDATE ${collection} SET _deleted = 1, _updated_at = ?, _version = ? WHERE id = ? AND ${lww.sql}`,
388
+ sql: `UPDATE ${(0, import_core5.quoteIdent)(collection)} SET _deleted = 1, _updated_at = ?, _version = ? WHERE id = ? AND ${lww.sql}`,
374
389
  params: [updatedAt, version, id, ...lww.params]
375
390
  };
376
391
  }
@@ -407,31 +422,32 @@ function buildWhereClauseParts(where, fields, params) {
407
422
  }
408
423
  function buildOperatorCondition(fieldName, operator, value, descriptor, params) {
409
424
  const sqlValue = descriptor?.kind === "boolean" && typeof value === "boolean" ? value ? 1 : 0 : value;
425
+ const column = (0, import_core5.quoteIdent)(fieldName);
410
426
  switch (operator) {
411
427
  case "$eq":
412
428
  if (sqlValue === null) {
413
- return `${fieldName} IS NULL`;
429
+ return `${column} IS NULL`;
414
430
  }
415
431
  params.push(sqlValue);
416
- return `${fieldName} = ?`;
432
+ return `${column} = ?`;
417
433
  case "$ne":
418
434
  if (sqlValue === null) {
419
- return `${fieldName} IS NOT NULL`;
435
+ return `${column} IS NOT NULL`;
420
436
  }
421
437
  params.push(sqlValue);
422
- return `${fieldName} != ?`;
438
+ return `${column} != ?`;
423
439
  case "$gt":
424
440
  params.push(sqlValue);
425
- return `${fieldName} > ?`;
441
+ return `${column} > ?`;
426
442
  case "$gte":
427
443
  params.push(sqlValue);
428
- return `${fieldName} >= ?`;
444
+ return `${column} >= ?`;
429
445
  case "$lt":
430
446
  params.push(sqlValue);
431
- return `${fieldName} < ?`;
447
+ return `${column} < ?`;
432
448
  case "$lte":
433
449
  params.push(sqlValue);
434
- return `${fieldName} <= ?`;
450
+ return `${column} <= ?`;
435
451
  case "$in": {
436
452
  if (!Array.isArray(sqlValue)) {
437
453
  throw new QueryError(`$in operator requires an array value for field "${fieldName}"`, {
@@ -445,7 +461,7 @@ function buildOperatorCondition(fieldName, operator, value, descriptor, params)
445
461
  descriptor?.kind === "boolean" && typeof item === "boolean" ? item ? 1 : 0 : item
446
462
  );
447
463
  }
448
- return `${fieldName} IN (${placeholders.join(", ")})`;
464
+ return `${column} IN (${placeholders.join(", ")})`;
449
465
  }
450
466
  default:
451
467
  throw new QueryError(`Unknown operator "${operator}"`, { operator });
@@ -469,7 +485,7 @@ function validateFieldName(fieldName, fields) {
469
485
  }
470
486
 
471
487
  // src/mutations/execute-insert.ts
472
- var import_core5 = require("@korajs/core");
488
+ var import_core6 = require("@korajs/core");
473
489
 
474
490
  // src/lww/field-versions.ts
475
491
  function parseFieldVersions(raw) {
@@ -536,19 +552,24 @@ function resolveCausalDeps(ctx) {
536
552
 
537
553
  // src/mutations/execute-insert.ts
538
554
  async function executeInsert(ctx, data) {
539
- const validated = (0, import_core5.validateRecord)(ctx.collection, ctx.definition, data, "insert");
540
- const recordId = (0, import_core5.generateUUIDv7)();
555
+ const validated = (0, import_core6.validateRecord)(ctx.collection, ctx.definition, data, "insert");
556
+ const recordId = (0, import_core6.generateUUIDv7)();
541
557
  for (const [fieldName, descriptor] of Object.entries(ctx.definition.fields)) {
542
558
  if (descriptor.auto && descriptor.kind === "timestamp") {
543
559
  validated[fieldName] = Date.now();
544
560
  }
545
561
  }
562
+ const writeData = await (0, import_core6.transformSecretFieldsForWrite)(
563
+ validated,
564
+ ctx.definition,
565
+ ctx.secretKeyProvider
566
+ );
546
567
  const causalDeps = resolveCausalDeps(ctx);
547
568
  let operation;
548
569
  let record;
549
570
  await ctx.adapter.transaction(async (tx) => {
550
571
  const sequenceNumber = await allocateNextSequenceInTransaction(tx, ctx.nodeId);
551
- operation = await (0, import_core5.createOperation)(
572
+ operation = await (0, import_core6.createOperation)(
552
573
  {
553
574
  nodeId: ctx.nodeId,
554
575
  type: "insert",
@@ -557,7 +578,7 @@ async function executeInsert(ctx, data) {
557
578
  // Binary richtext values are tagged as canonical JSON BEFORE the
558
579
  // operation is content-hashed, so the hash input, persisted JSON,
559
580
  // and wire payload are the identical value.
560
- data: encodeRichtextFieldsForOpData(validated, ctx.definition.fields),
581
+ data: encodeRichtextFieldsForOpData(writeData, ctx.definition.fields),
561
582
  previousData: null,
562
583
  sequenceNumber,
563
584
  causalDeps,
@@ -566,7 +587,7 @@ async function executeInsert(ctx, data) {
566
587
  ctx.clock
567
588
  );
568
589
  ctx.causalTracker?.afterOperation(ctx.collection, operation.id, ctx.inTransaction);
569
- const serializedData = serializeRecord(validated, ctx.definition.fields);
590
+ const serializedData = serializeRecord(writeData, ctx.definition.fields);
570
591
  const version = serializeRowVersion(operation.timestamp);
571
592
  record = {
572
593
  id: recordId,
@@ -591,18 +612,18 @@ async function executeInsert(ctx, data) {
591
612
  ctx.onMutation(ctx.collection, operation);
592
613
  return {
593
614
  id: recordId,
594
- ...validated,
615
+ ...writeData,
595
616
  createdAt: operation.timestamp.wallTime,
596
617
  updatedAt: operation.timestamp.wallTime
597
618
  };
598
619
  }
599
620
 
600
621
  // src/mutations/execute-update.ts
601
- var import_core7 = require("@korajs/core");
622
+ var import_core8 = require("@korajs/core");
602
623
 
603
624
  // src/state-machine/state-validator.ts
604
- var import_core6 = require("@korajs/core");
605
- var InvalidStateTransitionError = class extends import_core6.KoraError {
625
+ var import_core7 = require("@korajs/core");
626
+ var InvalidStateTransitionError = class extends import_core7.KoraError {
606
627
  constructor(collection, recordId, field, fromState, toState, allowedStates) {
607
628
  super(
608
629
  `Invalid state transition in collection "${collection}": cannot transition field "${field}" from "${fromState}" to "${toState}". Allowed transitions from "${fromState}": ${allowedStates.length > 0 ? allowedStates.join(", ") : "(none -- terminal state)"}`,
@@ -636,7 +657,7 @@ function validateStateTransition(collectionName, recordId, stateMachine, current
636
657
  collection: collectionName,
637
658
  transitions: stateMachine.transitions
638
659
  };
639
- const transitionResult = (0, import_core6.validateTransition)(constraint, currentState, newState);
660
+ const transitionResult = (0, import_core7.validateTransition)(constraint, currentState, newState);
640
661
  if (transitionResult.valid) {
641
662
  return { valid: true, allowedStates: transitionResult.allowedTargets };
642
663
  }
@@ -685,14 +706,14 @@ function validateUpdateStateMachine(collectionName, recordId, collectionDef, cur
685
706
  // src/mutations/execute-update.ts
686
707
  async function executeUpdate(ctx, id, data) {
687
708
  const currentRows = await ctx.adapter.query(
688
- `SELECT * FROM ${ctx.collection} WHERE id = ? AND _deleted = 0`,
709
+ `SELECT * FROM ${(0, import_core8.quoteIdent)(ctx.collection)} WHERE id = ? AND _deleted = 0`,
689
710
  [id]
690
711
  );
691
712
  const currentRow = currentRows[0];
692
713
  if (!currentRow) {
693
714
  throw new RecordNotFoundError(ctx.collection, id);
694
715
  }
695
- let validated = (0, import_core7.validateRecord)(ctx.collection, ctx.definition, data, "update");
716
+ let validated = (0, import_core8.validateRecord)(ctx.collection, ctx.definition, data, "update");
696
717
  const currentRecord = deserializeRecord(currentRow, ctx.definition.fields);
697
718
  validated = validateUpdateStateMachine(
698
719
  ctx.collection,
@@ -710,19 +731,24 @@ async function executeUpdate(ctx, id, data) {
710
731
  for (const key of Object.keys(validated)) {
711
732
  const value = validated[key];
712
733
  previousData[key] = currentRecord[key];
713
- if ((0, import_core7.isAtomicOp)(value)) {
714
- resolvedData[key] = (0, import_core7.resolveAtomicOp)(currentRecord[key], value);
715
- atomicOps[key] = (0, import_core7.toAtomicOp)(value);
734
+ if ((0, import_core8.isAtomicOp)(value)) {
735
+ resolvedData[key] = (0, import_core8.resolveAtomicOp)(currentRecord[key], value);
736
+ atomicOps[key] = (0, import_core8.toAtomicOp)(value);
716
737
  } else {
717
738
  resolvedData[key] = value;
718
739
  }
719
740
  }
741
+ const writeData = await (0, import_core8.transformSecretFieldsForWrite)(
742
+ resolvedData,
743
+ ctx.definition,
744
+ ctx.secretKeyProvider
745
+ );
720
746
  const hasAtomicOps = Object.keys(atomicOps).length > 0;
721
747
  const causalDeps = resolveCausalDeps(ctx);
722
748
  let operation;
723
749
  await ctx.adapter.transaction(async (tx) => {
724
750
  const sequenceNumber = await allocateNextSequenceInTransaction(tx, ctx.nodeId);
725
- operation = await (0, import_core7.createOperation)(
751
+ operation = await (0, import_core8.createOperation)(
726
752
  {
727
753
  nodeId: ctx.nodeId,
728
754
  type: "update",
@@ -731,7 +757,7 @@ async function executeUpdate(ctx, id, data) {
731
757
  // Binary richtext values (new and previous) are tagged as canonical
732
758
  // JSON BEFORE the operation is content-hashed, so the hash input,
733
759
  // persisted JSON, and wire payload are the identical value.
734
- data: encodeRichtextFieldsForOpData(resolvedData, ctx.definition.fields),
760
+ data: encodeRichtextFieldsForOpData(writeData, ctx.definition.fields),
735
761
  previousData: encodeRichtextFieldsForOpData(previousData, ctx.definition.fields),
736
762
  sequenceNumber,
737
763
  causalDeps,
@@ -741,7 +767,7 @@ async function executeUpdate(ctx, id, data) {
741
767
  ctx.clock
742
768
  );
743
769
  ctx.causalTracker?.afterOperation(ctx.collection, operation.id, ctx.inTransaction);
744
- const serializedChanges = serializeRecord(resolvedData, ctx.definition.fields);
770
+ const serializedChanges = serializeRecord(writeData, ctx.definition.fields);
745
771
  const version = serializeRowVersion(operation.timestamp);
746
772
  const mergedFieldVersions = parseFieldVersions(currentRow._field_versions);
747
773
  for (const changedField of Object.keys(serializedChanges)) {
@@ -762,7 +788,7 @@ async function executeUpdate(ctx, id, data) {
762
788
  });
763
789
  ctx.onMutation(ctx.collection, operation);
764
790
  const rows = await ctx.adapter.query(
765
- `SELECT * FROM ${ctx.collection} WHERE id = ? AND _deleted = 0`,
791
+ `SELECT * FROM ${(0, import_core8.quoteIdent)(ctx.collection)} WHERE id = ? AND _deleted = 0`,
766
792
  [id]
767
793
  );
768
794
  const row = rows[0];
@@ -773,10 +799,10 @@ async function executeUpdate(ctx, id, data) {
773
799
  }
774
800
 
775
801
  // src/mutations/execute-delete.ts
776
- var import_core8 = require("@korajs/core");
802
+ var import_core9 = require("@korajs/core");
777
803
  async function executeDelete(ctx, id, options) {
778
804
  const currentRows = await ctx.adapter.query(
779
- `SELECT * FROM ${ctx.collection} WHERE id = ? AND _deleted = 0`,
805
+ `SELECT * FROM ${(0, import_core9.quoteIdent)(ctx.collection)} WHERE id = ? AND _deleted = 0`,
780
806
  [id]
781
807
  );
782
808
  if (!currentRows[0]) {
@@ -788,7 +814,7 @@ async function executeDelete(ctx, id, options) {
788
814
  await ctx.adapter.transaction(async (tx) => {
789
815
  if (!operation) {
790
816
  const sequenceNumber = await allocateNextSequenceInTransaction(tx, ctx.nodeId);
791
- operation = await (0, import_core8.createOperation)(
817
+ operation = await (0, import_core9.createOperation)(
792
818
  {
793
819
  nodeId: ctx.nodeId,
794
820
  type: "delete",