@ronaldroe/micro-flow 0.0.9

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 (110) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +527 -0
  3. package/dist/index.js +2 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/src/classes/base.js +4 -0
  6. package/dist/src/classes/base.js.map +7 -0
  7. package/dist/src/classes/events/broadcast.js +2 -0
  8. package/dist/src/classes/events/broadcast.js.map +7 -0
  9. package/dist/src/classes/events/event.js +2 -0
  10. package/dist/src/classes/events/event.js.map +7 -0
  11. package/dist/src/classes/events/index.js +2 -0
  12. package/dist/src/classes/events/index.js.map +7 -0
  13. package/dist/src/classes/events/state_event.js +2 -0
  14. package/dist/src/classes/events/state_event.js.map +7 -0
  15. package/dist/src/classes/events/step_event.js +2 -0
  16. package/dist/src/classes/events/step_event.js.map +7 -0
  17. package/dist/src/classes/events/workflow_event.js +2 -0
  18. package/dist/src/classes/events/workflow_event.js.map +7 -0
  19. package/dist/src/classes/index.js +2 -0
  20. package/dist/src/classes/index.js.map +7 -0
  21. package/dist/src/classes/state.js +2 -0
  22. package/dist/src/classes/state.js.map +7 -0
  23. package/dist/src/classes/steps/case.js +2 -0
  24. package/dist/src/classes/steps/case.js.map +7 -0
  25. package/dist/src/classes/steps/conditional_step.js +2 -0
  26. package/dist/src/classes/steps/conditional_step.js.map +7 -0
  27. package/dist/src/classes/steps/delay_step.js +2 -0
  28. package/dist/src/classes/steps/delay_step.js.map +7 -0
  29. package/dist/src/classes/steps/flow_control_step.js +2 -0
  30. package/dist/src/classes/steps/flow_control_step.js.map +7 -0
  31. package/dist/src/classes/steps/index.js +2 -0
  32. package/dist/src/classes/steps/index.js.map +7 -0
  33. package/dist/src/classes/steps/logic_step.js +2 -0
  34. package/dist/src/classes/steps/logic_step.js.map +7 -0
  35. package/dist/src/classes/steps/loop_step.js +2 -0
  36. package/dist/src/classes/steps/loop_step.js.map +7 -0
  37. package/dist/src/classes/steps/step.js +2 -0
  38. package/dist/src/classes/steps/step.js.map +7 -0
  39. package/dist/src/classes/steps/switch_step.js +2 -0
  40. package/dist/src/classes/steps/switch_step.js.map +7 -0
  41. package/dist/src/classes/workflow.js +2 -0
  42. package/dist/src/classes/workflow.js.map +7 -0
  43. package/dist/src/classes/workflow.test.js +2 -0
  44. package/dist/src/classes/workflow.test.js.map +7 -0
  45. package/dist/src/enums/base_types.js +2 -0
  46. package/dist/src/enums/base_types.js.map +7 -0
  47. package/dist/src/enums/conditional_step_comparators.js +2 -0
  48. package/dist/src/enums/conditional_step_comparators.js.map +7 -0
  49. package/dist/src/enums/delay_types.js +2 -0
  50. package/dist/src/enums/delay_types.js.map +7 -0
  51. package/dist/src/enums/errors.js +6 -0
  52. package/dist/src/enums/errors.js.map +7 -0
  53. package/dist/src/enums/flow_control_types.js +2 -0
  54. package/dist/src/enums/flow_control_types.js.map +7 -0
  55. package/dist/src/enums/index.js +2 -0
  56. package/dist/src/enums/index.js.map +7 -0
  57. package/dist/src/enums/logic_step_types.js +2 -0
  58. package/dist/src/enums/logic_step_types.js.map +7 -0
  59. package/dist/src/enums/loop_types.js +2 -0
  60. package/dist/src/enums/loop_types.js.map +7 -0
  61. package/dist/src/enums/state_event_names.js +2 -0
  62. package/dist/src/enums/state_event_names.js.map +7 -0
  63. package/dist/src/enums/step_event_names.js +2 -0
  64. package/dist/src/enums/step_event_names.js.map +7 -0
  65. package/dist/src/enums/step_statuses.js +2 -0
  66. package/dist/src/enums/step_statuses.js.map +7 -0
  67. package/dist/src/enums/step_types.js +2 -0
  68. package/dist/src/enums/step_types.js.map +7 -0
  69. package/dist/src/enums/sub_step_types.js +2 -0
  70. package/dist/src/enums/sub_step_types.js.map +7 -0
  71. package/dist/src/enums/workflow_event_names.js +2 -0
  72. package/dist/src/enums/workflow_event_names.js.map +7 -0
  73. package/dist/src/enums/workflow_statuses.js +2 -0
  74. package/dist/src/enums/workflow_statuses.js.map +7 -0
  75. package/package.json +58 -0
  76. package/src/classes/base.js +143 -0
  77. package/src/classes/events/broadcast.js +57 -0
  78. package/src/classes/events/event.js +144 -0
  79. package/src/classes/events/index.js +5 -0
  80. package/src/classes/events/state_event.js +28 -0
  81. package/src/classes/events/step_event.js +28 -0
  82. package/src/classes/events/workflow_event.js +28 -0
  83. package/src/classes/index.js +5 -0
  84. package/src/classes/state.js +301 -0
  85. package/src/classes/steps/case.js +70 -0
  86. package/src/classes/steps/conditional_step.js +90 -0
  87. package/src/classes/steps/delay_step.js +103 -0
  88. package/src/classes/steps/flow_control_step.js +70 -0
  89. package/src/classes/steps/index.js +8 -0
  90. package/src/classes/steps/logic_step.js +148 -0
  91. package/src/classes/steps/loop_step.js +147 -0
  92. package/src/classes/steps/step.js +129 -0
  93. package/src/classes/steps/switch_step.js +64 -0
  94. package/src/classes/workflow.js +383 -0
  95. package/src/enums/base_types.js +6 -0
  96. package/src/enums/conditional_step_comparators.js +57 -0
  97. package/src/enums/delay_types.js +31 -0
  98. package/src/enums/errors.js +27 -0
  99. package/src/enums/flow_control_types.js +12 -0
  100. package/src/enums/index.js +14 -0
  101. package/src/enums/logic_step_types.js +16 -0
  102. package/src/enums/loop_types.js +14 -0
  103. package/src/enums/state_event_names.js +17 -0
  104. package/src/enums/step_event_names.js +25 -0
  105. package/src/enums/step_statuses.js +17 -0
  106. package/src/enums/step_types.js +15 -0
  107. package/src/enums/sub_step_types.js +20 -0
  108. package/src/enums/workflow_event_names.js +27 -0
  109. package/src/enums/workflow_statuses.js +21 -0
  110. package/src/index.js +2 -0
