@acmekit/workflows-sdk 2.13.1

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 (82) hide show
  1. package/dist/acmekit-workflow.d.ts +3 -0
  2. package/dist/acmekit-workflow.d.ts.map +1 -0
  3. package/dist/acmekit-workflow.js +22 -0
  4. package/dist/acmekit-workflow.js.map +1 -0
  5. package/dist/helper/index.d.ts +3 -0
  6. package/dist/helper/index.d.ts.map +1 -0
  7. package/dist/helper/index.js +19 -0
  8. package/dist/helper/index.js.map +1 -0
  9. package/dist/helper/type.d.ts +71 -0
  10. package/dist/helper/type.d.ts.map +1 -0
  11. package/dist/helper/type.js +3 -0
  12. package/dist/helper/type.js.map +1 -0
  13. package/dist/helper/workflow-export.d.ts +6 -0
  14. package/dist/helper/workflow-export.d.ts.map +1 -0
  15. package/dist/helper/workflow-export.js +291 -0
  16. package/dist/helper/workflow-export.js.map +1 -0
  17. package/dist/index.d.ts +5 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +44 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/tsconfig.tsbuildinfo +1 -0
  22. package/dist/utils/_playground.d.ts +2 -0
  23. package/dist/utils/_playground.d.ts.map +1 -0
  24. package/dist/utils/_playground.js +40 -0
  25. package/dist/utils/_playground.js.map +1 -0
  26. package/dist/utils/composer/create-hook.d.ts +60 -0
  27. package/dist/utils/composer/create-hook.d.ts.map +1 -0
  28. package/dist/utils/composer/create-hook.js +97 -0
  29. package/dist/utils/composer/create-hook.js.map +1 -0
  30. package/dist/utils/composer/create-step.d.ts +134 -0
  31. package/dist/utils/composer/create-step.d.ts.map +1 -0
  32. package/dist/utils/composer/create-step.js +262 -0
  33. package/dist/utils/composer/create-step.js.map +1 -0
  34. package/dist/utils/composer/create-workflow.d.ts +71 -0
  35. package/dist/utils/composer/create-workflow.d.ts.map +1 -0
  36. package/dist/utils/composer/create-workflow.js +230 -0
  37. package/dist/utils/composer/create-workflow.js.map +1 -0
  38. package/dist/utils/composer/helpers/create-step-handler.d.ts +20 -0
  39. package/dist/utils/composer/helpers/create-step-handler.d.ts.map +1 -0
  40. package/dist/utils/composer/helpers/create-step-handler.js +95 -0
  41. package/dist/utils/composer/helpers/create-step-handler.js.map +1 -0
  42. package/dist/utils/composer/helpers/index.d.ts +3 -0
  43. package/dist/utils/composer/helpers/index.d.ts.map +1 -0
  44. package/dist/utils/composer/helpers/index.js +19 -0
  45. package/dist/utils/composer/helpers/index.js.map +1 -0
  46. package/dist/utils/composer/helpers/proxy.d.ts +3 -0
  47. package/dist/utils/composer/helpers/proxy.d.ts.map +1 -0
  48. package/dist/utils/composer/helpers/proxy.js +18 -0
  49. package/dist/utils/composer/helpers/proxy.js.map +1 -0
  50. package/dist/utils/composer/helpers/resolve-value.d.ts +8 -0
  51. package/dist/utils/composer/helpers/resolve-value.d.ts.map +1 -0
  52. package/dist/utils/composer/helpers/resolve-value.js +211 -0
  53. package/dist/utils/composer/helpers/resolve-value.js.map +1 -0
  54. package/dist/utils/composer/helpers/step-response.d.ts +126 -0
  55. package/dist/utils/composer/helpers/step-response.d.ts.map +1 -0
  56. package/dist/utils/composer/helpers/step-response.js +166 -0
  57. package/dist/utils/composer/helpers/step-response.js.map +1 -0
  58. package/dist/utils/composer/helpers/workflow-response.d.ts +20 -0
  59. package/dist/utils/composer/helpers/workflow-response.d.ts.map +1 -0
  60. package/dist/utils/composer/helpers/workflow-response.js +16 -0
  61. package/dist/utils/composer/helpers/workflow-response.js.map +1 -0
  62. package/dist/utils/composer/index.d.ts +11 -0
  63. package/dist/utils/composer/index.d.ts.map +1 -0
  64. package/dist/utils/composer/index.js +27 -0
  65. package/dist/utils/composer/index.js.map +1 -0
  66. package/dist/utils/composer/parallelize.d.ts +43 -0
  67. package/dist/utils/composer/parallelize.d.ts.map +1 -0
  68. package/dist/utils/composer/parallelize.js +57 -0
  69. package/dist/utils/composer/parallelize.js.map +1 -0
  70. package/dist/utils/composer/transform.d.ts +79 -0
  71. package/dist/utils/composer/transform.d.ts.map +1 -0
  72. package/dist/utils/composer/transform.js +47 -0
  73. package/dist/utils/composer/transform.js.map +1 -0
  74. package/dist/utils/composer/type.d.ts +243 -0
  75. package/dist/utils/composer/type.d.ts.map +1 -0
  76. package/dist/utils/composer/type.js +3 -0
  77. package/dist/utils/composer/type.js.map +1 -0
  78. package/dist/utils/composer/when.d.ts +58 -0
  79. package/dist/utils/composer/when.d.ts.map +1 -0
  80. package/dist/utils/composer/when.js +67 -0
  81. package/dist/utils/composer/when.js.map +1 -0
  82. package/package.json +45 -0
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transform = transform;
4
+ const utils_1 = require("@acmekit/utils");
5
+ const helpers_1 = require("./helpers");
6
+ const proxy_1 = require("./helpers/proxy");
7
+ function transform(values, ...functions) {
8
+ const uniqId = Math.random().toString(36).substring(2, 20);
9
+ const ret = {
10
+ __id: uniqId,
11
+ __type: utils_1.OrchestrationUtils.SymbolWorkflowStepTransformer,
12
+ };
13
+ const returnFn = async function (
14
+ // If a transformer is returned as the result of a workflow, then at this point the workflow is entirely done, in that case we have a TransactionContext
15
+ transactionContext) {
16
+ if ("transaction" in transactionContext) {
17
+ const temporaryDataKey = `${transactionContext.transaction.modelId}_${transactionContext.transaction.transactionId}_${uniqId}`;
18
+ ret.__temporary_storage_key ??= temporaryDataKey;
19
+ if (transactionContext.transaction.hasTemporaryData(ret.__temporary_storage_key)) {
20
+ return transactionContext.transaction.getTemporaryData(ret.__temporary_storage_key);
21
+ }
22
+ }
23
+ let stepValue = (0, helpers_1.resolveValue)(values, transactionContext);
24
+ if (stepValue instanceof Promise) {
25
+ stepValue = await stepValue;
26
+ }
27
+ let finalResult;
28
+ for (let i = 0; i < functions.length; i++) {
29
+ const fn = functions[i];
30
+ const arg = i === 0 ? stepValue : finalResult;
31
+ finalResult = fn.apply(fn, [arg, transactionContext]);
32
+ if (finalResult instanceof Promise) {
33
+ finalResult = await finalResult;
34
+ }
35
+ }
36
+ if ("transaction" in transactionContext) {
37
+ const temporaryDataKey = ret.__temporary_storage_key;
38
+ transactionContext.transaction.setTemporaryData(temporaryDataKey, finalResult);
39
+ }
40
+ return finalResult;
41
+ };
42
+ const proxyfiedRet = (0, proxy_1.proxify)(ret);
43
+ proxyfiedRet.__resolver = returnFn;
44
+ proxyfiedRet.__temporary_storage_key = null;
45
+ return proxyfiedRet;
46
+ }
47
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/utils/composer/transform.ts"],"names":[],"mappings":";;AAgKA,8BAoEC;AAhOD,0CAAmD;AACnD,uCAAwC;AACxC,2CAAyC;AA0JzC,SAAgB,SAAS,CACvB,MAAmB,EACnB,GAAG,SAAqB;IAExB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAE1D,MAAM,GAAG,GAAG;QACV,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,0BAAkB,CAAC,6BAA6B;KAKzD,CAAA;IAED,MAAM,QAAQ,GAAG,KAAK;IACpB,wJAAwJ;IACxJ,kBAAqE;QAErE,IAAI,aAAa,IAAI,kBAAkB,EAAE,CAAC;YACxC,MAAM,gBAAgB,GAAG,GAAG,kBAAkB,CAAC,WAAW,CAAC,OAAO,IAAI,kBAAkB,CAAC,WAAW,CAAC,aAAa,IAAI,MAAM,EAAE,CAAA;YAC9H,GAAG,CAAC,uBAAuB,KAAK,gBAAgB,CAAA;YAEhD,IACE,kBAAkB,CAAC,WAAW,CAAC,gBAAgB,CAC7C,GAAG,CAAC,uBAAuB,CAC5B,EACD,CAAC;gBACD,OAAO,kBAAkB,CAAC,WAAW,CAAC,gBAAgB,CACpD,GAAG,CAAC,uBAAuB,CAC5B,CAAA;YACH,CAAC;QACH,CAAC;QAED,IAAI,SAAS,GAAG,IAAA,sBAAY,EAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;QACxD,IAAI,SAAS,YAAY,OAAO,EAAE,CAAC;YACjC,SAAS,GAAG,MAAM,SAAS,CAAA;QAC7B,CAAC;QAED,IAAI,WAAW,CAAA;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;YACvB,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAA;YAE7C,WAAW,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAA;YACrD,IAAI,WAAW,YAAY,OAAO,EAAE,CAAC;gBACnC,WAAW,GAAG,MAAM,WAAW,CAAA;YACjC,CAAC;QACH,CAAC;QAED,IAAI,aAAa,IAAI,kBAAkB,EAAE,CAAC;YACxC,MAAM,gBAAgB,GAAG,GAAG,CAAC,uBAAwB,CAAA;YACrD,kBAAkB,CAAC,WAAW,CAAC,gBAAgB,CAC7C,gBAAgB,EAChB,WAAW,CACZ,CAAA;QACH,CAAC;QAED,OAAO,WAAW,CAAA;IACpB,CAAC,CAAA;IAED,MAAM,YAAY,GAAG,IAAA,eAAO,EAE1B,GAA8B,CAAC,CAAA;IACjC,YAAY,CAAC,UAAU,GAAG,QAAe,CAAA;IACzC,YAAY,CAAC,uBAAuB,GAAG,IAAqB,CAAA;IAE5D,OAAO,YAAY,CAAA;AACrB,CAAC"}
@@ -0,0 +1,243 @@
1
+ import { LocalWorkflow, OrchestratorBuilder, TransactionContext as OriginalWorkflowTransactionContext, TransactionModelOptions, TransactionPayload, TransactionStepsDefinition, WorkflowHandler } from "@acmekit/orchestration";
2
+ import { Context, LoadedModule, AcmeKitContainer } from "@acmekit/types";
3
+ import { ExportedWorkflow } from "../../helper";
4
+ import { Hook } from "./create-hook";
5
+ import { CompensateFn, InvokeFn } from "./create-step";
6
+ export type StepFunctionResult<TOutput extends unknown | unknown[] = unknown> = (this: CreateWorkflowComposerContext) => WorkflowData<TOutput>;
7
+ export type StepFunctionReturnConfig<TOutput> = {
8
+ config(config: {
9
+ name?: string;
10
+ } & Omit<TransactionStepsDefinition, "next" | "uuid" | "action">): WorkflowData<TOutput>;
11
+ };
12
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
13
+ export type HookHandler = (...args: any[]) => void | Promise<void>;
14
+ type ConvertHookToObject<THook> = THook extends Hook<infer Name, infer Input, infer Output> ? {
15
+ [K in Name]: <TCompensateInput>(invoke: InvokeFn<Input, Output, TCompensateInput>, compensate?: CompensateFn<TCompensateInput>) => void;
16
+ } : never;
17
+ /**
18
+ * Helper to convert an array of hooks to functions
19
+ */
20
+ type ConvertHooksToFunctions<THooks extends any[]> = THooks extends [
21
+ infer A,
22
+ ...infer R
23
+ ] ? ConvertHookToObject<A> & ConvertHooksToFunctions<R> : {};
24
+ export type Void = {
25
+ " $$type": "void";
26
+ };
27
+ /**
28
+ * A step function to be used in a workflow.
29
+ *
30
+ * @typeParam TInput - The type of the input of the step.
31
+ * @typeParam TOutput - The type of the output of the step.
32
+ */
33
+ export type StepFunction<TInput, TOutput = unknown> = (KeysOfUnion<TInput> extends [] ? {
34
+ (): TOutput & {} extends never ? WorkflowData<Void> & StepFunctionReturnConfig<TOutput> : WorkflowData<TOutput> & StepFunctionReturnConfig<TOutput>;
35
+ } : {
36
+ (input: WorkflowData<TInput> | TInput): WorkflowData<TOutput> & StepFunctionReturnConfig<TOutput>;
37
+ }) & WorkflowDataProperties<TOutput>;
38
+ export type WorkflowDataProperties<T = unknown> = {
39
+ __type: string;
40
+ __step__: string;
41
+ };
42
+ /**
43
+ * This type is used to encapsulate the input or output type of all utils.
44
+ *
45
+ * @typeParam T - The type of a step's input or result.
46
+ */
47
+ export type WorkflowData<T = unknown> = (T extends Array<infer Item> ? Array<Item | WorkflowData<Item>> : T extends object ? {
48
+ [Key in keyof T]: T[Key] | WorkflowData<T[Key]>;
49
+ } : T & WorkflowDataProperties<T>) & T & WorkflowDataProperties<T> & {
50
+ config(config: {
51
+ name?: string;
52
+ } & Omit<TransactionStepsDefinition, "next" | "uuid" | "action">): WorkflowData<T>;
53
+ };
54
+ export type CreateWorkflowComposerContext = {
55
+ __type: string;
56
+ hooks_: {
57
+ declared: string[];
58
+ registered: string[];
59
+ };
60
+ hooksCallback_: Record<string, HookHandler>;
61
+ workflowId: string;
62
+ flow: OrchestratorBuilder;
63
+ isAsync: boolean;
64
+ handlers: WorkflowHandler;
65
+ overriddenHandler: WorkflowHandler;
66
+ stepBinder: <TOutput = unknown>(fn: StepFunctionResult) => WorkflowData<TOutput>;
67
+ hookBinder: (name: string, fn: () => HookHandler) => void;
68
+ stepConditions_: Record<string, {
69
+ condition: (...args: any[]) => boolean | WorkflowData;
70
+ input: any;
71
+ }>;
72
+ parallelizeBinder: <TOutput extends (WorkflowData | undefined)[] = WorkflowData[]>(fn: (this: CreateWorkflowComposerContext) => TOutput) => TOutput;
73
+ };
74
+ /**
75
+ * The step's context.
76
+ */
77
+ export interface StepExecutionContext {
78
+ /**
79
+ * The ID of the workflow.
80
+ */
81
+ workflowId: string;
82
+ /**
83
+ * The attempt number of the step.
84
+ */
85
+ attempt: number;
86
+ /**
87
+ * The idempoency key of the step.
88
+ */
89
+ idempotencyKey: string;
90
+ /**
91
+ * The idempoency key of the parent step.
92
+ */
93
+ parentStepIdempotencyKey?: string;
94
+ /**
95
+ * Whether to prevent release events.
96
+ */
97
+ preventReleaseEvents?: boolean;
98
+ /**
99
+ * The name of the step.
100
+ */
101
+ stepName: string;
102
+ /**
103
+ * The action of the step.
104
+ */
105
+ action: "invoke" | "compensate";
106
+ /**
107
+ * The container used to access resources, such as services, in the step.
108
+ */
109
+ container: AcmeKitContainer;
110
+ /**
111
+ * Metadata passed in the input.
112
+ */
113
+ metadata: TransactionPayload["metadata"];
114
+ /**
115
+ * {@inheritDoc types!Context}
116
+ */
117
+ context: Context;
118
+ /**
119
+ * A string indicating the ID of the group to aggregate the events to be emitted at a later point.
120
+ */
121
+ eventGroupId?: string;
122
+ /**
123
+ * A string indicating the ID of the current transaction.
124
+ */
125
+ transactionId?: string;
126
+ /**
127
+ * A string indicating the ID of the current run.
128
+ */
129
+ runId?: string;
130
+ /**
131
+ * Get access to the result returned by a named step. Returns undefined
132
+ * when step is not found or when nothing was returned.
133
+ *
134
+ * Adding a space hides the method from the autocomplete
135
+ */
136
+ " getStepResult"(stepId: string, action?: "invoke" | "compensate"): any;
137
+ /**
138
+ * Get access to the definition of the step.
139
+ */
140
+ " stepDefinition": TransactionStepsDefinition;
141
+ }
142
+ export type WorkflowTransactionContext = StepExecutionContext & OriginalWorkflowTransactionContext & {
143
+ invoke: {
144
+ [key: string]: {
145
+ output: any;
146
+ };
147
+ };
148
+ };
149
+ /**
150
+ * An exported workflow, which is the type of a workflow constructed by the {@link createWorkflow} function. The exported workflow can be invoked to create
151
+ * an executable workflow, optionally within a specified container. So, to execute the workflow, you must invoke the exported workflow, then run the
152
+ * `run` method of the exported workflow.
153
+ *
154
+ * @example
155
+ * To execute a workflow:
156
+ *
157
+ * ```ts
158
+ * myWorkflow()
159
+ * .run({
160
+ * input: {
161
+ * name: "John"
162
+ * }
163
+ * })
164
+ * .then(({ result }) => {
165
+ * console.log(result)
166
+ * })
167
+ * ```
168
+ *
169
+ * To specify the container of the workflow, you can pass it as an argument to the call of the exported workflow. This is necessary when executing the workflow
170
+ * within a AcmeKit resource such as an API Route or a Subscriber.
171
+ *
172
+ * For example:
173
+ *
174
+ * ```ts
175
+ * import type {
176
+ * AcmeKitRequest,
177
+ * AcmeKitResponse
178
+ * } from "@acmekit/acmekit";
179
+ * import myWorkflow from "../../../workflows/hello-world";
180
+ *
181
+ * export async function GET(
182
+ * req: AcmeKitRequest,
183
+ * res: AcmeKitResponse
184
+ * ) {
185
+ * const { result } = await myWorkflow(req.scope)
186
+ * .run({
187
+ * input: {
188
+ * name: req.query.name as string
189
+ * }
190
+ * })
191
+ *
192
+ * res.send(result)
193
+ * }
194
+ * ```
195
+ */
196
+ export type ReturnWorkflow<TData, TResult, THooks extends any[]> = {
197
+ <TDataOverride = undefined, TResultOverride = undefined>(container?: LoadedModule[] | AcmeKitContainer): Omit<LocalWorkflow, "run" | "registerStepSuccess" | "registerStepFailure" | "cancel" | "retryStep"> & ExportedWorkflow<TData, TResult, TDataOverride, TResultOverride>;
198
+ } & {
199
+ /**
200
+ * This method executes the workflow as a step. Useful when running a workflow within another.
201
+ *
202
+ * Learn more in [this documentation](https://docs.acmekit.com/learn/fundamentals/workflows/execute-another-workflow).
203
+ *
204
+ * @param param0 - The options to execute the workflow.
205
+ * @returns The workflow's result
206
+ */
207
+ runAsStep: ({ input, }: {
208
+ /**
209
+ * The workflow's input.
210
+ */
211
+ input: TData | WorkflowData<TData>;
212
+ }) => ReturnType<StepFunction<TData, TResult>>;
213
+ /**
214
+ * This method executes a workflow.
215
+ *
216
+ * @param args - The options to execute the workflow.
217
+ * @returns Details of the workflow's execution, including its result.
218
+ */
219
+ run: <TDataOverride = undefined, TResultOverride = undefined>(...args: Parameters<ExportedWorkflow<TData, TResult, TDataOverride, TResultOverride>["run"]>) => ReturnType<ExportedWorkflow<TData, TResult, TDataOverride, TResultOverride>["run"]>;
220
+ /**
221
+ * This method retrieves the workflow's name.
222
+ */
223
+ getName: () => string;
224
+ /**
225
+ * This method sets the workflow's configurations.
226
+ */
227
+ config: (config: TransactionModelOptions) => void;
228
+ /**
229
+ * The workflow's exposed hooks, used to register a handler to consume the hook.
230
+ *
231
+ * Learn more in [this documentation](https://docs.acmekit.com/learn/fundamentals/workflows/workflow-hooks#how-to-consume-a-hook).
232
+ */
233
+ hooks: ConvertHooksToFunctions<THooks>;
234
+ };
235
+ /**
236
+ * Extract the raw type of the expected input data of a workflow.
237
+ *
238
+ * @example
239
+ * type WorkflowInputData = UnwrapWorkflowInputDataType<typeof myWorkflow>
240
+ */
241
+ export type UnwrapWorkflowInputDataType<T extends ReturnWorkflow<any, any, any>> = T extends ReturnWorkflow<infer TData, infer R, infer THooks> ? TData : never;
242
+ export {};
243
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/type.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,IAAI,kCAAkC,EACxD,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEtD,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,EAAE,GAAG,OAAO,IAC1E,CAAC,IAAI,EAAE,6BAA6B,KAAK,YAAY,CAAC,OAAO,CAAC,CAAA;AAEhE,MAAM,MAAM,wBAAwB,CAAC,OAAO,IAAI;IAC9C,MAAM,CACJ,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAC9B,0BAA0B,EAC1B,MAAM,GAAG,MAAM,GAAG,QAAQ,CAC3B,GACA,YAAY,CAAC,OAAO,CAAC,CAAA;CACzB,CAAA;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAA;AACnD,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE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AAE,uBAAuB,CAAC,MAAM,CAAC,CAAA;CACvC,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,CACrC,CAAC,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IACrC,CAAC,SAAS,cAAc,CAAC,MAAM,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,GAAG,KAAK,GAAG,KAAK,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/utils/composer/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ import { StepExecutionContext, WorkflowData } from "./type";
2
+ type ConditionFunction<T extends object | WorkflowData> = (input: T extends WorkflowData<infer U> ? U : T extends object ? {
3
+ [K in keyof T]: T[K] extends WorkflowData<infer U> ? U : T[K];
4
+ } : {}, context: StepExecutionContext) => boolean;
5
+ type ThenFunc = <ThenResolver extends () => any>(resolver: ThenResolver) => ReturnType<ThenResolver> extends WorkflowData<infer ReturnedWorkflowData> ? WorkflowData<ReturnedWorkflowData> | undefined : ReturnType<ThenResolver>;
6
+ /**
7
+ * This function allows you to execute steps only if a condition is satisfied. As you can't use if conditions in
8
+ * a workflow's constructor function, use `when-then` instead.
9
+ *
10
+ * Learn more about why you can't use if conditions and `when-then` in [this documentation](https://docs.acmekit.com/learn/fundamentals/workflows/conditions).
11
+ *
12
+ * @param values - The data to pass to the second parameter function.
13
+ * @param condition - A function that returns a boolean value, indicating whether the steps in `then` should be executed.
14
+ *
15
+ * @example
16
+ * import {
17
+ * createWorkflow,
18
+ * WorkflowResponse,
19
+ * when,
20
+ * } from "@acmekit/framework/workflows-sdk"
21
+ * // step imports...
22
+ *
23
+ * export const workflow = createWorkflow(
24
+ * "workflow",
25
+ * function (input: {
26
+ * is_active: boolean
27
+ * }) {
28
+ *
29
+ * const result = when(
30
+ * input,
31
+ * (input) => {
32
+ * return input.is_active
33
+ * }
34
+ * ).then(() => {
35
+ * const stepResult = isActiveStep()
36
+ * return stepResult
37
+ * })
38
+ *
39
+ * // executed without condition
40
+ * const anotherStepResult = anotherStep(result)
41
+ *
42
+ * return new WorkflowResponse(
43
+ * anotherStepResult
44
+ * )
45
+ * }
46
+ * )
47
+ */
48
+ export declare function when<T extends object | WorkflowData, Then extends Function>(values: T, condition: ConditionFunction<T>): {
49
+ then: ThenFunc;
50
+ };
51
+ /**
52
+ * @internal
53
+ */
54
+ export declare function when<T extends object | WorkflowData, Then extends Function>(name: string, values: T, condition: ConditionFunction<T>): {
55
+ then: ThenFunc;
56
+ };
57
+ export {};
58
+ //# sourceMappingURL=when.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../../src/utils/composer/when.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE3D,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,YAAY,IAAI,CACxD,KAAK,EAAE,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAClC,CAAC,GACD,CAAC,SAAS,MAAM,GAChB;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GACjE,EAAE,EACN,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAA;AAEZ,KAAK,QAAQ,GAAG,CAAC,YAAY,SAAS,MAAM,GAAG,EAC7C,QAAQ,EAAE,YAAY,KACnB,UAAU,CAAC,YAAY,CAAC,SAAS,YAAY,CAAC,MAAM,oBAAoB,CAAC,GAC1E,YAAY,CAAC,oBAAoB,CAAC,GAAG,SAAS,GAC9C,UAAU,CAAC,YAAY,CAAC,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,YAAY,EAAE,IAAI,SAAS,QAAQ,EACzE,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC9B;IACD,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,YAAY,EAAE,IAAI,SAAS,QAAQ,EACzE,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC9B;IACD,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.when = when;
4
+ const utils_1 = require("@acmekit/utils");
5
+ const ulid_1 = require("ulid");
6
+ const create_step_1 = require("./create-step");
7
+ const step_response_1 = require("./helpers/step-response");
8
+ /**
9
+ * @internal
10
+ */
11
+ function when(...args) {
12
+ let [name, input, condition] = args;
13
+ if (args.length === 2) {
14
+ condition = input;
15
+ input = name;
16
+ name = undefined;
17
+ }
18
+ if (typeof condition !== "function") {
19
+ throw new Error(`"when condition" must be a function`);
20
+ }
21
+ global[utils_1.OrchestrationUtils.SymbolAcmeKitWorkflowComposerCondition] = {
22
+ input,
23
+ condition,
24
+ steps: [],
25
+ };
26
+ let thenCalled = false;
27
+ process.nextTick(() => {
28
+ if (!thenCalled) {
29
+ throw new Error(`".then" is missing after "when" condition`);
30
+ }
31
+ });
32
+ return {
33
+ then: (fn) => {
34
+ thenCalled = true;
35
+ const ret = fn();
36
+ let returnStep = ret;
37
+ const applyCondition = global[utils_1.OrchestrationUtils.SymbolAcmeKitWorkflowComposerCondition].steps;
38
+ if ((0, utils_1.isDefined)(ret) &&
39
+ ret?.__type !== utils_1.OrchestrationUtils.SymbolWorkflowStep) {
40
+ if (!(0, utils_1.isDefined)(name)) {
41
+ name = "when-then-" + (0, ulid_1.ulid)();
42
+ const context = global[utils_1.OrchestrationUtils.SymbolAcmeKitWorkflowComposerContext];
43
+ console.warn(`${context.workflowId}: "when" name should be defined. A random one will be assigned to it, which is not recommended for production.\n`, condition.toString());
44
+ }
45
+ const retStep = (0, create_step_1.createStep)(name, ({ input }) => new step_response_1.StepResponse(input));
46
+ /**
47
+ * object ret = { result, hooks }
48
+ */
49
+ if ((0, utils_1.isObject)(ret) && "hooks" in ret && "result" in ret) {
50
+ returnStep = {
51
+ hooks: ret.hooks,
52
+ result: retStep({ input: ret.result }),
53
+ };
54
+ }
55
+ else {
56
+ returnStep = retStep({ input: ret });
57
+ }
58
+ }
59
+ for (const step of applyCondition) {
60
+ step.if(input, condition);
61
+ }
62
+ delete global[utils_1.OrchestrationUtils.SymbolAcmeKitWorkflowComposerCondition];
63
+ return returnStep;
64
+ },
65
+ };
66
+ }
67
+ //# sourceMappingURL=when.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when.js","sourceRoot":"","sources":["../../../src/utils/composer/when.ts"],"names":[],"mappings":";;AAoFA,oBA4EC;AAhKD,0CAAwE;AACxE,+BAA2B;AAC3B,+CAA0C;AAC1C,2DAAsD;AA8EtD;;GAEG;AACH,SAAgB,IAAI,CAAC,GAAG,IAAI;IAC1B,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI,CAAA;IACnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,SAAS,GAAG,KAAK,CAAA;QACjB,KAAK,GAAG,IAAI,CAAA;QACZ,IAAI,GAAG,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IACxD,CAAC;IAED,MAAM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AU,GAAG;wBACX,KAAK,EAAE,GAAG,CAAC,KAAK;wBAChB,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;qBACvC,CAAA;gBACH,CAAC;qBAAM,CAAC;oBACN,UAAU,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;gBACtC,CAAC;YACH,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;gBAClC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;YAC3B,CAAC;YAED,OAAO,MAAM,CAAC,0BAAkB,CAAC,sCAAsC,CAAC,CAAA;YAExE,OAAO,UAAU,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@acmekit/workflows-sdk",
3
+ "version": "2.13.1",
4
+ "description": "Set of workflows tooling for AcmeKit",
5
+ "main": "dist/index.js",
6
+ "exports": {
7
+ ".": "./dist/index.js",
8
+ "./composer": "./dist/utils/composer/index.js"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/acmekit/acmekit",
13
+ "directory": "packages/core/workflows-sdk"
14
+ },
15
+ "engines": {
16
+ "node": ">=20.0.0"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "!dist/**/__tests__",
24
+ "!dist/**/__mocks__",
25
+ "!dist/**/__fixtures__"
26
+ ],
27
+ "author": "AcmeKit",
28
+ "license": "MIT",
29
+ "devDependencies": {
30
+ "@acmekit/types": "2.13.1"
31
+ },
32
+ "dependencies": {
33
+ "@acmekit/deps": "2.13.1",
34
+ "@acmekit/modules-sdk": "2.13.1",
35
+ "@acmekit/orchestration": "2.13.1",
36
+ "@acmekit/utils": "2.13.1",
37
+ "ulid": "^2.3.0"
38
+ },
39
+ "scripts": {
40
+ "build": "yarn run -T rimraf dist && yarn run -T tsc --build",
41
+ "watch": "yarn run -T tsc --build --watch",
42
+ "test": "../../../node_modules/.bin/jest --bail --forceExit --testPathPattern=src",
43
+ "test:run": "node ./dist/utils/_playground.js"
44
+ }
45
+ }