@entifix/transactions 0.14.0 → 0.16.0
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 +6 -6
- package/dist/contracts/flow-messages.d.ts +3 -3
- package/dist/contracts/flow-messages.d.ts.map +1 -1
- package/dist/contracts/flow-messages.js +7 -3
- package/dist/contracts/flow-messages.js.map +1 -1
- package/dist/engine/index.d.ts +2 -9
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +3 -10
- package/dist/engine/index.js.map +1 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -14
- package/dist/index.js.map +1 -1
- package/dist/ports/flow-engine.d.ts +17 -8
- package/dist/ports/flow-engine.d.ts.map +1 -1
- package/dist/ports/flow-engine.js +2 -2
- package/dist/ports/flow-engine.js.map +1 -1
- package/dist/ports/participant-client.d.ts +7 -2
- package/dist/ports/participant-client.d.ts.map +1 -1
- package/dist/ports/participant-client.js.map +1 -1
- package/package.json +4 -4
- package/dist/contracts/command.d.ts +0 -59
- package/dist/contracts/command.d.ts.map +0 -1
- package/dist/contracts/command.js +0 -46
- package/dist/contracts/command.js.map +0 -1
- package/dist/contracts/event.d.ts +0 -85
- package/dist/contracts/event.d.ts.map +0 -1
- package/dist/contracts/event.js +0 -81
- package/dist/contracts/event.js.map +0 -1
- package/dist/contracts/messages.d.ts +0 -37
- package/dist/contracts/messages.d.ts.map +0 -1
- package/dist/contracts/messages.js +0 -68
- package/dist/contracts/messages.js.map +0 -1
- package/dist/contracts/record.d.ts +0 -106
- package/dist/contracts/record.d.ts.map +0 -1
- package/dist/contracts/record.js +0 -27
- package/dist/contracts/record.js.map +0 -1
- package/dist/contracts/saga-definition.d.ts +0 -181
- package/dist/contracts/saga-definition.d.ts.map +0 -1
- package/dist/contracts/saga-definition.js +0 -101
- package/dist/contracts/saga-definition.js.map +0 -1
- package/dist/engine/local-saga-dispatcher.d.ts +0 -35
- package/dist/engine/local-saga-dispatcher.d.ts.map +0 -1
- package/dist/engine/local-saga-dispatcher.js +0 -28
- package/dist/engine/local-saga-dispatcher.js.map +0 -1
- package/dist/engine/resolve-template.d.ts +0 -48
- package/dist/engine/resolve-template.d.ts.map +0 -1
- package/dist/engine/resolve-template.js +0 -95
- package/dist/engine/resolve-template.js.map +0 -1
- package/dist/engine/resume-sweep.d.ts +0 -46
- package/dist/engine/resume-sweep.d.ts.map +0 -1
- package/dist/engine/resume-sweep.js +0 -74
- package/dist/engine/resume-sweep.js.map +0 -1
- package/dist/engine/run-saga.d.ts +0 -54
- package/dist/engine/run-saga.d.ts.map +0 -1
- package/dist/engine/run-saga.js +0 -463
- package/dist/engine/run-saga.js.map +0 -1
- package/dist/engine/run-transaction.d.ts +0 -55
- package/dist/engine/run-transaction.d.ts.map +0 -1
- package/dist/engine/run-transaction.js +0 -101
- package/dist/engine/run-transaction.js.map +0 -1
- package/dist/mixins/transaction-mixins.d.ts +0 -20
- package/dist/mixins/transaction-mixins.d.ts.map +0 -1
- package/dist/mixins/transaction-mixins.js +0 -13
- package/dist/mixins/transaction-mixins.js.map +0 -1
- package/dist/ports/lock-service.d.ts +0 -24
- package/dist/ports/lock-service.d.ts.map +0 -1
- package/dist/ports/lock-service.js +0 -5
- package/dist/ports/lock-service.js.map +0 -1
- package/dist/ports/saga-dispatcher.d.ts +0 -46
- package/dist/ports/saga-dispatcher.d.ts.map +0 -1
- package/dist/ports/saga-dispatcher.js +0 -5
- package/dist/ports/saga-dispatcher.js.map +0 -1
- package/dist/ports/saga-store.d.ts +0 -96
- package/dist/ports/saga-store.d.ts.map +0 -1
- package/dist/ports/saga-store.js +0 -19
- package/dist/ports/saga-store.js.map +0 -1
- package/dist/ports/sequence-service.d.ts +0 -17
- package/dist/ports/sequence-service.d.ts.map +0 -1
- package/dist/ports/sequence-service.js +0 -5
- package/dist/ports/sequence-service.js.map +0 -1
- package/dist/ports/transaction-handler.d.ts +0 -66
- package/dist/ports/transaction-handler.d.ts.map +0 -1
- package/dist/ports/transaction-handler.js +0 -5
- package/dist/ports/transaction-handler.js.map +0 -1
- package/dist/ports/transaction-sink.d.ts +0 -120
- package/dist/ports/transaction-sink.d.ts.map +0 -1
- package/dist/ports/transaction-sink.js +0 -28
- package/dist/ports/transaction-sink.js.map +0 -1
- package/dist/ports/transaction-stream-hub.d.ts +0 -28
- package/dist/ports/transaction-stream-hub.d.ts.map +0 -1
- package/dist/ports/transaction-stream-hub.js +0 -5
- package/dist/ports/transaction-stream-hub.js.map +0 -1
- package/dist/stream/transaction-stream-hub.d.ts +0 -18
- package/dist/stream/transaction-stream-hub.d.ts.map +0 -1
- package/dist/stream/transaction-stream-hub.js +0 -50
- package/dist/stream/transaction-stream-hub.js.map +0 -1
- package/dist/use-case/facade.uc.d.ts +0 -22
- package/dist/use-case/facade.uc.d.ts.map +0 -1
- package/dist/use-case/facade.uc.js +0 -55
- package/dist/use-case/facade.uc.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @entifix/transactions
|
|
2
2
|
|
|
3
|
-
Writes that span more than one step.
|
|
3
|
+
Writes that span more than one step. The event announcing a write is enqueued in an outbox inside the same unit of work as the write itself, ordered per aggregate; a redelivered message is claimed once through the inbox; and a flow across several services is a composed slip run by a durable engine behind the `FlowEngineTag` port, whose participants are guarded by a circuit breaker, a bulkhead and a retry budget.
|
|
4
4
|
|
|
5
|
-
This package holds the ports and the
|
|
5
|
+
This package holds the ports and the in-memory resilience engines only. The storage and transport behind them come from `@entifix/mongo/transactions`, `@entifix/sql/transactions`, `@entifix/amqp/transactions` and `@entifix/workflow`.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -12,10 +12,10 @@ pnpm add @entifix/transactions effect
|
|
|
12
12
|
|
|
13
13
|
## Entry points
|
|
14
14
|
|
|
15
|
-
| Import | What it holds
|
|
16
|
-
| ------------------------------ |
|
|
17
|
-
| `@entifix/transactions` |
|
|
18
|
-
| `@entifix/transactions/engine` | The
|
|
15
|
+
| Import | What it holds |
|
|
16
|
+
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| `@entifix/transactions` | The unit of work; inbox, outbox and event-bus ports; the flow engine, participant client, circuit breaker, bulkhead and retry budget ports; flow messages and capabilities; `On` |
|
|
18
|
+
| `@entifix/transactions/engine` | The in-memory circuit breaker, bulkhead and retry budget, and the outbox relay and its metrics |
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type AudienceEntry } from '@entifix/core';
|
|
2
2
|
import { Schema } from 'effect';
|
|
3
3
|
import type { OutboxEvent } from './outbox.js';
|
|
4
|
-
/** The
|
|
5
|
-
export declare const FLOW_EVENTS: readonly ["flow.started", "flow.completed", "flow.failed", "flow.suspended"];
|
|
4
|
+
/** The five things a flow announces about itself. */
|
|
5
|
+
export declare const FLOW_EVENTS: readonly ["flow.started", "flow.completed", "flow.failed", "flow.suspended", "flow.stranded"];
|
|
6
6
|
export type FlowEventName = (typeof FLOW_EVENTS)[number];
|
|
7
7
|
/**
|
|
8
8
|
* What a `flow.*` event carries. A `flow.failed` without a failure, or with a
|
|
@@ -41,7 +41,7 @@ export type FlowAccepted = typeof FlowAccepted.Type;
|
|
|
41
41
|
*/
|
|
42
42
|
export declare const FlowStatusBody: Schema.Struct<{
|
|
43
43
|
readonly flowId: Schema.String;
|
|
44
|
-
readonly state: Schema.Literals<readonly ["running", "waiting", "suspended", "completed", "compensated", "failed", "interrupted"]>;
|
|
44
|
+
readonly state: Schema.Literals<readonly ["running", "waiting", "suspended", "completed", "compensated", "failed", "interrupted", "stranded"]>;
|
|
45
45
|
readonly step: Schema.optionalKey<Schema.String>;
|
|
46
46
|
readonly failure: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
47
47
|
code: Schema.NonEmptyString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-messages.d.ts","sourceRoot":"","sources":["../../src/contracts/flow-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,qDAAqD;AACrD,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"flow-messages.d.ts","sourceRoot":"","sources":["../../src/contracts/flow-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,qDAAqD;AACrD,eAAO,MAAM,WAAW,+FAMd,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAQzD;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;EAOxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;AAYtD;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;EAQvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAIpD;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;;;;;;EAgBzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAIxD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,cAAc,KACpB,WAAW,CAAC,aAAa,CAU1B,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
2
|
import { openStruct, registerEvent, registerMessage } from '@entifix/core';
|
|
3
3
|
import { Schema } from 'effect';
|
|
4
|
-
/** The
|
|
4
|
+
/** The five things a flow announces about itself. */ export const FLOW_EVENTS = [
|
|
5
5
|
'flow.started',
|
|
6
6
|
'flow.completed',
|
|
7
7
|
'flow.failed',
|
|
8
|
-
'flow.suspended'
|
|
8
|
+
'flow.suspended',
|
|
9
|
+
'flow.stranded'
|
|
9
10
|
];
|
|
10
11
|
/** A failure inside an asynchronous message: the problem's code and category. */ const FlowFailure = openStruct({
|
|
11
12
|
code: Schema.NonEmptyString,
|
|
@@ -57,7 +58,10 @@ registerMessage('flowAccepted', FlowAccepted);
|
|
|
57
58
|
'completed',
|
|
58
59
|
'compensated',
|
|
59
60
|
'failed',
|
|
60
|
-
'interrupted'
|
|
61
|
+
'interrupted',
|
|
62
|
+
// A wait's timeout stranded it for a person; like `suspended`, a browser
|
|
63
|
+
// holding it pending keeps it pending — the write neither landed nor failed.
|
|
64
|
+
'stranded'
|
|
61
65
|
]),
|
|
62
66
|
step: Schema.optionalKey(Schema.String),
|
|
63
67
|
failure: Schema.optionalKey(FlowFailure)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contracts/flow-messages.ts"],"sourcesContent":["import {\n type AudienceEntry,\n openStruct,\n registerEvent,\n registerMessage,\n} from '@entifix/core';\nimport { Schema } from 'effect';\n\nimport type { OutboxEvent } from './outbox.js';\n\n/** The
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/flow-messages.ts"],"sourcesContent":["import {\n type AudienceEntry,\n openStruct,\n registerEvent,\n registerMessage,\n} from '@entifix/core';\nimport { Schema } from 'effect';\n\nimport type { OutboxEvent } from './outbox.js';\n\n/** The five things a flow announces about itself. */\nexport const FLOW_EVENTS = [\n 'flow.started',\n 'flow.completed',\n 'flow.failed',\n 'flow.suspended',\n 'flow.stranded',\n] as const;\nexport type FlowEventName = (typeof FLOW_EVENTS)[number];\n\n/** A failure inside an asynchronous message: the problem's code and category. */\nconst FlowFailure = openStruct({\n code: Schema.NonEmptyString,\n category: Schema.NonEmptyString,\n});\n\n/**\n * What a `flow.*` event carries. A `flow.failed` without a failure, or with a\n * failure missing its `code` or `category`, does not decode: a client settling\n * a write must be able to translate why it failed.\n */\nexport const FlowEventData = Schema.Struct({\n flowId: Schema.String,\n definition: Schema.String,\n slipVersion: Schema.Number,\n step: Schema.optionalKey(Schema.String),\n outcome: Schema.optionalKey(Schema.Unknown),\n failure: Schema.optionalKey(FlowFailure),\n});\nexport type FlowEventData = typeof FlowEventData.Type;\n\nconst FlowFailedData = Schema.Struct({\n ...FlowEventData.fields,\n failure: FlowFailure,\n});\n\nfor (const name of FLOW_EVENTS)\n registerEvent(name, name === 'flow.failed' ? FlowFailedData : FlowEventData, {\n versioned: true,\n });\n\n/**\n * The `202` body a flow start answers: the flow's id, and where to watch it —\n * its status read and its stream.\n */\nexport const FlowAccepted = Schema.Struct({\n flowId: Schema.String,\n links: Schema.Array(\n Schema.Struct({\n rel: Schema.Literals(['status', 'stream']),\n href: Schema.String,\n }),\n ),\n});\nexport type FlowAccepted = typeof FlowAccepted.Type;\n\nregisterMessage('flowAccepted', FlowAccepted);\n\n/**\n * The body a flow's `status` link answers: where the flow stands, and why it\n * failed when it did. A browser reads it to settle a write whose outcome it\n * did not hear pushed; a `404` from that link means the flow is not projected\n * yet, never that it failed.\n */\nexport const FlowStatusBody = Schema.Struct({\n flowId: Schema.String,\n state: Schema.Literals([\n 'running',\n 'waiting',\n 'suspended',\n 'completed',\n 'compensated',\n 'failed',\n 'interrupted',\n // A wait's timeout stranded it for a person; like `suspended`, a browser\n // holding it pending keeps it pending — the write neither landed nor failed.\n 'stranded',\n ]),\n step: Schema.optionalKey(Schema.String),\n failure: Schema.optionalKey(FlowFailure),\n});\nexport type FlowStatusBody = typeof FlowStatusBody.Type;\n\nregisterMessage('flowStatus', FlowStatusBody);\n\nexport interface FlowEventInput {\n readonly name: FlowEventName;\n readonly source: string;\n readonly at: string;\n /** The step this event is about, and its ordinal — the event's version. */\n readonly step: string;\n readonly ordinal: number;\n readonly audience: readonly AudienceEntry[];\n readonly data: FlowEventData;\n}\n\n/**\n * Builds a `flow.*` event: id `<flowId>:<step>` so a redelivered announce is\n * the same message, `correlationId` the flow, the step ordinal as version, and\n * an audience that must not be empty.\n */\nexport const flowEvent = (\n input: FlowEventInput,\n): OutboxEvent<FlowEventData> => ({\n name: input.name,\n id: `${input.data.flowId}:${input.step}`,\n source: input.source,\n at: input.at,\n correlationId: input.data.flowId,\n aggregate: { type: 'flow', id: input.data.flowId },\n version: input.ordinal,\n audience: input.audience,\n data: input.data,\n});\n"],"names":["openStruct","registerEvent","registerMessage","Schema","FLOW_EVENTS","FlowFailure","code","NonEmptyString","category","FlowEventData","Struct","flowId","String","definition","slipVersion","Number","step","optionalKey","outcome","Unknown","failure","FlowFailedData","fields","name","versioned","FlowAccepted","links","Array","rel","Literals","href","FlowStatusBody","state","flowEvent","input","id","data","source","at","correlationId","aggregate","type","version","ordinal","audience"],"mappings":";AAAA,SAEEA,UAAU,EACVC,aAAa,EACbC,eAAe,QACV,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAIhC,mDAAmD,GACnD,OAAO,MAAMC,cAAc;IACzB;IACA;IACA;IACA;IACA;CACD,CAAU;AAGX,+EAA+E,GAC/E,MAAMC,cAAcL,WAAW;IAC7BM,MAAMH,OAAOI,cAAc;IAC3BC,UAAUL,OAAOI,cAAc;AACjC;AAEA;;;;CAIC,GACD,OAAO,MAAME,gBAAgBN,OAAOO,MAAM,CAAC;IACzCC,QAAQR,OAAOS,MAAM;IACrBC,YAAYV,OAAOS,MAAM;IACzBE,aAAaX,OAAOY,MAAM;IAC1BC,MAAMb,OAAOc,WAAW,CAACd,OAAOS,MAAM;IACtCM,SAASf,OAAOc,WAAW,CAACd,OAAOgB,OAAO;IAC1CC,SAASjB,OAAOc,WAAW,CAACZ;AAC9B,GAAG;AAGH,MAAMgB,iBAAiBlB,OAAOO,MAAM,CAAC,aAChCD,cAAca,MAAM;IACvBF,SAASf;;AAGX,KAAK,MAAMkB,QAAQnB,YACjBH,cAAcsB,MAAMA,SAAS,gBAAgBF,iBAAiBZ,eAAe;IAC3Ee,WAAW;AACb;AAEF;;;CAGC,GACD,OAAO,MAAMC,eAAetB,OAAOO,MAAM,CAAC;IACxCC,QAAQR,OAAOS,MAAM;IACrBc,OAAOvB,OAAOwB,KAAK,CACjBxB,OAAOO,MAAM,CAAC;QACZkB,KAAKzB,OAAO0B,QAAQ,CAAC;YAAC;YAAU;SAAS;QACzCC,MAAM3B,OAAOS,MAAM;IACrB;AAEJ,GAAG;AAGHV,gBAAgB,gBAAgBuB;AAEhC;;;;;CAKC,GACD,OAAO,MAAMM,iBAAiB5B,OAAOO,MAAM,CAAC;IAC1CC,QAAQR,OAAOS,MAAM;IACrBoB,OAAO7B,OAAO0B,QAAQ,CAAC;QACrB;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yEAAyE;QACzE,6EAA6E;QAC7E;KACD;IACDb,MAAMb,OAAOc,WAAW,CAACd,OAAOS,MAAM;IACtCQ,SAASjB,OAAOc,WAAW,CAACZ;AAC9B,GAAG;AAGHH,gBAAgB,cAAc6B;AAa9B;;;;CAIC,GACD,OAAO,MAAME,YAAY,CACvBC,QACgC,CAAA;QAChCX,MAAMW,MAAMX,IAAI;QAChBY,IAAI,GAAGD,MAAME,IAAI,CAACzB,MAAM,CAAC,CAAC,EAAEuB,MAAMlB,IAAI,EAAE;QACxCqB,QAAQH,MAAMG,MAAM;QACpBC,IAAIJ,MAAMI,EAAE;QACZC,eAAeL,MAAME,IAAI,CAACzB,MAAM;QAChC6B,WAAW;YAAEC,MAAM;YAAQN,IAAID,MAAME,IAAI,CAACzB,MAAM;QAAC;QACjD+B,SAASR,MAAMS,OAAO;QACtBC,UAAUV,MAAMU,QAAQ;QACxBR,MAAMF,MAAME,IAAI;IAClB,CAAA,EAAG"}
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The mechanism behind `@entifix/transactions`' ports: the
|
|
3
|
-
*
|
|
4
|
-
* and the stream hub.
|
|
2
|
+
* The mechanism behind `@entifix/transactions`' ports: the in-memory circuit
|
|
3
|
+
* breaker, bulkhead and retry budget, and the outbox relay and its metrics.
|
|
5
4
|
*
|
|
6
5
|
* A subpath rather than part of `.` although it installs nothing `.` does not,
|
|
7
6
|
* because a consumer that writes against the contracts — a cell, a route, a
|
|
8
7
|
* participant — must be able to ban the engine by name, and a ban matches a
|
|
9
8
|
* specifier (ADR 0006).
|
|
10
9
|
*/
|
|
11
|
-
export * from '../stream/transaction-stream-hub.js';
|
|
12
10
|
export * from './in-memory-bulkhead.js';
|
|
13
11
|
export * from './in-memory-circuit-breaker.js';
|
|
14
12
|
export * from './in-memory-retry-budget.js';
|
|
15
|
-
export * from './local-saga-dispatcher.js';
|
|
16
13
|
export * from './outbox-metrics.js';
|
|
17
14
|
export * from './outbox-relay.js';
|
|
18
|
-
export * from './resolve-template.js';
|
|
19
|
-
export * from './resume-sweep.js';
|
|
20
|
-
export * from './run-saga.js';
|
|
21
|
-
export * from './run-transaction.js';
|
|
22
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
package/dist/engine/index.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The mechanism behind `@entifix/transactions`' ports: the
|
|
3
|
-
*
|
|
4
|
-
* and the stream hub.
|
|
2
|
+
* The mechanism behind `@entifix/transactions`' ports: the in-memory circuit
|
|
3
|
+
* breaker, bulkhead and retry budget, and the outbox relay and its metrics.
|
|
5
4
|
*
|
|
6
5
|
* A subpath rather than part of `.` although it installs nothing `.` does not,
|
|
7
6
|
* because a consumer that writes against the contracts — a cell, a route, a
|
|
8
7
|
* participant — must be able to ban the engine by name, and a ban matches a
|
|
9
8
|
* specifier (ADR 0006).
|
|
10
|
-
*/ export * from '
|
|
11
|
-
export * from './in-memory-bulkhead.js';
|
|
9
|
+
*/ export * from './in-memory-bulkhead.js';
|
|
12
10
|
export * from './in-memory-circuit-breaker.js';
|
|
13
11
|
export * from './in-memory-retry-budget.js';
|
|
14
|
-
export * from './local-saga-dispatcher.js';
|
|
15
12
|
export * from './outbox-metrics.js';
|
|
16
13
|
export * from './outbox-relay.js';
|
|
17
|
-
export * from './resolve-template.js';
|
|
18
|
-
export * from './resume-sweep.js';
|
|
19
|
-
export * from './run-saga.js';
|
|
20
|
-
export * from './run-transaction.js';
|
|
21
14
|
|
|
22
15
|
//# sourceMappingURL=index.js.map
|
package/dist/engine/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/engine/index.ts"],"sourcesContent":["/**\n * The mechanism behind `@entifix/transactions`' ports: the
|
|
1
|
+
{"version":3,"sources":["../../src/engine/index.ts"],"sourcesContent":["/**\n * The mechanism behind `@entifix/transactions`' ports: the in-memory circuit\n * breaker, bulkhead and retry budget, and the outbox relay and its metrics.\n *\n * A subpath rather than part of `.` although it installs nothing `.` does not,\n * because a consumer that writes against the contracts — a cell, a route, a\n * participant — must be able to ban the engine by name, and a ban matches a\n * specifier (ADR 0006).\n */\nexport * from './in-memory-bulkhead.js';\nexport * from './in-memory-circuit-breaker.js';\nexport * from './in-memory-retry-budget.js';\nexport * from './outbox-metrics.js';\nexport * from './outbox-relay.js';\n"],"names":[],"mappings":"AAAA;;;;;;;;CAQC,GACD,cAAc,0BAA0B;AACxC,cAAc,iCAAiC;AAC/C,cAAc,8BAA8B;AAC5C,cAAc,sBAAsB;AACpC,cAAc,oBAAoB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
export * from './contracts/command.js';
|
|
2
|
-
export * from './contracts/event.js';
|
|
3
1
|
export * from './contracts/flow-capability.js';
|
|
4
2
|
export * from './contracts/flow-messages.js';
|
|
5
3
|
export * from './contracts/inbox.js';
|
|
6
|
-
export * from './contracts/messages.js';
|
|
7
4
|
export * from './contracts/outbox.js';
|
|
8
|
-
export * from './contracts/record.js';
|
|
9
|
-
export * from './contracts/saga-definition.js';
|
|
10
5
|
export * from './contracts/unit-of-work.js';
|
|
11
|
-
export * from './mixins/transaction-mixins.js';
|
|
12
6
|
export * from './ports/bulkhead.js';
|
|
13
7
|
export * from './ports/circuit-breaker.js';
|
|
14
8
|
export * from './ports/event-bus.js';
|
|
15
9
|
export * from './ports/event-source.js';
|
|
16
10
|
export * from './ports/flow-engine.js';
|
|
17
|
-
export * from './ports/lock-service.js';
|
|
18
11
|
export * from './ports/participant-client.js';
|
|
19
12
|
export * from './ports/retry-budget.js';
|
|
20
|
-
export * from './ports/saga-dispatcher.js';
|
|
21
|
-
export * from './ports/saga-store.js';
|
|
22
|
-
export * from './ports/sequence-service.js';
|
|
23
|
-
export * from './ports/transaction-handler.js';
|
|
24
|
-
export * from './ports/transaction-sink.js';
|
|
25
|
-
export * from './ports/transaction-stream-hub.js';
|
|
26
13
|
export * from './reactions/on.js';
|
|
27
|
-
export * from './use-case/facade.uc.js';
|
|
28
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
export * from './contracts/command.js';
|
|
2
|
-
export * from './contracts/event.js';
|
|
3
1
|
export * from './contracts/flow-capability.js';
|
|
4
2
|
export * from './contracts/flow-messages.js';
|
|
5
3
|
export * from './contracts/inbox.js';
|
|
6
|
-
export * from './contracts/messages.js';
|
|
7
4
|
export * from './contracts/outbox.js';
|
|
8
|
-
export * from './contracts/record.js';
|
|
9
|
-
export * from './contracts/saga-definition.js';
|
|
10
5
|
export * from './contracts/unit-of-work.js';
|
|
11
|
-
export * from './mixins/transaction-mixins.js';
|
|
12
6
|
export * from './ports/bulkhead.js';
|
|
13
7
|
export * from './ports/circuit-breaker.js';
|
|
14
8
|
export * from './ports/event-bus.js';
|
|
15
9
|
export * from './ports/event-source.js';
|
|
16
10
|
export * from './ports/flow-engine.js';
|
|
17
|
-
export * from './ports/lock-service.js';
|
|
18
11
|
export * from './ports/participant-client.js';
|
|
19
12
|
export * from './ports/retry-budget.js';
|
|
20
|
-
export * from './ports/saga-dispatcher.js';
|
|
21
|
-
export * from './ports/saga-store.js';
|
|
22
|
-
export * from './ports/sequence-service.js';
|
|
23
|
-
export * from './ports/transaction-handler.js';
|
|
24
|
-
export * from './ports/transaction-sink.js';
|
|
25
|
-
export * from './ports/transaction-stream-hub.js';
|
|
26
13
|
export * from './reactions/on.js';
|
|
27
|
-
export * from './use-case/facade.uc.js';
|
|
28
14
|
|
|
29
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './contracts/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './contracts/flow-capability.js';\nexport * from './contracts/flow-messages.js';\nexport * from './contracts/inbox.js';\nexport * from './contracts/outbox.js';\nexport * from './contracts/unit-of-work.js';\nexport * from './ports/bulkhead.js';\nexport * from './ports/circuit-breaker.js';\nexport * from './ports/event-bus.js';\nexport * from './ports/event-source.js';\nexport * from './ports/flow-engine.js';\nexport * from './ports/participant-client.js';\nexport * from './ports/retry-budget.js';\nexport * from './reactions/on.js';\n"],"names":[],"mappings":"AAAA,cAAc,iCAAiC;AAC/C,cAAc,+BAA+B;AAC7C,cAAc,uBAAuB;AACrC,cAAc,wBAAwB;AACtC,cAAc,8BAA8B;AAC5C,cAAc,sBAAsB;AACpC,cAAc,6BAA6B;AAC3C,cAAc,uBAAuB;AACrC,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,gCAAgC;AAC9C,cAAc,0BAA0B;AACxC,cAAc,oBAAoB"}
|
|
@@ -4,9 +4,11 @@ import { Context, type Effect, Schema } from 'effect';
|
|
|
4
4
|
/**
|
|
5
5
|
* Where a flow stands. `suspended` is a flow past its commit point whose step
|
|
6
6
|
* keeps failing — it is waiting for retries or an operator, never compensated;
|
|
7
|
-
* `waiting` is a flow parked at a durable wait for a signal
|
|
7
|
+
* `waiting` is a flow parked at a durable wait for a signal; `stranded` is a
|
|
8
|
+
* flow whose wait ran out with nothing left it could do on its own, ended for
|
|
9
|
+
* an operator rather than retried.
|
|
8
10
|
*/
|
|
9
|
-
export type FlowState = 'running' | 'waiting' | 'suspended' | 'completed' | 'compensated' | 'failed' | 'interrupted';
|
|
11
|
+
export type FlowState = 'running' | 'waiting' | 'suspended' | 'completed' | 'compensated' | 'failed' | 'interrupted' | 'stranded';
|
|
10
12
|
export interface FlowStatus {
|
|
11
13
|
readonly flowId: string;
|
|
12
14
|
readonly state: FlowState;
|
|
@@ -25,8 +27,8 @@ declare const FlowSignalRejected_base: Schema.Class<FlowSignalRejected, Schema.T
|
|
|
25
27
|
}>, import("effect/Cause").YieldableError & import("@entifix/core").FailureFacts<"flowSignalRejected", "conflict">>;
|
|
26
28
|
/**
|
|
27
29
|
* A signal the flow will not take: it is not waiting, it waits for another
|
|
28
|
-
* token,
|
|
29
|
-
* outage.
|
|
30
|
+
* token, its wait is not answered with that outcome, or the wait already
|
|
31
|
+
* timed out. A late signal is an answer, not an outage.
|
|
30
32
|
*/
|
|
31
33
|
export declare class FlowSignalRejected extends FlowSignalRejected_base {
|
|
32
34
|
}
|
|
@@ -46,11 +48,18 @@ export interface FlowEngine {
|
|
|
46
48
|
/** Completes a durable wait the flow is parked at. */
|
|
47
49
|
readonly signal: (flowId: string, token: string, outcome: unknown) => Effect.Effect<void, FlowNotFound | FlowSignalRejected | StoreFailure>;
|
|
48
50
|
/**
|
|
49
|
-
* Completes
|
|
50
|
-
* the
|
|
51
|
-
*
|
|
51
|
+
* Completes whichever durable wait the flow correlated with `correlation` —
|
|
52
|
+
* the shipment a delivery flow follows, say — is parked at, for a sender
|
|
53
|
+
* that knows that and neither the flow's id nor the wait's step name.
|
|
54
|
+
*
|
|
55
|
+
* `signal.outcome` must be one the parked wait declares, or the signal is
|
|
56
|
+
* rejected: a sender's report meant for a later wait is never taken by an
|
|
57
|
+
* earlier one. No flow parked under the correlation answers `FlowNotFound`,
|
|
58
|
+
* which a sender may retry — the flow may simply not have reached its wait.
|
|
52
59
|
*/
|
|
53
|
-
readonly signalCorrelated: (correlation: string,
|
|
60
|
+
readonly signalCorrelated: (correlation: string, signal: {
|
|
61
|
+
readonly outcome: string;
|
|
62
|
+
} & Readonly<Record<string, unknown>>) => Effect.Effect<void, FlowNotFound | FlowSignalRejected | StoreFailure>;
|
|
54
63
|
readonly interrupt: (flowId: string) => Effect.Effect<void, FlowNotFound | StoreFailure>;
|
|
55
64
|
}
|
|
56
65
|
declare const FlowEngineTag_base: Context.ServiceClass<FlowEngineTag, "@entifix/transactions/FlowEngine", FlowEngine>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-engine.d.ts","sourceRoot":"","sources":["../../src/ports/flow-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtD
|
|
1
|
+
{"version":3,"file":"flow-engine.d.ts","sourceRoot":"","sources":["../../src/ports/flow-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,SAAS,GACT,WAAW,GACX,WAAW,GACX,aAAa,GACb,QAAQ,GACR,aAAa,GACb,UAAU,CAAC;AAEf,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;;;;AAED,mCAAmC;AACnC,qBAAa,YAAa,SAAQ,iBAIjC;CAAG;;;;;AAEJ;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,uBAIvC;CAAG;AAEJ;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,CACd,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,KACnB,MAAM,CAAC,MAAM,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,YAAY,CAAC,CAAC;IAC9D,QAAQ,CAAC,MAAM,EAAE,CACf,MAAM,EAAE,MAAM,KACX,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC;IAC5D,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,CACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,kBAAkB,GAAG,YAAY,CAAC,CAAC;IAC3E;;;;;;;;;OASG;IACH,QAAQ,CAAC,gBAAgB,EAAE,CACzB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACrE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,kBAAkB,GAAG,YAAY,CAAC,CAAC;IAC3E,QAAQ,CAAC,SAAS,EAAE,CAClB,MAAM,EAAE,MAAM,KACX,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC;CACvD;;AAED,qBAAa,aAAc,SAAQ,kBAElC;CAAG"}
|
|
@@ -6,8 +6,8 @@ import { Context, Schema } from 'effect';
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* A signal the flow will not take: it is not waiting, it waits for another
|
|
9
|
-
* token,
|
|
10
|
-
* outage.
|
|
9
|
+
* token, its wait is not answered with that outcome, or the wait already
|
|
10
|
+
* timed out. A late signal is an answer, not an outage.
|
|
11
11
|
*/ export class FlowSignalRejected extends Failure.conflict()('FlowSignalRejected', 'flowSignalRejected', {
|
|
12
12
|
flowId: Schema.String,
|
|
13
13
|
token: Schema.String
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ports/flow-engine.ts"],"sourcesContent":["import type { Slip } from '@entifix/business/flow';\nimport { Failure, type StoreFailure } from '@entifix/core';\nimport { Context, type Effect, Schema } from 'effect';\n\n/**\n * Where a flow stands. `suspended` is a flow past its commit point whose step\n * keeps failing — it is waiting for retries or an operator, never compensated;\n * `waiting` is a flow parked at a durable wait for a signal.\n */\nexport type FlowState =\n | 'running'\n | 'waiting'\n | 'suspended'\n | 'completed'\n | 'compensated'\n | 'failed'\n | 'interrupted';\n\nexport interface FlowStatus {\n readonly flowId: string;\n readonly state: FlowState;\n /** The step in progress, or the one the flow stopped at. */\n readonly step?: string;\n}\n\n/** No flow is known by this id. */\nexport class FlowNotFound extends Failure.notFound<FlowNotFound>()(\n 'FlowNotFound',\n 'flowNotFound',\n { flowId: Schema.String },\n) {}\n\n/**\n * A signal the flow will not take: it is not waiting, it waits for another\n * token, or the wait already timed out. A late signal is an answer, not an
|
|
1
|
+
{"version":3,"sources":["../../src/ports/flow-engine.ts"],"sourcesContent":["import type { Slip } from '@entifix/business/flow';\nimport { Failure, type StoreFailure } from '@entifix/core';\nimport { Context, type Effect, Schema } from 'effect';\n\n/**\n * Where a flow stands. `suspended` is a flow past its commit point whose step\n * keeps failing — it is waiting for retries or an operator, never compensated;\n * `waiting` is a flow parked at a durable wait for a signal; `stranded` is a\n * flow whose wait ran out with nothing left it could do on its own, ended for\n * an operator rather than retried.\n */\nexport type FlowState =\n | 'running'\n | 'waiting'\n | 'suspended'\n | 'completed'\n | 'compensated'\n | 'failed'\n | 'interrupted'\n | 'stranded';\n\nexport interface FlowStatus {\n readonly flowId: string;\n readonly state: FlowState;\n /** The step in progress, or the one the flow stopped at. */\n readonly step?: string;\n}\n\n/** No flow is known by this id. */\nexport class FlowNotFound extends Failure.notFound<FlowNotFound>()(\n 'FlowNotFound',\n 'flowNotFound',\n { flowId: Schema.String },\n) {}\n\n/**\n * A signal the flow will not take: it is not waiting, it waits for another\n * token, its wait is not answered with that outcome, or the wait already\n * timed out. A late signal is an answer, not an outage.\n */\nexport class FlowSignalRejected extends Failure.conflict<FlowSignalRejected>()(\n 'FlowSignalRejected',\n 'flowSignalRejected',\n { flowId: Schema.String, token: Schema.String },\n) {}\n\n/**\n * Runs pinned slips durably\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)).\n *\n * There is deliberately no `await`: a caller learns how a flow ended from its\n * `flow.*` events, pushed, never by holding a request open on it.\n */\nexport interface FlowEngine {\n /** Starts a flow, idempotently: the same key answers the same `flowId`. */\n readonly start: (\n slip: Slip,\n idempotencyKey: string,\n ) => Effect.Effect<{ readonly flowId: string }, StoreFailure>;\n readonly status: (\n flowId: string,\n ) => Effect.Effect<FlowStatus, FlowNotFound | StoreFailure>;\n /** Completes a durable wait the flow is parked at. */\n readonly signal: (\n flowId: string,\n token: string,\n outcome: unknown,\n ) => Effect.Effect<void, FlowNotFound | FlowSignalRejected | StoreFailure>;\n /**\n * Completes whichever durable wait the flow correlated with `correlation` —\n * the shipment a delivery flow follows, say — is parked at, for a sender\n * that knows that and neither the flow's id nor the wait's step name.\n *\n * `signal.outcome` must be one the parked wait declares, or the signal is\n * rejected: a sender's report meant for a later wait is never taken by an\n * earlier one. No flow parked under the correlation answers `FlowNotFound`,\n * which a sender may retry — the flow may simply not have reached its wait.\n */\n readonly signalCorrelated: (\n correlation: string,\n signal: { readonly outcome: string } & Readonly<Record<string, unknown>>,\n ) => Effect.Effect<void, FlowNotFound | FlowSignalRejected | StoreFailure>;\n readonly interrupt: (\n flowId: string,\n ) => Effect.Effect<void, FlowNotFound | StoreFailure>;\n}\n\nexport class FlowEngineTag extends Context.Service<FlowEngineTag, FlowEngine>()(\n '@entifix/transactions/FlowEngine',\n) {}\n"],"names":["Failure","Context","Schema","FlowNotFound","notFound","flowId","String","FlowSignalRejected","conflict","token","FlowEngineTag","Service"],"mappings":"AACA,SAASA,OAAO,QAA2B,gBAAgB;AAC3D,SAASC,OAAO,EAAeC,MAAM,QAAQ,SAAS;AA0BtD,iCAAiC,GACjC,OAAO,MAAMC,qBAAqBH,QAAQI,QAAQ,GAChD,gBACA,gBACA;IAAEC,QAAQH,OAAOI,MAAM;AAAC;AACvB;AAEH;;;;CAIC,GACD,OAAO,MAAMC,2BAA2BP,QAAQQ,QAAQ,GACtD,sBACA,sBACA;IAAEH,QAAQH,OAAOI,MAAM;IAAEG,OAAOP,OAAOI,MAAM;AAAC;AAC7C;AA2CH,OAAO,MAAMI,sBAAsBT,QAAQU,OAAO,GAChD;AACC"}
|
|
@@ -11,8 +11,13 @@ export interface ParticipantCall {
|
|
|
11
11
|
* `Idempotency-Key`, stable across every redelivery and resume.
|
|
12
12
|
*/
|
|
13
13
|
readonly idempotencyKey: string;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Everything the call is given, flat: the step's pinned parameters, the keys
|
|
16
|
+
* it consumes as earlier steps bound them, and — for an undoing — what its
|
|
17
|
+
* own action answered. A path's `:name` and the request body read this and
|
|
18
|
+
* nothing else.
|
|
19
|
+
*/
|
|
20
|
+
readonly inputs: Readonly<Record<string, unknown>>;
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* How a flow reaches its participants
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant-client.d.ts","sourceRoot":"","sources":["../../src/ports/participant-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC
|
|
1
|
+
{"version":3,"file":"participant-client.d.ts","sourceRoot":"","sources":["../../src/ports/participant-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,CACb,OAAO,EAAE,eAAe,KACrB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CAC7C;;AAED,qBAAa,oBAAqB,SAAQ,yBAGI;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ports/participant-client.ts"],"sourcesContent":["import type { SlipStep } from '@entifix/business/flow';\nimport type { EntifixFailure } from '@entifix/core';\nimport { Context, type Effect } from 'effect';\n\n/** One call a flow makes to a participant, for a step or for its undoing. */\nexport interface ParticipantCall {\n readonly step: SlipStep;\n /** `action` runs the step's call, `compensation` the call that undoes it. */\n readonly kind: 'action' | 'compensation';\n /**\n * `<flowId>:<step>`, with `:compensation` for an undoing — the participant's\n * `Idempotency-Key`, stable across every redelivery and resume.\n */\n readonly idempotencyKey: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/ports/participant-client.ts"],"sourcesContent":["import type { SlipStep } from '@entifix/business/flow';\nimport type { EntifixFailure } from '@entifix/core';\nimport { Context, type Effect } from 'effect';\n\n/** One call a flow makes to a participant, for a step or for its undoing. */\nexport interface ParticipantCall {\n readonly step: SlipStep;\n /** `action` runs the step's call, `compensation` the call that undoes it. */\n readonly kind: 'action' | 'compensation';\n /**\n * `<flowId>:<step>`, with `:compensation` for an undoing — the participant's\n * `Idempotency-Key`, stable across every redelivery and resume.\n */\n readonly idempotencyKey: string;\n /**\n * Everything the call is given, flat: the step's pinned parameters, the keys\n * it consumes as earlier steps bound them, and — for an undoing — what its\n * own action answered. A path's `:name` and the request body read this and\n * nothing else.\n */\n readonly inputs: Readonly<Record<string, unknown>>;\n}\n\n/**\n * How a flow reaches its participants\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)).\n * The interpreter calls this and nothing else, so the transport — HTTP with a\n * crossing token, or an in-process double — is the composition root's choice.\n * A refusal is the participant's typed failure; anything that kept the call\n * from being answered is a technical one.\n */\nexport interface ParticipantClient {\n readonly call: (\n request: ParticipantCall,\n ) => Effect.Effect<unknown, EntifixFailure>;\n}\n\nexport class ParticipantClientTag extends Context.Service<\n ParticipantClientTag,\n ParticipantClient\n>()('@entifix/transactions/ParticipantClient') {}\n"],"names":["Context","ParticipantClientTag","Service"],"mappings":"AAEA,SAASA,OAAO,QAAqB,SAAS;AAmC9C,OAAO,MAAMC,6BAA6BD,QAAQE,OAAO,GAGrD;AAA4C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/transactions",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "Units of work, inbox and outbox ports, an event bus, and the flow engine and resilience ports a durable flow runs on.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@swc/helpers": "0.5.23",
|
|
59
|
-
"@entifix/
|
|
60
|
-
"@entifix/
|
|
59
|
+
"@entifix/business": "0.16.0",
|
|
60
|
+
"@entifix/core": "0.16.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"effect": "^4.0.7"
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import './messages.js';
|
|
2
|
-
import { type EntifixEnvelope, InvalidEnvelope, type SerializedEntity } from '@entifix/core';
|
|
3
|
-
import { Effect } from 'effect';
|
|
4
|
-
/**
|
|
5
|
-
* A write intent in CQRS terms. A client no longer mutates directly — it issues
|
|
6
|
-
* a command, the service runs the transaction facade over it, and answers with a
|
|
7
|
-
* transaction id. `payload` is a serialized entity (the same wire shape the
|
|
8
|
-
* entity envelopes carry), so a command round-trips through the existing
|
|
9
|
-
* (de)serializer.
|
|
10
|
-
*/
|
|
11
|
-
export interface TransactionCommand<TPayload = SerializedEntity> {
|
|
12
|
-
/**
|
|
13
|
-
* Correlates every event and record for this run, and **the client mints it**.
|
|
14
|
-
*
|
|
15
|
-
* It is also the stored entity's id and the idempotency key: re-sending a
|
|
16
|
-
* command with the same id returns the first one's answer instead of writing
|
|
17
|
-
* twice. That makes it untrusted input which becomes a primary key, so
|
|
18
|
-
* {@link readCommandEnvelope} constrains it to a UUID rather than accepting
|
|
19
|
-
* any string.
|
|
20
|
-
*/
|
|
21
|
-
transactionId: string;
|
|
22
|
-
/** What to do — only `create` in phase 1. */
|
|
23
|
-
type: 'create';
|
|
24
|
-
/** The target entity's `key` (e.g. `product`), the routing/lock subject. */
|
|
25
|
-
entity: string;
|
|
26
|
-
/** The serialized entity to act on. */
|
|
27
|
-
payload: TPayload;
|
|
28
|
-
/**
|
|
29
|
-
* Whose organization this command acts in — **stamped by the route from the
|
|
30
|
-
* verified token, never read from the wire**.
|
|
31
|
-
*
|
|
32
|
-
* {@link readCommandEnvelope} drops whatever a caller sent under this name, so
|
|
33
|
-
* a client cannot name another tenant by writing one into the body. It is the
|
|
34
|
-
* same rule the id already follows (`entity.id = params.id`), and the same
|
|
35
|
-
* rule the organization guard states: the organization comes from the token and
|
|
36
|
-
* nowhere else.
|
|
37
|
-
*
|
|
38
|
-
* Optional because the parser produces a command without it and the route
|
|
39
|
-
* fills it in a moment later. A command that reaches the engine still carrying
|
|
40
|
-
* `undefined` emits events that no tenant-scoped stream connection receives —
|
|
41
|
-
* which is the intended direction to fail.
|
|
42
|
-
*/
|
|
43
|
-
organizationId?: string;
|
|
44
|
-
}
|
|
45
|
-
export type CommandEnvelope<TPayload = SerializedEntity> = EntifixEnvelope<TransactionCommand<TPayload>>;
|
|
46
|
-
/** Frames a command as a transport-free `command` envelope. */
|
|
47
|
-
export declare function makeCommandEnvelope<TPayload = SerializedEntity>(command: TransactionCommand<TPayload>): CommandEnvelope<TPayload>;
|
|
48
|
-
/** Whether a value is a usable transaction id. */
|
|
49
|
-
export declare const isTransactionId: (value: unknown) => value is string;
|
|
50
|
-
/**
|
|
51
|
-
* Parses a `command` envelope, failing on a wrong shape/type.
|
|
52
|
-
*
|
|
53
|
-
* A command carrying no valid transaction id is rejected outright — there is no
|
|
54
|
-
* server-side fallback that mints one. That is deliberate: the id is the
|
|
55
|
-
* idempotency key, and a caller who omits it silently loses retry safety while
|
|
56
|
-
* appearing to succeed.
|
|
57
|
-
*/
|
|
58
|
-
export declare function readCommandEnvelope<TPayload = SerializedEntity>(body: unknown): Effect.Effect<TransactionCommand<TPayload>, InvalidEnvelope>;
|
|
59
|
-
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/contracts/command.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAEL,KAAK,eAAe,EACpB,eAAe,EAEf,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,gBAAgB;IAC7D;;;;;;;;OAQG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,IAAI,EAAE,QAAQ,CAAC;IACf,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,EAAE,QAAQ,CAAC;IAClB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,eAAe,CAAC,QAAQ,GAAG,gBAAgB,IAAI,eAAe,CACxE,kBAAkB,CAAC,QAAQ,CAAC,CAC7B,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,QAAQ,GAAG,gBAAgB,EAC7D,OAAO,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACpC,eAAe,CAAC,QAAQ,CAAC,CAE3B;AAaD,kDAAkD;AAClD,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACX,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,GAAG,gBAAgB,EAC7D,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,CAmB9D"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
2
|
-
// Evaluated for its registrations: this reader decodes against them.
|
|
3
|
-
import './messages.js';
|
|
4
|
-
import { decodeRequestEnvelope, InvalidEnvelope, makeEnvelope } from '@entifix/core';
|
|
5
|
-
import { Effect } from 'effect';
|
|
6
|
-
/** Frames a command as a transport-free `command` envelope. */ export function makeCommandEnvelope(command) {
|
|
7
|
-
return makeEnvelope('command', command.entity, command);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A canonical RFC 9562 UUID — any version, standard variant.
|
|
11
|
-
*
|
|
12
|
-
* The transaction id arrives from the client and becomes a primary key, so the
|
|
13
|
-
* key space it may address has to be fixed rather than "whatever string was
|
|
14
|
-
* sent". Accepting every version keeps v4 (random) and v7 (time-ordered) both
|
|
15
|
-
* usable without the wire format becoming a second decision.
|
|
16
|
-
*/ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
17
|
-
/** Whether a value is a usable transaction id. */ export const isTransactionId = (value)=>typeof value === 'string' && UUID.test(value);
|
|
18
|
-
/**
|
|
19
|
-
* Parses a `command` envelope, failing on a wrong shape/type.
|
|
20
|
-
*
|
|
21
|
-
* A command carrying no valid transaction id is rejected outright — there is no
|
|
22
|
-
* server-side fallback that mints one. That is deliberate: the id is the
|
|
23
|
-
* idempotency key, and a caller who omits it silently loses retry safety while
|
|
24
|
-
* appearing to succeed.
|
|
25
|
-
*/ export function readCommandEnvelope(body) {
|
|
26
|
-
return Effect.gen(function*() {
|
|
27
|
-
const envelope = yield* decodeRequestEnvelope(body, 'command', 'command');
|
|
28
|
-
const command = envelope.data;
|
|
29
|
-
// The registered schema already proved the frame; what it cannot say is
|
|
30
|
-
// that the id is a UUID, which is what makes it safe as a primary key.
|
|
31
|
-
if (!isTransactionId(command.transactionId)) {
|
|
32
|
-
return yield* Effect.fail(new InvalidEnvelope({
|
|
33
|
-
reason: 'command envelope carried no valid command'
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
// `organizationId` is deliberately **not** carried over from the parsed
|
|
37
|
-
// body. Spreading the caller's object here would let a request name another
|
|
38
|
-
// tenant, which is precisely the scoping the stream depends on.
|
|
39
|
-
const { organizationId: _ignored } = command, trusted = _object_without_properties_loose(command, [
|
|
40
|
-
"organizationId"
|
|
41
|
-
]);
|
|
42
|
-
return trusted;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//# sourceMappingURL=command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contracts/command.ts"],"sourcesContent":["// Evaluated for its registrations: this reader decodes against them.\nimport './messages.js';\n\nimport {\n decodeRequestEnvelope,\n type EntifixEnvelope,\n InvalidEnvelope,\n makeEnvelope,\n type SerializedEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\n/**\n * A write intent in CQRS terms. A client no longer mutates directly — it issues\n * a command, the service runs the transaction facade over it, and answers with a\n * transaction id. `payload` is a serialized entity (the same wire shape the\n * entity envelopes carry), so a command round-trips through the existing\n * (de)serializer.\n */\nexport interface TransactionCommand<TPayload = SerializedEntity> {\n /**\n * Correlates every event and record for this run, and **the client mints it**.\n *\n * It is also the stored entity's id and the idempotency key: re-sending a\n * command with the same id returns the first one's answer instead of writing\n * twice. That makes it untrusted input which becomes a primary key, so\n * {@link readCommandEnvelope} constrains it to a UUID rather than accepting\n * any string.\n */\n transactionId: string;\n /** What to do — only `create` in phase 1. */\n type: 'create';\n /** The target entity's `key` (e.g. `product`), the routing/lock subject. */\n entity: string;\n /** The serialized entity to act on. */\n payload: TPayload;\n /**\n * Whose organization this command acts in — **stamped by the route from the\n * verified token, never read from the wire**.\n *\n * {@link readCommandEnvelope} drops whatever a caller sent under this name, so\n * a client cannot name another tenant by writing one into the body. It is the\n * same rule the id already follows (`entity.id = params.id`), and the same\n * rule the organization guard states: the organization comes from the token and\n * nowhere else.\n *\n * Optional because the parser produces a command without it and the route\n * fills it in a moment later. A command that reaches the engine still carrying\n * `undefined` emits events that no tenant-scoped stream connection receives —\n * which is the intended direction to fail.\n */\n organizationId?: string;\n}\n\nexport type CommandEnvelope<TPayload = SerializedEntity> = EntifixEnvelope<\n TransactionCommand<TPayload>\n>;\n\n/** Frames a command as a transport-free `command` envelope. */\nexport function makeCommandEnvelope<TPayload = SerializedEntity>(\n command: TransactionCommand<TPayload>,\n): CommandEnvelope<TPayload> {\n return makeEnvelope('command', command.entity, command);\n}\n\n/**\n * A canonical RFC 9562 UUID — any version, standard variant.\n *\n * The transaction id arrives from the client and becomes a primary key, so the\n * key space it may address has to be fixed rather than \"whatever string was\n * sent\". Accepting every version keeps v4 (random) and v7 (time-ordered) both\n * usable without the wire format becoming a second decision.\n */\nconst UUID =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\n/** Whether a value is a usable transaction id. */\nexport const isTransactionId = (value: unknown): value is string =>\n typeof value === 'string' && UUID.test(value);\n\n/**\n * Parses a `command` envelope, failing on a wrong shape/type.\n *\n * A command carrying no valid transaction id is rejected outright — there is no\n * server-side fallback that mints one. That is deliberate: the id is the\n * idempotency key, and a caller who omits it silently loses retry safety while\n * appearing to succeed.\n */\nexport function readCommandEnvelope<TPayload = SerializedEntity>(\n body: unknown,\n): Effect.Effect<TransactionCommand<TPayload>, InvalidEnvelope> {\n return Effect.gen(function* () {\n const envelope = yield* decodeRequestEnvelope(body, 'command', 'command');\n const command = envelope.data as TransactionCommand<TPayload>;\n // The registered schema already proved the frame; what it cannot say is\n // that the id is a UUID, which is what makes it safe as a primary key.\n if (!isTransactionId(command.transactionId)) {\n return yield* Effect.fail(\n new InvalidEnvelope({\n reason: 'command envelope carried no valid command',\n }),\n );\n }\n // `organizationId` is deliberately **not** carried over from the parsed\n // body. Spreading the caller's object here would let a request name another\n // tenant, which is precisely the scoping the stream depends on.\n const { organizationId: _ignored, ...trusted } = command;\n return trusted as TransactionCommand<TPayload>;\n });\n}\n"],"names":["decodeRequestEnvelope","InvalidEnvelope","makeEnvelope","Effect","makeCommandEnvelope","command","entity","UUID","isTransactionId","value","test","readCommandEnvelope","body","gen","envelope","data","transactionId","fail","reason","organizationId","_ignored","trusted"],"mappings":";AAAA,qEAAqE;AACrE,OAAO,gBAAgB;AAEvB,SACEA,qBAAqB,EAErBC,eAAe,EACfC,YAAY,QAEP,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAgDhC,6DAA6D,GAC7D,OAAO,SAASC,oBACdC,OAAqC;IAErC,OAAOH,aAAa,WAAWG,QAAQC,MAAM,EAAED;AACjD;AAEA;;;;;;;CAOC,GACD,MAAME,OACJ;AAEF,gDAAgD,GAChD,OAAO,MAAMC,kBAAkB,CAACC,QAC9B,OAAOA,UAAU,YAAYF,KAAKG,IAAI,CAACD,OAAO;AAEhD;;;;;;;CAOC,GACD,OAAO,SAASE,oBACdC,IAAa;IAEb,OAAOT,OAAOU,GAAG,CAAC;QAChB,MAAMC,WAAW,OAAOd,sBAAsBY,MAAM,WAAW;QAC/D,MAAMP,UAAUS,SAASC,IAAI;QAC7B,wEAAwE;QACxE,uEAAuE;QACvE,IAAI,CAACP,gBAAgBH,QAAQW,aAAa,GAAG;YAC3C,OAAO,OAAOb,OAAOc,IAAI,CACvB,IAAIhB,gBAAgB;gBAClBiB,QAAQ;YACV;QAEJ;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,gEAAgE;QAChE,MAAM,EAAEC,gBAAgBC,QAAQ,EAAc,GAAGf,SAAZgB,2CAAYhB;;;QACjD,OAAOgB;IACT;AACF"}
|