@@ -0,0 +1,383 @@
1
+ import { Base } from './index.js';
2
+ import { base_types } from '../enums/index.js';
3
+
4
+ /**
5
+ * Workflow class for managing and executing a sequence of steps.
6
+ * @class Workflow
7
+ * @extends Base
8
+ */
9
+ export default class Workflow extends Base {
10
+ /**
11
+ * Creates a new Workflow instance.
12
+ * @param {Object} options - Configuration options.
13
+ * @param {string} [options.name] - Name of the workflow.
14
+ * @param {boolean} [options.exit_on_error=false] - Whether to exit on error.
15
+ * @param {Array<Step>} [options.steps=[]] - Array of steps to add to the workflow.
16
+ * @param {boolean} [options.throw_on_empty=false] - Whether to throw error if workflow is empty.
17
+ */
18
+ constructor({
19
+ name,
20
+ exit_on_error = false,
21
+ steps = [],
22
+ throw_on_empty = false
23
+ }) {
24
+ super({ name, base_type: base_types.WORKFLOW });
25
+
26
+ this.initializeWorkflowState();
27
+
28
+ this.addSteps(steps);
29
+
30
+ this.exit_on_error = exit_on_error;
31
+ this.throw_on_empty = throw_on_empty;
32
+ }
33
+
34
+ /**
35
+ * Executes the workflow by running all steps in sequence.
36
+ * @async
37
+ * @returns {Promise<Workflow>} The workflow instance with execution results.
38
+ * @throws {Error} Throws if workflow is empty and throw_on_empty is true.
39
+ */
40
+ async execute() {
41
+ if (this.isEmpty()) {
42
+ if (this.throw_on_empty) {
43
+ throw new Error('Cannot execute an empty workflow');
44
+ }
45
+
46
+ this.markAsComplete();
47
+ this.prepareResult('Workflow is empty', null);
48
+ return this;
49
+ }
50
+
51
+ this.markAsRunning();
52
+
53
+ for (let i = 0; i < this._steps.length; i++) {
54
+ if (this.should_pause) {
55
+ this.markAsPaused();
56
+ this.should_pause = false;
57
+ return this;
58
+ }
59
+
60
+ if (this.should_break) {
61
+ this.should_break = false;
62
+ this.log(this.getState('event_names.workflow').WORKFLOW_BREAK_EXECUTED, `Workflow "${this.name}" execution broken at step ${this._steps[i].name} - ${this._steps[i].id}.`);
63
+ break;
64
+ }
65
+
66
+ if (this.should_skip) {
67
+ this.log(
68
+ this.getState('events.workflow.event_names.WORKFLOW_STEP_SKIPPED'),
69
+ `Workflow "${this.name}" skipping step ${this._steps[i].name} - ${this._steps[i].id}.`
70
+ );
71
+ this.should_skip = false;
72
+ continue;
73
+ }
74
+
75
+ this.current_step = this._steps[i].id;
76
+
77
+ try {
78
+ const step_result = await this.step();
79
+ this.prepareResult('Success', step_result);
80
+ } catch (error) {
81
+ this.markAsFailed();
82
+ this.prepareResult(`Workflow execution failed at step ${this.steps_by_id[this.current_step].name} - ${this.current_step}`, { error });
83
+
84
+ if (this.exit_on_error) {
85
+ return this;
86
+ }
87
+ }
88
+ }
89
+
90
+ this.markAsComplete();
91
+ return this;
92
+ }
93
+
94
+ /**
95
+ * Resumes a paused workflow.
96
+ * @async
97
+ * @returns {Promise<Workflow>} The workflow instance.
98
+ */
99
+ async resume() {
100
+ this.should_pause = false;
101
+ this.timing.resume_time = new Date();
102
+
103
+ this.getState('events.workflow').emit(
104
+ this.getState('event_names.workflow').WORKFLOW_RESUMED,
105
+ this.getState()
106
+ );
107
+ return this.execute();
108
+ }
109
+
110
+ /**
111
+ * Executes a single step in the workflow.
112
+ * @async
113
+ * @returns {Promise<*>} The result of the step execution.
114
+ */
115
+ async step() {
116
+ const step = this.steps_by_id[this.current_step];
117
+
118
+ step.parentWorkflowId = this.id;
119
+ const result = await step.execute();
120
+
121
+ if (step.status === this.getState('statuses.step.FAILED')) {
122
+ throw step.errors[step.errors.length - 1] ?? new Error(`Step "${step.name}" failed`);
123
+ }
124
+
125
+ return result;
126
+ }
127
+
128
+ /**
129
+ * Adds a step to the workflow.
130
+ * @param {Step} step - The step to add.
131
+ * @throws {Error} Throws if step is not a valid Step instance.
132
+ */
133
+ addStep(step) {
134
+ if (typeof step.getCallableType !== 'function') {
135
+ throw new Error('Invalid step type. Must be an instance of Step.');
136
+ }
137
+
138
+ if (!Array.isArray(this._steps)) {
139
+ this._steps = [];
140
+ }
141
+
142
+ if (!this.steps_by_id || typeof this.steps_by_id !== 'object') {
143
+ this.steps_by_id = {};
144
+ }
145
+
146
+ this.steps_by_id[step.id] = step;
147
+
148
+ step.parentWorkflowId = this.id;
149
+ this._steps.push(step);
150
+ }
151
+
152
+ /**
153
+ * Adds a step at a specific index in the workflow.
154
+ * @param {Step} step - The step to add.
155
+ * @param {number} index - The index at which to insert the step.
156
+ */
157
+ addStepAtIndex(step, index) {
158
+ step.parentWorkflowId = this.id;
159
+ this._steps.splice(index, 0, step);
160
+ }
161
+
162
+ /**
163
+ * Adds multiple steps to the workflow.
164
+ * @param {Step[]} steps - Array of steps to add.
165
+ */
166
+ addSteps(steps) {
167
+ steps.forEach(step => this.addStep(step));
168
+ }
169
+
170
+ /**
171
+ * Clears all steps from the workflow.
172
+ */
173
+ clearSteps() {
174
+ this._steps = [];
175
+ }
176
+
177
+ /**
178
+ * Deletes a step from the workflow by its ID.
179
+ * @param {string} stepId - The ID of the step to delete.
180
+ */
181
+ deleteStep(stepId) {
182
+ this._steps = this._steps.filter(step => step.id !== stepId);
183
+ }
184
+
185
+ /**
186
+ * Deletes a step from the workflow by its index.
187
+ * @param {number} index - The index of the step to delete.
188
+ */
189
+ deleteStepByIndex(index) {
190
+ this._steps.splice(index, 1);
191
+ }
192
+
193
+ /**
194
+ * Initializes the workflow state with default values.
195
+ */
196
+ initializeWorkflowState() {
197
+ this.results = [];
198
+ this.exit_on_error = false;
199
+ this.current_step = null;
200
+ this.should_break = false;
201
+ this.should_continue = false;
202
+ this.should_pause = false;
203
+ this.should_skip = false;
204
+ this.status = this.getState('statuses.workflow').CREATED;
205
+ this._steps = [];
206
+ this.throw_on_empty = this.throw_on_empty;
207
+ this.timing = {
208
+ ...this.timing,
209
+ create_time: new Date(),
210
+ pause_time: null,
211
+ resume_time: null,
212
+ }
213
+
214
+ const workflows = this.getState('workflows');
215
+ workflows[this.id] = this;
216
+ this.setState('workflows', workflows);
217
+
218
+ this.log(
219
+ this.getState('event_names.workflow').WORKFLOW_CREATED,
220
+ `Workflow "${this.name}" initialized.`
221
+ );
222
+ }
223
+
224
+ /**
225
+ * Checks if the workflow has no steps.
226
+ * @returns {boolean} True if the workflow is empty.
227
+ */
228
+ isEmpty() {
229
+ return !this._steps || !this._steps.length
230
+ }
231
+
232
+ /**
233
+ * Marks the workflow as created.
234
+ * @returns {string} The CREATED status.
235
+ */
236
+ markAsCreated() {
237
+ this.timing.create_time = new Date();
238
+
239
+ this.log(
240
+ this.getState('event_names.workflow').WORKFLOW_CREATED,
241
+ `Workflow "${this.name}" created.`
242
+ );
243
+
244
+ return this.getState('statuses.workflow').CREATED;
245
+ }
246
+
247
+ /**
248
+ * Marks the workflow as paused.
249
+ */
250
+ markAsPaused() {
251
+ this.timing.pause_time = new Date();
252
+ this.status = this.getState('statuses.workflow').PAUSED;
253
+
254
+ this.getState('events.workflow').emit(
255
+ this.getState('event_names.workflow').WORKFLOW_PAUSED,
256
+ this.getState()
257
+ );
258
+ }
259
+
260
+ /**
261
+ * Marks the workflow as resumed.
262
+ */
263
+ markAsResumed() {
264
+ this.timing.resume_time = new Date();
265
+ this.status = this.getState('statuses.workflow').RUNNING;
266
+
267
+ this.getState('events.workflow').emit(
268
+ this.getState('event_names.workflow').WORKFLOW_RESUMED,
269
+ this.getState()
270
+ );
271
+ }
272
+
273
+ /**
274
+ * Moves a step from one index to another.
275
+ * @param {number} fromIndex - The current index of the step.
276
+ * @param {number} toIndex - The target index for the step.
277
+ */
278
+ moveStep(fromIndex, toIndex) {
279
+ const [step] = this._steps.splice(fromIndex, 1);
280
+ this._steps.splice(toIndex, 0, step);
281
+
282
+ this.getState('events.workflow').emit(
283
+ this.getState('event_names.workflow').WORKFLOW_STEP_MOVED,
284
+ this.getState()
285
+ );
286
+ }
287
+
288
+ /**
289
+ * Pauses the workflow execution.
290
+ */
291
+ pause() {
292
+ this.should_pause = true;
293
+ this.timing.pause_time = new Date();
294
+
295
+ this.getState('events.workflow').emit(
296
+ this.getState('event_names.workflow').WORKFLOW_PAUSED,
297
+ this.getState()
298
+ );
299
+ }
300
+
301
+ /**
302
+ * Removes and returns the last step from the workflow.
303
+ * @returns {Step} The last step.
304
+ */
305
+ popStep() {
306
+ return this._steps.pop();
307
+ }
308
+
309
+ /**
310
+ * Prepares a result object and adds it to the results array.
311
+ * @param {string} message - Result message.
312
+ * @param {*} data - Result data.
313
+ */
314
+ prepareResult(message, data) {
315
+ this.results.push({ message, data });
316
+ }
317
+
318
+ /**
319
+ * Adds a step to the end of the workflow.
320
+ * @param {Step} step - The step to add.
321
+ */
322
+ pushStep(step) {
323
+ this.addStep(step);
324
+ }
325
+
326
+ /**
327
+ * Adds multiple steps to the end of the workflow.
328
+ * @param {Step[]} steps - Array of steps to add.
329
+ */
330
+ pushSteps(steps) {
331
+ steps.forEach(step => this.addStep(step));
332
+ }
333
+
334
+ /**
335
+ * Removes and returns the first step from the workflow.
336
+ * @returns {Step} The first step.
337
+ */
338
+ shiftStep() {
339
+ return this._steps.shift();
340
+ }
341
+
342
+ /**
343
+ * Adds a step to the beginning of the workflow.
344
+ * @param {Step} step - The step to add.
345
+ * @throws {Error} Throws if step is not a valid Step instance.
346
+ */
347
+ unshiftStep(step) {
348
+ if (typeof step.getCallableType !== 'function') {
349
+ throw new Error('Invalid step type. Must be an instance of Step.');
350
+ }
351
+
352
+ if (!this.steps_by_id || typeof this.steps_by_id !== 'object') {
353
+ this.steps_by_id = {};
354
+ }
355
+
356
+ this.steps_by_id[step.id] = step;
357
+
358
+ step.parentWorkflowId = this.id;
359
+ this._steps.unshift(step);
360
+ }
361
+
362
+ /**
363
+ * Gets the array of steps in the workflow.
364
+ * @returns {Step[]} Array of steps.
365
+ */
366
+ get steps() {
367
+ return this._steps;
368
+ }
369
+
370
+ /**
371
+ * Sets the steps array by adding multiple steps.
372
+ * @param {Step[]} steps - Array of steps to add.
373
+ */
374
+ set steps(steps) {
375
+ steps.forEach((step, index) => {
376
+ if (typeof step.getCallableType !== 'function') {
377
+ throw new Error(`Invalid step type. Step at index ${index} is not an instance of Step.`);
378
+ }
379
+ });
380
+
381
+ this.addSteps(steps);
382
+ }
383
+ }
@@ -0,0 +1,6 @@
1
+ const base_types = {
2
+ STEP: 'step',
3
+ WORKFLOW: 'workflow'
4
+ };
5
+
6
+ export default base_types;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Enumeration of comparison operators for conditional steps.
3
+ * Provides both named and symbolic operator formats.
4
+ *
5
+ * @enum {string}
6
+ * @readonly
7
+ */
8
+ const conditional_step_comparators = {
9
+ EQUALS: 'equals',
10
+ GREATER_THAN: 'greater_than',
11
+ GREATER_THAN_OR_EQUAL: 'greater_than_or_equal',
12
+ LESS_THAN: 'less_than',
13
+ LESS_THAN_OR_EQUAL: 'less_than_or_equal',
14
+ NOT_EQUALS: 'not_equals',
15
+ STRICT_EQUALS: 'strict_equals',
16
+ STRICT_NOT_EQUALS: 'strict_not_equals',
17
+
18
+ SIGN_EQUALS: '==',
19
+ SIGN_GREATER_THAN: '>',
20
+ SIGN_GREATER_THAN_OR_EQUAL: '>=',
21
+ SIGN_LESS_THAN: '<',
22
+ SIGN_LESS_THAN_OR_EQUAL: '<=',
23
+ SIGN_NOT_EQUALS: '!=',
24
+ SIGN_STRICT_EQUALS: '===',
25
+ SIGN_STRICT_NOT_EQUALS: '!==',
26
+
27
+ STRING_CONTAINS: 'string_contains',
28
+ STRING_INCLUDES: 'string_includes',
29
+ STRING_NOT_CONTAINS: 'string_not_contains',
30
+ STRING_NOT_INCLUDES: 'string_not_includes',
31
+ STRING_STARTS_WITH: 'string_starts_with',
32
+ STRING_ENDS_WITH: 'string_ends_with',
33
+
34
+ ARRAY_CONTAINS: 'array_contains',
35
+ ARRAY_INCLUDES: 'array_includes',
36
+ ARRAY_NOT_CONTAINS: 'array_not_contains',
37
+ ARRAY_NOT_INCLUDES: 'array_not_includes',
38
+
39
+ EMPTY: 'empty',
40
+ NOT_EMPTY: 'not_empty',
41
+
42
+ REGEX_MATCH: 'regex_match',
43
+ REGEX_NOT_MATCH: 'regex_not_match',
44
+
45
+ IN: 'in',
46
+ NOT_IN: 'not_in',
47
+
48
+ NULLISH: 'nullish',
49
+ NOT_NULLISH: 'not_nullish',
50
+
51
+ IS_TYPE: 'is_type',
52
+ IS_NOT_TYPE: 'is_not_type',
53
+
54
+ CUSTOM_FUNCTION: 'custom_function'
55
+ };
56
+
57
+ export default conditional_step_comparators;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Enumeration of delay types for DelayStep.
3
+ *
4
+ * @enum {string}
5
+ * @readonly
6
+ * @example
7
+ * import delay_types from 'micro-flow';
8
+ *
9
+ * const delayStep = new DelayStep({
10
+ * name: 'wait-5-seconds',
11
+ * delay_type: delay_types.RELATIVE,
12
+ * delay_duration: 5000
13
+ * });
14
+ */
15
+ const delay_types = {
16
+ /**
17
+ * Delay until a specific absolute timestamp or Date.
18
+ * Use with delay_timestamp property.
19
+ * @type {string}
20
+ */
21
+ ABSOLUTE: 'absolute',
22
+
23
+ /**
24
+ * Delay for a relative duration in milliseconds.
25
+ * Use with delay_duration property.
26
+ * @type {string}
27
+ */
28
+ RELATIVE: 'relative',
29
+ };
30
+
31
+ export default delay_types;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Error messages used in the micro-flow library.
3
+ *
4
+ * @enum {string}
5
+ * @readonly
6
+ */
7
+ const errors = {
8
+ INVALID_STATE_PATH: 'The provided state path is invalid.\n',
9
+ INVALID_CONDITIONAL: 'Conditional properties are required for LogicStep.',
10
+ OBJECT_NOT_PARSEABLE: 'The provided object could not be parsed.\n',
11
+ VALUE_NOT_ITERABLE: 'The provided value is not iterable.\n',
12
+ };
13
+
14
+ /**
15
+ * Warning messages used in the micro-flow library.
16
+ * These are typically logged to the console to alert developers of potential issues.
17
+ *
18
+ * @enum {string}
19
+ * @readonly
20
+ */
21
+ const warnings = {
22
+ DO_NOT_SET_STEPS_DIRECTLY: 'Using this.setState("steps", ...) is not recommended. ' +
23
+ 'State will not be initialized correctly. Use workflow methods to manage steps instead.',
24
+ BROADCAST_FAILED: 'Broadcast failed or is not supported in this environment. The error has more detail:\n',
25
+ };
26
+
27
+ export { errors, warnings };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Enumeration of flow control types for breaking or continuing execution.
3
+ *
4
+ * @enum {string}
5
+ * @readonly
6
+ */
7
+ const flow_control_types = {
8
+ BREAK: 'break',
9
+ SKIP: 'skip'
10
+ };
11
+
12
+ export default flow_control_types;
@@ -0,0 +1,14 @@
1
+ export { default as conditional_step_comparators } from './conditional_step_comparators.js';
2
+ export { default as delay_types } from './delay_types.js';
3
+ export * from './errors.js';
4
+ export { default as flow_control_types } from './flow_control_types.js';
5
+ export { default as logic_step_types } from './logic_step_types.js';
6
+ export { default as loop_types } from './loop_types.js';
7
+ export { default as state_event_names } from './state_event_names.js';
8
+ export { default as step_event_names } from './step_event_names.js';
9
+ export { default as step_statuses } from './step_statuses.js';
10
+ export { default as step_types } from './step_types.js';
11
+ export { default as sub_step_types } from './sub_step_types.js';
12
+ export { default as workflow_event_names } from './workflow_event_names.js';
13
+ export { default as workflow_statuses } from './workflow_statuses.js';
14
+ export { default as base_types } from './base_types.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Enumeration of logic step types for control flow operations.
3
+ * These types define different kinds of logic-based workflow steps.
4
+ *
5
+ * @enum {string}
6
+ * @readonly
7
+ */
8
+ const LogicStepTypes = {
9
+ CONDITIONAL: 'conditional',
10
+ LOOP: 'loop',
11
+ FLOW_CONTROL: 'flow_control',
12
+ SWITCH: 'switch',
13
+ SKIP: 'skip'
14
+ };
15
+
16
+ export default LogicStepTypes;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Enumeration of loop types for LoopStep.
3
+ *
4
+ * @enum {string}
5
+ * @readonly
6
+ */
7
+ const loop_types = {
8
+ FOR: 'for',
9
+ FOR_EACH: 'for_each',
10
+ GENERATOR: 'generator',
11
+ WHILE: 'while',
12
+ };
13
+
14
+ export default loop_types;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Enumeration of state event names.
3
+ */
4
+ const state_event_names = {
5
+ DELETED: 'deleted',
6
+ EACH: 'each',
7
+ FROZEN: 'frozen',
8
+ GET: 'get',
9
+ GET_FROM_PROPERTY_PATH: 'get_from_property_path',
10
+ GET_STATE: 'get_state',
11
+ MERGE: 'merge',
12
+ RESET: 'reset',
13
+ SET: 'set',
14
+ SET_TO_PROPERTY_PATH: 'set_to_property_path',
15
+ }
16
+
17
+ export default state_event_names;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Enumeration of step lifecycle event names.
3
+ * Steps emit these events during their execution lifecycle.
4
+ *
5
+ * @enum {string}
6
+ * @readonly
7
+ */
8
+ const step_event_names = {
9
+ CONDITIONAL_FALSE_BRANCH_EXECUTED: 'conditional_false_branch_executed',
10
+ CONDITIONAL_TRUE_BRANCH_EXECUTED: 'conditional_true_branch_executed',
11
+ DELAY_STEP_ABSOLUTE_SCHEDULED: 'delay_step_absolute_scheduled',
12
+ DELAY_STEP_RELATIVE_SCHEDULED: 'delay_step_relative_scheduled',
13
+ DELAY_STEP_ABSOLUTE_COMPLETE: 'delay_step_absolute_complete',
14
+ DELAY_STEP_RELATIVE_COMPLETE: 'delay_step_relative_complete',
15
+ LOOP_ITERATION_COMPLETE: 'loop_iteration_complete',
16
+ STEP_COMPLETE: 'step_complete',
17
+ STEP_FAILED: 'step_failed',
18
+ STEP_RUNNING: 'step_running',
19
+ STEP_PENDING: 'step_pending',
20
+ STEP_WAITING: 'step_waiting',
21
+ STEP_RETRYING: 'step_retrying',
22
+ SWITCH_CASE_MATCHED: 'switch_case_matched',
23
+ }
24
+
25
+ export default step_event_names;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Enumeration of possible step execution statuses.
3
+ * Steps transition through these statuses during their lifecycle.
4
+ *
5
+ * @enum {string}
6
+ * @readonly
7
+ */
8
+ const step_statuses = {
9
+ COMPLETE: 'complete',
10
+ FAILED: 'failed',
11
+ PENDING: 'pending',
12
+ QUEUED: 'queued',
13
+ RUNNING: 'running',
14
+ WAITING: 'waiting',
15
+ };
16
+
17
+ export default step_statuses;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Enumeration of step types used throughout the workflow system.
3
+ * These types categorize steps by their primary function.
4
+ *
5
+ * @enum {string}
6
+ * @readonly
7
+ */
8
+ const step_types = {
9
+ ACTION: 'action',
10
+ DELAY: 'delay',
11
+ LOGIC: 'logic',
12
+ LOOP: 'loop',
13
+ };
14
+
15
+ export default step_types;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Enumeration of sub-step types used in the workflow system.
3
+ * @type {Object.<string, string>}
4
+ * @readonly
5
+ * @example
6
+ * console.log(sub_step_types.Step); // "step"
7
+ * console.log(sub_step_types.ConditionalStep); // "conditional"
8
+ */
9
+ const sub_step_types = {
10
+ Step: 'step',
11
+ LogicStep: 'logic',
12
+ ConditionalStep: 'conditional',
13
+ FlowControlStep: 'flow_control',
14
+ LoopStep: 'loop',
15
+ SwitchStep: 'switch',
16
+ Case: 'case',
17
+ DelayStep: 'delay',
18
+ };
19
+
20
+ export default sub_step_types;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Enumeration of workflow lifecycle event names.
3
+ * Workflows emit these events during their creation and execution lifecycle.
4
+ *
5
+ * @enum {string}
6
+ * @readonly
7
+ */
8
+ const workflow_event_names = {
9
+ WORKFLOW_BREAK_EXECUTED: 'workflow_break_executed',
10
+ WORKFLOW_CANCELLED: 'workflow_cancelled',
11
+ WORKFLOW_COMPLETE: 'workflow_complete',
12
+ WORKFLOW_CREATED: 'workflow_created',
13
+ WORKFLOW_ERRORED: 'workflow_errored',
14
+ WORKFLOW_FAILED: 'workflow_failed',
15
+ WORKFLOW_PAUSED: 'workflow_paused',
16
+ WORKFLOW_RESUMED: 'workflow_resumed',
17
+ WORKFLOW_RUNNING: 'workflow_running',
18
+ WORKFLOW_STEP_ADDED: 'workflow_step_added',
19
+ WORKFLOW_STEP_MOVED: 'workflow_step_moved',
20
+ WORKFLOW_STEP_REMOVED: 'workflow_step_removed',
21
+ WORKFLOW_STEP_SHIFTED: 'workflow_step_shifted',
22
+ WORKFLOW_STEP_SKIPPED: 'workflow_step_skipped',
23
+ WORKFLOW_STEPS_ADDED: 'workflow_steps_added',
24
+ WORKFLOW_STEPS_CLEARED: 'workflow_steps_cleared',
25
+ }
26
+
27
+ export default workflow_event_names;