@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.
- 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,285 @@
|
|
|
1
|
+
import { createPresignedHeader } from "document-model/core";
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
export class KyselyDocumentView {
|
|
4
|
+
db;
|
|
5
|
+
operationStore;
|
|
6
|
+
lastOperationId = 0;
|
|
7
|
+
constructor(db, operationStore) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
this.operationStore = operationStore;
|
|
10
|
+
}
|
|
11
|
+
async init() {
|
|
12
|
+
// Create tables if they don't exist
|
|
13
|
+
await this.createTablesIfNotExist();
|
|
14
|
+
// Load the last processed operation ID from ViewState
|
|
15
|
+
const viewState = await this.db
|
|
16
|
+
.selectFrom("ViewState")
|
|
17
|
+
.selectAll()
|
|
18
|
+
.executeTakeFirst();
|
|
19
|
+
if (viewState) {
|
|
20
|
+
this.lastOperationId = viewState.lastOperationId;
|
|
21
|
+
// Catch up with any operations we missed
|
|
22
|
+
const missedOperations = await this.operationStore.getSinceId(this.lastOperationId);
|
|
23
|
+
if (missedOperations.length > 0) {
|
|
24
|
+
await this.indexOperations(missedOperations);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Initialize ViewState with ID 0
|
|
29
|
+
await this.db
|
|
30
|
+
.insertInto("ViewState")
|
|
31
|
+
.values({
|
|
32
|
+
lastOperationId: 0,
|
|
33
|
+
})
|
|
34
|
+
.execute();
|
|
35
|
+
// Process all existing operations
|
|
36
|
+
const allOperations = await this.operationStore.getSinceId(0);
|
|
37
|
+
if (allOperations.length > 0) {
|
|
38
|
+
await this.indexOperations(allOperations);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async indexOperations(items) {
|
|
43
|
+
if (items.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
await this.db.transaction().execute(async (trx) => {
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
const { operation, context } = item;
|
|
48
|
+
const { documentId, scope, branch, documentType } = context;
|
|
49
|
+
const { index, hash } = operation;
|
|
50
|
+
// Check if we need to create or update a snapshot
|
|
51
|
+
const existingSnapshot = await trx
|
|
52
|
+
.selectFrom("DocumentSnapshot")
|
|
53
|
+
.selectAll()
|
|
54
|
+
.where("documentId", "=", documentId)
|
|
55
|
+
.where("scope", "=", scope)
|
|
56
|
+
.where("branch", "=", branch)
|
|
57
|
+
.executeTakeFirst();
|
|
58
|
+
if (existingSnapshot) {
|
|
59
|
+
// Update existing snapshot
|
|
60
|
+
await trx
|
|
61
|
+
.updateTable("DocumentSnapshot")
|
|
62
|
+
.set({
|
|
63
|
+
lastOperationIndex: index,
|
|
64
|
+
lastOperationHash: hash,
|
|
65
|
+
lastUpdatedAt: new Date(),
|
|
66
|
+
snapshotVersion: existingSnapshot.snapshotVersion + 1,
|
|
67
|
+
})
|
|
68
|
+
.where("documentId", "=", documentId)
|
|
69
|
+
.where("scope", "=", scope)
|
|
70
|
+
.where("branch", "=", branch)
|
|
71
|
+
.execute();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Create new snapshot
|
|
75
|
+
const snapshot = {
|
|
76
|
+
id: uuidv4(),
|
|
77
|
+
documentId,
|
|
78
|
+
slug: null,
|
|
79
|
+
name: null,
|
|
80
|
+
scope,
|
|
81
|
+
branch,
|
|
82
|
+
content: JSON.stringify({}), // Empty for now, will be filled when we build full documents
|
|
83
|
+
documentType,
|
|
84
|
+
lastOperationIndex: index,
|
|
85
|
+
lastOperationHash: hash,
|
|
86
|
+
identifiers: null,
|
|
87
|
+
metadata: null,
|
|
88
|
+
deletedAt: null,
|
|
89
|
+
};
|
|
90
|
+
await trx.insertInto("DocumentSnapshot").values(snapshot).execute();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async getHeader(documentId, branch, signal) {
|
|
96
|
+
if (signal?.aborted) {
|
|
97
|
+
throw new Error("Operation aborted");
|
|
98
|
+
}
|
|
99
|
+
// Query operations from header and document scopes only
|
|
100
|
+
// - "header" scope: CREATE_DOCUMENT actions contain initial header metadata
|
|
101
|
+
// - "document" scope: UPGRADE_DOCUMENT actions contain version transitions
|
|
102
|
+
const headerAndDocOps = await this.db
|
|
103
|
+
.selectFrom("Operation")
|
|
104
|
+
.selectAll()
|
|
105
|
+
.where("documentId", "=", documentId)
|
|
106
|
+
.where("branch", "=", branch)
|
|
107
|
+
.where("scope", "in", ["header", "document"])
|
|
108
|
+
.orderBy("timestampUtcMs", "asc") // Process in chronological order
|
|
109
|
+
.execute();
|
|
110
|
+
if (headerAndDocOps.length === 0) {
|
|
111
|
+
throw new Error(`Document header not found: ${documentId}`);
|
|
112
|
+
}
|
|
113
|
+
// Reconstruct header from header and document scope operations
|
|
114
|
+
let header = createPresignedHeader();
|
|
115
|
+
for (const op of headerAndDocOps) {
|
|
116
|
+
const action = JSON.parse(op.action);
|
|
117
|
+
if (action.type === "CREATE_DOCUMENT") {
|
|
118
|
+
const input = action.input;
|
|
119
|
+
// Extract header from CREATE_DOCUMENT action's signing parameters
|
|
120
|
+
if (input.signing) {
|
|
121
|
+
header = {
|
|
122
|
+
...header,
|
|
123
|
+
id: input.signing.signature, // documentId === signing.signature
|
|
124
|
+
documentType: input.signing.documentType,
|
|
125
|
+
createdAtUtcIso: input.signing.createdAtUtcIso,
|
|
126
|
+
lastModifiedAtUtcIso: input.signing.createdAtUtcIso,
|
|
127
|
+
sig: {
|
|
128
|
+
nonce: input.signing.nonce,
|
|
129
|
+
publicKey: input.signing.publicKey,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (action.type === "UPGRADE_DOCUMENT") {
|
|
135
|
+
// UPGRADE_DOCUMENT tracks version changes in the document scope
|
|
136
|
+
// Version information would be in the operation's resulting state
|
|
137
|
+
// For now, this is handled elsewhere in the document state
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Get revision map and latest timestamp from all scopes efficiently
|
|
141
|
+
const { revision, latestTimestamp } = await this.operationStore.getRevisions(documentId, branch, signal);
|
|
142
|
+
// Update header with cross-scope revision and timestamp information
|
|
143
|
+
header.revision = revision;
|
|
144
|
+
header.lastModifiedAtUtcIso = latestTimestamp;
|
|
145
|
+
return header;
|
|
146
|
+
}
|
|
147
|
+
async exists(documentIds, signal) {
|
|
148
|
+
if (signal?.aborted) {
|
|
149
|
+
throw new Error("Operation aborted");
|
|
150
|
+
}
|
|
151
|
+
if (documentIds.length === 0) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
// Query for all documents at once
|
|
155
|
+
const snapshots = await this.db
|
|
156
|
+
.selectFrom("DocumentSnapshot")
|
|
157
|
+
.select(["documentId"])
|
|
158
|
+
.where("documentId", "in", documentIds)
|
|
159
|
+
.where("isDeleted", "=", false)
|
|
160
|
+
.distinct()
|
|
161
|
+
.execute();
|
|
162
|
+
// Create a Set of existing document IDs for fast lookup
|
|
163
|
+
const existingIds = new Set(snapshots.map((s) => s.documentId));
|
|
164
|
+
// Return a boolean array in the same order as the input
|
|
165
|
+
return documentIds.map((id) => existingIds.has(id));
|
|
166
|
+
}
|
|
167
|
+
async getMany(documentIds, scope = "global", branch = "main", signal) {
|
|
168
|
+
if (signal?.aborted) {
|
|
169
|
+
throw new Error("Operation aborted");
|
|
170
|
+
}
|
|
171
|
+
if (documentIds.length === 0) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
// Query for all documents at once
|
|
175
|
+
const snapshots = await this.db
|
|
176
|
+
.selectFrom("DocumentSnapshot")
|
|
177
|
+
.selectAll()
|
|
178
|
+
.where("documentId", "in", documentIds)
|
|
179
|
+
.where("scope", "=", scope)
|
|
180
|
+
.where("branch", "=", branch)
|
|
181
|
+
.where("isDeleted", "=", false)
|
|
182
|
+
.execute();
|
|
183
|
+
// Create a Map of document ID to snapshot for fast lookup
|
|
184
|
+
const snapshotMap = new Map(snapshots.map((s) => [s.documentId, s]));
|
|
185
|
+
// Return an array in the same order as the input, with null for missing documents
|
|
186
|
+
return documentIds.map((id) => snapshotMap.get(id) || null);
|
|
187
|
+
}
|
|
188
|
+
async createTablesIfNotExist() {
|
|
189
|
+
// Check if tables exist by trying to query them
|
|
190
|
+
const tablesExist = await this.checkTablesExist();
|
|
191
|
+
if (!tablesExist) {
|
|
192
|
+
// Create ViewState table
|
|
193
|
+
await this.db.schema
|
|
194
|
+
.createTable("ViewState")
|
|
195
|
+
.ifNotExists()
|
|
196
|
+
.addColumn("lastOperationId", "integer", (col) => col.primaryKey())
|
|
197
|
+
.addColumn("lastOperationTimestamp", "timestamptz", (col) => col.defaultTo("now()").notNull())
|
|
198
|
+
.execute();
|
|
199
|
+
// Create DocumentSnapshot table
|
|
200
|
+
await this.db.schema
|
|
201
|
+
.createTable("DocumentSnapshot")
|
|
202
|
+
.ifNotExists()
|
|
203
|
+
.addColumn("id", "text", (col) => col.primaryKey())
|
|
204
|
+
.addColumn("documentId", "text", (col) => col.notNull())
|
|
205
|
+
.addColumn("slug", "text")
|
|
206
|
+
.addColumn("name", "text")
|
|
207
|
+
.addColumn("scope", "text", (col) => col.notNull())
|
|
208
|
+
.addColumn("branch", "text", (col) => col.notNull())
|
|
209
|
+
.addColumn("content", "text", (col) => col.notNull())
|
|
210
|
+
.addColumn("documentType", "text", (col) => col.notNull())
|
|
211
|
+
.addColumn("lastOperationIndex", "integer", (col) => col.notNull())
|
|
212
|
+
.addColumn("lastOperationHash", "text", (col) => col.notNull())
|
|
213
|
+
.addColumn("lastUpdatedAt", "timestamptz", (col) => col.defaultTo("now()").notNull())
|
|
214
|
+
.addColumn("snapshotVersion", "integer", (col) => col.defaultTo(1).notNull())
|
|
215
|
+
.addColumn("identifiers", "text")
|
|
216
|
+
.addColumn("metadata", "text")
|
|
217
|
+
.addColumn("isDeleted", "boolean", (col) => col.defaultTo(false).notNull())
|
|
218
|
+
.addColumn("deletedAt", "timestamptz")
|
|
219
|
+
.addUniqueConstraint("unique_doc_scope_branch", [
|
|
220
|
+
"documentId",
|
|
221
|
+
"scope",
|
|
222
|
+
"branch",
|
|
223
|
+
])
|
|
224
|
+
.execute();
|
|
225
|
+
// Create indexes for DocumentSnapshot
|
|
226
|
+
await this.db.schema
|
|
227
|
+
.createIndex("idx_slug_scope_branch")
|
|
228
|
+
.on("DocumentSnapshot")
|
|
229
|
+
.columns(["slug", "scope", "branch"])
|
|
230
|
+
.execute();
|
|
231
|
+
await this.db.schema
|
|
232
|
+
.createIndex("idx_doctype_scope_branch")
|
|
233
|
+
.on("DocumentSnapshot")
|
|
234
|
+
.columns(["documentType", "scope", "branch"])
|
|
235
|
+
.execute();
|
|
236
|
+
await this.db.schema
|
|
237
|
+
.createIndex("idx_last_updated")
|
|
238
|
+
.on("DocumentSnapshot")
|
|
239
|
+
.column("lastUpdatedAt")
|
|
240
|
+
.execute();
|
|
241
|
+
await this.db.schema
|
|
242
|
+
.createIndex("idx_is_deleted")
|
|
243
|
+
.on("DocumentSnapshot")
|
|
244
|
+
.column("isDeleted")
|
|
245
|
+
.execute();
|
|
246
|
+
// Create SlugMapping table
|
|
247
|
+
await this.db.schema
|
|
248
|
+
.createTable("SlugMapping")
|
|
249
|
+
.ifNotExists()
|
|
250
|
+
.addColumn("slug", "text", (col) => col.primaryKey())
|
|
251
|
+
.addColumn("documentId", "text", (col) => col.notNull())
|
|
252
|
+
.addColumn("scope", "text", (col) => col.notNull())
|
|
253
|
+
.addColumn("branch", "text", (col) => col.notNull())
|
|
254
|
+
.addColumn("createdAt", "timestamptz", (col) => col.defaultTo("now()").notNull())
|
|
255
|
+
.addColumn("updatedAt", "timestamptz", (col) => col.defaultTo("now()").notNull())
|
|
256
|
+
.addUniqueConstraint("unique_docid_scope_branch", [
|
|
257
|
+
"documentId",
|
|
258
|
+
"scope",
|
|
259
|
+
"branch",
|
|
260
|
+
])
|
|
261
|
+
.execute();
|
|
262
|
+
// Create index for SlugMapping
|
|
263
|
+
await this.db.schema
|
|
264
|
+
.createIndex("idx_slug_documentid")
|
|
265
|
+
.on("SlugMapping")
|
|
266
|
+
.column("documentId")
|
|
267
|
+
.execute();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async checkTablesExist() {
|
|
271
|
+
try {
|
|
272
|
+
// Try to query ViewState table
|
|
273
|
+
await this.db
|
|
274
|
+
.selectFrom("ViewState")
|
|
275
|
+
.select("lastOperationId")
|
|
276
|
+
.limit(1)
|
|
277
|
+
.execute();
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=document-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-view.js","sourceRoot":"","sources":["../../../src/read-models/document-view.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAgBpC,MAAM,OAAO,kBAAkB;IAInB;IACA;IAJF,eAAe,GAAW,CAAC,CAAC;IAEpC,YACU,EAAoB,EACpB,cAA+B;QAD/B,OAAE,GAAF,EAAE,CAAkB;QACpB,mBAAc,GAAd,cAAc,CAAiB;IACtC,CAAC;IAEJ,KAAK,CAAC,IAAI;QACR,oCAAoC;QACpC,MAAM,IAAI,CAAC,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,CAAC;iBACnD,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CACjC;iBACA,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CACjC;iBACA,mBAAmB,CAAC,2BAA2B,EAAE;gBAChD,YAAY;gBACZ,OAAO;gBACP,QAAQ;aACT,CAAC;iBACD,OAAO,EAAE,CAAC;YAEb,+BAA+B;YAC/B,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM;iBACjB,WAAW,CAAC,qBAAqB,CAAC;iBAClC,EAAE,CAAC,aAAa,CAAC;iBACjB,MAAM,CAAC,YAAY,CAAC;iBACpB,OAAO,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,IAAI,CAAC;YACH,+BAA+B;YAC/B,MAAM,IAAI,CAAC,EAAE;iBACV,UAAU,CAAC,WAAW,CAAC;iBACvB,MAAM,CAAC,iBAAiB,CAAC;iBACzB,KAAK,CAAC,CAAC,CAAC;iBACR,OAAO,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Generated, Insertable, Selectable, Updateable } from "kysely";
|
|
2
|
+
export interface ViewStateTable {
|
|
3
|
+
lastOperationId: number;
|
|
4
|
+
lastOperationTimestamp: Generated<Date>;
|
|
5
|
+
}
|
|
6
|
+
export interface DocumentSnapshotTable {
|
|
7
|
+
id: Generated<string>;
|
|
8
|
+
documentId: string;
|
|
9
|
+
slug: string | null;
|
|
10
|
+
name: string | null;
|
|
11
|
+
scope: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
content: string;
|
|
14
|
+
documentType: string;
|
|
15
|
+
lastOperationIndex: number;
|
|
16
|
+
lastOperationHash: string;
|
|
17
|
+
lastUpdatedAt: Generated<Date>;
|
|
18
|
+
snapshotVersion: Generated<number>;
|
|
19
|
+
identifiers: string | null;
|
|
20
|
+
metadata: string | null;
|
|
21
|
+
isDeleted: Generated<boolean>;
|
|
22
|
+
deletedAt: Date | null;
|
|
23
|
+
}
|
|
24
|
+
export interface SlugMappingTable {
|
|
25
|
+
slug: string;
|
|
26
|
+
documentId: string;
|
|
27
|
+
scope: string;
|
|
28
|
+
branch: string;
|
|
29
|
+
createdAt: Generated<Date>;
|
|
30
|
+
updatedAt: Generated<Date>;
|
|
31
|
+
}
|
|
32
|
+
export interface DocumentViewDatabase {
|
|
33
|
+
ViewState: ViewStateTable;
|
|
34
|
+
DocumentSnapshot: DocumentSnapshotTable;
|
|
35
|
+
SlugMapping: SlugMappingTable;
|
|
36
|
+
}
|
|
37
|
+
export type ViewStateRow = Selectable<ViewStateTable>;
|
|
38
|
+
export type InsertableViewState = Insertable<ViewStateTable>;
|
|
39
|
+
export type UpdateableViewState = Updateable<ViewStateTable>;
|
|
40
|
+
export type DocumentSnapshotRow = Selectable<DocumentSnapshotTable>;
|
|
41
|
+
export type InsertableDocumentSnapshot = Insertable<DocumentSnapshotTable>;
|
|
42
|
+
export type UpdateableDocumentSnapshot = Updateable<DocumentSnapshotTable>;
|
|
43
|
+
export type SlugMappingRow = Selectable<SlugMappingTable>;
|
|
44
|
+
export type InsertableSlugMapping = Insertable<SlugMappingTable>;
|
|
45
|
+
export type UpdateableSlugMapping = Updateable<SlugMappingTable>;
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/read-models/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,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ACtD,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;AAC7D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3E,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;AACjE,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/read-models/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DocumentModelModule } from "document-model";
|
|
2
|
+
import type { IDocumentModelRegistry } from "./interfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when a document model module is not found in the registry.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ModuleNotFoundError extends Error {
|
|
7
|
+
constructor(documentType: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when attempting to register a module that already exists.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DuplicateModuleError extends Error {
|
|
13
|
+
constructor(documentType: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when a module is invalid or malformed.
|
|
17
|
+
*/
|
|
18
|
+
export declare class InvalidModuleError extends Error {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* In-memory implementation of the IDocumentModelRegistry interface.
|
|
23
|
+
* Manages document model modules and provides centralized access to their reducers, utils, and specifications.
|
|
24
|
+
*/
|
|
25
|
+
export declare class DocumentModelRegistry implements IDocumentModelRegistry {
|
|
26
|
+
private modules;
|
|
27
|
+
/**
|
|
28
|
+
* Register multiple modules at once.
|
|
29
|
+
*
|
|
30
|
+
* @param modules Document model modules to register
|
|
31
|
+
* @throws DuplicateModuleError if a module with the same document type is already registered
|
|
32
|
+
* @throws InvalidModuleError if a module is malformed
|
|
33
|
+
*/
|
|
34
|
+
registerModules(...modules: DocumentModelModule<any>[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Unregister multiple document model modules at once.
|
|
37
|
+
*
|
|
38
|
+
* @param documentTypes The document types to unregister
|
|
39
|
+
* @returns true if all modules were unregistered, false if any were not found
|
|
40
|
+
*/
|
|
41
|
+
unregisterModules(...documentTypes: string[]): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Get a specific document model module by document type.
|
|
44
|
+
*
|
|
45
|
+
* @param documentType The document type identifier
|
|
46
|
+
* @returns The document model module
|
|
47
|
+
* @throws ModuleNotFoundError if the document type is not registered
|
|
48
|
+
*/
|
|
49
|
+
getModule(documentType: string): DocumentModelModule<any>;
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered document model modules.
|
|
52
|
+
* Note: This only returns loaded modules, not lazy-loaded ones.
|
|
53
|
+
*
|
|
54
|
+
* @returns Array of all registered modules
|
|
55
|
+
*/
|
|
56
|
+
getAllModules(): DocumentModelModule<any>[];
|
|
57
|
+
/**
|
|
58
|
+
* Clear all registered modules
|
|
59
|
+
*/
|
|
60
|
+
clear(): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=implementation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/registry/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,YAAY,EAAE,MAAM;CAIjC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,YAAY,EAAE,MAAM;CAIjC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,sBAAsB;IAClE,OAAO,CAAC,OAAO,CAA+C;IAE9D;;;;;;OAMG;IACH,eAAe,CAAC,GAAG,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI;IAY7D;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO;IAatD;;;;;;OAMG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC;IAUzD;;;;;OAKG;IACH,aAAa,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE;IAI3C;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a document model module is not found in the registry.
|
|
3
|
+
*/
|
|
4
|
+
export class ModuleNotFoundError extends Error {
|
|
5
|
+
constructor(documentType) {
|
|
6
|
+
super(`Document model module not found for type: ${documentType}`);
|
|
7
|
+
this.name = "ModuleNotFoundError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when attempting to register a module that already exists.
|
|
12
|
+
*/
|
|
13
|
+
export class DuplicateModuleError extends Error {
|
|
14
|
+
constructor(documentType) {
|
|
15
|
+
super(`Document model module already registered for type: ${documentType}`);
|
|
16
|
+
this.name = "DuplicateModuleError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when a module is invalid or malformed.
|
|
21
|
+
*/
|
|
22
|
+
export class InvalidModuleError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(`Invalid document model module: ${message}`);
|
|
25
|
+
this.name = "InvalidModuleError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* In-memory implementation of the IDocumentModelRegistry interface.
|
|
30
|
+
* Manages document model modules and provides centralized access to their reducers, utils, and specifications.
|
|
31
|
+
*/
|
|
32
|
+
export class DocumentModelRegistry {
|
|
33
|
+
modules = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* Register multiple modules at once.
|
|
36
|
+
*
|
|
37
|
+
* @param modules Document model modules to register
|
|
38
|
+
* @throws DuplicateModuleError if a module with the same document type is already registered
|
|
39
|
+
* @throws InvalidModuleError if a module is malformed
|
|
40
|
+
*/
|
|
41
|
+
registerModules(...modules) {
|
|
42
|
+
for (const module of modules) {
|
|
43
|
+
const documentType = module.documentModel.global.id;
|
|
44
|
+
if (this.modules.has(documentType)) {
|
|
45
|
+
throw new DuplicateModuleError(documentType);
|
|
46
|
+
}
|
|
47
|
+
this.modules.set(documentType, module);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Unregister multiple document model modules at once.
|
|
52
|
+
*
|
|
53
|
+
* @param documentTypes The document types to unregister
|
|
54
|
+
* @returns true if all modules were unregistered, false if any were not found
|
|
55
|
+
*/
|
|
56
|
+
unregisterModules(...documentTypes) {
|
|
57
|
+
let allFound = true;
|
|
58
|
+
for (const documentType of documentTypes) {
|
|
59
|
+
const wasDeleted = this.modules.delete(documentType);
|
|
60
|
+
if (!wasDeleted) {
|
|
61
|
+
allFound = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return allFound;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get a specific document model module by document type.
|
|
68
|
+
*
|
|
69
|
+
* @param documentType The document type identifier
|
|
70
|
+
* @returns The document model module
|
|
71
|
+
* @throws ModuleNotFoundError if the document type is not registered
|
|
72
|
+
*/
|
|
73
|
+
getModule(documentType) {
|
|
74
|
+
const module = this.modules.get(documentType);
|
|
75
|
+
if (module) {
|
|
76
|
+
return module;
|
|
77
|
+
}
|
|
78
|
+
throw new ModuleNotFoundError(documentType);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get all registered document model modules.
|
|
82
|
+
* Note: This only returns loaded modules, not lazy-loaded ones.
|
|
83
|
+
*
|
|
84
|
+
* @returns Array of all registered modules
|
|
85
|
+
*/
|
|
86
|
+
getAllModules() {
|
|
87
|
+
return Array.from(this.modules.values());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Clear all registered modules
|
|
91
|
+
*/
|
|
92
|
+
clear() {
|
|
93
|
+
this.modules.clear();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/registry/implementation.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,YAAoB;QAC9B,KAAK,CAAC,6CAA6C,YAAY,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,YAAoB;QAC9B,KAAK,CAAC,sDAAsD,YAAY,EAAE,CAAC,CAAC;QAC5E,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;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AAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocumentModelModule } from "document-model";
|
|
2
|
+
/**
|
|
3
|
+
* Registry for managing document model modules.
|
|
4
|
+
* Provides centralized access to document models' reducers, utils, and specifications.
|
|
5
|
+
*/
|
|
6
|
+
export interface IDocumentModelRegistry {
|
|
7
|
+
/**
|
|
8
|
+
* Register multiple modules at once.
|
|
9
|
+
*
|
|
10
|
+
* @param modules Document model modules to register
|
|
11
|
+
* @throws Error if a module with the same document type is already registered
|
|
12
|
+
*/
|
|
13
|
+
registerModules(...modules: DocumentModelModule<any>[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* Unregister multiple document model modules at once.
|
|
16
|
+
*
|
|
17
|
+
* @param documentTypes The document types to unregister
|
|
18
|
+
* @returns true if all modules were unregistered, false if any were not found
|
|
19
|
+
*/
|
|
20
|
+
unregisterModules(...documentTypes: string[]): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get a specific document model module by document type.
|
|
23
|
+
*
|
|
24
|
+
* @param documentType The document type identifier
|
|
25
|
+
* @returns The document model module
|
|
26
|
+
* @throws Error if the document type is not registered
|
|
27
|
+
*/
|
|
28
|
+
getModule(documentType: string): DocumentModelModule<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Get all registered document model modules
|
|
31
|
+
* @returns Array of all registered modules
|
|
32
|
+
*/
|
|
33
|
+
getAllModules(): DocumentModelModule<any>[];
|
|
34
|
+
/**
|
|
35
|
+
* Clear all registered modules
|
|
36
|
+
*/
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/registry/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,eAAe,CAAC,GAAG,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;IAE9D;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEvD;;;;;;OAMG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAE1D;;;OAGG;IACH,aAAa,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;IAE5C;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/registry/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type JobInfo } from "./types.js";
|
|
2
|
+
export interface IJobAwaiter {
|
|
3
|
+
/**
|
|
4
|
+
* Waits for a job to complete: turns a job into a promise.
|
|
5
|
+
*
|
|
6
|
+
* @param jobId - The job id or job object
|
|
7
|
+
* @param signal - Optional abort signal to cancel the request
|
|
8
|
+
* @returns The result of the job
|
|
9
|
+
*/
|
|
10
|
+
waitForJob(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
11
|
+
/**
|
|
12
|
+
* Shuts down the job awaiter. This will synchronously reject all pending jobs.
|
|
13
|
+
*/
|
|
14
|
+
shutdown(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Default implementation of IJobAwaiter that polls for job status.
|
|
18
|
+
* Uses a single interval timer to check all pending jobs.
|
|
19
|
+
*/
|
|
20
|
+
export declare class JobAwaiter implements IJobAwaiter {
|
|
21
|
+
private getJobStatus;
|
|
22
|
+
private pollIntervalMs;
|
|
23
|
+
private pendingJobs;
|
|
24
|
+
private intervalId;
|
|
25
|
+
constructor(getJobStatus: (jobId: string, signal?: AbortSignal) => Promise<JobInfo>, pollIntervalMs?: number);
|
|
26
|
+
shutdown(): void;
|
|
27
|
+
waitForJob(jobId: string, signal?: AbortSignal): Promise<JobInfo>;
|
|
28
|
+
private startInterval;
|
|
29
|
+
private stopIntervalIfNoJobs;
|
|
30
|
+
private checkPendingJobs;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=awaiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awaiter.d.ts","sourceRoot":"","sources":["../../../src/shared/awaiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAElE;;OAEG;IACH,QAAQ,IAAI,IAAI,CAAC;CAClB;AAQD;;;GAGG;AACH,qBAAa,UAAW,YAAW,WAAW;IAM1C,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IARxB,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,UAAU,CAA+B;gBAGvC,YAAY,EAAE,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,OAAO,CAAC,EACb,cAAc,SAAK;IAK7B,QAAQ,IAAI,IAAI;IAcV,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IA2CvE,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,oBAAoB;YAOd,gBAAgB;CA+D/B"}
|