@ronaldroe/micro-flow 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -153
- 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 +10 -6
- package/src/classes/base.js +4 -5
- package/src/classes/events/event.js +16 -9
- package/src/classes/events/index.js +1 -1
- package/src/classes/events/state_event.js +28 -0
- package/src/classes/state.js +161 -54
- package/src/classes/steps/case.js +70 -0
- package/src/classes/steps/conditional_step.js +20 -7
- package/src/classes/steps/delay_step.js +103 -0
- package/src/classes/steps/flow_control_step.js +8 -7
- package/src/classes/steps/index.js +4 -0
- package/src/classes/steps/logic_step.js +89 -29
- package/src/classes/steps/loop_step.js +148 -0
- package/src/classes/steps/step.js +59 -18
- package/src/classes/steps/switch_step.js +77 -0
- package/src/classes/workflow.js +74 -26
- package/src/enums/conditional_step_comparators.js +38 -8
- package/src/enums/delay_types.js +0 -7
- package/src/enums/errors.js +2 -0
- package/src/enums/index.js +1 -0
- package/src/enums/loop_types.js +3 -1
- package/src/enums/state_event_names.js +17 -0
- package/src/enums/step_event_names.js +3 -0
- package/src/enums/step_types.js +2 -1
- package/src/enums/sub_step_types.js +15 -125
- package/src/enums/workflow_event_names.js +1 -0
- package/index.js +0 -1
- package/src/classes/events/broadcast.js +0 -57
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/classes/steps/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default as Step } from './step.js';\nexport { default as LogicStep } from './logic_step.js';\nexport { default as Case } from './case.js';\nexport { default as ConditionalStep } from './conditional_step.js';\nexport { default as DelayStep } from './delay_step.js';\nexport { default as FlowControlStep } from './flow_control_step.js';\nexport { default as LoopStep } from './loop_step.js';\nexport { default as SwitchStep } from './switch_step.js';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAoB,WAAXA,MAAuB,YAChC,OAAoB,WAAXA,MAA4B,kBACrC,OAAoB,WAAXA,MAAuB,YAChC,OAAoB,WAAXA,MAAkC,wBAC3C,OAAoB,WAAXA,MAA4B,kBACrC,OAAoB,WAAXA,MAAkC,yBAC3C,OAAoB,WAAXA,MAA2B,iBACpC,OAAoB,WAAXA,MAA6B",
|
|
6
|
+
"names": ["default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=Object.defineProperty;var n=(i,o)=>r(i,"name",{value:o,configurable:!0});import c from"./step.js";import{step_types as _}from"../../enums/index.js";class p extends c{static{n(this,"LogicStep")}static step_name="logic";constructor({name:o,callable:a=n(async()=>{},"callable"),conditional:s={operator:null,subject:null,value:null}}){super({name:o,step_type:_.LOGIC,callable:a}),this.setConditional(s)}checkCondition(){const o=this.conditional_config.subject,a=this.conditional_config.value,s=this.conditional_config.operator,t=typeof o=="function"?o():o,e=!(s===this.getState("conditional_step_comparators.CUSTOM_FUNCTION"))&&typeof a=="function"?a():a;switch(s){case this.getState("conditional_step_comparators.STRICT_EQUALS"):case this.getState("conditional_step_comparators.SIGN_STRICT_EQUALS"):return t===e;case this.getState("conditional_step_comparators.SIGN_EQUALS"):case this.getState("conditional_step_comparators.EQUALS"):return t==e;case this.getState("conditional_step_comparators.NOT_EQUALS"):case this.getState("conditional_step_comparators.SIGN_NOT_EQUALS"):return t!=e;case this.getState("conditional_step_comparators.STRICT_NOT_EQUALS"):case this.getState("conditional_step_comparators.SIGN_STRICT_NOT_EQUALS"):return t!==e;case this.getState("conditional_step_comparators.GREATER_THAN"):case this.getState("conditional_step_comparators.SIGN_GREATER_THAN"):return t>e;case this.getState("conditional_step_comparators.LESS_THAN"):case this.getState("conditional_step_comparators.SIGN_LESS_THAN"):return t<e;case this.getState("conditional_step_comparators.GREATER_THAN_OR_EQUAL"):case this.getState("conditional_step_comparators.SIGN_GREATER_THAN_OR_EQUAL"):return t>=e;case this.getState("conditional_step_comparators.LESS_THAN_OR_EQUAL"):case this.getState("conditional_step_comparators.SIGN_LESS_THAN_OR_EQUAL"):return t<=e;case this.getState("conditional_step_comparators.STRING_CONTAINS"):case this.getState("conditional_step_comparators.STRING_INCLUDES"):case this.getState("conditional_step_comparators.ARRAY_CONTAINS"):case this.getState("conditional_step_comparators.ARRAY_INCLUDES"):return(Array.isArray(t)||typeof t=="string")&&t.includes(e);case this.getState("conditional_step_comparators.IN"):return(Array.isArray(e)||typeof e=="string")&&e.includes(t);case this.getState("conditional_step_comparators.STRING_NOT_CONTAINS"):case this.getState("conditional_step_comparators.STRING_NOT_INCLUDES"):case this.getState("conditional_step_comparators.ARRAY_NOT_CONTAINS"):case this.getState("conditional_step_comparators.ARRAY_NOT_INCLUDES"):return(Array.isArray(t)||typeof t=="string")&&!t.includes(e);case this.getState("conditional_step_comparators.NOT_IN"):return(Array.isArray(e)||typeof e=="string")&&!e.includes(t);case this.getState("conditional_step_comparators.EMPTY"):return t===""||t===null||t===void 0||t.length===0;case this.getState("conditional_step_comparators.NOT_EMPTY"):return t!==""&&t!==null&&t!==void 0&&t.length>0;case this.getState("conditional_step_comparators.REGEX_MATCH"):if(typeof e!="string")throw new Error("Regex input must be a string.");return new RegExp(e).test(t);case this.getState("conditional_step_comparators.REGEX_NOT_MATCH"):if(typeof e!="string")throw new Error("Regex input must be a string.");return!new RegExp(e).test(t);case this.getState("conditional_step_comparators.STRING_STARTS_WITH"):return typeof t=="string"&&typeof e=="string"&&t.startsWith(e);case this.getState("conditional_step_comparators.STRING_ENDS_WITH"):return typeof t=="string"&&typeof e=="string"&&t.endsWith(e);case this.getState("conditional_step_comparators.NULLISH"):return t==null;case this.getState("conditional_step_comparators.NOT_NULLISH"):return t!=null;case this.getState("conditional_step_comparators.IS_TYPE"):return typeof t===e;case this.getState("conditional_step_comparators.IS_NOT_TYPE"):return typeof t!==e;case this.getState("conditional_step_comparators.CUSTOM_FUNCTION"):if(typeof e!="function")throw new Error(`Invalid custom function: ${e}`);return e(t);default:throw new Error(`Unknown operator: ${s}`)}}conditionalIsValid(){return this.conditional_config.subject!==null&&this.conditional_config.subject!==void 0&&this.conditional_config.operator!==null&&this.conditional_config.operator!==void 0&&this.conditional_config.value!==null&&this.conditional_config.value!==void 0}setConditional(o){this.conditional_config={subject:o.subject,operator:o.operator,value:o.value}}}export{p as default};
|
|
2
|
+
//# sourceMappingURL=logic_step.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/classes/steps/logic_step.js"],
|
|
4
|
+
"sourcesContent": ["import Step from './step.js';\nimport { conditional_step_comparators, step_types } from '../../enums/index.js';\n\n/**\n * LogicStep class for conditional logic operations.\n * @class LogicStep\n * @extends Step\n */\nexport default class LogicStep extends Step {\n static step_name = 'logic';\n\n /**\n * Creates a new LogicStep instance.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the step.\n * @param {Object} [options.conditional] - Conditional configuration.\n * @param {*|Function} [options.conditional.subject] - Subject to evaluate. Can be a function that returns the value.\n * @param {conditional_step_comparators|string} [options.conditional.operator] - Comparison operator.\n * @param {*|Function} [options.conditional.value] - Value to compare against. Can be a function that returns the value.\n * @param {Function} [options.callable=async () => {}] - Function to execute.\n */\n constructor({\n name,\n callable = async () => {},\n conditional = {\n operator: null,\n subject: null,\n value: null,\n },\n }) {\n super({\n name,\n step_type: step_types.LOGIC,\n callable\n });\n\n this.setConditional(conditional);\n }\n\n /**\n * Evaluates the conditional expression.\n * Supports function subjects and values - they are called to get the actual value.\n * @returns {boolean} True if the condition is met.\n * @throws {Error} Throws if operator is unknown.\n */\n checkCondition() {\n const rawSubject = this.conditional_config.subject;\n const rawValue = this.conditional_config.value;\n const operator = this.conditional_config.operator;\n \n // Resolve subject - call it if it's a function\n const subject = typeof rawSubject === 'function' ? rawSubject() : rawSubject;\n \n // Don't resolve value for CUSTOM_FUNCTION - the value IS the function to call\n const isCustomFunction = operator === this.getState('conditional_step_comparators.CUSTOM_FUNCTION');\n const value = (!isCustomFunction && typeof rawValue === 'function') ? rawValue() : rawValue;\n\n switch (operator) {\n case this.getState('conditional_step_comparators.STRICT_EQUALS'):\n case this.getState('conditional_step_comparators.SIGN_STRICT_EQUALS'):\n return subject === value;\n case this.getState('conditional_step_comparators.SIGN_EQUALS'):\n case this.getState('conditional_step_comparators.EQUALS'):\n return subject == value;\n case this.getState('conditional_step_comparators.NOT_EQUALS'):\n case this.getState('conditional_step_comparators.SIGN_NOT_EQUALS'):\n return subject != value;\n case this.getState('conditional_step_comparators.STRICT_NOT_EQUALS'):\n case this.getState('conditional_step_comparators.SIGN_STRICT_NOT_EQUALS'):\n return subject !== value;\n case this.getState('conditional_step_comparators.GREATER_THAN'):\n case this.getState('conditional_step_comparators.SIGN_GREATER_THAN'):\n return subject > value;\n case this.getState('conditional_step_comparators.LESS_THAN'):\n case this.getState('conditional_step_comparators.SIGN_LESS_THAN'):\n return subject < value;\n case this.getState('conditional_step_comparators.GREATER_THAN_OR_EQUAL'):\n case this.getState('conditional_step_comparators.SIGN_GREATER_THAN_OR_EQUAL'):\n return subject >= value;\n case this.getState('conditional_step_comparators.LESS_THAN_OR_EQUAL'):\n case this.getState('conditional_step_comparators.SIGN_LESS_THAN_OR_EQUAL'):\n return subject <= value;\n case this.getState('conditional_step_comparators.STRING_CONTAINS'):\n case this.getState('conditional_step_comparators.STRING_INCLUDES'):\n case this.getState('conditional_step_comparators.ARRAY_CONTAINS'):\n case this.getState('conditional_step_comparators.ARRAY_INCLUDES'):\n return (Array.isArray(subject) || typeof subject === 'string') && subject.includes(value);\n case this.getState('conditional_step_comparators.IN'):\n return (Array.isArray(value) || typeof value === 'string') && value.includes(subject);\n case this.getState('conditional_step_comparators.STRING_NOT_CONTAINS'):\n case this.getState('conditional_step_comparators.STRING_NOT_INCLUDES'):\n case this.getState('conditional_step_comparators.ARRAY_NOT_CONTAINS'):\n case this.getState('conditional_step_comparators.ARRAY_NOT_INCLUDES'):\n return (Array.isArray(subject) || typeof subject === 'string') && !subject.includes(value);\n case this.getState('conditional_step_comparators.NOT_IN'):\n return (Array.isArray(value) || typeof value === 'string') && !value.includes(subject);\n case this.getState('conditional_step_comparators.EMPTY'):\n return subject === '' || subject === null || subject === undefined || subject.length === 0;\n case this.getState('conditional_step_comparators.NOT_EMPTY'):\n return subject !== '' && subject !== null && subject !== undefined && subject.length > 0;\n case this.getState('conditional_step_comparators.REGEX_MATCH'):\n if (typeof value !== 'string') {\n throw new Error(`Regex input must be a string.`);\n }\n const regex = new RegExp(value);\n return regex.test(subject);\n case this.getState('conditional_step_comparators.REGEX_NOT_MATCH'):\n if (typeof value !== 'string') {\n throw new Error(`Regex input must be a string.`);\n }\n const notMatchRegex = new RegExp(value);\n return !notMatchRegex.test(subject);\n case this.getState('conditional_step_comparators.STRING_STARTS_WITH'):\n return typeof subject === 'string' && typeof value === 'string' && subject.startsWith(value);\n case this.getState('conditional_step_comparators.STRING_ENDS_WITH'):\n return typeof subject === 'string' && typeof value === 'string' && subject.endsWith(value);\n case this.getState('conditional_step_comparators.NULLISH'):\n return subject === null || subject === undefined;\n case this.getState('conditional_step_comparators.NOT_NULLISH'):\n return subject !== null && subject !== undefined;\n case this.getState('conditional_step_comparators.IS_TYPE'):\n return typeof subject === value;\n case this.getState('conditional_step_comparators.IS_NOT_TYPE'):\n return typeof subject !== value;\n case this.getState('conditional_step_comparators.CUSTOM_FUNCTION'):\n if (typeof value !== 'function') {\n throw new Error(`Invalid custom function: ${value}`);\n }\n return value(subject);\n default:\n throw new Error(`Unknown operator: ${operator}`);\n }\n }\n\n /**\n * Checks if the conditional configuration is valid.\n * A valid conditional has subject, operator, and value all set (not null/undefined).\n * Functions are valid as subject or value - they will be called during checkCondition().\n * @returns {boolean} True if conditional is valid.\n */\n conditionalIsValid() {\n // Check if all conditional properties are set (not null or undefined)\n // Can't use falsy check here because valid values could be falsy (e.g. empty string, 0, false)\n // Functions are valid - they'll be called to get the actual value\n return (\n this.conditional_config.subject !== null &&\n this.conditional_config.subject !== undefined &&\n this.conditional_config.operator !== null &&\n this.conditional_config.operator !== undefined &&\n this.conditional_config.value !== null &&\n this.conditional_config.value !== undefined\n );\n }\n\n /**\n * Sets the conditional properties.\n * @param {Object} conditional - Conditional configuration object.\n */\n setConditional(conditional) {\n this.conditional_config = { subject: conditional.subject, operator: conditional.operator, value: conditional.value };\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAOA,MAAU,YACjB,OAAuC,cAAAC,MAAkB,uBAOzD,MAAOC,UAAgCF,CAAK,CAR5C,MAQ4C,CAAAG,EAAA,kBAC1C,OAAO,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C,EAChE,OAAO,OAAOD,GAAY,UAAY,OAAOC,GAAU,UAAYD,EAAQ,SAASC,CAAK,EAC3F,KAAK,KAAK,SAAS,sCAAsC,EACvD,OAAOD,GAAY,KACrB,KAAK,KAAK,SAAS,0CAA0C,EAC3D,OAAOA,GAAY,KACrB,KAAK,KAAK,SAAS,sCAAsC,EACvD,OAAO,OAAOA,IAAYC,EAC5B,KAAK,KAAK,SAAS,0CAA0C,EAC3D,OAAO,OAAOD,IAAYC,EAC5B,KAAK,KAAK,SAAS,8CAA8C,EAC/D,GAAI,OAAOA,GAAU,WACnB,MAAM,IAAI,MAAM,4BAA4BA,CAAK,EAAE,EAErD,OAAOA,EAAMD,CAAO,EACtB,QACE,MAAM,IAAI,MAAM,qBAAqBD,CAAQ,EAAE,CACnD,CACF,CAQA,oBAAqB,CAInB,OACE,KAAK,mBAAmB,UAAY,MACpC,KAAK,mBAAmB,UAAY,QACpC,KAAK,mBAAmB,WAAa,MACrC,KAAK,mBAAmB,WAAa,QACrC,KAAK,mBAAmB,QAAU,MAClC,KAAK,mBAAmB,QAAU,MAEtC,CAMA,eAAeH,EAAa,CAC1B,KAAK,mBAAqB,CAAE,QAASA,EAAY,QAAS,SAAUA,EAAY,SAAU,MAAOA,EAAY,KAAM,CACrH,CACF",
|
|
6
|
+
"names": ["Step", "step_types", "LogicStep", "__name", "name", "callable", "conditional", "rawSubject", "rawValue", "operator", "subject", "value"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var p=Object.defineProperty;var o=(r,t)=>p(r,"name",{value:t,configurable:!0});import{loop_types as u,step_types as c}from"../../enums/index.js";import f from"./logic_step.js";import"../../enums/index.js";class _ extends f{static{o(this,"LoopStep")}static step_name=c.LOOP;constructor({name:t,iterable:e,callable:s=o(async()=>{},"callable"),conditional:n={operator:null,subject:null,value:null},loop_type:l=u.FOR_EACH,iterations:a=0,max_iterations:i=1e3}){super({name:t,conditional:n}),this.iterable=e,this.loop_type=l,this.iterations=a>i?i:a,this.max_iterations=i,this.results=[],this.current_item=null;const h=this.getCallableType(s);this._loop_callable=h==="function"?s.bind(this):s.execute.bind(s),this.callable=this[`${l}_loop`].bind(this)}async generator_loop(){if(!this._loop_callable.constructor.name.includes("Generator"))throw new Error("Iterable must be a generator function for generator loops");let t=0;for await(const e of this._loop_callable())if(this.results.push(e),++t>=this.max_iterations)break;return{message:`Generator loop ${this.name} completed after ${t} iterations`,result:this.results}}async for_loop(){let t=0;for(;t<this.iterations;t++)this.results.push(await this._loop_callable());return{message:`For loop ${this.name} completed after ${t} iterations`,result:this.results}}async for_each_loop(){if(!this.iterable)throw new Error("Iterable is required for for_each loops");typeof this.iterable=="function"&&(this.iterable=this.iterable());let t=0;for(const e of this.iterable)t++,this.current_item=e,this.results.push(await this._loop_callable());return{message:`For each loop ${this.name} completed after ${t} iterations`,result:this.results}}async while_loop(){if(!this.conditionalIsValid())throw new Error("Valid conditional is required for while loops");let t=0;for(;this.checkCondition()&&t<this.max_iterations;)t++,this.results.push(await this._loop_callable());return{message:`While loop ${this.name} completed after ${t} iterations`,result:this.results}}}export{_ as default};
|
|
2
|
+
//# sourceMappingURL=loop_step.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/classes/steps/loop_step.js"],
|
|
4
|
+
"sourcesContent": ["import { loop_types, step_types } from '../../enums/index.js';\nimport LogicStep from './logic_step.js';\nimport { conditional_step_comparators } from '../../enums/index.js';\n\n/**\n * LoopStep class for executing loops within a workflow.\n * @class LoopStep\n * @extends LogicStep\n */\nexport default class LoopStep extends LogicStep {\n static step_name = step_types.LOOP;\n\n /**\n * Creates a new LoopStep instance.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the step.\n * @param {Array|Iterable|Function} options.iterable - Iterable to loop over or function returning an iterable. Required for 'for_each' and 'generator' loops.\n * @param {Function} [options.callable=async () => {}] - Function to execute for each iteration.\n * @param {Object} [options.conditional] - Conditional configuration for while loops. Required for 'while' loops.\n * @param {*|Function} [options.conditional.subject] - Subject to evaluate. Can be a function that returns the value.\n * @param {conditional_step_comparators|string} [options.conditional.operator] - Comparison operator.\n * @param {*|Function} [options.conditional.value] - Value to compare against. Can be a function that returns the value.\n * @param {string} [options.loop_type=loop_types.FOR_EACH] - Type of loop ('for', 'for_each', 'while', or 'generator').\n * @param {number} [options.iterations=0] - Number of iterations to execute. Only used for 'for' loops.\n * @param {number} [options.max_iterations=1000] - Maximum number of iterations to prevent infinite loops.\n */\n constructor({\n name,\n iterable,\n callable = async () => {},\n conditional = {\n operator: null,\n subject: null,\n value: null,\n },\n loop_type = loop_types.FOR_EACH,\n iterations = 0,\n max_iterations = 1000,\n }) {\n super({ name, conditional });\n this.iterable = iterable;\n this.loop_type = loop_type;\n this.iterations = iterations > max_iterations ? max_iterations : iterations;\n this.max_iterations = max_iterations;\n this.results = [];\n this.current_item = null;\n\n // Store the user's callable separately so loop methods can invoke it.\n // this._callable will be set to the loop method by the setter below.\n const userCallableType = this.getCallableType(callable);\n this._loop_callable = userCallableType === 'function'\n ? callable.bind(this)\n : callable.execute.bind(callable);\n\n this.callable = this[`${loop_type}_loop`].bind(this);\n }\n\n /**\n * Executes a generator/async generator and appends yielded values to results.\n * @throws {Error} If the callable is not a generator or async generator function.\n * @returns {Object} - An object containing a message and the results of the loop.\n */\n async generator_loop() {\n if (!this._loop_callable.constructor.name.includes('Generator')) {\n throw new Error('Iterable must be a generator function for generator loops');\n }\n\n let iterations = 0;\n // Use for await...of to handle both sync and async generators\n for await (const item of this._loop_callable()) {\n this.results.push(item);\n\n if (++iterations >= this.max_iterations) {\n break;\n }\n }\n\n return {\n message: `Generator loop ${this.name} completed after ${iterations} iterations`,\n result: this.results\n };\n }\n\n /**\n * Executes a for loop calling the callable for a set number of iterations\n * @returns {Object} - An object containing a message and the results of the loop.\n */\n async for_loop() {\n let i = 0;\n for (; i < this.iterations; i++) {\n this.results.push(await this._loop_callable());\n }\n\n return {\n message: `For loop ${this.name} completed after ${i} iterations`,\n result: this.results\n };\n }\n\n /**\n * Executes the callable for each item in the iterable.\n * @throws {Error} If the iterable is not provided.\n * @returns {Object} - An object containing a message and the results of the loop.\n */\n async for_each_loop() {\n if (!this.iterable) {\n throw new Error('Iterable is required for for_each loops');\n }\n\n if (typeof this.iterable === 'function') {\n this.iterable = this.iterable();\n }\n\n let iterations = 0;\n for (const item of this.iterable) {\n iterations++;\n this.current_item = item;\n this.results.push(await this._loop_callable());\n }\n\n return {\n message: `For each loop ${this.name} completed after ${iterations} iterations`,\n result: this.results\n };\n }\n\n /**\n * Executes the callable while the condition is true.\n * @throws {Error} If the conditional is not valid.\n * @returns {Object} - An object containing a message and the results of the loop.\n */\n async while_loop() {\n if (!this.conditionalIsValid()) {\n throw new Error('Valid conditional is required for while loops');\n }\n\n let iterations = 0;\n while (this.checkCondition() && iterations < this.max_iterations) {\n iterations++;\n this.results.push(await this._loop_callable());\n }\n\n return {\n message: `While loop ${this.name} completed after ${iterations} iterations`,\n result: this.results\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,uBACvC,OAAOC,MAAe,kBACtB,MAA6C,uBAO7C,MAAOC,UAA+BD,CAAU,CAThD,MASgD,CAAAE,EAAA,iBAC9C,OAAO,UAAYH,EAAW,KAgB9B,YAAY,CACV,KAAAI,EACA,SAAAC,EACA,SAAAC,EAAWH,EAAA,SAAY,CAAC,EAAb,YACX,YAAAI,EAAc,CACZ,SAAU,KACV,QAAS,KACT,MAAO,IACT,EACA,UAAAC,EAAYT,EAAW,SACvB,WAAAU,EAAa,EACb,eAAAC,EAAiB,GACnB,EAAG,CACD,MAAM,CAAE,KAAAN,EAAM,YAAAG,CAAY,CAAC,EAC3B,KAAK,SAAWF,EAChB,KAAK,UAAYG,EACjB,KAAK,WAAaC,EAAaC,EAAiBA,EAAiBD,EACjE,KAAK,eAAiBC,EACtB,KAAK,QAAU,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AAa,KAAK,gBAChDA,IACA,KAAK,QAAQ,KAAK,MAAM,KAAK,eAAe,CAAC,EAG/C,MAAO,CACL,QAAS,cAAc,KAAK,IAAI,oBAAoBA,CAAU,cAC9D,OAAQ,KAAK,OACf,CACF,CACF",
|
|
6
|
+
"names": ["loop_types", "step_types", "LogicStep", "LoopStep", "__name", "name", "iterable", "callable", "conditional", "loop_type", "iterations", "max_iterations", "userCallableType", "item", "i"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var l=Object.defineProperty;var i=(h,t)=>l(h,"name",{value:t,configurable:!0});import u from"../base.js";import"../workflow.js";import{base_types as o,step_types as p}from"../../enums/index.js";class _ extends u{static{i(this,"Step")}static step_name="step";#t=null;constructor({name:t,callable:s=i(async()=>{},"callable"),max_retries:e=0,max_timeout_ms:r=3e4,step_type:n=p.ACTION,sub_step_type:a=null}){super({name:t,base_type:o.STEP}),this.callable=s,this.#t=s,this.max_retries=e,this.retry_count=0,this.max_timeout_ms=r,this.step_type=n,this.sub_step_type=a,this.errors=[],this.result=null,this.retry_results=[],this.timeout=null}async execute(){this.timeout||(this.timeout=new Promise((e,r)=>setTimeout(r,this.max_timeout_ms,new Error(`Step "${this.name}" timed out after ${this.max_timeout_ms}ms`)))),this.markAsRunning();try{this.result=await Promise.race([this._callable(),this.timeout])}catch(e){if(this.max_retries&&this.retry_count<this.max_retries)this.retry_count++,this.retry_results.push({retry_count:this.retry_count,result:await this.execute()});else if(this.errors.push(e),this.markAsFailed(),this.getState("exit_on_error"))throw e}const{FAILED:t,COMPLETE:s}=this.getState("statuses")[this.base_type];return[t,s].includes(this.status)||this.markAsComplete(),["step","workflow"].includes(this.callable_type)?this.#t:this}getCallableType(t){if(t&&t.base_type===o.WORKFLOW)return"workflow";if(t&&t.base_type===o.STEP)return"step";if(typeof t=="function")return"function";throw new Error("Invalid callable type. Must be one of function, Step, or Workflow.")}setParentWorkflowValue(t,s,e){const r=this.getState("workflows")[t];if(!r)throw new Error(`Parent workflow with ID ${t} not found.`);r[s]=e}set callable(t){this.callable_type=this.getCallableType(t),["step","workflow"].includes(this.callable_type)?(this.callable_type==="step"&&(t.parentWorkflowId=this.parentWorkflowId??null),this._callable=t.execute.bind(t)):this._callable=t.bind(this)}}export{_ as default};
|
|
2
|
+
//# sourceMappingURL=step.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/classes/steps/step.js"],
|
|
4
|
+
"sourcesContent": ["import Base from '../base.js';\nimport Workflow from '../workflow.js';\nimport { base_types, step_types } from '../../enums/index.js';\n\n/**\n * Step class representing an executable unit within a workflow.\n * @class Step\n * @extends Base\n */\nexport default class Step extends Base {\n static step_name = 'step';\n #callable_object = null;\n\n /**\n * Creates a new Step instance.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the step.\n * @param {Function|Step|Workflow} [options.callable=async () => {}] - Function, Step, or Workflow to execute.\n * @param {number} [options.max_retries=0] - Maximum number of retries on failure.\n * @param {number} [options.max_timeout_ms=30000] - Maximum execution time in milliseconds before timing out.\n * @param {string} [options.step_type=step_types.ACTION] - Type of the step.\n * @param {sub_step_types|null} [options.sub_step_type=null] - Sub-type of the step (use values from the sub_step_types enum).\n */\n constructor({\n name,\n callable = async () => {},\n max_retries = 0,\n max_timeout_ms = 30000,\n step_type = step_types.ACTION,\n sub_step_type = null,\n }) {\n super({ name, base_type: base_types.STEP });\n\n this.callable = callable;\n\n // Store off the original callable object, because if it's a Step or Workflow,\n // this.callable is set to the execute method of that object, but we may need to access its properties later.\n this.#callable_object = callable;\n\n this.max_retries = max_retries;\n this.retry_count = 0;\n this.max_timeout_ms = max_timeout_ms;\n this.step_type = step_type;\n this.sub_step_type = sub_step_type;\n\n this.errors = [];\n this.result = null;\n this.retry_results = [];\n this.timeout = null;\n }\n\n /**\n * Executes the step's callable function, Step, or Workflow.\n * @async\n * @returns {Promise<Step>} The step instance with execution results.\n */\n async execute() {\n if (!this.timeout ) {\n this.timeout = new Promise((_, reject) =>\n setTimeout(reject, this.max_timeout_ms, new Error(`Step \"${this.name}\" timed out after ${this.max_timeout_ms}ms`))\n );\n }\n\n this.markAsRunning();\n\n try {\n this.result = await Promise.race([this._callable(), this.timeout]);\n } catch (error) {\n if (this.max_retries && this.retry_count < this.max_retries) {\n this.retry_count++;\n this.retry_results.push({\n retry_count: this.retry_count,\n result: await this.execute(),\n });\n } else {\n this.errors.push(error);\n\n this.markAsFailed();\n\n if (this.getState('exit_on_error')) {\n throw error;\n }\n }\n\n }\n\n const { FAILED, COMPLETE } = this.getState('statuses')[this.base_type];\n\n if (! [FAILED, COMPLETE].includes(this.status)) {\n this.markAsComplete();\n }\n\n if (['step', 'workflow'].includes(this.callable_type)) {\n return this.#callable_object;\n }\n\n return this;\n }\n\n /**\n * Determines the type of the callable (function, step, or workflow).\n * @param {Function|Step|Workflow} callable - The callable to check.\n * @returns {string} The type: 'function', 'step', or 'workflow'.\n * @throws {Error} Throws if callable type is invalid.\n */\n getCallableType(callable) {\n if (callable && callable.base_type === base_types.WORKFLOW) {\n return 'workflow';\n } else if (callable && callable.base_type === base_types.STEP) {\n return 'step';\n } else if (typeof callable === 'function') {\n return 'function';\n } \n\n throw new Error('Invalid callable type. Must be one of function, Step, or Workflow.');\n }\n\n /**\n * Sets a value in the parent workflow's state.\n * @param {string} workflowId - ID of the parent workflow.\n * @param {string} path - Path in the workflow state to set.\n * @param {*} value - Value to set at the specified path.\n * @throws {Error} Throws if parent workflow is not found.\n */\n setParentWorkflowValue(workflowId, path, value) {\n const parentWorkflow = this.getState('workflows')[workflowId];\n\n if (!parentWorkflow) {\n throw new Error(`Parent workflow with ID ${workflowId} not found.`);\n }\n\n parentWorkflow[path] = value;\n }\n\n /**\n * Sets the callable for the step and determines its type.\n * @param {Function|Step|Workflow} callable - The callable to set.\n */\n set callable(callable) {\n this.callable_type = this.getCallableType(callable);\n\n if (['step', 'workflow'].includes(this.callable_type)) {\n if (this.callable_type === 'step') {\n callable.parentWorkflowId = this.parentWorkflowId ?? null;\n }\n\n this._callable = callable.execute.bind(callable);\n } else {\n this._callable = callable.bind(this);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAOA,MAAU,aACjB,MAAqB,iBACrB,OAAS,cAAAC,EAAY,cAAAC,MAAkB,uBAOvC,MAAOC,UAA2BH,CAAK,CATvC,MASuC,CAAAI,EAAA,aACrC,OAAO,UAAY,OACnBC,GAAmB,KAYnB,YAAY,CACV,KAAAC,EACA,SAAAC,EAAWH,EAAA,SAAY,CAAC,EAAb,YACX,YAAAI,EAAc,EACd,eAAAC,EAAiB,IACjB,UAAAC,EAAYR,EAAW,OACvB,cAAAS,EAAgB,IAClB,EAAG,CACD,MAAM,CAAE,KAAAL,EAAM,UAAWL,EAAW,IAAK,CAAC,EAE1C,KAAK,SAAWM,EAIhB,KAAKF,GAAmBE,EAExB,KAAK,YAAcC,EACnB,KAAK,YAAc,EACnB,KAAK,eAAiBC,EACtB,KAAK,UAAYC,EACjB,KAAK,cAAgBC,EAErB,KAAK,OAAS,CAAC,EACf,KAAK,OAAS,KACd,KAAK,cAAgB,CAAC,EACtB,KAAK,QAAU,IACjB,CAOA,MAAM,SAAU,CACT,KAAK,UACR,KAAK,QAAU,IAAI,QAAQ,CAACC,EAAGC,IAC7B,WAAWA,EAAQ,KAAK,eAAgB,IAAI,MAAM,SAAS,KAAK,IAAI,qBAAqB,KAAK,cAAc,IAAI,CAAC,CACnH,GAGF,KAAK,cAAc,EAEnB,GAAI,CACF,KAAK,OAAS,MAAM,QAAQ,KAAK,CAAC,KAAK,UAAU,EAAG,KAAK,OAAO,CAAC,CACnE,OAASC,EAAO,CACd,GAAI,KAAK,aAAe,KAAK,YAAc,KAAK,YAC9C,KAAK,cACL,KAAK,cAAc,KAAK,CACtB,YAAa,KAAK,YAClB,OAAQ,MAAM,KAAK,QAAQ,CAC7B,CAAC,UAED,KAAK,OAAO,KAAKA,CAAK,EAEtB,KAAK,aAAa,EAEd,KAAK,SAAS,eAAe,EAC/B,MAAMA,CAIZ,CAEA,KAAM,CAAE,OAAAC,EAAQ,SAAAC,CAAS,EAAI,KAAK,SAAS,UAAU,EAAE,KAAK,SAAS,EAMrE,MAJM,CAACD,EAAQC,CAAQ,EAAE,SAAS,KAAK,MAAM,GAC3C,KAAK,eAAe,EAGlB,CAAC,OAAQ,UAAU,EAAE,SAAS,KAAK,aAAa,EAC3C,KAAKX,GAGP,IACT,CAQA,gBAAgBE,EAAU,CACxB,GAAIA,GAAYA,EAAS,YAAcN,EAAW,SAChD,MAAO,WACF,GAAIM,GAAYA,EAAS,YAAcN,EAAW,KACvD,MAAO,OACF,GAAI,OAAOM,GAAa,WAC7B,MAAO,WAGT,MAAM,IAAI,MAAM,oEAAoE,CACtF,CASA,uBAAuBU,EAAYC,EAAMC,EAAO,CAC9C,MAAMC,EAAiB,KAAK,SAAS,WAAW,EAAEH,CAAU,EAE5D,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,2BAA2BH,CAAU,aAAa,EAGpEG,EAAeF,CAAI,EAAIC,CACzB,CAMA,IAAI,SAASZ,EAAU,CACrB,KAAK,cAAgB,KAAK,gBAAgBA,CAAQ,EAE9C,CAAC,OAAQ,UAAU,EAAE,SAAS,KAAK,aAAa,GAC9C,KAAK,gBAAkB,SACzBA,EAAS,iBAAmB,KAAK,kBAAoB,MAGvD,KAAK,UAAYA,EAAS,QAAQ,KAAKA,CAAQ,GAE/C,KAAK,UAAYA,EAAS,KAAK,IAAI,CAEvC,CACF",
|
|
6
|
+
"names": ["Base", "base_types", "step_types", "Step", "__name", "#callable_object", "name", "callable", "max_retries", "max_timeout_ms", "step_type", "sub_step_type", "_", "reject", "error", "FAILED", "COMPLETE", "workflowId", "path", "value", "parentWorkflow"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var h=Object.defineProperty;var c=(n,e)=>h(n,"name",{value:e,configurable:!0});import l from"./step.js";class i extends l{static{c(this,"SwitchStep")}static step_name="switch";constructor({name:e,cases:s=[],default_callable:t=c(async()=>{},"default_callable"),subject:a=null}){super({name:e,step_type:i.step_name}),this.cases=s,this._default_callable_type=this.getCallableType(t),this._default_callable_raw=t,this.default_callable=this._default_callable_type==="function"?t.bind(this):t.execute.bind(t),this.subject=a,this.callable=this.switch.bind(this)}async switch(){const e=typeof this.subject=="function"?this.subject():this.subject;for(const t of this.cases)if(t.switch_subject=e,await t.checkCondition())return this.log(this.getState("events.step.event_names.SWITCH_CASE_MATCHED"),`Case matched for step: ${this.name}, executing case callable`),(await t.execute()).result;const s=await this.default_callable();return this._default_callable_type!=="function"?s.result:s}}export{i as default};
|
|
2
|
+
//# sourceMappingURL=switch_step.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/classes/steps/switch_step.js"],
|
|
4
|
+
"sourcesContent": ["import Step from './step.js';\n\n/**\n * SwitchStep class for implementing switch/case logic in workflows.\n * Evaluates cases in order and executes the first matching case, or a default callable if no cases match.\n * @class SwitchStep\n * @extends Step\n */\nexport default class SwitchStep extends Step {\n static step_name = 'switch';\n\n /**\n * Creates a new SwitchStep instance.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the step.\n * @param {Array<Case|LogicStep>} [options.cases=[]] - Array of Case or LogicStep instances to evaluate. LogicStep instances MUST have conditional.subject set.\n * @param {Function|Step|Workflow} [options.default_callable=async () => {}] - Function, Step, or Workflow to execute if no cases match.\n * @param {*|Function} [options.subject=null] - Subject value to evaluate against each case. Can be a function that returns the value.\n */\n constructor({\n name,\n cases = [],\n default_callable = async () => {},\n subject = null\n }) {\n super({\n name,\n step_type: SwitchStep.step_name,\n });\n\n this.cases = cases;\n this._default_callable_type = this.getCallableType(default_callable);\n this._default_callable_raw = default_callable;\n this.default_callable = this._default_callable_type === 'function'\n ? default_callable.bind(this)\n : default_callable.execute.bind(default_callable);\n this.subject = subject;\n\n this.callable = this.switch.bind(this);\n }\n\n /**\n * Executes the switch logic by evaluating each case in order.\n * Returns the result of the first matching case, or the default callable if no match.\n * @returns {Promise<*>} The result of the matched case or default callable.\n */\n async switch() {\n // Resolve subject once - call it if it's a function\n const resolvedSubject = typeof this.subject === 'function' ? this.subject() : this.subject;\n \n for (const switch_case of this.cases) {\n switch_case.switch_subject = resolvedSubject;\n\n const is_matched = await switch_case.checkCondition();\n\n if (is_matched) {\n this.log(\n this.getState('events.step.event_names.SWITCH_CASE_MATCHED'),\n `Case matched for step: ${this.name}, executing case callable`\n );\n\n // Return the case's result value directly, not the Case object.\n // This keeps result structure consistent: switchStep.result contains the\n // callable's return value, matching how Step.result works.\n const caseResult = await switch_case.execute();\n return caseResult.result;\n }\n }\n\n // Unwrap Step/Workflow results for consistency with case results\n const defaultResult = await this.default_callable();\n if (this._default_callable_type !== 'function') {\n return defaultResult.result;\n }\n return defaultResult;\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAOA,MAAU,YAQjB,MAAOC,UAAiCD,CAAK,CAR7C,MAQ6C,CAAAE,EAAA,mBAC3C,OAAO,UAAY,SAUnB,YAAY,CACV,KAAAC,EACA,MAAAC,EAAQ,CAAC,EACT,iBAAAC,EAAmBH,EAAA,SAAY,CAAC,EAAb,oBACnB,QAAAI,EAAU,IACZ,EAAG,CACD,MAAM,CACJ,KAAAH,EACA,UAAWF,EAAW,SACxB,CAAC,EAED,KAAK,MAAQG,EACb,KAAK,uBAAyB,KAAK,gBAAgBC,CAAgB,EACnE,KAAK,sBAAwBA,EAC7B,KAAK,iBAAmB,KAAK,yBAA2B,WACpDA,EAAiB,KAAK,IAAI,EAC1BA,EAAiB,QAAQ,KAAKA,CAAgB,EAClD,KAAK,QAAUC,EAEf,KAAK,SAAW,KAAK,OAAO,KAAK,IAAI,CACvC,CAOA,MAAM,QAAS,CAEb,MAAMC,EAAkB,OAAO,KAAK,SAAY,WAAa,KAAK,QAAQ,EAAI,KAAK,QAEnF,UAAWC,KAAe,KAAK,MAK7B,GAJAA,EAAY,eAAiBD,EAEV,MAAMC,EAAY,eAAe,EAGlD,YAAK,IACH,KAAK,SAAS,6CAA6C,EAC3D,0BAA0B,KAAK,IAAI,2BACrC,GAKmB,MAAMA,EAAY,QAAQ,GAC3B,OAKtB,MAAMC,EAAgB,MAAM,KAAK,iBAAiB,EAClD,OAAI,KAAK,yBAA2B,WAC3BA,EAAc,OAEhBA,CACT,CACF",
|
|
6
|
+
"names": ["Step", "SwitchStep", "__name", "name", "cases", "default_callable", "subject", "resolvedSubject", "switch_case", "defaultResult"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var o=Object.defineProperty;var r=(i,t)=>o(i,"name",{value:t,configurable:!0});import a from"crypto";import n from"./base.js";import{base_types as p}from"../enums/index.js";class _ extends n{static{r(this,"Workflow")}constructor({name:t,exit_on_error:s=!1,steps:e=[],throw_on_empty:h=!1}){super({name:t,base_type:p.WORKFLOW}),this.initializeWorkflowState(),this.addSteps(e),this.exit_on_error=s,this.throw_on_empty=h,this.sessions={},this.current_session_id=null}async execute(){if(this.current_session_id||(this.current_session_id=a.randomUUID()),this.isEmpty()){if(this.throw_on_empty)throw new Error("Cannot execute an empty workflow");return this.markAsComplete(),this.prepareResult("Workflow is empty",null),this}this.markAsRunning();for(let t=0;t<this._steps.length;t++){if(this.should_break){this.log(this.getState("event_names.workflow").WORKFLOW_BREAK_EXECUTED,`Workflow "${this.name}" execution broken at step ${this._steps[t].name} - ${this._steps[t].id}.`);break}if(this.should_skip){this.log(this.getState("events.workflow.event_names.WORKFLOW_STEP_SKIPPED"),`Workflow "${this.name}" skipping step ${this._steps[t].name} - ${this._steps[t].id}.`),this.should_skip=!1;continue}this.current_step=this._steps[t].id;try{const s=await this.step();this.prepareResult("Success",s)}catch(s){if(this.markAsFailed(),this.prepareResult(`Workflow execution failed at step ${this.steps_by_id[this.current_step].name} - ${this.current_step}`,{error:s}),this.exit_on_error)return this}if(this.should_pause)return this.markAsPaused(),this.should_pause=!1,this}return this.markAsComplete(),this}async resume(){return this.should_pause=!1,this.timing.resume_time=new Date,this.getState("events.workflow").emit(this.getState("event_names.workflow").WORKFLOW_RESUMED,this.getState()),this.execute()}async step(){const t=this.steps_by_id[this.current_step];t.parentWorkflowId=this.id;const s=await t.execute();if(t.status===this.getState("statuses.step.FAILED"))throw t.errors[t.errors.length-1]??new Error(`Step "${t.name}" failed`);return s}addStep(t){if(typeof t.getCallableType!="function")throw new Error("Invalid step type. Must be an instance of Step.");Array.isArray(this._steps)||(this._steps=[]),(!this.steps_by_id||typeof this.steps_by_id!="object")&&(this.steps_by_id={}),this.steps_by_id[t.id]=t,t.parentWorkflowId=this.id,this._steps.push(t)}addStepAtIndex(t,s){(!this.steps_by_id||typeof this.steps_by_id!="object")&&(this.steps_by_id={}),this.steps_by_id[t.id]=t,t.parentWorkflowId=this.id,this._steps.splice(s,0,t)}addSteps(t){t.forEach(s=>this.addStep(s))}clearSteps(){this._steps=[]}closeCurrentSession(){this.current_session_id&&(this.sessions[this.current_session_id]={results:[...this.results],status:this.status,timing:{...this.timing},closed_at:new Date},this.current_session_id=null)}deleteStep(t){this._steps=this._steps.filter(s=>s.id!==t)}deleteStepByIndex(t){this._steps.splice(t,1)}initializeWorkflowState(){this.results=[],this.exit_on_error=!1,this.current_step=null,this.should_break=!1,this.should_continue=!1,this.should_pause=!1,this.should_skip=!1,this.status=this.getState("statuses.workflow").CREATED,this._steps=[],this.throw_on_empty=this.throw_on_empty,this.timing={...this.timing,create_time:new Date,pause_time:null,resume_time:null};const t=this.getState("workflows");t[this.id]=this,this.setState("workflows",t),this.log(this.getState("event_names.workflow").WORKFLOW_CREATED,`Workflow "${this.name}" initialized.`)}isEmpty(){return!this._steps||!this._steps.length}markAsComplete(){super.markAsComplete(),this.closeCurrentSession()}markAsCreated(){return this.timing.create_time=new Date,this.log(this.getState("event_names.workflow").WORKFLOW_CREATED,`Workflow "${this.name}" created.`),this.getState("statuses.workflow").CREATED}markAsFailed(){super.markAsFailed(),this.closeCurrentSession()}markAsPaused(){this.timing.pause_time=new Date,this.status=this.getState("statuses.workflow").PAUSED,this.getState("events.workflow").emit(this.getState("event_names.workflow").WORKFLOW_PAUSED,this.getState())}markAsResumed(){this.timing.resume_time=new Date,this.status=this.getState("statuses.workflow").RUNNING,this.getState("events.workflow").emit(this.getState("event_names.workflow").WORKFLOW_RESUMED,this.getState())}moveStep(t,s){const[e]=this._steps.splice(t,1);this._steps.splice(s,0,e),this.getState("events.workflow").emit(this.getState("event_names.workflow").WORKFLOW_STEP_MOVED,this.getState())}pause(){this.should_pause=!0,this.timing.pause_time=new Date,this.getState("events.workflow").emit(this.getState("event_names.workflow").WORKFLOW_PAUSED,this.getState())}popStep(){return this._steps.pop()}prepareResult(t,s){this.results.push({message:t,data:s})}pushStep(t){this.addStep(t)}pushSteps(t){t.forEach(s=>this.addStep(s))}shiftStep(){return this._steps.shift()}unshiftStep(t){if(typeof t.getCallableType!="function")throw new Error("Invalid step type. Must be an instance of Step.");(!this.steps_by_id||typeof this.steps_by_id!="object")&&(this.steps_by_id={}),this.steps_by_id[t.id]=t,t.parentWorkflowId=this.id,this._steps.unshift(t)}get steps(){return this._steps}set steps(t){t.forEach((s,e)=>{if(typeof s.getCallableType!="function")throw new Error(`Invalid step type. Step at index ${e} is not an instance of Step.`)}),this.addSteps(t)}}export{_ as default};
|
|
2
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/classes/workflow.js"],
|
|
4
|
+
"sourcesContent": ["import crypto from 'crypto';\nimport Base from './base.js';\nimport { base_types } from '../enums/index.js';\n\n/**\n * Workflow class for managing and executing a sequence of steps.\n * @class Workflow\n * @extends Base\n */\nexport default class Workflow extends Base {\n /**\n * Creates a new Workflow instance.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the workflow.\n * @param {boolean} [options.exit_on_error=false] - Whether to exit on error.\n * @param {Array<Step>} [options.steps=[]] - Array of steps to add to the workflow.\n * @param {boolean} [options.throw_on_empty=false] - Whether to throw error if workflow is empty.\n */\n constructor({\n name,\n exit_on_error = false,\n steps = [],\n throw_on_empty = false\n }) {\n super({ name, base_type: base_types.WORKFLOW });\n\n this.initializeWorkflowState();\n\n this.addSteps(steps);\n\n this.exit_on_error = exit_on_error;\n this.throw_on_empty = throw_on_empty;\n this.sessions = {};\n this.current_session_id = null;\n }\n\n /**\n * Executes the workflow by running all steps in sequence.\n * @async\n * @returns {Promise<Workflow>} The workflow instance with execution results.\n * @throws {Error} Throws if workflow is empty and throw_on_empty is true.\n */\n async execute() {\n if (!this.current_session_id) {\n this.current_session_id = crypto.randomUUID();\n }\n\n if (this.isEmpty()) {\n if (this.throw_on_empty) {\n throw new Error('Cannot execute an empty workflow');\n }\n\n this.markAsComplete();\n this.prepareResult('Workflow is empty', null);\n return this;\n }\n \n this.markAsRunning();\n\n for (let i = 0; i < this._steps.length; i++) {\n if (this.should_break) {\n 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}.`);\n break;\n }\n\n if (this.should_skip) {\n this.log(\n this.getState('events.workflow.event_names.WORKFLOW_STEP_SKIPPED'),\n `Workflow \"${this.name}\" skipping step ${this._steps[i].name} - ${this._steps[i].id}.`\n );\n this.should_skip = false;\n continue;\n }\n\n this.current_step = this._steps[i].id;\n\n try {\n const step_result = await this.step();\n this.prepareResult('Success', step_result);\n } catch (error) {\n this.markAsFailed();\n this.prepareResult(`Workflow execution failed at step ${this.steps_by_id[this.current_step].name} - ${this.current_step}`, { error });\n \n if (this.exit_on_error) {\n return this;\n }\n }\n\n if (this.should_pause) {\n this.markAsPaused();\n this.should_pause = false;\n return this;\n }\n }\n\n this.markAsComplete();\n return this;\n }\n\n /**\n * Resumes a paused workflow.\n * @async\n * @returns {Promise<Workflow>} The workflow instance.\n */\n async resume() {\n this.should_pause = false;\n this.timing.resume_time = new Date();\n\n this.getState('events.workflow').emit(\n this.getState('event_names.workflow').WORKFLOW_RESUMED,\n this.getState()\n );\n return this.execute();\n }\n\n /**\n * Executes a single step in the workflow.\n * @async\n * @returns {Promise<*>} The result of the step execution.\n */\n async step() {\n const step = this.steps_by_id[this.current_step];\n\n step.parentWorkflowId = this.id;\n const result = await step.execute();\n\n if (step.status === this.getState('statuses.step.FAILED')) {\n throw step.errors[step.errors.length - 1] ?? new Error(`Step \"${step.name}\" failed`);\n }\n\n return result;\n }\n\n /**\n * Adds a step to the workflow.\n * @param {Step} step - The step to add.\n * @throws {Error} Throws if step is not a valid Step instance.\n */\n addStep(step) {\n if (typeof step.getCallableType !== 'function') {\n throw new Error('Invalid step type. Must be an instance of Step.');\n }\n\n if (!Array.isArray(this._steps)) {\n this._steps = [];\n }\n\n if (!this.steps_by_id || typeof this.steps_by_id !== 'object') {\n this.steps_by_id = {};\n }\n\n this.steps_by_id[step.id] = step;\n\n step.parentWorkflowId = this.id;\n this._steps.push(step);\n }\n\n /**\n * Adds a step at a specific index in the workflow.\n * @param {Step} step - The step to add.\n * @param {number} index - The index at which to insert the step.\n */\n addStepAtIndex(step, index) {\n if (!this.steps_by_id || typeof this.steps_by_id !== 'object') {\n this.steps_by_id = {};\n }\n\n this.steps_by_id[step.id] = step;\n step.parentWorkflowId = this.id;\n this._steps.splice(index, 0, step);\n }\n\n /**\n * Adds multiple steps to the workflow.\n * @param {Step[]} steps - Array of steps to add.\n */\n addSteps(steps) {\n steps.forEach(step => this.addStep(step));\n }\n\n /**\n * Clears all steps from the workflow.\n */\n clearSteps() {\n this._steps = [];\n }\n\n /**\n * Closes the current session and stores a snapshot of the workflow state.\n */\n closeCurrentSession() {\n if (!this.current_session_id) {\n return;\n }\n\n this.sessions[this.current_session_id] = {\n results: [...this.results],\n status: this.status,\n timing: { ...this.timing },\n closed_at: new Date()\n };\n this.current_session_id = null;\n }\n\n /**\n * Deletes a step from the workflow by its ID.\n * @param {string} stepId - The ID of the step to delete.\n */\n deleteStep(stepId) {\n this._steps = this._steps.filter(step => step.id !== stepId);\n }\n\n /**\n * Deletes a step from the workflow by its index.\n * @param {number} index - The index of the step to delete.\n */\n deleteStepByIndex(index) {\n this._steps.splice(index, 1);\n }\n\n /**\n * Initializes the workflow state with default values.\n */\n initializeWorkflowState() {\n this.results = [];\n this.exit_on_error = false;\n this.current_step = null;\n this.should_break = false;\n this.should_continue = false;\n this.should_pause = false;\n this.should_skip = false;\n this.status = this.getState('statuses.workflow').CREATED;\n this._steps = [];\n this.throw_on_empty = this.throw_on_empty;\n this.timing = {\n ...this.timing,\n create_time: new Date(),\n pause_time: null,\n resume_time: null,\n }\n\n const workflows = this.getState('workflows');\n workflows[this.id] = this;\n this.setState('workflows', workflows);\n\n this.log(\n this.getState('event_names.workflow').WORKFLOW_CREATED,\n `Workflow \"${this.name}\" initialized.`\n );\n }\n\n /**\n * Checks if the workflow has no steps.\n * @returns {boolean} True if the workflow is empty.\n */\n isEmpty() {\n return !this._steps || !this._steps.length\n }\n\n /**\n * Marks the workflow as complete and closes the current session.\n */\n markAsComplete() {\n super.markAsComplete();\n this.closeCurrentSession();\n }\n\n /**\n * Marks the workflow as created.\n * @returns {string} The CREATED status.\n */\n markAsCreated() {\n this.timing.create_time = new Date();\n \n this.log(\n this.getState('event_names.workflow').WORKFLOW_CREATED,\n `Workflow \"${this.name}\" created.`\n );\n\n return this.getState('statuses.workflow').CREATED;\n }\n\n /**\n * Marks the workflow as failed and closes the current session.\n */\n markAsFailed() {\n super.markAsFailed();\n this.closeCurrentSession();\n }\n\n /**\n * Marks the workflow as paused.\n */\n markAsPaused() {\n this.timing.pause_time = new Date();\n this.status = this.getState('statuses.workflow').PAUSED;\n\n this.getState('events.workflow').emit(\n this.getState('event_names.workflow').WORKFLOW_PAUSED,\n this.getState()\n );\n }\n \n /**\n * Marks the workflow as resumed.\n */\n markAsResumed() {\n this.timing.resume_time = new Date();\n this.status = this.getState('statuses.workflow').RUNNING;\n\n this.getState('events.workflow').emit(\n this.getState('event_names.workflow').WORKFLOW_RESUMED,\n this.getState()\n );\n }\n\n /**\n * Moves a step from one index to another.\n * @param {number} fromIndex - The current index of the step.\n * @param {number} toIndex - The target index for the step.\n */\n moveStep(fromIndex, toIndex) {\n const [step] = this._steps.splice(fromIndex, 1);\n this._steps.splice(toIndex, 0, step);\n\n this.getState('events.workflow').emit(\n this.getState('event_names.workflow').WORKFLOW_STEP_MOVED,\n this.getState()\n );\n }\n\n /**\n * Pauses the workflow execution.\n */\n pause() {\n this.should_pause = true;\n this.timing.pause_time = new Date();\n\n this.getState('events.workflow').emit(\n this.getState('event_names.workflow').WORKFLOW_PAUSED,\n this.getState()\n );\n }\n\n /**\n * Removes and returns the last step from the workflow.\n * @returns {Step} The last step.\n */\n popStep() {\n return this._steps.pop();\n }\n\n /**\n * Prepares a result object and adds it to the results array.\n * @param {string} message - Result message.\n * @param {*} data - Result data.\n */\n prepareResult(message, data) {\n this.results.push({ message, data });\n }\n\n /**\n * Adds a step to the end of the workflow.\n * @param {Step} step - The step to add.\n */\n pushStep(step) {\n this.addStep(step);\n }\n\n /**\n * Adds multiple steps to the end of the workflow.\n * @param {Step[]} steps - Array of steps to add.\n */\n pushSteps(steps) {\n steps.forEach(step => this.addStep(step));\n }\n\n /**\n * Removes and returns the first step from the workflow.\n * @returns {Step} The first step.\n */\n shiftStep() {\n return this._steps.shift();\n }\n\n /**\n * Adds a step to the beginning of the workflow.\n * @param {Step} step - The step to add.\n * @throws {Error} Throws if step is not a valid Step instance.\n */\n unshiftStep(step) {\n if (typeof step.getCallableType !== 'function') {\n throw new Error('Invalid step type. Must be an instance of Step.');\n }\n\n if (!this.steps_by_id || typeof this.steps_by_id !== 'object') {\n this.steps_by_id = {};\n }\n\n this.steps_by_id[step.id] = step;\n\n step.parentWorkflowId = this.id;\n this._steps.unshift(step);\n }\n\n /**\n * Gets the array of steps in the workflow.\n * @returns {Step[]} Array of steps.\n */\n get steps() {\n return this._steps;\n }\n\n /**\n * Sets the steps array by adding multiple steps.\n * @param {Step[]} steps - Array of steps to add.\n */\n set steps(steps) {\n steps.forEach((step, index) => {\n if (typeof step.getCallableType !== 'function') {\n throw new Error(`Invalid step type. Step at index ${index} is not an instance of Step.`);\n }\n });\n\n this.addSteps(steps);\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAOA,MAAY,SACnB,OAAOC,MAAU,YACjB,OAAS,cAAAC,MAAkB,oBAO3B,MAAOC,UAA+BF,CAAK,CAT3C,MAS2C,CAAAG,EAAA,iBASzC,YAAY,CACV,KAAAC,EACA,cAAAC,EAAgB,GAChB,MAAAC,EAAQ,CAAC,EACT,eAAAC,EAAiB,EACnB,EAAG,CACD,MAAM,CAAE,KAAAH,EAAM,UAAWH,EAAW,QAAS,CAAC,EAE9C,KAAK,wBAAwB,EAE7B,KAAK,SAASK,CAAK,EAEnB,KAAK,cAAgBD,EACrB,KAAK,eAAiBE,EACtB,KAAK,SAAW,CAAC,EACjB,KAAK,mBAAqB,IAC5B,CAQA,MAAM,SAAU,CAKd,GAJK,KAAK,qBACR,KAAK,mBAAqBR,EAAO,WAAW,GAG1C,KAAK,QAAQ,EAAG,CAClB,GAAI,KAAK,eACP,MAAM,IAAI,MAAM,kCAAkC,EAGpD,YAAK,eAAe,EACpB,KAAK,cAAc,oBAAqB,IAAI,EACrC,IACT,CAEA,KAAK,cAAc,EAEnB,QAASS,EAAI,EAAGA,EAAI,KAAK,OAAO,OAAQA,IAAK,CAC3C,GAAI,KAAK,aAAc,CACrB,KAAK,IAAI,KAAK,SAAS,sBAAsB,EAAE,wBAAyB,aAAa,KAAK,IAAI,8BAA8B,KAAK,OAAOA,CAAC,EAAE,IAAI,MAAM,KAAK,OAAOA,CAAC,EAAE,EAAE,GAAG,EACzK,KACF,CAEA,GAAI,KAAK,YAAa,CACpB,KAAK,IACH,KAAK,SAAS,mDAAmD,EACjE,aAAa,KAAK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KAAK,CAAE,QAAAD,EAAS,KAAAC,CAAK,CAAC,CACrC,CAMA,SAASR,EAAM,CACb,KAAK,QAAQA,CAAI,CACnB,CAMA,UAAUL,EAAO,CACfA,EAAM,QAAQK,GAAQ,KAAK,QAAQA,CAAI,CAAC,CAC1C,CAMA,WAAY,CACV,OAAO,KAAK,OAAO,MAAM,CAC3B,CAOA,YAAYA,EAAM,CAChB,GAAI,OAAOA,EAAK,iBAAoB,WAClC,MAAM,IAAI,MAAM,iDAAiD,GAG/D,CAAC,KAAK,aAAe,OAAO,KAAK,aAAgB,YACnD,KAAK,YAAc,CAAC,GAGtB,KAAK,YAAYA,EAAK,EAAE,EAAIA,EAE5BA,EAAK,iBAAmB,KAAK,GAC7B,KAAK,OAAO,QAAQA,CAAI,CAC1B,CAMA,IAAI,OAAQ,CACV,OAAO,KAAK,MACd,CAMA,IAAI,MAAML,EAAO,CACfA,EAAM,QAAQ,CAACK,EAAME,IAAU,CAC7B,GAAI,OAAOF,EAAK,iBAAoB,WAClC,MAAM,IAAI,MAAM,oCAAoCE,CAAK,8BAA8B,CAE3F,CAAC,EAED,KAAK,SAASP,CAAK,CACrB,CACF",
|
|
6
|
+
"names": ["crypto", "Base", "base_types", "Workflow", "__name", "name", "exit_on_error", "steps", "throw_on_empty", "i", "step_result", "error", "step", "result", "index", "stepId", "workflows", "fromIndex", "toIndex", "message", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var S=Object.defineProperty;var n=(e,i)=>S(e,"name",{value:i,configurable:!0});import{describe as u,it as l,expect as s,beforeEach as c,vi as h,afterEach as f}from"vitest";import r from"./workflow.js";import o from"./steps/step.js";import d from"./state.js";import{base_types as y}from"../enums/index.js";u("Workflow",()=>{let e,i,m;c(()=>{i=h.spyOn(console,"log").mockImplementation(()=>{}),m=h.spyOn(console,"error").mockImplementation(()=>{})}),f(()=>{i.mockRestore(),m.mockRestore()}),u("constructor",()=>{l("should create a workflow with default options",()=>{e=new r({}),s(e.id).toBeDefined(),s(e.name).toMatch(/workflow-/),s(e.base_type).toBe(y.WORKFLOW),s(e.exit_on_error).toBe(!1),s(e.throw_on_empty).toBe(!1),s(e._steps).toEqual([]),s(e.results).toEqual([]),s(e.current_step).toBeNull()}),l("should create a workflow with custom name",()=>{e=new r({name:"Custom Workflow"}),s(e.name).toBe("Custom Workflow")}),l("should create a workflow with exit_on_error enabled",()=>{e=new r({exit_on_error:!0}),s(e.exit_on_error).toBe(!0)}),l("should create a workflow with throw_on_empty enabled",()=>{e=new r({throw_on_empty:!0}),s(e.throw_on_empty).toBe(!0)}),l("should initialize with provided steps",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e=new r({steps:[t,a]}),s(e._steps.length).toBe(2),s(e._steps[0]).toBe(t),s(e._steps[1]).toBe(a)}),l("should set timing.create_time",()=>{const t=new Date;e=new r({});const a=new Date;s(e.timing.create_time).toBeInstanceOf(Date),s(e.timing.create_time.getTime()).toBeGreaterThanOrEqual(t.getTime()),s(e.timing.create_time.getTime()).toBeLessThanOrEqual(a.getTime())})}),u("addStep",()=>{c(()=>{e=new r({})}),l("should add a step to the workflow",()=>{const t=new o({name:"Test Step",callable:n(async()=>"result","callable")});e.addStep(t),s(e._steps.length).toBe(1),s(e._steps[0]).toBe(t),s(e.steps_by_id[t.id]).toBe(t)}),l("should set parentWorkflowId on the step",()=>{const t=new o({name:"Test Step",callable:n(async()=>"result","callable")});e.addStep(t),s(t.parentWorkflowId).toBe(e.id)}),l("should throw error if step is not a valid Step instance",()=>{const t={name:"Invalid"};s(()=>e.addStep(t)).toThrow("Invalid step type. Must be an instance of Step.")}),l("should handle multiple steps",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addStep(t),e.addStep(a),s(e._steps.length).toBe(2),s(e._steps[0]).toBe(t),s(e._steps[1]).toBe(a)})}),u("addSteps",()=>{c(()=>{e=new r({})}),l("should add multiple steps at once",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")}),p=new o({name:"Step 3",callable:n(async()=>"result3","callable")});e.addSteps([t,a,p]),s(e._steps.length).toBe(3),s(e._steps[0]).toBe(t),s(e._steps[1]).toBe(a),s(e._steps[2]).toBe(p)}),l("should handle empty array",()=>{e.addSteps([]),s(e._steps.length).toBe(0)})}),u("addStepAtIndex",()=>{c(()=>{e=new r({})}),l("should insert step at specified index",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")}),p=new o({name:"Step 3",callable:n(async()=>"result3","callable")});e.addStep(t),e.addStep(p),e.addStepAtIndex(a,1),s(e._steps.length).toBe(3),s(e._steps[0]).toBe(t),s(e._steps[1]).toBe(a),s(e._steps[2]).toBe(p)}),l("should set parentWorkflowId on the step",()=>{const t=new o({name:"Test Step",callable:n(async()=>"result","callable")});e.addStepAtIndex(t,0),s(t.parentWorkflowId).toBe(e.id)})}),u("pushStep",()=>{c(()=>{e=new r({})}),l("should add step to the end of workflow",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.pushStep(t),e.pushStep(a),s(e._steps.length).toBe(2),s(e._steps[1]).toBe(a)})}),u("pushSteps",()=>{c(()=>{e=new r({})}),l("should add multiple steps to the end of workflow",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")}),p=new o({name:"Step 3",callable:n(async()=>"result3","callable")});e.pushStep(t),e.pushSteps([a,p]),s(e._steps.length).toBe(3),s(e._steps[2]).toBe(p)})}),u("unshiftStep",()=>{c(()=>{e=new r({})}),l("should add step to the beginning of workflow",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addStep(t),e.unshiftStep(a),s(e._steps.length).toBe(2),s(e._steps[0]).toBe(a),s(e._steps[1]).toBe(t)}),l("should set parentWorkflowId on the step",()=>{const t=new o({name:"Test Step",callable:n(async()=>"result","callable")});e.unshiftStep(t),s(t.parentWorkflowId).toBe(e.id)}),l("should throw error if step is not a valid Step instance",()=>{const t={name:"Invalid"};s(()=>e.unshiftStep(t)).toThrow("Invalid step type. Must be an instance of Step.")})}),u("popStep",()=>{c(()=>{e=new r({})}),l("should remove and return the last step",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addSteps([t,a]);const p=e.popStep();s(p).toBe(a),s(e._steps.length).toBe(1),s(e._steps[0]).toBe(t)}),l("should return undefined when workflow is empty",()=>{const t=e.popStep();s(t).toBeUndefined()})}),u("shiftStep",()=>{c(()=>{e=new r({})}),l("should remove and return the first step",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addSteps([t,a]);const p=e.shiftStep();s(p).toBe(t),s(e._steps.length).toBe(1),s(e._steps[0]).toBe(a)}),l("should return undefined when workflow is empty",()=>{const t=e.shiftStep();s(t).toBeUndefined()})}),u("deleteStep",()=>{c(()=>{e=new r({})}),l("should delete step by ID",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addSteps([t,a]),e.deleteStep(t.id),s(e._steps.length).toBe(1),s(e._steps[0]).toBe(a)}),l("should do nothing if step ID not found",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")});e.addStep(t),e.deleteStep("non-existent-id"),s(e._steps.length).toBe(1)})}),u("deleteStepByIndex",()=>{c(()=>{e=new r({})}),l("should delete step at specified index",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")}),p=new o({name:"Step 3",callable:n(async()=>"result3","callable")});e.addSteps([t,a,p]),e.deleteStepByIndex(1),s(e._steps.length).toBe(2),s(e._steps[0]).toBe(t),s(e._steps[1]).toBe(p)})}),u("moveStep",()=>{c(()=>{e=new r({})}),l("should move step from one index to another",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")}),p=new o({name:"Step 3",callable:n(async()=>"result3","callable")});e.addSteps([t,a,p]),e.moveStep(0,2),s(e._steps[0]).toBe(a),s(e._steps[1]).toBe(p),s(e._steps[2]).toBe(t)})}),u("clearSteps",()=>{c(()=>{e=new r({})}),l("should remove all steps from workflow",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addSteps([t,a]),e.clearSteps(),s(e._steps).toEqual([])})}),u("isEmpty",()=>{c(()=>{e=new r({})}),l("should return true for empty workflow",()=>{s(e.isEmpty()).toBe(!0)}),l("should return false for workflow with steps",()=>{const t=new o({name:"Test Step",callable:n(async()=>"result","callable")});e.addStep(t),s(e.isEmpty()).toBe(!1)})}),u("execute",()=>{c(()=>{e=new r({})}),l("should execute all steps in sequence",async()=>{const t=[],a=new o({name:"Step 1",callable:n(async()=>(t.push(1),"result1"),"callable")}),p=new o({name:"Step 2",callable:n(async()=>(t.push(2),"result2"),"callable")}),w=new o({name:"Step 3",callable:n(async()=>(t.push(3),"result3"),"callable")});e.addSteps([a,p,w]),await e.execute(),s(t).toEqual([1,2,3]),s(e.results.length).toBeGreaterThan(0)}),l("should mark workflow as complete after execution",async()=>{const t=new o({name:"Test Step",callable:n(async()=>"result","callable")});e.addStep(t),await e.execute(),s(e.status).toBe(d.get("statuses.workflow").COMPLETE)}),l("should throw error if empty and throw_on_empty is true",async()=>{e=new r({throw_on_empty:!0}),await s(e.execute()).rejects.toThrow("Cannot execute an empty workflow")}),l("should not throw error if empty and throw_on_empty is false",async()=>{e=new r({throw_on_empty:!1}),await e.execute(),s(e.status).toBe(d.get("statuses.workflow").COMPLETE)}),l("should continue execution if step fails and exit_on_error is false",async()=>{const t=new o({name:"Step 1",callable:n(async()=>{throw new Error("Step 1 error")},"callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e=new r({exit_on_error:!1}),e.addSteps([t,a]),await e.execute(),s(e._steps.length).toBe(2)}),l("should stop execution if step fails and exit_on_error is true",async()=>{const t=new o({name:"Step 1",callable:n(async()=>{throw new Error("Step 1 error")},"callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e=new r({exit_on_error:!0}),e.addSteps([t,a]),await e.execute(),s(e.status).toBe(d.get("statuses.workflow").FAILED)}),l("should pause execution when should_pause is set",async()=>{let t=0;const a=new o({name:"Step 1",callable:n(async()=>(t++,e.pause(),"result1"),"callable")}),p=new o({name:"Step 2",callable:n(async()=>(t++,"result2"),"callable")});e.addSteps([a,p]),await e.execute(),s(e.status).toBe(d.get("statuses.workflow").PAUSED),s(t).toBe(1)}),l("should skip step when should_skip is set",async()=>{let t=0;const a=new o({name:"Step 1",callable:n(async()=>(t++,e.setState("should_skip",!0),"result1"),"callable")}),p=new o({name:"Step 2",callable:n(async()=>(t++,"result2"),"callable")}),w=new o({name:"Step 3",callable:n(async()=>(t++,"result3"),"callable")});e.addSteps([a,p,w]),await e.execute(),s(t).toBe(2)}),l("should break execution when should_break is set",async()=>{let t=0;const a=new o({name:"Step 1",callable:n(async()=>(t++,e.setState("should_break",!0),"result1"),"callable")}),p=new o({name:"Step 2",callable:n(async()=>(t++,"result2"),"callable")});e.addSteps([a,p]),await e.execute(),s(t).toBe(1),s(e.status).toBe(d.get("statuses.workflow").COMPLETE)})}),u("resume",()=>{c(()=>{e=new r({})}),l("should resume a paused workflow",async()=>{let t=0;const a=new o({name:"Step 1",callable:n(async()=>(t++,e.pause(),"result1"),"callable")}),p=new o({name:"Step 2",callable:n(async()=>(t++,"result2"),"callable")});e.addSteps([a,p]),await e.execute(),s(e.status).toBe(d.get("statuses.workflow").PAUSED),s(t).toBe(1),await e.resume(),s(e.status).toBe(d.get("statuses.workflow").COMPLETE),s(t).toBe(2)}),l("should set resume_time when resuming",async()=>{const t=new o({name:"Step 1",callable:n(async()=>(e.pause(),"result"),"callable")});e.addStep(t),await e.execute();const a=new Date;await e.resume();const p=new Date;s(e.timing.resume_time).toBeInstanceOf(Date),s(e.timing.resume_time.getTime()).toBeGreaterThanOrEqual(a.getTime()),s(e.timing.resume_time.getTime()).toBeLessThanOrEqual(p.getTime())})}),u("pause",()=>{c(()=>{e=new r({})}),l("should set should_pause flag",()=>{e.pause(),s(e.should_pause).toBe(!0)}),l("should set pause_time",()=>{const t=new Date;e.pause();const a=new Date;s(e.timing.pause_time).toBeInstanceOf(Date),s(e.timing.pause_time.getTime()).toBeGreaterThanOrEqual(t.getTime()),s(e.timing.pause_time.getTime()).toBeLessThanOrEqual(a.getTime())})}),u("prepareResult",()=>{c(()=>{e=new r({})}),l("should add result object to results array",()=>{e.prepareResult("Test message",{data:"test"}),s(e.results.length).toBe(1),s(e.results[0]).toEqual({message:"Test message",data:{data:"test"}})}),l("should handle multiple results",()=>{e.prepareResult("Message 1","data1"),e.prepareResult("Message 2","data2"),s(e.results.length).toBe(2),s(e.results[0].message).toBe("Message 1"),s(e.results[1].message).toBe("Message 2")})}),u("steps getter/setter",()=>{c(()=>{e=new r({})}),l("should get steps array",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.addSteps([t,a]);const p=e.steps;s(p.length).toBe(2),s(p[0]).toBe(t),s(p[1]).toBe(a)}),l("should set steps using setter",()=>{const t=new o({name:"Step 1",callable:n(async()=>"result1","callable")}),a=new o({name:"Step 2",callable:n(async()=>"result2","callable")});e.steps=[t,a],s(e._steps.length).toBe(2),s(e._steps[0]).toBe(t),s(e._steps[1]).toBe(a)})}),u("status transitions",()=>{c(()=>{e=new r({})}),l("should mark as created",()=>{const t=e.markAsCreated();s(e.timing.create_time).toBeInstanceOf(Date),s(t).toBe(d.get("statuses.workflow").CREATED)}),l("should mark as paused",()=>{e.markAsPaused(),s(e.status).toBe(d.get("statuses.workflow").PAUSED),s(e.timing.pause_time).toBeInstanceOf(Date)}),l("should mark as resumed",()=>{e.markAsResumed(),s(e.status).toBe(d.get("statuses.workflow").RUNNING),s(e.timing.resume_time).toBeInstanceOf(Date)})}),u("integration tests",()=>{l("should execute a complex workflow with nested steps",async()=>{const t=[],a=new o({name:"Data Fetch",callable:n(async()=>(t.push("fetched"),{data:[1,2,3]}),"callable")}),p=new o({name:"Data Process",callable:n(async()=>(t.push("processed"),{data:[2,4,6]}),"callable")}),w=new o({name:"Data Save",callable:n(async()=>(t.push("saved"),{success:!0}),"callable")});e=new r({name:"Data Pipeline",steps:[a,p,w]}),await e.execute(),s(t).toEqual(["fetched","processed","saved"]),s(e.status).toBe(d.get("statuses.workflow").COMPLETE),s(e.results.length).toBeGreaterThan(0)}),l("should handle workflow with conditional execution",async()=>{let t=!1;const a=new o({name:"Check Condition",callable:n(async()=>(t=!0,{shouldContinue:!0}),"callable")}),p=new o({name:"Conditional Step",callable:n(async()=>(t||e.setState("should_skip",!0),{executed:t}),"callable")});e=new r({steps:[a,p]}),await e.execute(),s(t).toBe(!0),s(e.status).toBe(d.get("statuses.workflow").COMPLETE)})})});
|
|
2
|
+
//# sourceMappingURL=workflow.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/classes/workflow.test.js"],
|
|
4
|
+
"sourcesContent": ["import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';\nimport Workflow from './workflow.js';\nimport Step from './steps/step.js';\nimport State from './state.js';\nimport { step_types, base_types } from '../enums/index.js';\n\ndescribe('Workflow', () => {\n let workflow;\n let consoleLogSpy;\n let consoleErrorSpy;\n\n beforeEach(() => {\n // Suppress console output during tests\n consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});\n consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});\n });\n\n afterEach(() => {\n // Restore console\n consoleLogSpy.mockRestore();\n consoleErrorSpy.mockRestore();\n });\n\n describe('constructor', () => {\n it('should create a workflow with default options', () => {\n workflow = new Workflow({});\n \n expect(workflow.id).toBeDefined();\n expect(workflow.name).toMatch(/workflow-/);\n expect(workflow.base_type).toBe(base_types.WORKFLOW);\n expect(workflow.exit_on_error).toBe(false);\n expect(workflow.throw_on_empty).toBe(false);\n expect(workflow._steps).toEqual([]);\n expect(workflow.results).toEqual([]);\n expect(workflow.current_step).toBeNull();\n });\n\n it('should create a workflow with custom name', () => {\n workflow = new Workflow({ name: 'Custom Workflow' });\n \n expect(workflow.name).toBe('Custom Workflow');\n });\n\n it('should create a workflow with exit_on_error enabled', () => {\n workflow = new Workflow({ exit_on_error: true });\n \n expect(workflow.exit_on_error).toBe(true);\n });\n\n it('should create a workflow with throw_on_empty enabled', () => {\n workflow = new Workflow({ throw_on_empty: true });\n \n expect(workflow.throw_on_empty).toBe(true);\n });\n\n it('should initialize with provided steps', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow = new Workflow({ steps: [step1, step2] });\n \n expect(workflow._steps.length).toBe(2);\n expect(workflow._steps[0]).toBe(step1);\n expect(workflow._steps[1]).toBe(step2);\n });\n\n it('should set timing.create_time', () => {\n const before = new Date();\n workflow = new Workflow({});\n const after = new Date();\n \n expect(workflow.timing.create_time).toBeInstanceOf(Date);\n expect(workflow.timing.create_time.getTime()).toBeGreaterThanOrEqual(before.getTime());\n expect(workflow.timing.create_time.getTime()).toBeLessThanOrEqual(after.getTime());\n });\n });\n\n describe('addStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should add a step to the workflow', () => {\n const step = new Step({ name: 'Test Step', callable: async () => 'result' });\n \n workflow.addStep(step);\n \n expect(workflow._steps.length).toBe(1);\n expect(workflow._steps[0]).toBe(step);\n expect(workflow.steps_by_id[step.id]).toBe(step);\n });\n\n it('should set parentWorkflowId on the step', () => {\n const step = new Step({ name: 'Test Step', callable: async () => 'result' });\n \n workflow.addStep(step);\n \n expect(step.parentWorkflowId).toBe(workflow.id);\n });\n\n it('should throw error if step is not a valid Step instance', () => {\n const invalidStep = { name: 'Invalid' };\n \n expect(() => workflow.addStep(invalidStep)).toThrow('Invalid step type. Must be an instance of Step.');\n });\n\n it('should handle multiple steps', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addStep(step1);\n workflow.addStep(step2);\n \n expect(workflow._steps.length).toBe(2);\n expect(workflow._steps[0]).toBe(step1);\n expect(workflow._steps[1]).toBe(step2);\n });\n });\n\n describe('addSteps', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should add multiple steps at once', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n const step3 = new Step({ name: 'Step 3', callable: async () => 'result3' });\n \n workflow.addSteps([step1, step2, step3]);\n \n expect(workflow._steps.length).toBe(3);\n expect(workflow._steps[0]).toBe(step1);\n expect(workflow._steps[1]).toBe(step2);\n expect(workflow._steps[2]).toBe(step3);\n });\n\n it('should handle empty array', () => {\n workflow.addSteps([]);\n \n expect(workflow._steps.length).toBe(0);\n });\n });\n\n describe('addStepAtIndex', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should insert step at specified index', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n const step3 = new Step({ name: 'Step 3', callable: async () => 'result3' });\n \n workflow.addStep(step1);\n workflow.addStep(step3);\n workflow.addStepAtIndex(step2, 1);\n \n expect(workflow._steps.length).toBe(3);\n expect(workflow._steps[0]).toBe(step1);\n expect(workflow._steps[1]).toBe(step2);\n expect(workflow._steps[2]).toBe(step3);\n });\n\n it('should set parentWorkflowId on the step', () => {\n const step = new Step({ name: 'Test Step', callable: async () => 'result' });\n \n workflow.addStepAtIndex(step, 0);\n \n expect(step.parentWorkflowId).toBe(workflow.id);\n });\n });\n\n describe('pushStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should add step to the end of workflow', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.pushStep(step1);\n workflow.pushStep(step2);\n \n expect(workflow._steps.length).toBe(2);\n expect(workflow._steps[1]).toBe(step2);\n });\n });\n\n describe('pushSteps', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should add multiple steps to the end of workflow', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n const step3 = new Step({ name: 'Step 3', callable: async () => 'result3' });\n \n workflow.pushStep(step1);\n workflow.pushSteps([step2, step3]);\n \n expect(workflow._steps.length).toBe(3);\n expect(workflow._steps[2]).toBe(step3);\n });\n });\n\n describe('unshiftStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should add step to the beginning of workflow', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addStep(step1);\n workflow.unshiftStep(step2);\n \n expect(workflow._steps.length).toBe(2);\n expect(workflow._steps[0]).toBe(step2);\n expect(workflow._steps[1]).toBe(step1);\n });\n\n it('should set parentWorkflowId on the step', () => {\n const step = new Step({ name: 'Test Step', callable: async () => 'result' });\n \n workflow.unshiftStep(step);\n \n expect(step.parentWorkflowId).toBe(workflow.id);\n });\n\n it('should throw error if step is not a valid Step instance', () => {\n const invalidStep = { name: 'Invalid' };\n \n expect(() => workflow.unshiftStep(invalidStep)).toThrow('Invalid step type. Must be an instance of Step.');\n });\n });\n\n describe('popStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should remove and return the last step', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addSteps([step1, step2]);\n const popped = workflow.popStep();\n \n expect(popped).toBe(step2);\n expect(workflow._steps.length).toBe(1);\n expect(workflow._steps[0]).toBe(step1);\n });\n\n it('should return undefined when workflow is empty', () => {\n const popped = workflow.popStep();\n \n expect(popped).toBeUndefined();\n });\n });\n\n describe('shiftStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should remove and return the first step', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addSteps([step1, step2]);\n const shifted = workflow.shiftStep();\n \n expect(shifted).toBe(step1);\n expect(workflow._steps.length).toBe(1);\n expect(workflow._steps[0]).toBe(step2);\n });\n\n it('should return undefined when workflow is empty', () => {\n const shifted = workflow.shiftStep();\n \n expect(shifted).toBeUndefined();\n });\n });\n\n describe('deleteStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should delete step by ID', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addSteps([step1, step2]);\n workflow.deleteStep(step1.id);\n \n expect(workflow._steps.length).toBe(1);\n expect(workflow._steps[0]).toBe(step2);\n });\n\n it('should do nothing if step ID not found', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n \n workflow.addStep(step1);\n workflow.deleteStep('non-existent-id');\n \n expect(workflow._steps.length).toBe(1);\n });\n });\n\n describe('deleteStepByIndex', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should delete step at specified index', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n const step3 = new Step({ name: 'Step 3', callable: async () => 'result3' });\n \n workflow.addSteps([step1, step2, step3]);\n workflow.deleteStepByIndex(1);\n \n expect(workflow._steps.length).toBe(2);\n expect(workflow._steps[0]).toBe(step1);\n expect(workflow._steps[1]).toBe(step3);\n });\n });\n\n describe('moveStep', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should move step from one index to another', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n const step3 = new Step({ name: 'Step 3', callable: async () => 'result3' });\n \n workflow.addSteps([step1, step2, step3]);\n workflow.moveStep(0, 2);\n \n expect(workflow._steps[0]).toBe(step2);\n expect(workflow._steps[1]).toBe(step3);\n expect(workflow._steps[2]).toBe(step1);\n });\n });\n\n describe('clearSteps', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should remove all steps from workflow', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addSteps([step1, step2]);\n workflow.clearSteps();\n \n expect(workflow._steps).toEqual([]);\n });\n });\n\n describe('isEmpty', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should return true for empty workflow', () => {\n expect(workflow.isEmpty()).toBe(true);\n });\n\n it('should return false for workflow with steps', () => {\n const step = new Step({ name: 'Test Step', callable: async () => 'result' });\n workflow.addStep(step);\n \n expect(workflow.isEmpty()).toBe(false);\n });\n });\n\n describe('execute', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should execute all steps in sequence', async () => {\n const results = [];\n const step1 = new Step({ name: 'Step 1', callable: async () => { results.push(1); return 'result1'; } });\n const step2 = new Step({ name: 'Step 2', callable: async () => { results.push(2); return 'result2'; } });\n const step3 = new Step({ name: 'Step 3', callable: async () => { results.push(3); return 'result3'; } });\n \n workflow.addSteps([step1, step2, step3]);\n await workflow.execute();\n \n expect(results).toEqual([1, 2, 3]);\n expect(workflow.results.length).toBeGreaterThan(0);\n });\n\n it('should mark workflow as complete after execution', async () => {\n const step = new Step({ name: 'Test Step', callable: async () => 'result' });\n workflow.addStep(step);\n \n await workflow.execute();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').COMPLETE);\n });\n\n it('should throw error if empty and throw_on_empty is true', async () => {\n workflow = new Workflow({ throw_on_empty: true });\n \n await expect(workflow.execute()).rejects.toThrow('Cannot execute an empty workflow');\n });\n\n it('should not throw error if empty and throw_on_empty is false', async () => {\n workflow = new Workflow({ throw_on_empty: false });\n \n await workflow.execute();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').COMPLETE);\n });\n\n it('should continue execution if step fails and exit_on_error is false', async () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => { throw new Error('Step 1 error'); } });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow = new Workflow({ exit_on_error: false });\n workflow.addSteps([step1, step2]);\n \n await workflow.execute();\n \n expect(workflow._steps.length).toBe(2);\n });\n\n it('should stop execution if step fails and exit_on_error is true', async () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => { throw new Error('Step 1 error'); } });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow = new Workflow({ exit_on_error: true });\n workflow.addSteps([step1, step2]);\n \n await workflow.execute();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').FAILED);\n });\n\n it('should pause execution when should_pause is set', async () => {\n let executed = 0;\n const step1 = new Step({ \n name: 'Step 1', \n callable: async () => { \n executed++; \n workflow.pause();\n return 'result1'; \n } \n });\n const step2 = new Step({ name: 'Step 2', callable: async () => { executed++; return 'result2'; } });\n \n workflow.addSteps([step1, step2]);\n await workflow.execute();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').PAUSED);\n expect(executed).toBe(1);\n });\n\n it('should skip step when should_skip is set', async () => {\n let executed = 0;\n const step1 = new Step({ \n name: 'Step 1', \n callable: async () => { \n executed++; \n workflow.setState('should_skip', true);\n return 'result1'; \n } \n });\n const step2 = new Step({ name: 'Step 2', callable: async () => { executed++; return 'result2'; } });\n const step3 = new Step({ name: 'Step 3', callable: async () => { executed++; return 'result3'; } });\n \n workflow.addSteps([step1, step2, step3]);\n await workflow.execute();\n \n expect(executed).toBe(2); // step1 and step3, step2 skipped\n });\n\n it('should break execution when should_break is set', async () => {\n let executed = 0;\n const step1 = new Step({ \n name: 'Step 1', \n callable: async () => { \n executed++; \n workflow.setState('should_break', true);\n return 'result1'; \n } \n });\n const step2 = new Step({ name: 'Step 2', callable: async () => { executed++; return 'result2'; } });\n \n workflow.addSteps([step1, step2]);\n await workflow.execute();\n \n expect(executed).toBe(1);\n expect(workflow.status).toBe(State.get('statuses.workflow').COMPLETE);\n });\n });\n\n describe('resume', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should resume a paused workflow', async () => {\n let executed = 0;\n const step1 = new Step({ \n name: 'Step 1', \n callable: async () => { \n executed++; \n workflow.pause();\n return 'result1'; \n } \n });\n const step2 = new Step({ name: 'Step 2', callable: async () => { executed++; return 'result2'; } });\n \n workflow.addSteps([step1, step2]);\n await workflow.execute();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').PAUSED);\n expect(executed).toBe(1);\n \n await workflow.resume();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').COMPLETE);\n expect(executed).toBe(2);\n });\n\n it('should set resume_time when resuming', async () => {\n const step = new Step({ \n name: 'Step 1', \n callable: async () => { \n workflow.pause();\n return 'result'; \n } \n });\n \n workflow.addStep(step);\n await workflow.execute();\n \n const before = new Date();\n await workflow.resume();\n const after = new Date();\n \n expect(workflow.timing.resume_time).toBeInstanceOf(Date);\n expect(workflow.timing.resume_time.getTime()).toBeGreaterThanOrEqual(before.getTime());\n expect(workflow.timing.resume_time.getTime()).toBeLessThanOrEqual(after.getTime());\n });\n });\n\n describe('pause', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should set should_pause flag', () => {\n workflow.pause();\n \n expect(workflow.should_pause).toBe(true);\n });\n\n it('should set pause_time', () => {\n const before = new Date();\n workflow.pause();\n const after = new Date();\n \n expect(workflow.timing.pause_time).toBeInstanceOf(Date);\n expect(workflow.timing.pause_time.getTime()).toBeGreaterThanOrEqual(before.getTime());\n expect(workflow.timing.pause_time.getTime()).toBeLessThanOrEqual(after.getTime());\n });\n });\n\n describe('prepareResult', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should add result object to results array', () => {\n workflow.prepareResult('Test message', { data: 'test' });\n \n expect(workflow.results.length).toBe(1);\n expect(workflow.results[0]).toEqual({\n message: 'Test message',\n data: { data: 'test' }\n });\n });\n\n it('should handle multiple results', () => {\n workflow.prepareResult('Message 1', 'data1');\n workflow.prepareResult('Message 2', 'data2');\n \n expect(workflow.results.length).toBe(2);\n expect(workflow.results[0].message).toBe('Message 1');\n expect(workflow.results[1].message).toBe('Message 2');\n });\n });\n\n describe('steps getter/setter', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should get steps array', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.addSteps([step1, step2]);\n \n const steps = workflow.steps;\n expect(steps.length).toBe(2);\n expect(steps[0]).toBe(step1);\n expect(steps[1]).toBe(step2);\n });\n\n it('should set steps using setter', () => {\n const step1 = new Step({ name: 'Step 1', callable: async () => 'result1' });\n const step2 = new Step({ name: 'Step 2', callable: async () => 'result2' });\n \n workflow.steps = [step1, step2];\n \n expect(workflow._steps.length).toBe(2);\n expect(workflow._steps[0]).toBe(step1);\n expect(workflow._steps[1]).toBe(step2);\n });\n });\n\n describe('status transitions', () => {\n beforeEach(() => {\n workflow = new Workflow({});\n });\n\n it('should mark as created', () => {\n const status = workflow.markAsCreated();\n \n expect(workflow.timing.create_time).toBeInstanceOf(Date);\n expect(status).toBe(State.get('statuses.workflow').CREATED);\n });\n\n it('should mark as paused', () => {\n workflow.markAsPaused();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').PAUSED);\n expect(workflow.timing.pause_time).toBeInstanceOf(Date);\n });\n\n it('should mark as resumed', () => {\n workflow.markAsResumed();\n \n expect(workflow.status).toBe(State.get('statuses.workflow').RUNNING);\n expect(workflow.timing.resume_time).toBeInstanceOf(Date);\n });\n });\n\n describe('integration tests', () => {\n it('should execute a complex workflow with nested steps', async () => {\n const results = [];\n \n const step1 = new Step({ \n name: 'Data Fetch', \n callable: async () => { \n results.push('fetched');\n return { data: [1, 2, 3] }; \n } \n });\n \n const step2 = new Step({ \n name: 'Data Process', \n callable: async () => { \n results.push('processed');\n return { data: [2, 4, 6] }; \n } \n });\n \n const step3 = new Step({ \n name: 'Data Save', \n callable: async () => { \n results.push('saved');\n return { success: true }; \n } \n });\n \n workflow = new Workflow({ \n name: 'Data Pipeline',\n steps: [step1, step2, step3]\n });\n \n await workflow.execute();\n \n expect(results).toEqual(['fetched', 'processed', 'saved']);\n expect(workflow.status).toBe(State.get('statuses.workflow').COMPLETE);\n expect(workflow.results.length).toBeGreaterThan(0);\n });\n\n it('should handle workflow with conditional execution', async () => {\n let shouldExecuteStep2 = false;\n \n const step1 = new Step({ \n name: 'Check Condition', \n callable: async () => { \n shouldExecuteStep2 = true;\n return { shouldContinue: true }; \n } \n });\n \n const step2 = new Step({ \n name: 'Conditional Step', \n callable: async () => { \n if (!shouldExecuteStep2) {\n workflow.setState('should_skip', true);\n }\n return { executed: shouldExecuteStep2 }; \n } \n });\n \n workflow = new Workflow({ steps: [step1, step2] });\n await workflow.execute();\n \n expect(shouldExecuteStep2).toBe(true);\n expect(workflow.status).toBe(State.get('statuses.workflow').COMPLETE);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,YAAAA,EAAU,MAAAC,EAAI,UAAAC,EAAQ,cAAAC,EAAY,MAAAC,EAAI,aAAAC,MAAiB,SAChE,OAAOC,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E,EAAOK,CAAK,CAC7B,CAAC,EAED,MAAMV,EAAS,QAAQ,EAEvBR,EAAOqB,CAAO,EAAE,QAAQ,CAAC,UAAW,YAAa,OAAO,CAAC,EACzDrB,EAAOQ,EAAS,MAAM,EAAE,KAAKF,EAAM,IAAI,mBAAmB,EAAE,QAAQ,EACpEN,EAAOQ,EAAS,QAAQ,MAAM,EAAE,gBAAgB,CAAC,CACnD,CAAC,EAEDT,EAAG,oDAAqD,SAAY,CAClE,IAAI0B,EAAqB,GAEzB,MAAMd,EAAQ,IAAIN,EAAK,CACrB,KAAM,kBACN,SAAUO,EAAA,UACRa,EAAqB,GACd,CAAE,eAAgB,EAAK,GAFtB,WAIZ,CAAC,EAEKZ,EAAQ,IAAIR,EAAK,CACrB,KAAM,mBACN,SAAUO,EAAA,UACHa,GACHjB,EAAS,SAAS,cAAe,EAAI,EAEhC,CAAE,SAAUiB,CAAmB,GAJ9B,WAMZ,CAAC,EAEDjB,EAAW,IAAIJ,EAAS,CAAE,MAAO,CAACO,EAAOE,CAAK,CAAE,CAAC,EACjD,MAAML,EAAS,QAAQ,EAEvBR,EAAOyB,CAAkB,EAAE,KAAK,EAAI,EACpCzB,EAAOQ,EAAS,MAAM,EAAE,KAAKF,EAAM,IAAI,mBAAmB,EAAE,QAAQ,CACtE,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["describe", "it", "expect", "beforeEach", "vi", "afterEach", "Workflow", "Step", "State", "base_types", "workflow", "consoleLogSpy", "consoleErrorSpy", "step1", "__name", "step2", "before", "after", "step", "invalidStep", "step3", "popped", "shifted", "results", "executed", "steps", "status", "shouldExecuteStep2"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/base_types.js"],
|
|
4
|
+
"sourcesContent": ["const base_types = {\n STEP: 'step',\n WORKFLOW: 'workflow'\n};\n\nexport default base_types;\n"],
|
|
5
|
+
"mappings": "AAAA,MAAMA,EAAa,CACjB,KAAM,OACN,SAAU,UACZ,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["base_types", "base_types_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const _={EQUALS:"equals",GREATER_THAN:"greater_than",GREATER_THAN_OR_EQUAL:"greater_than_or_equal",LESS_THAN:"less_than",LESS_THAN_OR_EQUAL:"less_than_or_equal",NOT_EQUALS:"not_equals",STRICT_EQUALS:"strict_equals",STRICT_NOT_EQUALS:"strict_not_equals",SIGN_EQUALS:"==",SIGN_GREATER_THAN:">",SIGN_GREATER_THAN_OR_EQUAL:">=",SIGN_LESS_THAN:"<",SIGN_LESS_THAN_OR_EQUAL:"<=",SIGN_NOT_EQUALS:"!=",SIGN_STRICT_EQUALS:"===",SIGN_STRICT_NOT_EQUALS:"!==",STRING_CONTAINS:"string_contains",STRING_INCLUDES:"string_includes",STRING_NOT_CONTAINS:"string_not_contains",STRING_NOT_INCLUDES:"string_not_includes",STRING_STARTS_WITH:"string_starts_with",STRING_ENDS_WITH:"string_ends_with",ARRAY_CONTAINS:"array_contains",ARRAY_INCLUDES:"array_includes",ARRAY_NOT_CONTAINS:"array_not_contains",ARRAY_NOT_INCLUDES:"array_not_includes",EMPTY:"empty",NOT_EMPTY:"not_empty",REGEX_MATCH:"regex_match",REGEX_NOT_MATCH:"regex_not_match",IN:"in",NOT_IN:"not_in",NULLISH:"nullish",NOT_NULLISH:"not_nullish",IS_TYPE:"is_type",IS_NOT_TYPE:"is_not_type",CUSTOM_FUNCTION:"custom_function"};var T=_;export{T as default};
|
|
2
|
+
//# sourceMappingURL=conditional_step_comparators.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/conditional_step_comparators.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of comparison operators for conditional steps.\n * Provides both named and symbolic operator formats.\n * \n * @enum {string}\n * @readonly\n */\nconst conditional_step_comparators = {\n EQUALS: 'equals',\n GREATER_THAN: 'greater_than',\n GREATER_THAN_OR_EQUAL: 'greater_than_or_equal',\n LESS_THAN: 'less_than',\n LESS_THAN_OR_EQUAL: 'less_than_or_equal',\n NOT_EQUALS: 'not_equals',\n STRICT_EQUALS: 'strict_equals',\n STRICT_NOT_EQUALS: 'strict_not_equals',\n\n SIGN_EQUALS: '==',\n SIGN_GREATER_THAN: '>',\n SIGN_GREATER_THAN_OR_EQUAL: '>=',\n SIGN_LESS_THAN: '<',\n SIGN_LESS_THAN_OR_EQUAL: '<=',\n SIGN_NOT_EQUALS: '!=',\n SIGN_STRICT_EQUALS: '===',\n SIGN_STRICT_NOT_EQUALS: '!==',\n\n STRING_CONTAINS: 'string_contains',\n STRING_INCLUDES: 'string_includes',\n STRING_NOT_CONTAINS: 'string_not_contains',\n STRING_NOT_INCLUDES: 'string_not_includes',\n STRING_STARTS_WITH: 'string_starts_with',\n STRING_ENDS_WITH: 'string_ends_with',\n\n ARRAY_CONTAINS: 'array_contains',\n ARRAY_INCLUDES: 'array_includes',\n ARRAY_NOT_CONTAINS: 'array_not_contains',\n ARRAY_NOT_INCLUDES: 'array_not_includes',\n\n EMPTY: 'empty',\n NOT_EMPTY: 'not_empty',\n\n REGEX_MATCH: 'regex_match',\n REGEX_NOT_MATCH: 'regex_not_match',\n\n IN: 'in',\n NOT_IN: 'not_in',\n\n NULLISH: 'nullish',\n NOT_NULLISH: 'not_nullish',\n\n IS_TYPE: 'is_type',\n IS_NOT_TYPE: 'is_not_type',\n\n CUSTOM_FUNCTION: 'custom_function'\n};\n\nexport default conditional_step_comparators;\n"],
|
|
5
|
+
"mappings": "AAOA,MAAMA,EAA+B,CACnC,OAAQ,SACR,aAAc,eACd,sBAAuB,wBACvB,UAAW,YACX,mBAAoB,qBACpB,WAAY,aACZ,cAAe,gBACf,kBAAmB,oBAEnB,YAAa,KACb,kBAAmB,IACnB,2BAA4B,KAC5B,eAAgB,IAChB,wBAAyB,KACzB,gBAAiB,KACjB,mBAAoB,MACpB,uBAAwB,MAExB,gBAAiB,kBACjB,gBAAiB,kBACjB,oBAAqB,sBACrB,oBAAqB,sBACrB,mBAAoB,qBACpB,iBAAkB,mBAElB,eAAgB,iBAChB,eAAgB,iBAChB,mBAAoB,qBACpB,mBAAoB,qBAEpB,MAAO,QACP,UAAW,YAEX,YAAa,cACb,gBAAiB,kBAEjB,GAAI,KACJ,OAAQ,SAER,QAAS,UACT,YAAa,cAEb,QAAS,UACT,YAAa,cAEb,gBAAiB,iBACnB,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["conditional_step_comparators", "conditional_step_comparators_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/enums/delay_types.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Enumeration of delay types for DelayStep.\n * \n * @enum {string}\n * @readonly\n * @example\n * import delay_types from 'micro-flow';\n * \n * const delayStep = new DelayStep({\n * name: 'wait-5-seconds',\n * delay_type: delay_types.RELATIVE,\n * delay_duration: 5000\n * });\n */\nconst delay_types = {\n /**\n * Delay until a specific absolute timestamp or Date.\n * Use with delay_timestamp property.\n * @type {string}\n */\n ABSOLUTE: 'absolute',\n \n /**\n * Delay for a relative duration in milliseconds.\n * Use with delay_duration property.\n * @type {string}\n */\n RELATIVE: 'relative',\n};\n\nexport default delay_types;\n"],
|
|
5
|
+
"mappings": "AAcA,MAAMA,EAAc,CAMlB,SAAU,WAOV,SAAU,UACZ,EAEA,IAAOC,EAAQD",
|
|
6
|
+
"names": ["delay_types", "delay_types_default"]
|
|
7
|
+
}
|
|
@@ -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
|