@entifix/transactions 0.15.0 → 0.17.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.
@@ -1,8 +1,12 @@
1
1
  import { type AudienceEntry } from '@entifix/core';
2
2
  import { Schema } from 'effect';
3
3
  import type { OutboxEvent } from './outbox.js';
4
- /** The four things a flow announces about itself. */
5
- export declare const FLOW_EVENTS: readonly ["flow.started", "flow.completed", "flow.failed", "flow.suspended"];
4
+ /**
5
+ * The six things a flow announces about itself. `flow.waiting` is announced
6
+ * only at a wait **past the commit point**: the caller's write has landed, and
7
+ * what the flow waits for — a courier, a person — is someone else's.
8
+ */
9
+ export declare const FLOW_EVENTS: readonly ["flow.started", "flow.waiting", "flow.completed", "flow.failed", "flow.suspended", "flow.stranded"];
6
10
  export type FlowEventName = (typeof FLOW_EVENTS)[number];
7
11
  /**
8
12
  * What a `flow.*` event carries. A `flow.failed` without a failure, or with a
@@ -41,8 +45,14 @@ export type FlowAccepted = typeof FlowAccepted.Type;
41
45
  */
42
46
  export declare const FlowStatusBody: Schema.Struct<{
43
47
  readonly flowId: Schema.String;
44
- readonly state: Schema.Literals<readonly ["running", "waiting", "suspended", "completed", "compensated", "failed", "interrupted"]>;
48
+ readonly state: Schema.Literals<readonly ["running", "waiting", "suspended", "completed", "compensated", "failed", "interrupted", "stranded"]>;
45
49
  readonly step: Schema.optionalKey<Schema.String>;
50
+ /**
51
+ * `true` once the flow is past its commit point. A `waiting` flow that says
52
+ * so has landed the caller's write; one that does not is parked before it,
53
+ * and a browser holding it pending keeps it pending.
54
+ */
55
+ readonly committed: Schema.optionalKey<Schema.Boolean>;
46
56
  readonly failure: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
47
57
  code: Schema.NonEmptyString;
48
58
  category: Schema.NonEmptyString;
@@ -1 +1 @@
1
- {"version":3,"file":"flow-messages.d.ts","sourceRoot":"","sources":["../../src/contracts/flow-messages.ts"],"names":[],"mappings":"AAAA,OAAO,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AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,WAAW,+GAOd,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;;;;IAezB;;;;OAIG;;;;;;EAGH,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,17 @@
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 four things a flow announces about itself. */ export const FLOW_EVENTS = [
4
+ /**
5
+ * The six things a flow announces about itself. `flow.waiting` is announced
6
+ * only at a wait **past the commit point**: the caller's write has landed, and
7
+ * what the flow waits for — a courier, a person — is someone else's.
8
+ */ export const FLOW_EVENTS = [
5
9
  'flow.started',
10
+ 'flow.waiting',
6
11
  'flow.completed',
7
12
  'flow.failed',
8
- 'flow.suspended'
13
+ 'flow.suspended',
14
+ 'flow.stranded'
9
15
  ];
10
16
  /** A failure inside an asynchronous message: the problem's code and category. */ const FlowFailure = openStruct({
11
17
  code: Schema.NonEmptyString,
@@ -57,9 +63,17 @@ registerMessage('flowAccepted', FlowAccepted);
57
63
  'completed',
58
64
  'compensated',
59
65
  'failed',
60
- 'interrupted'
66
+ 'interrupted',
67
+ // A wait's timeout stranded it for a person; like `suspended`, a browser
68
+ // holding it pending keeps it pending — the write neither landed nor failed.
69
+ 'stranded'
61
70
  ]),
62
71
  step: Schema.optionalKey(Schema.String),
72
+ /**
73
+ * `true` once the flow is past its commit point. A `waiting` flow that says
74
+ * so has landed the caller's write; one that does not is parked before it,
75
+ * and a browser holding it pending keeps it pending.
76
+ */ committed: Schema.optionalKey(Schema.Boolean),
63
77
  failure: Schema.optionalKey(FlowFailure)
64
78
  });
65
79
  registerMessage('flowStatus', FlowStatusBody);
@@ -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 four things a flow announces about itself. */\nexport const FLOW_EVENTS = [\n 'flow.started',\n 'flow.completed',\n 'flow.failed',\n 'flow.suspended',\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 ]),\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;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;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"}
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/**\n * The six things a flow announces about itself. `flow.waiting` is announced\n * only at a wait **past the commit point**: the caller's write has landed, and\n * what the flow waits for — a courier, a person — is someone else's.\n */\nexport const FLOW_EVENTS = [\n 'flow.started',\n 'flow.waiting',\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 /**\n * `true` once the flow is past its commit point. A `waiting` flow that says\n * so has landed the caller's write; one that does not is parked before it,\n * and a browser holding it pending keeps it pending.\n */\n committed: Schema.optionalKey(Schema.Boolean),\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","committed","Boolean","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;;;;CAIC,GACD,OAAO,MAAMC,cAAc;IACzB;IACA;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,g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B,MAAM,CAAC,CAAC,EAAEyB,MAAMpB,IAAI,EAAE;QACxCuB,QAAQH,MAAMG,MAAM;QACpBC,IAAIJ,MAAMI,EAAE;QACZC,eAAeL,MAAME,IAAI,CAAC3B,MAAM;QAChC+B,WAAW;YAAEC,MAAM;YAAQN,IAAID,MAAME,IAAI,CAAC3B,MAAM;QAAC;QACjDiC,SAASR,MAAMS,OAAO;QACtBC,UAAUV,MAAMU,QAAQ;QACxBR,MAAMF,MAAME,IAAI;IAClB,CAAA,EAAG"}
@@ -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, or the wait already timed out. A late signal is an answer, not an
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 a durable wait by what the waiting flow is correlated with —
50
- * the order a delivery flow follows, say — for a sender that knows that and
51
- * not the flow's id.
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, token: string, outcome: unknown) => Effect.Effect<void, FlowNotFound | FlowSignalRejected | StoreFailure>;
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;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,SAAS,GACT,WAAW,GACX,WAAW,GACX,aAAa,GACb,QAAQ,GACR,aAAa,CAAC;AAElB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,C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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, or the wait already timed out. A late signal is an answer, not an
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\n * 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 a durable wait by what the waiting flow is correlated with —\n * the order a delivery flow follows, say — for a sender that knows that and\n * not the flow's id.\n */\n readonly signalCorrelated: (\n correlation: string,\n token: string,\n outcome: 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;AAuBtD,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;AAuCH,OAAO,MAAMI,sBAAsBT,QAAQU,OAAO,GAChD;AACC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/transactions",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
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": {
@@ -56,8 +56,8 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@swc/helpers": "0.5.23",
59
- "@entifix/business": "0.15.0",
60
- "@entifix/core": "0.15.0"
59
+ "@entifix/business": "0.17.0",
60
+ "@entifix/core": "0.17.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "effect": "^4.0.7"