@bitcobblers/wod-wiki-engine 0.59.2236 → 0.59.2240

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 { KNOWN_SECTION_WIDGETS, MetricType, reconcileNoteBlocks, validateNoteBlocks, parseDocumentSections, blockContentId, toNotebookId as toNotebookId$1, isSystemReadOnlyNotebook, notebookSlugFromId as notebookSlugFromId$1, patchFrontmatterProperty, createTagIndex, isNonPublishableNotebook, serializeNoteBundleToJsonl, derivePublicationVisibility, isPublishableNotebookLanding, parseNoteBundleFromJsonl, isNoteEditable, mapNoteBlockChanges } from '@bitcobblers/wod-wiki-core';
2
- import { getHints, documentToEffort, documentToEquipment, documentToTag, createReferenceIndex, parseEffortFile, parseEquipmentFile, parseScript, extractStatementRefs } from '@bitcobblers/wod-wiki-lang';
3
- import { WQL_TYPED_TAG_KEYS, notebookSlugFromId, toNotebookId, migrateLegacyChunkId, hasLegacyIdentity, migrateLegacyRow, notebooksOfItem, notebookOfItem, notebookOriginOfItem, notebookSlugOfSourceId } from '@bitcobblers/wod-wiki-wql';
2
+ import { getHints, documentToEffort, documentToEquipment, documentToTag, createReferenceIndex, parseEffortFile, parseEquipmentFile, bundledEfforts, parseScript, extractStatementRefs } from '@bitcobblers/wod-wiki-lang';
3
+ import { WQL_TYPED_TAG_KEYS, notebookSlugFromId, toNotebookId, migrateLegacyChunkId, hasLegacyIdentity, migrateLegacyRow, notebooksOfItem, notebookOfItem, notebookOriginOfItem, coalescingEventStore, notebookSlugOfSourceId } from '@bitcobblers/wod-wiki-wql';
4
4
  import { userDeletedSeedNoteId } from '@bitcobblers/wod-wiki-storage';
5
5
 
6
6
  // src/ir.ts
@@ -858,13 +858,13 @@ function csvToTelemetryBundle(csv) {
858
858
  }
859
859
 
860
860
  // src/version.ts
861
- var VERSION = "0.59.2236";
862
- var GIT_SHA = "7b4743b";
863
- var BUILD_TIME = "2026-11-16T04:52:27.639Z";
861
+ var VERSION = "0.59.2240";
862
+ var GIT_SHA = "920602f";
863
+ var BUILD_TIME = "2026-11-17T14:03:29.403Z";
864
864
  var SEMVER = {
865
- version: "0.59.2236",
866
- gitSha: "7b4743b",
867
- buildTime: "2026-11-16T04:52:27.639Z"
865
+ version: "0.59.2240",
866
+ gitSha: "920602f",
867
+ buildTime: "2026-11-17T14:03:29.403Z"
868
868
  };
869
869
  var SEED_SCHEMA = 9;
870
870
  var SEED_REGISTERED_WIDGETS = KNOWN_SECTION_WIDGETS;
