@bitcobblers/wod-wiki-storage 0.37.2137 → 0.37.2140

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,6 +1,6 @@
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 { a as StoreDef, R as RangeDTO, K as KeyDTO, e as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, b as IReadOnlyStore, c as StoreType, d as IReadWriteStore, D as DomainQuery, f as IStorageTransaction } from '../wire-CiFcjo6_.cjs';
3
+ import { a as StoreDef, R as RangeDTO, K as KeyDTO, e as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, b as IReadOnlyStore, c as StoreType, d as IReadWriteStore, D as DomainQuery, f as IStorageTransaction } from '../wire-CKJDK_Nq.cjs';
4
4
  import '@libsql/client';
5
5
  import '@bitcobblers/wod-wiki-core';
6
6
  import '@bitcobblers/wod-wiki-lang';
@@ -1,6 +1,6 @@
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 { a as StoreDef, R as RangeDTO, K as KeyDTO, e as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, b as IReadOnlyStore, c as StoreType, d as IReadWriteStore, D as DomainQuery, f as IStorageTransaction } from '../wire-CiFcjo6_.js';
3
+ import { a as StoreDef, R as RangeDTO, K as KeyDTO, e as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, b as IReadOnlyStore, c as StoreType, d as IReadWriteStore, D as DomainQuery, f as IStorageTransaction } from '../wire-CKJDK_Nq.js';
4
4
  import '@libsql/client';
5
5
  import '@bitcobblers/wod-wiki-core';
6
6
  import '@bitcobblers/wod-wiki-lang';
@@ -1,4 +1,4 @@
1
- import { STORE_DEFS, extractKeyPart, validateStorageRow, isRange, DB_VERSION, rowsEqual, validateStoredPins, DOMAIN_PROJECTION_VERSION, bufferToOps, stampUserOwned, bufferedGet, overlayRows, rangeFromIDB, isDirty, keyFromValue, bufferSlot, COLUMN_TYPES, keyInRange, compareKeys } from '../chunk-Y3CYPF2E.mjs';
1
+ import { STORE_DEFS, extractKeyPart, validateStorageRow, isRange, DB_VERSION, rowsEqual, validateStoredPins, DOMAIN_PROJECTION_VERSION, bufferToOps, stampUserOwned, bufferedGet, overlayRows, rangeFromIDB, isDirty, keyFromValue, bufferSlot, COLUMN_TYPES, keyInRange, compareKeys } from '../chunk-7BDO6DD4.mjs';
2
2
  import { libsqlDatabase } from '../chunk-6ZTAWTAP.mjs';
3
3
  export { libsqlDatabase } from '../chunk-6ZTAWTAP.mjs';
4
4
  import { StorageError } from '../chunk-XRQKLSOT.mjs';
@@ -63,6 +63,16 @@ function decodeRowJson(text2, binaryField) {
63
63
  // src/sql/store.ts
64
64
  var SCHEMA_TABLE = "_wodwiki_schema";
65
65
  var SCHEMA_KEY = "schema";
66
+ var ADDED_STORES_BY_VERSION = {
67
+ 31: ["equipment", "block_equipment"]
68
+ };
69
+ function additiveStoresSince(stored) {
70
+ const added = /* @__PURE__ */ new Set();
71
+ for (const [version, names] of Object.entries(ADDED_STORES_BY_VERSION)) {
72
+ if (Number(version) > stored) for (const name of names) added.add(name);
73
+ }
74
+ return added;
75
+ }
66
76
  var BINARY_FIELD = { attachments: "data" };
67
77
  var binaryFieldOf = (def) => BINARY_FIELD[def.name];
68
78
  function storeDefinition(name) {
@@ -544,7 +554,7 @@ async function initializeStore(db) {
544
554
  await tx.exec(
545
555
  `CREATE TABLE IF NOT EXISTS "${SCHEMA_TABLE}" ("key" TEXT PRIMARY KEY, "value" TEXT NOT NULL)`
546
556
  );
547
- const ignored = (name) => name.startsWith("_wodwiki_") || name.startsWith("sqlite_");
557
+ const ignored = (name) => name.startsWith("_wodwiki_") || name.startsWith("sqlite_") || name === "domain_note" || name === "query_block";
548
558
  const storeTables = new Set(STORE_DEFS.map((d) => d.name));
549
559
  for (const def of STORE_DEFS) {
550
560
  const multi = def.indexes.find((i) => i.multiEntry);
@@ -571,7 +581,8 @@ async function initializeStore(db) {
571
581
  if (stored < DB_VERSION) {
572
582
  const missing = [...storeTables].filter((name) => !tableNames.has(name));
573
583
  const unexpected = [...tableNames].filter((name) => name !== SCHEMA_TABLE && !storeTables.has(name));
574
- if (missing.length > 0 || unexpected.length > 0) {
584
+ const additive = additiveStoresSince(stored);
585
+ if (stored < 30 || unexpected.length > 0 || missing.some((name) => !additive.has(name))) {
575
586
  throw new StorageError(
576
587
  500,
577
588
  `database schema v${stored} is incompatible with v${DB_VERSION} (missing tables: ${missing.join(", ") || "none"}; unrecognized tables: ${unexpected.join(", ") || "none"}); recreation required using an explicitly disposable database`,