@bitcobblers/wod-wiki-storage 0.51.2196 → 0.53.2203
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-UN56ET7P.mjs → chunk-7HPAY2MQ.mjs} +5 -4
- package/dist/chunk-7HPAY2MQ.mjs.map +1 -0
- package/dist/{chunk-7ICLFFYU.mjs → chunk-AK7366MO.mjs} +4 -2
- package/dist/chunk-AK7366MO.mjs.map +1 -0
- package/dist/{chunk-PJ7GRYOZ.mjs → chunk-SGZMJ4UK.mjs} +3 -3
- package/dist/{chunk-PJ7GRYOZ.mjs.map → chunk-SGZMJ4UK.mjs.map} +1 -1
- package/dist/{chunk-J6KVDPTL.mjs → chunk-SYGE26AO.mjs} +25 -6
- package/dist/chunk-SYGE26AO.mjs.map +1 -0
- package/dist/idb/index.cjs +23 -4
- 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 +3 -3
- package/dist/index.cjs +25 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +5 -5
- package/dist/{policy-BBwCBMtp.d.cts → policy-CIp-4Qhy.d.cts} +1 -1
- package/dist/{policy-C86TCPSM.d.ts → policy-HlkmPine.d.ts} +1 -1
- package/dist/sql/index.cjs +41 -10
- 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 +20 -9
- package/dist/sql/index.mjs.map +1 -1
- package/dist/{sync-BDu_Q__z.d.cts → sync-BNkMF5dK.d.cts} +1 -1
- package/dist/{sync-BQ0g8ctt.d.ts → sync-DyTQ8hIc.d.ts} +1 -1
- package/dist/{wire-BO8FM1LJ.d.ts → wire-DPD-vJPP.d.cts} +4 -2
- package/dist/{wire-BO8FM1LJ.d.cts → wire-DPD-vJPP.d.ts} +4 -2
- package/package.json +6 -6
- package/dist/chunk-7ICLFFYU.mjs.map +0 -1
- package/dist/chunk-J6KVDPTL.mjs.map +0 -1
- package/dist/chunk-UN56ET7P.mjs.map +0 -1
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 = 33;
|
|
128
128
|
var COLUMN_TYPES = {
|
|
129
129
|
notes: { date: "number", createdAt: "number" },
|
|
130
130
|
page: { createdAt: "number" },
|
|
@@ -172,6 +172,8 @@ var COLUMN_TYPES = {
|
|
|
172
172
|
},
|
|
173
173
|
block_efforts: { createdAt: "number", isStatic: "boolean" },
|
|
174
174
|
block_equipment: { createdAt: "number", isStatic: "boolean" },
|
|
175
|
+
notebook_links: { createdAt: "number" },
|
|
176
|
+
property_overrides: { updatedAt: "number" },
|
|
175
177
|
meta: {},
|
|
176
178
|
memberships: { createdAt: "number" }
|
|
177
179
|
};
|
|
@@ -288,6 +290,21 @@ var STORE_DEFS = [
|
|
|
288
290
|
{ name: "by-block", keyPath: ["blockContentId"] },
|
|
289
291
|
{ name: "by-user", keyPath: ["userId"] }
|
|
290
292
|
] },
|
|
293
|
+
// 13c. notebook_links (V33) — many-to-many Note & Session <-> Notebook links
|
|
294
|
+
{ name: "notebook_links", keyPath: ["id"], indexes: [
|
|
295
|
+
{ name: "by-notebook", keyPath: ["notebookId"] },
|
|
296
|
+
{ name: "by-note", keyPath: ["noteId"] },
|
|
297
|
+
{ name: "by-target", keyPath: ["targetKind", "targetId"] },
|
|
298
|
+
{ name: "by-notebook-target", keyPath: ["notebookId", "targetKind", "targetId"], unique: true },
|
|
299
|
+
{ name: "by-user", keyPath: ["userId"] }
|
|
300
|
+
] },
|
|
301
|
+
// 13d. property_overrides (V33) — Notebook-scoped Property Note overrides
|
|
302
|
+
{ name: "property_overrides", keyPath: ["id"], indexes: [
|
|
303
|
+
{ name: "by-notebook", keyPath: ["notebookId"] },
|
|
304
|
+
{ name: "by-kind-slug", keyPath: ["kind", "slug"] },
|
|
305
|
+
{ name: "by-owner-note", keyPath: ["ownerNoteId"] },
|
|
306
|
+
{ name: "by-user", keyPath: ["userId"] }
|
|
307
|
+
] },
|
|
291
308
|
// 14. meta
|
|
292
309
|
{ name: "meta", keyPath: ["key"], indexes: [] },
|
|
293
310
|
// 15. memberships (V25, system — survives wipe; truth lives in
|
|
@@ -387,7 +404,7 @@ function validateStorageRow(store, value) {
|
|
|
387
404
|
const positive = (field) => typeof row[field] === "number" && Number.isSafeInteger(row[field]) && row[field] > 0;
|
|
388
405
|
const required = (field) => typeof row[field] === "string" && row[field].length > 0;
|
|
389
406
|
if (store === "notes") {
|
|
390
|
-
if (!required("id") || typeof row.title !== "string" || typeof row.rawContent !== "string" || !positive("sourceRevision") || typeof row.createdAt !== "number" || !Number.isFinite(row.createdAt) || "segments" in row || "segmentIds" in row || row.date !== void 0 && (typeof row.date !== "number" || !Number.isFinite(row.date)) || row.seedOrigin !== void 0 && row.seedOrigin !== "seed" && row.seedOrigin !== "user" || row.feedOrigin !== void 0 && row.feedOrigin !== "feed" && row.feedOrigin !== "user" || row.feedOrigin === "feed" && (row.seedOrigin === void 0 || typeof row.feedSourceId !== "string" || row.feedSourceId.length === 0) || row.feedOrigin === "user" && row.seedOrigin === "seed" || row.feedSourceId !== void 0 && row.feedOrigin !== "feed" || row.seedVersion !== void 0 && !(typeof row.seedVersion === "number" && Number.isSafeInteger(row.seedVersion) && row.seedVersion >= 0) || row.tags !== void 0 && (!Array.isArray(row.tags) || !row.tags.every((tag) => typeof tag === "string")) || ["type", "sourceId", "sourcePath", "notebookId", "seedChunkId", "feedSourceId"].some((field) => row[field] !== void 0 && typeof row[field] !== "string")) {
|
|
407
|
+
if (!required("id") || typeof row.title !== "string" || typeof row.rawContent !== "string" || !positive("sourceRevision") || typeof row.createdAt !== "number" || !Number.isFinite(row.createdAt) || "segments" in row || "segmentIds" in row || row.date !== void 0 && (typeof row.date !== "number" || !Number.isFinite(row.date)) || row.seedOrigin !== void 0 && row.seedOrigin !== "seed" && row.seedOrigin !== "user" || row.feedOrigin !== void 0 && row.feedOrigin !== "feed" && row.feedOrigin !== "user" || row.feedOrigin === "feed" && (row.seedOrigin === void 0 || typeof row.feedSourceId !== "string" || row.feedSourceId.length === 0) || row.feedOrigin === "user" && row.seedOrigin === "seed" || row.feedSourceId !== void 0 && row.feedOrigin !== "feed" || row.seedVersion !== void 0 && !(typeof row.seedVersion === "number" && Number.isSafeInteger(row.seedVersion) && row.seedVersion >= 0) || row.tags !== void 0 && (!Array.isArray(row.tags) || !row.tags.every((tag) => typeof tag === "string")) || row.public !== void 0 && typeof row.public !== "boolean" || row.notebookIds !== void 0 && (!Array.isArray(row.notebookIds) || !row.notebookIds.every((nb) => typeof nb === "string")) || row.provenance !== void 0 && (typeof row.provenance !== "object" || row.provenance === null || Array.isArray(row.provenance) || typeof row.provenance.sourceNoteId !== "string") || ["type", "sourceId", "sourcePath", "notebookId", "seedChunkId", "feedSourceId"].some((field) => row[field] !== void 0 && typeof row[field] !== "string")) {
|
|
391
408
|
throw new StorageError(400, "invalid whole Note", "invalid_note_blocks");
|
|
392
409
|
}
|
|
393
410
|
try {
|
|
@@ -412,7 +429,7 @@ function validateStorageRow(store, value) {
|
|
|
412
429
|
throw new StorageError(400, error instanceof Error ? error.message : "invalid revision source", "invalid_note_blocks");
|
|
413
430
|
}
|
|
414
431
|
} else if (store === "sessions") {
|
|
415
|
-
if (!required("noteId") || !required("blockId") || !positive("blockVersion") || ["segmentId", "segmentVersion", "version", "rawContent", "script", "serializedScript", "source", "data", "logs"].some((field) => field in row)) {
|
|
432
|
+
if (!required("noteId") || !required("blockId") || !positive("blockVersion") || row.public !== void 0 && typeof row.public !== "boolean" || row.notebookIds !== void 0 && (!Array.isArray(row.notebookIds) || !row.notebookIds.every((nb) => typeof nb === "string")) || ["segmentId", "segmentVersion", "version", "rawContent", "script", "serializedScript", "source", "data", "logs"].some((field) => field in row)) {
|
|
416
433
|
throw new StorageError(400, "Session requires immutable block pin", "invalid_session_pin");
|
|
417
434
|
}
|
|
418
435
|
} else if (!required("noteId") || !required("blockId") || !positive("blockVersion") || !positive("sourceRevision") || row.id !== `${row.noteId}:${row.blockId}` || !Number.isSafeInteger(row.from) || !Number.isSafeInteger(row.to) || "segmentId" in row || "segmentVersion" in row || !["wod", "query", "widget", "embed"].includes(String(row.dataType)) || typeof row.rawContent !== "string" || typeof row.noteTitle !== "string" || typeof row.from !== "number" || typeof row.to !== "number" || row.from < 0 || row.to <= row.from) {
|
|
@@ -439,7 +456,8 @@ async function validateStoredPins(notes, sessions, getRevisions) {
|
|
|
439
456
|
var SCHEMA_TABLE = "_wodwiki_schema";
|
|
440
457
|
var SCHEMA_KEY = "schema";
|
|
441
458
|
var ADDED_STORES_BY_VERSION = {
|
|
442
|
-
31: ["equipment", "block_equipment"]
|
|
459
|
+
31: ["equipment", "block_equipment"],
|
|
460
|
+
33: ["notebook_links", "property_overrides"]
|
|
443
461
|
};
|
|
444
462
|
function additiveStoresSince(stored) {
|
|
445
463
|
const added = /* @__PURE__ */ new Set();
|
|
@@ -1554,11 +1572,22 @@ function predicateSql(ctx, p, plan) {
|
|
|
1554
1572
|
p.negate === true,
|
|
1555
1573
|
`EXISTS (SELECT 1 FROM "note_tags" nt JOIN "tags" t ON t."k0" = nt."i_by_tag_0" WHERE nt."i_by_note_0" = ${noteId} AND t."i_by_label_0" IN (${p.values.map((v) => ctx.bind(v)).join(", ")}))`
|
|
1556
1574
|
);
|
|
1557
|
-
case "typedTag":
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1575
|
+
case "typedTag": {
|
|
1576
|
+
const tagMatch = `EXISTS (SELECT 1 FROM "note_tags" nt JOIN "tags" t ON t."k0" = nt."i_by_tag_0" WHERE nt."i_by_note_0" = ${noteId} AND t."i_by_type_0" = ${ctx.bind(p.tagType)} AND t."i_by_label_0" IN (${p.values.map((v) => ctx.bind(v)).join(", ")}))`;
|
|
1577
|
+
if (p.tagType === "equipment") {
|
|
1578
|
+
const slugs = Array.from(
|
|
1579
|
+
new Set(
|
|
1580
|
+
p.values.flatMap((v) => {
|
|
1581
|
+
const slug = v.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
1582
|
+
return slug && slug !== v ? [v, slug] : [v];
|
|
1583
|
+
})
|
|
1584
|
+
)
|
|
1585
|
+
);
|
|
1586
|
+
const blockMatch = `EXISTS (SELECT 1 FROM "block_equipment" beq WHERE beq."i_by_note_0" = ${noteId} AND beq."i_by_equipment_0" IN (${slugs.map((v) => ctx.bind(v)).join(", ")}))`;
|
|
1587
|
+
return wrap(p.negate === true, `(${tagMatch} OR ${blockMatch})`);
|
|
1588
|
+
}
|
|
1589
|
+
return wrap(p.negate === true, tagMatch);
|
|
1590
|
+
}
|
|
1562
1591
|
case "effort":
|
|
1563
1592
|
return wrap(
|
|
1564
1593
|
p.negate === true,
|
|
@@ -1690,7 +1719,9 @@ var USER_OWNED_STORES = [
|
|
|
1690
1719
|
"block_index",
|
|
1691
1720
|
"block_efforts",
|
|
1692
1721
|
"equipment",
|
|
1693
|
-
"block_equipment"
|
|
1722
|
+
"block_equipment",
|
|
1723
|
+
"notebook_links",
|
|
1724
|
+
"property_overrides"
|
|
1694
1725
|
];
|
|
1695
1726
|
var STAMPABLE = Object.fromEntries(
|
|
1696
1727
|
USER_OWNED_STORES.map((s) => [s, true])
|