@powerhousedao/reactor 4.1.0-dev.7 → 4.1.0-dev.71

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 (173) hide show
  1. package/dist/src/client/reactor-client.d.ts +103 -0
  2. package/dist/src/client/reactor-client.d.ts.map +1 -0
  3. package/dist/src/client/reactor-client.js +184 -0
  4. package/dist/src/client/reactor-client.js.map +1 -0
  5. package/dist/src/client/types.d.ts +213 -0
  6. package/dist/src/client/types.d.ts.map +1 -0
  7. package/dist/src/client/types.js +14 -0
  8. package/dist/src/client/types.js.map +1 -0
  9. package/dist/src/core/builder.d.ts +20 -0
  10. package/dist/src/core/builder.d.ts.map +1 -0
  11. package/dist/src/core/builder.js +47 -0
  12. package/dist/src/core/builder.js.map +1 -0
  13. package/dist/src/core/reactor.d.ts +98 -0
  14. package/dist/src/core/reactor.d.ts.map +1 -0
  15. package/dist/src/core/reactor.js +630 -0
  16. package/dist/src/core/reactor.js.map +1 -0
  17. package/dist/src/core/types.d.ts +121 -0
  18. package/dist/src/core/types.d.ts.map +1 -0
  19. package/dist/src/core/types.js +2 -0
  20. package/dist/src/core/types.js.map +1 -0
  21. package/dist/src/core/utils.d.ts +11 -0
  22. package/dist/src/core/utils.d.ts.map +1 -0
  23. package/dist/src/core/utils.js +31 -0
  24. package/dist/src/core/utils.js.map +1 -0
  25. package/dist/src/events/event-bus.d.ts +3 -3
  26. package/dist/src/events/event-bus.d.ts.map +1 -1
  27. package/dist/src/events/event-bus.js.map +1 -1
  28. package/dist/src/events/interfaces.d.ts +1 -1
  29. package/dist/src/events/interfaces.d.ts.map +1 -1
  30. package/dist/src/events/types.d.ts +1 -1
  31. package/dist/src/events/types.d.ts.map +1 -1
  32. package/dist/src/events/types.js.map +1 -1
  33. package/dist/src/executor/interfaces.d.ts +31 -54
  34. package/dist/src/executor/interfaces.d.ts.map +1 -1
  35. package/dist/src/executor/simple-job-executor-manager.d.ts +27 -0
  36. package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -0
  37. package/dist/src/executor/simple-job-executor-manager.js +128 -0
  38. package/dist/src/executor/simple-job-executor-manager.js.map +1 -0
  39. package/dist/src/executor/simple-job-executor.d.ts +29 -0
  40. package/dist/src/executor/simple-job-executor.d.ts.map +1 -0
  41. package/dist/src/executor/simple-job-executor.js +154 -0
  42. package/dist/src/executor/simple-job-executor.js.map +1 -0
  43. package/dist/src/executor/types.d.ts +23 -8
  44. package/dist/src/executor/types.d.ts.map +1 -1
  45. package/dist/src/executor/types.js.map +1 -1
  46. package/dist/src/index.d.ts +19 -2
  47. package/dist/src/index.d.ts.map +1 -1
  48. package/dist/src/index.js +25 -1
  49. package/dist/src/index.js.map +1 -1
  50. package/dist/src/queue/interfaces.d.ts +45 -5
  51. package/dist/src/queue/interfaces.d.ts.map +1 -1
  52. package/dist/src/queue/job-execution-handle.d.ts +24 -0
  53. package/dist/src/queue/job-execution-handle.d.ts.map +1 -0
  54. package/dist/src/queue/job-execution-handle.js +62 -0
  55. package/dist/src/queue/job-execution-handle.js.map +1 -0
  56. package/dist/src/queue/queue.d.ts +54 -5
  57. package/dist/src/queue/queue.d.ts.map +1 -1
  58. package/dist/src/queue/queue.js +265 -36
  59. package/dist/src/queue/queue.js.map +1 -1
  60. package/dist/src/queue/types.d.ts +26 -1
  61. package/dist/src/queue/types.d.ts.map +1 -1
  62. package/dist/src/queue/types.js +12 -0
  63. package/dist/src/queue/types.js.map +1 -1
  64. package/dist/src/read-models/document-view.d.ts +21 -0
  65. package/dist/src/read-models/document-view.d.ts.map +1 -0
  66. package/dist/src/read-models/document-view.js +285 -0
  67. package/dist/src/read-models/document-view.js.map +1 -0
  68. package/dist/src/read-models/types.d.ts +46 -0
  69. package/dist/src/read-models/types.d.ts.map +1 -0
  70. package/dist/src/read-models/types.js +2 -0
  71. package/dist/src/read-models/types.js.map +1 -0
  72. package/dist/src/registry/implementation.d.ts +62 -0
  73. package/dist/src/registry/implementation.d.ts.map +1 -0
  74. package/dist/src/registry/implementation.js +96 -0
  75. package/dist/src/registry/implementation.js.map +1 -0
  76. package/dist/src/registry/index.d.ts +3 -0
  77. package/dist/src/registry/index.d.ts.map +1 -0
  78. package/dist/src/registry/index.js +2 -0
  79. package/dist/src/registry/index.js.map +1 -0
  80. package/dist/src/registry/interfaces.d.ts +39 -0
  81. package/dist/src/registry/interfaces.d.ts.map +1 -0
  82. package/dist/src/registry/interfaces.js +2 -0
  83. package/dist/src/registry/interfaces.js.map +1 -0
  84. package/dist/src/shared/awaiter.d.ts +32 -0
  85. package/dist/src/shared/awaiter.d.ts.map +1 -0
  86. package/dist/src/shared/awaiter.js +132 -0
  87. package/dist/src/shared/awaiter.js.map +1 -0
  88. package/dist/src/shared/errors.d.ts +9 -0
  89. package/dist/src/shared/errors.d.ts.map +1 -0
  90. package/dist/src/shared/errors.js +18 -0
  91. package/dist/src/shared/errors.js.map +1 -0
  92. package/dist/src/shared/factories.d.ts +16 -0
  93. package/dist/src/shared/factories.d.ts.map +1 -0
  94. package/dist/src/shared/factories.js +33 -0
  95. package/dist/src/shared/factories.js.map +1 -0
  96. package/dist/src/shared/types.d.ts +91 -19
  97. package/dist/src/shared/types.d.ts.map +1 -1
  98. package/dist/src/shared/types.js +35 -1
  99. package/dist/src/shared/types.js.map +1 -1
  100. package/dist/src/shared/utils.d.ts +3 -0
  101. package/dist/src/shared/utils.d.ts.map +1 -0
  102. package/dist/src/shared/utils.js +8 -0
  103. package/dist/src/shared/utils.js.map +1 -0
  104. package/dist/src/signer/passthrough-signer.d.ts +6 -0
  105. package/dist/src/signer/passthrough-signer.d.ts.map +1 -0
  106. package/dist/src/signer/passthrough-signer.js +6 -0
  107. package/dist/src/signer/passthrough-signer.js.map +1 -0
  108. package/dist/src/signer/types.d.ts +15 -0
  109. package/dist/src/signer/types.d.ts.map +1 -0
  110. package/dist/src/signer/types.js +2 -0
  111. package/dist/src/signer/types.js.map +1 -0
  112. package/dist/src/storage/interfaces.d.ts +125 -0
  113. package/dist/src/storage/interfaces.d.ts.map +1 -0
  114. package/dist/src/storage/interfaces.js +19 -0
  115. package/dist/src/storage/interfaces.js.map +1 -0
  116. package/dist/src/storage/kysely/store.d.ts +15 -0
  117. package/dist/src/storage/kysely/store.d.ts.map +1 -0
  118. package/dist/src/storage/kysely/store.js +173 -0
  119. package/dist/src/storage/kysely/store.js.map +1 -0
  120. package/dist/src/storage/kysely/types.d.ts +26 -0
  121. package/dist/src/storage/kysely/types.d.ts.map +1 -0
  122. package/dist/src/storage/kysely/types.js +2 -0
  123. package/dist/src/storage/kysely/types.js.map +1 -0
  124. package/dist/src/storage/txn.d.ts +15 -0
  125. package/dist/src/storage/txn.d.ts.map +1 -0
  126. package/dist/src/storage/txn.js +42 -0
  127. package/dist/src/storage/txn.js.map +1 -0
  128. package/dist/src/subs/default-error-handler.d.ts +13 -0
  129. package/dist/src/subs/default-error-handler.d.ts.map +1 -0
  130. package/dist/src/subs/default-error-handler.js +27 -0
  131. package/dist/src/subs/default-error-handler.js.map +1 -0
  132. package/dist/src/subs/react-subscription-manager.d.ts +45 -0
  133. package/dist/src/subs/react-subscription-manager.d.ts.map +1 -0
  134. package/dist/src/subs/react-subscription-manager.js +185 -0
  135. package/dist/src/subs/react-subscription-manager.js.map +1 -0
  136. package/dist/src/subs/types.d.ts +64 -0
  137. package/dist/src/subs/types.d.ts.map +1 -0
  138. package/dist/src/subs/types.js +2 -0
  139. package/dist/src/subs/types.js.map +1 -0
  140. package/package.json +13 -5
  141. package/dist/bench/end-to-end-flow.bench.d.ts +0 -2
  142. package/dist/bench/end-to-end-flow.bench.d.ts.map +0 -1
  143. package/dist/bench/end-to-end-flow.bench.js +0 -256
  144. package/dist/bench/end-to-end-flow.bench.js.map +0 -1
  145. package/dist/bench/event-bus.bench.d.ts +0 -2
  146. package/dist/bench/event-bus.bench.d.ts.map +0 -1
  147. package/dist/bench/event-bus.bench.js +0 -238
  148. package/dist/bench/event-bus.bench.js.map +0 -1
  149. package/dist/bench/queue-only.bench.d.ts +0 -2
  150. package/dist/bench/queue-only.bench.d.ts.map +0 -1
  151. package/dist/bench/queue-only.bench.js +0 -40
  152. package/dist/bench/queue-only.bench.js.map +0 -1
  153. package/dist/bench/reactor-throughput.bench.d.ts +0 -2
  154. package/dist/bench/reactor-throughput.bench.d.ts.map +0 -1
  155. package/dist/bench/reactor-throughput.bench.js +0 -137
  156. package/dist/bench/reactor-throughput.bench.js.map +0 -1
  157. package/dist/src/executor/job-executor.d.ts +0 -62
  158. package/dist/src/executor/job-executor.d.ts.map +0 -1
  159. package/dist/src/executor/job-executor.js +0 -325
  160. package/dist/src/executor/job-executor.js.map +0 -1
  161. package/dist/test/event-bus.test.d.ts +0 -2
  162. package/dist/test/event-bus.test.d.ts.map +0 -1
  163. package/dist/test/event-bus.test.js +0 -532
  164. package/dist/test/event-bus.test.js.map +0 -1
  165. package/dist/test/job-executor.test.d.ts +0 -2
  166. package/dist/test/job-executor.test.d.ts.map +0 -1
  167. package/dist/test/job-executor.test.js +0 -581
  168. package/dist/test/job-executor.test.js.map +0 -1
  169. package/dist/test/queue.test.d.ts +0 -2
  170. package/dist/test/queue.test.d.ts.map +0 -1
  171. package/dist/test/queue.test.js +0 -396
  172. package/dist/test/queue.test.js.map +0 -1
  173. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,15 @@
