@bitcobblers/wod-wiki-storage 0.60.2258 → 0.62.2260

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.
@@ -1,8 +1,8 @@
1
1
  import { S as SqlConnection, D as Database } from '../connection-DxuCLpRc.cjs';
2
2
  export { L as LibsqlClient, a as SqlRow, b as SqlStatement, c as SqlValue, l as libsqlDatabase } from '../connection-DxuCLpRc.cjs';
3
- import { e as StoreDef, R as RangeDTO, K as KeyDTO, f as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, d as IStorageTransaction } from '../wire-sRdblNjM.cjs';
4
- import { b as StoredSyncOp, S as SyncMutation } from '../sync-Dnogcmm_.cjs';
5
- export { A as ApplySyncBatchOptions, R as RawSyncOp, c as SYNC_OPS_TABLE, d as SYNC_STATE_TABLE, a as SyncEntry, e as SyncTargetKind, f as applySyncBatch, g as fetchSyncOps, i as initSyncTarget, p as probeSyncTarget, r as readLegacyRows, h as readRawSyncOps } from '../sync-Dnogcmm_.cjs';
3
+ import { e as StoreDef, R as RangeDTO, K as KeyDTO, f as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, d as IStorageTransaction } from '../wire-CerODSdR.cjs';
4
+ import { b as StoredSyncOp, S as SyncMutation } from '../sync-DJYfvXeH.cjs';
5
+ export { A as ApplySyncBatchOptions, R as RawSyncOp, c as SYNC_OPS_TABLE, d as SYNC_STATE_TABLE, a as SyncEntry, e as SyncTargetKind, f as applySyncBatch, g as fetchSyncOps, i as initSyncTarget, p as probeSyncTarget, r as readLegacyRows, h as readRawSyncOps } from '../sync-DJYfvXeH.cjs';
6
6
  import '@libsql/client';
7
7
  import '@bitcobblers/wod-wiki-core';
8
8
  import '@bitcobblers/wod-wiki-lang';
@@ -1,8 +1,8 @@
1
1
  import { S as SqlConnection, D as Database } from '../connection-DxuCLpRc.js';
2
2
  export { L as LibsqlClient, a as SqlRow, b as SqlStatement, c as SqlValue, l as libsqlDatabase } from '../connection-DxuCLpRc.js';
3
- import { e as StoreDef, R as RangeDTO, K as KeyDTO, f as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, d as IStorageTransaction } from '../wire-sRdblNjM.js';
4
- import { b as StoredSyncOp, S as SyncMutation } from '../sync-BeNNJq5-.js';
5
- export { A as ApplySyncBatchOptions, R as RawSyncOp, c as SYNC_OPS_TABLE, d as SYNC_STATE_TABLE, a as SyncEntry, e as SyncTargetKind, f as applySyncBatch, g as fetchSyncOps, i as initSyncTarget, p as probeSyncTarget, r as readLegacyRows, h as readRawSyncOps } from '../sync-BeNNJq5-.js';
3
+ import { e as StoreDef, R as RangeDTO, K as KeyDTO, f as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, d as IStorageTransaction } from '../wire-CerODSdR.js';
4
+ import { b as StoredSyncOp, S as SyncMutation } from '../sync-Bl-3Hr1W.js';
5
+ export { A as ApplySyncBatchOptions, R as RawSyncOp, c as SYNC_OPS_TABLE, d as SYNC_STATE_TABLE, a as SyncEntry, e as SyncTargetKind, f as applySyncBatch, g as fetchSyncOps, i as initSyncTarget, p as probeSyncTarget, r as readLegacyRows, h as readRawSyncOps } from '../sync-Bl-3Hr1W.js';
6
6
  import '@libsql/client';
7
7
  import '@bitcobblers/wod-wiki-core';
8
8
  import '@bitcobblers/wod-wiki-lang';
@@ -1,7 +1,7 @@
1
- import { DOMAIN_PROJECTION_VERSION, bufferToOps, bufferedGet, overlayRows, isDirty, bufferSlot } from '../chunk-WSFEAN7C.mjs';
2
- import { getRows, storeDefinition, deleteRows, clearRows, SCHEMA_TABLE, decodeRowJson, encodeRowJson, initializeStore, putRow, wipeRows, getRow, listRowsFromIndexMany, listRows, countRows, putRows, deleteIn, batchInsert, SYNC_STATE_TABLE } from '../chunk-6WNKSMMW.mjs';
3
- export { SCHEMA_TABLE, SYNC_OPS_TABLE, SYNC_STATE_TABLE, applySyncBatch, clearRows, countRows, decodeRowJson, deleteRows, encodeRowJson, fetchSyncOps, getRow, getRows, initSyncTarget, initializeStore, listRows, listRowsFromIndexMany, probeSyncTarget, putRow, putRows, readLegacyRows, readRawSyncOps, storeDefinition, wipeRows } from '../chunk-6WNKSMMW.mjs';
4
- import { rowsEqual, validateStoredPins, DB_VERSION, STORE_DEFS, stampUserOwned, rangeFromIDB, keyFromValue, isRange } from '../chunk-W4J74CHN.mjs';
1
+ import { DOMAIN_PROJECTION_VERSION, bufferToOps, bufferedGet, overlayRows, isDirty, bufferSlot } from '../chunk-UZU3SJVC.mjs';
2
+ import { getRows, storeDefinition, deleteRows, clearRows, SCHEMA_TABLE, decodeRowJson, encodeRowJson, initializeStore, putRow, wipeRows, getRow, listRowsFromIndexMany, listRows, countRows, putRows, deleteIn, batchInsert, SYNC_STATE_TABLE } from '../chunk-62HQFP3B.mjs';
3
+ export { SCHEMA_TABLE, SYNC_OPS_TABLE, SYNC_STATE_TABLE, applySyncBatch, clearRows, countRows, decodeRowJson, deleteRows, encodeRowJson, fetchSyncOps, getRow, getRows, initSyncTarget, initializeStore, listRows, listRowsFromIndexMany, probeSyncTarget, putRow, putRows, readLegacyRows, readRawSyncOps, storeDefinition, wipeRows } from '../chunk-62HQFP3B.mjs';
4
+ import { rowsEqual, validateStoredPins, DB_VERSION, STORE_DEFS, stampUserOwned, rangeFromIDB, keyFromValue, isRange } from '../chunk-WPWAMGAW.mjs';
5
5
  import { libsqlDatabase } from '../chunk-6ZTAWTAP.mjs';
