@powerhousedao/reactor 5.1.0 → 5.2.0-staging.10

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 (140) hide show
  1. package/dist/src/cache/document-meta-cache-types.d.ts +114 -0
  2. package/dist/src/cache/document-meta-cache-types.d.ts.map +1 -0
  3. package/dist/src/cache/document-meta-cache-types.js +2 -0
  4. package/dist/src/cache/document-meta-cache-types.js.map +1 -0
  5. package/dist/src/cache/document-meta-cache.d.ts +30 -0
  6. package/dist/src/cache/document-meta-cache.d.ts.map +1 -0
  7. package/dist/src/cache/document-meta-cache.js +127 -0
  8. package/dist/src/cache/document-meta-cache.js.map +1 -0
  9. package/dist/src/cache/kysely-operation-index.d.ts +4 -2
  10. package/dist/src/cache/kysely-operation-index.d.ts.map +1 -1
  11. package/dist/src/cache/kysely-operation-index.js +54 -0
  12. package/dist/src/cache/kysely-operation-index.js.map +1 -1
  13. package/dist/src/cache/operation-index-types.d.ts +3 -2
  14. package/dist/src/cache/operation-index-types.d.ts.map +1 -1
  15. package/dist/src/cache/operation-index-types.js.map +1 -1
  16. package/dist/src/client/reactor-client.d.ts +6 -6
  17. package/dist/src/client/reactor-client.d.ts.map +1 -1
  18. package/dist/src/client/reactor-client.js +48 -45
  19. package/dist/src/client/reactor-client.js.map +1 -1
  20. package/dist/src/client/types.d.ts +10 -10
  21. package/dist/src/client/types.d.ts.map +1 -1
  22. package/dist/src/core/reactor-builder.d.ts +9 -3
  23. package/dist/src/core/reactor-builder.d.ts.map +1 -1
  24. package/dist/src/core/reactor-builder.js +81 -29
  25. package/dist/src/core/reactor-builder.js.map +1 -1
  26. package/dist/src/core/{builder.d.ts → reactor-client-builder.d.ts} +11 -4
  27. package/dist/src/core/reactor-client-builder.d.ts.map +1 -0
  28. package/dist/src/core/{builder.js → reactor-client-builder.js} +43 -23
  29. package/dist/src/core/reactor-client-builder.js.map +1 -0
  30. package/dist/src/core/reactor.d.ts +11 -14
  31. package/dist/src/core/reactor.d.ts.map +1 -1
  32. package/dist/src/core/reactor.js +47 -43
  33. package/dist/src/core/reactor.js.map +1 -1
  34. package/dist/src/core/types.d.ts +84 -20
  35. package/dist/src/core/types.d.ts.map +1 -1
  36. package/dist/src/core/utils.d.ts +9 -0
  37. package/dist/src/core/utils.d.ts.map +1 -1
  38. package/dist/src/core/utils.js +30 -0
  39. package/dist/src/core/utils.js.map +1 -1
  40. package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
  41. package/dist/src/executor/simple-job-executor-manager.js +1 -0
  42. package/dist/src/executor/simple-job-executor-manager.js.map +1 -1
  43. package/dist/src/executor/simple-job-executor.d.ts +7 -1
  44. package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
  45. package/dist/src/executor/simple-job-executor.js +142 -21
  46. package/dist/src/executor/simple-job-executor.js.map +1 -1
  47. package/dist/src/index.d.ts +13 -6
  48. package/dist/src/index.d.ts.map +1 -1
  49. package/dist/src/index.js +9 -3
  50. package/dist/src/index.js.map +1 -1
  51. package/dist/src/logging/console.d.ts +13 -0
  52. package/dist/src/logging/console.d.ts.map +1 -0
  53. package/dist/src/logging/console.js +77 -0
  54. package/dist/src/logging/console.js.map +1 -0
  55. package/dist/src/logging/types.d.ts +11 -0
  56. package/dist/src/logging/types.d.ts.map +1 -0
  57. package/dist/src/logging/types.js +2 -0
  58. package/dist/src/logging/types.js.map +1 -0
  59. package/dist/src/read-models/base-read-model.d.ts +60 -0
  60. package/dist/src/read-models/base-read-model.d.ts.map +1 -0
  61. package/dist/src/read-models/base-read-model.js +143 -0
  62. package/dist/src/read-models/base-read-model.js.map +1 -0
  63. package/dist/src/read-models/document-view.d.ts +6 -7
  64. package/dist/src/read-models/document-view.d.ts.map +1 -1
  65. package/dist/src/read-models/document-view.js +16 -81
  66. package/dist/src/read-models/document-view.js.map +1 -1
  67. package/dist/src/read-models/types.d.ts +2 -1
  68. package/dist/src/read-models/types.d.ts.map +1 -1
  69. package/dist/src/shared/errors.d.ts +8 -0
  70. package/dist/src/shared/errors.d.ts.map +1 -1
  71. package/dist/src/shared/errors.js +14 -0
  72. package/dist/src/shared/errors.js.map +1 -1
  73. package/dist/src/signer/types.d.ts +23 -1
  74. package/dist/src/signer/types.d.ts.map +1 -1
  75. package/dist/src/storage/consistency-aware-legacy-storage.d.ts +33 -0
  76. package/dist/src/storage/consistency-aware-legacy-storage.d.ts.map +1 -0
  77. package/dist/src/storage/consistency-aware-legacy-storage.js +65 -0
  78. package/dist/src/storage/consistency-aware-legacy-storage.js.map +1 -0
  79. package/dist/src/storage/interfaces.d.ts +81 -0
  80. package/dist/src/storage/interfaces.d.ts.map +1 -1
  81. package/dist/src/storage/interfaces.js.map +1 -1
  82. package/dist/src/storage/kysely/store.d.ts.map +1 -1
  83. package/dist/src/storage/kysely/store.js +1 -0
  84. package/dist/src/storage/kysely/store.js.map +1 -1
  85. package/dist/src/storage/kysely/sync-remote-storage.d.ts.map +1 -1
  86. package/dist/src/storage/kysely/sync-remote-storage.js +3 -4
  87. package/dist/src/storage/kysely/sync-remote-storage.js.map +1 -1
  88. package/dist/src/storage/migrations/008_create_view_state_table.d.ts +1 -1
  89. package/dist/src/storage/migrations/008_create_view_state_table.d.ts.map +1 -1
  90. package/dist/src/storage/migrations/008_create_view_state_table.js +2 -1
  91. package/dist/src/storage/migrations/008_create_view_state_table.js.map +1 -1
  92. package/dist/src/storage/migrations/run-migrations.js +3 -3
  93. package/dist/src/storage/migrations/run-migrations.js.map +1 -1
  94. package/dist/src/sync/channels/composite-channel-factory.d.ts +27 -0
  95. package/dist/src/sync/channels/composite-channel-factory.d.ts.map +1 -0
  96. package/dist/src/sync/channels/composite-channel-factory.js +83 -0
  97. package/dist/src/sync/channels/composite-channel-factory.js.map +1 -0
  98. package/dist/src/sync/channels/gql-channel-factory.d.ts +22 -0
  99. package/dist/src/sync/channels/gql-channel-factory.d.ts.map +1 -0
  100. package/dist/src/sync/channels/gql-channel-factory.js +72 -0
  101. package/dist/src/sync/channels/gql-channel-factory.js.map +1 -0
  102. package/dist/src/sync/channels/gql-channel.d.ts +104 -0
  103. package/dist/src/sync/channels/gql-channel.d.ts.map +1 -0
  104. package/dist/src/sync/channels/gql-channel.js +362 -0
  105. package/dist/src/sync/channels/gql-channel.js.map +1 -0
  106. package/dist/src/sync/channels/index.d.ts +4 -1
  107. package/dist/src/sync/channels/index.d.ts.map +1 -1
  108. package/dist/src/sync/channels/index.js +4 -1
  109. package/dist/src/sync/channels/index.js.map +1 -1
  110. package/dist/src/sync/channels/polling-channel.d.ts +39 -0
  111. package/dist/src/sync/channels/polling-channel.d.ts.map +1 -0
  112. package/dist/src/sync/channels/polling-channel.js +70 -0
  113. package/dist/src/sync/channels/polling-channel.js.map +1 -0
  114. package/dist/src/sync/errors.d.ts +1 -1
  115. package/dist/src/sync/errors.d.ts.map +1 -1
  116. package/dist/src/sync/errors.js +2 -2
  117. package/dist/src/sync/errors.js.map +1 -1
  118. package/dist/src/sync/index.d.ts +2 -2
  119. package/dist/src/sync/index.d.ts.map +1 -1
  120. package/dist/src/sync/index.js +2 -2
  121. package/dist/src/sync/index.js.map +1 -1
  122. package/dist/src/sync/interfaces.d.ts +33 -3
  123. package/dist/src/sync/interfaces.d.ts.map +1 -1
  124. package/dist/src/sync/sync-builder.d.ts +2 -1
  125. package/dist/src/sync/sync-builder.d.ts.map +1 -1
  126. package/dist/src/sync/sync-builder.js +11 -1
  127. package/dist/src/sync/sync-builder.js.map +1 -1
  128. package/dist/src/sync/sync-manager.d.ts +5 -2
  129. package/dist/src/sync/sync-manager.d.ts.map +1 -1
  130. package/dist/src/sync/sync-manager.js +70 -5
  131. package/dist/src/sync/sync-manager.js.map +1 -1
  132. package/dist/src/sync/types.d.ts +1 -2
  133. package/dist/src/sync/types.d.ts.map +1 -1
  134. package/package.json +6 -5
  135. package/dist/src/core/builder.d.ts.map +0 -1
  136. package/dist/src/core/builder.js.map +0 -1
  137. package/dist/src/sync/channels/internal-channel.d.ts +0 -57
  138. package/dist/src/sync/channels/internal-channel.d.ts.map +0 -1
  139. package/dist/src/sync/channels/internal-channel.js +0 -106
  140. package/dist/src/sync/channels/internal-channel.js.map +0 -1