1
+ import type { Kysely } from "kysely";
2
+ import { type AtomicTxn, type DocumentRevisions, type IOperationStore, type OperationWithContext } from "../interfaces.js";
3
+ import type { Database } from "./types.js";
4
+ export declare class KyselyOperationStore implements IOperationStore {
5
+ private db;
6
+ constructor(db: Kysely<Database>);
7
+ apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<void>;
8
+ get(documentId: string, scope: string, branch: string, index: number, signal?: AbortSignal): Promise<OperationWithContext>;
9
+ getSince(documentId: string, scope: string, branch: string, index: number, signal?: AbortSignal): Promise<OperationWithContext[]>;
10
+ getSinceTimestamp(documentId: string, scope: string, branch: string, timestampUtcMs: number, signal?: AbortSignal): Promise<OperationWithContext[]>;
11
+ getSinceId(id: number, signal?: AbortSignal): Promise<OperationWithContext[]>;
12
+ getRevisions(documentId: string, branch: string, signal?: AbortSignal): Promise<DocumentRevisions>;
13
+ private rowToOperationWithContext;
14
+ }
15
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/storage/kysely/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAEzD,qBAAa,oBAAqB,YAAW,eAAe;IAC9C,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC;IAElC,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC5C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAiEV,GAAG,CACP,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAuB1B,QAAQ,CACZ,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAkB5B,iBAAiB,CACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAkB5B,UAAU,CACd,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAe5B,YAAY,CAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,iBAAiB,CAAC;IA4C7B,OAAO,CAAC,yBAAyB;CAoBlC"}
@@ -0,0 +1,173 @@
1
+ import {} from "document-model";
2
+ import { DuplicateOperationError, RevisionMismatchError, } from "../interfaces.js";
3
+ import { AtomicTransaction } from "../txn.js";
4
+ export class KyselyOperationStore {
5
+ db;
6
+ constructor(db) {
7
+ this.db = db;
8
+ }
9
+ async apply(documentId, documentType, scope, branch, revision, fn, signal) {
10
+ await this.db.transaction().execute(async (trx) => {
11
+ // Check for abort signal
12
+ if (signal?.aborted) {
13
+ throw new Error("Operation aborted");
14
+ }
15
+ // Get the latest operation for this stream to verify revision
16
+ const latestOp = await trx
17
+ .selectFrom("Operation")
18
+ .selectAll()
19
+ .where("documentId", "=", documentId)
20
+ .where("scope", "=", scope)
21
+ .where("branch", "=", branch)
22
+ .orderBy("index", "desc")
23
+ .limit(1)
24
+ .executeTakeFirst();
25
+ // Check revision matches
26
+ const currentRevision = latestOp ? latestOp.index : -1;
27
+ if (currentRevision !== revision - 1) {
28
+ throw new RevisionMismatchError(revision - 1, currentRevision);
29
+ }
30
+ // Create atomic transaction
31
+ const atomicTxn = new AtomicTransaction(documentId, documentType, scope, branch, revision);
32
+ await fn(atomicTxn);
33
+ // Get operations and header updates
34
+ const operations = atomicTxn.getOperations();
35
+ // Insert operations
36
+ if (operations.length > 0) {
37
+ // Set prevOpId for each operation
38
+ let prevOpId = latestOp?.opId || "";
39
+ for (const op of operations) {
40
+ op.prevOpId = prevOpId;
41
+ prevOpId = op.opId;
42
+ }
43
+ try {
44
+ await trx.insertInto("Operation").values(operations).execute();
45
+ }
46
+ catch (error) {
47
+ if (error instanceof Error) {
48
+ if (error.message.includes("unique constraint")) {
49
+ // Extract the opId from the error if possible
50
+ const opId = operations[0]?.opId || "unknown";
51
+ throw new DuplicateOperationError(opId);
52
+ }
53
+ throw error;
54
+ }
55
+ throw error;
56
+ }
57
+ }
58
+ });
59
+ }
60
+ async get(documentId, scope, branch, index, signal) {
61
+ if (signal?.aborted) {
62
+ throw new Error("Operation aborted");
63
+ }
64
+ const row = await this.db
65
+ .selectFrom("Operation")
66
+ .selectAll()
67
+ .where("documentId", "=", documentId)
68
+ .where("scope", "=", scope)
69
+ .where("branch", "=", branch)
70
+ .where("index", "=", index)
71
+ .executeTakeFirst();
72
+ if (!row) {
73
+ throw new Error(`Operation not found: ${documentId}/${scope}/${branch}/${index}`);
74
+ }
75
+ return this.rowToOperationWithContext(row);
76
+ }
77
+ async getSince(documentId, scope, branch, index, signal) {
78
+ if (signal?.aborted) {
79
+ throw new Error("Operation aborted");
80
+ }
81
+ const rows = await this.db
82
+ .selectFrom("Operation")
83
+ .selectAll()
84
+ .where("documentId", "=", documentId)
85
+ .where("scope", "=", scope)
86
+ .where("branch", "=", branch)
87
+ .where("index", ">", index)
88
+ .orderBy("index", "asc")
89
+ .execute();
90
+ return rows.map((row) => this.rowToOperationWithContext(row));
91
+ }
92
+ async getSinceTimestamp(documentId, scope, branch, timestampUtcMs, signal) {
93
+ if (signal?.aborted) {
94
+ throw new Error("Operation aborted");
95
+ }
96
+ const rows = await this.db
97
+ .selectFrom("Operation")
98
+ .selectAll()
99
+ .where("documentId", "=", documentId)
100
+ .where("scope", "=", scope)
101
+ .where("branch", "=", branch)
102
+ .where("writeTimestampUtcMs", ">", new Date(timestampUtcMs))
103
+ .orderBy("index", "asc")
104
+ .execute();
105
+ return rows.map((row) => this.rowToOperationWithContext(row));
106
+ }
107
+ async getSinceId(id, signal) {
108
+ if (signal?.aborted) {
109
+ throw new Error("Operation aborted");
110
+ }
111
+ const rows = await this.db
112
+ .selectFrom("Operation")
113
+ .selectAll()
114
+ .where("id", ">", id)
115
+ .orderBy("id", "asc")
116
+ .execute();
117
+ return rows.map((row) => this.rowToOperationWithContext(row));
118
+ }
119
+ async getRevisions(documentId, branch, signal) {
120
+ if (signal?.aborted) {
121
+ throw new Error("Operation aborted");
122
+ }
123
+ // Get the latest operation for each scope in a single query
124
+ // Uses a subquery to find operations where the index equals the max index for that scope
125
+ const scopeRevisions = await this.db
126
+ .selectFrom("Operation as o1")
127
+ .select(["o1.scope", "o1.index", "o1.timestampUtcMs"])
128
+ .where("o1.documentId", "=", documentId)
129
+ .where("o1.branch", "=", branch)
130
+ .where((eb) => eb("o1.index", "=", eb
131
+ .selectFrom("Operation as o2")
132
+ .select((eb2) => eb2.fn.max("o2.index").as("maxIndex"))
133
+ .where("o2.documentId", "=", eb.ref("o1.documentId"))
134
+ .where("o2.branch", "=", eb.ref("o1.branch"))
135
+ .where("o2.scope", "=", eb.ref("o1.scope"))))
136
+ .execute();
137
+ // Build the revision map and find the latest timestamp
138
+ const revision = {};
139
+ let latestTimestamp = new Date(0).toISOString(); // Start with epoch
140
+ for (const row of scopeRevisions) {
141
+ revision[row.scope] = row.index;
142
+ const timestamp = row.timestampUtcMs.toISOString();
143
+ if (timestamp > latestTimestamp) {
144
+ latestTimestamp = timestamp;
145
+ }
146
+ }
147
+ return {
148
+ revision,
149
+ latestTimestamp,
150
+ };
151
+ }
152
+ rowToOperationWithContext(row) {
153
+ return {
154
+ operation: {
155
+ index: row.index,
156
+ timestampUtcMs: row.timestampUtcMs.toISOString(),
157
+ hash: row.hash,
158
+ skip: row.skip,
159
+ error: row.error || undefined,
160
+ resultingState: row.resultingState || undefined,
161
+ id: row.opId,
162
+ action: JSON.parse(row.action),
163
+ },
164
+ context: {
165
+ documentId: row.documentId,
166
+ documentType: row.documentType,
167
+ scope: row.scope,
168
+ branch: row.branch,
169
+ },
170
+ };
171
+ }
172
+ }
173
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/storage/kysely/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GAKtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9C,MAAM,OAAO,oBAAoB;IACX;IAApB,YAAoB,EAAoB;QAApB,OAAE,GAAF,EAAE,CAAkB;IAAG,CAAC;IAE5C,KAAK,CAAC,KAAK,CACT,UAAkB,EAClB,YAAoB,EACpB,KAAa,EACb,MAAc,EACd,QAAgB,EAChB,EAA4C,EAC5C,MAAoB;QAEpB,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAChD,yBAAyB;YACzB,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;YAED,8DAA8D;YAC9D,MAAM,QAAQ,GAAG,MAAM,GAAG;iBACvB,UAAU,CAAC,WAAW,CAAC;iBACvB,SAAS,EAAE;iBACX,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,UAAU,CAAC;iBACpC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC;iBAC1B,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC;iBAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC;iBACxB,KAAK,CAAC,CAAC,CAAC;iBACR,gBAAgB,EAAE,CAAC;YAEtB,yBA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@@
1
+ import type { Generated, Insertable, Selectable, Updateable } from "kysely";
2
+ export interface OperationTable {
3
+ id: Generated<number>;
4
+ jobId: string;
5
+ opId: string;
6
+ prevOpId: string;
7
+ writeTimestampUtcMs: Generated<Date>;
8
+ documentId: string;
9
+ documentType: string;
10
+ scope: string;
11
+ branch: string;
12
+ timestampUtcMs: Date;
13
+ index: number;
14
+ action: string;
15
+ skip: number;
16
+ resultingState?: string | null;
17
+ error?: string | null;
18
+ hash: string;
19
+ }
20
+ export interface Database {
21
+ Operation: OperationTable;
22
+ }
23
+ export type OperationRow = Selectable<OperationTable>;
24
+ export type InsertableOperation = Insertable<OperationTable>;
25
+ export type UpdateableOperation = Updateable<OperationTable>;
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/storage/kysely/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;AAC7D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/storage/kysely/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { Operation } from "document-model";
2
+ import { type AtomicTxn as IAtomicTxn } from "./interfaces.js";
3
+ import type { InsertableOperation } from "./kysely/types.js";
4
+ export declare class AtomicTransaction implements IAtomicTxn {
5
+ private documentId;
6
+ private documentType;
7
+ private scope;
8
+ private branch;
9
+ private baseRevision;
10
+ private operations;
11
+ constructor(documentId: string, documentType: string, scope: string, branch: string, baseRevision: number);
12
+ addOperations(...operations: Operation[]): void;
13
+ getOperations(): InsertableOperation[];
14
+ }
15
+ //# sourceMappingURL=txn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txn.d.ts","sourceRoot":"","sources":["../../../src/storage/txn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,KAAK,SAAS,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,qBAAa,iBAAkB,YAAW,UAAU;IAIhD,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IAPtB,OAAO,CAAC,UAAU,CAA6B;gBAGrC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM;IAK9B,aAAa,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAqB/C,aAAa,IAAI,mBAAmB,EAAE;CAGvC"}
@@ -0,0 +1,42 @@
1
+ import { v4 as uuidv4 } from "uuid";
2
+ import {} from "./interfaces.js";
3
+ export class AtomicTransaction {
4
+ documentId;
5
+ documentType;
6
+ scope;
7
+ branch;
8
+ baseRevision;
9
+ operations = [];
10
+ constructor(documentId, documentType, scope, branch, baseRevision) {
11
+ this.documentId = documentId;
12
+ this.documentType = documentType;
13
+ this.scope = scope;
14
+ this.branch = branch;
15
+ this.baseRevision = baseRevision;
16
+ //
17
+ }
18
+ addOperations(...operations) {
19
+ for (const op of operations) {
20
+ this.operations.push({
21
+ jobId: uuidv4(),
22
+ opId: op.id || uuidv4(),
23
+ prevOpId: "", // Will be set during apply
24
+ documentId: this.documentId,
25
+ documentType: this.documentType,
26
+ scope: this.scope,
27
+ branch: this.branch,
28
+ timestampUtcMs: new Date(op.timestampUtcMs),
29
+ index: op.index,
30
+ action: JSON.stringify(op.action),
31
+ skip: op.skip,
32
+ resultingState: op.resultingState || null,
33
+ error: op.error || null,
34
+ hash: op.hash,
35
+ });
36
+ }
37
+ }
38
+ getOperations() {
39
+ return this.operations;
40
+ }
41
+ }
42
+ //# sourceMappingURL=txn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txn.js","sourceRoot":"","sources":["../../../src/storage/txn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAgC,MAAM,iBAAiB,CAAC;AAG/D,MAAM,OAAO,iBAAiB;IAIlB;IACA;IACA;IACA;IACA;IAPF,UAAU,GAA0B,EAAE,CAAC;IAE/C,YACU,UAAkB,EAClB,YAAoB,EACpB,KAAa,EACb,MAAc,EACd,YAAoB;QAJpB,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAAQ;QAE5B,EAAE;IACJ,CAAC;IAED,aAAa,CAAC,GAAG,UAAuB;QACtC,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,MAAM,EAAE;gBACf,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,MAAM,EAAE;gBACvB,QAAQ,EAAE,EAAE,EAAE,2BAA2B;gBACzC,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,cAAc,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC;gBAC3C,KAAK,EAAE,EAAE,CAAC,KAAK;gBACf,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC;gBACjC,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,cAAc,EAAE,EAAE,CAAC,cAAc,IAAI,IAAI;gBACzC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI;gBACvB,IAAI,EAAE,EAAE,CAAC,IAAI;aACd,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import type { ISubscriptionErrorHandler, SubscriptionErrorContext } from "./types.js";
2
+ /**
3
+ * Default error handler that re-throws subscription errors.
4
+ * This ensures that errors are not silently swallowed.
5
+ */
6
+ export declare class DefaultSubscriptionErrorHandler implements ISubscriptionErrorHandler {
7
+ handleError(error: unknown, context: SubscriptionErrorContext): void;
8
+ }
9
+ /**
10
+ * Creates a default subscription error handler instance
11
+ */
12
+ export declare function createDefaultSubscriptionErrorHandler(): ISubscriptionErrorHandler;
13
+ //# sourceMappingURL=default-error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-error-handler.d.ts","sourceRoot":"","sources":["../../../src/subs/default-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,+BACX,YAAW,yBAAyB;IAEpC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAcrE;AAED;;GAEG;AACH,wBAAgB,qCAAqC,IAAI,yBAAyB,CAEjF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Default error handler that re-throws subscription errors.
3
+ * This ensures that errors are not silently swallowed.
4
+ */
5
+ export class DefaultSubscriptionErrorHandler {
6
+ handleError(error, context) {
7
+ const errorMessage = `Subscription error in ${context.eventType} (${context.subscriptionId})`;
8
+ if (error instanceof Error) {
9
+ // Preserve the original error with additional context
10
+ const enhancedError = new Error(`${errorMessage}: ${error.message}`);
11
+ enhancedError.cause = error;
12
+ enhancedError.stack = error.stack;
13
+ throw enhancedError;
14
+ }
15
+ else {
16
+ // Handle non-Error objects
17
+ throw new Error(`${errorMessage}: ${String(error)}`);
18
+ }
19
+ }
20
+ }
21
+ /**
22
+ * Creates a default subscription error handler instance
23
+ */
24
+ export function createDefaultSubscriptionErrorHandler() {
25
+ return new DefaultSubscriptionErrorHandler();
26
+ }
27
+ //# sourceMappingURL=default-error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-error-handler.js","sourceRoot":"","sources":["../../../src/subs/default-error-handler.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,+BAA+B;IAG1C,WAAW,CAAC,KAAc,EAAE,OAAiC;QAC3D,MAAM,YAAY,GAAG,yBAAyB,OAAO,CAAC,SAAS,KAAK,OAAO,CAAC,cAAc,GAAG,CAAC;QAE9F,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,sDAAsD;YACtD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,GAAG,YAAY,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;YAC5B,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAClC,MAAM,aAAa,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,2BAA2B;YAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qCAAqC;IACnD,OAAO,IAAI,+BAA+B,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { PHDocument } from "document-model";
2
+ import type { PagedResults, RelationshipChangeType, SearchFilter, ViewFilter } from "../shared/types.js";
3
+ import type { IReactorSubscriptionManager, ISubscriptionErrorHandler } from "./types.js";
4
+ type DocumentCreatedCallback = (result: PagedResults<string>) => void;
5
+ type DocumentDeletedCallback = (documentIds: string[]) => void;
6
+ type DocumentStateUpdatedCallback = (result: PagedResults<PHDocument>) => void;
7
+ type RelationshipChangedCallback = (parentId: string, childId: string, changeType: RelationshipChangeType) => void;
8
+ export declare class ReactorSubscriptionManager implements IReactorSubscriptionManager {
9
+ private createdSubscriptions;
10
+ private deletedSubscriptions;
11
+ private updatedSubscriptions;
12
+ private relationshipSubscriptions;
13
+ private subscriptionCounter;
14
+ private errorHandler;
15
+ constructor(errorHandler: ISubscriptionErrorHandler);
16
+ onDocumentCreated(callback: DocumentCreatedCallback, search?: SearchFilter): () => void;
17
+ onDocumentDeleted(callback: DocumentDeletedCallback, search?: SearchFilter): () => void;
18
+ onDocumentStateUpdated(callback: DocumentStateUpdatedCallback, search?: SearchFilter, view?: ViewFilter): () => void;
19
+ onRelationshipChanged(callback: RelationshipChangedCallback, search?: SearchFilter): () => void;
20
+ /**
21
+ * Notify subscribers about created documents
22
+ */
23
+ notifyDocumentsCreated(documentIds: string[], documentTypes?: Map<string, string>, parentIds?: Map<string, string | null>): void;
24
+ /**
25
+ * Notify subscribers about deleted documents
26
+ */
27
+ notifyDocumentsDeleted(documentIds: string[], documentTypes?: Map<string, string>, parentIds?: Map<string, string | null>): void;
28
+ /**
29
+ * Notify subscribers about updated documents
30
+ */
31
+ notifyDocumentsUpdated(documents: PHDocument[]): void;
32
+ /**
33
+ * Notify subscribers about relationship changes
34
+ */
35
+ notifyRelationshipChanged(parentId: string, childId: string, changeType: RelationshipChangeType, childType?: string): void;
36
+ /**
37
+ * Clear all subscriptions
38
+ */
39
+ clearAll(): void;
40
+ private filterDocumentIds;
41
+ private filterDocuments;
42
+ private matchesRelationshipFilter;
43
+ }
44
+ export {};
45
+ //# sourceMappingURL=react-subscription-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-subscription-manager.d.ts","sourceRoot":"","sources":["../../../src/subs/react-subscription-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;AACtE,KAAK,uBAAuB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;AAC/D,KAAK,4BAA4B,GAAG,CAAC,MAAM,EA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;IACH,sBAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI;IA0BrD;;OAEG;IACH,yBAAyB,CACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,sBAAsB,EAClC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAuBP;;OAEG;IACH,QAAQ,IAAI,IAAI;IAOhB,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,yBAAyB;CAclC"}
@@ -0,0 +1,185 @@
1
+ export class ReactorSubscriptionManager {
2
+ createdSubscriptions = new Map();
3
+ deletedSubscriptions = new Map();
4
+ updatedSubscriptions = new Map();
5
+ relationshipSubscriptions = new Map();
6
+ subscriptionCounter = 0;
7
+ errorHandler;
8
+ constructor(errorHandler) {
9
+ this.errorHandler = errorHandler;
10
+ }
11
+ onDocumentCreated(callback, search) {
12
+ const id = `created-${++this.subscriptionCounter}`;
13
+ this.createdSubscriptions.set(id, { id, callback, search });
14
+ return () => {
15
+ this.createdSubscriptions.delete(id);
16
+ };
17
+ }
18
+ onDocumentDeleted(callback, search) {
19
+ const id = `deleted-${++this.subscriptionCounter}`;
20
+ this.deletedSubscriptions.set(id, { id, callback, search });
21
+ return () => {
22
+ this.deletedSubscriptions.delete(id);
23
+ };
24
+ }
25
+ onDocumentStateUpdated(callback, search, view) {
26
+ const id = `updated-${++this.subscriptionCounter}`;
27
+ this.updatedSubscriptions.set(id, { id, callback, search, view });
28
+ return () => {
29
+ this.updatedSubscriptions.delete(id);
30
+ };
31
+ }
32
+ onRelationshipChanged(callback, search) {
33
+ const id = `relationship-${++this.subscriptionCounter}`;
34
+ this.relationshipSubscriptions.set(id, { id, callback, search });
35
+ return () => {
36
+ this.relationshipSubscriptions.delete(id);
37
+ };
38
+ }
39
+ /**
40
+ * Notify subscribers about created documents
41
+ */
42
+ notifyDocumentsCreated(documentIds, documentTypes, parentIds) {
43
+ const result = {
44
+ results: documentIds,
45
+ options: { cursor: "", limit: documentIds.length },
46
+ };
47
+ for (const subscription of this.createdSubscriptions.values()) {
48
+ const filteredIds = this.filterDocumentIds(documentIds, subscription.search, documentTypes, parentIds);
49
+ if (filteredIds.length > 0) {
50
+ try {
51
+ subscription.callback({
52
+ ...result,
53
+ results: filteredIds,
54
+ });
55
+ }
56
+ catch (error) {
57
+ this.errorHandler.handleError(error, {
58
+ eventType: "created",
59
+ subscriptionId: subscription.id,
60
+ eventData: filteredIds,
61
+ });
62
+ }
63
+ }
64
+ }
65
+ }
66
+ /**
67
+ * Notify subscribers about deleted documents
68
+ */
69
+ notifyDocumentsDeleted(documentIds, documentTypes, parentIds) {
70
+ for (const subscription of this.deletedSubscriptions.values()) {
71
+ const filteredIds = this.filterDocumentIds(documentIds, subscription.search, documentTypes, parentIds);
72
+ if (filteredIds.length > 0) {
73
+ try {
74
+ subscription.callback(filteredIds);
75
+ }
76
+ catch (error) {
77
+ this.errorHandler.handleError(error, {
78
+ eventType: "deleted",
79
+ subscriptionId: subscription.id,
80
+ eventData: filteredIds,
81
+ });
82
+ }
83
+ }
84
+ }
85
+ }
86
+ /**
87
+ * Notify subscribers about updated documents
88
+ */
89
+ notifyDocumentsUpdated(documents) {
90
+ const result = {
91
+ results: documents,
92
+ options: { cursor: "", limit: documents.length },
93
+ };
94
+ for (const subscription of this.updatedSubscriptions.values()) {
95
+ const filteredDocs = this.filterDocuments(documents, subscription.search);
96
+ if (filteredDocs.length > 0) {
97
+ try {
98
+ subscription.callback({
99
+ ...result,
100
+ results: filteredDocs,
101
+ });
102
+ }
103
+ catch (error) {
104
+ this.errorHandler.handleError(error, {
105
+ eventType: "updated",
106
+ subscriptionId: subscription.id,
107
+ eventData: filteredDocs,
108
+ });
109
+ }
110
+ }
111
+ }
112
+ }
113
+ /**
114
+ * Notify subscribers about relationship changes
115
+ */
116
+ notifyRelationshipChanged(parentId, childId, changeType, childType) {
117
+ for (const subscription of this.relationshipSubscriptions.values()) {
118
+ if (this.matchesRelationshipFilter(parentId, childId, childType, subscription.search)) {
119
+ try {
120
+ subscription.callback(parentId, childId, changeType);
121
+ }
122
+ catch (error) {
123
+ this.errorHandler.handleError(error, {
124
+ eventType: "relationshipChanged",
125
+ subscriptionId: subscription.id,
126
+ eventData: { parentId, childId, changeType },
127
+ });
128
+ }
129
+ }
130
+ }
131
+ }
132
+ /**
133
+ * Clear all subscriptions
134
+ */
135
+ clearAll() {
136
+ this.createdSubscriptions.clear();
137
+ this.deletedSubscriptions.clear();
138
+ this.updatedSubscriptions.clear();
139
+ this.relationshipSubscriptions.clear();
140
+ }
141
+ filterDocumentIds(documentIds, search, documentTypes, parentIds) {
142
+ if (!search)
143
+ return documentIds;
144
+ return documentIds.filter((id) => {
145
+ if (search.ids && !search.ids.includes(id))
146
+ return false;
147
+ if (search.type && documentTypes) {
148
+ const docType = documentTypes.get(id);
149
+ if (docType !== search.type)
150
+ return false;
151
+ }
152
+ if (search.parentId && parentIds) {
153
+ const parentId = parentIds.get(id);
154
+ if (parentId !== search.parentId)
155
+ return false;
156
+ }
157
+ return true;
158
+ });
159
+ }
160
+ filterDocuments(documents, search) {
161
+ if (!search)
162
+ return documents;
163
+ return documents.filter((doc) => {
164
+ if (search.ids && !search.ids.includes(doc.header.id))
165
+ return false;
166
+ if (search.type && doc.header.documentType !== search.type)
167
+ return false;
168
+ if (search.slugs && !search.slugs.includes(doc.header.slug))
169
+ return false;
170
+ return true;
171
+ });
172
+ }
173
+ matchesRelationshipFilter(parentId, childId, childType, search) {
174
+ if (!search)
175
+ return true;
176
+ if (search.parentId && parentId !== search.parentId)
177
+ return false;
178
+ if (search.ids && !search.ids.includes(childId))
179
+ return false;
180
+ if (search.type && childType && childType !== search.type)
181
+ return false;
182
+ return true;
183
+ }
184
+ }
185
+ //# sourceMappingURL=react-subscription-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-subscription-manager.js","sourceRoot":"","sources":["../../../src/subs/react-subscription-manager.ts"],"names":[],"mappings":"A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