@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.
- package/LICENSE +7 -0
- package/README.md +527 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/src/classes/base.js +4 -0
- package/dist/src/classes/base.js.map +7 -0
- package/dist/src/classes/events/broadcast.js +2 -0
- package/dist/src/classes/events/broadcast.js.map +7 -0
- package/dist/src/classes/events/event.js +2 -0
- package/dist/src/classes/events/event.js.map +7 -0
- package/dist/src/classes/events/index.js +2 -0
- package/dist/src/classes/events/index.js.map +7 -0
- package/dist/src/classes/events/state_event.js +2 -0
- package/dist/src/classes/events/state_event.js.map +7 -0
- package/dist/src/classes/events/step_event.js +2 -0
- package/dist/src/classes/events/step_event.js.map +7 -0
- package/dist/src/classes/events/workflow_event.js +2 -0
- package/dist/src/classes/events/workflow_event.js.map +7 -0
- package/dist/src/classes/index.js +2 -0
- package/dist/src/classes/index.js.map +7 -0
- package/dist/src/classes/state.js +2 -0
- package/dist/src/classes/state.js.map +7 -0
- package/dist/src/classes/steps/case.js +2 -0
- package/dist/src/classes/steps/case.js.map +7 -0
- package/dist/src/classes/steps/conditional_step.js +2 -0
- package/dist/src/classes/steps/conditional_step.js.map +7 -0
- package/dist/src/classes/steps/delay_step.js +2 -0
- package/dist/src/classes/steps/delay_step.js.map +7 -0
- package/dist/src/classes/steps/flow_control_step.js +2 -0
- package/dist/src/classes/steps/flow_control_step.js.map +7 -0
- package/dist/src/classes/steps/index.js +2 -0
- package/dist/src/classes/steps/index.js.map +7 -0
- package/dist/src/classes/steps/logic_step.js +2 -0
- package/dist/src/classes/steps/logic_step.js.map +7 -0
- package/dist/src/classes/steps/loop_step.js +2 -0
- package/dist/src/classes/steps/loop_step.js.map +7 -0
- package/dist/src/classes/steps/step.js +2 -0
- package/dist/src/classes/steps/step.js.map +7 -0
- package/dist/src/classes/steps/switch_step.js +2 -0
- package/dist/src/classes/steps/switch_step.js.map +7 -0
- package/dist/src/classes/workflow.js +2 -0
- package/dist/src/classes/workflow.js.map +7 -0
- package/dist/src/classes/workflow.test.js +2 -0
- package/dist/src/classes/workflow.test.js.map +7 -0
- package/dist/src/enums/base_types.js +2 -0
- package/dist/src/enums/base_types.js.map +7 -0
- package/dist/src/enums/conditional_step_comparators.js +2 -0
- package/dist/src/enums/conditional_step_comparators.js.map +7 -0
- package/dist/src/enums/delay_types.js +2 -0
- package/dist/src/enums/delay_types.js.map +7 -0
- package/dist/src/enums/errors.js +6 -0
- package/dist/src/enums/errors.js.map +7 -0
- package/dist/src/enums/flow_control_types.js +2 -0
- package/dist/src/enums/flow_control_types.js.map +7 -0
- package/dist/src/enums/index.js +2 -0
- package/dist/src/enums/index.js.map +7 -0
- package/dist/src/enums/logic_step_types.js +2 -0
- package/dist/src/enums/logic_step_types.js.map +7 -0
- package/dist/src/enums/loop_types.js +2 -0
- package/dist/src/enums/loop_types.js.map +7 -0
- package/dist/src/enums/state_event_names.js +2 -0
- package/dist/src/enums/state_event_names.js.map +7 -0
- package/dist/src/enums/step_event_names.js +2 -0
- package/dist/src/enums/step_event_names.js.map +7 -0
- package/dist/src/enums/step_statuses.js +2 -0
- package/dist/src/enums/step_statuses.js.map +7 -0
- package/dist/src/enums/step_types.js +2 -0
- package/dist/src/enums/step_types.js.map +7 -0
- package/dist/src/enums/sub_step_types.js +2 -0
- package/dist/src/enums/sub_step_types.js.map +7 -0
- package/dist/src/enums/workflow_event_names.js +2 -0
- package/dist/src/enums/workflow_event_names.js.map +7 -0
- package/dist/src/enums/workflow_statuses.js +2 -0
- package/dist/src/enums/workflow_statuses.js.map +7 -0
- package/package.json +58 -0
- package/src/classes/base.js +143 -0
- package/src/classes/events/broadcast.js +57 -0
- package/src/classes/events/event.js +144 -0
- package/src/classes/events/index.js +5 -0
- package/src/classes/events/state_event.js +28 -0
- package/src/classes/events/step_event.js +28 -0
- package/src/classes/events/workflow_event.js +28 -0
- package/src/classes/index.js +5 -0
- package/src/classes/state.js +301 -0
- package/src/classes/steps/case.js +70 -0
- package/src/classes/steps/conditional_step.js +90 -0
- package/src/classes/steps/delay_step.js +103 -0
- package/src/classes/steps/flow_control_step.js +70 -0
- package/src/classes/steps/index.js +8 -0
- package/src/classes/steps/logic_step.js +148 -0
- package/src/classes/steps/loop_step.js +147 -0
- package/src/classes/steps/step.js +129 -0
- package/src/classes/steps/switch_step.js +64 -0
- package/src/classes/workflow.js +383 -0
- package/src/enums/base_types.js +6 -0
- package/src/enums/conditional_step_comparators.js +57 -0
- package/src/enums/delay_types.js +31 -0
- package/src/enums/errors.js +27 -0
- package/src/enums/flow_control_types.js +12 -0
- package/src/enums/index.js +14 -0
- package/src/enums/logic_step_types.js +16 -0
- package/src/enums/loop_types.js +14 -0
- package/src/enums/state_event_names.js +17 -0
- package/src/enums/step_event_names.js +25 -0
- package/src/enums/step_statuses.js +17 -0
- package/src/enums/step_types.js +15 -0
- package/src/enums/sub_step_types.js +20 -0
- package/src/enums/workflow_event_names.js +27 -0
- package/src/enums/workflow_statuses.js +21 -0
- package/src/index.js +2 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const e={INVALID_STATE_PATH:`The provided state path is invalid.
|
|
2
|
+
`,INVALID_CONDITIONAL:"Conditional properties are required for LogicStep.",OBJECT_NOT_PARSEABLE:`The provided object could not be parsed.
|
|
3
|
+
`,VALUE_NOT_ITERABLE:`The provided value is not iterable.
|
|
4
|
+
`},t={DO_NOT_SET_STEPS_DIRECTLY:'Using this.setState("steps", ...) is not recommended. State will not be initialized correctly. Use workflow methods to manage steps instead.',BROADCAST_FAILED:`Broadcast failed or is not supported in this environment. The error has more detail:
|
|
5
|
+
`};export{e as errors,t as warnings};
|
|
6
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/errors.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Error messages used in the micro-flow library.\n * \n * @enum {string}\n * @readonly\n */\nconst errors = {\n INVALID_STATE_PATH: 'The provided state path is invalid.\\n',\n INVALID_CONDITIONAL: 'Conditional properties are required for LogicStep.',\n OBJECT_NOT_PARSEABLE: 'The provided object could not be parsed.\\n',\n VALUE_NOT_ITERABLE: 'The provided value is not iterable.\\n',\n};\n\n/**\n * Warning messages used in the micro-flow library.\n * These are typically logged to the console to alert developers of potential issues.\n * \n * @enum {string}\n * @readonly\n */\nconst warnings = {\n DO_NOT_SET_STEPS_DIRECTLY: 'Using this.setState(\"steps\", ...) is not recommended. ' +\n 'State will not be initialized correctly. Use workflow methods to manage steps instead.',\n BROADCAST_FAILED: 'Broadcast failed or is not supported in this environment. The error has more detail:\\n',\n};\n\nexport { errors, warnings };\n"],
|
|
5
|
+
"mappings": "AAMA,MAAMA,EAAS,CACb,mBAAoB;AAAA,EACpB,oBAAqB,qDACrB,qBAAsB;AAAA,EACtB,mBAAoB;AAAA,CACtB,EASMC,EAAW,CACf,0BAA2B,+IAE3B,iBAAkB;AAAA,CACpB",
|
|
6
|
+
"names": ["errors", "warnings"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/flow_control_types.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of flow control types for breaking or continuing execution.\n * \n * @enum {string}\n * @readonly\n */\nconst flow_control_types = {\n BREAK: 'break',\n SKIP: 'skip'\n};\n\nexport default flow_control_types;\n"],
|
|
5
|
+
"mappings": "AAMA,MAAMA,EAAqB,CACzB,MAAO,QACP,KAAM,MACR,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["flow_control_types", "flow_control_types_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{default as o}from"./conditional_step_comparators.js";import{default as a}from"./delay_types.js";export*from"./errors.js";import{default as p}from"./flow_control_types.js";import{default as _}from"./logic_step_types.js";import{default as u}from"./loop_types.js";import{default as x}from"./state_event_names.js";import{default as y}from"./step_event_names.js";import{default as c}from"./step_statuses.js";import{default as v}from"./step_types.js";import{default as k}from"./sub_step_types.js";import{default as h}from"./workflow_event_names.js";import{default as q}from"./workflow_statuses.js";import{default as A}from"./base_types.js";export{A as base_types,o as conditional_step_comparators,a as delay_types,p as flow_control_types,_ as logic_step_types,u as loop_types,x as state_event_names,y as step_event_names,c as step_statuses,v as step_types,k as sub_step_types,h as workflow_event_names,q as workflow_statuses};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default as conditional_step_comparators } from './conditional_step_comparators.js';\nexport { default as delay_types } from './delay_types.js';\nexport * from './errors.js';\nexport { default as flow_control_types } from './flow_control_types.js';\nexport { default as logic_step_types } from './logic_step_types.js';\nexport { default as loop_types } from './loop_types.js';\nexport { default as state_event_names } from './state_event_names.js';\nexport { default as step_event_names } from './step_event_names.js';\nexport { default as step_statuses } from './step_statuses.js';\nexport { default as step_types } from './step_types.js';\nexport { default as sub_step_types } from './sub_step_types.js';\nexport { default as workflow_event_names } from './workflow_event_names.js';\nexport { default as workflow_statuses } from './workflow_statuses.js';\nexport { default as base_types } from './base_types.js';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAoB,WAAXA,MAA+C,oCACxD,OAAoB,WAAXA,MAA8B,mBACvC,WAAc,cACd,OAAoB,WAAXA,MAAqC,0BAC9C,OAAoB,WAAXA,MAAmC,wBAC5C,OAAoB,WAAXA,MAA6B,kBACtC,OAAoB,WAAXA,MAAoC,yBAC7C,OAAoB,WAAXA,MAAmC,wBAC5C,OAAoB,WAAXA,MAAgC,qBACzC,OAAoB,WAAXA,MAA6B,kBACtC,OAAoB,WAAXA,MAAiC,sBAC1C,OAAoB,WAAXA,MAAuC,4BAChD,OAAoB,WAAXA,MAAoC,yBAC7C,OAAoB,WAAXA,MAA6B",
|
|
6
|
+
"names": ["default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/logic_step_types.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of logic step types for control flow operations.\n * These types define different kinds of logic-based workflow steps.\n * \n * @enum {string}\n * @readonly\n */\nconst LogicStepTypes = {\n CONDITIONAL: 'conditional',\n LOOP: 'loop',\n FLOW_CONTROL: 'flow_control',\n SWITCH: 'switch',\n SKIP: 'skip'\n};\n\nexport default LogicStepTypes;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAAiB,CACrB,YAAa,cACb,KAAM,OACN,aAAc,eACd,OAAQ,SACR,KAAM,MACR,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["LogicStepTypes", "logic_step_types_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/loop_types.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of loop types for LoopStep.\n * \n * @enum {string}\n * @readonly\n */\nconst loop_types = {\n FOR: 'for',\n FOR_EACH: 'for_each',\n GENERATOR: 'generator',\n WHILE: 'while',\n};\n\nexport default loop_types;\n"],
|
|
5
|
+
"mappings": "AAMA,MAAMA,EAAa,CACjB,IAAK,MACL,SAAU,WACV,UAAW,YACX,MAAO,OACT,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["loop_types", "loop_types_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={DELETED:"deleted",EACH:"each",FROZEN:"frozen",GET:"get",GET_FROM_PROPERTY_PATH:"get_from_property_path",GET_STATE:"get_state",MERGE:"merge",RESET:"reset",SET:"set",SET_TO_PROPERTY_PATH:"set_to_property_path"};var t=e;export{t as default};
|
|
2
|
+
//# sourceMappingURL=state_event_names.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/state_event_names.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of state event names.\n */\nconst state_event_names = {\n DELETED: 'deleted',\n EACH: 'each',\n FROZEN: 'frozen',\n GET: 'get',\n GET_FROM_PROPERTY_PATH: 'get_from_property_path',\n GET_STATE: 'get_state',\n MERGE: 'merge',\n RESET: 'reset',\n SET: 'set',\n SET_TO_PROPERTY_PATH: 'set_to_property_path',\n}\n\nexport default state_event_names;\n"],
|
|
5
|
+
"mappings": "AAGA,MAAMA,EAAoB,CACxB,QAAS,UACT,KAAM,OACN,OAAQ,SACR,IAAK,MACL,uBAAwB,yBACxB,UAAW,YACX,MAAO,QACP,MAAO,QACP,IAAK,MACL,qBAAsB,sBACxB,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["state_event_names", "state_event_names_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const _={CONDITIONAL_FALSE_BRANCH_EXECUTED:"conditional_false_branch_executed",CONDITIONAL_TRUE_BRANCH_EXECUTED:"conditional_true_branch_executed",DELAY_STEP_ABSOLUTE_SCHEDULED:"delay_step_absolute_scheduled",DELAY_STEP_RELATIVE_SCHEDULED:"delay_step_relative_scheduled",DELAY_STEP_ABSOLUTE_COMPLETE:"delay_step_absolute_complete",DELAY_STEP_RELATIVE_COMPLETE:"delay_step_relative_complete",LOOP_ITERATION_COMPLETE:"loop_iteration_complete",STEP_COMPLETE:"step_complete",STEP_FAILED:"step_failed",STEP_RUNNING:"step_running",STEP_PENDING:"step_pending",STEP_WAITING:"step_waiting",STEP_RETRYING:"step_retrying",SWITCH_CASE_MATCHED:"switch_case_matched"};var e=_;export{e as default};
|
|
2
|
+
//# sourceMappingURL=step_event_names.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/step_event_names.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of step lifecycle event names.\n * Steps emit these events during their execution lifecycle.\n * \n * @enum {string}\n * @readonly\n */\nconst step_event_names = {\n CONDITIONAL_FALSE_BRANCH_EXECUTED: 'conditional_false_branch_executed',\n CONDITIONAL_TRUE_BRANCH_EXECUTED: 'conditional_true_branch_executed',\n DELAY_STEP_ABSOLUTE_SCHEDULED: 'delay_step_absolute_scheduled',\n DELAY_STEP_RELATIVE_SCHEDULED: 'delay_step_relative_scheduled',\n DELAY_STEP_ABSOLUTE_COMPLETE: 'delay_step_absolute_complete',\n DELAY_STEP_RELATIVE_COMPLETE: 'delay_step_relative_complete',\n LOOP_ITERATION_COMPLETE: 'loop_iteration_complete',\n STEP_COMPLETE: 'step_complete',\n STEP_FAILED: 'step_failed',\n STEP_RUNNING: 'step_running',\n STEP_PENDING: 'step_pending',\n STEP_WAITING: 'step_waiting',\n STEP_RETRYING: 'step_retrying',\n SWITCH_CASE_MATCHED: 'switch_case_matched',\n}\n\nexport default step_event_names;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAAmB,CACvB,kCAAmC,oCACnC,iCAAkC,mCAClC,8BAA+B,gCAC/B,8BAA+B,gCAC/B,6BAA8B,+BAC9B,6BAA8B,+BAC9B,wBAAyB,0BACzB,cAAe,gBACf,YAAa,cACb,aAAc,eACd,aAAc,eACd,aAAc,eACd,cAAe,gBACf,oBAAqB,qBACvB,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["step_event_names", "step_event_names_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/step_statuses.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of possible step execution statuses.\n * Steps transition through these statuses during their lifecycle.\n * \n * @enum {string}\n * @readonly\n */\nconst step_statuses = {\n COMPLETE: 'complete',\n FAILED: 'failed',\n PENDING: 'pending',\n QUEUED: 'queued',\n RUNNING: 'running',\n WAITING: 'waiting',\n};\n\nexport default step_statuses;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAAgB,CACpB,SAAU,WACV,OAAQ,SACR,QAAS,UACT,OAAQ,SACR,QAAS,UACT,QAAS,SACX,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["step_statuses", "step_statuses_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/step_types.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of step types used throughout the workflow system.\n * These types categorize steps by their primary function.\n * \n * @enum {string}\n * @readonly\n */\nconst step_types = {\n ACTION: 'action',\n DELAY: 'delay',\n LOGIC: 'logic',\n LOOP: 'loop',\n};\n\nexport default step_types;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAAa,CACjB,OAAQ,SACR,MAAO,QACP,MAAO,QACP,KAAM,MACR,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["step_types", "step_types_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/sub_step_types.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of sub-step types used in the workflow system.\n * @type {Object.<string, string>}\n * @readonly\n * @example\n * console.log(sub_step_types.Step); // \"step\"\n * console.log(sub_step_types.ConditionalStep); // \"conditional\"\n */\nconst sub_step_types = {\n Step: 'step',\n LogicStep: 'logic',\n ConditionalStep: 'conditional',\n FlowControlStep: 'flow_control',\n LoopStep: 'loop',\n SwitchStep: 'switch',\n Case: 'case',\n DelayStep: 'delay',\n};\n\nexport default sub_step_types;\n"],
|
|
5
|
+
"mappings": "AAQA,MAAMA,EAAiB,CACrB,KAAM,OACN,UAAW,QACX,gBAAiB,cACjB,gBAAiB,eACjB,SAAU,OACV,WAAY,SACZ,KAAM,OACN,UAAW,OACb,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["sub_step_types", "sub_step_types_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const _={WORKFLOW_BREAK_EXECUTED:"workflow_break_executed",WORKFLOW_CANCELLED:"workflow_cancelled",WORKFLOW_COMPLETE:"workflow_complete",WORKFLOW_CREATED:"workflow_created",WORKFLOW_ERRORED:"workflow_errored",WORKFLOW_FAILED:"workflow_failed",WORKFLOW_PAUSED:"workflow_paused",WORKFLOW_RESUMED:"workflow_resumed",WORKFLOW_RUNNING:"workflow_running",WORKFLOW_STEP_ADDED:"workflow_step_added",WORKFLOW_STEP_MOVED:"workflow_step_moved",WORKFLOW_STEP_REMOVED:"workflow_step_removed",WORKFLOW_STEP_SHIFTED:"workflow_step_shifted",WORKFLOW_STEP_SKIPPED:"workflow_step_skipped",WORKFLOW_STEPS_ADDED:"workflow_steps_added",WORKFLOW_STEPS_CLEARED:"workflow_steps_cleared"};var o=_;export{o as default};
|
|
2
|
+
//# sourceMappingURL=workflow_event_names.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/workflow_event_names.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of workflow lifecycle event names.\n * Workflows emit these events during their creation and execution lifecycle.\n * \n * @enum {string}\n * @readonly\n */\nconst workflow_event_names = {\n WORKFLOW_BREAK_EXECUTED: 'workflow_break_executed',\n WORKFLOW_CANCELLED: 'workflow_cancelled',\n WORKFLOW_COMPLETE: 'workflow_complete',\n WORKFLOW_CREATED: 'workflow_created',\n WORKFLOW_ERRORED: 'workflow_errored',\n WORKFLOW_FAILED: 'workflow_failed',\n WORKFLOW_PAUSED: 'workflow_paused',\n WORKFLOW_RESUMED: 'workflow_resumed',\n WORKFLOW_RUNNING: 'workflow_running',\n WORKFLOW_STEP_ADDED: 'workflow_step_added',\n WORKFLOW_STEP_MOVED: 'workflow_step_moved',\n WORKFLOW_STEP_REMOVED: 'workflow_step_removed',\n WORKFLOW_STEP_SHIFTED: 'workflow_step_shifted',\n WORKFLOW_STEP_SKIPPED: 'workflow_step_skipped',\n WORKFLOW_STEPS_ADDED: 'workflow_steps_added',\n WORKFLOW_STEPS_CLEARED: 'workflow_steps_cleared',\n}\n\nexport default workflow_event_names;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAAuB,CAC3B,wBAAyB,0BACzB,mBAAoB,qBACpB,kBAAmB,oBACnB,iBAAkB,mBAClB,iBAAkB,mBAClB,gBAAiB,kBACjB,gBAAiB,kBACjB,iBAAkB,mBAClB,iBAAkB,mBAClB,oBAAqB,sBACrB,oBAAqB,sBACrB,sBAAuB,wBACvB,sBAAuB,wBACvB,sBAAuB,wBACvB,qBAAsB,uBACtB,uBAAwB,wBAC1B,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["workflow_event_names", "workflow_event_names_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/workflow_statuses.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of possible workflow execution statuses.\n * Workflows transition through these statuses during their lifecycle.\n * \n * @enum {string}\n * @readonly\n */\nconst workflow_statuses = {\n CANCELLED: 'cancelled',\n COMPLETE: 'complete',\n CREATED: 'created',\n ERRORED: 'errored',\n FROZEN: 'frozen',\n FAILED: 'failed',\n PAUSED: 'paused',\n PENDING: 'pending',\n RUNNING: 'running',\n SKIPPED: 'skipped'\n};\n\nexport default workflow_statuses;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAAoB,CACxB,UAAW,YACX,SAAU,WACV,QAAS,UACT,QAAS,UACT,OAAQ,SACR,OAAQ,SACR,OAAQ,SACR,QAAS,UACT,QAAS,UACT,QAAS,SACX,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["workflow_statuses", "workflow_statuses_default"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ronaldroe/micro-flow",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "A lightweight, flexible workflow orchestration library for Node.js and browser environments. Build complex, sequential processes with ease using an intuitive API that supports conditional logic, flow control, event handling, and state management.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "node build.js",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"test:watch": "vitest",
|
|
13
|
+
"test:coverage": "vitest run --coverage",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"workflow",
|
|
18
|
+
"orchestration",
|
|
19
|
+
"state-machine",
|
|
20
|
+
"flow-control",
|
|
21
|
+
"event-driven",
|
|
22
|
+
"browser",
|
|
23
|
+
"nodejs",
|
|
24
|
+
"state-management",
|
|
25
|
+
"sequential",
|
|
26
|
+
"process-automation"
|
|
27
|
+
],
|
|
28
|
+
"author": "Starkey Software",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"type": "module",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/starkeysoft/micro-flow.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/starkeysoft/micro-flow/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/starkeysoft/micro-flow#readme",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist/",
|
|
41
|
+
"src/",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"date-fns": "^4.1.0",
|
|
50
|
+
"node-schedule": "^2.1.1",
|
|
51
|
+
"uuid": "^13.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@vitest/coverage-v8": "^4.0.14",
|
|
55
|
+
"esbuild": "^0.27.0",
|
|
56
|
+
"vitest": "^4.0.14"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { base_types } from '../enums/index.js';
|
|
3
|
+
import State from './state.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for workflows and steps.
|
|
7
|
+
* Provides common functionality for timing, status management, logging, and state access.
|
|
8
|
+
* @class Base
|
|
9
|
+
*/
|
|
10
|
+
export default class Base {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Base instance.
|
|
13
|
+
* @param {Object} options - Configuration options.
|
|
14
|
+
* @param {string} [options.name] - Name of the instance.
|
|
15
|
+
* @param {string} [options.base_type=base_types.STEP] - Type of the base instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor({ name, base_type = base_types.STEP }) {
|
|
18
|
+
this.id = uuidv4();
|
|
19
|
+
this.name = name ?? `${base_type}-${this.id}`;
|
|
20
|
+
|
|
21
|
+
this.base_type = base_type;
|
|
22
|
+
this.timing = {
|
|
23
|
+
cancel_time: null,
|
|
24
|
+
complete_time: null,
|
|
25
|
+
end_time: null,
|
|
26
|
+
execution_time_ms: null,
|
|
27
|
+
start_time: null,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Executes the instance. Must be overridden by subclasses.
|
|
33
|
+
* @async
|
|
34
|
+
* @throws {Error} Throws if not implemented in subclass.
|
|
35
|
+
*/
|
|
36
|
+
async execute() {
|
|
37
|
+
throw new Error('Execute method not implemented');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Logs an event and emits it to the appropriate event emitter.
|
|
42
|
+
* @param {string} event_name - Name of the event to log.
|
|
43
|
+
* @param {string} [message=null] - Optional message to log.
|
|
44
|
+
* @throws {Error} Throws if event name is invalid or event emitter not found.
|
|
45
|
+
*/
|
|
46
|
+
log(event_name, message = null) {
|
|
47
|
+
if (!event_name || !State.get(`events.${this.base_type}`)) {
|
|
48
|
+
throw new Error('Invalid event name or event emitter not found');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
State.get(`events.${this.base_type}`).emit(event_name, this);
|
|
52
|
+
if (State.get('log_suppress')) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const logMessage = message ? `\n[${this.base_type.toUpperCase()} - ${this.name}] ${message}` : `\n[${this.base_type.toUpperCase()} - ${this.name}] Event: ${event_name}`;
|
|
57
|
+
const logType = event_name.endsWith('_failed') ? 'error' : 'log';
|
|
58
|
+
|
|
59
|
+
console[logType](logMessage);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Marks the instance as complete and calculates execution time.
|
|
64
|
+
*/
|
|
65
|
+
markAsComplete() {
|
|
66
|
+
this.timing.complete_time = new Date();
|
|
67
|
+
this.status = State.get('statuses')[this.base_type].COMPLETE;
|
|
68
|
+
this.timing.execution_time_ms = this.timing.complete_time - this.timing.start_time;
|
|
69
|
+
|
|
70
|
+
if (this.steps_by_id) {
|
|
71
|
+
delete this.steps_by_id;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.log(
|
|
75
|
+
State.get(`event_names.${this.base_type}`)[`${this.base_type.toUpperCase()}_COMPLETE`],
|
|
76
|
+
`${this.base_type.charAt(0).toUpperCase() + this.base_type.slice(1)} "${this.name}" complete.`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Marks the instance as failed and calculates execution time.
|
|
82
|
+
*/
|
|
83
|
+
markAsFailed() {
|
|
84
|
+
this.timing.complete_time = new Date();
|
|
85
|
+
this.status = State.get('statuses')[this.base_type].FAILED;
|
|
86
|
+
this.timing.execution_time_ms = this.timing.complete_time - this.timing.start_time;
|
|
87
|
+
|
|
88
|
+
this.log(
|
|
89
|
+
State.get(`event_names.${this.base_type}`)[`${this.base_type.toUpperCase()}_FAILED`],
|
|
90
|
+
`${this.base_type.charAt(0).toUpperCase() + this.base_type.slice(1)} "${this.name}" failed.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Marks the instance as waiting. To be implemented by subclasses.
|
|
96
|
+
*/
|
|
97
|
+
markAsWaiting() { }
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Marks the instance as pending. To be implemented by subclasses.
|
|
101
|
+
*/
|
|
102
|
+
markAsPending() { }
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Marks the instance as running and sets the start time.
|
|
106
|
+
*/
|
|
107
|
+
markAsRunning() {
|
|
108
|
+
this.timing.start_time = new Date();
|
|
109
|
+
this.status = State.get('statuses')[this.base_type].RUNNING;
|
|
110
|
+
|
|
111
|
+
this.log(
|
|
112
|
+
State.get(`event_names.${this.base_type}`)[`${this.base_type.toUpperCase()}_RUNNING`],
|
|
113
|
+
`${this.base_type.charAt(0).toUpperCase() + this.base_type.slice(1)} "${this.name}" started.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// State management methods
|
|
118
|
+
/**
|
|
119
|
+
* Gets a value from the global state.
|
|
120
|
+
* @param {string} path - Path to the state property.
|
|
121
|
+
* @returns {*} The state value at the specified path.
|
|
122
|
+
*/
|
|
123
|
+
getState(path) {
|
|
124
|
+
return State.get(path);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sets a value in the global state.
|
|
129
|
+
* @param {string} path - Path to the state property.
|
|
130
|
+
* @param {*} value - Value to set.
|
|
131
|
+
*/
|
|
132
|
+
setState(path, value) {
|
|
133
|
+
State.set(path, value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Deletes a property from the global state.
|
|
138
|
+
* @param {string} path - Path to the state property to delete.
|
|
139
|
+
*/
|
|
140
|
+
deleteState(path) {
|
|
141
|
+
State.delete(path);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Broadcast class provides a simplified wrapper around the BroadcastChannel API
|
|
3
|
+
* for cross-context communication (e.g., between tabs, windows, workers).
|
|
4
|
+
*
|
|
5
|
+
* This class allows you to send and receive messages across different browsing contexts
|
|
6
|
+
* that share the same origin. It encapsulates the creation and management of a BroadcastChannel,
|
|
7
|
+
* providing a simplified API for sending and receiving messages.
|
|
8
|
+
*
|
|
9
|
+
* @class Broadcast
|
|
10
|
+
* @extends BroadcastChannel
|
|
11
|
+
*/
|
|
12
|
+
export default class Broadcast extends BroadcastChannel {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new Broadcast instance for a named channel.
|
|
15
|
+
*
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {string} channelName - The name of the broadcast channel to create or connect to.
|
|
18
|
+
* Multiple Broadcast instances with the same channel name can communicate with each other.
|
|
19
|
+
*/
|
|
20
|
+
constructor(channelName) {
|
|
21
|
+
super(channelName);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sends data to all other contexts listening on this channel.
|
|
26
|
+
*
|
|
27
|
+
* @param {*} data - The data to broadcast. Can be any structured-cloneable value
|
|
28
|
+
* (primitives, objects, arrays, etc.). Functions and DOM nodes cannot be sent.
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
send(data) {
|
|
32
|
+
this.postMessage(data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Registers a callback to handle incoming messages on this channel.
|
|
37
|
+
*
|
|
38
|
+
* @param {Function} callback - Function to call when a message is received.
|
|
39
|
+
* Receives the message data as its only parameter.
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
42
|
+
onReceive(callback) {
|
|
43
|
+
this.onmessage = (event) => {
|
|
44
|
+
callback(event.data);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Closes the broadcast channel and releases its resources.
|
|
50
|
+
* After calling this method, the Broadcast instance can no longer send or receive messages.
|
|
51
|
+
*
|
|
52
|
+
* @returns {void}
|
|
53
|
+
*/
|
|
54
|
+
destroy() {
|
|
55
|
+
this.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { errors, warnings } from '../../enums/index.js';
|
|
2
|
+
import Broadcast from './broadcast.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Event class for micro-flow
|
|
6
|
+
* Provides a simple event emitter implementation for workflow steps and state changes.
|
|
7
|
+
*
|
|
8
|
+
* This class is used for emitting and listening to events within workflows and steps.
|
|
9
|
+
* For broadcasting events across multiple workflows or listeners, see the Broadcast class.
|
|
10
|
+
*/
|
|
11
|
+
class Event extends EventTarget {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new Event instance.
|
|
14
|
+
* @constructor
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.events = {};
|
|
19
|
+
this._listener_map = new Map();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Registers multiple events by creating Event instances for each event name.
|
|
24
|
+
* @param {Object} event_names - An object containing event name constants.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
registerEvents(event_names) {
|
|
28
|
+
for (const event_name of Object.values(event_names)) {
|
|
29
|
+
this.events[event_name] = new Event();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Emits a custom event with optional data payload.
|
|
35
|
+
* This method maintains API compatibility with EventEmitter while using CustomEvent.
|
|
36
|
+
* @param {string} event_name - The name of the event to emit.
|
|
37
|
+
* @param {*} [data] - Optional data to pass with the event in the detail property.
|
|
38
|
+
* @param {boolean} [bubbles=false] - Whether the event should bubble up through the DOM.
|
|
39
|
+
* @param {boolean} [cancelable=true] - Whether the event is cancelable.
|
|
40
|
+
* @returns {boolean} True if the event was not cancelled, false if it was cancelled.
|
|
41
|
+
*/
|
|
42
|
+
emit(event_name, data, bubbles = false, cancelable = true) {
|
|
43
|
+
const workingData = JSON.parse(JSON.stringify(data));
|
|
44
|
+
|
|
45
|
+
const custom_event = new CustomEvent(event_name, {
|
|
46
|
+
detail: workingData,
|
|
47
|
+
bubbles,
|
|
48
|
+
cancelable
|
|
49
|
+
});
|
|
50
|
+
const result = this.dispatchEvent(custom_event);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const channel = new Broadcast(event_name);
|
|
54
|
+
channel.send(workingData);
|
|
55
|
+
channel.destroy();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.warn(warnings.BROADCAST_FAILED, e);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Listen for broadcasts on a given event name (channel).
|
|
64
|
+
* @param {string} event_name - The event name/channel to listen for.
|
|
65
|
+
* @param {Function} listener - Callback for broadcasted data.
|
|
66
|
+
* @returns {Broadcast} Returns the Broadcast instance for manual control.
|
|
67
|
+
*/
|
|
68
|
+
onBroadcast(event_name, listener) {
|
|
69
|
+
const channel = new Broadcast(event_name);
|
|
70
|
+
channel.onReceive(listener);
|
|
71
|
+
return channel;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Listen for both local and broadcast events.
|
|
76
|
+
* @param {string} event_name - The event name/channel to listen for.
|
|
77
|
+
* @param {Function} listener - Callback for event data.
|
|
78
|
+
* @returns {Object} Returns { event: this, broadcast: Broadcast instance }
|
|
79
|
+
*/
|
|
80
|
+
onAny(event_name, listener) {
|
|
81
|
+
this.on(event_name, listener);
|
|
82
|
+
const broadcast = this.onBroadcast(event_name, listener);
|
|
83
|
+
return { event: this, broadcast };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Adds an event listener with EventEmitter-style API.
|
|
88
|
+
* Maintains compatibility with the original API while using addEventListener.
|
|
89
|
+
* @param {string} event_name - The name of the event to listen for.
|
|
90
|
+
* @param {Function} listener - The callback function to execute when the event fires.
|
|
91
|
+
* @returns {Event} Returns this for chaining.
|
|
92
|
+
*/
|
|
93
|
+
on(event_name, listener) {
|
|
94
|
+
const wrapped_listener = (event) => {
|
|
95
|
+
// Call the listener with the detail (data) from CustomEvent
|
|
96
|
+
listener(event.detail);
|
|
97
|
+
};
|
|
98
|
+
// Store the original listener reference for removeListener
|
|
99
|
+
this._listener_map.set(listener, wrapped_listener);
|
|
100
|
+
this.addEventListener(event_name, wrapped_listener);
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Adds a one-time event listener with EventEmitter-style API.
|
|
106
|
+
* @param {string} event_name - The name of the event to listen for.
|
|
107
|
+
* @param {Function} listener - The callback function to execute when the event fires.
|
|
108
|
+
* @returns {Event} Returns this for chaining.
|
|
109
|
+
*/
|
|
110
|
+
once(event_name, listener) {
|
|
111
|
+
const wrapped_listener = (event) => {
|
|
112
|
+
listener(event.detail);
|
|
113
|
+
};
|
|
114
|
+
this.addEventListener(event_name, wrapped_listener, { once: true });
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Removes an event listener with EventEmitter-style API.
|
|
120
|
+
* @param {string} event_name - The name of the event.
|
|
121
|
+
* @param {Function} listener - The callback function to remove.
|
|
122
|
+
* @returns {Event} Returns this for chaining.
|
|
123
|
+
*/
|
|
124
|
+
off(event_name, listener) {
|
|
125
|
+
if (this._listener_map && this._listener_map.has(listener)) {
|
|
126
|
+
const wrapped_listener = this._listener_map.get(listener);
|
|
127
|
+
this.removeEventListener(event_name, wrapped_listener);
|
|
128
|
+
this._listener_map.delete(listener);
|
|
129
|
+
}
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Alias for off() to maintain EventEmitter API compatibility.
|
|
135
|
+
* @param {string} event_name - The name of the event.
|
|
136
|
+
* @param {Function} listener - The callback function to remove.
|
|
137
|
+
* @returns {Event} Returns this for chaining.
|
|
138
|
+
*/
|
|
139
|
+
removeListener(event_name, listener) {
|
|
140
|
+
return this.off(event_name, listener);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default Event;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Broadcast } from './broadcast.js';
|
|
2
|
+
export { default as Event } from './event.js';
|
|
3
|
+
export { default as StateEvent } from './state_event.js';
|
|
4
|
+
export { default as StepEvent } from './step_event.js';
|
|
5
|
+
export { default as WorkflowEvent } from './workflow_event.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Event } from './index.js';
|
|
2
|
+
import { state_event_names } from '../../enums/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Manages state-specific events by extending the base Event class.
|
|
6
|
+
* @class StateEvent
|
|
7
|
+
* @extends Event
|
|
8
|
+
*/
|
|
9
|
+
export default class StateEvent extends Event {
|
|
10
|
+
event_names = state_event_names;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new StateEvent instance and registers all state events.
|
|
14
|
+
* @constructor
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.registerStateEvents();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Registers all state event names defined in the state_event_names enum.
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
registerStateEvents() {
|
|
26
|
+
this.registerEvents(this.event_names);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Event } from './index.js';
|
|
2
|
+
import { step_event_names } from '../../enums/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Manages step-specific events by extending the base Event class.
|
|
6
|
+
* @class StepEvent
|
|
7
|
+
* @extends Event
|
|
8
|
+
*/
|
|
9
|
+
export default class StepEvent extends Event {
|
|
10
|
+
event_names = step_event_names;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new StepEvent instance and registers all step events.
|
|
14
|
+
* @constructor
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.registerStepEvents();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Registers all step event names defined in the step_event_names enum.
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
registerStepEvents() {
|
|
26
|
+
this.registerEvents(this.event_names);
|
|
27
|
+
}
|
|
28
|
+
}
|