@ronaldroe/micro-flow 0.1.2 → 0.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.
@@ -1,2 +1,2 @@
1
- var l=Object.defineProperty;var r=(n,t)=>l(n,"name",{value:t,configurable:!0});import a from"../base.js";import"../workflow.js";import{base_types as o,step_types as h}from"../../enums/index.js";class p extends a{static{r(this,"Step")}static step_name="step";#t=null;constructor({name:t,step_type:i=h.ACTION,callable:e=r(async()=>{},"callable"),sub_step_type:s=null}){super({name:t,base_type:o.STEP}),this.callable=e,this.#t=e,this.step_type=i,this.sub_step_type=s,this.errors=[],this.result=null,this.retry_results=[]}async execute(){this.markAsRunning();try{this.result=await this._callable()}catch(t){if(this.errors.push(t),this.markAsFailed(),this.timing.end_time=new Date,this.timing.execution_time_ms=this.timing.end_time-this.timing.start_time,this.getState("exit_on_error"))throw t}return this.status!==this.getState("statuses")[this.base_type].FAILED&&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,i,e){const s=this.getState("workflows")[t];if(!s)throw new Error(`Parent workflow with ID ${t} not found.`);s[i]=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{p as default};
1
+ var m=Object.defineProperty;var r=(h,t)=>m(h,"name",{value:t,configurable:!0});import u from"../base.js";import"../workflow.js";import{base_types as o,step_types as l}from"../../enums/index.js";class _ extends u{static{r(this,"Step")}static step_name="step";#t=null;constructor({name:t,callable:e=r(async()=>{},"callable"),max_retries:i=0,max_timeout_ms:s=3e4,step_type:n=l.ACTION,sub_step_type:a=null}){super({name:t,base_type:o.STEP}),this.callable=e,this.#t=e,this.max_retries=i,this.retry_count=0,this.max_timeout_ms=s,this.step_type=n,this.sub_step_type=a,this.errors=[],this.result=null,this.retry_results=[],this.timeout=null,this.start_time=null}async execute(){this.timeout||(this.timeout=new Promise((t,e)=>setTimeout(e,this.max_timeout_ms,new Error(`Step "${this.name}" timed out after ${this.max_timeout_ms}ms`)))),this.start_time||(this.start_time=new Date),this.markAsRunning();try{this.result=await Promise.race([this._callable(),this.timeout])}catch(t){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()}),this.timing.end_time=new Date,this.timing.execution_time_ms=this.timing.end_time-this.timing.start_time;else if(this.errors.push(t),this.timing.end_time=new Date,this.timing.execution_time_ms=this.timing.end_time-this.timing.start_time,this.markAsFailed(),this.getState("exit_on_error"))throw t}return this.status!==this.getState("statuses")[this.base_type].FAILED&&this.status!==this.getState("statuses")[this.base_type].COMPLETE&&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,e,i){const s=this.getState("workflows")[t];if(!s)throw new Error(`Parent workflow with ID ${t} not found.`);s[e]=i}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
2
  //# sourceMappingURL=step.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 {string} [options.step_type=step_types.ACTION] - Type of the step.\n * @param {Function|Step|Workflow} [options.callable=async () => {}] - Function, Step, or Workflow to execute.\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 step_type = step_types.ACTION,\n callable = async () => {},\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.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 }\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 this.markAsRunning();\n\n try {\n this.result = await this._callable();\n } catch (error) {\n this.errors.push(error);\n this.markAsFailed();\n\n this.timing.end_time = new Date();\n this.timing.execution_time_ms = this.timing.end_time - this.timing.start_time;\n\n if (this.getState('exit_on_error')) {\n throw error;\n }\n }\n\n if (this.status !== this.getState('statuses')[this.base_type].FAILED) {\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,KAUnB,YAAY,CACV,KAAAC,EACA,UAAAC,EAAYL,EAAW,OACvB,SAAAM,EAAWJ,EAAA,SAAY,CAAC,EAAb,YACX,cAAAK,EAAgB,IAClB,EAAG,CACD,MAAM,CAAE,KAAAH,EAAM,UAAWL,EAAW,IAAK,CAAC,EAE1C,KAAK,SAAWO,EAIhB,KAAKH,GAAmBG,EAExB,KAAK,UAAYD,EACjB,KAAK,cAAgBE,EAErB,KAAK,OAAS,CAAC,EACf,KAAK,OAAS,KACd,KAAK,cAAgB,CAAC,CACxB,CAOA,MAAM,SAAU,CACd,KAAK,cAAc,EAEnB,GAAI,CACF,KAAK,OAAS,MAAM,KAAK,UAAU,CACrC,OAASC,EAAO,CAOd,GANA,KAAK,OAAO,KAAKA,CAAK,EACtB,KAAK,aAAa,EAElB,KAAK,OAAO,SAAW,IAAI,KAC3B,KAAK,OAAO,kBAAoB,KAAK,OAAO,SAAW,KAAK,OAAO,WAE/D,KAAK,SAAS,eAAe,EAC/B,MAAMA,CAEV,CAMA,OAJI,KAAK,SAAW,KAAK,SAAS,UAAU,EAAE,KAAK,SAAS,EAAE,QAC5D,KAAK,eAAe,EAGlB,CAAC,OAAQ,UAAU,EAAE,SAAS,KAAK,aAAa,EAC3C,KAAKL,GAGP,IACT,CAQA,gBAAgBG,EAAU,CACxB,GAAIA,GAAYA,EAAS,YAAcP,EAAW,SAChD,MAAO,WACF,GAAIO,GAAYA,EAAS,YAAcP,EAAW,KACvD,MAAO,OACF,GAAI,OAAOO,GAAa,WAC7B,MAAO,WAGT,MAAM,IAAI,MAAM,oEAAoE,CACtF,CASA,uBAAuBG,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,SAASL,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", "step_type", "callable", "sub_step_type", "error", "workflowId", "path", "value", "parentWorkflow"]
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 this.start_time = 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 if (!this.start_time) {\n this.start_time = new Date();\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\n this.timing.end_time = new Date();\n this.timing.execution_time_ms = this.timing.end_time - this.timing.start_time;\n } else {\n this.errors.push(error);\n\n this.timing.end_time = new Date();\n this.timing.execution_time_ms = this.timing.end_time - this.timing.start_time;\n\n this.markAsFailed();\n\n if (this.getState('exit_on_error')) {\n throw error;\n }\n }\n\n }\n\n if (\n this.status !== this.getState('statuses')[this.base_type].FAILED\n && this.status !== this.getState('statuses')[this.base_type].COMPLETE\n ) {\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,KACf,KAAK,WAAa,IACpB,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,GAGG,KAAK,aACR,KAAK,WAAa,IAAI,MAGxB,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,EAED,KAAK,OAAO,SAAW,IAAI,KAC3B,KAAK,OAAO,kBAAoB,KAAK,OAAO,SAAW,KAAK,OAAO,mBAEnE,KAAK,OAAO,KAAKA,CAAK,EAEtB,KAAK,OAAO,SAAW,IAAI,KAC3B,KAAK,OAAO,kBAAoB,KAAK,OAAO,SAAW,KAAK,OAAO,WAEnE,KAAK,aAAa,EAEd,KAAK,SAAS,eAAe,EAC/B,MAAMA,CAIZ,CASA,OANE,KAAK,SAAW,KAAK,SAAS,UAAU,EAAE,KAAK,SAAS,EAAE,QACvD,KAAK,SAAW,KAAK,SAAS,UAAU,EAAE,KAAK,SAAS,EAAE,UAE7D,KAAK,eAAe,EAGlB,CAAC,OAAQ,UAAU,EAAE,SAAS,KAAK,aAAa,EAC3C,KAAKT,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,uBAAuBQ,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,SAASV,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", "workflowId", "path", "value", "parentWorkflow"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronaldroe/micro-flow",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "A lightweight, flexible workflow orchestration library for Node.js and browser environments. Build complex, sequential processes with ease using an intuitive API that supports conditional logic, flow control, event handling, and state management.",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -15,14 +15,18 @@ export default class Step extends Base {
15
15
  * Creates a new Step instance.
16
16
  * @param {Object} options - Configuration options.
17
17
  * @param {string} [options.name] - Name of the step.
18
- * @param {string} [options.step_type=step_types.ACTION] - Type of the step.
19
18
  * @param {Function|Step|Workflow} [options.callable=async () => {}] - Function, Step, or Workflow to execute.
19
+ * @param {number} [options.max_retries=0] - Maximum number of retries on failure.
20
+ * @param {number} [options.max_timeout_ms=30000] - Maximum execution time in milliseconds before timing out.
21
+ * @param {string} [options.step_type=step_types.ACTION] - Type of the step.
20
22
  * @param {sub_step_types|null} [options.sub_step_type=null] - Sub-type of the step (use values from the sub_step_types enum).
21
23
  */
22
24
  constructor({
23
25
  name,
24
- step_type = step_types.ACTION,
25
26
  callable = async () => {},
27
+ max_retries = 0,
28
+ max_timeout_ms = 30000,
29
+ step_type = step_types.ACTION,
26
30
  sub_step_type = null,
27
31
  }) {
28
32
  super({ name, base_type: base_types.STEP });
@@ -33,12 +37,17 @@ export default class Step extends Base {
33
37
  // this.callable is set to the execute method of that object, but we may need to access its properties later.
34
38
  this.#callable_object = callable;
35
39
 
40
+ this.max_retries = max_retries;
41
+ this.retry_count = 0;
42
+ this.max_timeout_ms = max_timeout_ms;
36
43
  this.step_type = step_type;
37
44
  this.sub_step_type = sub_step_type;
38
45
 
39
46
  this.errors = [];
40
47
  this.result = null;
41
48
  this.retry_results = [];
49
+ this.timeout = null;
50
+ this.start_time = null;
42
51
  }
43
52
 
44
53
  /**
@@ -47,23 +56,49 @@ export default class Step extends Base {
47
56
  * @returns {Promise<Step>} The step instance with execution results.
48
57
  */
49
58
  async execute() {
59
+ if (!this.timeout ) {
60
+ this.timeout = new Promise((_, reject) =>
61
+ setTimeout(reject, this.max_timeout_ms, new Error(`Step "${this.name}" timed out after ${this.max_timeout_ms}ms`))
62
+ );
63
+ }
64
+
65
+ if (!this.start_time) {
66
+ this.start_time = new Date();
67
+ }
68
+
50
69
  this.markAsRunning();
51
70
 
52
71
  try {
53
- this.result = await this._callable();
72
+ this.result = await Promise.race([this._callable(), this.timeout]);
54
73
  } catch (error) {
55
- this.errors.push(error);
56
- this.markAsFailed();
57
-
58
- this.timing.end_time = new Date();
59
- this.timing.execution_time_ms = this.timing.end_time - this.timing.start_time;
60
-
61
- if (this.getState('exit_on_error')) {
62
- throw error;
74
+ if (this.max_retries && this.retry_count < this.max_retries) {
75
+ this.retry_count++;
76
+ this.retry_results.push({
77
+ retry_count: this.retry_count,
78
+ result: await this.execute(),
79
+ });
80
+
81
+ this.timing.end_time = new Date();
82
+ this.timing.execution_time_ms = this.timing.end_time - this.timing.start_time;
83
+ } else {
84
+ this.errors.push(error);
85
+
86
+ this.timing.end_time = new Date();
87
+ this.timing.execution_time_ms = this.timing.end_time - this.timing.start_time;
88
+
89
+ this.markAsFailed();
90
+
91
+ if (this.getState('exit_on_error')) {
92
+ throw error;
93
+ }
63
94
  }
95
+
64
96
  }
65
97
 
66
- if (this.status !== this.getState('statuses')[this.base_type].FAILED) {
98
+ if (
99
+ this.status !== this.getState('statuses')[this.base_type].FAILED
100
+ && this.status !== this.getState('statuses')[this.base_type].COMPLETE
101
+ ) {
67
102
  this.markAsComplete();
68
103
  }
69
104