@@ -1753,7 +1753,7 @@ async function applyPreparedSeedChunkInTx(tx, prepared) {
1753
1753
  if (compiledById.get(compiled.blockId)?.dataType !== "wod") throw new Error("Orphan seed session pin");
1754
1754
  const prior = existingTelemetrySessions.get(compiled.id);
1755
1755
  if (prior && prior.noteId !== id) throw new Error(`Seed session ${compiled.id} belongs to another note`);
1756
- if (prior?.origin) {
1756
+ if (prior && (prior.origin || !prior.id.startsWith("seed:"))) {
1757
1757
  userRecordedSessions.add(compiled.id);
1758
1758
  continue;
1759
1759
  }
@@ -3105,10 +3105,26 @@ async function collectPublicStorageState(storage, options = {}) {
3105
3105
  storedCheckpoint
3106
3106
  };
3107
3107
  }
3108
+ async function recordPublishedFeedCheckpoint(storage, report) {
3109
+ const chunkShas = {};
3110
+ for (const c of report.manifest.chunks) chunkShas[c.id] = c.sha256;
3111
+ const cp = {
3112
+ key: PUBLISHED_FEED_META_KEY,
3113
+ version: report.manifest.version,
3114
+ builtAt: report.manifest.builtAt,
3115
+ manifestSha256: report.manifestSha256,
3116
+ chunkShas
3117
+ };
3118
+ await storage.transaction(["meta"], "readwrite", async (tx) => {
3119
+ await tx.readwrite("meta").put(cp);
3120
+ });
3121
+ }
3108
3122
  async function publishFeedFromStorage(storage, tree, options = {}) {
3123
+ options.signal?.throwIfAborted();
3109
3124
  const t0 = Date.now();
3110
3125
  const layout = options.layout ?? "feed";
3111
3126
  const state = await collectPublicStorageState(storage, options);
3127
+ options.signal?.throwIfAborted();
3112
3128
  if (state.notebooks.size === 0) {
3113
3129
  throw new Error("No public notebooks found to publish. Mark at least one user-owned notebook as Public first.");
3114
3130
  }
@@ -3396,28 +3412,19 @@ ${group.description ?? ""}
3396
3412
  const manifestBytes = encodeUtf8(JSON.stringify(manifest, null, 2) + "\n");
3397
3413
  const manifestSha256 = await sha256HexAsync(manifestBytes);
3398
3414
  await tree.write(`${artifactPrefix}manifest.json`, manifestBytes);
3399
- const shouldCheckpoint = options.recordCheckpoint ?? (layout === "feed" && !options.notebookSlug);
3400
- if (shouldCheckpoint) {
3401
- const chunkShas = {};
3402
- for (const c of manifestChunks) chunkShas[c.id] = c.sha256;
3403
- const cp = {
3404
- key: PUBLISHED_FEED_META_KEY,
3405
- version: nextVersion,
3406
- builtAt,
3407
- manifestSha256,
3408
- chunkShas
3409
- };
3410
- await storage.transaction(["meta"], "readwrite", async (tx) => {
3411
- await tx.readwrite("meta").put(cp);
3412
- });
3413
- }
3414
- return {
3415
+ const report = {
3415
3416
  manifest,
3416
3417
  notebooks: sortedSlugs,
3417
3418
  totalNotes,
3418
3419
  totalPublicSessions,
3419
3420
  manifestSha256
3420
3421
  };
3422
+ const shouldCheckpoint = options.recordCheckpoint ?? (layout === "feed" && !options.notebookSlug);
3423
+ if (shouldCheckpoint) {
3424
+ options.signal?.throwIfAborted();
3425
+ await recordPublishedFeedCheckpoint(storage, report);
3426
+ }
3427
+ return report;
3421
3428
  }
3422
3429
  async function checkUnpublishedFeedChanges(storage, currentTree, options = {}) {
3423
3430
  const state = await collectPublicStorageState(storage, options);
@@ -4236,6 +4243,208 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
4236
4243
  errors
4237
4244
  };
4238
4245
  }
4246
+ var FEED_SUBSCRIPTIONS_META_KEY = "feed:subscriptions";
4247
+ async function removeSeedSourceContent(storage, meta) {
4248
+ return await storage.transaction(
4249
+ [
4250
+ "notes",
4251
+ "attachments",
4252
+ "tags",
4253
+ "note_tags",
4254
+ "block_index",
4255
+ "block_efforts",
4256
+ "block_equipment",
4257
+ "page_notes",
4258
+ "efforts",
4259
+ "equipment",
4260
+ "property_overrides",
4261
+ "meta"
4262
+ ],
4263
+ "readwrite",
4264
+ async (tx) => {
4265
+ const targetIds = /* @__PURE__ */ new Set();
4266
+ const legacyChunks = [];
4267
+ for (const [chunkId, chunk] of Object.entries(meta.chunks)) {
4268
+ if (chunk.noteIds?.length) {
4269
+ for (const id of chunk.noteIds) targetIds.add(id);
4270
+ } else {
4271
+ legacyChunks.push(chunkId);
4272
+ }
4273
+ }
4274
+ if (legacyChunks.length) {
4275
+ for (const note of await tx.readwrite("notes").getAll()) {
4276
+ if (note.seedOrigin === "seed" && note.seedChunkId && legacyChunks.includes(note.seedChunkId)) {
4277
+ targetIds.add(note.id);
4278
+ }
4279
+ }
4280
+ }
4281
+ const metaStore = tx.readwrite("meta");
4282
+ const otherCheckpoints = [];
4283
+ for (const row of await metaStore.getAll()) {
4284
+ const other = row;
4285
+ if (!other || typeof other.key !== "string" || !other.key.startsWith("seed:") || other.key === meta.key) {
4286
+ continue;
4287
+ }
4288
+ const noteIds = /* @__PURE__ */ new Set();
4289
+ for (const chunk of Object.values(other.chunks ?? {})) {
4290
+ for (const id of chunk.noteIds ?? []) noteIds.add(id);
4291
+ }
4292
+ otherCheckpoints.push({
4293
+ key: other.key,
4294
+ sourceId: other.key.slice(5),
4295
+ rank: seedPrecedenceRank(other.key, other.tier),
4296
+ meta: other,
4297
+ noteIds
4298
+ });
4299
+ }
4300
+ otherCheckpoints.sort((a, b) => b.rank - a.rank);
4301
+ const isClaimedByOther = (noteId) => otherCheckpoints.some((cp) => cp.noteIds.has(noteId));
4302
+ const removedSourceId = meta.key.startsWith("seed:") ? meta.key.slice(5) : meta.key;
4303
+ const notes = tx.readwrite("notes");
4304
+ const noteTags = tx.readwrite("note_tags");
4305
+ let deleted = 0;
4306
+ const removedPaths = /* @__PURE__ */ new Set();
4307
+ const touchedTagIds = /* @__PURE__ */ new Set();
4308
+ for (const id of targetIds) {
4309
+ if (isClaimedByOther(id)) continue;
4310
+ const note = await notes.get(id);
4311
+ if (!note || note.seedOrigin !== "seed") continue;
4312
+ if (note.seedChunkId && !meta.chunks[note.seedChunkId]) continue;
4313
+ if (note.sourcePath) removedPaths.add(note.sourcePath);
4314
+ await notes.delete(id);
4315
+ const attachments = tx.readwrite("attachments");
4316
+ for (const attachment of await attachments.getAllFromIndex("by-note", id)) {
4317
+ await attachments.delete(attachment.id);
4318
+ }
4319
+ for (const link of await noteTags.getAllFromIndex("by-note", id)) {
4320
+ touchedTagIds.add(link.tagId);
4321
+ await noteTags.delete(link.id);
4322
+ }
4323
+ const blockIndex = tx.readwrite("block_index");
4324
+ for (const row of await blockIndex.getAllFromIndex("by-note", id)) await blockIndex.delete(row.id);
4325
+ const blockEfforts = tx.readwrite("block_efforts");
4326
+ for (const row of await blockEfforts.getAllFromIndex("by-note", id)) await blockEfforts.delete(row.id);
4327
+ const blockEquipment = tx.readwrite("block_equipment");
4328
+ for (const row of await blockEquipment.getAllFromIndex("by-note", id)) await blockEquipment.delete(row.id);
4329
+ const pageNotes = tx.readwrite("page_notes");
4330
+ for (const link of await pageNotes.getAllFromIndex("by-note", id)) await pageNotes.delete(link.id);
4331
+ deleted++;
4332
+ }
4333
+ if (touchedTagIds.size > 0) {
4334
+ const tagsStore = tx.readwrite("tags");
4335
+ for (const tagId of touchedTagIds) {
4336
+ const remainingLinks = await noteTags.countFromIndex("by-tag", tagId);
4337
+ if (remainingLinks > 0) continue;
4338
+ const tag = await tagsStore.get(tagId);
4339
+ if (!tag) continue;
4340
+ if (tag.contributions && tag.contributions.length > 0) continue;
4341
+ const refNote = await notes.get(`t/${tag.type ?? "tag"}/${tag.label}`);
4342
+ if (refNote) continue;
4343
+ await tagsStore.delete(tagId);
4344
+ }
4345
+ }
4346
+ const defFamilies = [
4347
+ { storeName: "efforts", familyPathPrefix: "markdown/efforts/", parse: parseEffortFile },
4348
+ { storeName: "equipment", familyPathPrefix: "markdown/equipment/", parse: parseEquipmentFile }
4349
+ ];
4350
+ for (const { storeName, familyPathPrefix, parse } of defFamilies) {
4351
+ const store = tx.readwrite(storeName);
4352
+ for (const row of await store.getAll()) {
4353
+ if (row.registrySource !== "bundled") continue;
4354
+ const owned = row.sourceId === removedSourceId || row.ownerNoteId !== void 0 && targetIds.has(row.ownerNoteId) && (!row.sourceId || row.sourceId === storeName) || row.sourcePath !== void 0 && row.sourcePath.startsWith(familyPathPrefix) && removedPaths.has(row.sourcePath);
4355
+ if (!owned) continue;
4356
+ let restored = false;
4357
+ for (const cp of otherCheckpoints) {
4358
+ const candidateIds = cp.meta.chunks?.[storeName]?.noteIds ?? [];
4359
+ for (const candidateId of candidateIds) {
4360
+ const candidateNote = await notes.get(candidateId);
4361
+ if (!candidateNote || candidateNote.seedOrigin !== "seed") continue;
4362
+ const parsed = parse(candidateNote.rawContent);
4363
+ if (parsed && parsed.slug === row.slug) {
4364
+ await store.put({
4365
+ ...parsed,
4366
+ registrySource: "bundled",
4367
+ ownerNoteId: candidateNote.id,
4368
+ sourceId: cp.sourceId,
4369
+ feedSourceId: cp.sourceId,
4370
+ sourcePath: candidateNote.sourcePath ?? ""
4371
+ });
4372
+ restored = true;
4373
+ break;
4374
+ }
4375
+ }
4376
+ if (restored) break;
4377
+ }
4378
+ if (!restored) await store.delete(row.slug);
4379
+ }
4380
+ }
4381
+ try {
4382
+ const overrideStore = tx.readwrite("property_overrides");
4383
+ for (const ov of await overrideStore.getAll()) {
4384
+ if (ov.seedOrigin === "seed" && ov.feedSourceId === removedSourceId) {
4385
+ await overrideStore.delete(ov.id);
4386
+ }
4387
+ }
4388
+ } catch {
4389
+ }
4390
+ await metaStore.delete(meta.key);
4391
+ return deleted;
4392
+ }
4393
+ );
4394
+ }
4395
+ async function readFeedSubscriptionsMap(storage) {
4396
+ const row = await storage.readonly("meta").get(FEED_SUBSCRIPTIONS_META_KEY);
4397
+ return { ...row?.entries ?? {} };
4398
+ }
4399
+ async function writeFeedSubscriptionEntry(storage, sourceId, entry) {
4400
+ await storage.transaction(["meta"], "readwrite", async (tx) => {
4401
+ const metaStore = tx.readwrite("meta");
4402
+ const existing = await metaStore.get(FEED_SUBSCRIPTIONS_META_KEY);
4403
+ const entries = { ...existing?.entries ?? {}, [sourceId]: entry };
4404
+ await metaStore.put({ key: FEED_SUBSCRIPTIONS_META_KEY, entries });
4405
+ });
4406
+ }
4407
+ async function listFeedSubscriptionsHeadless(storage) {
4408
+ return readFeedSubscriptionsMap(storage);
4409
+ }
4410
+ async function subscribeFeedSourceHeadless(storage, sourceId, options) {
4411
+ const notebookIds = options?.notebookIds && options.notebookIds.length > 0 ? options.notebookIds : null;
4412
+ await writeFeedSubscriptionEntry(storage, sourceId, {
4413
+ subscribed: true,
4414
+ notebookIds,
4415
+ hidden: false,
4416
+ ...options?.url ? { url: options.url } : {},
4417
+ ...options?.name ? { name: options.name } : {},
4418
+ updatedAt: Date.now()
4419
+ });
4420
+ return { sourceId, subscribed: true, notebookIds };
4421
+ }
4422
+ async function unsubscribeFeedSourceHeadless(storage, sourceId) {
4423
+ if (sourceId === "core") {
4424
+ throw new Error("Core feed cannot be unsubscribed.");
4425
+ }
4426
+ const meta = await storage.readonly("meta").get(seedMetaKey(sourceId));
4427
+ const deletedNotes = meta ? await removeSeedSourceContent(storage, meta) : 0;
4428
+ await writeFeedSubscriptionEntry(storage, sourceId, {
4429
+ subscribed: false,
4430
+ hidden: false,
4431
+ updatedAt: Date.now()
4432
+ });
4433
+ return { sourceId, unsubscribed: true, deletedNotes };
4434
+ }
4435
+ async function deleteFeedSourceHeadless(storage, sourceId) {
4436
+ if (sourceId === "core") {
4437
+ throw new Error("Core feed cannot be deleted.");
4438
+ }
4439
+ const meta = await storage.readonly("meta").get(seedMetaKey(sourceId));
4440
+ const deletedNotes = meta ? await removeSeedSourceContent(storage, meta) : 0;
4441
+ await writeFeedSubscriptionEntry(storage, sourceId, {
4442
+ subscribed: false,
4443
+ hidden: true,
4444
+ updatedAt: Date.now()
4445
+ });
4446
+ return { sourceId, deleted: true, deletedNotes };
4447
+ }
4239
4448
  function mintUuid() {
4240
4449
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
4241
4450
  return crypto.randomUUID();
@@ -4534,7 +4743,198 @@ function buildNoteProvenance(sourceNote, sourceNotebookId, clonedAt) {
4534
4743
  clonedAt
4535
4744
  };
4536
4745
  }
4746
+ function buildQueryServiceStoresFromStorage(storage, options = {}) {
4747
+ const asRange = (lower, upper) => typeof IDBKeyRange !== "undefined" ? IDBKeyRange.bound(lower, upper) : { lower, upper };
4748
+ const resultRows = (key) => asRange([key, ""], [`${key}\uFFFF`, "\uFFFF"]);
4749
+ const rawEventStore = {
4750
+ getEventsByTimeRange: async (start, end) => storage.readonly("events").getAllFromIndex("by-timestamp", asRange(start, end)),
4751
+ getEventsByMetricDates: async (dates) => {
4752
+ const store = storage.readonly("events");
4753
+ const byId = /* @__PURE__ */ new Map();
4754
+ for (const date of dates) {
4755
+ for (const row of await store.getAllFromIndex("by-metric-date", date)) {
4756
+ byId.set(row.id, row);
4757
+ }
4758
+ }
4759
+ return Array.from(byId.values());
4760
+ },
4761
+ getEventsByResult: async (resultId) => storage.readonly("events").getAllFromIndex("by-result-grain", resultRows(resultId)),
4762
+ getEventsForNote: async (noteId) => (await storage.readonly("events").getAll()).filter((row) => row.noteId === noteId),
4763
+ getEventsByContent: async (cid) => storage.readonly("events").getAllFromIndex("by-content-grain", resultRows(cid)),
4764
+ scanAll: () => storage.readonly("events").getAll(),
4765
+ appendEvents: async (rows) => {
4766
+ if (rows.length > 0) await storage.readwrite("events").putMany(rows);
4767
+ },
4768
+ finalizeSummaries: async (resultId, rows) => {
4769
+ await storage.transaction(["events"], "readwrite", async (tx) => {
4770
+ const allForResult = (await tx.readonly("events").getAll()).filter(
4771
+ (r) => r.resultId === resultId && r.grain === "summary" && r.origin !== "user"
4772
+ );
4773
+ for (const r of allForResult) await tx.readwrite("events").delete(r.id);
4774
+ if (rows.length > 0) await tx.readwrite("events").putMany(rows);
4775
+ });
4776
+ },
4777
+ deleteEvents: async (ids) => {
4778
+ for (const id of ids) await storage.readwrite("events").delete(id);
4779
+ }
4780
+ };
4781
+ const eventStore = options.coalesce !== false ? coalescingEventStore(rawEventStore) : rawEventStore;
4782
+ const noteStore = {
4783
+ getAllNotes: () => storage.readonly("notes").getAll(),
4784
+ getNotesByIds: async (ids) => {
4785
+ const rows = await storage.readonly("notes").getMany([...ids]);
4786
+ return rows.filter((row) => row !== void 0);
4787
+ },
4788
+ getNoteIdsForTag: async (label) => {
4789
+ const ids = /* @__PURE__ */ new Set();
4790
+ for (const tag of await storage.readonly("tags").getAllFromIndex("by-label", label)) {
4791
+ for (const link of await storage.readonly("note_tags").getAllFromIndex("by-tag", tag.id)) {
4792
+ ids.add(link.noteId);
4793
+ }
4794
+ }
4795
+ return ids;
4796
+ },
4797
+ getNoteTagLabels: async (noteId) => {
4798
+ const links = await storage.readonly("note_tags").getAllFromIndex("by-note", noteId);
4799
+ const tags = await storage.readonly("tags").getMany(links.map((l) => l.tagId));
4800
+ return tags.flatMap((t) => t ? [t.label] : []);
4801
+ },
4802
+ queryDomain: async (request) => {
4803
+ if (!storage.queryDomain) return void 0;
4804
+ const result = await storage.queryDomain({ ...request, plan: "notes" });
4805
+ return result && result.plan === "notes" ? result : void 0;
4806
+ }
4807
+ };
4808
+ const blockStore = {
4809
+ getAllBlocks: () => storage.readonly("block_index").getAll(),
4810
+ queryDomain: async (request) => {
4811
+ if (!storage.queryDomain) return void 0;
4812
+ const result = await storage.queryDomain({ ...request, plan: "blocks" });
4813
+ return result && result.plan === "blocks" ? result : void 0;
4814
+ }
4815
+ };
4816
+ const effortStore = options.effortStore ?? {
4817
+ getAllEfforts: async () => {
4818
+ const stored = await storage.readonly("efforts").getAll();
4819
+ const bySlug = /* @__PURE__ */ new Map();
4820
+ for (const eff of bundledEfforts) bySlug.set(eff.slug, eff);
4821
+ for (const eff of stored) bySlug.set(eff.slug, eff);
4822
+ return [...bySlug.values()];
4823
+ }
4824
+ };
4825
+ const feedCatalogStore = options.feedCatalogStore ?? {
4826
+ getAllFeeds: async () => {
4827
+ const rows = [];
4828
+ for (const row of await storage.readonly("meta").getAll()) {
4829
+ const key = row.key;
4830
+ if (typeof key !== "string" || !key.startsWith("seed:") || key === seedMetaKey("user")) continue;
4831
+ const id = key.slice("seed:".length);
4832
+ rows.push({
4833
+ id,
4834
+ label: id,
4835
+ url: `https://${id}.example/feed/`,
4836
+ tier: "imported",
4837
+ subscribed: true,
4838
+ installed: true,
4839
+ notebookCount: 0,
4840
+ itemCount: 0
4841
+ });
4842
+ }
4843
+ return rows;
4844
+ },
4845
+ getAllNotebooks: async () => {
4846
+ const links = await storage.readonly("notebook_links").getAll().catch(() => []);
4847
+ const notes = await storage.readonly("notes").getAll();
4848
+ const memberCount = /* @__PURE__ */ new Map();
4849
+ for (const link of links) {
4850
+ if (link.targetKind === "note") {
4851
+ memberCount.set(link.notebookId, (memberCount.get(link.notebookId) ?? 0) + 1);
4852
+ }
4853
+ }
4854
+ const rows = [];
4855
+ for (const [notebookId, count] of memberCount) {
4856
+ const slug = notebookId.startsWith("notebook/") ? notebookId.slice("notebook/".length) : notebookId;
4857
+ const landing = notes.find((n) => n.id === notebookId);
4858
+ const feedSourceId = landing?.feedSourceId;
4859
+ const chunkId = `notebook.${slug}`;
4860
+ const feedId = feedSourceId ?? "local";
4861
+ let subscribed = feedSourceId !== void 0;
4862
+ if (options.isNotebookSubscribed) {
4863
+ const res = options.isNotebookSubscribed(feedId, chunkId);
4864
+ subscribed = typeof res === "boolean" ? res : Boolean(await res);
4865
+ }
4866
+ rows.push({
4867
+ id: notebookId,
4868
+ feedId,
4869
+ feedLabel: feedSourceId ?? "Yours (Local)",
4870
+ chunkId,
4871
+ slug,
4872
+ label: landing?.title ?? slug,
4873
+ count,
4874
+ subscribed,
4875
+ installed: true,
4876
+ origin: feedSourceId ? "feed" : "user",
4877
+ ...landing?.public !== void 0 ? { public: landing.public } : {}
4878
+ });
4879
+ }
4880
+ return rows;
4881
+ }
4882
+ };
4883
+ const stores = {
4884
+ eventStore,
4885
+ noteStore,
4886
+ blockStore,
4887
+ effortStore,
4888
+ blockEffortsStore: {
4889
+ getAllFromIndex: (index, key) => storage.readonly("block_efforts").getAllFromIndex(index, key)
4890
+ },
4891
+ blockEquipmentStore: {
4892
+ getAllFromIndex: (index, key) => storage.readonly("block_equipment").getAllFromIndex(index, key)
4893
+ },
4894
+ tagsStore: {
4895
+ getAllFromIndex: (index, key) => storage.readonly("tags").getAllFromIndex(index, key),
4896
+ getAll: () => storage.readonly("tags").getAll()
4897
+ },
4898
+ noteTagsStore: {
4899
+ getAllFromIndex: (index, key) => storage.readonly("note_tags").getAllFromIndex(index, key)
4900
+ },
4901
+ pageStore: {
4902
+ getNotePages: (noteId) => storage.readonly("page_notes").getAllFromIndex("by-note", noteId),
4903
+ getPage: (pageId) => storage.readonly("page").get(pageId),
4904
+ getAllPages: () => storage.readonly("page").getAll(),
4905
+ getAllLinks: () => storage.readonly("page_notes").getAll()
4906
+ },
4907
+ relationStore: {
4908
+ getBatches: async (noteIds) => {
4909
+ const bundles = /* @__PURE__ */ new Map();
4910
+ for (const noteId of noteIds) {
4911
+ const links = await storage.readonly("page_notes").getAllFromIndex("by-note", noteId);
4912
+ const tagLinks = await storage.readonly("note_tags").getAllFromIndex("by-note", noteId);
4913
+ const tags = await storage.readonly("tags").getMany(tagLinks.map((l) => l.tagId));
4914
+ const pages = await storage.readonly("page").getMany([...new Set(links.map((l) => l.pageId))]);
4915
+ bundles.set(noteId, {
4916
+ tags: tags.flatMap((t) => t ? [{ label: t.label, ...t.type ? { type: t.type } : {} }] : []),
4917
+ links,
4918
+ pages: pages.filter((p) => p !== void 0)
4919
+ });
4920
+ }
4921
+ return bundles;
4922
+ }
4923
+ },
4924
+ feedCatalogStore
4925
+ };
4926
+ if (options.datasetStore) {
4927
+ stores.datasetStore = options.datasetStore;
4928
+ }
4929
+ if (options.isNotebookSubscribed) {
4930
+ stores.isNotebookSubscribed = (feedId, chunkId) => {
4931
+ const res = options.isNotebookSubscribed(feedId, chunkId);
4932
+ return typeof res === "boolean" ? res : true;
4933
+ };
4934
+ }
4935
+ return stores;
4936
+ }
4537
4937
 
4538
- export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FeedTreeError, GIT_SHA, HttpFeedTree, MemoryFeedTree, NOTE_ID_FRONTMATTER_KEY, PUBLISHED_FEED_META_KEY, QR_SCRIPT_ID, SEED_BROADCAST_CHANNEL, SEED_NAMESPACE, SEED_REGISTERED_WIDGETS, SEED_SCHEMA, SEMVER, SESSION_CSV_HEADER, TELEMETRY_CSV_HEADER, VERSION, applySeedChunk, applySeedChunks, assertNotebookIndex, assertSeedManifest, assertSeedRow, assertSeedRows, backfillFeedProvenance, buildNoteProvenance, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, effortToMarkdown, emptySeedMeta, encodeUtf8, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, getNoteNotebooks, getNotePublicationSummary, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listScopedPropertyOverrides, makeNotebookLinkId, makeScopedOverrideId, migrateNotebookVocabulary, normalizeFeedTreePath, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFrontmatterMeta, removeNoteFromNotebook, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveUpstreamProvenance, saveScopedPropertyOverride, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, splitCsvRecords, statementToNode, telemetryBundleToCsv };
4539
- //# sourceMappingURL=chunk-KQYTRLW3.mjs.map
4540
- //# sourceMappingURL=chunk-KQYTRLW3.mjs.map
4938
+ export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FEED_SUBSCRIPTIONS_META_KEY, FeedTreeError, GIT_SHA, HttpFeedTree, MemoryFeedTree, NOTE_ID_FRONTMATTER_KEY, PUBLISHED_FEED_META_KEY, QR_SCRIPT_ID, SEED_BROADCAST_CHANNEL, SEED_NAMESPACE, SEED_REGISTERED_WIDGETS, SEED_SCHEMA, SEMVER, SESSION_CSV_HEADER, TELEMETRY_CSV_HEADER, VERSION, applySeedChunk, applySeedChunks, assertNotebookIndex, assertSeedManifest, assertSeedRow, assertSeedRows, backfillFeedProvenance, buildNoteProvenance, buildQueryServiceStoresFromStorage, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, deleteFeedSourceHeadless, effortToMarkdown, emptySeedMeta, encodeUtf8, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, getNoteNotebooks, getNotePublicationSummary, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listFeedSubscriptionsHeadless, listScopedPropertyOverrides, makeNotebookLinkId, makeScopedOverrideId, migrateNotebookVocabulary, normalizeFeedTreePath, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFrontmatterMeta, recordPublishedFeedCheckpoint, removeNoteFromNotebook, removeSeedSourceContent, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveUpstreamProvenance, saveScopedPropertyOverride, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, splitCsvRecords, statementToNode, subscribeFeedSourceHeadless, telemetryBundleToCsv, unsubscribeFeedSourceHeadless };
4939
+ //# sourceMappingURL=chunk-F6DE535O.mjs.map
4940
+ //# sourceMappingURL=chunk-F6DE535O.mjs.map