mindoodb 0.3.0 → 0.3.2

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.
Files changed (57) hide show
  1. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +19 -0
  2. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
  3. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +88 -5
  4. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
  5. package/dist/browser/index.mjs +20 -0
  6. package/dist/core/BaseMindooTenantDirectory.d.ts +12 -1
  7. package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
  8. package/dist/core/BaseMindooTenantDirectory.js +27 -4
  9. package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
  10. package/dist/core/activity/ActivityIndex.d.ts +80 -0
  11. package/dist/core/activity/ActivityIndex.d.ts.map +1 -0
  12. package/dist/core/activity/ActivityIndex.js +402 -0
  13. package/dist/core/activity/ActivityIndex.js.map +1 -0
  14. package/dist/core/activity/MemoryActivityTable.d.ts +52 -0
  15. package/dist/core/activity/MemoryActivityTable.d.ts.map +1 -0
  16. package/dist/core/activity/MemoryActivityTable.js +196 -0
  17. package/dist/core/activity/MemoryActivityTable.js.map +1 -0
  18. package/dist/core/activity/SqliteActivityTable.d.ts +41 -0
  19. package/dist/core/activity/SqliteActivityTable.d.ts.map +1 -0
  20. package/dist/core/activity/SqliteActivityTable.js +302 -0
  21. package/dist/core/activity/SqliteActivityTable.js.map +1 -0
  22. package/dist/core/activity/index.d.ts +7 -0
  23. package/dist/core/activity/index.d.ts.map +1 -0
  24. package/dist/core/activity/index.js +37 -0
  25. package/dist/core/activity/index.js.map +1 -0
  26. package/dist/core/activity/mindoodbActivitySource.d.ts +17 -0
  27. package/dist/core/activity/mindoodbActivitySource.d.ts.map +1 -0
  28. package/dist/core/activity/mindoodbActivitySource.js +44 -0
  29. package/dist/core/activity/mindoodbActivitySource.js.map +1 -0
  30. package/dist/core/activity/summaryRuleClassifier.d.ts +59 -0
  31. package/dist/core/activity/summaryRuleClassifier.d.ts.map +1 -0
  32. package/dist/core/activity/summaryRuleClassifier.js +169 -0
  33. package/dist/core/activity/summaryRuleClassifier.js.map +1 -0
  34. package/dist/core/activity/types.d.ts +230 -0
  35. package/dist/core/activity/types.d.ts.map +1 -0
  36. package/dist/core/activity/types.js +37 -0
  37. package/dist/core/activity/types.js.map +1 -0
  38. package/dist/core/guestAdmissions.d.ts +41 -0
  39. package/dist/core/guestAdmissions.d.ts.map +1 -1
  40. package/dist/core/guestAdmissions.js +81 -1
  41. package/dist/core/guestAdmissions.js.map +1 -1
  42. package/dist/core/index.d.ts +2 -1
  43. package/dist/core/index.d.ts.map +1 -1
  44. package/dist/core/index.js +6 -1
  45. package/dist/core/index.js.map +1 -1
  46. package/dist/guest/guestChat.d.ts +79 -0
  47. package/dist/guest/guestChat.d.ts.map +1 -0
  48. package/dist/guest/guestChat.js +297 -0
  49. package/dist/guest/guestChat.js.map +1 -0
  50. package/dist/guest/index.d.ts +1 -0
  51. package/dist/guest/index.d.ts.map +1 -1
  52. package/dist/guest/index.js +3 -1
  53. package/dist/guest/index.js.map +1 -1
  54. package/dist/server/TenantManager.d.ts.map +1 -1
  55. package/dist/server/TenantManager.js +1 -0
  56. package/dist/server/TenantManager.js.map +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,80 @@
