@powerhousedao/reactor 4.1.0-dev.7 → 4.1.0-dev.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/client/reactor-client.d.ts +103 -0
- package/dist/src/client/reactor-client.d.ts.map +1 -0
- package/dist/src/client/reactor-client.js +184 -0
- package/dist/src/client/reactor-client.js.map +1 -0
- package/dist/src/client/types.d.ts +213 -0
- package/dist/src/client/types.d.ts.map +1 -0
- package/dist/src/client/types.js +14 -0
- package/dist/src/client/types.js.map +1 -0
- package/dist/src/core/builder.d.ts +20 -0
- package/dist/src/core/builder.d.ts.map +1 -0
- package/dist/src/core/builder.js +47 -0
- package/dist/src/core/builder.js.map +1 -0
- package/dist/src/core/reactor.d.ts +98 -0
- package/dist/src/core/reactor.d.ts.map +1 -0
- package/dist/src/core/reactor.js +630 -0
- package/dist/src/core/reactor.js.map +1 -0
- package/dist/src/core/types.d.ts +121 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/core/types.js +2 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/core/utils.d.ts +11 -0
- package/dist/src/core/utils.d.ts.map +1 -0
- package/dist/src/core/utils.js +31 -0
- package/dist/src/core/utils.js.map +1 -0
- package/dist/src/events/event-bus.d.ts +3 -3
- package/dist/src/events/event-bus.d.ts.map +1 -1
- package/dist/src/events/event-bus.js.map +1 -1
- package/dist/src/events/interfaces.d.ts +1 -1
- package/dist/src/events/interfaces.d.ts.map +1 -1
- package/dist/src/events/types.d.ts +1 -1
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/executor/interfaces.d.ts +31 -54
- package/dist/src/executor/interfaces.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +27 -0
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor-manager.js +128 -0
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -0
- package/dist/src/executor/simple-job-executor.d.ts +29 -0
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor.js +154 -0
- package/dist/src/executor/simple-job-executor.js.map +1 -0
- package/dist/src/executor/types.d.ts +23 -8
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/types.js.map +1 -1
- package/dist/src/index.d.ts +19 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +25 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/queue/interfaces.d.ts +45 -5
- package/dist/src/queue/interfaces.d.ts.map +1 -1
- package/dist/src/queue/job-execution-handle.d.ts +24 -0
- package/dist/src/queue/job-execution-handle.d.ts.map +1 -0
- package/dist/src/queue/job-execution-handle.js +62 -0
- package/dist/src/queue/job-execution-handle.js.map +1 -0
- package/dist/src/queue/queue.d.ts +54 -5
- package/dist/src/queue/queue.d.ts.map +1 -1
- package/dist/src/queue/queue.js +265 -36
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/queue/types.d.ts +26 -1
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js +12 -0
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/document-view.d.ts +21 -0
- package/dist/src/read-models/document-view.d.ts.map +1 -0
- package/dist/src/read-models/document-view.js +285 -0
- package/dist/src/read-models/document-view.js.map +1 -0
- package/dist/src/read-models/types.d.ts +46 -0
- package/dist/src/read-models/types.d.ts.map +1 -0
- package/dist/src/read-models/types.js +2 -0
- package/dist/src/read-models/types.js.map +1 -0
- package/dist/src/registry/implementation.d.ts +62 -0
- package/dist/src/registry/implementation.d.ts.map +1 -0
- package/dist/src/registry/implementation.js +96 -0
- package/dist/src/registry/implementation.js.map +1 -0
- package/dist/src/registry/index.d.ts +3 -0
- package/dist/src/registry/index.d.ts.map +1 -0
- package/dist/src/registry/index.js +2 -0
- package/dist/src/registry/index.js.map +1 -0
- package/dist/src/registry/interfaces.d.ts +39 -0
- package/dist/src/registry/interfaces.d.ts.map +1 -0
- package/dist/src/registry/interfaces.js +2 -0
- package/dist/src/registry/interfaces.js.map +1 -0
- package/dist/src/shared/awaiter.d.ts +32 -0
- package/dist/src/shared/awaiter.d.ts.map +1 -0
- package/dist/src/shared/awaiter.js +132 -0
- package/dist/src/shared/awaiter.js.map +1 -0
- package/dist/src/shared/errors.d.ts +9 -0
- package/dist/src/shared/errors.d.ts.map +1 -0
- package/dist/src/shared/errors.js +18 -0
- package/dist/src/shared/errors.js.map +1 -0
- package/dist/src/shared/factories.d.ts +16 -0
- package/dist/src/shared/factories.d.ts.map +1 -0
- package/dist/src/shared/factories.js +33 -0
- package/dist/src/shared/factories.js.map +1 -0
- package/dist/src/shared/types.d.ts +91 -19
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js +35 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/shared/utils.d.ts +3 -0
- package/dist/src/shared/utils.d.ts.map +1 -0
- package/dist/src/shared/utils.js +8 -0
- package/dist/src/shared/utils.js.map +1 -0
- package/dist/src/signer/passthrough-signer.d.ts +6 -0
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -0
- package/dist/src/signer/passthrough-signer.js +6 -0
- package/dist/src/signer/passthrough-signer.js.map +1 -0
- package/dist/src/signer/types.d.ts +15 -0
- package/dist/src/signer/types.d.ts.map +1 -0
- package/dist/src/signer/types.js +2 -0
- package/dist/src/signer/types.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +125 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +19 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/kysely/store.d.ts +15 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -0
- package/dist/src/storage/kysely/store.js +173 -0
- package/dist/src/storage/kysely/store.js.map +1 -0
- package/dist/src/storage/kysely/types.d.ts +26 -0
- package/dist/src/storage/kysely/types.d.ts.map +1 -0
- package/dist/src/storage/kysely/types.js +2 -0
- package/dist/src/storage/kysely/types.js.map +1 -0
- package/dist/src/storage/txn.d.ts +15 -0
- package/dist/src/storage/txn.d.ts.map +1 -0
- package/dist/src/storage/txn.js +42 -0
- package/dist/src/storage/txn.js.map +1 -0
- package/dist/src/subs/default-error-handler.d.ts +13 -0
- package/dist/src/subs/default-error-handler.d.ts.map +1 -0
- package/dist/src/subs/default-error-handler.js +27 -0
- package/dist/src/subs/default-error-handler.js.map +1 -0
- package/dist/src/subs/react-subscription-manager.d.ts +45 -0
- package/dist/src/subs/react-subscription-manager.d.ts.map +1 -0
- package/dist/src/subs/react-subscription-manager.js +185 -0
- package/dist/src/subs/react-subscription-manager.js.map +1 -0
- package/dist/src/subs/types.d.ts +64 -0
- package/dist/src/subs/types.d.ts.map +1 -0
- package/dist/src/subs/types.js +2 -0
- package/dist/src/subs/types.js.map +1 -0
- package/package.json +13 -5
- package/dist/bench/end-to-end-flow.bench.d.ts +0 -2
- package/dist/bench/end-to-end-flow.bench.d.ts.map +0 -1
- package/dist/bench/end-to-end-flow.bench.js +0 -256
- package/dist/bench/end-to-end-flow.bench.js.map +0 -1
- package/dist/bench/event-bus.bench.d.ts +0 -2
- package/dist/bench/event-bus.bench.d.ts.map +0 -1
- package/dist/bench/event-bus.bench.js +0 -238
- package/dist/bench/event-bus.bench.js.map +0 -1
- package/dist/bench/queue-only.bench.d.ts +0 -2
- package/dist/bench/queue-only.bench.d.ts.map +0 -1
- package/dist/bench/queue-only.bench.js +0 -40
- package/dist/bench/queue-only.bench.js.map +0 -1
- package/dist/bench/reactor-throughput.bench.d.ts +0 -2
- package/dist/bench/reactor-throughput.bench.d.ts.map +0 -1
- package/dist/bench/reactor-throughput.bench.js +0 -137
- package/dist/bench/reactor-throughput.bench.js.map +0 -1
- package/dist/src/executor/job-executor.d.ts +0 -62
- package/dist/src/executor/job-executor.d.ts.map +0 -1
- package/dist/src/executor/job-executor.js +0 -325
- package/dist/src/executor/job-executor.js.map +0 -1
- package/dist/test/event-bus.test.d.ts +0 -2
- package/dist/test/event-bus.test.d.ts.map +0 -1
- package/dist/test/event-bus.test.js +0 -532
- package/dist/test/event-bus.test.js.map +0 -1
- package/dist/test/job-executor.test.d.ts +0 -2
- package/dist/test/job-executor.test.d.ts.map +0 -1
- package/dist/test/job-executor.test.js +0 -581
- package/dist/test/job-executor.test.js.map +0 -1
- package/dist/test/queue.test.d.ts +0 -2
- package/dist/test/queue.test.d.ts.map +0 -1
- package/dist/test/queue.test.js +0 -396
- package/dist/test/queue.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { JobStatus } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default implementation of IJobAwaiter that polls for job status.
|
|
4
|
+
* Uses a single interval timer to check all pending jobs.
|
|
5
|
+
*/
|
|
6
|
+
export class JobAwaiter {
|
|
7
|
+
getJobStatus;
|
|
8
|
+
pollIntervalMs;
|
|
9
|
+
// Map from job ID to list of waiters (multiple waiters can wait for same job)
|
|
10
|
+
pendingJobs = new Map();
|
|
11
|
+
intervalId = null;
|
|
12
|
+
constructor(getJobStatus, pollIntervalMs = 10) {
|
|
13
|
+
this.getJobStatus = getJobStatus;
|
|
14
|
+
this.pollIntervalMs = pollIntervalMs;
|
|
15
|
+
//
|
|
16
|
+
}
|
|
17
|
+
shutdown() {
|
|
18
|
+
if (this.intervalId !== null) {
|
|
19
|
+
clearInterval(this.intervalId);
|
|
20
|
+
this.intervalId = null;
|
|
21
|
+
}
|
|
22
|
+
// Reject all pending jobs
|
|
23
|
+
for (const [, waiters] of this.pendingJobs) {
|
|
24
|
+
for (const waiter of waiters) {
|
|
25
|
+
waiter.reject(new Error("JobAwaiter destroyed"));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
this.pendingJobs.clear();
|
|
29
|
+
}
|
|
30
|
+
async waitForJob(jobId, signal) {
|
|
31
|
+
// Check if signal is already aborted
|
|
32
|
+
if (signal?.aborted) {
|
|
33
|
+
throw new Error("Operation aborted");
|
|
34
|
+
}
|
|
35
|
+
// Create promise for this job
|
|
36
|
+
const promise = new Promise((resolve, reject) => {
|
|
37
|
+
const waiter = { resolve, reject, signal };
|
|
38
|
+
// Add to the list of waiters for this job
|
|
39
|
+
const existingWaiters = this.pendingJobs.get(jobId) || [];
|
|
40
|
+
existingWaiters.push(waiter);
|
|
41
|
+
this.pendingJobs.set(jobId, existingWaiters);
|
|
42
|
+
// If signal is provided, handle abort
|
|
43
|
+
if (signal) {
|
|
44
|
+
const abortHandler = () => {
|
|
45
|
+
// Find and remove this specific waiter
|
|
46
|
+
const waiters = this.pendingJobs.get(jobId);
|
|
47
|
+
if (waiters) {
|
|
48
|
+
const index = waiters.indexOf(waiter);
|
|
49
|
+
if (index !== -1) {
|
|
50
|
+
waiters.splice(index, 1);
|
|
51
|
+
if (waiters.length === 0) {
|
|
52
|
+
this.pendingJobs.delete(jobId);
|
|
53
|
+
}
|
|
54
|
+
waiter.reject(new Error("Operation aborted"));
|
|
55
|
+
this.stopIntervalIfNoJobs();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
// Start interval if not already running
|
|
63
|
+
this.startInterval();
|
|
64
|
+
return promise;
|
|
65
|
+
}
|
|
66
|
+
startInterval() {
|
|
67
|
+
if (this.intervalId === null && this.pendingJobs.size > 0) {
|
|
68
|
+
this.intervalId = setInterval(() => {
|
|
69
|
+
void this.checkPendingJobs();
|
|
70
|
+
}, this.pollIntervalMs);
|
|
71
|
+
// Check immediately as well - schedule it for next tick
|
|
72
|
+
setTimeout(() => void this.checkPendingJobs(), 0);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
stopIntervalIfNoJobs() {
|
|
76
|
+
if (this.pendingJobs.size === 0 && this.intervalId !== null) {
|
|
77
|
+
clearInterval(this.intervalId);
|
|
78
|
+
this.intervalId = null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async checkPendingJobs() {
|
|
82
|
+
// Get unique job IDs to check
|
|
83
|
+
const jobIds = Array.from(this.pendingJobs.keys());
|
|
84
|
+
// Check each job
|
|
85
|
+
const jobChecks = jobIds.map(async (jobId) => {
|
|
86
|
+
const waiters = this.pendingJobs.get(jobId);
|
|
87
|
+
if (!waiters || waiters.length === 0) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
// Filter out aborted waiters
|
|
92
|
+
const activeWaiters = waiters.filter((w) => !w.signal?.aborted);
|
|
93
|
+
if (activeWaiters.length === 0) {
|
|
94
|
+
// All waiters were aborted
|
|
95
|
+
this.pendingJobs.delete(jobId);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Use the first active waiter's signal for the status check
|
|
99
|
+
const jobInfo = await this.getJobStatus(jobId, activeWaiters[0].signal);
|
|
100
|
+
// Check if job is complete
|
|
101
|
+
if (jobInfo.status === JobStatus.COMPLETED ||
|
|
102
|
+
jobInfo.status === JobStatus.FAILED) {
|
|
103
|
+
// Remove from pending
|
|
104
|
+
this.pendingJobs.delete(jobId);
|
|
105
|
+
// Resolve all active waiters
|
|
106
|
+
for (const waiter of activeWaiters) {
|
|
107
|
+
waiter.resolve(jobInfo);
|
|
108
|
+
}
|
|
109
|
+
// Reject aborted waiters
|
|
110
|
+
for (const waiter of waiters) {
|
|
111
|
+
if (waiter.signal?.aborted) {
|
|
112
|
+
waiter.reject(new Error("Operation aborted"));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
// Remove from pending
|
|
119
|
+
this.pendingJobs.delete(jobId);
|
|
120
|
+
// Reject all waiters with the error
|
|
121
|
+
for (const waiter of waiters) {
|
|
122
|
+
waiter.reject(error instanceof Error ? error : new Error(String(error)));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// Wait for all checks to complete
|
|
127
|
+
await Promise.all(jobChecks);
|
|
128
|
+
// Stop interval if no more jobs
|
|
129
|
+
this.stopIntervalIfNoJobs();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=awaiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awaiter.js","sourceRoot":"","sources":["../../../src/shared/awaiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AAwBrD;;;GAGG;AACH,MAAM,OAAO,UAAU;IAMX;IAIA;IATV,8EAA8E;IACtE,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,UAAU,GAA0B,IAAI,CAAC;IAEjD,YACU,YAGa,EACb,iBAAiB,EAAE;QAJnB,iBAAY,GAAZ,YAAY,CAGC;QACb,mBAAc,GAAd,cAAc,CAAK;QAE3B,EAAE;IACJ,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC7B,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QACD,0BAA0B;QAC1B,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,MAAoB;QAClD,qCAAqC;QACrC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CA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AC,KAAK,CAAC,CAAC,CAC1D,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,kCAAkC;QAClC,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE7B,gCAAgC;QAChC,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when attempting to access a deleted document.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DocumentDeletedError extends Error {
|
|
5
|
+
readonly documentId: string;
|
|
6
|
+
readonly deletedAtUtcIso: string | null;
|
|
7
|
+
constructor(documentId: string, deletedAtUtcIso?: string | null);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEnC,UAAU,EAAE,MAAM,EAAE,eAAe,GAAE,MAAM,GAAG,IAAW;CAYtE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when attempting to access a deleted document.
|
|
3
|
+
*/
|
|
4
|
+
export class DocumentDeletedError extends Error {
|
|
5
|
+
documentId;
|
|
6
|
+
deletedAtUtcIso;
|
|
7
|
+
constructor(documentId, deletedAtUtcIso = null) {
|
|
8
|
+
const message = deletedAtUtcIso
|
|
9
|
+
? `Document ${documentId} was deleted at ${deletedAtUtcIso}`
|
|
10
|
+
: `Document ${documentId} has been deleted`;
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "DocumentDeletedError";
|
|
13
|
+
this.documentId = documentId;
|
|
14
|
+
this.deletedAtUtcIso = deletedAtUtcIso;
|
|
15
|
+
Error.captureStackTrace(this, DocumentDeletedError);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7B,UAAU,CAAS;IACnB,eAAe,CAAgB;IAE/C,YAAY,UAAkB,EAAE,kBAAiC,IAAI;QACnE,MAAM,OAAO,GAAG,eAAe;YAC7B,CAAC,CAAC,YAAY,UAAU,mBAAmB,eAAe,EAAE;YAC5D,CAAC,CAAC,YAAY,UAAU,mBAAmB,CAAC;QAE9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAEvC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACtD,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,KAAK,EAAE,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory method to create a ShutdownStatus object
|
|
3
|
+
*
|
|
4
|
+
* @param isShutdown - Initial shutdown state
|
|
5
|
+
* @returns A ShutdownStatus object with a getter for the shutdown state
|
|
6
|
+
*/
|
|
7
|
+
export function createShutdownStatus(isShutdown) {
|
|
8
|
+
const shutdownState = isShutdown;
|
|
9
|
+
return {
|
|
10
|
+
get isShutdown() {
|
|
11
|
+
return shutdownState;
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Factory method to create a ShutdownStatus that can be updated
|
|
17
|
+
*
|
|
18
|
+
* @param initialState - Initial shutdown state (default: false)
|
|
19
|
+
* @returns A tuple of [ShutdownStatus, setter function]
|
|
20
|
+
*/
|
|
21
|
+
export function createMutableShutdownStatus(initialState = false) {
|
|
22
|
+
let shutdownState = initialState;
|
|
23
|
+
const status = {
|
|
24
|
+
get isShutdown() {
|
|
25
|
+
return shutdownState;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const setShutdown = (value) => {
|
|
29
|
+
shutdownState = value;
|
|
30
|
+
};
|
|
31
|
+
return [status, setShutdown];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=factories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../src/shared/factories.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAmB;IACtD,MAAM,aAAa,GAAG,UAAU,CAAC;IAEjC,OAAO;QACL,IAAI,UAAU;YACZ,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAAY,GAAG,KAAK;IAEpB,IAAI,aAAa,GAAG,YAAY,CAAC;IAEjC,MAAM,MAAM,GAAmB;QAC7B,IAAI,UAAU;YACZ,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,EAAE;QACrC,aAAa,GAAG,KAAK,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,23 +1,95 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
* The document ID used for system operations (CREATE_DOCUMENT, DELETE_DOCUMENT, etc.)
|
|
3
|
+
* System operations use this special ID along with the "system" scope.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SYSTEM_DOCUMENT_ID = "00000000-0000-0000-0000-000000000000";
|
|
6
|
+
/**
|
|
7
|
+
* Describes the status of a shutdown operation.
|
|
8
|
+
*/
|
|
9
|
+
export type ShutdownStatus = {
|
|
10
|
+
/**
|
|
11
|
+
* True if and only if the system has been shutdown.
|
|
12
|
+
*
|
|
13
|
+
* This value is meant to be polled to determine if the system has been shutdown.
|
|
14
|
+
*
|
|
15
|
+
* In the case of a browser process, the `kill` method should be able to synchronously set this to true.
|
|
16
|
+
*
|
|
17
|
+
* In the case of a server process, a graceful shutdown period should be allowed for the system to finish its work.
|
|
18
|
+
*/
|
|
19
|
+
get isShutdown(): boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Enum that determines deletion propagation.
|
|
23
|
+
*/
|
|
24
|
+
export declare enum PropagationMode {
|
|
25
|
+
None = "none",
|
|
26
|
+
Cascade = "cascade"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enum that describes the type of relationship change.
|
|
30
|
+
*/
|
|
31
|
+
export declare enum RelationshipChangeType {
|
|
32
|
+
Added = "added",
|
|
33
|
+
Removed = "removed"
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Describes the current state of a job.
|
|
37
|
+
*/
|
|
38
|
+
export type JobInfo = {
|
|
39
|
+
id: string;
|
|
40
|
+
status: JobStatus;
|
|
41
|
+
createdAtUtcIso: string;
|
|
42
|
+
completedAtUtcIso?: string;
|
|
19
43
|
error?: string;
|
|
20
|
-
|
|
21
|
-
|
|
44
|
+
result?: any;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Job execution statuses
|
|
48
|
+
*/
|
|
49
|
+
export declare enum JobStatus {
|
|
50
|
+
/** Job is queued but not yet started */
|
|
51
|
+
PENDING = "PENDING",
|
|
52
|
+
/** Job is currently being executed */
|
|
53
|
+
RUNNING = "RUNNING",
|
|
54
|
+
/** Job completed successfully */
|
|
55
|
+
COMPLETED = "COMPLETED",
|
|
56
|
+
/** Job failed (may be retried) */
|
|
57
|
+
FAILED = "FAILED"
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Describe the view of a set of documents. That is, what pieces of the
|
|
61
|
+
* documents are populated.
|
|
62
|
+
*/
|
|
63
|
+
export type ViewFilter = {
|
|
64
|
+
branch?: string;
|
|
65
|
+
scopes?: string[];
|
|
66
|
+
revision?: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Describes filter options for searching documents.
|
|
70
|
+
*
|
|
71
|
+
* Each parameter is treated as an AND condition.
|
|
72
|
+
*/
|
|
73
|
+
export type SearchFilter = {
|
|
74
|
+
type?: string;
|
|
75
|
+
parentId?: string;
|
|
76
|
+
ids?: string[];
|
|
77
|
+
slugs?: string[];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Describes the options for paging.
|
|
81
|
+
*/
|
|
82
|
+
export type PagingOptions = {
|
|
83
|
+
cursor: string;
|
|
84
|
+
limit: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The paged result.
|
|
88
|
+
*/
|
|
89
|
+
export type PagedResults<T> = {
|
|
90
|
+
results: T[];
|
|
91
|
+
options: PagingOptions;
|
|
92
|
+
next?: () => Promise<PagedResults<T>>;
|
|
93
|
+
nextCursor?: string;
|
|
22
94
|
};
|
|
23
95
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;OAQG;IACH,IAAI,UAAU,IAAI,OAAO,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAChC,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IAC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CUMENT, DELETE_DOCUMENT, etc.)
|
|
3
|
+
* System operations use this special ID along with the "system" scope.
|
|
4
|
+
*/
|
|
5
|
+
export const SYSTEM_DOCUMENT_ID = "00000000-0000-0000-0000-000000000000";
|
|
6
|
+
/**
|
|
7
|
+
* Enum that determines deletion propagation.
|
|
8
|
+
*/
|
|
9
|
+
export var PropagationMode;
|
|
10
|
+
(function (PropagationMode) {
|
|
11
|
+
PropagationMode["None"] = "none";
|
|
12
|
+
PropagationMode["Cascade"] = "cascade";
|
|
13
|
+
})(PropagationMode || (PropagationMode = {}));
|
|
14
|
+
/**
|
|
15
|
+
* Enum that describes the type of relationship change.
|
|
16
|
+
*/
|
|
17
|
+
export var RelationshipChangeType;
|
|
18
|
+
(function (RelationshipChangeType) {
|
|
19
|
+
RelationshipChangeType["Added"] = "added";
|
|
20
|
+
RelationshipChangeType["Removed"] = "removed";
|
|
21
|
+
})(RelationshipChangeType || (RelationshipChangeType = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Job execution statuses
|
|
24
|
+
*/
|
|
25
|
+
export var JobStatus;
|
|
26
|
+
(function (JobStatus) {
|
|
27
|
+
/** Job is queued but not yet started */
|
|
28
|
+
JobStatus["PENDING"] = "PENDING";
|
|
29
|
+
/** Job is currently being executed */
|
|
30
|
+
JobStatus["RUNNING"] = "RUNNING";
|
|
31
|
+
/** Job completed successfully */
|
|
32
|
+
JobStatus["COMPLETED"] = "COMPLETED";
|
|
33
|
+
/** Job failed (may be retried) */
|
|
34
|
+
JobStatus["FAILED"] = "FAILED";
|
|
35
|
+
})(JobStatus || (JobStatus = {}));
|
|
2
36
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AAkBzE;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,6CAAmB,CAAA;AACrB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAcD;;GAEG;AACH,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB,wCAAwC;IACxC,gCAAmB,CAAA;IACnB,sCAAsC;IACtC,gCAAmB,CAAA;IACnB,iCAAiC;IACjC,oCAAuB,CAAA;IACvB,kCAAkC;IAClC,8BAAiB,CAAA;AACnB,CAAC,EATW,SAAS,KAAT,SAAS,QASpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,YAAK,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/shared/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,OAAmB,EAAE,EAAE,KAAa;IAC/D,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,wDAAwD;IACxD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passthrough-signer.d.ts","sourceRoot":"","sources":["../../../src/signer/passthrough-signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,qBAAa,iBAAkB,YAAW,OAAO;IAC/C,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC;CAG3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passthrough-signer.js","sourceRoot":"","sources":["../../../src/signer/passthrough-signer.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAiB;IAC5B,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Action, Signature } from "document-model";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for signing actions before submission to the reactor.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISigner {
|
|
6
|
+
/**
|
|
7
|
+
* Signs an action
|
|
8
|
+
*
|
|
9
|
+
* @param action - The action to sign
|
|
10
|
+
* @param abortSignal - Optional abort signal to cancel the signing
|
|
11
|
+
* @returns The signature
|
|
12
|
+
*/
|
|
13
|
+
sign(action: Action, abortSignal?: AbortSignal): Promise<Signature>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { Operation, PHDocumentHeader } from "document-model";
|
|
2
|
+
export type OperationContext = {
|
|
3
|
+
documentId: string;
|
|
4
|
+
documentType: string;
|
|
5
|
+
scope: string;
|
|
6
|
+
branch: string;
|
|
7
|
+
};
|
|
8
|
+
export type OperationWithContext = {
|
|
9
|
+
operation: Operation;
|
|
10
|
+
context: OperationContext;
|
|
11
|
+
};
|
|
12
|
+
export declare class DuplicateOperationError extends Error {
|
|
13
|
+
constructor(opId: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class OptimisticLockError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class RevisionMismatchError extends Error {
|
|
19
|
+
constructor(expected: number, actual: number);
|
|
20
|
+
}
|
|
21
|
+
export interface AtomicTxn {
|
|
22
|
+
addOperations(...operations: Operation[]): void;
|
|
23
|
+
}
|
|
24
|
+
export type DocumentRevisions = {
|
|
25
|
+
/** Map of scope to operation index for that scope */
|
|
26
|
+
revision: Record<string, number>;
|
|
27
|
+
/** Latest timestamp across revisions */
|
|
28
|
+
latestTimestamp: string;
|
|
29
|
+
};
|
|
30
|
+
export interface IOperationStore {
|
|
31
|
+
apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<void>;
|
|
32
|
+
get(documentId: string, scope: string, branch: string, revision: number, signal?: AbortSignal): Promise<OperationWithContext>;
|
|
33
|
+
getSince(documentId: string, scope: string, branch: string, revision: number, signal?: AbortSignal): Promise<OperationWithContext[]>;
|
|
34
|
+
getSinceTimestamp(documentId: string, scope: string, branch: string, timestampUtcMs: number, signal?: AbortSignal): Promise<OperationWithContext[]>;
|
|
35
|
+
getSinceId(id: number, signal?: AbortSignal): Promise<OperationWithContext[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the latest operation index for each scope of a document, along with
|
|
38
|
+
* the latest timestamp across all scopes. This is used to efficiently reconstruct
|
|
39
|
+
* the revision map and lastModified timestamp for document headers.
|
|
40
|
+
*
|
|
41
|
+
* @param documentId - The document id
|
|
42
|
+
* @param branch - The branch name
|
|
43
|
+
* @param signal - Optional abort signal to cancel the request
|
|
44
|
+
* @returns Object containing revision map and latest timestamp
|
|
45
|
+
*/
|
|
46
|
+
getRevisions(documentId: string, branch: string, signal?: AbortSignal): Promise<DocumentRevisions>;
|
|
47
|
+
}
|
|
48
|
+
export interface ViewFilter {
|
|
49
|
+
branch?: string;
|
|
50
|
+
scopes?: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface SearchFilter {
|
|
53
|
+
documentType?: string;
|
|
54
|
+
parentId?: string;
|
|
55
|
+
identifiers?: Record<string, any>;
|
|
56
|
+
includeDeleted?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface PagingOptions {
|
|
59
|
+
cursor?: string;
|
|
60
|
+
limit?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface PagedResults<T> {
|
|
63
|
+
items: T[];
|
|
64
|
+
nextCursor?: string;
|
|
65
|
+
hasMore: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface DocumentSnapshot {
|
|
68
|
+
id: string;
|
|
69
|
+
documentId: string;
|
|
70
|
+
slug: string | null;
|
|
71
|
+
name: string | null;
|
|
72
|
+
scope: string;
|
|
73
|
+
branch: string;
|
|
74
|
+
content: string;
|
|
75
|
+
documentType: string;
|
|
76
|
+
lastOperationIndex: number;
|
|
77
|
+
lastOperationHash: string;
|
|
78
|
+
lastUpdatedAt: Date;
|
|
79
|
+
snapshotVersion: number;
|
|
80
|
+
identifiers: string | null;
|
|
81
|
+
metadata: string | null;
|
|
82
|
+
isDeleted: boolean;
|
|
83
|
+
deletedAt: Date | null;
|
|
84
|
+
}
|
|
85
|
+
export interface IDocumentView {
|
|
86
|
+
/**
|
|
87
|
+
* Initializes the view.
|
|
88
|
+
*/
|
|
89
|
+
init(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Indexes a list of operations.
|
|
92
|
+
*/
|
|
93
|
+
indexOperations(items: OperationWithContext[]): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Retrieves a document header by reconstructing it from operations across all scopes.
|
|
96
|
+
*
|
|
97
|
+
* Headers contain cross-scope metadata (revision tracking, lastModified timestamps)
|
|
98
|
+
* that require aggregating information from multiple scopes, making this a
|
|
99
|
+
* view-layer concern rather than an operation store concern.
|
|
100
|
+
*
|
|
101
|
+
* @param documentId - The document id
|
|
102
|
+
* @param branch - The branch name
|
|
103
|
+
* @param signal - Optional abort signal to cancel the request
|
|
104
|
+
* @returns The reconstructed document header
|
|
105
|
+
*/
|
|
106
|
+
getHeader(documentId: string, branch: string, signal?: AbortSignal): Promise<PHDocumentHeader>;
|
|
107
|
+
/**
|
|
108
|
+
* Returns true if and only if the documents exist.
|
|
109
|
+
*
|
|
110
|
+
* @param documentIds - The list of document ids to check.
|
|
111
|
+
* @param signal - Optional abort signal to cancel the request
|
|
112
|
+
*/
|
|
113
|
+
exists(documentIds: string[], signal?: AbortSignal): Promise<boolean[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Retrieves multiple document snapshots by their IDs.
|
|
116
|
+
*
|
|
117
|
+
* @param documentIds - The list of document ids to retrieve.
|
|
118
|
+
* @param scope - The scope to filter by (default: "global")
|
|
119
|
+
* @param branch - The branch to filter by (default: "main")
|
|
120
|
+
* @param signal - Optional abort signal to cancel the request
|
|
121
|
+
* @returns Array of document snapshots in the same order as input IDs (null for non-existent docs)
|
|
122
|
+
*/
|
|
123
|
+
getMany(documentIds: string[], scope?: string, branch?: string, signal?: AbortSignal): Promise<(DocumentSnapshot | null)[]>;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
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,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class DuplicateOperationError extends Error {
|
|
2
|
+
constructor(opId) {
|
|
3
|
+
super(`Operation with opId ${opId} already exists`);
|
|
4
|
+
this.name = "DuplicateOperationError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class OptimisticLockError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "OptimisticLockError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class RevisionMismatchError extends Error {
|
|
14
|
+
constructor(expected, actual) {
|
|
15
|
+
super(`Revision mismatch: expected ${expected}, got ${actual}`);
|
|
16
|
+
this.name = "RevisionMismatchError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/storage/interfaces.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,IAAY;QACtB,KAAK,CAAC,uBAAuB,IAAI,iBAAiB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,QAAgB,EAAE,MAAc;QAC1C,KAAK,CAAC,+BAA+B,QAAQ,SAAS,MAAM,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|