@powerhousedao/reactor 4.1.0-dev.4 → 4.1.0-dev.41

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 (61) hide show
  1. package/dist/bench/end-to-end-flow.bench.js +21 -11
  2. package/dist/bench/end-to-end-flow.bench.js.map +1 -1
  3. package/dist/bench/event-bus.bench.js +7 -7
  4. package/dist/bench/event-bus.bench.js.map +1 -1
  5. package/dist/bench/queue-only.bench.js +8 -3
  6. package/dist/bench/queue-only.bench.js.map +1 -1
  7. package/dist/bench/reactor-throughput.bench.js +18 -8
  8. package/dist/bench/reactor-throughput.bench.js.map +1 -1
  9. package/dist/src/executor/job-executor.d.ts +5 -5
  10. package/dist/src/executor/job-executor.d.ts.map +1 -1
  11. package/dist/src/executor/job-executor.js +1 -1
  12. package/dist/src/executor/job-executor.js.map +1 -1
  13. package/dist/src/index.d.ts +4 -1
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/index.js +3 -0
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/interfaces/reactor.d.ts +121 -0
  18. package/dist/src/interfaces/reactor.d.ts.map +1 -0
  19. package/dist/src/interfaces/reactor.js +2 -0
  20. package/dist/src/interfaces/reactor.js.map +1 -0
  21. package/dist/src/queue/queue.d.ts +3 -3
  22. package/dist/src/queue/queue.d.ts.map +1 -1
  23. package/dist/src/queue/queue.js.map +1 -1
  24. package/dist/src/queue/types.d.ts +1 -1
  25. package/dist/src/queue/types.d.ts.map +1 -1
  26. package/dist/src/reactor.d.ts +99 -0
  27. package/dist/src/reactor.d.ts.map +1 -0
  28. package/dist/src/reactor.js +607 -0
  29. package/dist/src/reactor.js.map +1 -0
  30. package/dist/src/shared/factories.d.ts +16 -0
  31. package/dist/src/shared/factories.d.ts.map +1 -0
  32. package/dist/src/shared/factories.js +33 -0
  33. package/dist/src/shared/factories.js.map +1 -0
  34. package/dist/src/shared/types.d.ts +83 -19
  35. package/dist/src/shared/types.d.ts.map +1 -1
  36. package/dist/src/shared/types.js +30 -1
  37. package/dist/src/shared/types.js.map +1 -1
  38. package/dist/src/shared/utils.d.ts +3 -0
  39. package/dist/src/shared/utils.d.ts.map +1 -0
  40. package/dist/src/shared/utils.js +8 -0
  41. package/dist/src/shared/utils.js.map +1 -0
  42. package/dist/src/utils.d.ts +11 -0
  43. package/dist/src/utils.d.ts.map +1 -0
  44. package/dist/src/utils.js +29 -0
  45. package/dist/src/utils.js.map +1 -0
  46. package/dist/test/event-bus.test.js +4 -4
  47. package/dist/test/event-bus.test.js.map +1 -1
  48. package/dist/test/job-executor.test.js +9 -3
  49. package/dist/test/job-executor.test.js.map +1 -1
  50. package/dist/test/queue.test.js +17 -6
  51. package/dist/test/queue.test.js.map +1 -1
  52. package/dist/test/reactor.test.d.ts +2 -0
  53. package/dist/test/reactor.test.d.ts.map +1 -0
  54. package/dist/test/reactor.test.js +445 -0
  55. package/dist/test/reactor.test.js.map +1 -0
  56. package/dist/test/utils.test.d.ts +2 -0
  57. package/dist/test/utils.test.d.ts.map +1 -0
  58. package/dist/test/utils.test.js +66 -0
  59. package/dist/test/utils.test.js.map +1 -0
  60. package/dist/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +6 -1