1
+ import type { StoreScanCursor, StoreScanResult } from "../appendonlystores/types";
2
+ import { type ActivityClassifier, type ActivityQuery, type ActivityQueryResult, type ActivityTable } from "./types";
3
+ /** Where an activity index reads its entries from (a database's store and the reader's keys). */
4
+ export interface ActivitySource {
5
+ /** Metadata scan of the store in receipt order (see `ContentAddressedStore.scanEntriesSince`). */
6
+ scan(cursor: StoreScanCursor | null, limit: number): Promise<StoreScanResult>;
7
+ /** Current cursor epoch of the store, when it has one. */
8
+ epoch?(): Promise<string | null>;
9
+ /** Whether the reader holds the key an entry is encrypted with. */
10
+ hasKey(decryptionKeyId: string): Promise<boolean>;
11
+ }
12
+ export interface ActivityIndexOptions {
13
+ /** Key of this feed in the table, e.g. `<tenantId>/<dbId>`. */
14
+ feedKey: string;
15
+ source: ActivitySource;
16
+ classifier: ActivityClassifier;
17
+ table: ActivityTable;
18
+ /** Entries of one subject, author and verb with at most this gap form one event (default 15 min). */
19
+ sessionGapMs?: number;
20
+ /** When the feed is built for the first time, entries older than this are skipped (default 30 days). */
21
+ initialWindowMs?: number;
22
+ /** Store entries per scan page (default 500). */
23
+ pageSize?: number;
24
+ /** Clock, for tests. */
25
+ now?: () => number;
26
+ }
27
+ export interface ActivityUpdateResult {
28
+ /** Store entries read. */
29
+ scanned: number;
30
+ /** Entries that became part of an event. */
31
+ added: number;
32
+ /** Events created or extended. */
33
+ events: number;
34
+ }
35
+ export declare const DEFAULT_ACTIVITY_SESSION_GAP_MS: number;
36
+ export declare const DEFAULT_ACTIVITY_INITIAL_WINDOW_MS: number;
37
+ /**
38
+ * Builds and maintains the activity feed of one database: reads the store's
39
+ * entries after its cursor (metadata only), drops what the reader cannot
40
+ * decrypt and what the classifier does not report, maps parts to their
41
+ * subject and groups the entries into sessions (see {@link ActivityEvent}).
42
+ *
43
+ * Call {@link update} after syncs and local writes (and periodically); it is
44
+ * incremental, resumable and idempotent. The cursor is written in the same
45
+ * table write as the events, so a crash only repeats work.
46
+ */
47
+ export declare class ActivityIndex {
48
+ readonly feedKey: string;
49
+ private readonly source;
50
+ private readonly classifier;
51
+ private readonly table;
52
+ private readonly gap;
53
+ private readonly initialWindow;
54
+ private readonly pageSize;
55
+ private readonly now;
56
+ private running;
57
+ private queued;
58
+ constructor(options: ActivityIndexOptions);
59
+ /** Events of this feed, newest first. */
60
+ query(query?: Omit<ActivityQuery, "feedKeys">): Promise<ActivityQueryResult>;
61
+ /**
62
+ * Bring the feed up to date with the store. Concurrent calls share one
63
+ * run; a call during a run gets one follow-up run.
64
+ */
65
+ update(): Promise<ActivityUpdateResult>;
66
+ /** Remove events older than `before` and never take such entries in again. */
67
+ prune(before: number): Promise<number>;
68
+ private runUpdate;
69
+ private processPage;
70
+ private fieldRuleFires;
71
+ /**
72
+ * The newest event of this subject and author within the gap that the
73
+ * entry may join: the same verb, or a `create` followed by edits.
74
+ */
75
+ private openEventFor;
76
+ private newEvent;
77
+ /** Add `entry` to `event`; `owners` names the event of every earlier entry known so far. */
78
+ private addEntry;
79
+ }
80
+ //# sourceMappingURL=ActivityIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActivityIndex.d.ts","sourceRoot":"","sources":["../../../src/core/activity/ActivityIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAEL,KAAK,kBAAkB,EAKvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EAExB,KAAK,aAAa,EAEnB,MAAM,SAAS,CAAC;AAEjB,iGAAiG;AACjG,MAAM,WAAW,cAAc;IAC7B,kGAAkG;IAClG,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9E,0DAA0D;IAC1D,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjC,mEAAmE;IACnE,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,qGAAqG;IACrG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wGAAwG;IACxG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,QAAQ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QAAQ;CAsBjB"}
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivityIndex = exports.DEFAULT_ACTIVITY_INITIAL_WINDOW_MS = exports.DEFAULT_ACTIVITY_SESSION_GAP_MS = void 0;
4
+ exports.DEFAULT_ACTIVITY_SESSION_GAP_MS = 15 * 60 * 1000;
5
+ exports.DEFAULT_ACTIVITY_INITIAL_WINDOW_MS = 30 * 24 * 60 * 60 * 1000;
6
+ const FEED_ENTRY_TYPES = new Set(["doc_create", "doc_change", "doc_delete", "doc_undelete"]);
7
+ /** Documents that never appear in a feed: setup, sealed key series, internal ids. */
8
+ function isTechnicalDocId(docId) {
9
+ return docId === "dbsetup" || docId.startsWith("$") || docId.startsWith("acl_");
10
+ }
11
+ function baseVerb(entryType) {
12
+ switch (entryType) {
13
+ case "doc_create":
14
+ return "create";
15
+ case "doc_delete":
16
+ return "delete";
17
+ case "doc_undelete":
18
+ return "restore";
19
+ default:
20
+ return "edit";
21
+ }
22
+ }
23
+ function toRawEntry(meta) {
24
+ const trusted = typeof meta.receivedAt === "number";
25
+ return {
26
+ entryId: meta.id,
27
+ docId: meta.docId,
28
+ entryType: meta.entryType,
29
+ createdAt: meta.createdAt,
30
+ trustedTime: trusted ? meta.receivedAt : meta.createdAt,
31
+ trusted,
32
+ actorKey: meta.createdByPublicKey,
33
+ dependencyIds: meta.dependencyIds ?? [],
34
+ decryptionKeyId: meta.decryptionKeyId,
35
+ };
36
+ }
37
+ function sameValue(a, b) {
38
+ return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
39
+ }
40
+ /**
41
+ * Builds and maintains the activity feed of one database: reads the store's
42
+ * entries after its cursor (metadata only), drops what the reader cannot
43
+ * decrypt and what the classifier does not report, maps parts to their
44
+ * subject and groups the entries into sessions (see {@link ActivityEvent}).
45
+ *
46
+ * Call {@link update} after syncs and local writes (and periodically); it is
47
+ * incremental, resumable and idempotent. The cursor is written in the same
48
+ * table write as the events, so a crash only repeats work.
49
+ */
50
+ class ActivityIndex {
51
+ constructor(options) {
52
+ this.running = null;
53
+ this.queued = null;
54
+ this.feedKey = options.feedKey;
55
+ this.source = options.source;
56
+ this.classifier = options.classifier;
57
+ this.table = options.table;
58
+ this.gap = options.sessionGapMs ?? exports.DEFAULT_ACTIVITY_SESSION_GAP_MS;
59
+ this.initialWindow = options.initialWindowMs ?? exports.DEFAULT_ACTIVITY_INITIAL_WINDOW_MS;
60
+ this.pageSize = Math.max(1, options.pageSize ?? 500);
61
+ this.now = options.now ?? Date.now;
62
+ }
63
+ /** Events of this feed, newest first. */
64
+ query(query = {}) {
65
+ return this.table.query({ ...query, feedKeys: [this.feedKey] });
66
+ }
67
+ /**
68
+ * Bring the feed up to date with the store. Concurrent calls share one
69
+ * run; a call during a run gets one follow-up run.
70
+ */
71
+ update() {
72
+ if (!this.running) {
73
+ this.running = this.runUpdate().finally(() => {
74
+ this.running = null;
75
+ });
76
+ return this.running;
77
+ }
78
+ if (!this.queued) {
79
+ this.queued = this.running.then(() => {
80
+ this.queued = null;
81
+ return this.update();
82
+ }, () => {
83
+ this.queued = null;
84
+ return this.update();
85
+ });
86
+ }
87
+ return this.queued;
88
+ }
89
+ /** Remove events older than `before` and never take such entries in again. */
90
+ async prune(before) {
91
+ await this.running?.catch(() => undefined);
92
+ const state = await this.table.readState(this.feedKey);
93
+ const removed = await this.table.prune(this.feedKey, before);
94
+ if (state && state.since < before) {
95
+ await this.table.write(this.feedKey, {
96
+ state: { ...state, since: before },
97
+ events: [],
98
+ entries: [],
99
+ docMappings: [],
100
+ subjectFields: [],
101
+ });
102
+ }
103
+ return removed;
104
+ }
105
+ async runUpdate() {
106
+ const result = { scanned: 0, added: 0, events: 0 };
107
+ let state = await this.table.readState(this.feedKey);
108
+ const epoch = this.source.epoch ? await this.source.epoch() : null;
109
+ let clearDocMappings = false;
110
+ if (!state) {
111
+ state = { cursor: null, epoch, rulesFingerprint: this.classifier.fingerprint, since: this.now() - this.initialWindow };
112
+ }
113
+ else {
114
+ if (epoch !== null && state.epoch !== null && state.epoch !== epoch) {
115
+ // Another numbering of the store: scan again. Entries already in the
116
+ // feed are recognised by id, so nothing is counted twice.
117
+ state = { ...state, cursor: null };
118
+ }
119
+ state = { ...state, epoch };
120
+ if (state.rulesFingerprint !== this.classifier.fingerprint) {
121
+ clearDocMappings = true;
122
+ state = { ...state, rulesFingerprint: this.classifier.fingerprint };
123
+ }
124
+ }
125
+ await this.classifier.prepare?.();
126
+ const keyCache = new Map();
127
+ for (;;) {
128
+ const page = await this.source.scan(state.cursor, this.pageSize);
129
+ result.scanned += page.entries.length;
130
+ const next = { ...state, cursor: page.nextCursor ?? state.cursor };
131
+ const change = await this.processPage(page.entries, next, keyCache, clearDocMappings);
132
+ clearDocMappings = false;
133
+ result.added += change.added;
134
+ result.events += change.write.events.length;
135
+ await this.table.write(this.feedKey, change.write);
136
+ state = next;
137
+ if (!page.hasMore || !page.nextCursor)
138
+ break;
139
+ }
140
+ return result;
141
+ }
142
+ async processPage(metas, state, keyCache, clearDocMappings) {
143
+ const write = {
144
+ state,
145
+ events: [],
146
+ entries: [],
147
+ docMappings: [],
148
+ subjectFields: [],
149
+ clearDocMappings,
150
+ };
151
+ // 1. Candidate entries: document entries in the window that the reader can decrypt.
152
+ const candidates = [];
153
+ for (const meta of metas) {
154
+ if (!FEED_ENTRY_TYPES.has(meta.entryType) || isTechnicalDocId(meta.docId))
155
+ continue;
156
+ const entry = toRawEntry(meta);
157
+ if (entry.trustedTime < state.since)
158
+ continue;
159
+ let readable = keyCache.get(entry.decryptionKeyId);
160
+ if (readable === undefined) {
161
+ readable = await this.source.hasKey(entry.decryptionKeyId);
162
+ keyCache.set(entry.decryptionKeyId, readable);
163
+ }
164
+ if (readable)
165
+ candidates.push(entry);
166
+ }
167
+ if (candidates.length === 0)
168
+ return { write, added: 0 };
169
+ const events = new Map();
170
+ const touched = new Set();
171
+ // 2. Entries already in the feed (rescan, or now witnessed).
172
+ const known = await this.table.readEntries(this.feedKey, candidates.map((entry) => entry.entryId));
173
+ const fresh = [];
174
+ const witnessed = [];
175
+ for (const entry of candidates) {
176
+ const existing = known.get(entry.entryId);
177
+ if (!existing)
178
+ fresh.push(entry);
179
+ else if (entry.trusted && !existing.trusted)
180
+ witnessed.push({ entry, eventId: existing.eventId });
181
+ }
182
+ if (witnessed.length) {
183
+ for (const event of await this.table.readEvents([...new Set(witnessed.map((w) => w.eventId))])) {
184
+ events.set(event.id, event);
185
+ }
186
+ for (const { entry, eventId } of witnessed) {
187
+ const event = events.get(eventId);
188
+ if (!event)
189
+ continue;
190
+ event.untrusted = Math.max(0, event.untrusted - 1);
191
+ event.trusted = event.untrusted === 0;
192
+ touched.add(eventId);
193
+ write.entries.push({ entryId: entry.entryId, eventId, trusted: true });
194
+ }
195
+ }
196
+ if (fresh.length === 0) {
197
+ write.events = [...touched].map((id) => events.get(id)).filter(Boolean);
198
+ return { write, added: 0 };
199
+ }
200
+ // 3. Classify the changed documents (cached mapping first).
201
+ const docIds = [...new Set(fresh.map((entry) => entry.docId))];
202
+ const mappings = clearDocMappings ? new Map() : await this.table.readDocMappings(this.feedKey, docIds);
203
+ const missing = docIds.filter((docId) => !mappings.has(docId));
204
+ if (missing.length) {
205
+ const classified = await this.classifier.classify(missing);
206
+ for (const docId of missing) {
207
+ const found = classified.get(docId) ?? null;
208
+ // The mapping is kept; field values are not (they are read fresh per run).
209
+ const classification = found ? { ...found } : null;
210
+ if (classification)
211
+ delete classification.subjectFields;
212
+ const mapping = { classification };
213
+ // A document the classifier cannot see yet (deleted before it was
214
+ // summarized) is not remembered as "not taking part".
215
+ if (classified.has(docId))
216
+ write.docMappings.push({ docId, mapping });
217
+ mappings.set(docId, mapping);
218
+ }
219
+ }
220
+ // Current field values of the subjects touched by this page.
221
+ const subjects = [
222
+ ...new Set(docIds
223
+ .map((docId) => mappings.get(docId)?.classification?.subjectDocId)
224
+ .filter((id) => typeof id === "string")),
225
+ ];
226
+ const current = subjects.length ? await this.classifier.classify(subjects) : new Map();
227
+ const fresherFields = new Map();
228
+ for (const subjectDocId of subjects) {
229
+ const fields = current.get(subjectDocId)?.subjectFields;
230
+ if (fields)
231
+ fresherFields.set(subjectDocId, fields);
232
+ }
233
+ // Last known values: for subjects the classifier no longer sees (deleted).
234
+ const previousFields = subjects.length
235
+ ? await this.table.readSubjectFields(this.feedKey, subjects)
236
+ : new Map();
237
+ // Which event earlier entries (the parents of this page's entries) belong to.
238
+ const owners = new Map();
239
+ const parentIds = [...new Set(fresh.flatMap((entry) => entry.dependencyIds))];
240
+ if (parentIds.length) {
241
+ for (const [entryId, owner] of await this.table.readEntries(this.feedKey, parentIds))
242
+ owners.set(entryId, owner.eventId);
243
+ }
244
+ // 4. Group into sessions.
245
+ const oldestFresh = Math.min(...fresh.map((entry) => entry.trustedTime));
246
+ const recent = subjects.length
247
+ ? await this.table.readRecentEvents(this.feedKey, subjects, oldestFresh - this.gap)
248
+ : [];
249
+ for (const event of recent)
250
+ if (!events.has(event.id))
251
+ events.set(event.id, event);
252
+ let added = 0;
253
+ for (const entry of fresh) {
254
+ const classification = mappings.get(entry.docId)?.classification;
255
+ if (!classification)
256
+ continue;
257
+ const verb = classification.partVerb && classification.subjectDocId !== entry.docId
258
+ ? classification.partVerb
259
+ : baseVerb(entry.entryType);
260
+ if (classification.report && !classification.report.includes(verb))
261
+ continue;
262
+ const event = this.openEventFor(events, classification.subjectDocId, entry.actorKey, verb, entry.trustedTime)
263
+ ?? this.newEvent(entry, classification, verb);
264
+ events.set(event.id, event);
265
+ this.addEntry(event, entry, owners);
266
+ owners.set(entry.entryId, event.id);
267
+ const fields = fresherFields.get(classification.subjectDocId) ?? previousFields.get(classification.subjectDocId);
268
+ if (fields)
269
+ event.fields = fields;
270
+ touched.add(event.id);
271
+ write.entries.push({ entryId: entry.entryId, eventId: event.id, trusted: entry.trusted });
272
+ added++;
273
+ }
274
+ // Fields of changed parts (a node's title), as they are now.
275
+ const partFieldNames = new Map();
276
+ for (const docId of docIds) {
277
+ const classification = mappings.get(docId)?.classification;
278
+ if (classification?.partFieldNames?.length && classification.subjectDocId !== docId) {
279
+ partFieldNames.set(docId, classification.partFieldNames);
280
+ }
281
+ }
282
+ if (partFieldNames.size && this.classifier.readFields) {
283
+ const current = await this.classifier.readFields([...partFieldNames.keys()]);
284
+ for (const id of touched) {
285
+ for (const doc of events.get(id)?.docs ?? []) {
286
+ const names = partFieldNames.get(doc.docId);
287
+ const fields = current.get(doc.docId);
288
+ if (!names || !fields)
289
+ continue; // deleted since: keep what the event had
290
+ const picked = {};
291
+ for (const name of names)
292
+ if (fields[name] !== undefined)
293
+ picked[name] = fields[name];
294
+ doc.fields = picked;
295
+ }
296
+ }
297
+ }
298
+ // 5. Business events from field changes of the subjects.
299
+ if (fresherFields.size) {
300
+ const previous = previousFields;
301
+ for (const [subjectDocId, fields] of fresherFields) {
302
+ const rules = current.get(subjectDocId)?.fieldEvents ?? [];
303
+ const classification = current.get(subjectDocId);
304
+ const before = previous.get(subjectDocId);
305
+ if (before && rules.length) {
306
+ const lastEntry = [...fresh].reverse().find((entry) => mappings.get(entry.docId)?.classification?.subjectDocId === subjectDocId);
307
+ if (lastEntry) {
308
+ for (const rule of rules) {
309
+ if (!this.fieldRuleFires(rule, before[rule.when.field], fields[rule.when.field]))
310
+ continue;
311
+ const event = this.newEvent(lastEntry, classification, rule.id);
312
+ event.id = `${this.feedKey}|${lastEntry.entryId}#${rule.id}`;
313
+ this.addEntry(event, lastEntry, owners);
314
+ event.fields = fields;
315
+ if (rule.highlight)
316
+ event.highlight = true;
317
+ events.set(event.id, event);
318
+ touched.add(event.id);
319
+ }
320
+ }
321
+ }
322
+ if (!before || !sameValue(before, fields))
323
+ write.subjectFields.push({ subjectDocId, fields });
324
+ }
325
+ }
326
+ write.events = [...touched].map((id) => events.get(id)).filter(Boolean);
327
+ return { write, added };
328
+ }
329
+ fieldRuleFires(rule, before, after) {
330
+ if (sameValue(before, after))
331
+ return false;
332
+ if (rule.when.to !== undefined)
333
+ return sameValue(after, rule.when.to);
334
+ if (rule.when.from !== undefined)
335
+ return sameValue(before, rule.when.from);
336
+ return rule.when.changed === true;
337
+ }
338
+ /**
339
+ * The newest event of this subject and author within the gap that the
340
+ * entry may join: the same verb, or a `create` followed by edits.
341
+ */
342
+ openEventFor(events, subjectDocId, actorKey, verb, time) {
343
+ let best = null;
344
+ for (const event of events.values()) {
345
+ if (event.subjectDocId !== subjectDocId || event.actorKey !== actorKey)
346
+ continue;
347
+ if (event.highlight || event.id.includes("#"))
348
+ continue;
349
+ if (event.verb !== verb && !(event.verb === "create" && verb === "edit"))
350
+ continue;
351
+ if (time > event.lastTime + this.gap || time < event.firstTime - this.gap)
352
+ continue;
353
+ if (!best || event.lastTime > best.lastTime)
354
+ best = event;
355
+ }
356
+ return best;
357
+ }
358
+ newEvent(entry, classification, verb) {
359
+ const event = {
360
+ id: `${this.feedKey}|${entry.entryId}`,
361
+ feedKey: this.feedKey,
362
+ subjectDocId: classification.subjectDocId,
363
+ verb,
364
+ actorKey: entry.actorKey,
365
+ firstTime: entry.trustedTime,
366
+ lastTime: entry.trustedTime,
367
+ trusted: true,
368
+ untrusted: 0,
369
+ entryCount: 0,
370
+ docs: [],
371
+ };
372
+ if (classification.kind !== undefined)
373
+ event.kind = classification.kind;
374
+ return event;
375
+ }
376
+ /** Add `entry` to `event`; `owners` names the event of every earlier entry known so far. */
377
+ addEntry(event, entry, owners) {
378
+ event.firstTime = Math.min(event.firstTime, entry.trustedTime);
379
+ event.lastTime = Math.max(event.lastTime, entry.trustedTime);
380
+ event.entryCount++;
381
+ if (!entry.trusted) {
382
+ event.untrusted++;
383
+ event.trusted = false;
384
+ }
385
+ let doc = event.docs.find((candidate) => candidate.docId === entry.docId);
386
+ if (!doc) {
387
+ doc = { docId: entry.docId, before: [], after: [], entryCount: 0 };
388
+ event.docs.push(doc);
389
+ }
390
+ doc.entryCount++;
391
+ // `before`: parents of the event's changes that lie outside the event.
392
+ for (const dep of entry.dependencyIds) {
393
+ if (owners.get(dep) !== event.id && !doc.before.includes(dep))
394
+ doc.before.push(dep);
395
+ }
396
+ // `after`: the event's heads of this document.
397
+ doc.after = doc.after.filter((id) => !entry.dependencyIds.includes(id));
398
+ doc.after.push(entry.entryId);
399
+ }
400
+ }
401
+ exports.ActivityIndex = ActivityIndex;
402
+ //# sourceMappingURL=ActivityIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActivityIndex.js","sourceRoot":"","sources":["../../../src/core/activity/ActivityIndex.ts"],"names":[],"mappings":";;;AAmDa,QAAA,+BAA+B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACjD,QAAA,kCAAkC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3E,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AAE7F,qFAAqF;AACrF,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,QAAQ,CAAC,SAAiB;IACjC,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc;YACjB,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAwB;IAC1C,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC;IACpD,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,EAAE;QAChB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CA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aAAa,EAAE,CAAC;YACtC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtF,CAAC;QACD,+CAA+C;QAC/C,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF;AA1WD,sCA0WC"}
@@ -0,0 +1,52 @@
1
+ import { type ActivityDocMapping, type ActivityEvent, type ActivityFeedState, type ActivityQuery, type ActivityQueryResult, type ActivityTable, type ActivityTableWrite } from "./types";
2
+ /** Matches `query` except for the keyset position. */
3
+ export declare function activityEventMatches(event: ActivityEvent, query: ActivityQuery): boolean;
4
+ /**
5
+ * {@link ActivityTable} in memory: for tests, small databases and hosts
6
+ * without SQLite. Values are copied in and out, like a real table.
7
+ */
8
+ export declare class MemoryActivityTable implements ActivityTable {
9
+ private readonly feeds;
10
+ private feed;
11
+ readState(feedKey: string): Promise<ActivityFeedState | null>;
12
+ readDocMappings(feedKey: string, docIds: readonly string[]): Promise<Map<string, ActivityDocMapping>>;
13
+ readSubjectFields(feedKey: string, subjectDocIds: readonly string[]): Promise<Map<string, Record<string, unknown>>>;
14
+ readRecentEvents(feedKey: string, subjectDocIds: readonly string[], since: number): Promise<ActivityEvent[]>;
15
+ readEntries(feedKey: string, entryIds: readonly string[]): Promise<Map<string, {
16
+ eventId: string;
17
+ trusted: boolean;
18
+ }>>;
19
+ readEvents(eventIds: readonly string[]): Promise<ActivityEvent[]>;
20
+ write(feedKey: string, change: ActivityTableWrite): Promise<void>;
21
+ query(query: ActivityQuery): Promise<ActivityQueryResult>;
22
+ prune(feedKey: string, before: number): Promise<number>;
23
+ clear(feedKey: string): Promise<void>;
24
+ /** Feeds held here. */
25
+ feedKeys(): string[];
26
+ /**
27
+ * Everything of one feed as plain JSON, for hosts that persist the table
28
+ * themselves (e.g. encrypted in IndexedDB); `null` for an unknown feed.
29
+ */
30
+ exportFeed(feedKey: string): ActivityFeedSnapshot | null;
31
+ /** Replace one feed with a snapshot from {@link exportFeed}. */
32
+ importFeed(feedKey: string, snapshot: ActivityFeedSnapshot): void;
33
+ }
34
+ /** One feed of a {@link MemoryActivityTable} as plain JSON. */
35
+ export interface ActivityFeedSnapshot {
36
+ state: ActivityFeedState | null;
37
+ events: ActivityEvent[];
38
+ entries: Array<{
39
+ entryId: string;
40
+ eventId: string;
41
+ trusted: boolean;
42
+ }>;
43
+ docMappings: Array<{
44
+ docId: string;
45
+ mapping: ActivityDocMapping;
46
+ }>;
47
+ subjectFields: Array<{
48
+ subjectDocId: string;
49
+ fields: Record<string, unknown>;
50
+ }>;
51
+ }
52
+ //# sourceMappingURL=MemoryActivityTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryActivityTable.d.ts","sourceRoot":"","sources":["../../../src/core/activity/MemoryActivityTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,SAAS,CAAC;AAcjB,sDAAsD;AACtD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAQxF;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+B;IAErD,OAAO,CAAC,IAAI;IASN,SAAS,CAA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