@spine-event-engine/storage-postgres 2.0.0-snapshot.13
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/LICENSE +201 -0
- package/README.md +102 -0
- package/REFERENCE.md +85 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/postgres/column-mapping.d.ts +33 -0
- package/dist/postgres/column-mapping.d.ts.map +1 -0
- package/dist/postgres/column-mapping.js +93 -0
- package/dist/postgres/column-mapping.js.map +1 -0
- package/dist/postgres/data-type.d.ts +25 -0
- package/dist/postgres/data-type.d.ts.map +1 -0
- package/dist/postgres/data-type.js +29 -0
- package/dist/postgres/data-type.js.map +1 -0
- package/dist/postgres/delivery-cleanup.d.ts +76 -0
- package/dist/postgres/delivery-cleanup.d.ts.map +1 -0
- package/dist/postgres/delivery-cleanup.js +224 -0
- package/dist/postgres/delivery-cleanup.js.map +1 -0
- package/dist/postgres/entity-commit.d.ts +114 -0
- package/dist/postgres/entity-commit.d.ts.map +1 -0
- package/dist/postgres/entity-commit.js +385 -0
- package/dist/postgres/entity-commit.js.map +1 -0
- package/dist/postgres/entity-history.d.ts +85 -0
- package/dist/postgres/entity-history.d.ts.map +1 -0
- package/dist/postgres/entity-history.js +840 -0
- package/dist/postgres/entity-history.js.map +1 -0
- package/dist/postgres/errors.d.ts +51 -0
- package/dist/postgres/errors.d.ts.map +1 -0
- package/dist/postgres/errors.js +113 -0
- package/dist/postgres/errors.js.map +1 -0
- package/dist/postgres/id-column.d.ts +61 -0
- package/dist/postgres/id-column.d.ts.map +1 -0
- package/dist/postgres/id-column.js +165 -0
- package/dist/postgres/id-column.js.map +1 -0
- package/dist/postgres/parameter.d.ts +5 -0
- package/dist/postgres/parameter.d.ts.map +1 -0
- package/dist/postgres/parameter.js +15 -0
- package/dist/postgres/parameter.js.map +1 -0
- package/dist/postgres/record-storage.d.ts +514 -0
- package/dist/postgres/record-storage.d.ts.map +1 -0
- package/dist/postgres/record-storage.js +849 -0
- package/dist/postgres/record-storage.js.map +1 -0
- package/dist/postgres/storage-factory.d.ts +321 -0
- package/dist/postgres/storage-factory.d.ts.map +1 -0
- package/dist/postgres/storage-factory.js +584 -0
- package/dist/postgres/storage-factory.js.map +1 -0
- package/dist/postgres/table-initializer.d.ts +66 -0
- package/dist/postgres/table-initializer.d.ts.map +1 -0
- package/dist/postgres/table-initializer.js +301 -0
- package/dist/postgres/table-initializer.js.map +1 -0
- package/dist/postgres/table-resolver.d.ts +41 -0
- package/dist/postgres/table-resolver.d.ts.map +1 -0
- package/dist/postgres/table-resolver.js +225 -0
- package/dist/postgres/table-resolver.js.map +1 -0
- package/dist/postgres/table-spec.d.ts +40 -0
- package/dist/postgres/table-spec.d.ts.map +1 -0
- package/dist/postgres/table-spec.js +126 -0
- package/dist/postgres/table-spec.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { toBinary } from "@bufbuild/protobuf";
|
|
15
|
+
import { EntityRecordSchema, } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
|
|
16
|
+
import {} from "@spine-event-engine/storage";
|
|
17
|
+
import { TenantBoundary, eventHistorySpec, eventStoreRecordSpec, stateHistorySpec, } from "@spine-event-engine/storage/provider";
|
|
18
|
+
import { PostgresRollbackErrors, PostgresStorageOperationError, PostgresTransactionErrors, } from "./errors.js";
|
|
19
|
+
import { PostgresRecordStorage, } from "./record-storage.js";
|
|
20
|
+
/**
|
|
21
|
+
* Acquires fresh clients for a complete Entity transaction and one safe retry.
|
|
22
|
+
*/
|
|
23
|
+
class PostgresEntityCommitCoordinator {
|
|
24
|
+
lifecycle;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a coordinator for one tenant-bound record lifecycle.
|
|
27
|
+
*
|
|
28
|
+
* @param lifecycle Acquires transaction clients for the selected database.
|
|
29
|
+
*/
|
|
30
|
+
constructor(lifecycle) {
|
|
31
|
+
this.lifecycle = lifecycle;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Commits one complete Entity change with one serialization retry.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam T Result returned by the transaction work.
|
|
37
|
+
* @param work Applies the Entity commit on an acquired client.
|
|
38
|
+
* @returns The committed work result.
|
|
39
|
+
*/
|
|
40
|
+
async commit(work) {
|
|
41
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
42
|
+
const client = await this.lifecycle.acquire();
|
|
43
|
+
let discard;
|
|
44
|
+
try {
|
|
45
|
+
await client.query("BEGIN");
|
|
46
|
+
const result = await work(client);
|
|
47
|
+
await client.query("COMMIT");
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
try {
|
|
52
|
+
await client.query("ROLLBACK");
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
discard = PostgresRollbackErrors.discard(error);
|
|
56
|
+
}
|
|
57
|
+
if (attempt === 0 && PostgresTransactionErrors.retryable(error))
|
|
58
|
+
continue;
|
|
59
|
+
throw PostgresCommitErrors.operation(error);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
client.release(discard);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw new Error("Unreachable PostgreSQL Entity commit retry.");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Opens and closes the exact record families participating in one commit.
|
|
70
|
+
*
|
|
71
|
+
* @typeParam I Entity identifier type.
|
|
72
|
+
* @typeParam S Entity state message type.
|
|
73
|
+
*/
|
|
74
|
+
class PostgresCommitRecords {
|
|
75
|
+
current;
|
|
76
|
+
states;
|
|
77
|
+
diagnostics;
|
|
78
|
+
events;
|
|
79
|
+
#handles;
|
|
80
|
+
/**
|
|
81
|
+
* Opens the current record family and each enabled immutable family.
|
|
82
|
+
*
|
|
83
|
+
* @param input Describes the Entity commit and enabled histories.
|
|
84
|
+
* @param open Opens one record family.
|
|
85
|
+
*/
|
|
86
|
+
constructor(input, open) {
|
|
87
|
+
const current = open(input.entity.recordSpec);
|
|
88
|
+
const handles = [current];
|
|
89
|
+
this.current = current.historyExecutor();
|
|
90
|
+
this.states = input.states?.length ? this.openState(input, open, handles) : undefined;
|
|
91
|
+
this.diagnostics = input.diagnostics?.length
|
|
92
|
+
? this.openDiagnostic(input, open, handles)
|
|
93
|
+
: undefined;
|
|
94
|
+
this.events = input.events?.length ? this.openEvents(open, handles) : undefined;
|
|
95
|
+
this.#handles = handles;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Prepares every record family before the transaction begins.
|
|
99
|
+
*
|
|
100
|
+
* @returns Completion after all required tables are ready.
|
|
101
|
+
*/
|
|
102
|
+
async prepare() {
|
|
103
|
+
for (const handle of this.#handles)
|
|
104
|
+
await handle.prepare();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Closes every temporary record-family handle.
|
|
108
|
+
*/
|
|
109
|
+
close() {
|
|
110
|
+
for (const handle of this.#handles)
|
|
111
|
+
handle.close();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Opens the Entity state-history record family.
|
|
115
|
+
*
|
|
116
|
+
* @param input Describes the Entity state schema.
|
|
117
|
+
* @param open Opens one record family.
|
|
118
|
+
* @param handles Collects handles that must close after the commit.
|
|
119
|
+
* @returns The state-history transaction executor.
|
|
120
|
+
*/
|
|
121
|
+
openState(input, open, handles) {
|
|
122
|
+
const layout = stateHistorySpec(input.entity.stateSchema);
|
|
123
|
+
const handle = open(layout.spec, layout.group);
|
|
124
|
+
handles.push(handle);
|
|
125
|
+
return handle.historyExecutor();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Opens the Entity diagnostic-event history record family.
|
|
129
|
+
*
|
|
130
|
+
* @param input Describes the Entity state schema.
|
|
131
|
+
* @param open Opens one record family.
|
|
132
|
+
* @param handles Collects handles that must close after the commit.
|
|
133
|
+
* @returns The diagnostic-history transaction executor.
|
|
134
|
+
*/
|
|
135
|
+
openDiagnostic(input, open, handles) {
|
|
136
|
+
const layout = eventHistorySpec(input.entity.stateSchema);
|
|
137
|
+
const handle = open(layout.spec, layout.group);
|
|
138
|
+
handles.push(handle);
|
|
139
|
+
return handle.historyExecutor();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Opens the shared event-store record family.
|
|
143
|
+
*
|
|
144
|
+
* @param open Opens one record family.
|
|
145
|
+
* @param handles Collects handles that must close after the commit.
|
|
146
|
+
* @returns The event-store transaction executor.
|
|
147
|
+
*/
|
|
148
|
+
openEvents(open, handles) {
|
|
149
|
+
const handle = open(eventStoreRecordSpec);
|
|
150
|
+
handles.push(handle);
|
|
151
|
+
return handle.historyExecutor();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Represents a factory-tracked PostgreSQL Entity commit handle.
|
|
156
|
+
*
|
|
157
|
+
* @typeParam I Entity identifier type captured by this handle.
|
|
158
|
+
* @typeParam S Entity state message type captured by this handle.
|
|
159
|
+
*/
|
|
160
|
+
export class PostgresEntityCommitStorage {
|
|
161
|
+
entity;
|
|
162
|
+
open;
|
|
163
|
+
onClose;
|
|
164
|
+
#open = true;
|
|
165
|
+
#coordinator;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a PostgreSQL Entity commit handle for one Entity storage boundary.
|
|
168
|
+
*
|
|
169
|
+
* @param entity Defines the captured Entity source, state, and tenant scope.
|
|
170
|
+
* @param open Opens temporary current and history record-family handles.
|
|
171
|
+
* @param lifecycle Acquires transaction clients for the captured database.
|
|
172
|
+
* @param onClose Removes this handle from the factory's live-handle set.
|
|
173
|
+
*/
|
|
174
|
+
constructor(entity, open, lifecycle, onClose) {
|
|
175
|
+
this.entity = entity;
|
|
176
|
+
this.open = open;
|
|
177
|
+
this.onClose = onClose;
|
|
178
|
+
this.#coordinator = new PostgresEntityCommitCoordinator(lifecycle);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Commits one current Entity record and its optional immutable records.
|
|
182
|
+
*
|
|
183
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
184
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
185
|
+
* @param input Defines the expected and next current records plus histories.
|
|
186
|
+
* @returns Whether PostgreSQL committed the mutation or found a conflict.
|
|
187
|
+
*/
|
|
188
|
+
async commit(input) {
|
|
189
|
+
this.validate(input);
|
|
190
|
+
const records = new PostgresCommitRecords(input, this.open);
|
|
191
|
+
try {
|
|
192
|
+
await records.prepare();
|
|
193
|
+
return await this.#coordinator.commit((client) => this.apply(client, input, records));
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
records.close();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Closes this handle to new commits while allowing started work to settle.
|
|
201
|
+
*/
|
|
202
|
+
close() {
|
|
203
|
+
if (this.#open) {
|
|
204
|
+
this.#open = false;
|
|
205
|
+
this.onClose();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Applies one validated Entity commit on an active transaction.
|
|
210
|
+
*
|
|
211
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
212
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
213
|
+
* @param client PostgreSQL transaction client.
|
|
214
|
+
* @param input Defines the Entity records to commit.
|
|
215
|
+
* @param records Provides the prepared record families.
|
|
216
|
+
* @returns Whether records were committed or conflicted.
|
|
217
|
+
*/
|
|
218
|
+
async apply(client, input, records) {
|
|
219
|
+
await this.locks(client, input, records);
|
|
220
|
+
const current = await records.current.read(client, input.entityId, "for-update");
|
|
221
|
+
if (!PostgresCommitValues.same(current, input.expected) &&
|
|
222
|
+
!PostgresCommitValues.same(current, input.next))
|
|
223
|
+
return "conflict";
|
|
224
|
+
await this.preflight(client, input, records);
|
|
225
|
+
await this.append(client, input, records);
|
|
226
|
+
if (!PostgresCommitValues.same(current, input.next))
|
|
227
|
+
await records.current.write(client, input.next);
|
|
228
|
+
return "committed";
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Acquires locks for each mutable or append-only family in the commit.
|
|
232
|
+
*
|
|
233
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
234
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
235
|
+
* @param client PostgreSQL transaction client.
|
|
236
|
+
* @param input Defines the Entity records to commit.
|
|
237
|
+
* @param records Provides the prepared record families.
|
|
238
|
+
* @returns Completion after all transaction locks are acquired.
|
|
239
|
+
*/
|
|
240
|
+
async locks(client, input, records) {
|
|
241
|
+
if (records.states)
|
|
242
|
+
await client.query("SELECT pg_advisory_xact_lock_shared($1)", [
|
|
243
|
+
records.states.lock("history-family", records.states.table()),
|
|
244
|
+
]);
|
|
245
|
+
if (records.diagnostics)
|
|
246
|
+
await client.query("SELECT pg_advisory_xact_lock_shared($1)", [
|
|
247
|
+
records.diagnostics.lock("history-family", records.diagnostics.table()),
|
|
248
|
+
]);
|
|
249
|
+
await client.query("SELECT pg_advisory_xact_lock($1)", [
|
|
250
|
+
records.current.lock("entity-mutation", input.entity.sourceType.typeName, this.entity.id.key(input.entityId)),
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Verifies that every immutable record can be appended.
|
|
255
|
+
*
|
|
256
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
257
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
258
|
+
* @param client PostgreSQL transaction client.
|
|
259
|
+
* @param input Defines the immutable records to verify.
|
|
260
|
+
* @param records Provides the prepared record families.
|
|
261
|
+
* @returns Completion after all immutable checks pass.
|
|
262
|
+
*/
|
|
263
|
+
async preflight(client, input, records) {
|
|
264
|
+
for (const record of input.states ?? [])
|
|
265
|
+
await records.states?.assertImmutable(client, record);
|
|
266
|
+
for (const record of input.diagnostics ?? [])
|
|
267
|
+
await records.diagnostics?.assertImmutable(client, record);
|
|
268
|
+
for (const record of input.events ?? [])
|
|
269
|
+
await records.events?.assertImmutable(client, record);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Stores every immutable history and event-store record.
|
|
273
|
+
*
|
|
274
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
275
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
276
|
+
* @param client PostgreSQL transaction client.
|
|
277
|
+
* @param input Defines the immutable records to append.
|
|
278
|
+
* @param records Provides the prepared record families.
|
|
279
|
+
* @returns Completion after all records are appended.
|
|
280
|
+
*/
|
|
281
|
+
async append(client, input, records) {
|
|
282
|
+
for (const record of input.states ?? [])
|
|
283
|
+
await records.states?.appendImmutable(client, record);
|
|
284
|
+
for (const record of input.diagnostics ?? [])
|
|
285
|
+
await records.diagnostics?.appendImmutable(client, record);
|
|
286
|
+
for (const record of input.events ?? [])
|
|
287
|
+
await records.events?.appendImmutable(client, record);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Validates the commit against the Entity boundary captured by this handle.
|
|
291
|
+
*
|
|
292
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
293
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
294
|
+
* @param input Defines the Entity records to validate.
|
|
295
|
+
*/
|
|
296
|
+
validate(input) {
|
|
297
|
+
if (!this.#open)
|
|
298
|
+
throw new PostgresStorageOperationError("Entity commit storage is closed.");
|
|
299
|
+
if (input.entity.sourceType.typeName !== this.entity.sourceType.typeName)
|
|
300
|
+
throw new PostgresStorageOperationError("Entity commit source type is incompatible.");
|
|
301
|
+
if (input.entity.stateSchema.typeName !== this.entity.stateSchema.typeName)
|
|
302
|
+
throw new PostgresStorageOperationError("Entity commit state schema is incompatible.");
|
|
303
|
+
if (!PostgresCommitValues.sameBoundary(input.context, this.entity.context) ||
|
|
304
|
+
!PostgresCommitValues.sameBoundary(input.entity.context, this.entity.context))
|
|
305
|
+
throw new PostgresStorageOperationError("Entity commit context is incompatible.");
|
|
306
|
+
if (input.states?.length && !this.entity.stateHistory)
|
|
307
|
+
throw new PostgresStorageOperationError("Entity state history is disabled.");
|
|
308
|
+
if (input.diagnostics?.length && !this.entity.eventHistory)
|
|
309
|
+
throw new PostgresStorageOperationError("Entity event history is disabled.");
|
|
310
|
+
this.validateRows(input);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Validates record identifiers inside one Entity commit.
|
|
314
|
+
*
|
|
315
|
+
* @typeParam Id Entity identifier type supplied by the commit.
|
|
316
|
+
* @typeParam State Entity state message type supplied by the commit.
|
|
317
|
+
* @param input Defines current and historical records to validate.
|
|
318
|
+
*/
|
|
319
|
+
validateRows(input) {
|
|
320
|
+
for (const record of [input.expected, input.next, ...(input.states ?? [])]) {
|
|
321
|
+
if (record === undefined)
|
|
322
|
+
continue;
|
|
323
|
+
const decoded = this.entity.id.unpack(record.entityId ?? {});
|
|
324
|
+
if (decoded === undefined ||
|
|
325
|
+
this.entity.id.key(decoded) !== this.entity.id.key(input.entityId))
|
|
326
|
+
throw new PostgresStorageOperationError("Entity commit record does not identify the requested Entity.");
|
|
327
|
+
}
|
|
328
|
+
this.validateEventIds(input.diagnostics, "diagnostic");
|
|
329
|
+
this.validateEventIds(input.events, "delivery");
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Validates event identifiers for one immutable event family.
|
|
333
|
+
*
|
|
334
|
+
* @param events Events to validate when the family is enabled.
|
|
335
|
+
* @param family Names the event family in validation errors.
|
|
336
|
+
*/
|
|
337
|
+
validateEventIds(events, family) {
|
|
338
|
+
const ids = events?.map((event) => event.id?.value) ?? [];
|
|
339
|
+
if (ids.some((id) => id === undefined))
|
|
340
|
+
throw new PostgresStorageOperationError(`Entity commit requires ${family} event IDs.`);
|
|
341
|
+
if (ids.some((id) => id?.trim() === ""))
|
|
342
|
+
throw new PostgresStorageOperationError(`Entity commit rejects blank ${family} event IDs.`);
|
|
343
|
+
if (new Set(ids).size !== ids.length)
|
|
344
|
+
throw new PostgresStorageOperationError(`Entity commit rejects duplicate ${family} event IDs.`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const PostgresCommitValues = Object.freeze({
|
|
348
|
+
/**
|
|
349
|
+
* Compares two Entity records through their Protobuf wire representation.
|
|
350
|
+
*
|
|
351
|
+
* @param left Stored Entity record.
|
|
352
|
+
* @param right Expected Entity record.
|
|
353
|
+
* @returns Whether both records are absent or have identical wire bytes.
|
|
354
|
+
*/
|
|
355
|
+
same(left, right) {
|
|
356
|
+
return left === undefined || right === undefined
|
|
357
|
+
? left === right
|
|
358
|
+
: Buffer.compare(toBinary(EntityRecordSchema, left), toBinary(EntityRecordSchema, right)) ===
|
|
359
|
+
0;
|
|
360
|
+
},
|
|
361
|
+
/**
|
|
362
|
+
* Compares two complete storage tenant boundaries.
|
|
363
|
+
*
|
|
364
|
+
* @param left First storage context.
|
|
365
|
+
* @param right Second storage context.
|
|
366
|
+
* @returns Whether both contexts select the same tenant boundary.
|
|
367
|
+
*/
|
|
368
|
+
sameBoundary(left, right) {
|
|
369
|
+
return TenantBoundary.of(left).key === TenantBoundary.of(right).key;
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
const PostgresCommitErrors = Object.freeze({
|
|
373
|
+
/**
|
|
374
|
+
* Converts an internal commit failure to the stable provider error.
|
|
375
|
+
*
|
|
376
|
+
* @param error Failure raised during the Entity commit.
|
|
377
|
+
* @returns Stable public commit error.
|
|
378
|
+
*/
|
|
379
|
+
operation(error) {
|
|
380
|
+
return error instanceof PostgresStorageOperationError
|
|
381
|
+
? error
|
|
382
|
+
: new PostgresStorageOperationError("PostgreSQL Entity commit failed.");
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
//# sourceMappingURL=entity-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-commit.js","sourceRoot":"","sources":["../../src/postgres/entity-commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EACL,kBAAkB,GAEnB,MAAM,sEAAsE,CAAC;AAE9E,OAAO,EAAsC,MAAM,6BAA6B,CAAC;AACjF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GAKjB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,GAGtB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,+BAA+B;IAMN;IAL7B;;;;OAIG;IACH,YAA6B,SAAkC;QAAlC,cAAS,GAAT,SAAS,CAAyB;IAAG,CAAC;IAEnE;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAI,IAAwC;QACtD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YAC9C,IAAI,OAA0B,CAAC;YAC/B,IAAI,CAAC;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spine/server/entity/entity_pb.js";
|
|
3
|
+
import type { EntityEventHistoryPort, EntityRecordStorage, EntityStateHistoryPort, EntityStorageInput } from "@spine-event-engine/storage/provider";
|
|
4
|
+
import { PostgresRecordStorage } from "./record-storage.js";
|
|
5
|
+
/**
|
|
6
|
+
* Opens one grouped PostgreSQL record family for an Entity history.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam I Record identifier type.
|
|
9
|
+
* @typeParam R Stored Protobuf record type.
|
|
10
|
+
*/
|
|
11
|
+
type OpenRecords = <I, R extends Message>(spec: import("@spine-event-engine/storage").RecordSpec<I, R>, group?: import("@spine-event-engine/storage").StorageGroup) => PostgresRecordStorage<I, R>;
|
|
12
|
+
/**
|
|
13
|
+
* Describes PostgreSQL-backed Entity record-family handles.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam I Entity identifier type.
|
|
16
|
+
* @typeParam S Entity state message type.
|
|
17
|
+
*/
|
|
18
|
+
export interface PostgresEntityStorageHandle<I, S extends Message> {
|
|
19
|
+
/**
|
|
20
|
+
* Exposes current Entity records.
|
|
21
|
+
*/
|
|
22
|
+
readonly current: EntityRecordStorage<I>;
|
|
23
|
+
/**
|
|
24
|
+
* Exposes Entity state history records.
|
|
25
|
+
*/
|
|
26
|
+
readonly states: EntityStateHistoryPort<I, S>;
|
|
27
|
+
/**
|
|
28
|
+
* Exposes Entity event history records.
|
|
29
|
+
*/
|
|
30
|
+
readonly events: EntityEventHistoryPort<I>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns whether this Entity storage handle accepts operations.
|
|
33
|
+
*
|
|
34
|
+
* @returns Whether the handle is open.
|
|
35
|
+
*/
|
|
36
|
+
isOpen(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Closes the Entity record-family handles.
|
|
39
|
+
*/
|
|
40
|
+
close(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Provides PostgreSQL-backed current Entity storage and optional disabled history ports.
|
|
44
|
+
*
|
|
45
|
+
* @typeParam I Entity identifier type.
|
|
46
|
+
* @typeParam S Entity state message type.
|
|
47
|
+
*/
|
|
48
|
+
export declare class PostgresEntityStorage<I, S extends Message> implements PostgresEntityStorageHandle<I, S> {
|
|
49
|
+
#private;
|
|
50
|
+
private readonly records;
|
|
51
|
+
private readonly onClose;
|
|
52
|
+
/**
|
|
53
|
+
* Exposes current Entity records.
|
|
54
|
+
*/
|
|
55
|
+
readonly current: EntityRecordStorage<I>;
|
|
56
|
+
/**
|
|
57
|
+
* Exposes optional Entity state history.
|
|
58
|
+
*/
|
|
59
|
+
readonly states: EntityStateHistoryPort<I, S>;
|
|
60
|
+
/**
|
|
61
|
+
* Exposes optional Entity event history.
|
|
62
|
+
*/
|
|
63
|
+
readonly events: EntityEventHistoryPort<I>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates Entity ports around one current-record handle.
|
|
66
|
+
*
|
|
67
|
+
* @param input Supplies Entity identity and materialized column definitions.
|
|
68
|
+
* @param records Stores current Entity record envelopes.
|
|
69
|
+
* @param open Opens grouped PostgreSQL record families.
|
|
70
|
+
* @param onClose Unregisters this Entity handle from its factory.
|
|
71
|
+
*/
|
|
72
|
+
constructor(input: EntityStorageInput<I, S>, records: PostgresRecordStorage<I, EntityRecord>, open: OpenRecords, onClose: () => void);
|
|
73
|
+
/**
|
|
74
|
+
* Returns whether this Entity handle accepts operations.
|
|
75
|
+
*
|
|
76
|
+
* @returns Whether this handle remains open.
|
|
77
|
+
*/
|
|
78
|
+
isOpen(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Closes the current-record handle and unregisters this Entity handle.
|
|
81
|
+
*/
|
|
82
|
+
close(): void;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=entity-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-history.d.ts","sourceRoot":"","sources":["../../src/postgres/entity-history.ts"],"names":[],"mappings":"AAcA,OAAO,EAAc,KAAK,OAAO,EAAE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