@ontemper/sdk 0.9.0-flow.1 → 0.9.0-flow.3
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 +68 -50
- package/dist/Contract/Manifest.d.ts +26 -46
- package/dist/Contract/Manifest.d.ts.map +1 -1
- package/dist/Contract/Manifest.js +16 -32
- package/dist/Contract/Manifest.js.map +1 -1
- package/dist/Contract/index.d.ts +1 -1
- package/dist/Contract/index.d.ts.map +1 -1
- package/dist/Contract/index.js +1 -1
- package/dist/Contract/index.js.map +1 -1
- package/dist/Logger.js +1 -1
- package/dist/Logger.js.map +1 -1
- package/dist/Manifest.d.ts +12 -1
- package/dist/Manifest.d.ts.map +1 -1
- package/dist/Manifest.js +93 -68
- package/dist/Manifest.js.map +1 -1
- package/dist/Step.d.ts +22 -9
- package/dist/Step.d.ts.map +1 -1
- package/dist/Step.js +59 -22
- package/dist/Step.js.map +1 -1
- package/dist/StepCatalog.d.ts +11 -0
- package/dist/StepCatalog.d.ts.map +1 -0
- package/dist/StepCatalog.js +18 -0
- package/dist/StepCatalog.js.map +1 -0
- package/dist/Workflow.d.ts +2 -0
- package/dist/Workflow.d.ts.map +1 -1
- package/dist/Workflow.js +3 -2
- package/dist/Workflow.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/Flow.d.ts +0 -32
- package/dist/Flow.d.ts.map +0 -1
- package/dist/Flow.js +0 -43
- package/dist/Flow.js.map +0 -1
package/dist/Manifest.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Context, Option, Schema } from 'effect';
|
|
1
|
+
import { Context, Option, Predicate, Schema } from 'effect';
|
|
2
2
|
import { HttpApi } from 'effect/http-api';
|
|
3
|
-
import { declaredRunBudgetSeconds, declaredTriggerConcurrency, concurrencyProblem, runBudgetProblem, stepIdProblem, TriggerMetadata,
|
|
4
|
-
import { Flow } from './Flow.js';
|
|
3
|
+
import { declaredRunBudgetSeconds, declaredTriggerConcurrency, FlowStep, FlowStepKind, concurrencyProblem, runBudgetProblem, stepIdProblem, TriggerMetadata, } from './Contract/Manifest.js';
|
|
5
4
|
import { declarationOf } from './Resource.js';
|
|
6
|
-
import {
|
|
5
|
+
import { closeCatalog } from './StepCatalog.js';
|
|
7
6
|
import { Trigger } from './Trigger.js';
|
|
8
7
|
const decodeTrigger = Schema.decodeUnknownSync(TriggerMetadata, { onExcessProperty: 'error' });
|
|
9
|
-
const
|
|
8
|
+
const isFlowStep = Schema.is(FlowStep);
|
|
9
|
+
const isStepKind = Schema.is(FlowStepKind);
|
|
10
10
|
const identityOf = (resource) => `${resource.kind}:${resource.kind === 'resourceType' ? resource.type : resource.key}`;
|
|
11
|
-
export const SDK_VERSION = '0.9.0-flow.
|
|
11
|
+
export const SDK_VERSION = '0.9.0-flow.3';
|
|
12
12
|
export const RUNTIME_API_VERSION = 1;
|
|
13
13
|
/** The route the SDK serves for platform probes; an API declaring `GET` on it collides with it on every request. */
|
|
14
14
|
export const HEALTHCHECK_PATH = '/healthcheck';
|
|
@@ -62,69 +62,91 @@ const assertOnePolicyPerPath = (endpoints) => {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const stepProblem = (problem) => `Workflow steps: ${problem}`;
|
|
66
|
+
/** The identity of one resource `step` names; it must be a declaration that an endpoint of the workflow holds. */
|
|
67
|
+
const resourceOf = (step, resource, declarations) => {
|
|
68
|
+
const declaration = Predicate.isNotNullish(resource) ? declarationOf(resource) : undefined;
|
|
69
|
+
if (declaration === undefined) {
|
|
70
|
+
return {
|
|
71
|
+
problem: `step ${step.id} names a resource that Resource, Variable, or ResourceType did not declare. Declare it with one of them.`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const identity = identityOf(declaration.manifest);
|
|
75
|
+
const own = declarations.get(identity);
|
|
76
|
+
if (own === undefined) {
|
|
77
|
+
return {
|
|
78
|
+
problem: `step ${step.id} names ${identity}, which no endpoint of the workflow declares. Add it to the middleware of the endpoints that run the step.`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (own !== declaration) {
|
|
82
|
+
return {
|
|
83
|
+
problem: `step ${step.id} names a second declaration of ${identity}. Declare it once and share that class.`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { identity };
|
|
87
|
+
};
|
|
88
|
+
/** Identities of the configuration `step` reads; a resource with a problem is left out and its problem kept. */
|
|
89
|
+
const stepResources = (step, declarations, problems) => {
|
|
90
|
+
const identities = new Set();
|
|
91
|
+
for (const resource of step.resources) {
|
|
92
|
+
const named = resourceOf(step, resource, declarations);
|
|
93
|
+
if ('problem' in named)
|
|
94
|
+
problems.push(stepProblem(named.problem));
|
|
95
|
+
else
|
|
96
|
+
identities.add(named.identity);
|
|
97
|
+
}
|
|
98
|
+
return [...identities].sort(compareText);
|
|
99
|
+
};
|
|
100
|
+
/** Why `step` cannot join a catalog that already holds `first` under its id, or `undefined`. */
|
|
101
|
+
const catalogProblem = (step, first) => {
|
|
102
|
+
const idProblem = stepIdProblem(step.id);
|
|
103
|
+
if (idProblem !== undefined)
|
|
104
|
+
return `${idProblem} Rename the step in Step.make.`;
|
|
105
|
+
if (first !== undefined && first !== step) {
|
|
106
|
+
return `step id ${step.id} repeats with another definition. Give each step its own id, or share one Step value.`;
|
|
107
|
+
}
|
|
108
|
+
if (!isStepKind(step.kind)) {
|
|
109
|
+
return `step ${step.id} has kind ${String(step.kind)}, which is not one of ${FlowStepKind.literals.join(', ')}. Use one of them.`;
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
};
|
|
70
113
|
/**
|
|
71
|
-
* The manifest `
|
|
72
|
-
*
|
|
114
|
+
* The manifest `steps` catalog (FLOW-2) of `declared`, in declaration order, and its problems. Of two values
|
|
115
|
+
* with one id the first stays; a value with an invalid id, kind, title, or summary is left out.
|
|
73
116
|
*/
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
throw new Error(`Endpoint ${name}: ${problem}`);
|
|
77
|
-
};
|
|
117
|
+
const stepsOf = (declared, declarations) => {
|
|
118
|
+
const byId = new Map();
|
|
78
119
|
const steps = [];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
workflowSteps.set(step.id, step);
|
|
90
|
-
const identities = new Set();
|
|
91
|
-
for (const resource of step.resources) {
|
|
92
|
-
const declaration = declarationOf(resource);
|
|
93
|
-
if (declaration === undefined) {
|
|
94
|
-
return fail(`step ${step.id} names a resource that Resource, Variable, or ResourceType did not declare.`);
|
|
95
|
-
}
|
|
96
|
-
const identity = identityOf(declaration.manifest);
|
|
97
|
-
const own = declared.get(identity);
|
|
98
|
-
if (own === undefined) {
|
|
99
|
-
return fail(`step ${step.id} names ${identity}, which the endpoint does not declare. Add it to the endpoint's middleware.`);
|
|
100
|
-
}
|
|
101
|
-
if (own !== declaration)
|
|
102
|
-
return fail(`two declarations use ${identity}: declare it once and share that class.`);
|
|
103
|
-
identities.add(identity);
|
|
104
|
-
}
|
|
120
|
+
const problems = [];
|
|
121
|
+
for (const step of declared) {
|
|
122
|
+
const first = byId.get(step.id);
|
|
123
|
+
const problem = catalogProblem(step, first);
|
|
124
|
+
if (first === undefined)
|
|
125
|
+
byId.set(step.id, step);
|
|
126
|
+
if (problem !== undefined)
|
|
127
|
+
problems.push(stepProblem(problem));
|
|
128
|
+
if (problem !== undefined || first === step)
|
|
129
|
+
continue;
|
|
105
130
|
const { id, title, kind, summary } = step;
|
|
106
|
-
const resources =
|
|
131
|
+
const resources = stepResources(step, declarations, problems);
|
|
107
132
|
// Key order is the wire order; `summary` is left out, not `undefined`, when the step has none.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
fail(`a Flow node names step ${id}, which the Flow does not declare.`);
|
|
115
|
-
}
|
|
116
|
-
for (const id of declaredIds) {
|
|
117
|
-
if (!used.has(id))
|
|
118
|
-
fail(`step ${id} is declared in the Flow, but no node uses it.`);
|
|
133
|
+
const entry = summary === undefined ? { id, title, kind, resources } : { id, title, kind, summary, resources };
|
|
134
|
+
// Checked so a title or summary that a cast let through never reaches the manifest the Flow pane reads.
|
|
135
|
+
if (isFlowStep(entry))
|
|
136
|
+
steps.push(entry);
|
|
137
|
+
else
|
|
138
|
+
problems.push(stepProblem(`step ${id} has a title or summary that is not a string. Give it text in Step.make.`));
|
|
119
139
|
}
|
|
120
|
-
|
|
121
|
-
return Object.freeze(decodeFlow({ steps, nodes: flow.nodes }));
|
|
140
|
+
return { steps, problems };
|
|
122
141
|
};
|
|
123
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Builds the manifest of `api`. A step problem never throws: the catalog keeps what is valid and
|
|
144
|
+
* `stepProblems` names the rest (FLOW-2). The first build closes the step catalog of the process.
|
|
145
|
+
*/
|
|
146
|
+
export const buildManifest = (api) => {
|
|
124
147
|
const endpoints = [];
|
|
125
148
|
// One key serves one declaration: a second class with the same key would read the first one's value.
|
|
126
149
|
const declarations = new Map();
|
|
127
|
-
const workflowSteps = new Map();
|
|
128
150
|
HttpApi.reflect(api, {
|
|
129
151
|
onGroup() { },
|
|
130
152
|
onEndpoint({ endpoint, group, middleware }) {
|
|
@@ -141,7 +163,6 @@ export const makeManifest = (api) => {
|
|
|
141
163
|
throw new Error(`Endpoint ${name}: ${budgetProblem}`);
|
|
142
164
|
}
|
|
143
165
|
const resources = [];
|
|
144
|
-
const declared = new Map();
|
|
145
166
|
for (const key of middleware) {
|
|
146
167
|
const declaration = declarationOf(key);
|
|
147
168
|
if (declaration === undefined)
|
|
@@ -153,12 +174,10 @@ export const makeManifest = (api) => {
|
|
|
153
174
|
throw new Error(`Two declarations use ${identity}: declare it once and share that class.`);
|
|
154
175
|
}
|
|
155
176
|
declarations.set(identity, declaration);
|
|
156
|
-
declared.set(identity, declaration);
|
|
157
177
|
resources.push(declaration.manifest);
|
|
158
178
|
}
|
|
159
179
|
resources.sort((left, right) => compareText(identityOf(left), identityOf(right)));
|
|
160
|
-
|
|
161
|
-
const entry = {
|
|
180
|
+
endpoints.push(Object.freeze({
|
|
162
181
|
group: group.identifier,
|
|
163
182
|
name: endpoint.identifier,
|
|
164
183
|
method: endpoint.method,
|
|
@@ -166,19 +185,25 @@ export const makeManifest = (api) => {
|
|
|
166
185
|
// Validated so a typo in a default never reaches the deploy that seeds records from it.
|
|
167
186
|
trigger: Object.freeze(decodeTrigger(trigger)),
|
|
168
187
|
resources: Object.freeze(resources),
|
|
169
|
-
};
|
|
170
|
-
// Added only when declared, so a manifest without steps keeps its bytes.
|
|
171
|
-
endpoints.push(Object.freeze(flow === undefined ? entry : { ...entry, flow: flowOf(name, flow, declared, workflowSteps) }));
|
|
188
|
+
}));
|
|
172
189
|
},
|
|
173
190
|
});
|
|
174
191
|
endpoints.sort(compareEndpoints);
|
|
175
192
|
assertOnePolicyPerPath(endpoints);
|
|
176
|
-
|
|
193
|
+
const { steps, problems } = stepsOf(closeCatalog(), declarations);
|
|
194
|
+
const manifest = {
|
|
177
195
|
version: 1,
|
|
178
196
|
sdkVersion: SDK_VERSION,
|
|
179
197
|
runtimeApiVersion: RUNTIME_API_VERSION,
|
|
180
198
|
apiId: api.identifier,
|
|
181
199
|
endpoints: Object.freeze(endpoints),
|
|
182
|
-
}
|
|
200
|
+
};
|
|
201
|
+
return {
|
|
202
|
+
// Added only when declared, so a manifest without steps keeps its bytes.
|
|
203
|
+
manifest: Object.freeze(steps.length === 0 ? manifest : { ...manifest, steps: Object.freeze(steps) }),
|
|
204
|
+
stepProblems: Object.freeze(problems),
|
|
205
|
+
};
|
|
183
206
|
};
|
|
207
|
+
/** The manifest of `api`; `buildManifest` also returns the step problems that the build refuses. */
|
|
208
|
+
export const makeManifest = (api) => buildManifest(api).manifest;
|
|
184
209
|
//# sourceMappingURL=Manifest.js.map
|
package/dist/Manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manifest.js","sourceRoot":"","sources":["../src/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Manifest.js","sourceRoot":"","sources":["../src/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAqB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,QAAQ,EACR,YAAY,EAIZ,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,GAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAA2B,aAAa,EAAwB,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,aAAa,GAAG,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/F,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACvC,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;AAE3C,MAAM,UAAU,GAAG,CAAC,QAA0B,EAAU,EAAE,CACxD,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC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,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,YAAY,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG;QACf,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,WAAW;QACvB,iBAAiB,EAAE,mBAAmB;QACtC,KAAK,EAAE,GAAG,CAAC,UAAU;QACrB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;KAC3B,CAAC;IACX,OAAO;QACL,yEAAyE;QACzE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACrG,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;KACtC,CAAC;AACJ,CAAC,CAAC;AAEF,oGAAoG;AACpG,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAgC,EACT,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC"}
|
package/dist/Step.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { type FlowStepKind } from './Contract/Manifest.js';
|
|
3
|
-
import type { FlowGroup } from './Flow.js';
|
|
4
3
|
import type { MiddlewareClass } from './Resource.js';
|
|
5
4
|
export declare const TypeId = "~@temper/workflow/Step";
|
|
6
5
|
/** What one run of a step names, such as the order it maps. */
|
|
7
6
|
export interface RunOptions {
|
|
8
|
-
/** The item this run handles; its first 256 characters become `temperStepItem
|
|
7
|
+
/** The item this run handles; its first 256 characters become `temperStepItem`. A value that is not a string names none. */
|
|
9
8
|
readonly item?: string | undefined;
|
|
10
9
|
}
|
|
11
10
|
/** Wraps an effect in the step's start and end lines and keeps its result, error, and requirements. */
|
|
@@ -13,9 +12,22 @@ export interface Run {
|
|
|
13
12
|
<A, E, R>(effect: Effect.Effect<A, E, R>, options?: RunOptions): Effect.Effect<A, E, R>;
|
|
14
13
|
(options: RunOptions): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
15
14
|
}
|
|
15
|
+
/** What `fn` takes: `item` names the item of one call from its arguments when the step starts; a throw names none. */
|
|
16
|
+
export interface FnOptions<ItemArgs extends Array<unknown>> {
|
|
17
|
+
readonly item?: ((...args: ItemArgs) => string | undefined) | undefined;
|
|
18
|
+
}
|
|
19
|
+
type ErrorOf<Eff> = [Eff] extends [never] ? never : [Eff] extends [Effect.Effect<infer _A, infer E, infer _R>] ? E : never;
|
|
20
|
+
type ServicesOf<Eff> = [Eff] extends [never] ? never : [Eff] extends [Effect.Effect<infer _A, infer _E, infer R>] ? R : never;
|
|
21
|
+
/** A function that runs the step once per call; its arguments, result, error, and requirements are the body's. */
|
|
22
|
+
export type StepFunction<Eff, AEff, Args extends Array<unknown>> = (...args: Args) => Effect.Effect<AEff, ErrorOf<Eff>, ServicesOf<Eff>>;
|
|
23
|
+
/** Builds a function from a generator body, as `Effect.fn` does, and runs the step once per call. */
|
|
24
|
+
export interface Fn {
|
|
25
|
+
<Eff extends Effect.Effect<unknown, unknown, unknown>, AEff, Args extends Array<unknown>>(body: (...args: Args) => Generator<Eff, AEff, never>): StepFunction<Eff, AEff, Args>;
|
|
26
|
+
<ItemArgs extends Array<unknown>>(options: FnOptions<ItemArgs>): <Eff extends Effect.Effect<unknown, unknown, unknown>, AEff, Args extends [...ItemArgs, ...Array<unknown>]>(body: (...args: Args) => Generator<Eff, AEff, never>) => StepFunction<Eff, AEff, Args>;
|
|
27
|
+
}
|
|
16
28
|
/**
|
|
17
|
-
* One named unit of work
|
|
18
|
-
*
|
|
29
|
+
* One named unit of work. Declare it at module level, by convention in `src/Steps.ts`, then run it where
|
|
30
|
+
* the work runs, at any depth. Keep `id` when the title changes: the platform keys Run state on it.
|
|
19
31
|
*/
|
|
20
32
|
export interface Step<Id extends string = string> {
|
|
21
33
|
readonly [TypeId]: typeof TypeId;
|
|
@@ -23,9 +35,10 @@ export interface Step<Id extends string = string> {
|
|
|
23
35
|
readonly title: string;
|
|
24
36
|
readonly kind: FlowStepKind;
|
|
25
37
|
readonly summary: string | undefined;
|
|
26
|
-
/** Classes made with `Resource`, `Variable`, or `ResourceType`; the build rejects
|
|
38
|
+
/** Classes made with `Resource`, `Variable`, or `ResourceType`; the build rejects one that no endpoint declares. */
|
|
27
39
|
readonly resources: ReadonlyArray<MiddlewareClass>;
|
|
28
40
|
readonly run: Run;
|
|
41
|
+
readonly fn: Fn;
|
|
29
42
|
}
|
|
30
43
|
interface Description {
|
|
31
44
|
readonly title: string;
|
|
@@ -40,11 +53,11 @@ export type Options = Description & ({
|
|
|
40
53
|
readonly resources?: ReadonlyArray<MiddlewareClass>;
|
|
41
54
|
readonly resource?: never;
|
|
42
55
|
});
|
|
43
|
-
export declare const isStep: (value: Step | FlowGroup) => value is Step;
|
|
44
56
|
/**
|
|
45
|
-
* Declares a step. `step.run(effect, { item })`
|
|
46
|
-
* `<title> failed.`,
|
|
47
|
-
* nothing. Throws when `id` breaks the FLOW-2
|
|
57
|
+
* Declares a step. `step.run(effect, { item })` and the functions `step.fn(body)` builds write
|
|
58
|
+
* `<title> started.`, then `<title> completed.` or `<title> failed.`, with `temperStep`, `temperStepEvent`,
|
|
59
|
+
* and `temperStepPath` (FLOW-3), at every log level. They retry nothing. Throws when `id` breaks the FLOW-2
|
|
60
|
+
* id rule, with the text the build reports.
|
|
48
61
|
*/
|
|
49
62
|
export declare const make: <const Id extends string>(id: Id, options: Options) => Step<Id>;
|
|
50
63
|
export {};
|
package/dist/Step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Step.d.ts","sourceRoot":"","sources":["../src/Step.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Step.d.ts","sourceRoot":"","sources":["../src/Step.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 +1,70 @@
|
|
|
1
|
-
import { Cause, Effect, Exit, Option, Predicate } from 'effect';
|
|
1
|
+
import { Cause, Context, Effect, Exit, Option, Predicate } from 'effect';
|
|
2
2
|
import { MAX_STEP_FIELD_LENGTH, STEP_LOG_FIELDS, stepIdProblem, } from './Contract/Manifest.js';
|
|
3
3
|
import { logSpan } from './LogContext.js';
|
|
4
|
+
import { isCatalogClosed, register } from './StepCatalog.js';
|
|
4
5
|
export const TypeId = '~@temper/workflow/Step';
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
6
|
+
/** Ids of the steps that enclose the running fiber, outermost first; a forked fiber inherits them. */
|
|
7
|
+
const CurrentStepPath = Context.Reference('@temper/workflow/StepPath', {
|
|
8
|
+
defaultValue: () => [],
|
|
9
|
+
});
|
|
10
|
+
// `ids` joined with `/`. Past 256 characters, a `*` segment replaces the outer ids that do not fit.
|
|
11
|
+
const pathOf = (ids) => {
|
|
12
|
+
const whole = ids.join('/');
|
|
13
|
+
if (whole.length <= MAX_STEP_FIELD_LENGTH)
|
|
14
|
+
return whole;
|
|
15
|
+
const kept = [];
|
|
16
|
+
for (const id of [...ids].reverse()) {
|
|
17
|
+
if (kept.length > 0 && `*/${[id, ...kept].join('/')}`.length > MAX_STEP_FIELD_LENGTH)
|
|
18
|
+
break;
|
|
19
|
+
kept.unshift(id);
|
|
20
|
+
}
|
|
21
|
+
return `*/${kept.join('/')}`;
|
|
22
|
+
};
|
|
23
|
+
const lineFields = ({ id, path, item }, event) => {
|
|
24
|
+
const fields = { [STEP_LOG_FIELDS.step]: id, [STEP_LOG_FIELDS.event]: event, [STEP_LOG_FIELDS.path]: path };
|
|
25
|
+
return item === undefined ? fields : { ...fields, [STEP_LOG_FIELDS.item]: item.slice(0, MAX_STEP_FIELD_LENGTH) };
|
|
26
|
+
};
|
|
27
|
+
/** The item of one run, or `undefined` when `name` throws or returns no string: an item never changes a run (FLOW-4). */
|
|
28
|
+
const itemOf = (name) => Effect.try(name).pipe(Effect.map((item) => (Predicate.isString(item) ? item : undefined)), Effect.orElseSucceed(() => undefined));
|
|
29
|
+
const wrap = (id, title, name) => (effect) => Effect.flatMap(itemOf(name), (item) => Effect.withFiber((fiber) => {
|
|
30
|
+
const ids = [...fiber.getRef(CurrentStepPath), id];
|
|
31
|
+
const line = { id, path: pathOf(ids), item };
|
|
32
|
+
return logSpan(title, {
|
|
33
|
+
fields: (exit) => lineFields(line, exit === undefined ? 'started' : Exit.isSuccess(exit) ? 'completed' : 'failed'),
|
|
34
|
+
// An interrupted run did not complete, so it ends `failed`; its end line still carries `duration`.
|
|
35
|
+
failure: (exit) => (Exit.isSuccess(exit) ? Option.none() : Option.some(Cause.squash(exit.cause))),
|
|
36
|
+
// The API folds started, completed, and failed together, so a level that drops some lines misstates the step (FLOW-3).
|
|
37
|
+
ignoreMinimumLogLevel: true,
|
|
38
|
+
})(Effect.provideService(effect, CurrentStepPath, ids));
|
|
39
|
+
}));
|
|
40
|
+
// A step whose id breaks the FLOW-2 rule writes no line: its effect runs unchanged.
|
|
41
|
+
const passThrough = () => (effect) => effect;
|
|
42
|
+
const fnOf = (id, title, write) => {
|
|
43
|
+
const traced = (body, item) =>
|
|
44
|
+
// The item function runs inside the effect, when the step starts, never when the function is called.
|
|
45
|
+
Effect.fn(id)(body, (effect, ...args) => write(id, title, () => item?.(...args))(effect));
|
|
46
|
+
// SAFETY: `traced` keeps the body's arguments, result, error, and requirements; `Fn` states them.
|
|
47
|
+
return ((first) => Predicate.isFunction(first) ? traced(first, undefined) : (body) => traced(body, first.item));
|
|
48
|
+
};
|
|
20
49
|
/**
|
|
21
|
-
* Declares a step. `step.run(effect, { item })`
|
|
22
|
-
* `<title> failed.`,
|
|
23
|
-
* nothing. Throws when `id` breaks the FLOW-2
|
|
50
|
+
* Declares a step. `step.run(effect, { item })` and the functions `step.fn(body)` builds write
|
|
51
|
+
* `<title> started.`, then `<title> completed.` or `<title> failed.`, with `temperStep`, `temperStepEvent`,
|
|
52
|
+
* and `temperStepPath` (FLOW-3), at every log level. They retry nothing. Throws when `id` breaks the FLOW-2
|
|
53
|
+
* id rule, with the text the build reports.
|
|
24
54
|
*/
|
|
25
55
|
export const make = (id, options) => {
|
|
26
56
|
const idProblem = stepIdProblem(id);
|
|
27
|
-
|
|
57
|
+
// A bad id fails module load, and so the build. After the first build it must not fail a Run (FLOW-4).
|
|
58
|
+
if (idProblem !== undefined && !isCatalogClosed())
|
|
28
59
|
throw new Error(`Step.make: ${idProblem}`);
|
|
60
|
+
const write = idProblem === undefined ? wrap : passThrough;
|
|
29
61
|
const resources = options.resource === undefined ? (options.resources ?? []) : [options.resource];
|
|
30
62
|
function run(first, second) {
|
|
31
|
-
return Effect.isEffect(first)
|
|
63
|
+
return Effect.isEffect(first)
|
|
64
|
+
? write(id, options.title, () => second?.item)(first)
|
|
65
|
+
: write(id, options.title, () => first.item);
|
|
32
66
|
}
|
|
33
|
-
|
|
67
|
+
const step = Object.freeze({
|
|
34
68
|
[TypeId]: TypeId,
|
|
35
69
|
id,
|
|
36
70
|
title: options.title,
|
|
@@ -38,6 +72,9 @@ export const make = (id, options) => {
|
|
|
38
72
|
summary: options.summary,
|
|
39
73
|
resources: Object.freeze([...resources]),
|
|
40
74
|
run,
|
|
75
|
+
fn: fnOf(id, options.title, write),
|
|
41
76
|
});
|
|
77
|
+
register(step);
|
|
78
|
+
return step;
|
|
42
79
|
};
|
|
43
80
|
//# sourceMappingURL=Step.js.map
|
package/dist/Step.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Step.js","sourceRoot":"","sources":["../src/Step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE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B,EAAE;QACF,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;QACxC,GAAG;QACH,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;KACnC,CAAC,CAAC;IACH,QAAQ,CAAC,IAAI,CAAC,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Step } from './Step.js';
|
|
2
|
+
/** Adds a value that `Step.make` returned, until the first build closes the catalog (FLOW-2). */
|
|
3
|
+
export declare const register: (step: Step) => void;
|
|
4
|
+
/** Whether the first build ran: module load is over, and a step made now is made for a Run. */
|
|
5
|
+
export declare const isCatalogClosed: () => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Closes the catalog and returns the values declared before, in declaration order, so a step made per request
|
|
8
|
+
* cannot grow it. A second `workflow()` in one process, which only tests have, reads the same closed list.
|
|
9
|
+
*/
|
|
10
|
+
export declare const closeCatalog: () => ReadonlyArray<Step>;
|
|
11
|
+
//# sourceMappingURL=StepCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepCatalog.d.ts","sourceRoot":"","sources":["../src/StepCatalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKtC,iGAAiG;AACjG,eAAO,MAAM,QAAQ,SAAU,IAAI,KAAG,IAErC,CAAC;AAEF,+FAA+F;AAC/F,eAAO,MAAM,eAAe,QAAO,OAAiB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAO,aAAa,CAAC,IAAI,CAGjD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const declared = [];
|
|
2
|
+
let closed = false;
|
|
3
|
+
/** Adds a value that `Step.make` returned, until the first build closes the catalog (FLOW-2). */
|
|
4
|
+
export const register = (step) => {
|
|
5
|
+
if (!closed)
|
|
6
|
+
declared.push(step);
|
|
7
|
+
};
|
|
8
|
+
/** Whether the first build ran: module load is over, and a step made now is made for a Run. */
|
|
9
|
+
export const isCatalogClosed = () => closed;
|
|
10
|
+
/**
|
|
11
|
+
* Closes the catalog and returns the values declared before, in declaration order, so a step made per request
|
|
12
|
+
* cannot grow it. A second `workflow()` in one process, which only tests have, reads the same closed list.
|
|
13
|
+
*/
|
|
14
|
+
export const closeCatalog = () => {
|
|
15
|
+
closed = true;
|
|
16
|
+
return [...declared];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=StepCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepCatalog.js","sourceRoot":"","sources":["../src/StepCatalog.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAgB,EAAE,CAAC;AACjC,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,iGAAiG;AACjG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC3C,IAAI,CAAC,MAAM;QAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,+FAA+F;AAC/F,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE,CAAC,MAAM,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAwB,EAAE;IACpD,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACvB,CAAC,CAAC"}
|
package/dist/Workflow.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface WorkflowPlatform {
|
|
|
23
23
|
export interface WorkflowModule<Api extends HttpApi.Constraint = HttpApi.Constraint> {
|
|
24
24
|
readonly api: Api;
|
|
25
25
|
readonly manifest: BuiltWorkflowManifest;
|
|
26
|
+
/** Step catalog problems (FLOW-2), each a `Workflow steps: …` text; the build fails while one exists. */
|
|
27
|
+
readonly stepProblems: ReadonlyArray<string>;
|
|
26
28
|
readonly fetch: (request: Request, context: InvocationContext) => Promise<Response>;
|
|
27
29
|
readonly dispose: () => Promise<void>;
|
|
28
30
|
/** The same workflow over replaced platform services; the caller disposes it. */
|
package/dist/Workflow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.d.ts","sourceRoot":"","sources":["../src/Workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAuB,KAAK,EAAgB,MAAM,QAAQ,CAAC;AACzF,OAAO,EAAQ,KAAK,UAAU,EAAgB,UAAU,EAAkC,MAAM,aAAa,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK7C,OAAO,EAAE,KAAK,cAAc,EAAmC,MAAM,eAAe,CAAC;AACrF,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAkB9E,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACzD,wEAAwE;IACxE,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,GAAG,SAAS,CAAC;IACpE,yFAAyF;IACzF,QAAQ,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As2RouteKeys } from './As2Route.js';
|
|
|
6
6
|
import { httpClientLayer } from './HttpClient.js';
|
|
7
7
|
import { Invocation } from './Invocation.js';
|
|
8
8
|
import { loggerLayer, writeStdoutLine } from './Logger.js';
|
|
9
|
-
import {
|
|
9
|
+
import { buildManifest, HEALTHCHECK_PATH } from './Manifest.js';
|
|
10
10
|
import { EventRequestMiddleware, UnmatchedRequestMiddleware } from './Middleware.js';
|
|
11
11
|
import { makeSecretMasks, SecretMasks } from './Redaction.js';
|
|
12
12
|
import { declarationLayer, declarationOf } from './Resource.js';
|
|
@@ -65,7 +65,7 @@ const as2RouteKeysOf = (api) => {
|
|
|
65
65
|
return keys;
|
|
66
66
|
};
|
|
67
67
|
export const workflow = (options) => {
|
|
68
|
-
const manifest =
|
|
68
|
+
const { manifest, stepProblems } = buildManifest(options.api);
|
|
69
69
|
const handlers = options.handlers.pipe(Layer.provide(declarationsOf(options.api, options)));
|
|
70
70
|
const appLayer = Layer.mergeAll(PlatformRoutes, HttpApiBuilder.layer(options.api).pipe(Layer.provide(handlers), Layer.provide(EventRequestMiddleware)), UnmatchedRequestMiddleware).pipe(Layer.provide(HttpServer.layerServices), Layer.provide(InMemoryHttpPlatform), Layer.provideMerge(platformLayer(options)), Layer.provideMerge(Layer.succeed(As2RouteKeys, as2RouteKeysOf(options.api))));
|
|
71
71
|
// Legacy Hono routing: exact case, no trailing- or duplicate-slash folding, unbounded parameters.
|
|
@@ -83,6 +83,7 @@ export const workflow = (options) => {
|
|
|
83
83
|
return Object.freeze({
|
|
84
84
|
api: options.api,
|
|
85
85
|
manifest,
|
|
86
|
+
stepProblems,
|
|
86
87
|
fetch: (request, invocation) => {
|
|
87
88
|
stripPlatformHeaders(request);
|
|
88
89
|
const run = (served = request) => handler(served, Context.make(Invocation, invocation));
|
package/dist/Workflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.js","sourceRoot":"","sources":["../src/Workflow.ts"],"names":[],"mappings":"A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K,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC/G,CAAC;QACD,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,YAAY,EAAE,CAAC,QAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;KACpF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ export { type ChildRequest, childMessageId, type Correlation, currentCorrelation
|
|
|
4
4
|
export { type OutboundFetch } from './HttpClient.js';
|
|
5
5
|
export type { AnswerTrailer, AnswerTrailerError, InvocationResponsePolicy } from './Contract/EarlyAnswer.js';
|
|
6
6
|
export type { InvocationContext, InvocationTriggerKind } from './Contract/Invocation.js';
|
|
7
|
-
export {
|
|
8
|
-
export { Flow, type FlowDeclaration, type FlowGroup, type FlowPart } from './Flow.js';
|
|
7
|
+
export { FlowStep, FlowStepKind, ManifestResource, ResponsePolicy, TriggerKind, TriggerMetadata, WorkflowManifest, WorkflowManifestEndpoint, WorkflowSteps, } from './Contract/Manifest.js';
|
|
9
8
|
export { As2IdentityResource, As2PartnerResource } from './As2Resource.js';
|
|
10
9
|
export { As2Route } from './As2Route.js';
|
|
11
10
|
export { HttpApiAuth, HttpApiResource, HttpApiUnsupportedAuth, HttpProxy, OAuthTokenRequest, TlsSettings, } from './HttpApiResource.js';
|