@bitcobblers/wod-wiki-storage 0.55.2206 → 0.56.2208
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/{chunk-SYGE26AO.mjs → chunk-325UJL7V.mjs} +4 -3
- package/dist/chunk-325UJL7V.mjs.map +1 -0
- package/dist/{chunk-7HPAY2MQ.mjs → chunk-57JHRZPS.mjs} +39 -4
- package/dist/{chunk-7HPAY2MQ.mjs.map → chunk-57JHRZPS.mjs.map} +1 -1
- package/dist/{chunk-SGZMJ4UK.mjs → chunk-S5RXBUSQ.mjs} +3 -3
- package/dist/{chunk-SGZMJ4UK.mjs.map → chunk-S5RXBUSQ.mjs.map} +1 -1
- package/dist/idb/index.cjs +2 -1
- package/dist/idb/index.cjs.map +1 -1
- package/dist/idb/index.d.cts +3 -3
- package/dist/idb/index.d.ts +3 -3
- package/dist/idb/index.mjs +2 -2
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/{policy-CIp-4Qhy.d.cts → policy-BrDCt3IU.d.cts} +1 -1
- package/dist/{policy-HlkmPine.d.ts → policy-JQg92EFM.d.ts} +1 -1
- package/dist/sql/index.cjs +38 -2
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +3 -3
- package/dist/sql/index.d.ts +3 -3
- package/dist/sql/index.mjs +4 -4
- package/dist/{sync-DyTQ8hIc.d.ts → sync-BeNNJq5-.d.ts} +1 -1
- package/dist/{sync-BNkMF5dK.d.cts → sync-Dnogcmm_.d.cts} +1 -1
- package/dist/{wire-DPD-vJPP.d.ts → wire-sRdblNjM.d.cts} +1 -1
- package/dist/{wire-DPD-vJPP.d.cts → wire-sRdblNjM.d.ts} +1 -1
- package/package.json +6 -6
- package/dist/chunk-SYGE26AO.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Membership, Note, Session, BlockRevision } from '@bitcobblers/wod-wiki-core';
|
|
2
2
|
export { AnalyticsDataPoint, Attachment, BlockEffort, BlockEquipment, BlockIndexRow, BlockRevision, EventGrain, EventRecord, Membership, Note, NoteBlock, NoteBlockKind, NoteKind, NoteProvenance, NoteTag, NotebookLink, NotebookLinkTargetKind, OverridePropertyKind, Page, PageNote, ResultOrigin, ScopedPropertyOverride, Session, Tag, TagType, TagTypeRecord } from '@bitcobblers/wod-wiki-core';
|
|
3
|
-
import { S as StoreName, I as IStorage, e as StoreDef, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, f as DomainQueryResult, d as IStorageTransaction } from './wire-
|
|
4
|
-
export { C as COLUMN_TYPES, g as DB_VERSION, h as DOMAIN_PROJECTION_VERSION, i as DomainDetail, j as DomainOrder, k as DomainPredicate, l as IndexDef, K as KeyDTO, R as RangeDTO, m as STORE_DEFS, n as Scalar, o as StorageColumnType, p as StorageSchema, T as TxOp, q as compareKeys, r as encodeKey, s as extractKeyPart, t as isRange, u as keyFromValue, v as keyInRange, w as parseDomainQueryResult, x as rangeFromIDB } from './wire-
|
|
5
|
-
export { a as USER_DELETED_SEED_PREFIX, U as UserScopeContext, c as collectUserScopeContext, i as isSeedMetaKey, b as isUserOwnedRow, u as userDeletedSeedKey, d as userDeletedSeedNoteId } from './policy-
|
|
3
|
+
import { S as StoreName, I as IStorage, e as StoreDef, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, f as DomainQueryResult, d as IStorageTransaction } from './wire-sRdblNjM.js';
|
|
4
|
+
export { C as COLUMN_TYPES, g as DB_VERSION, h as DOMAIN_PROJECTION_VERSION, i as DomainDetail, j as DomainOrder, k as DomainPredicate, l as IndexDef, K as KeyDTO, R as RangeDTO, m as STORE_DEFS, n as Scalar, o as StorageColumnType, p as StorageSchema, T as TxOp, q as compareKeys, r as encodeKey, s as extractKeyPart, t as isRange, u as keyFromValue, v as keyInRange, w as parseDomainQueryResult, x as rangeFromIDB } from './wire-sRdblNjM.js';
|
|
5
|
+
export { a as USER_DELETED_SEED_PREFIX, U as UserScopeContext, c as collectUserScopeContext, i as isSeedMetaKey, b as isUserOwnedRow, u as userDeletedSeedKey, d as userDeletedSeedNoteId } from './policy-JQg92EFM.js';
|
|
6
6
|
import '@bitcobblers/wod-wiki-lang';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { USER_DELETED_SEED_PREFIX, collectUserScopeContext, isSeedMetaKey, isUserOwnedRow, userDeletedSeedKey, userDeletedSeedNoteId } from './chunk-AK7366MO.mjs';
|
|
2
|
-
import { parseDomainQueryResult, bufferToOps, isDirty, bufferedGet, bufferSlot, overlayRows } from './chunk-
|
|
3
|
-
export { DOMAIN_PROJECTION_VERSION, parseDomainQueryResult } from './chunk-
|
|
4
|
-
import { STORE_DEFS, isRange, rangeFromIDB, keyFromValue, stampUserOwned, rowsEqual, encodeKey } from './chunk-
|
|
5
|
-
export { COLUMN_TYPES, DB_VERSION, DEFAULT_MEMBERSHIP_ID, STORE_DEFS, USER_OWNED_STORES, compareKeys, createDefaultMembership, encodeKey, extractKeyPart, isRange, keyFromValue, keyInRange, rangeFromIDB, rowsEqual, stampUserOwned, validateNoteWrite, validateSessionWrite, validateStorageRow, validateStoredPins } from './chunk-
|
|
2
|
+
import { parseDomainQueryResult, bufferToOps, isDirty, bufferedGet, bufferSlot, overlayRows } from './chunk-S5RXBUSQ.mjs';
|
|
3
|
+
export { DOMAIN_PROJECTION_VERSION, parseDomainQueryResult } from './chunk-S5RXBUSQ.mjs';
|
|
4
|
+
import { STORE_DEFS, isRange, rangeFromIDB, keyFromValue, stampUserOwned, rowsEqual, encodeKey } from './chunk-325UJL7V.mjs';
|
|
5
|
+
export { COLUMN_TYPES, DB_VERSION, DEFAULT_MEMBERSHIP_ID, STORE_DEFS, USER_OWNED_STORES, compareKeys, createDefaultMembership, encodeKey, extractKeyPart, isRange, keyFromValue, keyInRange, rangeFromIDB, rowsEqual, stampUserOwned, validateNoteWrite, validateSessionWrite, validateStorageRow, validateStoredPins } from './chunk-325UJL7V.mjs';
|
|
6
6
|
import './chunk-XRQKLSOT.mjs';
|
|
7
7
|
|
|
8
8
|
// src/api.ts
|
package/dist/sql/index.cjs
CHANGED
|
@@ -124,7 +124,7 @@ function decodeRowJson(text2, binaryField) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// src/schema.ts
|
|
127
|
-
var DB_VERSION =
|
|
127
|
+
var DB_VERSION = 34;
|
|
128
128
|
var COLUMN_TYPES = {
|
|
129
129
|
notes: { date: "number", createdAt: "number" },
|
|
130
130
|
page: { createdAt: "number" },
|
|
@@ -182,6 +182,7 @@ var STORE_DEFS = [
|
|
|
182
182
|
{ name: "notes", keyPath: ["id"], indexes: [
|
|
183
183
|
{ name: "by-date", keyPath: ["date"] },
|
|
184
184
|
{ name: "by-created", keyPath: ["createdAt"] },
|
|
185
|
+
{ name: "by-type", keyPath: ["type"] },
|
|
185
186
|
{ name: "by-user", keyPath: ["userId"] }
|
|
186
187
|
] },
|
|
187
188
|
// 2. page
|
|
@@ -883,13 +884,28 @@ async function wipeRows(conn) {
|
|
|
883
884
|
function tableListSql(dialect) {
|
|
884
885
|
return dialect === "sqlite" ? `SELECT "name" FROM "sqlite_master" WHERE "type" = 'table'` : `SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = current_schema()`;
|
|
885
886
|
}
|
|
887
|
+
async function existingColumnSet(conn, dialect, tableName) {
|
|
888
|
+
if (dialect === "sqlite") {
|
|
889
|
+
const rows2 = await conn.query(`PRAGMA table_info("${tableName}")`);
|
|
890
|
+
return new Set(rows2.map((r) => String(r.name)));
|
|
891
|
+
}
|
|
892
|
+
const rows = await conn.query(
|
|
893
|
+
`SELECT "column_name" FROM "information_schema"."columns" WHERE "table_schema" = current_schema() AND "table_name" = ?`,
|
|
894
|
+
[tableName]
|
|
895
|
+
);
|
|
896
|
+
return new Set(rows.map((r) => String(r.column_name)));
|
|
897
|
+
}
|
|
886
898
|
async function ensureStoreTables(conn, dialect, def) {
|
|
887
899
|
const keys = keyCols(def);
|
|
888
900
|
const cols = keys.map((k, i) => [k, colSql(dialect, pathType(def, def.keyPath[i]))]);
|
|
901
|
+
const indexedParts = [];
|
|
889
902
|
for (const idx of def.indexes) {
|
|
890
903
|
if (idx.multiEntry) continue;
|
|
891
904
|
idx.keyPath.forEach((path, part) => {
|
|
892
|
-
|
|
905
|
+
const col = indexCol(idx.name, part);
|
|
906
|
+
const typeSql = colSql(dialect, pathType(def, path));
|
|
907
|
+
cols.push([col, typeSql]);
|
|
908
|
+
indexedParts.push({ col, path, typeSql });
|
|
893
909
|
});
|
|
894
910
|
}
|
|
895
911
|
cols.push(["data", " TEXT NOT NULL"]);
|
|
@@ -897,6 +913,26 @@ async function ensureStoreTables(conn, dialect, def) {
|
|
|
897
913
|
await conn.exec(
|
|
898
914
|
`CREATE TABLE IF NOT EXISTS "${def.name}" (${colDefs.join(", ")}, PRIMARY KEY (${keys.map((k) => `"${k}"`).join(", ")}))`
|
|
899
915
|
);
|
|
916
|
+
if (indexedParts.length > 0) {
|
|
917
|
+
const existingCols = await existingColumnSet(conn, dialect, def.name);
|
|
918
|
+
const addedParts = indexedParts.filter((p) => !existingCols.has(p.col));
|
|
919
|
+
if (addedParts.length > 0) {
|
|
920
|
+
for (const part of addedParts) {
|
|
921
|
+
await conn.exec(`ALTER TABLE "${def.name}" ADD COLUMN "${part.col}"${part.typeSql}`);
|
|
922
|
+
}
|
|
923
|
+
const keySelect = keys.map((k) => `"${k}"`).join(", ");
|
|
924
|
+
const keyWhere = keys.map((k) => `"${k}" = ?`).join(" AND ");
|
|
925
|
+
const setClause = addedParts.map((p) => `"${p.col}" = ?`).join(", ");
|
|
926
|
+
const rows = await conn.query(`SELECT ${keySelect}, "data" FROM "${def.name}"`);
|
|
927
|
+
for (const row of rows) {
|
|
928
|
+
const decoded = decodeRowJson(String(row.data), binaryFieldOf(def));
|
|
929
|
+
const values = addedParts.map((p) => toSqlScalar(extractKeyPart(decoded, p.path)));
|
|
930
|
+
if (values.every((v) => v === null)) continue;
|
|
931
|
+
const keyValues = keys.map((k) => toSqlScalar(row[k]));
|
|
932
|
+
await conn.exec(`UPDATE "${def.name}" SET ${setClause} WHERE ${keyWhere}`, [...values, ...keyValues]);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
900
936
|
for (const idx of def.indexes) {
|
|
901
937
|
if (idx.multiEntry) continue;
|
|
902
938
|
const parts = idx.keyPath.map((_, part) => `"${indexCol(idx.name, part)}"`).join(", ");
|