@@ -1,57 +0,0 @@
1
- import type { ISyncCursorStorage } from "../../storage/interfaces.js";
2
- import type { IChannel } from "../interfaces.js";
3
- import type { SyncOperation } from "../sync-operation.js";
4
- import { Mailbox } from "../mailbox.js";
5
- import type { SyncEnvelope } from "../types.js";
6
- /**
7
- * In-memory synchronization channel for testing purposes only.
8
- *
9
- * InternalChannel enables direct bidirectional communication between two reactor
10
- * instances without network transport. Channels are wired together by passing
11
- * a send function that delivers envelopes to the peer's inbox.
12
- */
13
- export declare class InternalChannel implements IChannel {
14
- readonly inbox: Mailbox<SyncOperation>;
15
- readonly outbox: Mailbox<SyncOperation>;
16
- readonly deadLetter: Mailbox<SyncOperation>;
17
- private readonly channelId;
18
- private readonly remoteName;
19
- private readonly cursorStorage;
20
- private readonly send;
21
- private isShutdown;
22
- constructor(channelId: string, remoteName: string, cursorStorage: ISyncCursorStorage, send: (envelope: SyncEnvelope) => void);
23
- /**
24
- * Shuts down the channel and prevents further operations.
25
- */
26
- shutdown(): void;
27
- /**
28
- * Receives a sync envelope from a peer channel.
29
- *
30
- * This method is called by the peer's send function to deliver an envelope
31
- * to this channel's inbox.
32
- *
33
- * @param envelope - The sync envelope to receive
34
- * @throws {InternalChannelError} If channel is shutdown
35
- */
36
- receive(envelope: SyncEnvelope): void;
37
- /**
38
- * Updates the synchronization cursor for this channel's remote.
39
- *
40
- * Cursors track progress through the operation stream and enable resuming
41
- * synchronization after restarts. The cursor is exclusive - the next sync
42
- * will start at cursorOrdinal + 1.
43
- *
44
- * @param cursorOrdinal - The last processed ordinal (exclusive)
45
- */
46
- updateCursor(cursorOrdinal: number): Promise<void>;
47
- /**
48
- * Handles sync operations added to the outbox by sending them to the peer.
49
- *
50
- * This method is called automatically via the outbox.onAdded callback.
51
- * It converts the sync operation to a SyncEnvelope and sends it via the send function.
52
- *
53
- * @param syncOp - The sync operation to transport
54
- */
55
- private handleOutboxAdded;
56
- }
57
- //# sourceMappingURL=internal-channel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-channel.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/internal-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AAI9D;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmC;IACxD,OAAO,CAAC,UAAU,CAAU;gBAG1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,kBAAkB,EACjC,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI;IAiBxC;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAcrC;;;;;;;;OAQG;IACG,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxD;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;CAuB1B"}
@@ -1,106 +0,0 @@
1
- import { ChannelError, InternalChannelError } from "../errors.js";
2
- import { Mailbox } from "../mailbox.js";
3
- import { ChannelErrorSource } from "../types.js";
4
- import { envelopeToSyncOperation } from "./utils.js";
5
- /**
6
- * In-memory synchronization channel for testing purposes only.
7
- *
8
- * InternalChannel enables direct bidirectional communication between two reactor
9
- * instances without network transport. Channels are wired together by passing
10
- * a send function that delivers envelopes to the peer's inbox.
11
- */
12
- export class InternalChannel {
13
- inbox;
14
- outbox;
15
- deadLetter;
16
- channelId;
17
- remoteName;
18
- cursorStorage;
19
- send;
20
- isShutdown;
21
- constructor(channelId, remoteName, cursorStorage, send) {
22
- this.channelId = channelId;
23
- this.remoteName = remoteName;
24
- this.cursorStorage = cursorStorage;
25
- this.send = send;
26
- this.isShutdown = false;
27
- this.inbox = new Mailbox();
28
- this.outbox = new Mailbox();
29
- this.deadLetter = new Mailbox();
30
- this.outbox.onAdded((syncOp) => {
31
- this.handleOutboxAdded(syncOp);
32
- });
33
- }
34
- /**
35
- * Shuts down the channel and prevents further operations.
36
- */
37
- shutdown() {
38
- this.isShutdown = true;
39
- }
40
- /**
41
- * Receives a sync envelope from a peer channel.
42
- *
43
- * This method is called by the peer's send function to deliver an envelope
44
- * to this channel's inbox.
45
- *
46
- * @param envelope - The sync envelope to receive
47
- * @throws {InternalChannelError} If channel is shutdown
48
- */
49
- receive(envelope) {
50
- if (this.isShutdown) {
51
- throw new InternalChannelError(`Channel ${this.channelId} is shutdown and cannot receive envelopes`);
52
- }
53
- if (envelope.type === "operations" && envelope.operations) {
54
- const syncOp = envelopeToSyncOperation(envelope, this.remoteName);
55
- syncOp.transported();
56
- this.inbox.add(syncOp);
57
- }
58
- }
59
- /**
60
- * Updates the synchronization cursor for this channel's remote.
61
- *
62
- * Cursors track progress through the operation stream and enable resuming
63
- * synchronization after restarts. The cursor is exclusive - the next sync
64
- * will start at cursorOrdinal + 1.
65
- *
66
- * @param cursorOrdinal - The last processed ordinal (exclusive)
67
- */
68
- async updateCursor(cursorOrdinal) {
69
- const cursor = {
70
- remoteName: this.remoteName,
71
- cursorOrdinal,
72
- lastSyncedAtUtcMs: Date.now(),
73
- };
74
- await this.cursorStorage.upsert(cursor);
75
- }
76
- /**
77
- * Handles sync operations added to the outbox by sending them to the peer.
78
- *
79
- * This method is called automatically via the outbox.onAdded callback.
80
- * It converts the sync operation to a SyncEnvelope and sends it via the send function.
81
- *
82
- * @param syncOp - The sync operation to transport
83
- */
84
- handleOutboxAdded(syncOp) {
85
- if (this.isShutdown) {
86
- return;
87
- }
88
- try {
89
- syncOp.started();
90
- const envelope = {
91
- type: "operations",
92
- channelMeta: { id: this.channelId },
93
- operations: syncOp.operations,
94
- };
95
- this.send(envelope);
96
- }
97
- catch (error) {
98
- const err = error instanceof Error ? error : new Error(String(error));
99
- const channelError = new ChannelError(ChannelErrorSource.Outbox, err);
100
- syncOp.failed(channelError);
101
- this.deadLetter.add(syncOp);
102
- this.outbox.remove(syncOp);
103
- }
104
- }
105
- }
106
- //# sourceMappingURL=internal-channel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-channel.js","sourceRoot":"","sources":["../../../../src/sync/channels/internal-channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACjB,KAAK,CAAyB;IAC9B,MAAM,CAAyB;IAC/B,UAAU,CAAyB;IAE3B,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,aAAa,CAAqB;IAClC,IAAI,CAAmC;IAChD,UAAU,CAAU;IAE5B,YACE,SAAiB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