@@ -0,0 +1,607 @@
1
+ import { AbortError } from "document-drive/utils/errors";
2
+ import { v4 as uuidv4 } from "uuid";
3
+ import { createMutableShutdownStatus } from "./shared/factories.js";
4
+ import { JobStatus, } from "./shared/types.js";
5
+ import { matchesScope } from "./shared/utils.js";
6
+ import { filterByParentId, filterByType } from "./utils.js";
7
+ /**
8
+ * The Reactor facade implementation.
9
+ *
10
+ * This class implements the IReactor interface and serves as the main entry point
11
+ * for the new Reactor architecture. In Phase 2 of the refactoring plan, it acts
12
+ * as a facade over the existing BaseDocumentDriveServer while we incrementally
13
+ * migrate to the new architecture.
14
+ *
15
+ * The facade pattern allows us to:
16
+ * 1. Present the new IReactor API to clients immediately
17
+ * 2. Internally delegate to the refactored BaseDocumentDriveServer (post Phase 1)
18
+ * 3. Incrementally replace internal implementations without breaking clients
19
+ * 4. Validate the new architecture alongside the existing system
20
+ */
21
+ export class Reactor {
22
+ driveServer;
23
+ shutdownStatus;
24
+ setShutdown;
25
+ constructor(driveServer) {
26
+ this.driveServer = driveServer;
27
+ // Create mutable shutdown status using factory method
28
+ const [status, setter] = createMutableShutdownStatus(false);
29
+ this.shutdownStatus = status;
30
+ this.setShutdown = setter;
31
+ }
32
+ /**
33
+ * Signals that the reactor should shutdown.
34
+ */
35
+ kill() {
36
+ // Mark the reactor as shutdown
37
+ this.setShutdown(true);
38
+ // TODO: Phase 3+ - Implement graceful shutdown for queue, executors, etc.
39
+ // For now, we just mark as shutdown and return status
40
+ return this.shutdownStatus;
41
+ }
42
+ /**
43
+ * Retrieves a list of document model specifications
44
+ */
45
+ getDocumentModels(namespace, paging, signal) {
46
+ // Get document model modules from the drive server
47
+ // Note: BaseDocumentDriveServer provides modules, not model states
48
+ // This is an adaptation layer that converts modules to states
49
+ const modules = this.driveServer.getDocumentModelModules();
50
+ // Convert modules to DocumentModelState format
51
+ // TODO: Proper conversion when DocumentModelState structure is finalized
52
+ const filteredModels = modules
53
+ .filter((module) => !namespace || module.documentModel.name.startsWith(namespace))
54
+ .map((module) => ({
55
+ id: module.documentModel.id,
56
+ name: module.documentModel.name,
57
+ extension: module.documentModel.extension,
58
+ author: module.documentModel.author,
59
+ description: module.documentModel.description || "",
60
+ specifications: module.documentModel.specifications,
61
+ }));
62
+ // Apply paging
63
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
64
+ const limit = paging?.limit || filteredModels.length;
65
+ const pagedModels = filteredModels.slice(startIndex, startIndex + limit);
66
+ // Create paged results
67
+ const hasMore = startIndex + limit < filteredModels.length;
68
+ const nextCursor = hasMore ? String(startIndex + limit) : undefined;
69
+ // even thought this is currently synchronous, they could have passed in an already-aborted signal
70
+ if (signal?.aborted) {
71
+ throw new AbortError();
72
+ }
73
+ return Promise.resolve({
74
+ results: pagedModels,
75
+ options: paging || { cursor: "0", limit: filteredModels.length },
76
+ nextCursor,
77
+ next: hasMore
78
+ ? () => this.getDocumentModels(namespace, { cursor: nextCursor, limit }, signal)
79
+ : undefined,
80
+ });
81
+ }
82
+ /**
83
+ * Retrieves a specific PHDocument by id
84
+ */
85
+ async get(id, view, signal) {
86
+ const document = await this.driveServer.getDocument(id);
87
+ // this should be thrown by the storage layer
88
+ if (!document) {
89
+ throw new Error(`Document not found: ${id}`);
90
+ }
91
+ const childIds = await this.driveServer.getDocuments(id);
92
+ if (signal?.aborted) {
93
+ throw new AbortError();
94
+ }
95
+ // Apply view filter - This will be removed when we pass the viewfilter along
96
+ // to the underlying store, but is here now for the interface.
97
+ for (const scope in document.state) {
98
+ if (!matchesScope(view, scope)) {
99
+ // eslint-disable-next-line
100
+ delete document.state[scope];
101
+ }
102
+ }
103
+ return {
104
+ document,
105
+ childIds,
106
+ };
107
+ }
108
+ /**
109
+ * Retrieves a specific PHDocument by slug
110
+ */
111
+ async getBySlug(slug, view, signal) {
112
+ // Get all drives
113
+ const drives = await this.driveServer.getDrives();
114
+ // Search through drives to find a document with the matching slug
115
+ for (const driveId of drives) {
116
+ if (signal?.aborted) {
117
+ throw new AbortError();
118
+ }
119
+ const documentIds = await this.driveServer.getDocuments(driveId);
120
+ for (const docId of documentIds) {
121
+ const document = await this.driveServer.getDocument(docId);
122
+ if (document.header.slug === slug) {
123
+ const childIds = await this.driveServer.getDocuments(docId);
124
+ if (signal?.aborted) {
125
+ throw new AbortError();
126
+ }
127
+ // Apply view filter - This will be removed when we pass the viewfilter along
128
+ // to the underlying store, but is here now for the interface.
129
+ for (const scope in document.state) {
130
+ if (!matchesScope(view, scope)) {
131
+ // eslint-disable-next-line
132
+ delete document.state[scope];
133
+ }
134
+ }
135
+ return { document, childIds };
136
+ }
137
+ }
138
+ }
139
+ throw new Error(`Document not found with slug: ${slug}`);
140
+ }
141
+ /**
142
+ * Retrieves the operations for a document
143
+ */
144
+ async getOperations(documentId, view, paging, signal) {
145
+ const document = await this.driveServer.getDocument(documentId);
146
+ if (signal?.aborted) {
147
+ throw new AbortError();
148
+ }
149
+ const operations = document.operations;
150
+ const result = {};
151
+ // apply view filter, per scope -- this will be removed when we pass the viewfilter along
152
+ // to the underlying store, but is here now for the interface.
153
+ for (const scope in operations) {
154
+ if (matchesScope(view, scope)) {
155
+ const scopeOperations = operations[scope];
156
+ // apply paging too
157
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
158
+ const limit = paging?.limit || scopeOperations.length;
159
+ const pagedOperations = scopeOperations.slice(startIndex, startIndex + limit);
160
+ result[scope] = {
161
+ results: pagedOperations,
162
+ options: { cursor: String(startIndex + limit), limit },
163
+ };
164
+ }
165
+ }
166
+ return Promise.resolve(result);
167
+ }
168
+ /**
169
+ * Filters documents by criteria and returns a list of them
170
+ */
171
+ async find(search, view, paging, signal) {
172
+ let results;
173
+ if (search.ids) {
174
+ if (search.slugs && search.slugs.length > 0) {
175
+ throw new Error("Cannot use both ids and slugs in the same search");
176
+ }
177
+ results = await this.findByIds(search.ids, view, paging, signal);
178
+ if (search.parentId) {
179
+ results = filterByParentId(results, search.parentId);
180
+ }
181
+ if (search.type) {
182
+ results = filterByType(results, search.type);
183
+ }
184
+ }
185
+ else if (search.slugs) {
186
+ results = await this.findBySlugs(search.slugs, view, paging, signal);
187
+ if (search.parentId) {
188
+ results = filterByParentId(results, search.parentId);
189
+ }
190
+ if (search.type) {
191
+ results = filterByType(results, search.type);
192
+ }
193
+ }
194
+ else if (search.parentId) {
195
+ results = await this.findByParentId(search.parentId, view, paging, signal);
196
+ if (search.type) {
197
+ results = filterByType(results, search.type);
198
+ }
199
+ }
200
+ else if (search.type) {
201
+ results = await this.findByType(search.type, view, paging, signal);
202
+ }
203
+ else {
204
+ // Empty search filter - return all documents
205
+ results = await this.findAll(view, paging, signal);
206
+ }
207
+ if (signal?.aborted) {
208
+ throw new AbortError();
209
+ }
210
+ return results;
211
+ }
212
+ /**
213
+ * Creates a document
214
+ */
215
+ async create(document, signal) {
216
+ try {
217
+ // BaseDocumentDriveServer uses addDocument, not createDocument
218
+ // addDocument adds an existing document to a drive
219
+ await this.driveServer.addDocument(document);
220
+ // Return success status
221
+ // TODO: Phase 4 - This will return a job that goes through the queue
222
+ return JobStatus.COMPLETED;
223
+ }
224
+ catch (error) {
225
+ // TODO: Phase 4 - This will return a job that can be retried
226
+ return JobStatus.FAILED;
227
+ }
228
+ }
229
+ /**
230
+ * Deletes a document
231
+ */
232
+ async deleteDocument(id, propagate, signal) {
233
+ const jobId = uuidv4();
234
+ try {
235
+ // Delete document using drive server
236
+ await this.driveServer.deleteDocument(id);
237
+ // TODO: Implement cascade deletion when propagate mode is CASCADE
238
+ // Return success job info
239
+ // TODO: Phase 4 - This will return a job that goes through the queue
240
+ return {
241
+ id: jobId,
242
+ status: JobStatus.COMPLETED,
243
+ };
244
+ }
245
+ catch (error) {
246
+ // TODO: Phase 4 - This will return a job that can be retried
247
+ return {
248
+ id: jobId,
249
+ status: JobStatus.FAILED,
250
+ error: error instanceof Error ? error.message : "Unknown error",
251
+ };
252
+ }
253
+ }
254
+ /**
255
+ * Applies a list of actions to a document
256
+ */
257
+ async mutate(id, actions) {
258
+ const jobId = uuidv4();
259
+ try {
260
+ // BaseDocumentDriveServer expects Operations, not Actions
261
+ // We need to convert Actions to Operations
262
+ const operations = actions.map((action, index) => ({
263
+ index: index,
264
+ timestampUtcMs: action.timestampUtcMs,
265
+ hash: "", // Will be computed by the server
266
+ skip: 0,
267
+ action: action,
268
+ }));
269
+ // Apply operations to document
270
+ await this.driveServer.addOperations(id, operations);
271
+ // Return success job info
272
+ // TODO: Phase 4 - This will return a job that goes through the queue
273
+ return {
274
+ id: jobId,
275
+ status: JobStatus.COMPLETED,
276
+ };
277
+ }
278
+ catch (error) {
279
+ // TODO: Phase 4 - This will return a job that can be retried
280
+ return {
281
+ id: jobId,
282
+ status: JobStatus.FAILED,
283
+ error: error instanceof Error ? error.message : "Unknown error",
284
+ };
285
+ }
286
+ }
287
+ /**
288
+ * Adds multiple documents as children to another
289
+ */
290
+ async addChildren(parentId, documentIds, view, signal) {
291
+ const jobId = uuidv4();
292
+ try {
293
+ // TODO: Implement when drive server supports hierarchical documents
294
+ // For now, this is a placeholder implementation
295
+ // Verify parent exists
296
+ await this.driveServer.getDocument(parentId);
297
+ // Verify all children exist
298
+ for (const childId of documentIds) {
299
+ await this.driveServer.getDocument(childId);
300
+ }
301
+ // TODO: Actually establish parent-child relationships
302
+ // Return success job info
303
+ return {
304
+ id: jobId,
305
+ status: JobStatus.COMPLETED,
306
+ };
307
+ }
308
+ catch (error) {
309
+ return {
310
+ id: jobId,
311
+ status: JobStatus.FAILED,
312
+ error: error instanceof Error ? error.message : "Unknown error",
313
+ };
314
+ }
315
+ }
316
+ /**
317
+ * Removes multiple documents as children from another
318
+ */
319
+ async removeChildren(parentId, documentIds, view, signal) {
320
+ const jobId = uuidv4();
321
+ try {
322
+ // TODO: Implement when drive server supports hierarchical documents
323
+ // For now, this is a placeholder implementation
324
+ // Verify parent exists
325
+ await this.driveServer.getDocument(parentId);
326
+ // TODO: Actually remove parent-child relationships
327
+ // Return success job info
328
+ return {
329
+ id: jobId,
330
+ status: JobStatus.COMPLETED,
331
+ };
332
+ }
333
+ catch (error) {
334
+ return {
335
+ id: jobId,
336
+ status: JobStatus.FAILED,
337
+ error: error instanceof Error ? error.message : "Unknown error",
338
+ };
339
+ }
340
+ }
341
+ /**
342
+ * Retrieves the status of a job
343
+ */
344
+ async getJobStatus(jobId, signal) {
345
+ // TODO: Phase 3 - Implement once IQueue and job tracking is in place
346
+ // For now, return a not found status
347
+ return {
348
+ id: jobId,
349
+ status: JobStatus.FAILED,
350
+ error: "Job tracking not yet implemented",
351
+ };
352
+ }
353
+ /**
354
+ * Finds documents by their IDs
355
+ */
356
+ async findByIds(ids, view, paging, signal) {
357
+ const documents = [];
358
+ // Fetch each document by ID
359
+ for (const id of ids) {
360
+ if (signal?.aborted) {
361
+ throw new AbortError();
362
+ }
363
+ try {
364
+ const document = await this.driveServer.getDocument(id);
365
+ if (!document) {
366
+ continue; // Skip if document not found
367
+ }
368
+ // Apply view filter - This will be removed when we pass the viewfilter along
369
+ // to the underlying store, but is here now for the interface.
370
+ for (const scope in document.state) {
371
+ if (!matchesScope(view, scope)) {
372
+ // eslint-disable-next-line
373
+ delete document.state[scope];
374
+ }
375
+ }
376
+ documents.push(document);
377
+ }
378
+ catch {
379
+ // Skip documents that don't exist or can't be accessed
380
+ // This matches the behavior expected from a search operation
381
+ continue;
382
+ }
383
+ }
384
+ if (signal?.aborted) {
385
+ throw new AbortError();
386
+ }
387
+ // Apply paging
388
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
389
+ const limit = paging?.limit || documents.length;
390
+ const pagedDocuments = documents.slice(startIndex, startIndex + limit);
391
+ // Create paged results
392
+ const hasMore = startIndex + limit < documents.length;
393
+ const nextCursor = hasMore ? String(startIndex + limit) : undefined;
394
+ return {
395
+ results: pagedDocuments,
396
+ options: paging || { cursor: "0", limit: documents.length },
397
+ nextCursor,
398
+ next: hasMore
399
+ ? () => this.findByIds(ids, view, { cursor: nextCursor, limit }, signal)
400
+ : undefined,
401
+ };
402
+ }
403
+ /**
404
+ * Finds documents by their slugs
405
+ */
406
+ async findBySlugs(slugs, view, paging, signal) {
407
+ const documents = [];
408
+ // Fetch each document by slug
409
+ for (const slug of slugs) {
410
+ if (signal?.aborted) {
411
+ throw new AbortError();
412
+ }
413
+ try {
414
+ // Search through drives to find a document with the matching slug
415
+ const drives = await this.driveServer.getDrives();
416
+ let found = false;
417
+ for (const driveId of drives) {
418
+ const documentIds = await this.driveServer.getDocuments(driveId);
419
+ for (const docId of documentIds) {
420
+ const document = await this.driveServer.getDocument(docId);
421
+ if (document && document.header.slug === slug) {
422
+ // Apply view filter - This will be removed when we pass the viewfilter along
423
+ // to the underlying store, but is here now for the interface.
424
+ for (const scope in document.state) {
425
+ if (!matchesScope(view, scope)) {
426
+ // eslint-disable-next-line
427
+ delete document.state[scope];
428
+ }
429
+ }
430
+ documents.push(document);
431
+ found = true;
432
+ break;
433
+ }
434
+ }
435
+ if (found)
436
+ break;
437
+ }
438
+ }
439
+ catch {
440
+ // Skip documents that don't exist or can't be accessed
441
+ // This matches the behavior expected from a search operation
442
+ continue;
443
+ }
444
+ }
445
+ if (signal?.aborted) {
446
+ throw new AbortError();
447
+ }
448
+ // Apply paging
449
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
450
+ const limit = paging?.limit || documents.length;
451
+ const pagedDocuments = documents.slice(startIndex, startIndex + limit);
452
+ // Create paged results
453
+ const hasMore = startIndex + limit < documents.length;
454
+ const nextCursor = hasMore ? String(startIndex + limit) : undefined;
455
+ return {
456
+ results: pagedDocuments,
457
+ options: paging || { cursor: "0", limit: documents.length },
458
+ nextCursor,
459
+ next: hasMore
460
+ ? () => this.findBySlugs(slugs, view, { cursor: nextCursor, limit }, signal)
461
+ : undefined,
462
+ };
463
+ }
464
+ /**
465
+ * Finds all documents
466
+ */
467
+ async findAll(view, paging, signal) {
468
+ const documents = [];
469
+ // Get all drives
470
+ const drives = await this.driveServer.getDrives();
471
+ for (const driveId of drives) {
472
+ if (signal?.aborted) {
473
+ throw new AbortError();
474
+ }
475
+ const documentIds = await this.driveServer.getDocuments(driveId);
476
+ for (const docId of documentIds) {
477
+ const document = await this.driveServer.getDocument(docId);
478
+ if (document) {
479
+ // Apply view filter
480
+ for (const scope in document.state) {
481
+ if (!matchesScope(view, scope)) {
482
+ // eslint-disable-next-line
483
+ delete document.state[scope];
484
+ }
485
+ }
486
+ documents.push(document);
487
+ }
488
+ }
489
+ }
490
+ if (signal?.aborted) {
491
+ throw new AbortError();
492
+ }
493
+ // Apply paging
494
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
495
+ const limit = paging?.limit || documents.length;
496
+ const pagedDocuments = documents.slice(startIndex, startIndex + limit);
497
+ // Create paged results
498
+ const hasMore = startIndex + limit < documents.length;
499
+ const nextCursor = hasMore ? String(startIndex + limit) : undefined;
500
+ return {
501
+ results: pagedDocuments,
502
+ options: paging || { cursor: "0", limit: documents.length },
503
+ nextCursor,
504
+ next: hasMore
505
+ ? async () => this.findAll(view, { cursor: nextCursor, limit }, signal)
506
+ : undefined,
507
+ };
508
+ }
509
+ /**
510
+ * Finds documents by parent ID
511
+ */
512
+ async findByParentId(parentId, view, paging, signal) {
513
+ // Get child document IDs from the drive server
514
+ const childIds = await this.driveServer.getDocuments(parentId);
515
+ if (signal?.aborted) {
516
+ throw new AbortError();
517
+ }
518
+ const documents = [];
519
+ // Fetch each child document
520
+ for (const childId of childIds) {
521
+ if (signal?.aborted) {
522
+ throw new AbortError();
523
+ }
524
+ try {
525
+ const document = await this.driveServer.getDocument(childId);
526
+ // Apply view filter - This will be removed when we pass the viewfilter along
527
+ // to the underlying store, but is here now for the interface.
528
+ for (const scope in document.state) {
529
+ if (!matchesScope(view, scope)) {
530
+ // eslint-disable-next-line
531
+ delete document.state[scope];
532
+ }
533
+ }
534
+ documents.push(document);
535
+ }
536
+ catch {
537
+ // Skip documents that don't exist or can't be accessed
538
+ // This matches the behavior expected from a search operation
539
+ continue;
540
+ }
541
+ }
542
+ if (signal?.aborted) {
543
+ throw new AbortError();
544
+ }
545
+ // Apply paging
546
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
547
+ const limit = paging?.limit || documents.length;
548
+ const pagedDocuments = documents.slice(startIndex, startIndex + limit);
549
+ // Create paged results
550
+ const hasMore = startIndex + limit < documents.length;
551
+ const nextCursor = hasMore ? String(startIndex + limit) : undefined;
552
+ return {
553
+ results: pagedDocuments,
554
+ options: paging || { cursor: "0", limit: documents.length },
555
+ nextCursor,
556
+ next: hasMore
557
+ ? () => this.findByParentId(parentId, view, { cursor: nextCursor, limit }, signal)
558
+ : undefined,
559
+ };
560
+ }
561
+ /**
562
+ * Finds documents by type
563
+ */
564
+ async findByType(type, view, paging, signal) {
565
+ const documents = [];
566
+ // Get all drives
567
+ const drives = await this.driveServer.getDrives();
568
+ for (const driveId of drives) {
569
+ if (signal?.aborted) {
570
+ throw new AbortError();
571
+ }
572
+ const documentIds = await this.driveServer.getDocuments(driveId);
573
+ for (const docId of documentIds) {
574
+ const document = await this.driveServer.getDocument(docId);
575
+ if (document && document.header.documentType === type) {
576
+ // Apply view filter
577
+ for (const scope in document.state) {
578
+ if (!matchesScope(view, scope)) {
579
+ // eslint-disable-next-line
580
+ delete document.state[scope];
581
+ }
582
+ }
583
+ documents.push(document);
584
+ }
585
+ }
586
+ }
587
+ if (signal?.aborted) {
588
+ throw new AbortError();
589
+ }
590
+ // Apply paging
591
+ const startIndex = paging ? parseInt(paging.cursor) || 0 : 0;
592
+ const limit = paging?.limit || documents.length;
593
+ const pagedDocuments = documents.slice(startIndex, startIndex + limit);
594
+ // Create paged results
595
+ const hasMore = startIndex + limit < documents.length;
596
+ const nextCursor = hasMore ? String(startIndex + limit) : undefined;
597
+ return {
598
+ results: pagedDocuments,
599
+ options: paging || { cursor: "0", limit: documents.length },
600
+ nextCursor,
601
+ next: hasMore
602
+ ? async () => this.findByType(type, view, { cursor: nextCursor, limit }, signal)
603
+ : undefined,
604
+ };
605
+ }
606
+ }
607
+ //# sourceMappingURL=reactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactor.js","sourceRoot":"","sources":["../../src/reactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAQzD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,SAAS,GAQV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,O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CAAC,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,SAAS,CAAC,MAAM,CAAC;QAChD,MAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC,CAAC;QAEvE,uBAAuB;QACvB,MAAM,OAAO,GAAG,UAAU,GAAG,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC;QACtD,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEpE,OAAO;YACL,OAAO,EAAE,cAAc;YACvB,OAAO,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE;YAC3D,UAAU;YACV,IAAI,EAAE,OAAO;gBACX,CAAC,CAAC,KAAK,IAAI,EAAE,CACT,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,UAAW,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC;gBACvE,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { type ShutdownStatus } from "./types.js";
2
+ /**
3
+ * Factory method to create a ShutdownStatus object
4
+ *
5
+ * @param isShutdown - Initial shutdown state
6
+ * @returns A ShutdownStatus object with a getter for the shutdown state
7
+ */
8
+ export declare function createShutdownStatus(isShutdown: boolean): ShutdownStatus;
9
+ /**
10
+ * Factory method to create a ShutdownStatus that can be updated
11
+ *
12
+ * @param initialState - Initial shutdown state (default: false)
13
+ * @returns A tuple of [ShutdownStatus, setter function]
14
+ */
15
+ export declare function createMutableShutdownStatus(initialState?: boolean): [ShutdownStatus, (value: boolean) => void];
16
+ //# sourceMappingURL=factories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/shared/factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,cAAc,CAQxE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,UAAQ,GACnB,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,CAc5C"}