@spine-event-engine/server 2.0.0-snapshot.14 → 2.0.0-snapshot.15
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/README.md +18 -0
- package/REFERENCE.md +93 -7
- package/dist/entity/entity-transaction.d.ts +46 -42
- package/dist/entity/entity-transaction.d.ts.map +1 -1
- package/dist/entity/entity-transaction.js +130 -35
- package/dist/entity/entity-transaction.js.map +1 -1
- package/dist/entity/entity.d.ts +132 -84
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +213 -217
- package/dist/entity/entity.js.map +1 -1
- package/dist/handler/event-registration-readiness.d.ts +13 -56
- package/dist/handler/event-registration-readiness.d.ts.map +1 -1
- package/dist/handler/event-registration-readiness.js +23 -43
- package/dist/handler/event-registration-readiness.js.map +1 -1
- package/dist/handler/generated-handler-registry.d.ts +8 -0
- package/dist/handler/generated-handler-registry.d.ts.map +1 -1
- package/dist/handler/generated-handler-registry.js +165 -3
- package/dist/handler/generated-handler-registry.js.map +1 -1
- package/dist/handler/handler-decorators.d.ts +70 -33
- package/dist/handler/handler-decorators.d.ts.map +1 -1
- package/dist/handler/handler-decorators.js +88 -31
- package/dist/handler/handler-decorators.js.map +1 -1
- package/dist/handler/handler-metadata.d.ts +53 -51
- package/dist/handler/handler-metadata.d.ts.map +1 -1
- package/dist/handler/handler-metadata.js +214 -42
- package/dist/handler/handler-metadata.js.map +1 -1
- package/dist/handler/registration-readiness-metadata.d.ts +4 -0
- package/dist/handler/registration-readiness-metadata.d.ts.map +1 -1
- package/dist/handler/registration-readiness-metadata.js +82 -1
- package/dist/handler/registration-readiness-metadata.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/repository/repository.d.ts +137 -20
- package/dist/repository/repository.d.ts.map +1 -1
- package/dist/repository/repository.js +2589 -282
- package/dist/repository/repository.js.map +1 -1
- package/dist/runtime/standalone-handler-runtime.d.ts +16 -0
- package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -1
- package/dist/runtime/standalone-handler-runtime.js +93 -18
- package/dist/runtime/standalone-handler-runtime.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -52,6 +52,24 @@ results and structural or imported thenable lookalikes are rejected during handl
|
|
|
52
52
|
analysis. Rejection rolls back framework state and suppresses produced output; it
|
|
53
53
|
cannot roll back an external HTTP request or other side effect.
|
|
54
54
|
|
|
55
|
+
Handler return declarations can use native unions for one of several results,
|
|
56
|
+
or fixed tuples for several ordered results. For example,
|
|
57
|
+
`CreateAccessGrant | ExtendAccessGrant` selects one Command, while
|
|
58
|
+
`readonly [AccessGrantCreated, AccessRequestCompleted?]` returns an Event and
|
|
59
|
+
possibly a second Event. Each actual result must be declared by that handler.
|
|
60
|
+
Arrays and local/imported aliases of these concrete message types are supported
|
|
61
|
+
too. `@Assign` returns Events, `@Command` returns Commands, `@React` returns
|
|
62
|
+
Events or `undefined`, and `@Subscribe` declares `void` or `Promise<void>`.
|
|
63
|
+
Event/rejection-input `@Command` also permits `undefined`, alone or alongside
|
|
64
|
+
concrete Command types. Only subscriptions accept `void`; required empty
|
|
65
|
+
results and unexpected returned values fail before Entity commit or publication.
|
|
66
|
+
See the [return-type guide](https://github.com/SpineEventEngine/spine-ts/blob/master/docs/USER_GUIDE.md#choose-what-a-handler-returns)
|
|
67
|
+
for examples, optional results, and the restrictions for each decorator.
|
|
68
|
+
|
|
69
|
+
Every Entity's `version` is the generated Spine `Version`; the framework
|
|
70
|
+
advances it once when a successful dispatch produces Events or changes state or
|
|
71
|
+
lifecycle, not for a no-op.
|
|
72
|
+
|
|
55
73
|
Declare each domain rejection a command handler may throw. This registers the
|
|
56
74
|
rejection before the server starts, so a client can subscribe even when no
|
|
57
75
|
server handler consumes that rejection:
|
package/REFERENCE.md
CHANGED
|
@@ -253,6 +253,92 @@ rejection-input command reactions during generated metadata ingestion and
|
|
|
253
253
|
repository construction.
|
|
254
254
|
Event- and rejection-input `@Command` methods remain Event- or
|
|
255
255
|
rejection-to-command reactions on Event Bus.
|
|
256
|
+
|
|
257
|
+
### Handler return types
|
|
258
|
+
|
|
259
|
+
Use a TypeScript union such as `CreateAccessGrant | ExtendAccessGrant` to return
|
|
260
|
+
one of several Commands. A tuple such as
|
|
261
|
+
`readonly [AccessGrantCreated, AccessRequestCompleted?]` returns multiple Events
|
|
262
|
+
in order, with the second optional. Either declaration may have one outer
|
|
263
|
+
`Promise` layer. Generated metadata lists every possible schema; runtime checks
|
|
264
|
+
each result against the invoked handler's list. A whole result may be absent
|
|
265
|
+
for `@React` and Event/rejection-input `@Command`, using a generated signal type
|
|
266
|
+
unioned with `undefined`. A reaction that never emits can declare `undefined`
|
|
267
|
+
alone or `Promise<undefined>`. Either reaction kind may also return an empty
|
|
268
|
+
typed array. Command-input `@Command` and `@Assign` require nonempty results.
|
|
269
|
+
`@Subscribe` declares `void` or `Promise<void>` and produces no signals.
|
|
270
|
+
`@Throws` declares thrown rejections separately from normal results.
|
|
271
|
+
|
|
272
|
+
Only subscriptions accept `void`. An absent reaction result or optional tuple
|
|
273
|
+
entry uses `undefined`, never `null`. The framework validates all returned
|
|
274
|
+
values before committing Entity changes or publishing outputs. An invalid
|
|
275
|
+
subscription result fails even if it is an empty array. A valid no-output
|
|
276
|
+
reaction still saves its Entity state changes.
|
|
277
|
+
|
|
278
|
+
Other supported forms are `T[]`, `readonly T[]`, `Array<T>`, `ReadonlyArray<T>`,
|
|
279
|
+
named tuple entries, union alternatives inside tuple entries, and local or
|
|
280
|
+
imported aliases resolving to concrete generated messages. Only one flat
|
|
281
|
+
collection level is supported. Rest tuples, nested collections, nested promises,
|
|
282
|
+
custom thenables, framework envelopes, and unresolved/`any`/`unknown` result
|
|
283
|
+
branches are rejected. TypeScript enforces tuple structure; the runtime checks
|
|
284
|
+
declared message types, required nonempty results, and result order, not tuple
|
|
285
|
+
arity or positional schema constraints. See the
|
|
286
|
+
[user guide](https://github.com/SpineEventEngine/spine-ts/blob/master/docs/USER_GUIDE.md#choose-what-a-handler-returns) for a compact
|
|
287
|
+
return-type table and examples.
|
|
288
|
+
|
|
289
|
+
These independent examples use generated review-workflow messages. The Commander
|
|
290
|
+
chooses whether to start or schedule a review. The reactor example shows a
|
|
291
|
+
different workflow: record a started review and optionally schedule a follow-up.
|
|
292
|
+
They illustrate return declarations, not two handlers to register together.
|
|
293
|
+
|
|
294
|
+
<!-- docs-snippet-path: packages/server/test/runtime/standalone-handler-runtime.test.ts -->
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
import { create } from "@bufbuild/protobuf";
|
|
298
|
+
import {
|
|
299
|
+
AbstractCommander,
|
|
300
|
+
AbstractEventReactor,
|
|
301
|
+
Command,
|
|
302
|
+
React,
|
|
303
|
+
} from "@spine-event-engine/server";
|
|
304
|
+
import {
|
|
305
|
+
StartReviewSchema,
|
|
306
|
+
ScheduleReviewSchema,
|
|
307
|
+
type StartReview,
|
|
308
|
+
type ScheduleReview,
|
|
309
|
+
} from "../../test-fixtures/generated/handler-registry/commands_pb.js";
|
|
310
|
+
import {
|
|
311
|
+
ReviewStartedSchema,
|
|
312
|
+
ReviewFollowUpScheduledSchema,
|
|
313
|
+
type ReviewStarted,
|
|
314
|
+
type ReviewFollowUpScheduled,
|
|
315
|
+
type ReviewTaskAssigned,
|
|
316
|
+
} from "../../test-fixtures/generated/handler-registry/events_pb.js";
|
|
317
|
+
|
|
318
|
+
export class ReviewCommander extends AbstractCommander {
|
|
319
|
+
@Command
|
|
320
|
+
planReview(event: ReviewTaskAssigned): StartReview | ScheduleReview {
|
|
321
|
+
// Return one Command, choosing its type using the application's rules.
|
|
322
|
+
return event.name === "Security review"
|
|
323
|
+
? create(ScheduleReviewSchema, { id: event.id })
|
|
324
|
+
: create(StartReviewSchema, { id: event.id });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export class ReviewReactor extends AbstractEventReactor {
|
|
329
|
+
@React
|
|
330
|
+
recordReview(event: ReviewTaskAssigned): readonly [ReviewStarted, ReviewFollowUpScheduled?] {
|
|
331
|
+
const started = create(ReviewStartedSchema, { id: event.id });
|
|
332
|
+
// A tuple returns ordered Events. Its optional second value may be absent.
|
|
333
|
+
if (event.name !== "Security review") return [started];
|
|
334
|
+
return [
|
|
335
|
+
started,
|
|
336
|
+
create(ReviewFollowUpScheduledSchema, { id: event.id, name: "Security follow-up" }),
|
|
337
|
+
];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
256
342
|
Produced commands retain the source actor, tenant, origin, and causal lineage.
|
|
257
343
|
The enqueue is post-commit best effort, not an atomic outbox or exactly-once
|
|
258
344
|
delivery: a process crash between commit and enqueue can lose a child. Accepted
|
|
@@ -299,11 +385,7 @@ import {
|
|
|
299
385
|
type ProjectId,
|
|
300
386
|
} from "../generated/spine/server/testing/project_workflow_pb.js";
|
|
301
387
|
|
|
302
|
-
class ApprovalCoordinator extends ProcessManager<
|
|
303
|
-
ProjectId,
|
|
304
|
-
typeof CoordinationStateSchema,
|
|
305
|
-
number
|
|
306
|
-
> {
|
|
388
|
+
class ApprovalCoordinator extends ProcessManager<ProjectId, typeof CoordinationStateSchema> {
|
|
307
389
|
@Command
|
|
308
390
|
approve(command: ApproveProject, context: CommandContext): ScheduleProject {
|
|
309
391
|
this.update((draft) => Object.assign(draft, { id: this.id, projectName: command.status }));
|
|
@@ -335,7 +417,7 @@ const registry: GeneratedHandlerRegistry = {
|
|
|
335
417
|
};
|
|
336
418
|
const [handlers] = new HandlerRegistryIngestor().ingest(registry);
|
|
337
419
|
if (handlers === undefined) throw new Error("Generated Process Manager metadata is missing.");
|
|
338
|
-
const repository = new Repository({
|
|
420
|
+
const repository = new Repository<typeof ApprovalCoordinator>({
|
|
339
421
|
entityType: ApprovalCoordinator,
|
|
340
422
|
schema: CoordinationStateSchema,
|
|
341
423
|
handlers: handlers as EntityHandlersMetadata<ApprovalCoordinator, typeof CoordinationStateSchema>,
|
|
@@ -453,7 +535,7 @@ record-storage handle, while the context closes the registry.
|
|
|
453
535
|
|
|
454
536
|
`Entity` is the state base class. `Aggregate`, `Projection`, and
|
|
455
537
|
`ProcessManager` identify the three entity families. Handler decorators are
|
|
456
|
-
`@Assign`, `@Command`, `@React`,
|
|
538
|
+
`@Assign`, `@Command`, `@React`, and `@Subscribe`. A command-accepting
|
|
457
539
|
handler uses `@Throws(GeneratedRejection)` to declare its possible domain
|
|
458
540
|
rejections. Write the primary handler decorator first and `@Throws` immediately
|
|
459
541
|
below it; declaration order does not affect behavior. Generated metadata records
|
|
@@ -464,6 +546,10 @@ handler, `update(mutator)` changes the active draft and returns the draft;
|
|
|
464
546
|
`tryUpdate(mutator)` validates a scratch draft and returns violations without
|
|
465
547
|
applying an invalid change. Entity lifecycle and version changes are committed
|
|
466
548
|
only after the transaction accepts.
|
|
549
|
+
Every Entity exposes the generated Spine `Version` message, starting at number
|
|
550
|
+
zero. A dispatch that produces Events or changes state or lifecycle advances it
|
|
551
|
+
once; no-op and rejected dispatches do not. Repositories restore and persist the
|
|
552
|
+
full Version, including its timestamp, across current state, history, and Stand.
|
|
467
553
|
|
|
468
554
|
## Signals, validation, and rejection behavior
|
|
469
555
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MessageShape } from "@bufbuild/protobuf";
|
|
2
|
-
import { type ConstraintViolation } from "@spine-event-engine/proto";
|
|
2
|
+
import { type ConstraintViolation, type Version } from "@spine-event-engine/proto";
|
|
3
3
|
import type { DescriptorMessageSchema } from "./entity-metadata.js";
|
|
4
4
|
import { type StateTransitionResult } from "./entity-transition-validation.js";
|
|
5
5
|
/**
|
|
@@ -16,28 +16,28 @@ export interface EntityTransactionLifecycleFlags {
|
|
|
16
16
|
readonly deleted: boolean;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Spine Version values captured before a transaction commits.
|
|
20
20
|
*/
|
|
21
|
-
export interface EntityTransactionVersionMetadata
|
|
21
|
+
export interface EntityTransactionVersionMetadata {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Version of the Entity before this transaction.
|
|
24
24
|
*/
|
|
25
25
|
readonly previous: Version;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Version copied into the initial draft.
|
|
28
28
|
*/
|
|
29
29
|
readonly draft: Version;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Spine Version values before and after an accepted commit.
|
|
33
33
|
*/
|
|
34
|
-
export interface CommittedVersionMetadata
|
|
34
|
+
export interface CommittedVersionMetadata {
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Version of the Entity before this transaction.
|
|
37
37
|
*/
|
|
38
38
|
readonly previous: Version;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Version calculated by the accepted commit.
|
|
41
41
|
*/
|
|
42
42
|
readonly committed: Version;
|
|
43
43
|
}
|
|
@@ -48,7 +48,7 @@ export type EntityTransactionStatus = "active" | "committed" | "rolled-back";
|
|
|
48
48
|
/**
|
|
49
49
|
* Transaction operation guarded by active-status checks.
|
|
50
50
|
*/
|
|
51
|
-
export type EntityTransactionOperation = "archive" | "commit" | "markDeleted" | "requireActive" | "restore" | "rollback" | "tryUpdate" | "unarchive" | "update"
|
|
51
|
+
export type EntityTransactionOperation = "archive" | "commit" | "markDeleted" | "requireActive" | "restore" | "rollback" | "tryUpdate" | "unarchive" | "update";
|
|
52
52
|
/**
|
|
53
53
|
* Draft lifecycle reason that prevents active-only entity state mutation.
|
|
54
54
|
*/
|
|
@@ -56,13 +56,16 @@ export type DraftStateReason = "archived" | "deleted";
|
|
|
56
56
|
/**
|
|
57
57
|
* Updates an entity-state draft in place.
|
|
58
58
|
*
|
|
59
|
+
* @typeParam Schema Generated schema describing the mutable draft state.
|
|
59
60
|
* @param draft Live or scratch state draft to mutate synchronously.
|
|
60
61
|
*/
|
|
61
62
|
export type EntityTransactionMutator<Schema extends DescriptorMessageSchema> = (draft: MessageShape<Schema>) => void;
|
|
62
63
|
/**
|
|
63
64
|
* Options for creating an {@link EntityTransaction}.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam Schema Generated schema describing the Entity state.
|
|
64
67
|
*/
|
|
65
|
-
export interface EntityTransactionOptions<Schema extends DescriptorMessageSchema
|
|
68
|
+
export interface EntityTransactionOptions<Schema extends DescriptorMessageSchema> {
|
|
66
69
|
/**
|
|
67
70
|
* Generated Protobuf-ES schema describing the entity state.
|
|
68
71
|
*/
|
|
@@ -76,9 +79,9 @@ export interface EntityTransactionOptions<Schema extends DescriptorMessageSchema
|
|
|
76
79
|
*/
|
|
77
80
|
readonly draft?: MessageShape<Schema>;
|
|
78
81
|
/**
|
|
79
|
-
*
|
|
82
|
+
* Spine Version snapshots supplied by framework transaction code.
|
|
80
83
|
*/
|
|
81
|
-
readonly version: EntityTransactionVersionMetadata
|
|
84
|
+
readonly version: EntityTransactionVersionMetadata;
|
|
82
85
|
/**
|
|
83
86
|
* Draft lifecycle flags. Defaults to active, not deleted.
|
|
84
87
|
*/
|
|
@@ -86,8 +89,10 @@ export interface EntityTransactionOptions<Schema extends DescriptorMessageSchema
|
|
|
86
89
|
}
|
|
87
90
|
/**
|
|
88
91
|
* Result returned when a transaction commit is accepted.
|
|
92
|
+
*
|
|
93
|
+
* @typeParam Schema Generated schema describing the committed Entity state.
|
|
89
94
|
*/
|
|
90
|
-
export interface EntityTransactionAcceptedCommit<Schema extends DescriptorMessageSchema
|
|
95
|
+
export interface EntityTransactionAcceptedCommit<Schema extends DescriptorMessageSchema> {
|
|
91
96
|
/**
|
|
92
97
|
* Commit result discriminator.
|
|
93
98
|
*/
|
|
@@ -103,7 +108,7 @@ export interface EntityTransactionAcceptedCommit<Schema extends DescriptorMessag
|
|
|
103
108
|
/**
|
|
104
109
|
* Accepted commit version metadata.
|
|
105
110
|
*/
|
|
106
|
-
readonly version: CommittedVersionMetadata
|
|
111
|
+
readonly version: CommittedVersionMetadata;
|
|
107
112
|
/**
|
|
108
113
|
* Lifecycle flags accepted with the committed state.
|
|
109
114
|
*/
|
|
@@ -117,8 +122,10 @@ export interface EntityTransactionAcceptedCommit<Schema extends DescriptorMessag
|
|
|
117
122
|
}
|
|
118
123
|
/**
|
|
119
124
|
* Result returned when a transaction commit is rejected by validation.
|
|
125
|
+
*
|
|
126
|
+
* @typeParam Schema Generated schema describing the rejected Entity state.
|
|
120
127
|
*/
|
|
121
|
-
export interface EntityTransactionRejectedCommit<Schema extends DescriptorMessageSchema
|
|
128
|
+
export interface EntityTransactionRejectedCommit<Schema extends DescriptorMessageSchema> {
|
|
122
129
|
/**
|
|
123
130
|
* Commit result discriminator.
|
|
124
131
|
*/
|
|
@@ -134,7 +141,7 @@ export interface EntityTransactionRejectedCommit<Schema extends DescriptorMessag
|
|
|
134
141
|
/**
|
|
135
142
|
* Draft version metadata that was not accepted.
|
|
136
143
|
*/
|
|
137
|
-
readonly version: EntityTransactionVersionMetadata
|
|
144
|
+
readonly version: EntityTransactionVersionMetadata;
|
|
138
145
|
/**
|
|
139
146
|
* Lifecycle flags that were not accepted.
|
|
140
147
|
*/
|
|
@@ -148,12 +155,16 @@ export interface EntityTransactionRejectedCommit<Schema extends DescriptorMessag
|
|
|
148
155
|
}
|
|
149
156
|
/**
|
|
150
157
|
* Structured result returned by {@link EntityTransaction.commit}.
|
|
158
|
+
*
|
|
159
|
+
* @typeParam Schema Generated schema describing the transaction's state.
|
|
151
160
|
*/
|
|
152
|
-
export type EntityTransactionCommitResult<Schema extends DescriptorMessageSchema
|
|
161
|
+
export type EntityTransactionCommitResult<Schema extends DescriptorMessageSchema> = EntityTransactionAcceptedCommit<Schema> | EntityTransactionRejectedCommit<Schema>;
|
|
153
162
|
/**
|
|
154
163
|
* Structured result returned by {@link EntityTransaction.rollback}.
|
|
164
|
+
*
|
|
165
|
+
* @typeParam Schema Generated schema describing the discarded draft state.
|
|
155
166
|
*/
|
|
156
|
-
export interface EntityTransactionRollbackResult<Schema extends DescriptorMessageSchema
|
|
167
|
+
export interface EntityTransactionRollbackResult<Schema extends DescriptorMessageSchema> {
|
|
157
168
|
/**
|
|
158
169
|
* Rollback result discriminator.
|
|
159
170
|
*/
|
|
@@ -169,7 +180,7 @@ export interface EntityTransactionRollbackResult<Schema extends DescriptorMessag
|
|
|
169
180
|
/**
|
|
170
181
|
* Draft version metadata that was discarded.
|
|
171
182
|
*/
|
|
172
|
-
readonly version: EntityTransactionVersionMetadata
|
|
183
|
+
readonly version: EntityTransactionVersionMetadata;
|
|
173
184
|
/**
|
|
174
185
|
* Lifecycle flags that were discarded.
|
|
175
186
|
*/
|
|
@@ -215,20 +226,22 @@ export declare class DraftStateError extends Error {
|
|
|
215
226
|
constructor(reason: DraftStateReason);
|
|
216
227
|
}
|
|
217
228
|
/**
|
|
218
|
-
* Framework
|
|
229
|
+
* Framework transaction over one buffered Entity state draft.
|
|
219
230
|
*
|
|
220
|
-
* The transaction
|
|
231
|
+
* The transaction manages only in-memory draft and result data. It does not invoke
|
|
221
232
|
* handlers, write repositories, apply snapshots, dispatch messages, start
|
|
222
233
|
* buses, or participate in async-local/global transaction state.
|
|
234
|
+
*
|
|
235
|
+
* @typeParam Schema Generated schema describing the Entity state.
|
|
223
236
|
*/
|
|
224
|
-
export declare class EntityTransaction<Schema extends DescriptorMessageSchema
|
|
237
|
+
export declare class EntityTransaction<Schema extends DescriptorMessageSchema> {
|
|
225
238
|
#private;
|
|
226
239
|
/**
|
|
227
240
|
* Creates a transaction over previous state and a buffered draft.
|
|
228
241
|
*
|
|
229
242
|
* @param options State, version, and lifecycle inputs for the transaction.
|
|
230
243
|
*/
|
|
231
|
-
constructor(options: EntityTransactionOptions<Schema
|
|
244
|
+
constructor(options: EntityTransactionOptions<Schema>);
|
|
232
245
|
/**
|
|
233
246
|
* Gets the current lifecycle status of the transaction.
|
|
234
247
|
*
|
|
@@ -248,11 +261,11 @@ export declare class EntityTransaction<Schema extends DescriptorMessageSchema, V
|
|
|
248
261
|
*/
|
|
249
262
|
get currentDraft(): MessageShape<Schema>;
|
|
250
263
|
/**
|
|
251
|
-
* Gets
|
|
264
|
+
* Gets independent copies of the initial Spine Version values.
|
|
252
265
|
*
|
|
253
|
-
* @returns
|
|
266
|
+
* @returns Previous and initial draft Version snapshots.
|
|
254
267
|
*/
|
|
255
|
-
get version(): EntityTransactionVersionMetadata
|
|
268
|
+
get version(): EntityTransactionVersionMetadata;
|
|
256
269
|
/**
|
|
257
270
|
* Gets lifecycle flags carried by the current draft.
|
|
258
271
|
*
|
|
@@ -331,27 +344,17 @@ export declare class EntityTransaction<Schema extends DescriptorMessageSchema, V
|
|
|
331
344
|
* @returns The changed lifecycle flags.
|
|
332
345
|
*/
|
|
333
346
|
restore(): EntityTransactionLifecycleFlags;
|
|
334
|
-
/**
|
|
335
|
-
* Updates caller-owned explicit draft version metadata.
|
|
336
|
-
*
|
|
337
|
-
* This helper does not compute version increments, timestamps, producer
|
|
338
|
-
* metadata, or event versions. It preserves the transaction's `Version`
|
|
339
|
-
* generic and returns a snapshot of the previous/draft metadata pair.
|
|
340
|
-
*
|
|
341
|
-
* @param draft Replacement caller-owned draft version metadata.
|
|
342
|
-
* @returns The updated previous and draft metadata.
|
|
343
|
-
*/
|
|
344
|
-
updateVersionMetadata(draft: Version): EntityTransactionVersionMetadata<Version>;
|
|
345
347
|
/**
|
|
346
348
|
* Validates and commits the current draft at this transaction boundary.
|
|
347
349
|
*
|
|
348
350
|
* Ordinary entity state validation failures are returned as rejected commit
|
|
349
351
|
* results with validator violations. They do not throw and do not mark the
|
|
350
|
-
* transaction committed.
|
|
352
|
+
* transaction committed. A no-op skips validation and preserves the version.
|
|
351
353
|
*
|
|
354
|
+
* @param producedEvents Whether handling returned Events, requiring a version advance.
|
|
352
355
|
* @returns An accepted commit or a validation-rejected result.
|
|
353
356
|
*/
|
|
354
|
-
commit(): EntityTransactionCommitResult<Schema
|
|
357
|
+
commit(producedEvents?: boolean): EntityTransactionCommitResult<Schema>;
|
|
355
358
|
/**
|
|
356
359
|
* Returns unaccepted draft evidence and closes the transaction.
|
|
357
360
|
*
|
|
@@ -360,13 +363,14 @@ export declare class EntityTransaction<Schema extends DescriptorMessageSchema, V
|
|
|
360
363
|
*
|
|
361
364
|
* @returns The discarded draft and prior-state evidence.
|
|
362
365
|
*/
|
|
363
|
-
rollback(): EntityTransactionRollbackResult<Schema
|
|
366
|
+
rollback(): EntityTransactionRollbackResult<Schema>;
|
|
364
367
|
}
|
|
365
368
|
/**
|
|
366
369
|
* Creates a transaction with inferred schema state typing.
|
|
367
370
|
*
|
|
371
|
+
* @typeParam Schema Generated schema describing the transaction's state.
|
|
368
372
|
* @param options State, version, and lifecycle inputs for the transaction.
|
|
369
373
|
* @returns A new isolated entity transaction.
|
|
370
374
|
*/
|
|
371
|
-
export declare function createEntityTransaction<Schema extends DescriptorMessageSchema
|
|
375
|
+
export declare function createEntityTransaction<Schema extends DescriptorMessageSchema>(options: EntityTransactionOptions<Schema>): EntityTransaction<Schema>;
|
|
372
376
|
//# sourceMappingURL=entity-transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-transaction.d.ts","sourceRoot":"","sources":["../../src/entity/entity-transaction.ts"],"names":[],"mappings":"AAcA,OAAO,EAAuC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"entity-transaction.d.ts","sourceRoot":"","sources":["../../src/entity/entity-transaction.ts"],"names":[],"mappings":"AAcA,OAAO,EAAuC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,m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