@acmekit/workflows-sdk 2.13.36 → 2.13.38
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/dist/helper/type.d.ts +5 -15
- package/dist/helper/type.d.ts.map +1 -1
- package/dist/helper/workflow-export.d.ts +4 -1
- package/dist/helper/workflow-export.d.ts.map +1 -1
- package/dist/helper/workflow-export.js +42 -37
- package/dist/helper/workflow-export.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composer/create-step.d.ts +14 -21
- package/dist/utils/composer/create-step.d.ts.map +1 -1
- package/dist/utils/composer/create-step.js +16 -70
- package/dist/utils/composer/create-step.js.map +1 -1
- package/dist/utils/composer/create-workflow.d.ts +17 -13
- package/dist/utils/composer/create-workflow.d.ts.map +1 -1
- package/dist/utils/composer/create-workflow.js +12 -74
- package/dist/utils/composer/create-workflow.js.map +1 -1
- package/dist/utils/composer/helpers/create-step-handler.d.ts +1 -1
- package/dist/utils/composer/helpers/create-step-handler.d.ts.map +1 -1
- package/dist/utils/composer/helpers/create-step-handler.js +97 -52
- package/dist/utils/composer/helpers/create-step-handler.js.map +1 -1
- package/dist/utils/composer/helpers/workflow-response.d.ts +4 -27
- package/dist/utils/composer/helpers/workflow-response.d.ts.map +1 -1
- package/dist/utils/composer/helpers/workflow-response.js +1 -14
- package/dist/utils/composer/helpers/workflow-response.js.map +1 -1
- package/dist/utils/composer/index.d.ts +4 -4
- package/dist/utils/composer/index.d.ts.map +1 -1
- package/dist/utils/composer/index.js +7 -4
- package/dist/utils/composer/index.js.map +1 -1
- package/dist/utils/composer/metadata.d.ts +37 -0
- package/dist/utils/composer/metadata.d.ts.map +1 -0
- package/dist/utils/composer/metadata.js +134 -0
- package/dist/utils/composer/metadata.js.map +1 -0
- package/dist/utils/composer/query.d.ts +38 -0
- package/dist/utils/composer/query.d.ts.map +1 -0
- package/dist/utils/composer/query.js +55 -0
- package/dist/utils/composer/query.js.map +1 -0
- package/dist/utils/composer/signal.d.ts +42 -0
- package/dist/utils/composer/signal.d.ts.map +1 -0
- package/dist/utils/composer/signal.js +117 -0
- package/dist/utils/composer/signal.js.map +1 -0
- package/dist/utils/composer/type.d.ts +35 -8
- package/dist/utils/composer/type.d.ts.map +1 -1
- package/dist/utils/composer/type.js +12 -0
- package/dist/utils/composer/type.js.map +1 -1
- package/package.json +6 -6
- package/dist/testing/index.d.ts +0 -4
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -20
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/mock-step.d.ts +0 -26
- package/dist/testing/mock-step.d.ts.map +0 -1
- package/dist/testing/mock-step.js +0 -96
- package/dist/testing/mock-step.js.map +0 -1
- package/dist/testing/types.d.ts +0 -51
- package/dist/testing/types.d.ts.map +0 -1
- package/dist/testing/types.js +0 -3
- package/dist/testing/types.js.map +0 -1
- package/dist/testing/workflow-test-runner.d.ts +0 -35
- package/dist/testing/workflow-test-runner.d.ts.map +0 -1
- package/dist/testing/workflow-test-runner.js +0 -99
- package/dist/testing/workflow-test-runner.js.map +0 -1
- package/dist/utils/composer/for-each.d.ts +0 -25
- package/dist/utils/composer/for-each.d.ts.map +0 -1
- package/dist/utils/composer/for-each.js +0 -50
- package/dist/utils/composer/for-each.js.map +0 -1
- package/dist/utils/composer/pipe.d.ts +0 -24
- package/dist/utils/composer/pipe.d.ts.map +0 -1
- package/dist/utils/composer/pipe.js +0 -11
- package/dist/utils/composer/pipe.js.map +0 -1
- package/dist/utils/composer/race.d.ts +0 -19
- package/dist/utils/composer/race.d.ts.map +0 -1
- package/dist/utils/composer/race.js +0 -43
- package/dist/utils/composer/race.js.map +0 -1
- package/dist/utils/composer/retry.d.ts +0 -36
- package/dist/utils/composer/retry.d.ts.map +0 -1
- package/dist/utils/composer/retry.js +0 -27
- package/dist/utils/composer/retry.js.map +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mockStep = mockStep;
|
|
4
|
-
exports.restoreAllMocks = restoreAllMocks;
|
|
5
|
-
const orchestration_1 = require("@acmekit/orchestration");
|
|
6
|
-
const step_response_1 = require("../utils/composer/helpers/step-response");
|
|
7
|
-
const originals = new Map();
|
|
8
|
-
/**
|
|
9
|
-
* Replace the invoke and/or compensate handlers for a specific step in a
|
|
10
|
-
* registered workflow. Useful for isolating a single step's behavior in tests.
|
|
11
|
-
*
|
|
12
|
-
* Returns a `restore` function that reverts the mock.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const restore = mockStep("my-workflow", "create-record", {
|
|
17
|
-
* invoke: () => ({ id: "mock-id" }),
|
|
18
|
-
* })
|
|
19
|
-
*
|
|
20
|
-
* const { result } = await myWorkflow.run({ input: { ... } })
|
|
21
|
-
* expect(result.id).toBe("mock-id")
|
|
22
|
-
*
|
|
23
|
-
* restore()
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
function mockStep(workflowId, stepAction, options) {
|
|
27
|
-
const workflow = orchestration_1.WorkflowManager.getWorkflow(workflowId);
|
|
28
|
-
if (!workflow) {
|
|
29
|
-
throw new Error(`Cannot mock step: workflow "${workflowId}" is not registered.`);
|
|
30
|
-
}
|
|
31
|
-
const handlers = workflow.handlers_;
|
|
32
|
-
const existing = handlers.get(stepAction);
|
|
33
|
-
if (!existing) {
|
|
34
|
-
throw new Error(`Cannot mock step: action "${stepAction}" not found in workflow "${workflowId}".`);
|
|
35
|
-
}
|
|
36
|
-
// Save originals for restoration
|
|
37
|
-
if (!originals.has(workflowId)) {
|
|
38
|
-
originals.set(workflowId, new Map());
|
|
39
|
-
}
|
|
40
|
-
if (!originals.get(workflowId).has(stepAction)) {
|
|
41
|
-
originals.get(workflowId).set(stepAction, { ...existing });
|
|
42
|
-
}
|
|
43
|
-
// Replace handlers
|
|
44
|
-
const mockedHandlers = { ...existing };
|
|
45
|
-
if (options.invoke) {
|
|
46
|
-
const mockInvoke = options.invoke;
|
|
47
|
-
mockedHandlers.invoke = async () => {
|
|
48
|
-
const result = await mockInvoke();
|
|
49
|
-
return new step_response_1.StepResponse(result, result);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (options.compensate) {
|
|
53
|
-
const mockCompensate = options.compensate;
|
|
54
|
-
mockedHandlers.compensate = async () => {
|
|
55
|
-
await mockCompensate();
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
handlers.set(stepAction, mockedHandlers);
|
|
59
|
-
// Rebuild the handler function on the workflow definition
|
|
60
|
-
workflow.handler = orchestration_1.WorkflowManager.buildHandlers(handlers);
|
|
61
|
-
// Return restore function
|
|
62
|
-
return () => {
|
|
63
|
-
const original = originals.get(workflowId)?.get(stepAction);
|
|
64
|
-
if (original) {
|
|
65
|
-
handlers.set(stepAction, original);
|
|
66
|
-
workflow.handler = orchestration_1.WorkflowManager.buildHandlers(handlers);
|
|
67
|
-
originals.get(workflowId).delete(stepAction);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Restore all mocked steps for a given workflow (or all workflows).
|
|
73
|
-
* Useful in `afterEach` / `afterAll` hooks.
|
|
74
|
-
*/
|
|
75
|
-
function restoreAllMocks(workflowId) {
|
|
76
|
-
if (workflowId) {
|
|
77
|
-
const mocks = originals.get(workflowId);
|
|
78
|
-
if (mocks) {
|
|
79
|
-
const workflow = orchestration_1.WorkflowManager.getWorkflow(workflowId);
|
|
80
|
-
if (workflow) {
|
|
81
|
-
for (const [action, original] of mocks.entries()) {
|
|
82
|
-
workflow.handlers_.set(action, original);
|
|
83
|
-
}
|
|
84
|
-
workflow.handler = orchestration_1.WorkflowManager.buildHandlers(workflow.handlers_);
|
|
85
|
-
}
|
|
86
|
-
originals.delete(workflowId);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
for (const [wfId] of originals) {
|
|
91
|
-
restoreAllMocks(wfId);
|
|
92
|
-
}
|
|
93
|
-
originals.clear();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=mock-step.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-step.js","sourceRoot":"","sources":["../../src/testing/mock-step.ts"],"names":[],"mappings":";;AA6BA,4BA4DC;AAMD,0CAmBC;AAlHD,0DAAwD;AACxD,2EAAsE;AAQtE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyC,CAAA;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,QAAQ,CACtB,UAAkB,EAClB,UAAkB,EAClB,OAAiC;IAEjC,MAAM,QAAQ,GAAG,+BAAe,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,+BAA+B,UAAU,sBAAsB,CAChE,CAAA;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAA;IACnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,6BAA6B,UAAU,4BAA4B,UAAU,IAAI,CAClF,CAAA;IACH,CAAC;IAED,iCAAiC;IACjC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;IACtC,CAAC;IACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QAChD,SAAS,CAAC,GAAG,CAAC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,SAAgB,eAAe,CAAC,UAAmB;IACjD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvC,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,QAAQ,GAAG,+BAAe,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;YACxD,IAAI,QAAQ,EAAE,CAAC;gBACb,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;oBACjD,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,QAAe,CAAC,CAAA;gBACjD,CAAC;gBACD,QAAQ,CAAC,OAAO,GAAG,+BAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YACtE,CAAC;YACD,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAC9B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC;YAC/B,eAAe,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;AACH,CAAC"}
|
package/dist/testing/types.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { DistributedTransactionType } from "@acmekit/orchestration";
|
|
2
|
-
import { AcmeKitContainer } from "@acmekit/types";
|
|
3
|
-
import { WorkflowResult } from "../helper/type";
|
|
4
|
-
/**
|
|
5
|
-
* Context object provided to test assertions after a workflow run.
|
|
6
|
-
*/
|
|
7
|
-
export type WorkflowTestContext<TResult = unknown> = {
|
|
8
|
-
/** The workflow result */
|
|
9
|
-
result: WorkflowResult<TResult>;
|
|
10
|
-
/** All events captured during the run, in order */
|
|
11
|
-
events: WorkflowTestEvent[];
|
|
12
|
-
/** Errors thrown by the workflow (if any) */
|
|
13
|
-
errors: Error[];
|
|
14
|
-
/** The underlying transaction */
|
|
15
|
-
transaction: DistributedTransactionType;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* An event captured during a test run.
|
|
19
|
-
*/
|
|
20
|
-
export type WorkflowTestEvent = {
|
|
21
|
-
/** Event name (e.g. "begin", "step_success", "finish") */
|
|
22
|
-
name: string;
|
|
23
|
-
/** Timestamp of the event */
|
|
24
|
-
timestamp: number;
|
|
25
|
-
/** Associated data */
|
|
26
|
-
data?: Record<string, unknown>;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Options for `mockStep`.
|
|
30
|
-
*/
|
|
31
|
-
export type MockStepOptions<TOutput = unknown> = {
|
|
32
|
-
/**
|
|
33
|
-
* The mock invoke handler. Return the value the step should produce.
|
|
34
|
-
* Throw to simulate a step failure.
|
|
35
|
-
*/
|
|
36
|
-
invoke?: () => TOutput | Promise<TOutput>;
|
|
37
|
-
/**
|
|
38
|
-
* The mock compensate handler. Return void or throw to simulate compensation failure.
|
|
39
|
-
*/
|
|
40
|
-
compensate?: () => void | Promise<void>;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Options for `createWorkflowTestRunner`.
|
|
44
|
-
*/
|
|
45
|
-
export type WorkflowTestRunnerOptions = {
|
|
46
|
-
/** A container or loaded modules to use for the test run. */
|
|
47
|
-
container?: AcmeKitContainer;
|
|
48
|
-
/** Whether to throw on errors (defaults to false for test inspection). */
|
|
49
|
-
throwOnError?: boolean;
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,OAAO,GAAG,OAAO,IAAI;IACnD,0BAA0B;IAC1B,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B,mDAAmD;IACnD,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,6CAA6C;IAC7C,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,iCAAiC;IACjC,WAAW,EAAE,0BAA0B,CAAA;CACxC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,GAAG,OAAO,IAAI;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACzC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,6DAA6D;IAC7D,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA"}
|
package/dist/testing/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AcmeKitContainer } from "@acmekit/types";
|
|
2
|
-
import { MainExportedWorkflow } from "../helper/type";
|
|
3
|
-
import { WorkflowTestContext, WorkflowTestRunnerOptions } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* Creates a test runner that wraps a workflow with event capturing
|
|
6
|
-
* and assertion-friendly output.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { createWorkflowTestRunner } from "@acmekit/workflows-sdk/testing"
|
|
11
|
-
*
|
|
12
|
-
* const runner = createWorkflowTestRunner(myWorkflow)
|
|
13
|
-
*
|
|
14
|
-
* it("should create a record", async () => {
|
|
15
|
-
* const { result, events, errors } = await runner.run({
|
|
16
|
-
* input: { name: "Test" },
|
|
17
|
-
* })
|
|
18
|
-
*
|
|
19
|
-
* expect(errors).toHaveLength(0)
|
|
20
|
-
* expect(result.result).toEqual({ id: expect.any(String), name: "Test" })
|
|
21
|
-
* expect(events.some(e => e.name === "finish")).toBe(true)
|
|
22
|
-
* })
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare function createWorkflowTestRunner<TData = unknown, TResult = unknown>(workflow: MainExportedWorkflow<TData, TResult>, options?: WorkflowTestRunnerOptions): {
|
|
26
|
-
/**
|
|
27
|
-
* Run the workflow and capture all events for assertions.
|
|
28
|
-
*/
|
|
29
|
-
run(runOptions?: {
|
|
30
|
-
input?: TData;
|
|
31
|
-
container?: AcmeKitContainer;
|
|
32
|
-
throwOnError?: boolean;
|
|
33
|
-
}): Promise<WorkflowTestContext<TResult>>;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=workflow-test-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-test-runner.d.ts","sourceRoot":"","sources":["../../src/testing/workflow-test-runner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAkB,MAAM,gBAAgB,CAAA;AACrE,OAAO,EACL,mBAAmB,EAEnB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EACzE,QAAQ,EAAE,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,EAC9C,OAAO,CAAC,EAAE,yBAAyB;IAGjC;;OAEG;qBACoB;QACrB,KAAK,CAAC,EAAE,KAAK,CAAA;QACb,SAAS,CAAC,EAAE,gBAAgB,CAAA;QAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;KACvB,GAAG,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;EA0E5C"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWorkflowTestRunner = createWorkflowTestRunner;
|
|
4
|
-
/**
|
|
5
|
-
* Creates a test runner that wraps a workflow with event capturing
|
|
6
|
-
* and assertion-friendly output.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { createWorkflowTestRunner } from "@acmekit/workflows-sdk/testing"
|
|
11
|
-
*
|
|
12
|
-
* const runner = createWorkflowTestRunner(myWorkflow)
|
|
13
|
-
*
|
|
14
|
-
* it("should create a record", async () => {
|
|
15
|
-
* const { result, events, errors } = await runner.run({
|
|
16
|
-
* input: { name: "Test" },
|
|
17
|
-
* })
|
|
18
|
-
*
|
|
19
|
-
* expect(errors).toHaveLength(0)
|
|
20
|
-
* expect(result.result).toEqual({ id: expect.any(String), name: "Test" })
|
|
21
|
-
* expect(events.some(e => e.name === "finish")).toBe(true)
|
|
22
|
-
* })
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
function createWorkflowTestRunner(workflow, options) {
|
|
26
|
-
return {
|
|
27
|
-
/**
|
|
28
|
-
* Run the workflow and capture all events for assertions.
|
|
29
|
-
*/
|
|
30
|
-
async run(runOptions) {
|
|
31
|
-
const events = [];
|
|
32
|
-
const errors = [];
|
|
33
|
-
const captureEvent = (name) => {
|
|
34
|
-
return (args) => {
|
|
35
|
-
events.push({
|
|
36
|
-
name,
|
|
37
|
-
timestamp: Date.now(),
|
|
38
|
-
data: args.transaction
|
|
39
|
-
? {
|
|
40
|
-
transactionId: args.transaction.transactionId,
|
|
41
|
-
state: args.transaction.getFlow().state,
|
|
42
|
-
}
|
|
43
|
-
: undefined,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const eventHandlers = {
|
|
48
|
-
onBegin: captureEvent("begin"),
|
|
49
|
-
onResume: captureEvent("resume"),
|
|
50
|
-
onFinish: captureEvent("finish"),
|
|
51
|
-
onTimeout: captureEvent("timeout"),
|
|
52
|
-
onStepBegin: captureEvent("step_begin"),
|
|
53
|
-
onStepSuccess: captureEvent("step_success"),
|
|
54
|
-
onStepFailure: captureEvent("step_failure"),
|
|
55
|
-
onCompensateBegin: captureEvent("compensate_begin"),
|
|
56
|
-
onCompensateStepSuccess: captureEvent("compensate_step_success"),
|
|
57
|
-
onCompensateStepFailure: captureEvent("compensate_step_failure"),
|
|
58
|
-
};
|
|
59
|
-
const container = runOptions?.container ?? options?.container;
|
|
60
|
-
const throwOnError = runOptions?.throwOnError ?? options?.throwOnError ?? false;
|
|
61
|
-
let result;
|
|
62
|
-
try {
|
|
63
|
-
result = await workflow.run({
|
|
64
|
-
input: runOptions?.input,
|
|
65
|
-
container,
|
|
66
|
-
throwOnError,
|
|
67
|
-
events: eventHandlers,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
errors.push(error);
|
|
72
|
-
return {
|
|
73
|
-
result: {
|
|
74
|
-
errors: [error],
|
|
75
|
-
transaction: undefined,
|
|
76
|
-
result: undefined,
|
|
77
|
-
},
|
|
78
|
-
events,
|
|
79
|
-
errors,
|
|
80
|
-
transaction: undefined,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (result.errors?.length) {
|
|
84
|
-
for (const err of result.errors) {
|
|
85
|
-
if (err?.error) {
|
|
86
|
-
errors.push(err.error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
result,
|
|
92
|
-
events,
|
|
93
|
-
errors,
|
|
94
|
-
transaction: result.transaction,
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=workflow-test-runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-test-runner.js","sourceRoot":"","sources":["../../src/testing/workflow-test-runner.ts"],"names":[],"mappings":";;AAiCA,4DAsFC;AA3GD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,wBAAwB,CACtC,QAA8C,EAC9C,OAAmC;IAEnC,OAAO;QACL;;WAEG;QACH,KAAK,CAAC,GAAG,CAAC,UAIT;YACC,MAAM,MAAM,GAAwB,EAAE,CAAA;YACtC,MAAM,MAAM,GAAY,EAAE,CAAA;YAE1B,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;gBACpC,OAAO,CAAC,IAAkD,EAAE,EAAE;oBAC5D,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI;wBACJ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;wBACrB,IAAI,EAAE,IAAI,CAAC,WAAW;4BACpB,CAAC,CAAC;gCACE,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa;gCAC7C,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK;6BACxC;4BACH,CAAC,CAAC,SAAS;qBACd,CAAC,CAAA;gBACJ,CAAC,CAAA;YACH,CAAC,CAAA;YAED,MAAM,aAAa,GAAiC;gBAClD,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC;gBAC9B,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC;gBAChC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC;gBAChC,SAAS,EAAE,YAAY,C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;gBACN,MAAM;gBACN,MAAM;gBACN,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { WorkflowData } from "./type";
|
|
2
|
-
/**
|
|
3
|
-
* Dynamic fan-out primitive. Iterates over a runtime array and runs the provided
|
|
4
|
-
* step function for each element, collecting results. Compensation reverses the
|
|
5
|
-
* iteration order.
|
|
6
|
-
*
|
|
7
|
-
* Unlike `parallelize`, `forEach` works with arrays whose length is unknown at
|
|
8
|
-
* workflow definition time.
|
|
9
|
-
*
|
|
10
|
-
* @param name - A unique name for this forEach block.
|
|
11
|
-
* @param items - A workflow data reference to an array of items.
|
|
12
|
-
* @param stepFn - A step function to invoke for each item.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { forEach } from "@acmekit/framework/workflows-sdk"
|
|
17
|
-
*
|
|
18
|
-
* const notifyWorkflow = createWorkflow("notify-users", (input: { userIds: string[] }) => {
|
|
19
|
-
* const results = forEach("notify-each-user", input.userIds, sendNotificationStep)
|
|
20
|
-
* return new WorkflowResponse(results)
|
|
21
|
-
* })
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function forEach<TItem, TOutput>(name: string, items: WorkflowData<TItem[]>, stepFn: (item: TItem) => WorkflowData<TOutput> | TOutput): WorkflowData<TOutput[]>;
|
|
25
|
-
//# sourceMappingURL=for-each.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"for-each.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/for-each.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EACpC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,EAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO,GACvD,YAAY,CAAC,OAAO,EAAE,CAAC,CA6BzB"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forEach = forEach;
|
|
4
|
-
const create_step_1 = require("./create-step");
|
|
5
|
-
const step_response_1 = require("./helpers/step-response");
|
|
6
|
-
/**
|
|
7
|
-
* Dynamic fan-out primitive. Iterates over a runtime array and runs the provided
|
|
8
|
-
* step function for each element, collecting results. Compensation reverses the
|
|
9
|
-
* iteration order.
|
|
10
|
-
*
|
|
11
|
-
* Unlike `parallelize`, `forEach` works with arrays whose length is unknown at
|
|
12
|
-
* workflow definition time.
|
|
13
|
-
*
|
|
14
|
-
* @param name - A unique name for this forEach block.
|
|
15
|
-
* @param items - A workflow data reference to an array of items.
|
|
16
|
-
* @param stepFn - A step function to invoke for each item.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { forEach } from "@acmekit/framework/workflows-sdk"
|
|
21
|
-
*
|
|
22
|
-
* const notifyWorkflow = createWorkflow("notify-users", (input: { userIds: string[] }) => {
|
|
23
|
-
* const results = forEach("notify-each-user", input.userIds, sendNotificationStep)
|
|
24
|
-
* return new WorkflowResponse(results)
|
|
25
|
-
* })
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
function forEach(name, items, stepFn) {
|
|
29
|
-
if (!name || typeof name !== "string") {
|
|
30
|
-
throw new Error(`"forEach" name must be a non-empty string`);
|
|
31
|
-
}
|
|
32
|
-
const forEachStep = (0, create_step_1.createStep)({
|
|
33
|
-
name,
|
|
34
|
-
saveResponse: true,
|
|
35
|
-
}, async (resolvedItems, context) => {
|
|
36
|
-
const results = [];
|
|
37
|
-
const compensateData = [];
|
|
38
|
-
for (const item of resolvedItems) {
|
|
39
|
-
const result = await Promise.resolve(stepFn(item));
|
|
40
|
-
results.push(result);
|
|
41
|
-
compensateData.push(item);
|
|
42
|
-
}
|
|
43
|
-
return new step_response_1.StepResponse(results, compensateData);
|
|
44
|
-
}, async (compensateData) => {
|
|
45
|
-
// Compensation is a no-op at the forEach level.
|
|
46
|
-
// Individual step compensations are handled by the inner step definitions.
|
|
47
|
-
});
|
|
48
|
-
return forEachStep(items);
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=for-each.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"for-each.js","sourceRoot":"","sources":["../../../src/utils/composer/for-each.ts"],"names":[],"mappings":";;AA0BA,0BAiCC;AA3DD,+CAA0C;AAC1C,2DAAsD;AAGtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,OAAO,CACrB,IAAY,EACZ,KAA4B,EAC5B,MAAwD;IAExD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,wBAAU,EAC5B;QACE,IAAI;QACJ,YAAY,EAAE,IAAI;KACnB,EACD,KAAK,EAAE,aAAsB,EAAE,OAAO,EAAE,EAAE;QACxC,MAAM,OAAO,GAAc,EAAE,CAAA;QAC7B,MAAM,cAAc,GAAY,EAAE,CAAA;QAElC,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;YAClD,OAAO,CAAC,IAAI,CAAC,MAAiB,CAAC,CAAA;YAC/B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO,IAAI,4BAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAClD,CAAC,EACD,KAAK,EAAE,cAAmC,EAAE,EAAE;QAC5C,gDAAgD;QAChD,2EAA2E;IAC7E,CAAC,CACF,CAAA;IAED,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { StepFunction, WorkflowData } from "./type";
|
|
2
|
-
/**
|
|
3
|
-
* Sequentially chains steps, passing the output of each as input to the next.
|
|
4
|
-
* Pure ergonomics — compiles to the same sequential step chain.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* import { pipe } from "@acmekit/framework/workflows-sdk"
|
|
9
|
-
*
|
|
10
|
-
* const result = pipe(input, validateStep, transformStep, saveStep)
|
|
11
|
-
* // Equivalent to:
|
|
12
|
-
* // const a = validateStep(input)
|
|
13
|
-
* // const b = transformStep(a)
|
|
14
|
-
* // const c = saveStep(b)
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function pipe<TInput, TA>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>): WorkflowData<TA>;
|
|
18
|
-
export declare function pipe<TInput, TA, TB>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>, step2: StepFunction<TA, TB>): WorkflowData<TB>;
|
|
19
|
-
export declare function pipe<TInput, TA, TB, TC>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>, step2: StepFunction<TA, TB>, step3: StepFunction<TB, TC>): WorkflowData<TC>;
|
|
20
|
-
export declare function pipe<TInput, TA, TB, TC, TD>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>, step2: StepFunction<TA, TB>, step3: StepFunction<TB, TC>, step4: StepFunction<TC, TD>): WorkflowData<TD>;
|
|
21
|
-
export declare function pipe<TInput, TA, TB, TC, TD, TE>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>, step2: StepFunction<TA, TB>, step3: StepFunction<TB, TC>, step4: StepFunction<TC, TD>, step5: StepFunction<TD, TE>): WorkflowData<TE>;
|
|
22
|
-
export declare function pipe<TInput, TA, TB, TC, TD, TE, TF>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>, step2: StepFunction<TA, TB>, step3: StepFunction<TB, TC>, step4: StepFunction<TC, TD>, step5: StepFunction<TD, TE>, step6: StepFunction<TE, TF>): WorkflowData<TF>;
|
|
23
|
-
export declare function pipe<TInput, TA, TB, TC, TD, TE, TF, TG>(input: WorkflowData<TInput>, step1: StepFunction<TInput, TA>, step2: StepFunction<TA, TB>, step3: StepFunction<TB, TC>, step4: StepFunction<TC, TD>, step5: StepFunction<TD, TE>, step6: StepFunction<TE, TF>, step7: StepFunction<TF, TG>): WorkflowData<TG>;
|
|
24
|
-
//# sourceMappingURL=pipe.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAEnD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,EAAE,EAC7B,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,GAC9B,YAAY,CAAC,EAAE,CAAC,CAAA;AAEnB,wBAAgB,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EACjC,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,EAC/B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,GAC1B,YAAY,CAAC,EAAE,CAAC,CAAA;AAEnB,wBAAgB,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EACrC,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,EAC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AAC,EAC/B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,GAC1B,YAAY,CAAC,EAAE,CAAC,CAAA;AAEnB,wBAAgB,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EACrD,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,EAC/B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,KAAK,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,GAC1B,YAAY,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pipe = pipe;
|
|
4
|
-
function pipe(input, ...steps) {
|
|
5
|
-
let current = input;
|
|
6
|
-
for (const step of steps) {
|
|
7
|
-
current = step(current);
|
|
8
|
-
}
|
|
9
|
-
return current;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=pipe.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../src/utils/composer/pipe.ts"],"names":[],"mappings":";;AAyEA,oBASC;AATD,SAAgB,IAAI,CAClB,KAAwB,EACxB,GAAG,KAA+B;IAElC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;IACzB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { WorkflowData } from "./type";
|
|
2
|
-
/**
|
|
3
|
-
* Runs multiple steps in parallel and returns the first non-undefined result.
|
|
4
|
-
* Other steps still complete but their results are discarded.
|
|
5
|
-
*
|
|
6
|
-
* Useful for timeout/fallback patterns where you want the fastest response.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { race } from "@acmekit/framework/workflows-sdk"
|
|
11
|
-
*
|
|
12
|
-
* const result = race(
|
|
13
|
-
* callPrimaryApiStep(input),
|
|
14
|
-
* callFallbackApiStep(input),
|
|
15
|
-
* )
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function race<TResult>(...steps: WorkflowData<TResult>[]): WorkflowData<TResult>;
|
|
19
|
-
//# sourceMappingURL=race.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"race.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/race.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAC1B,GAAG,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,GAChC,YAAY,CAAC,OAAO,CAAC,CA0BvB"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.race = race;
|
|
4
|
-
const utils_1 = require("@acmekit/utils");
|
|
5
|
-
const parallelize_1 = require("./parallelize");
|
|
6
|
-
const transform_1 = require("./transform");
|
|
7
|
-
/**
|
|
8
|
-
* Runs multiple steps in parallel and returns the first non-undefined result.
|
|
9
|
-
* Other steps still complete but their results are discarded.
|
|
10
|
-
*
|
|
11
|
-
* Useful for timeout/fallback patterns where you want the fastest response.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { race } from "@acmekit/framework/workflows-sdk"
|
|
16
|
-
*
|
|
17
|
-
* const result = race(
|
|
18
|
-
* callPrimaryApiStep(input),
|
|
19
|
-
* callFallbackApiStep(input),
|
|
20
|
-
* )
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
function race(...steps) {
|
|
24
|
-
if (!global[utils_1.OrchestrationUtils.SymbolAcmeKitWorkflowComposerContext]) {
|
|
25
|
-
throw new Error("race must be used inside a createWorkflow definition");
|
|
26
|
-
}
|
|
27
|
-
if (steps.length < 2) {
|
|
28
|
-
throw new Error("race requires at least 2 steps");
|
|
29
|
-
}
|
|
30
|
-
// Run all steps in parallel
|
|
31
|
-
const parallelResults = (0, parallelize_1.parallelize)(...steps);
|
|
32
|
-
// Pick the first defined result
|
|
33
|
-
const result = (0, transform_1.transform)({ results: parallelResults }, ({ results }) => {
|
|
34
|
-
for (const r of results) {
|
|
35
|
-
if (r !== undefined && r !== null) {
|
|
36
|
-
return r;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return results[0];
|
|
40
|
-
});
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=race.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"race.js","sourceRoot":"","sources":["../../../src/utils/composer/race.ts"],"names":[],"mappings":";;AAqBA,oBA4BC;AAjDD,0CAAmD;AACnD,+CAA2C;AAC3C,2CAAuC;AAGvC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,IAAI,CAClB,GAAG,KAA8B;IAEjC,IAAI,CAAC,MAAM,CAAC,0BAAkB,CAAC,oCAAoC,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;IACzE,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC;IAED,4BAA4B;IAC5B,MAAM,eAAe,GAAG,IAAA,yBAAW,EAAC,GAAG,KAAK,CAAC,CAAA;IAE7C,gCAAgC;IAChC,MAAM,MAAM,GAAG,IAAA,qBAAS,EACtB,EAAE,OAAO,EAAE,eAAe,EAAE,EAC5B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACd,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gBAClC,OAAO,CAAC,CAAA;YACV,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC,CACF,CAAA;IAED,OAAO,MAA+B,CAAA;AACxC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { WorkflowData } from "./type";
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for retry behavior at the composition level.
|
|
4
|
-
*/
|
|
5
|
-
export type RetryConfig = {
|
|
6
|
-
/**
|
|
7
|
-
* Maximum number of retry attempts.
|
|
8
|
-
*/
|
|
9
|
-
maxRetries: number;
|
|
10
|
-
/**
|
|
11
|
-
* Interval between retries in seconds.
|
|
12
|
-
*/
|
|
13
|
-
retryInterval?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Whether to automatically retry on temporary failure. Defaults to true.
|
|
16
|
-
*/
|
|
17
|
-
autoRetry?: boolean;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Override retry configuration for a step at the composition site,
|
|
21
|
-
* without modifying the step definition itself.
|
|
22
|
-
*
|
|
23
|
-
* Useful when the same step is used in multiple workflows with different retry requirements.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* import { retry } from "@acmekit/framework/workflows-sdk"
|
|
28
|
-
*
|
|
29
|
-
* const result = retry(sendEmailStep(input), {
|
|
30
|
-
* maxRetries: 3,
|
|
31
|
-
* retryInterval: 5,
|
|
32
|
-
* })
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function retry<TOutput>(stepResult: WorkflowData<TOutput>, config: RetryConfig): WorkflowData<TOutput>;
|
|
36
|
-
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAC3B,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,EACjC,MAAM,EAAE,WAAW,GAClB,YAAY,CAAC,OAAO,CAAC,CAMvB"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.retry = retry;
|
|
4
|
-
/**
|
|
5
|
-
* Override retry configuration for a step at the composition site,
|
|
6
|
-
* without modifying the step definition itself.
|
|
7
|
-
*
|
|
8
|
-
* Useful when the same step is used in multiple workflows with different retry requirements.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { retry } from "@acmekit/framework/workflows-sdk"
|
|
13
|
-
*
|
|
14
|
-
* const result = retry(sendEmailStep(input), {
|
|
15
|
-
* maxRetries: 3,
|
|
16
|
-
* retryInterval: 5,
|
|
17
|
-
* })
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
function retry(stepResult, config) {
|
|
21
|
-
return stepResult.config({
|
|
22
|
-
maxRetries: config.maxRetries,
|
|
23
|
-
retryInterval: config.retryInterval,
|
|
24
|
-
autoRetry: config.autoRetry,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=retry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/utils/composer/retry.ts"],"names":[],"mappings":";;AAsCA,sBASC;AAzBD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,KAAK,CACnB,UAAiC,EACjC,MAAmB;IAEnB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC,CAAA;AACJ,CAAC"}
|