@entifix/business 0.10.2 → 0.12.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.
Files changed (73) hide show
  1. package/dist/compose/compose.d.ts +107 -0
  2. package/dist/compose/compose.d.ts.map +1 -0
  3. package/dist/compose/compose.js +146 -0
  4. package/dist/compose/compose.js.map +1 -0
  5. package/dist/compose/index.d.ts +2 -0
  6. package/dist/compose/index.d.ts.map +1 -0
  7. package/dist/compose/index.js +3 -0
  8. package/dist/compose/index.js.map +1 -0
  9. package/dist/entity-api/entity-api.d.ts +137 -0
  10. package/dist/entity-api/entity-api.d.ts.map +1 -0
  11. package/dist/entity-api/entity-api.js +17 -0
  12. package/dist/entity-api/entity-api.js.map +1 -0
  13. package/dist/entity-api/index.d.ts +2 -0
  14. package/dist/entity-api/index.d.ts.map +1 -0
  15. package/dist/entity-api/index.js +3 -0
  16. package/dist/entity-api/index.js.map +1 -0
  17. package/dist/flow/catalog.d.ts +51 -0
  18. package/dist/flow/catalog.d.ts.map +1 -0
  19. package/dist/flow/catalog.js +63 -0
  20. package/dist/flow/catalog.js.map +1 -0
  21. package/dist/flow/fragment.d.ts +105 -0
  22. package/dist/flow/fragment.d.ts.map +1 -0
  23. package/dist/flow/fragment.js +77 -0
  24. package/dist/flow/fragment.js.map +1 -0
  25. package/dist/flow/index.d.ts +5 -0
  26. package/dist/flow/index.d.ts.map +1 -0
  27. package/dist/flow/index.js +6 -0
  28. package/dist/flow/index.js.map +1 -0
  29. package/dist/flow/slip.d.ts +141 -0
  30. package/dist/flow/slip.d.ts.map +1 -0
  31. package/dist/flow/slip.js +81 -0
  32. package/dist/flow/slip.js.map +1 -0
  33. package/dist/flow/validate.d.ts +70 -0
  34. package/dist/flow/validate.d.ts.map +1 -0
  35. package/dist/flow/validate.js +145 -0
  36. package/dist/flow/validate.js.map +1 -0
  37. package/dist/idempotency/idempotency-store.d.ts +53 -0
  38. package/dist/idempotency/idempotency-store.d.ts.map +1 -0
  39. package/dist/idempotency/idempotency-store.js +5 -0
  40. package/dist/idempotency/idempotency-store.js.map +1 -0
  41. package/dist/idempotency/index.d.ts +2 -0
  42. package/dist/idempotency/index.d.ts.map +1 -0
  43. package/dist/idempotency/index.js +3 -0
  44. package/dist/idempotency/index.js.map +1 -0
  45. package/dist/index.d.ts +4 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +4 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/request/index.d.ts +2 -0
  50. package/dist/request/index.d.ts.map +1 -0
  51. package/dist/request/index.js +3 -0
  52. package/dist/request/index.js.map +1 -0
  53. package/dist/request/request-context.d.ts +86 -0
  54. package/dist/request/request-context.d.ts.map +1 -0
  55. package/dist/request/request-context.js +23 -0
  56. package/dist/request/request-context.js.map +1 -0
  57. package/dist/resolve/index.d.ts +3 -0
  58. package/dist/resolve/index.d.ts.map +1 -0
  59. package/dist/resolve/index.js +4 -0
  60. package/dist/resolve/index.js.map +1 -0
  61. package/dist/resolve/resolve.d.ts +70 -0
  62. package/dist/resolve/resolve.d.ts.map +1 -0
  63. package/dist/resolve/resolve.js +69 -0
  64. package/dist/resolve/resolve.js.map +1 -0
  65. package/dist/resolve/verified-context.d.ts +45 -0
  66. package/dist/resolve/verified-context.d.ts.map +1 -0
  67. package/dist/resolve/verified-context.js +8 -0
  68. package/dist/resolve/verified-context.js.map +1 -0
  69. package/dist/verified/index.d.ts +10 -0
  70. package/dist/verified/index.d.ts.map +1 -0
  71. package/dist/verified/index.js +10 -0
  72. package/dist/verified/index.js.map +1 -0
  73. package/package.json +17 -2
