@bitcobblers/wod-wiki-engine 0.63.2270 → 0.63.2272

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/agent.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { buildQueryServiceStoresFromStorage, extractNoteIdentity, extractTypedTags, noteHasRecordedSessionsInTx, snapshotNoteRevisionIfHasSessionsInTx, makeNotebookLinkId, resolveScopedPropertyCatalog, effortToMarkdown, equipmentToMarkdown, saveScopedPropertyOverride, listFeedSubscriptionsHeadless, seedMetaKey, subscribeFeedSourceHeadless, unsubscribeFeedSourceHeadless, deleteFeedSourceHeadless, checkUnpublishedFeedChanges, MemoryFeedTree, publishFeedFromStorage, ingestPortableFilesIntoStorage, exportPortableFilesFromStorage, getJournalDayOverlay, readFrontmatterMeta, createUserNotebookLanding, setNotebookPublic, promoteNoteToNotebooks, removeNoteFromNotebook, deleteUserNotebook, getNoteNotebooks, resolveUpstreamProvenance, getNotePublicationSummary, listScheduleItemsForNote, listNoteRevisions, composeNoteMarkdown, buildNoteProvenance, listScheduleItemsByDateRange, scheduleNoteOnDate, batchScheduleNotes, updateScheduleItem, removeScheduleItem, buildStatementTree, prepareJournalSessionRun, localCivilDateKey, setSessionPublic, attributeSession } from './chunk-AK57GBML.mjs';
1
+ import { buildQueryServiceStoresFromStorage, extractNoteIdentity, extractTypedTags, noteHasRecordedSessionsInTx, snapshotNoteRevisionIfHasSessionsInTx, makeNotebookLinkId, resolveScopedPropertyCatalog, effortToMarkdown, equipmentToMarkdown, saveScopedPropertyOverride, listFeedSubscriptionsHeadless, seedMetaKey, subscribeFeedSourceHeadless, unsubscribeFeedSourceHeadless, deleteFeedSourceHeadless, checkUnpublishedFeedChanges, MemoryFeedTree, publishFeedFromStorage, ingestPortableFilesIntoStorage, exportPortableFilesFromStorage, getJournalDayOverlay, readFrontmatterMeta, createUserNotebookLanding, setNotebookPublic, promoteNoteToNotebooks, removeNoteFromNotebook, deleteUserNotebook, getNoteNotebooks, resolveUpstreamProvenance, getNotePublicationSummary, listScheduleItemsForNote, listNoteRevisions, composeNoteMarkdown, buildNoteProvenance, listScheduleItemsByDateRange, scheduleNoteOnDate, batchScheduleNotes, updateScheduleItem, removeScheduleItem, buildStatementTree, prepareJournalSessionRun, localCivilDateKey, setSessionPublic, attributeSession } from './chunk-EYKTDOVO.mjs';
2
2
  import { BUILTIN_NOTEBOOKS, parseDocumentSections, KNOWN_SECTION_WIDGETS, isNoteEditable, reconcileNoteBlocks, validateNoteBlocks, toNotebookId, blockContentId, MetricType, orderPlacements, countNotesByNotebook, isSystemReadOnlyNotebook, isNotebookLanding, notebookSlugFromId, isNonPublishableNotebook } from '@bitcobblers/wod-wiki-core';
3
3
  import { bundledEfforts, createReferenceIndex, parseScript, extractStatementRefs, createParser, findUnresolvedChoices, createMockClock, RuntimeStack, EventBus, frozenNow, ScriptRuntime, createCompiler, createAnalyticsEngineForBlock, StartSessionAction, NextEvent, toStoredOutputStatement } from '@bitcobblers/wod-wiki-lang';
4
4
  import { rowsEqual, userDeletedSeedKey } from '@bitcobblers/wod-wiki-storage';
@@ -858,13 +858,13 @@ function csvToTelemetryBundle(csv) {
858
858
  }
859
859
 
860
860
  // src/version.ts
