@bitcobblers/wod-wiki-engine 0.59.2238 → 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.
- package/dist/agent.cjs +144 -113
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.mjs +1 -163
- package/dist/agent.mjs.map +1 -1
- package/dist/{chunk-YUFWRUL6.mjs → chunk-F6DE535O.mjs} +202 -11
- package/dist/chunk-F6DE535O.mjs.map +1 -0
- package/dist/index.cjs +716 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -13
- package/dist/index.d.ts +93 -13
- package/dist/index.mjs +514 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-YUFWRUL6.mjs.map +0 -1
package/dist/agent.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractNoteIdentity, extractTypedTags, makeNotebookLinkId, resolveScopedPropertyCatalog, effortToMarkdown, equipmentToMarkdown, saveScopedPropertyOverride, listFeedSubscriptionsHeadless, seedMetaKey, subscribeFeedSourceHeadless, unsubscribeFeedSourceHeadless, deleteFeedSourceHeadless, checkUnpublishedFeedChanges, MemoryFeedTree, publishFeedFromStorage, ingestPortableFilesIntoStorage, exportPortableFilesFromStorage, readFrontmatterMeta, createUserNotebookLanding, setNotebookPublic, promoteNoteToNotebooks, removeNoteFromNotebook, getNoteNotebooks, resolveUpstreamProvenance, getNotePublicationSummary, composeNoteMarkdown, buildNoteProvenance, buildStatementTree, prepareJournalSessionRun, setSessionPublic } from './chunk-
|
|
1
|
+
import { buildQueryServiceStoresFromStorage, extractNoteIdentity, extractTypedTags, makeNotebookLinkId, resolveScopedPropertyCatalog, effortToMarkdown, equipmentToMarkdown, saveScopedPropertyOverride, listFeedSubscriptionsHeadless, seedMetaKey, subscribeFeedSourceHeadless, unsubscribeFeedSourceHeadless, deleteFeedSourceHeadless, checkUnpublishedFeedChanges, MemoryFeedTree, publishFeedFromStorage, ingestPortableFilesIntoStorage, exportPortableFilesFromStorage, readFrontmatterMeta, createUserNotebookLanding, setNotebookPublic, promoteNoteToNotebooks, removeNoteFromNotebook, getNoteNotebooks, resolveUpstreamProvenance, getNotePublicationSummary, composeNoteMarkdown, buildNoteProvenance, buildStatementTree, prepareJournalSessionRun, setSessionPublic } from './chunk-F6DE535O.mjs';
|
|
2
2
|
import { BUILTIN_NOTEBOOKS, parseDocumentSections, KNOWN_SECTION_WIDGETS, isNoteEditable, reconcileNoteBlocks, validateNoteBlocks, toNotebookId, blockContentId, MetricType, orderPlacements, isSystemReadOnlyNotebook, 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';
|
|
@@ -95,168 +95,6 @@ function civilDateKey(input, nowMs = Date.now()) {
|
|
|
95
95
|
}
|
|
96
96
|
return trimmed;
|
|
97
97
|
}
|
|
98
|
-
function buildQueryServiceStoresFromStorage(storage) {
|
|
99
|
-
const asRange = (lower, upper) => typeof IDBKeyRange !== "undefined" ? IDBKeyRange.bound(lower, upper) : { lower, upper };
|
|
100
|
-
const resultRows = (key) => asRange([key, ""], [`${key}\uFFFF`, "\uFFFF"]);
|
|
101
|
-
const eventStore = {
|
|
102
|
-
getEventsByTimeRange: async (start, end) => storage.readonly("events").getAllFromIndex("by-timestamp", asRange(start, end)),
|
|
103
|
-
getEventsByResult: async (resultId) => storage.readonly("events").getAllFromIndex("by-result-grain", resultRows(resultId)),
|
|
104
|
-
getEventsForNote: async (noteId) => (await storage.readonly("events").getAll()).filter((row) => row.noteId === noteId),
|
|
105
|
-
getEventsByContent: async (cid) => storage.readonly("events").getAllFromIndex("by-content-grain", resultRows(cid)),
|
|
106
|
-
scanAll: () => storage.readonly("events").getAll(),
|
|
107
|
-
appendEvents: async (rows) => {
|
|
108
|
-
if (rows.length > 0) await storage.readwrite("events").putMany(rows);
|
|
109
|
-
},
|
|
110
|
-
finalizeSummaries: async (resultId, rows) => {
|
|
111
|
-
await storage.transaction(["events"], "readwrite", async (tx) => {
|
|
112
|
-
const allForResult = (await tx.readonly("events").getAll()).filter(
|
|
113
|
-
(r) => r.resultId === resultId && r.grain === "summary" && r.origin !== "user"
|
|
114
|
-
);
|
|
115
|
-
for (const r of allForResult) await tx.readwrite("events").delete(r.id);
|
|
116
|
-
if (rows.length > 0) await tx.readwrite("events").putMany(rows);
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
deleteEvents: async (ids) => {
|
|
120
|
-
for (const id of ids) await storage.readwrite("events").delete(id);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const noteStore = {
|
|
124
|
-
getAllNotes: () => storage.readonly("notes").getAll(),
|
|
125
|
-
getNotesByIds: async (ids) => {
|
|
126
|
-
const rows = await storage.readonly("notes").getMany([...ids]);
|
|
127
|
-
return rows.filter((row) => row !== void 0);
|
|
128
|
-
},
|
|
129
|
-
getNoteIdsForTag: async (label) => {
|
|
130
|
-
const ids = /* @__PURE__ */ new Set();
|
|
131
|
-
for (const tag of await storage.readonly("tags").getAllFromIndex("by-label", label)) {
|
|
132
|
-
for (const link of await storage.readonly("note_tags").getAllFromIndex("by-tag", tag.id)) {
|
|
133
|
-
ids.add(link.noteId);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return ids;
|
|
137
|
-
},
|
|
138
|
-
getNoteTagLabels: async (noteId) => {
|
|
139
|
-
const links = await storage.readonly("note_tags").getAllFromIndex("by-note", noteId);
|
|
140
|
-
const tags = await storage.readonly("tags").getMany(links.map((l) => l.tagId));
|
|
141
|
-
return tags.flatMap((t) => t ? [t.label] : []);
|
|
142
|
-
},
|
|
143
|
-
queryDomain: async (request) => {
|
|
144
|
-
if (!storage.queryDomain) return void 0;
|
|
145
|
-
const result = await storage.queryDomain({ ...request, plan: "notes" });
|
|
146
|
-
return result && result.plan === "notes" ? result : void 0;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const blockStore = {
|
|
150
|
-
getAllBlocks: () => storage.readonly("block_index").getAll(),
|
|
151
|
-
queryDomain: async (request) => {
|
|
152
|
-
if (!storage.queryDomain) return void 0;
|
|
153
|
-
const result = await storage.queryDomain({ ...request, plan: "blocks" });
|
|
154
|
-
return result && result.plan === "blocks" ? result : void 0;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const effortStore = {
|
|
158
|
-
getAllEfforts: async () => {
|
|
159
|
-
const stored = await storage.readonly("efforts").getAll();
|
|
160
|
-
const bySlug = /* @__PURE__ */ new Map();
|
|
161
|
-
for (const eff of bundledEfforts) bySlug.set(eff.slug, eff);
|
|
162
|
-
for (const eff of stored) bySlug.set(eff.slug, eff);
|
|
163
|
-
return [...bySlug.values()];
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
return {
|
|
167
|
-
eventStore,
|
|
168
|
-
noteStore,
|
|
169
|
-
blockStore,
|
|
170
|
-
effortStore,
|
|
171
|
-
blockEffortsStore: {
|
|
172
|
-
getAllFromIndex: (index, key) => storage.readonly("block_efforts").getAllFromIndex(index, key)
|
|
173
|
-
},
|
|
174
|
-
blockEquipmentStore: {
|
|
175
|
-
getAllFromIndex: (index, key) => storage.readonly("block_equipment").getAllFromIndex(index, key)
|
|
176
|
-
},
|
|
177
|
-
tagsStore: {
|
|
178
|
-
getAllFromIndex: (index, key) => storage.readonly("tags").getAllFromIndex(index, key),
|
|
179
|
-
getAll: () => storage.readonly("tags").getAll()
|
|
180
|
-
},
|
|
181
|
-
noteTagsStore: {
|
|
182
|
-
getAllFromIndex: (index, key) => storage.readonly("note_tags").getAllFromIndex(index, key)
|
|
183
|
-
},
|
|
184
|
-
pageStore: {
|
|
185
|
-
getNotePages: (noteId) => storage.readonly("page_notes").getAllFromIndex("by-note", noteId),
|
|
186
|
-
getPage: (pageId) => storage.readonly("page").get(pageId),
|
|
187
|
-
getAllPages: () => storage.readonly("page").getAll(),
|
|
188
|
-
getAllLinks: () => storage.readonly("page_notes").getAll()
|
|
189
|
-
},
|
|
190
|
-
relationStore: {
|
|
191
|
-
getBatches: async (noteIds) => {
|
|
192
|
-
const bundles = /* @__PURE__ */ new Map();
|
|
193
|
-
for (const noteId of noteIds) {
|
|
194
|
-
const links = await storage.readonly("page_notes").getAllFromIndex("by-note", noteId);
|
|
195
|
-
const tagLinks = await storage.readonly("note_tags").getAllFromIndex("by-note", noteId);
|
|
196
|
-
const tags = await storage.readonly("tags").getMany(tagLinks.map((l) => l.tagId));
|
|
197
|
-
const pages = await storage.readonly("page").getMany([...new Set(links.map((l) => l.pageId))]);
|
|
198
|
-
bundles.set(noteId, {
|
|
199
|
-
tags: tags.flatMap((t) => t ? [{ label: t.label, ...t.type ? { type: t.type } : {} }] : []),
|
|
200
|
-
links,
|
|
201
|
-
pages: pages.filter((p) => p !== void 0)
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return bundles;
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
feedCatalogStore: {
|
|
208
|
-
getAllFeeds: async () => {
|
|
209
|
-
const rows = [];
|
|
210
|
-
for (const row of await storage.readonly("meta").getAll()) {
|
|
211
|
-
const key = row.key;
|
|
212
|
-
if (typeof key !== "string" || !key.startsWith("seed:") || key === seedMetaKey("user")) continue;
|
|
213
|
-
const id = key.slice("seed:".length);
|
|
214
|
-
rows.push({
|
|
215
|
-
id,
|
|
216
|
-
label: id,
|
|
217
|
-
url: `https://${id}.example/feed/`,
|
|
218
|
-
tier: "imported",
|
|
219
|
-
subscribed: true,
|
|
220
|
-
installed: true,
|
|
221
|
-
notebookCount: 0,
|
|
222
|
-
itemCount: 0
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return rows;
|
|
226
|
-
},
|
|
227
|
-
getAllNotebooks: async () => {
|
|
228
|
-
const links = await storage.readonly("notebook_links").getAll().catch(() => []);
|
|
229
|
-
const notes = await storage.readonly("notes").getAll();
|
|
230
|
-
const memberCount = /* @__PURE__ */ new Map();
|
|
231
|
-
for (const link of links) {
|
|
232
|
-
if (link.targetKind === "note") {
|
|
233
|
-
memberCount.set(link.notebookId, (memberCount.get(link.notebookId) ?? 0) + 1);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const rows = [];
|
|
237
|
-
for (const [notebookId, count] of memberCount) {
|
|
238
|
-
const slug = notebookId.startsWith("notebook/") ? notebookId.slice("notebook/".length) : notebookId;
|
|
239
|
-
const landing = notes.find((n) => n.id === notebookId);
|
|
240
|
-
const feedSourceId = landing?.feedSourceId;
|
|
241
|
-
rows.push({
|
|
242
|
-
id: notebookId,
|
|
243
|
-
feedId: feedSourceId ?? "local",
|
|
244
|
-
feedLabel: feedSourceId ?? "Yours (Local)",
|
|
245
|
-
chunkId: `notebook.${slug}`,
|
|
246
|
-
slug,
|
|
247
|
-
label: landing?.title ?? slug,
|
|
248
|
-
count,
|
|
249
|
-
subscribed: feedSourceId !== void 0,
|
|
250
|
-
installed: true,
|
|
251
|
-
origin: feedSourceId ? "feed" : "user",
|
|
252
|
-
...landing?.public !== void 0 ? { public: landing.public } : {}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return rows;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
98
|
function createQueryServiceForStorage(storage) {
|
|
261
99
|
return new QueryService(buildQueryServiceStoresFromStorage(storage));
|
|
262
100
|
}
|