@@ -0,0 +1,63 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { fragmentFingerprint, fragmentRef, jsonSchemaOf, keysDocument } from './fragment.js';
3
+ /**
4
+ * Assembles a catalog. Two fragments claiming one `id@version` throw: a pinned
5
+ * reference must name exactly one contract, or a slip pinned to it means
6
+ * whichever module happened to load last.
7
+ */ export const defineCatalog = (fragments)=>{
8
+ const byRef = new Map();
9
+ for (const fragment of fragments){
10
+ const ref = fragmentRef(fragment);
11
+ const existing = byRef.get(ref);
12
+ if (existing !== undefined && existing !== fragment) throw new Error(`fragment '${ref}' is declared twice, by '${existing.module}' and '${fragment.module}'. ` + 'A pinned reference names one contract: bump one of them.');
13
+ byRef.set(ref, fragment);
14
+ }
15
+ const refs = [
16
+ ...byRef.keys()
17
+ ].sort();
18
+ return {
19
+ get: (ref)=>byRef.get(ref),
20
+ refs,
21
+ fragments: refs.map((ref)=>byRef.get(ref))
22
+ };
23
+ };
24
+ /**
25
+ * The catalog as a JSON document: every fragment with its contract as JSON
26
+ * Schema and its fingerprint, ordered by reference so it is snapshot-stable. It
27
+ * is what a CI check diffs, and what a register check reads without importing
28
+ * the packages that declare the fragments.
29
+ */ export const catalogDocument = (catalog)=>({
30
+ fragments: catalog.fragments.map((fragment)=>{
31
+ var _fragment_readOnly, _fragment_irreversible, _fragment_isolation, _fragment_requires, _fragment_excludedFrom;
32
+ return _extends({
33
+ ref: fragmentRef(fragment),
34
+ id: fragment.id,
35
+ version: fragment.version,
36
+ module: fragment.module,
37
+ kind: fragment.kind,
38
+ cardinality: fragment.cardinality
39
+ }, fragment.participant === undefined ? {} : {
40
+ participant: fragment.participant
41
+ }, fragment.call === undefined ? {} : {
42
+ call: fragment.call
43
+ }, fragment.compensation === undefined ? {} : {
44
+ compensation: fragment.compensation
45
+ }, {
46
+ readOnly: (_fragment_readOnly = fragment.readOnly) != null ? _fragment_readOnly : false,
47
+ irreversible: (_fragment_irreversible = fragment.irreversible) != null ? _fragment_irreversible : false,
48
+ isolation: (_fragment_isolation = fragment.isolation) != null ? _fragment_isolation : 'none',
49
+ requires: (_fragment_requires = fragment.requires) != null ? _fragment_requires : {},
50
+ excludedFrom: (_fragment_excludedFrom = fragment.excludedFrom) != null ? _fragment_excludedFrom : {},
51
+ consumes: keysDocument(fragment.consumes),
52
+ provides: keysDocument(fragment.provides),
53
+ contract: {
54
+ input: jsonSchemaOf(fragment.contract.input),
55
+ output: jsonSchemaOf(fragment.contract.output),
56
+ failure: jsonSchemaOf(fragment.contract.failure)
57
+ },
58
+ fingerprint: fragmentFingerprint(fragment)
59
+ });
60
+ })
61
+ });
62
+
63
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/flow/catalog.ts"],"sourcesContent":["import {\n type FragmentDescriptor,\n fragmentFingerprint,\n fragmentRef,\n jsonSchemaOf,\n keysDocument,\n} from './fragment.js';\n\n/** Every fragment a host composes flows from, by pinned reference. */\nexport interface FragmentCatalog {\n readonly get: (ref: string) => FragmentDescriptor | undefined;\n readonly refs: readonly string[];\n readonly fragments: readonly FragmentDescriptor[];\n}\n\n/**\n * Assembles a catalog. Two fragments claiming one `id@version` throw: a pinned\n * reference must name exactly one contract, or a slip pinned to it means\n * whichever module happened to load last.\n */\nexport const defineCatalog = (\n fragments: readonly FragmentDescriptor[],\n): FragmentCatalog => {\n const byRef = new Map<string, FragmentDescriptor>();\n for (const fragment of fragments) {\n const ref = fragmentRef(fragment);\n const existing = byRef.get(ref);\n if (existing !== undefined && existing !== fragment)\n throw new Error(\n `fragment '${ref}' is declared twice, by '${existing.module}' and '${fragment.module}'. ` +\n 'A pinned reference names one contract: bump one of them.',\n );\n byRef.set(ref, fragment);\n }\n const refs = [...byRef.keys()].sort();\n return {\n get: ref => byRef.get(ref),\n refs,\n fragments: refs.map(ref => byRef.get(ref) as FragmentDescriptor),\n };\n};\n\n/**\n * The catalog as a JSON document: every fragment with its contract as JSON\n * Schema and its fingerprint, ordered by reference so it is snapshot-stable. It\n * is what a CI check diffs, and what a register check reads without importing\n * the packages that declare the fragments.\n */\nexport const catalogDocument = (catalog: FragmentCatalog) => ({\n fragments: catalog.fragments.map(fragment => ({\n ref: fragmentRef(fragment),\n id: fragment.id,\n version: fragment.version,\n module: fragment.module,\n kind: fragment.kind,\n cardinality: fragment.cardinality,\n ...(fragment.participant === undefined\n ? {}\n : { participant: fragment.participant }),\n ...(fragment.call === undefined ? {} : { call: fragment.call }),\n ...(fragment.compensation === undefined\n ? {}\n : { compensation: fragment.compensation }),\n readOnly: fragment.readOnly ?? false,\n irreversible: fragment.irreversible ?? false,\n isolation: fragment.isolation ?? 'none',\n requires: fragment.requires ?? {},\n excludedFrom: fragment.excludedFrom ?? {},\n consumes: keysDocument(fragment.consumes),\n provides: keysDocument(fragment.provides),\n contract: {\n input: jsonSchemaOf(fragment.contract.input),\n output: jsonSchemaOf(fragment.contract.output),\n failure: jsonSchemaOf(fragment.contract.failure),\n },\n fingerprint: fragmentFingerprint(fragment),\n })),\n});\n\nexport type CatalogDocument = ReturnType<typeof catalogDocument>;\n"],"names":["fragmentFingerprint","fragmentRef","jsonSchemaOf","keysDocument","defineCatalog","fragments","byRef","Map","fragment","ref","existing","get","undefined","Error","module","set","refs","keys","sort","map","catalogDocument","catalog","id","version","kind","cardinality","participant","call","compensation","readOnly","irreversible","isolation","requires","excludedFrom","consumes","provides","contract","input","output","failure","fingerprint"],"mappings":";AAAA,SAEEA,mBAAmB,EACnBC,WAAW,EACXC,YAAY,EACZC,YAAY,QACP,gBAAgB;AASvB;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,CAC3BC;IAEA,MAAMC,QAAQ,IAAIC;IAClB,KAAK,MAAMC,YAAYH,UAAW;QAChC,MAAMI,MAAMR,YAAYO;QACxB,MAAME,WAAWJ,MAAMK,GAAG,CAACF;QAC3B,IAAIC,aAAaE,aAAaF,aAAaF,UACzC,MAAM,IAAIK,MACR,CAAC,UAAU,EAAEJ,IAAI,yBAAyB,EAAEC,SAASI,MAAM,CAAC,OAAO,EAAEN,SAASM,MAAM,CAAC,GAAG,CAAC,GACvF;QAENR,MAAMS,GAAG,CAACN,KAAKD;IACjB;IACA,MAAMQ,OAAO;WAAIV,MAAMW,IAAI;KAAG,CAACC,IAAI;IACnC,OAAO;QACLP,KAAKF,CAAAA,MAAOH,MAAMK,GAAG,CAACF;QACtBO;QACAX,W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OAAO;gBACjD;gBACAC,aAAaxC,oBAAoBQ;;;IAErC,CAAA,EAAG"}
@@ -0,0 +1,105 @@
1
+ import { Schema } from 'effect';
2
+ /**
3
+ * How a step behaves when a later one fails
4
+ * ([ADR 0015](../../../../../docs/adr/0015-composed-flows-and-use-case-resolution.md)).
5
+ *
6
+ * - `compensatable` — can be undone, so it sits before the commit point;
7
+ * - `pivot` — the point of no return, at most one per slip;
8
+ * - `retriable` — after the commit point, retried until it succeeds;
9
+ * - `wait` — a durable wait for a signal, after the commit point.
10
+ */
11
+ export type FragmentKind = 'compensatable' | 'pivot' | 'retriable' | 'wait';
12
+ /** How many calls one step makes: one, one per vendor segment, or one per line. */
13
+ export type FragmentCardinality = 'one' | 'perVendor' | 'perLine';
14
+ /**
15
+ * The countermeasure a step relies on for the isolation a saga lacks — what
16
+ * keeps a concurrent flow from seeing, or undoing, its intermediate state.
17
+ */
18
+ export type FragmentIsolation = 'commutative' | 'semanticLock' | 'reRead' | 'pessimisticView' | 'versionFile' | 'none';
19
+ /** One HTTP call a step makes on its participant: the public path, never a template. */
20
+ export interface FragmentCall {
21
+ readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
22
+ readonly path: `/${string}`;
23
+ }
24
+ /** The facts of a verified context a step may require. */
25
+ export interface FragmentRequirements {
26
+ readonly entitlements?: readonly string[];
27
+ readonly roles?: readonly string[];
28
+ readonly partyRoles?: readonly string[];
29
+ readonly channels?: readonly string[];
30
+ }
31
+ /** A step's contract, as Schemas: what it is given, answers, and refuses with. */
32
+ export interface FragmentContract<I, O, F> {
33
+ readonly input: Schema.Codec<I, unknown>;
34
+ readonly output: Schema.Codec<O, unknown>;
35
+ readonly failure: Schema.Codec<F, unknown>;
36
+ }
37
+ /** Keys a step reads from earlier steps, or makes available to later ones. */
38
+ export type FragmentKeys = Readonly<Record<string, Schema.Codec<unknown, unknown>>>;
39
+ /**
40
+ * One step a module contributes to a flow, declared beside the use case it
41
+ * calls. Versioned (`id@version`) and typed, so a contract change without a
42
+ * version bump is visible to a catalog snapshot before it reaches a running
43
+ * flow.
44
+ */
45
+ export interface FragmentDescriptor<I = unknown, O = unknown, F = unknown> {
46
+ readonly id: string;
47
+ readonly version: number;
48
+ /** The module that owns the step — its domain. */
49
+ readonly module: string;
50
+ readonly kind: FragmentKind;
51
+ /** The service the step calls. Absent only on a marker such as `flow.commit@1`. */
52
+ readonly participant?: string;
53
+ readonly call?: FragmentCall;
54
+ /** Required on a compensatable step unless it is `readOnly`; forbidden otherwise. */
55
+ readonly compensation?: FragmentCall;
56
+ /** A compensatable step that changes nothing, and so has nothing to undo. */
57
+ readonly readOnly?: boolean;
58
+ readonly contract: FragmentContract<I, O, F>;
59
+ readonly requires?: FragmentRequirements;
60
+ readonly consumes?: FragmentKeys;
61
+ readonly provides?: FragmentKeys;
62
+ /** A step whose effect no compensation can reverse — money moved, goods shipped. */
63
+ readonly irreversible?: boolean;
64
+ readonly isolation?: FragmentIsolation;
65
+ readonly cardinality: FragmentCardinality;
66
+ /**
67
+ * Segments this step may not run in, by tag. A card capture excludes the
68
+ * cash-on-delivery segment; the framework names neither.
69
+ */
70
+ readonly excludedFrom?: Readonly<Record<string, readonly string[]>>;
71
+ }
72
+ /** The pinned reference a slip carries: `stock.reserve@1`. */
73
+ export declare const fragmentRef: (fragment: {
74
+ readonly id: string;
75
+ readonly version: number;
76
+ }) => string;
77
+ /**
78
+ * Declares a fragment, checking its shape at module load: a malformed
79
+ * descriptor is a programming error and fails the boot, not the first flow
80
+ * that reaches it. What depends on *other* fragments — order, inputs, the
81
+ * commit point — is the validator's, over a whole slip.
82
+ */
83
+ export declare const defineFragment: <I, O, F>(fragment: FragmentDescriptor<I, O, F>) => FragmentDescriptor<I, O, F>;
84
+ /**
85
+ * The commit point of a flow that has no real pivot: a pivot with no
86
+ * participant and no call. A cash-on-delivery checkout takes no money, and
87
+ * still needs a line past which its stock conversions are retried rather than
88
+ * compensated.
89
+ */
90
+ export declare const flowCommit: FragmentDescriptor<unknown, unknown, never>;
91
+ /** The JSON Schema of a codec, as a plain object. */
92
+ export declare const jsonSchemaOf: (schema: Schema.Codec<unknown, unknown>) => unknown;
93
+ /** Consumed or provided keys as JSON Schema, ordered by key. */
94
+ export declare const keysDocument: (keys: FragmentKeys | undefined) => {
95
+ [k: string]: unknown;
96
+ };
97
+ /**
98
+ * A fingerprint of what a fragment promises: its contract and the keys it
99
+ * consumes and provides. It changes when any of those change and on nothing
100
+ * else, so renaming a module or rewording a description never looks like a
101
+ * contract change — and a contract change without a version bump fails the
102
+ * catalog snapshot.
103
+ */
104
+ export declare const fragmentFingerprint: (fragment: FragmentDescriptor) => string;
105
+ //# sourceMappingURL=fragment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment.d.ts","sourceRoot":"","sources":["../../src/flow/fragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5E,mFAAmF;AACnF,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,cAAc,GACd,QAAQ,GACR,iBAAiB,GACjB,aAAa,GACb,MAAM,CAAC;AAEX,wFAAwF;AACxF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;CAC7B;AAED,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE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2
+ /** The pinned reference a slip carries: `stock.reserve@1`. */ export const fragmentRef = (fragment)=>`${fragment.id}@${String(fragment.version)}`;
3
+ /** `domain.verb`, lower kebab, at least two segments. */ const FRAGMENT_ID = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/;
4
+ const shapeProblems = (fragment)=>{
5
+ const problems = [];
6
+ if (!FRAGMENT_ID.test(fragment.id)) problems.push(`its id must be 'domain.verb' in lower kebab case`);
7
+ if (!Number.isInteger(fragment.version) || fragment.version < 1) problems.push('its version must be a positive integer');
8
+ const marker = fragment.participant === undefined && fragment.call === undefined;
9
+ if (!marker && (fragment.participant === undefined || fragment.call === undefined)) problems.push('it names a participant and a call together, or neither');
10
+ if (marker && fragment.kind !== 'pivot') problems.push('only a pivot may be a marker with no participant and no call');
11
+ if (fragment.kind === 'compensatable') {
12
+ if (fragment.compensation === undefined && fragment.readOnly !== true) problems.push('a compensatable step declares its compensation, or is readOnly');
13
+ } else if (fragment.compensation !== undefined) {
14
+ problems.push(`a ${fragment.kind} step cannot declare a compensation`);
15
+ }
16
+ if (fragment.irreversible === true && fragment.kind === 'compensatable') problems.push('a compensatable step cannot be irreversible');
17
+ return problems;
18
+ };
19
+ /**
20
+ * Declares a fragment, checking its shape at module load: a malformed
21
+ * descriptor is a programming error and fails the boot, not the first flow
22
+ * that reaches it. What depends on *other* fragments — order, inputs, the
23
+ * commit point — is the validator's, over a whole slip.
24
+ */ export const defineFragment = (fragment)=>{
25
+ const problems = shapeProblems(fragment);
26
+ if (problems.length > 0) throw new Error(`fragment '${fragment.id}@${String(fragment.version)}' is malformed: ${problems.join('; ')}`);
27
+ return fragment;
28
+ };
29
+ /**
30
+ * The commit point of a flow that has no real pivot: a pivot with no
31
+ * participant and no call. A cash-on-delivery checkout takes no money, and
32
+ * still needs a line past which its stock conversions are retried rather than
33
+ * compensated.
34
+ */ export const flowCommit = defineFragment({
35
+ id: 'flow.commit',
36
+ version: 1,
37
+ module: 'flow',
38
+ kind: 'pivot',
39
+ cardinality: 'one',
40
+ contract: {
41
+ input: Schema.Unknown,
42
+ output: Schema.Unknown,
43
+ failure: Schema.Never
44
+ }
45
+ });
46
+ /** A stable 53-bit hash of a string, as hex — enough to see that a contract moved. */ const hash = (text)=>{
47
+ let h1 = 0xdeadbeef;
48
+ let h2 = 0x41c6ce57;
49
+ for(let index = 0; index < text.length; index += 1){
50
+ const code = text.charCodeAt(index);
51
+ h1 = Math.imul(h1 ^ code, 2654435761);
52
+ h2 = Math.imul(h2 ^ code, 1597334677);
53
+ }
54
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
55
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
56
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, '0');
57
+ };
58
+ /** The JSON Schema of a codec, as a plain object. */ export const jsonSchemaOf = (schema)=>Schema.toJsonSchemaDocument(schema);
59
+ /** Consumed or provided keys as JSON Schema, ordered by key. */ export const keysDocument = (keys)=>Object.fromEntries(Object.entries(keys != null ? keys : {}).sort(([a], [b])=>a.localeCompare(b)).map(([key, schema])=>[
60
+ key,
61
+ jsonSchemaOf(schema)
62
+ ]));
63
+ /**
64
+ * A fingerprint of what a fragment promises: its contract and the keys it
65
+ * consumes and provides. It changes when any of those change and on nothing
66
+ * else, so renaming a module or rewording a description never looks like a
67
+ * contract change — and a contract change without a version bump fails the
68
+ * catalog snapshot.
69
+ */ export const fragmentFingerprint = (fragment)=>hash(JSON.stringify({
70
+ input: jsonSchemaOf(fragment.contract.input),
71
+ output: jsonSchemaOf(fragment.contract.output),
72
+ failure: jsonSchemaOf(fragment.contract.failure),
73
+ consumes: keysDocument(fragment.consumes),
74
+ provides: keysDocument(fragment.provides)
75
+ }));
76
+
77
+ //# sourceMappingURL=fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/flow/fragment.ts"],"sourcesContent":["import { Schema } from 'effect';\n\n/**\n * How a step behaves when a later one fails\n * ([ADR 0015](../../../../../docs/adr/0015-composed-flows-and-use-case-resolution.md)).\n *\n * - `compensatable` — can be undone, so it sits before the commit point;\n * - `pivot` — the point of no return, at most one per slip;\n * - `retriable` — after the commit point, retried until it succeeds;\n * - `wait` — a durable wait for a signal, after the commit point.\n */\nexport type FragmentKind = 'compensatable' | 'pivot' | 'retriable' | 'wait';\n\n/** How many calls one step makes: one, one per vendor segment, or one per line. */\nexport type FragmentCardinality = 'one' | 'perVendor' | 'perLine';\n\n/**\n * The countermeasure a step relies on for the isolation a saga lacks — what\n * keeps a concurrent flow from seeing, or undoing, its intermediate state.\n */\nexport type FragmentIsolation =\n | 'commutative'\n | 'semanticLock'\n | 'reRead'\n | 'pessimisticView'\n | 'versionFile'\n | 'none';\n\n/** One HTTP call a step makes on its participant: the public path, never a template. */\nexport interface FragmentCall {\n readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n readonly path: `/${string}`;\n}\n\n/** The facts of a verified context a step may require. */\nexport interface FragmentRequirements {\n readonly entitlements?: readonly string[];\n readonly roles?: readonly string[];\n readonly partyRoles?: readonly string[];\n readonly channels?: readonly string[];\n}\n\n/** A step's contract, as Schemas: what it is given, answers, and refuses with. */\nexport interface FragmentContract<I, O, F> {\n readonly input: Schema.Codec<I, unknown>;\n readonly output: Schema.Codec<O, unknown>;\n readonly failure: Schema.Codec<F, unknown>;\n}\n\n/** Keys a step reads from earlier steps, or makes available to later ones. */\nexport type FragmentKeys = Readonly<\n Record<string, Schema.Codec<unknown, unknown>>\n>;\n\n/**\n * One step a module contributes to a flow, declared beside the use case it\n * calls. Versioned (`id@version`) and typed, so a contract change without a\n * version bump is visible to a catalog snapshot before it reaches a running\n * flow.\n */\nexport interface FragmentDescriptor<I = unknown, O = unknown, F = unknown> {\n readonly id: string;\n readonly version: number;\n /** The module that owns the step — its domain. */\n readonly module: string;\n readonly kind: FragmentKind;\n /** The service the step calls. Absent only on a marker such as `flow.commit@1`. */\n readonly participant?: string;\n readonly call?: FragmentCall;\n /** Required on a compensatable step unless it is `readOnly`; forbidden otherwise. */\n readonly compensation?: FragmentCall;\n /** A compensatable step that changes nothing, and so has nothing to undo. */\n readonly readOnly?: boolean;\n readonly contract: FragmentContract<I, O, F>;\n readonly requires?: FragmentRequirements;\n readonly consumes?: FragmentKeys;\n readonly provides?: FragmentKeys;\n /** A step whose effect no compensation can reverse — money moved, goods shipped. */\n readonly irreversible?: boolean;\n readonly isolation?: FragmentIsolation;\n readonly cardinality: FragmentCardinality;\n /**\n * Segments this step may not run in, by tag. A card capture excludes the\n * cash-on-delivery segment; the framework names neither.\n */\n readonly excludedFrom?: Readonly<Record<string, readonly string[]>>;\n}\n\n/** The pinned reference a slip carries: `stock.reserve@1`. */\nexport const fragmentRef = (fragment: {\n readonly id: string;\n readonly version: number;\n}): string => `${fragment.id}@${String(fragment.version)}`;\n\n/** `domain.verb`, lower kebab, at least two segments. */\nconst FRAGMENT_ID = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$/;\n\nconst shapeProblems = (fragment: FragmentDescriptor): string[] => {\n const problems: string[] = [];\n if (!FRAGMENT_ID.test(fragment.id))\n problems.push(`its id must be 'domain.verb' in lower kebab case`);\n if (!Number.isInteger(fragment.version) || fragment.version < 1)\n problems.push('its version must be a positive integer');\n const marker =\n fragment.participant === undefined && fragment.call === undefined;\n if (\n !marker &&\n (fragment.participant === undefined || fragment.call === undefined)\n )\n problems.push('it names a participant and a call together, or neither');\n if (marker && fragment.kind !== 'pivot')\n problems.push(\n 'only a pivot may be a marker with no participant and no call',\n );\n if (fragment.kind === 'compensatable') {\n if (fragment.compensation === undefined && fragment.readOnly !== true)\n problems.push(\n 'a compensatable step declares its compensation, or is readOnly',\n );\n } else if (fragment.compensation !== undefined) {\n problems.push(`a ${fragment.kind} step cannot declare a compensation`);\n }\n if (fragment.irreversible === true && fragment.kind === 'compensatable')\n problems.push('a compensatable step cannot be irreversible');\n return problems;\n};\n\n/**\n * Declares a fragment, checking its shape at module load: a malformed\n * descriptor is a programming error and fails the boot, not the first flow\n * that reaches it. What depends on *other* fragments — order, inputs, the\n * commit point — is the validator's, over a whole slip.\n */\nexport const defineFragment = <I, O, F>(\n fragment: FragmentDescriptor<I, O, F>,\n): FragmentDescriptor<I, O, F> => {\n const problems = shapeProblems(fragment as FragmentDescriptor);\n if (problems.length > 0)\n throw new Error(\n `fragment '${fragment.id}@${String(fragment.version)}' is malformed: ${problems.join('; ')}`,\n );\n return fragment;\n};\n\n/**\n * The commit point of a flow that has no real pivot: a pivot with no\n * participant and no call. A cash-on-delivery checkout takes no money, and\n * still needs a line past which its stock conversions are retried rather than\n * compensated.\n */\nexport const flowCommit = defineFragment({\n id: 'flow.commit',\n version: 1,\n module: 'flow',\n kind: 'pivot',\n cardinality: 'one',\n contract: {\n input: Schema.Unknown,\n output: Schema.Unknown,\n failure: Schema.Never,\n },\n});\n\n/** A stable 53-bit hash of a string, as hex — enough to see that a contract moved. */\nconst hash = (text: string): string => {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n for (let index = 0; index < text.length; index += 1) {\n const code = text.charCodeAt(index);\n h1 = Math.imul(h1 ^ code, 2654435761);\n h2 = Math.imul(h2 ^ code, 1597334677);\n }\n h1 =\n Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^\n Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 =\n Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^\n Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n return (4294967296 * (2097151 & h2) + (h1 >>> 0))\n .toString(16)\n .padStart(14, '0');\n};\n\n/** The JSON Schema of a codec, as a plain object. */\nexport const jsonSchemaOf = (schema: Schema.Codec<unknown, unknown>): unknown =>\n Schema.toJsonSchemaDocument(schema);\n\n/** Consumed or provided keys as JSON Schema, ordered by key. */\nexport const keysDocument = (keys: FragmentKeys | undefined) =>\n Object.fromEntries(\n Object.entries(keys ?? {})\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, schema]) => [key, jsonSchemaOf(schema)]),\n );\n\n/**\n * A fingerprint of what a fragment promises: its contract and the keys it\n * consumes and provides. It changes when any of those change and on nothing\n * else, so renaming a module or rewording a description never looks like a\n * contract change — and a contract change without a version bump fails the\n * catalog snapshot.\n */\nexport const fragmentFingerprint = (fragment: FragmentDescriptor): string =>\n hash(\n JSON.stringify({\n input: jsonSchemaOf(\n fragment.contract.input as Schema.Codec<unknown, unknown>,\n ),\n output: jsonSchemaOf(\n fragment.contract.output as Schema.Codec<unknown, unknown>,\n ),\n failure: jsonSchemaOf(\n fragment.contract.failure as Schema.Codec<unknown, unknown>,\n ),\n consumes: keysDocument(fragment.consumes),\n provides: keysDocument(fragment.provides),\n }),\n );\n"],"names":["Schema","fragmentRef","fragment","id","String","version","FRAGMENT_ID","shapeProblems","problems","test","push","Number","isInteger","marker","participant","undefined","call","kind","compensation","readOnly","irreversible","defineFragment","length","Error","join","flowCommit","module","cardinality","contract","input","Unknown","output","failure","Never","hash","text","h1","h2","index","code","charCodeAt","Math","imul","toString","padStart","jsonSchemaOf","schema","toJsonSchemaDocument","keysDocument","keys","Object","fromEntries","entries","sort","a","b","localeCompare","map","key","fragmentFingerprint","JSON","stringify","consumes","provides"],"mappings":"AAAA,SAASA,MAAM,QAAQ,SAAS;AAwFhC,4DAA4D,GAC5D,OAAO,MAAMC,cAAc,CAACC,WAGd,GAAGA,SAASC,EAAE,CAAC,CAAC,EAAEC,OAAOF,SAASG,OAAO,GAAG,CAAC;AAE3D,uDAAuD,GACvD,MAAMC,cAAc;AAEpB,MAAMC,gBAAgB,CAACL;IACrB,MAAMM,WAAqB,EAAE;IAC7B,IAAI,CAACF,YAAYG,IAAI,CAACP,SAASC,EAAE,GAC/BK,SAASE,IAAI,CAAC,CAAC,gDAAgD,CAAC;IAClE,IAAI,CAACC,OAAOC,SAAS,CAACV,SAASG,OAAO,KAAKH,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;IAC1C,IACA"}
@@ -0,0 +1,5 @@
1
+ export * from './catalog.js';
2
+ export * from './fragment.js';
3
+ export * from './slip.js';
4
+ export * from './validate.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './catalog.js';
2
+ export * from './fragment.js';
3
+ export * from './slip.js';
4
+ export * from './validate.js';
5
+
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/flow/index.ts"],"sourcesContent":["export * from './catalog.js';\nexport * from './fragment.js';\nexport * from './slip.js';\nexport * from './validate.js';\n"],"names":[],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,gBAAgB"}
@@ -0,0 +1,141 @@
1
+ import { ProtocolFailure } from '@entifix/core';
2
+ import { Effect, Schema } from 'effect';
3
+ /**
4
+ * The grammar version a slip is written in. An interpreter branches on it, so a
5
+ * flow that started under one grammar finishes under that grammar even after
6
+ * the next one ships.
7
+ */
8
+ export declare const SLIP_VERSION: 1;
9
+ /** Tags that place a step in a segment of the flow: whose lines, which payment. */
10
+ export declare const SlipSegment: Schema.Struct<{
11
+ readonly vendor: Schema.optionalKey<Schema.String>;
12
+ readonly paymentMethod: Schema.optionalKey<Schema.String>;
13
+ }>;
14
+ export type SlipSegment = typeof SlipSegment.Type;
15
+ /** One pinned step: a fragment reference and everything resolved for it. */
16
+ export declare const SlipStep: Schema.Struct<{
17
+ /** `id@version`, pinned when the slip was composed. */
18
+ readonly ref: Schema.String;
19
+ /** Unique within the slip; what an Activity is named after (`segment:step`). */
20
+ readonly step: Schema.String;
21
+ readonly cardinality: Schema.Literals<readonly ["one", "perVendor", "perLine"]>;
22
+ readonly segment: Schema.optionalKey<Schema.Struct<{
23
+ readonly vendor: Schema.optionalKey<Schema.String>;
24
+ readonly paymentMethod: Schema.optionalKey<Schema.String>;
25
+ }>>;
26
+ readonly participant: Schema.optionalKey<Schema.String>;
27
+ readonly call: Schema.optionalKey<Schema.Struct<{
28
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>;
29
+ readonly path: Schema.String;
30
+ }>>;
31
+ readonly compensation: Schema.optionalKey<Schema.Struct<{
32
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>;
33
+ readonly path: Schema.String;
34
+ }>>;
35
+ /** Configuration pinned at composition — a hold's expiry, a limit. */
36
+ readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
37
+ }>;
38
+ export type SlipStep = typeof SlipStep.Type;
39
+ export declare const SlipStage: Schema.Struct<{
40
+ readonly name: Schema.String;
41
+ readonly steps: Schema.$Array<Schema.Struct<{
42
+ /** `id@version`, pinned when the slip was composed. */
43
+ readonly ref: Schema.String;
44
+ /** Unique within the slip; what an Activity is named after (`segment:step`). */
45
+ readonly step: Schema.String;
46
+ readonly cardinality: Schema.Literals<readonly ["one", "perVendor", "perLine"]>;
47
+ readonly segment: Schema.optionalKey<Schema.Struct<{
48
+ readonly vendor: Schema.optionalKey<Schema.String>;
49
+ readonly paymentMethod: Schema.optionalKey<Schema.String>;
50
+ }>>;
51
+ readonly participant: Schema.optionalKey<Schema.String>;
52
+ readonly call: Schema.optionalKey<Schema.Struct<{
53
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>;
54
+ readonly path: Schema.String;
55
+ }>>;
56
+ readonly compensation: Schema.optionalKey<Schema.Struct<{
57
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>;
58
+ readonly path: Schema.String;
59
+ }>>;
60
+ /** Configuration pinned at composition — a hold's expiry, a limit. */
61
+ readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
62
+ }>>;
63
+ }>;
64
+ export type SlipStage = typeof SlipStage.Type;
65
+ /** Who may receive what the flow announces — the envelope's audience. */
66
+ export declare const SlipAudienceEntry: Schema.Struct<{
67
+ readonly kind: Schema.Literals<readonly ["organization", "party", "flow"]>;
68
+ readonly id: Schema.String;
69
+ readonly digest: Schema.optionalKey<Schema.String>;
70
+ }>;
71
+ /** Which variant each use case resolved to, and by which rule. */
72
+ export declare const SlipResolution: Schema.Struct<{
73
+ readonly useCase: Schema.String;
74
+ readonly variant: Schema.String;
75
+ readonly rule: Schema.Number;
76
+ }>;
77
+ export type SlipResolution = typeof SlipResolution.Type;
78
+ /**
79
+ * A routing slip: ordered stages of pinned steps, composed once at start and
80
+ * stored as the flow's payload. Changing a recipe or a fragment never changes a
81
+ * flow that has already started.
82
+ */
83
+ export declare const Slip: Schema.Struct<{
84
+ readonly slipVersion: Schema.Literal<1>;
85
+ readonly flowId: Schema.String;
86
+ readonly recipe: Schema.String;
87
+ /** The recipe demands a commit point even with no retriable step (a checkout). */
88
+ readonly requiresCommitPoint: Schema.optionalKey<Schema.Boolean>;
89
+ readonly stages: Schema.$Array<Schema.Struct<{
90
+ readonly name: Schema.String;
91
+ readonly steps: Schema.$Array<Schema.Struct<{
92
+ /** `id@version`, pinned when the slip was composed. */
93
+ readonly ref: Schema.String;
94
+ /** Unique within the slip; what an Activity is named after (`segment:step`). */
95
+ readonly step: Schema.String;
96
+ readonly cardinality: Schema.Literals<readonly ["one", "perVendor", "perLine"]>;
97
+ readonly segment: Schema.optionalKey<Schema.Struct<{
98
+ readonly vendor: Schema.optionalKey<Schema.String>;
99
+ readonly paymentMethod: Schema.optionalKey<Schema.String>;
100
+ }>>;
101
+ readonly participant: Schema.optionalKey<Schema.String>;
102
+ readonly call: Schema.optionalKey<Schema.Struct<{
103
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>;
104
+ readonly path: Schema.String;
105
+ }>>;
106
+ readonly compensation: Schema.optionalKey<Schema.Struct<{
107
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE"]>;
108
+ readonly path: Schema.String;
109
+ }>>;
110
+ /** Configuration pinned at composition — a hold's expiry, a limit. */
111
+ readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
112
+ }>>;
113
+ }>>;
114
+ readonly resolution: Schema.$Array<Schema.Struct<{
115
+ readonly useCase: Schema.String;
116
+ readonly variant: Schema.String;
117
+ readonly rule: Schema.Number;
118
+ }>>;
119
+ readonly composedAt: Schema.String;
120
+ /**
121
+ * Who the flow's `flow.*` events reach beside the flow itself — the
122
+ * organizations and parties it acts for, pinned when it was composed.
123
+ */
124
+ readonly audience: Schema.optionalKey<Schema.$Array<Schema.Struct<{
125
+ readonly kind: Schema.Literals<readonly ["organization", "party", "flow"]>;
126
+ readonly id: Schema.String;
127
+ readonly digest: Schema.optionalKey<Schema.String>;
128
+ }>>>;
129
+ }>;
130
+ export type Slip = typeof Slip.Type;
131
+ /**
132
+ * Decodes a stored or received slip. An unknown `slipVersion`, like any shape
133
+ * the grammar does not describe, is a protocol failure: an interpreter must
134
+ * never guess at a grammar it was not built for.
135
+ */
136
+ export declare const decodeSlip: (input: unknown) => Effect.Effect<Slip, ProtocolFailure>;
137
+ /** Encodes a slip as the workflow payload it travels as. */
138
+ export declare const encodeSlip: (slip: Slip) => unknown;
139
+ /** Every step of a slip, in the order it runs. */
140
+ export declare const slipSteps: (slip: Slip) => readonly SlipStep[];
141
+ //# sourceMappingURL=slip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slip.d.ts","sourceRoot":"","sources":["../../src/flow/slip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAA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1,81 @@
1
+ import { ProtocolFailure } from '@entifix/core';
2
+ import { Effect, Schema } from 'effect';
3
+ /**
4
+ * The grammar version a slip is written in. An interpreter branches on it, so a
5
+ * flow that started under one grammar finishes under that grammar even after
6
+ * the next one ships.
7
+ */ export const SLIP_VERSION = 1;
8
+ const Call = Schema.Struct({
9
+ method: Schema.Literals([
10
+ 'GET',
11
+ 'POST',
12
+ 'PUT',
13
+ 'PATCH',
14
+ 'DELETE'
15
+ ]),
16
+ path: Schema.String
17
+ });
18
+ /** Tags that place a step in a segment of the flow: whose lines, which payment. */ export const SlipSegment = Schema.Struct({
19
+ vendor: Schema.optionalKey(Schema.String),
20
+ paymentMethod: Schema.optionalKey(Schema.String)
21
+ });
22
+ /** One pinned step: a fragment reference and everything resolved for it. */ export const SlipStep = Schema.Struct({
23
+ /** `id@version`, pinned when the slip was composed. */ ref: Schema.String,
24
+ /** Unique within the slip; what an Activity is named after (`segment:step`). */ step: Schema.String,
25
+ cardinality: Schema.Literals([
26
+ 'one',
27
+ 'perVendor',
28
+ 'perLine'
29
+ ]),
30
+ segment: Schema.optionalKey(SlipSegment),
31
+ participant: Schema.optionalKey(Schema.String),
32
+ call: Schema.optionalKey(Call),
33
+ compensation: Schema.optionalKey(Call),
34
+ /** Configuration pinned at composition — a hold's expiry, a limit. */ parameters: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown))
35
+ });
36
+ export const SlipStage = Schema.Struct({
37
+ name: Schema.String,
38
+ steps: Schema.Array(SlipStep)
39
+ });
40
+ /** Who may receive what the flow announces — the envelope's audience. */ export const SlipAudienceEntry = Schema.Struct({
41
+ kind: Schema.Literals([
42
+ 'organization',
43
+ 'party',
44
+ 'flow'
45
+ ]),
46
+ id: Schema.String,
47
+ digest: Schema.optionalKey(Schema.String)
48
+ });
49
+ /** Which variant each use case resolved to, and by which rule. */ export const SlipResolution = Schema.Struct({
50
+ useCase: Schema.String,
51
+ variant: Schema.String,
52
+ rule: Schema.Number
53
+ });
54
+ /**
55
+ * A routing slip: ordered stages of pinned steps, composed once at start and
56
+ * stored as the flow's payload. Changing a recipe or a fragment never changes a
57
+ * flow that has already started.
58
+ */ export const Slip = Schema.Struct({
59
+ slipVersion: Schema.Literal(SLIP_VERSION),
60
+ flowId: Schema.String,
61
+ recipe: Schema.String,
62
+ /** The recipe demands a commit point even with no retriable step (a checkout). */ requiresCommitPoint: Schema.optionalKey(Schema.Boolean),
63
+ stages: Schema.Array(SlipStage),
64
+ resolution: Schema.Array(SlipResolution),
65
+ composedAt: Schema.String,
66
+ /**
67
+ * Who the flow's `flow.*` events reach beside the flow itself — the
68
+ * organizations and parties it acts for, pinned when it was composed.
69
+ */ audience: Schema.optionalKey(Schema.Array(SlipAudienceEntry))
70
+ });
71
+ /**
72
+ * Decodes a stored or received slip. An unknown `slipVersion`, like any shape
73
+ * the grammar does not describe, is a protocol failure: an interpreter must
74
+ * never guess at a grammar it was not built for.
75
+ */ export const decodeSlip = (input)=>Schema.decodeUnknownEffect(Slip)(input).pipe(Effect.mapError((error)=>new ProtocolFailure({
76
+ reason: `the slip does not decode: ${error.message}`
77
+ })));
78
+ /** Encodes a slip as the workflow payload it travels as. */ export const encodeSlip = (slip)=>Schema.encodeSync(Slip)(slip);
79
+ /** Every step of a slip, in the order it runs. */ export const slipSteps = (slip)=>slip.stages.flatMap((stage)=>stage.steps);
80
+
81
+ //# sourceMappingURL=slip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/flow/slip.ts"],"sourcesContent":["import { ProtocolFailure } from '@entifix/core';\nimport { Effect, Schema } from 'effect';\n\n/**\n * The grammar version a slip is written in. An interpreter branches on it, so a\n * flow that started under one grammar finishes under that grammar even after\n * the next one ships.\n */\nexport const SLIP_VERSION = 1 as const;\n\nconst Call = Schema.Struct({\n method: Schema.Literals(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),\n path: Schema.String,\n});\n\n/** Tags that place a step in a segment of the flow: whose lines, which payment. */\nexport const SlipSegment = Schema.Struct({\n vendor: Schema.optionalKey(Schema.String),\n paymentMethod: Schema.optionalKey(Schema.String),\n});\nexport type SlipSegment = typeof SlipSegment.Type;\n\n/** One pinned step: a fragment reference and everything resolved for it. */\nexport const SlipStep = Schema.Struct({\n /** `id@version`, pinned when the slip was composed. */\n ref: Schema.String,\n /** Unique within the slip; what an Activity is named after (`segment:step`). */\n step: Schema.String,\n cardinality: Schema.Literals(['one', 'perVendor', 'perLine']),\n segment: Schema.optionalKey(SlipSegment),\n participant: Schema.optionalKey(Schema.String),\n call: Schema.optionalKey(Call),\n compensation: Schema.optionalKey(Call),\n /** Configuration pinned at composition — a hold's expiry, a limit. */\n parameters: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),\n});\nexport type SlipStep = typeof SlipStep.Type;\n\nexport const SlipStage = Schema.Struct({\n name: Schema.String,\n steps: Schema.Array(SlipStep),\n});\nexport type SlipStage = typeof SlipStage.Type;\n\n/** Who may receive what the flow announces — the envelope's audience. */\nexport const SlipAudienceEntry = Schema.Struct({\n kind: Schema.Literals(['organization', 'party', 'flow']),\n id: Schema.String,\n digest: Schema.optionalKey(Schema.String),\n});\n\n/** Which variant each use case resolved to, and by which rule. */\nexport const SlipResolution = Schema.Struct({\n useCase: Schema.String,\n variant: Schema.String,\n rule: Schema.Number,\n});\nexport type SlipResolution = typeof SlipResolution.Type;\n\n/**\n * A routing slip: ordered stages of pinned steps, composed once at start and\n * stored as the flow's payload. Changing a recipe or a fragment never changes a\n * flow that has already started.\n */\nexport const Slip = Schema.Struct({\n slipVersion: Schema.Literal(SLIP_VERSION),\n flowId: Schema.String,\n recipe: Schema.String,\n /** The recipe demands a commit point even with no retriable step (a checkout). */\n requiresCommitPoint: Schema.optionalKey(Schema.Boolean),\n stages: Schema.Array(SlipStage),\n resolution: Schema.Array(SlipResolution),\n composedAt: Schema.String,\n /**\n * Who the flow's `flow.*` events reach beside the flow itself — the\n * organizations and parties it acts for, pinned when it was composed.\n */\n audience: Schema.optionalKey(Schema.Array(SlipAudienceEntry)),\n});\nexport type Slip = typeof Slip.Type;\n\n/**\n * Decodes a stored or received slip. An unknown `slipVersion`, like any shape\n * the grammar does not describe, is a protocol failure: an interpreter must\n * never guess at a grammar it was not built for.\n */\nexport const decodeSlip = (\n input: unknown,\n): Effect.Effect<Slip, ProtocolFailure> =>\n Schema.decodeUnknownEffect(Slip)(input).pipe(\n Effect.mapError(\n error =>\n new ProtocolFailure({\n reason: `the slip does not decode: ${error.message}`,\n }),\n ),\n );\n\n/** Encodes a slip as the workflow payload it travels as. */\nexport const encodeSlip = (slip: Slip): unknown =>\n Schema.encodeSync(Slip)(slip);\n\n/** Every step of a slip, in the order it runs. */\nexport const slipSteps = (slip: Slip): readonly SlipStep[] =>\n slip.stages.flatMap(stage => stage.steps);\n"],"names":["ProtocolFailure","Effect","Schema","SLIP_VERSION","Call","Struct","method","Literals","path","String","SlipSegment","vendor","optionalKey","paymentMethod","SlipStep","ref","step","cardinality","segment","participant","call","compensation","parameters","Record","Unknown","SlipStage","name","steps","Array","SlipAudienceEntry","kind","id","digest","SlipResolution","useCase","variant","rule","Number","Slip","slipVersion","Literal","flowId","recipe","requiresCommitPoint","Boolean","stages","resolution","composedAt","audience","decodeSlip","input","decodeUnknownEffect","pipe","mapError","error","reason","message","encodeSlip","slip","encodeSync","slipSteps","flatMap","stage"],"mappings":"AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,SAASC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AAExC;;;;CAIC,GACD,OAAO,MAAMC,eAAe,EAAW;AAEvC,MAAMC,OAAOF,OAAOG,MAAM,CAAC;IACzBC,QAAQJ,OAAOK,QAAQ,CAAC;QAAC;QAAO;QAAQ;QAAO;QAAS;KAAS;IACjEC,MAAMN,OAAOO,MAAM;AACrB;AAEA,iFAAiF,GACjF,OAAO,MAAMC,cAAcR,OAAOG,MAAM,CAAC;IACvCM,QAAQT,OAAOU,WAAW,CAACV,OAAOO,MAAM;IACxCI,eAAeX,OAAOU,W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OU,WAAW,CAACV,OAAO0C,OAAO;IACtDC,QAAQ3C,OAAO0B,KAAK,CAACH;IACrBqB,YAAY5C,OAAO0B,KAAK,CAACK;IACzBc,YAAY7C,OAAOO,MAAM;IACzB;;;GAGC,GACDuC,UAAU9C,OAAOU,WAAW,CAACV,OAAO0B,KAAK,CAACC;AAC5C,GAAG;AAGH;;;;CAIC,GACD,OAAO,MAAMoB,aAAa,CACxBC,QAEAhD,OAAOiD,mBAAmB,CAACb,MAAMY,OAAOE,IAAI,CAC1CnD,OAAOoD,QAAQ,CACbC,CAAAA,QACE,IAAItD,gBAAgB;YAClBuD,QAAQ,CAAC,0BAA0B,EAAED,MAAME,OAAO,EAAE;QACtD,KAEJ;AAEJ,0DAA0D,GAC1D,OAAO,MAAMC,aAAa,CAACC,OACzBxD,OAAOyD,UAAU,CAACrB,MAAMoB,MAAM;AAEhC,gDAAgD,GAChD,OAAO,MAAME,YAAY,CAACF,OACxBA,KAAKb,MAAM,CAACgB,OAAO,CAACC,CAAAA,QAASA,MAAMnC,KAAK,EAAE"}
@@ -0,0 +1,70 @@
1
+ import { Effect, Schema } from 'effect';
2
+ import type { FragmentCatalog } from './catalog.js';
3
+ import { type FragmentKeys, type FragmentRequirements } from './fragment.js';
4
+ import { type Slip } from './slip.js';
5
+ /** One rule a slip broke, named by its tag. */
6
+ export interface SlipViolation {
7
+ readonly tag: 'UnknownFragment' | 'TooManyPivots' | 'MissingCommitPoint' | 'RetriableBeforeCommit' | 'CompensatableAfterCommit' | 'IrreversibleBeforeCommit' | 'WaitBeforeCommit' | 'ExcludedFromSegment' | 'UnsatisfiedInput' | 'UnmetRequirement';
8
+ /** The step that broke it, when one step did. */
9
+ readonly step?: string;
10
+ readonly detail: string;
11
+ }
12
+ /** The facts of a verified context a slip's requirements are checked against. */
13
+ export interface RequirementFacts {
14
+ readonly entitlements?: readonly string[];
15
+ readonly roles?: readonly string[];
16
+ readonly partyRole?: string;
17
+ readonly channel?: string;
18
+ }
19
+ export interface ValidateSlipOptions {
20
+ /** The facts the caller was verified with; requirements go unchecked without them. */
21
+ readonly context?: RequirementFacts;
22
+ /** Keys the flow's start input provides, with their schemas. */
23
+ readonly start?: FragmentKeys;
24
+ }
25
+ /** The requirements `facts` do not meet, described; empty when all are met. */
26
+ export declare const unmetRequirements: (requires: FragmentRequirements, facts: RequirementFacts) => string[];
27
+ /**
28
+ * Checks a slip against its catalog and returns **every** violation, one tag
29
+ * per rule, rather than throwing at the first — so a CI job enumerating every
30
+ * composition reports them all in one run. Pure: no clock, no I/O.
31
+ */
32
+ export declare const validateSlip: (slip: Slip, catalog: FragmentCatalog, options?: ValidateSlipOptions) => readonly SlipViolation[];
33
+ declare const CompositionRefused_base: Schema.Class<CompositionRefused, Schema.TaggedStruct<"CompositionRefused", {
34
+ readonly violations: Schema.$Array<Schema.Struct<{
35
+ readonly tag: Schema.String;
36
+ readonly step: Schema.optionalKey<Schema.String>;
37
+ readonly detail: Schema.String;
38
+ }>>;
39
+ }>, import("effect/Cause").YieldableError & import("@entifix/core").FailureFacts<"flowNotComposable", "declined">>;
40
+ /**
41
+ * A flow that cannot be composed for this caller: the slip broke at least one
42
+ * rule. Every violation travels with it.
43
+ */
44
+ export declare class CompositionRefused extends CompositionRefused_base {
45
+ }
46
+ declare const FlowRequirementsUnmet_base: Schema.Class<FlowRequirementsUnmet, Schema.TaggedStruct<"FlowRequirementsUnmet", {
47
+ readonly violations: Schema.$Array<Schema.Struct<{
48
+ readonly tag: Schema.String;
49
+ readonly step: Schema.optionalKey<Schema.String>;
50
+ readonly detail: Schema.String;
51
+ }>>;
52
+ }>, import("effect/Cause").YieldableError & import("@entifix/core").FailureFacts<"flowRequirementsUnmet", "forbidden">>;
53
+ /**
54
+ * A flow this caller is not offered: every rule the slip broke is a step's
55
+ * requirement — an entitlement, a role, a party role or a channel — that the
56
+ * verified context lacks. The recipe is sound; the caller may not run it, so
57
+ * it is `forbidden` rather than a slip that could not be built.
58
+ */
59
+ export declare class FlowRequirementsUnmet extends FlowRequirementsUnmet_base {
60
+ }
61
+ /** Every violation is a requirement the caller lacks, and there is one. */
62
+ export declare const onlyUnmetRequirements: (violations: readonly SlipViolation[]) => boolean;
63
+ /**
64
+ * Validates a slip, failing on any violation: with {@link FlowRequirementsUnmet}
65
+ * when the caller lacks only what steps require, and otherwise with
66
+ * {@link CompositionRefused}, which carries every violation.
67
+ */
68
+ export declare const assertValidSlip: (slip: Slip, catalog: FragmentCatalog, options?: ValidateSlipOptions) => Effect.Effect<Slip, CompositionRefused | FlowRequirementsUnmet>;
69
+ export {};
70
+ //# sourceMappingURL=validate.d.ts.map