6
6
  export { libsqlDatabase } from '../chunk-6ZTAWTAP.mjs';
7
7
  import { StorageError } from '../chunk-XRQKLSOT.mjs';
@@ -23,6 +23,11 @@ function sourceNote(row) {
23
23
  if (!Array.isArray(tags) || !tags.every((t) => typeof t === "string")) throw new StorageError(400, "tags must be a string array");
24
24
  item.tags = tags;
25
25
  }
26
+ const notebookIds = row["notebookIds"];
27
+ if (notebookIds !== void 0 && notebookIds !== null) {
28
+ if (!Array.isArray(notebookIds) || !notebookIds.every((n) => typeof n === "string")) throw new StorageError(400, "notebookIds must be a string array");
29
+ item.notebookIds = notebookIds;
30
+ }
26
31
  return item;
27
32
  }
28
33
  var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
@@ -922,9 +927,11 @@ var SqlStore = class {
922
927
  this.assertMutable();
923
928
  const stored = this.owner.stamp(this.store, value);
924
929
  const key = keyFromValue(this.def, stored);
925
- if (this.store === "block_revisions") {
930
+ if (this.store === "block_revisions" || this.store === "note_revisions") {
926
931
  const previous = this.buffer?.get(bufferSlot(this.store, key));
927
- if (previous?.kind === "put" && !rowsEqual(previous.value, stored)) throw new StorageError(409, "immutable block revision collision", "revision_conflict");
932
+ if (previous?.kind === "put" && !rowsEqual(previous.value, stored)) {
933
+ throw new StorageError(409, this.store === "note_revisions" ? "immutable note revision collision" : "immutable block revision collision", "revision_conflict");
934
+ }
928
935
  }
929
936
  if (this.buffer) {
930
937
  this.buffer.set(bufferSlot(this.store, key), { kind: "put", value: stored });
@@ -938,12 +945,14 @@ var SqlStore = class {
938
945
  this.assertMutable();
939
946
  const stored = values.map((value) => this.owner.stamp(this.store, value));
940
947
  const keys = stored.map((value) => keyFromValue(this.def, value));
941
- if (this.store === "block_revisions") {
948
+ if (this.store === "block_revisions" || this.store === "note_revisions") {
942
949
  const seen = /* @__PURE__ */ new Map();
943
950
  keys.forEach((key, i) => {
944
951
  const slot = bufferSlot(this.store, key), previous = this.buffer?.get(slot);
945
952
  const value = seen.has(slot) ? seen.get(slot) : previous?.kind === "put" ? previous.value : void 0;
946
- if (value !== void 0 && !rowsEqual(value, stored[i])) throw new StorageError(409, "immutable block revision collision", "revision_conflict");
953
+ if (value !== void 0 && !rowsEqual(value, stored[i])) {
954
+ throw new StorageError(409, this.store === "note_revisions" ? "immutable note revision collision" : "immutable block revision collision", "revision_conflict");
955
+ }
947
956
  seen.set(slot, stored[i]);
948
957
  });
949
958
  }
@@ -954,7 +963,7 @@ var SqlStore = class {
954
963
  async delete(key) {
955
964
  await this.owner.ensureReady();
956
965
  this.assertMutable();
957
- if (this.store === "block_revisions") throw new StorageError(409, "block history requires explicit wipe", "revision_conflict");
966
+ if (this.store === "block_revisions" || this.store === "note_revisions") throw new StorageError(409, "block history requires explicit wipe", "revision_conflict");
958
967
  const range = isRange(key) ? key : void 0;
959
968
  const target = range ?? key;
960
969
  if (this.buffer) {
@@ -974,7 +983,7 @@ var SqlStore = class {
974
983
  async clear() {
975
984
  await this.owner.ensureReady();
976
985
  this.assertMutable();
977
- if (this.store === "block_revisions") throw new StorageError(409, "block history requires explicit wipe", "revision_conflict");
986
+ if (this.store === "block_revisions" || this.store === "note_revisions") throw new StorageError(409, "block history requires explicit wipe", "revision_conflict");
978
987
  if (this.buffer) {
979
988
  this.cleared?.add(this.store);
980
989
  const prefix = `${this.store}\0`;