861
- var VERSION = "0.63.2270";
862
- var GIT_SHA = "933be8b";
863
- var BUILD_TIME = "2026-11-25T23:07:35.393Z";
861
+ var VERSION = "0.63.2272";
862
+ var GIT_SHA = "b843712";
863
+ var BUILD_TIME = "2026-11-27T14:16:52.436Z";
864
864
  var SEMVER = {
865
- version: "0.63.2270",
866
- gitSha: "933be8b",
867
- buildTime: "2026-11-25T23:07:35.393Z"
865
+ version: "0.63.2272",
866
+ gitSha: "b843712",
867
+ buildTime: "2026-11-27T14:16:52.436Z"
868
868
  };
869
869
  var SEED_SCHEMA = 9;
870
870
  var SEED_REGISTERED_WIDGETS = KNOWN_SECTION_WIDGETS;
@@ -1872,6 +1872,8 @@ async function applyPreparedSeedChunkInTx(tx, prepared) {
1872
1872
  const seedCommit = row.commit ?? write.manifest.commit;
1873
1873
  const existingRetention = existing;
1874
1874
  const resolvedPin = pinnedNoteIds.has(id) || existingRetention?.retention === "session-pinned" ? "session-pinned" : existingRetention?.retention === "schedule-pinned" ? "schedule-pinned" : void 0;
1875
+ const parsedBuiltAt = typeof write.manifest.builtAt === "string" ? Date.parse(write.manifest.builtAt) : Number.NaN;
1876
+ const seedCreatedAt = write.manifest.version === 0 ? 0 : Number.isFinite(parsedBuiltAt) && parsedBuiltAt >= 9466848e5 ? parsedBuiltAt : Number.isFinite(write.meta.importedAt) && write.meta.importedAt >= 9466848e5 ? write.meta.importedAt : Date.now();
1875
1877
  const note = {
1876
1878
  ...existing,
1877
1879
  id,
@@ -1879,7 +1881,7 @@ async function applyPreparedSeedChunkInTx(tx, prepared) {
1879
1881
  rawContent: row.content,
1880
1882
  sourceRevision,
1881
1883
  blocks: map,
1882
- createdAt: write.manifest.version,
1884
+ createdAt: seedCreatedAt,
1883
1885
  ...date === void 0 ? {} : { date },
1884
1886
  type: write.chunkId === DASHBOARDS_CHUNK_ID ? "dashboard" : "note",
1885
1887
  sourceId,
@@ -1978,8 +1980,8 @@ async function applyPreparedSeedChunkInTx(tx, prepared) {
1978
1980
  const slug = fm["slug"];
1979
1981
  if (typeof slug === "string" && pagesBySlug.has(slug)) {
1980
1982
  const pageId = pagesBySlug.get(slug);
1981
- pages.push({ id: pageId, slug, title: titleFromPath(row.path), createdAt: write.manifest.version });
1982
- pageNotes.push({ id: linkIds.get(id), pageId, noteId: id, createdAt: write.manifest.version });
1983
+ pages.push({ id: pageId, slug, title: titleFromPath(row.path), createdAt: seedCreatedAt });
1984
+ pageNotes.push({ id: linkIds.get(id), pageId, noteId: id, createdAt: seedCreatedAt });
1983
1985
  }
1984
1986
  result.totalNotes++;
1985
1987
  result.totalBlocks += Object.keys(map).length;
@@ -2173,12 +2175,33 @@ function buildQueryServiceStoresFromStorage(storage, options = {}) {
2173
2175
  const rawEventStore = {
2174
2176
  getEventsByTimeRange: async (start, end) => storage.readonly("events").getAllFromIndex("by-timestamp", asRange(start, end)),
2175
2177
  getEventsByMetricDates: async (dates) => {
2178
+ if (dates.length === 0) return [];
2176
2179
  const store = storage.readonly("events");
2177
2180
  const byId = /* @__PURE__ */ new Map();
2178
- for (const date of dates) {
2179
- for (const row of await store.getAllFromIndex("by-metric-date", date)) {
2181
+ if (dates.length === 1) {
2182
+ for (const row of await store.getAllFromIndex("by-metric-date", dates[0])) {
2180
2183
  byId.set(row.id, row);
2181
2184
  }
2185
+ return Array.from(byId.values());
2186
+ }
2187
+ let minDate = dates[0];
2188
+ let maxDate = dates[0];
2189
+ const wanted = /* @__PURE__ */ new Set();
2190
+ for (const date of dates) {
2191
+ wanted.add(date);
2192
+ if (date < minDate) minDate = date;
2193
+ if (date > maxDate) maxDate = date;
2194
+ }
2195
+ const rows = await store.getAllFromIndex(
2196
+ "by-metric-date",
2197
+ asRange(minDate, maxDate)
2198
+ );
2199
+ for (const row of rows) {
2200
+ if (byId.has(row.id)) continue;
2201
+ if (Array.isArray(row.metricDateKeys) && row.metricDateKeys.length > 0) {
2202
+ if (!row.metricDateKeys.some((k) => wanted.has(k))) continue;
2203
+ }
2204
+ byId.set(row.id, row);
2182
2205
  }
2183
2206
  return Array.from(byId.values());
2184
2207
  },
@@ -2333,6 +2356,40 @@ function buildQueryServiceStoresFromStorage(storage, options = {}) {
2333
2356
  const bundles = /* @__PURE__ */ new Map();
2334
2357
  const uniqueIds = [...new Set(noteIds)];
2335
2358
  if (uniqueIds.length === 0) return bundles;
2359
+ if (storage.queryDomain) {
2360
+ const CHUNK_SIZE = 100;
2361
+ let usedDomain = true;
2362
+ let matchedRows = 0;
2363
+ for (let offset = 0; offset < uniqueIds.length; offset += CHUNK_SIZE) {
2364
+ const chunk = uniqueIds.slice(offset, offset + CHUNK_SIZE);
2365
+ const result = await storage.queryDomain({
2366
+ plan: "detail",
2367
+ selection: [{ field: "id", values: chunk }]
2368
+ });
2369
+ if (!result || result.plan !== "detail") {
2370
+ usedDomain = false;
2371
+ bundles.clear();
2372
+ break;
2373
+ }
2374
+ matchedRows += result.rows.length;
2375
+ for (const row of result.rows) {
2376
+ bundles.set(row.note.id, {
2377
+ tags: row.tags.map((t) => ({ label: t.label, ...t.type ? { type: t.type } : {} })),
2378
+ links: [...row.links],
2379
+ pages: [...row.pages]
2380
+ });
2381
+ }
2382
+ }
2383
+ if (usedDomain && matchedRows > 0) {
2384
+ for (const id of uniqueIds) {
2385
+ if (!bundles.has(id)) {
2386
+ bundles.set(id, { tags: [], links: [], pages: [] });
2387
+ }
2388
+ }
2389
+ return bundles;
2390
+ }
2391
+ bundles.clear();
2392
+ }
2336
2393
  return storage.transaction(["page_notes", "note_tags", "tags", "page"], "readonly", async (tx) => {
2337
2394
  const [pageLinkGroups, tagLinkGroups] = await Promise.all([
2338
2395
  tx.readonly("page_notes").getAllFromIndexMany("by-note", uniqueIds),
@@ -5465,20 +5522,27 @@ async function deleteUserNotebook(storage, notebookIdOrSlug) {
5465
5522
  );
5466
5523
  let touchedMembers = 0;
5467
5524
  const noteWriter = tx.readwrite("notes");
5525
+ const legacyColonTag = `notebook:${slug}`;
5526
+ const legacySlashTag = `notebook/${slug}`;
5468
5527
  for (const note of allNotes) {
5469
5528
  if (isNotebookLanding(note)) continue;
5470
5529
  const hasSingle = note.notebookId === nbId;
5471
5530
  const hasMulti = (note.notebookIds ?? []).includes(nbId);
5472
5531
  const hasLink = linkedNoteIds.has(note.id);
5473
- if (!hasSingle && !hasMulti && !hasLink) continue;
5532
+ const hasLegacyTag = (note.tags ?? []).some(
5533
+ (t) => t === legacyColonTag || t === legacySlashTag
5534
+ );
5535
+ if (!hasSingle && !hasMulti && !hasLink && !hasLegacyTag) continue;
5474
5536
  const baseIds = note.notebookIds !== void 0 ? note.notebookIds : note.notebookId ? [note.notebookId] : [];
5475
5537
  const remaining = baseIds.map((id) => toNotebookId$1(id)).filter((id) => id !== nbId);
5476
5538
  const primaryUser = remaining.find(
5477
5539
  (id) => id !== "notebook/journal" && id !== "notebook/playground"
5478
5540
  );
5541
+ const nextTags = hasLegacyTag ? (note.tags ?? []).filter((t) => t !== legacyColonTag && t !== legacySlashTag) : note.tags;
5479
5542
  const { notebookId: _droppedSingle, notebookIds: _droppedMulti, ...rest } = note;
5480
5543
  await noteWriter.put({
5481
5544
  ...rest,
5545
+ ...nextTags !== void 0 ? { tags: nextTags } : {},
5482
5546
  notebookIds: remaining,
5483
5547
  ...primaryUser ? { notebookId: primaryUser } : {}
5484
5548
  });
@@ -6732,6 +6796,20 @@ async function getJournalDayOverlay(storage, rawDate) {
6732
6796
  };
6733
6797
  }
6734
6798
  async function migrateDatedPageNotesToSchedule(storage) {
6799
+ const hasDatedPageNotes = await storage.transaction(["page", "page_notes"], "readonly", async (tx) => {
6800
+ const [pages, pageNotes] = await Promise.all([
6801
+ tx.readonly("page").getAll(),
6802
+ tx.readonly("page_notes").getAll()
6803
+ ]);
6804
+ if (pageNotes.length === 0) return false;
6805
+ const datedPageIds = /* @__PURE__ */ new Set();
6806
+ for (const p of pages) {
6807
+ if (p.date) datedPageIds.add(p.id);
6808
+ }
6809
+ if (datedPageIds.size === 0) return false;
6810
+ return pageNotes.some((pn) => datedPageIds.has(pn.pageId));
6811
+ });
6812
+ if (!hasDatedPageNotes) return 0;
6735
6813
  return storage.transaction(["page", "page_notes", "schedule_items", "notes"], "readwrite", async (tx) => {
6736
6814
  const [pages, pageNotes, existingSchedules, notes] = await Promise.all([
6737
6815
  tx.readonly("page").getAll(),
@@ -6780,5 +6858,5 @@ async function migrateDatedPageNotesToSchedule(storage) {
6780
6858
  }
6781
6859
 
6782
6860
  export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FEED_INDEX_META_PREFIX, FEED_REGISTRY_META_KEY, 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, attributeSession, backfillFeedProvenance, batchScheduleNotes, buildContextualPageSource, buildNoteProvenance, buildQueryServiceStoresFromStorage, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, compileSeedRowFromMarkdown, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, deleteFeedSourceHeadless, deleteUserNotebook, effortToMarkdown, emptySeedMeta, encodeUtf8, ensurePinnedExternalWorkout, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, feedIndexMetaKey, findNearbyMatchingScheduleItems, forkNoteToUserNotebook, getJournalDayOverlay, getNoteNotebooks, getNotePublicationSummary, getNoteRevision, getScheduleAndSessionCountsByNote, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listFeedSubscriptionsHeadless, listNoteRevisions, listScheduleItemsByDateRange, listScheduleItemsForNote, listScopedPropertyOverrides, localCivilDateKey, logSessionAgainstExternalWorkout, makeNotebookLinkId, makeScopedOverrideId, materializeCachedRemoteRecord, migrateDatedPageNotesToSchedule, migrateNotebookVocabulary, normalizeCivilDate, normalizeFeedTreePath, noteHasRecordedSessionsInTx, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, parseRemoteNoteId, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFeedRegistryHeadless, readFrontmatterMeta, reconcileRemovedFeedRecords, recordPublishedFeedCheckpoint, removeFeedNotebookContent, removeFeedSourceContentById, removeNoteFromNotebook, removeScheduleItem, removeSeedSourceContent, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveSessionCivilDate, resolveUpstreamProvenance, saveScopedPropertyOverride, scheduleNoteOnDate, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, snapshotNoteRevisionIfHasSessionsInTx, splitCsvRecords, statementToNode, subscribeFeedSourceHeadless, telemetryBundleToCsv, unsubscribeFeedSourceHeadless, updateScheduleItem, writeFeedRegistryHeadless };
6783
- //# sourceMappingURL=chunk-AK57GBML.mjs.map
6784
- //# sourceMappingURL=chunk-AK57GBML.mjs.map
6861
+ //# sourceMappingURL=chunk-EYKTDOVO.mjs.map
6862
+ //# sourceMappingURL=chunk-EYKTDOVO.mjs.map