@ronaldroe/micro-flow 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +527 -0
  3. package/dist/index.js +2 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/src/classes/base.js +4 -0
  6. package/dist/src/classes/base.js.map +7 -0
  7. package/dist/src/classes/events/broadcast.js +2 -0
  8. package/dist/src/classes/events/broadcast.js.map +7 -0
  9. package/dist/src/classes/events/event.js +2 -0
  10. package/dist/src/classes/events/event.js.map +7 -0
  11. package/dist/src/classes/events/index.js +2 -0
  12. package/dist/src/classes/events/index.js.map +7 -0
  13. package/dist/src/classes/events/state_event.js +2 -0
  14. package/dist/src/classes/events/state_event.js.map +7 -0
  15. package/dist/src/classes/events/step_event.js +2 -0
  16. package/dist/src/classes/events/step_event.js.map +7 -0
  17. package/dist/src/classes/events/workflow_event.js +2 -0
  18. package/dist/src/classes/events/workflow_event.js.map +7 -0
  19. package/dist/src/classes/index.js +2 -0
  20. package/dist/src/classes/index.js.map +7 -0
  21. package/dist/src/classes/state.js +2 -0
  22. package/dist/src/classes/state.js.map +7 -0
  23. package/dist/src/classes/steps/case.js +2 -0
  24. package/dist/src/classes/steps/case.js.map +7 -0
  25. package/dist/src/classes/steps/conditional_step.js +2 -0
  26. package/dist/src/classes/steps/conditional_step.js.map +7 -0
  27. package/dist/src/classes/steps/delay_step.js +2 -0
  28. package/dist/src/classes/steps/delay_step.js.map +7 -0
  29. package/dist/src/classes/steps/flow_control_step.js +2 -0
  30. package/dist/src/classes/steps/flow_control_step.js.map +7 -0
  31. package/dist/src/classes/steps/index.js +2 -0
  32. package/dist/src/classes/steps/index.js.map +7 -0
  33. package/dist/src/classes/steps/logic_step.js +2 -0
  34. package/dist/src/classes/steps/logic_step.js.map +7 -0
  35. package/dist/src/classes/steps/loop_step.js +2 -0
  36. package/dist/src/classes/steps/loop_step.js.map +7 -0
  37. package/dist/src/classes/steps/step.js +2 -0
  38. package/dist/src/classes/steps/step.js.map +7 -0
  39. package/dist/src/classes/steps/switch_step.js +2 -0
  40. package/dist/src/classes/steps/switch_step.js.map +7 -0
  41. package/dist/src/classes/workflow.js +2 -0
  42. package/dist/src/classes/workflow.js.map +7 -0
  43. package/dist/src/classes/workflow.test.js +2 -0
  44. package/dist/src/classes/workflow.test.js.map +7 -0
  45. package/dist/src/enums/base_types.js +2 -0
  46. package/dist/src/enums/base_types.js.map +7 -0
  47. package/dist/src/enums/conditional_step_comparators.js +2 -0
  48. package/dist/src/enums/conditional_step_comparators.js.map +7 -0
  49. package/dist/src/enums/delay_types.js +2 -0
  50. package/dist/src/enums/delay_types.js.map +7 -0
  51. package/dist/src/enums/errors.js +6 -0
  52. package/dist/src/enums/errors.js.map +7 -0
  53. package/dist/src/enums/flow_control_types.js +2 -0
  54. package/dist/src/enums/flow_control_types.js.map +7 -0
  55. package/dist/src/enums/index.js +2 -0
  56. package/dist/src/enums/index.js.map +7 -0
  57. package/dist/src/enums/logic_step_types.js +2 -0
  58. package/dist/src/enums/logic_step_types.js.map +7 -0
  59. package/dist/src/enums/loop_types.js +2 -0
  60. package/dist/src/enums/loop_types.js.map +7 -0
  61. package/dist/src/enums/state_event_names.js +2 -0
  62. package/dist/src/enums/state_event_names.js.map +7 -0
  63. package/dist/src/enums/step_event_names.js +2 -0
  64. package/dist/src/enums/step_event_names.js.map +7 -0
  65. package/dist/src/enums/step_statuses.js +2 -0
  66. package/dist/src/enums/step_statuses.js.map +7 -0
  67. package/dist/src/enums/step_types.js +2 -0
  68. package/dist/src/enums/step_types.js.map +7 -0
  69. package/dist/src/enums/sub_step_types.js +2 -0
  70. package/dist/src/enums/sub_step_types.js.map +7 -0
  71. package/dist/src/enums/workflow_event_names.js +2 -0
  72. package/dist/src/enums/workflow_event_names.js.map +7 -0
  73. package/dist/src/enums/workflow_statuses.js +2 -0
  74. package/dist/src/enums/workflow_statuses.js.map +7 -0
  75. package/package.json +58 -0
  76. package/src/classes/base.js +143 -0
  77. package/src/classes/events/broadcast.js +57 -0
  78. package/src/classes/events/event.js +144 -0
  79. package/src/classes/events/index.js +5 -0
  80. package/src/classes/events/state_event.js +28 -0
  81. package/src/classes/events/step_event.js +28 -0
  82. package/src/classes/events/workflow_event.js +28 -0
  83. package/src/classes/index.js +5 -0
  84. package/src/classes/state.js +301 -0
  85. package/src/classes/steps/case.js +70 -0
  86. package/src/classes/steps/conditional_step.js +90 -0
  87. package/src/classes/steps/delay_step.js +103 -0
  88. package/src/classes/steps/flow_control_step.js +70 -0
  89. package/src/classes/steps/index.js +8 -0
  90. package/src/classes/steps/logic_step.js +148 -0
  91. package/src/classes/steps/loop_step.js +147 -0
  92. package/src/classes/steps/step.js +129 -0
  93. package/src/classes/steps/switch_step.js +64 -0
  94. package/src/classes/workflow.js +383 -0
  95. package/src/enums/base_types.js +6 -0
  96. package/src/enums/conditional_step_comparators.js +57 -0
  97. package/src/enums/delay_types.js +31 -0
  98. package/src/enums/errors.js +27 -0
  99. package/src/enums/flow_control_types.js +12 -0
  100. package/src/enums/index.js +14 -0
  101. package/src/enums/logic_step_types.js +16 -0
  102. package/src/enums/loop_types.js +14 -0
  103. package/src/enums/state_event_names.js +17 -0
  104. package/src/enums/step_event_names.js +25 -0
  105. package/src/enums/step_statuses.js +17 -0
  106. package/src/enums/step_types.js +15 -0
  107. package/src/enums/sub_step_types.js +20 -0
  108. package/src/enums/workflow_event_names.js +27 -0
  109. package/src/enums/workflow_statuses.js +21 -0
  110. package/src/index.js +2 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/classes/events/workflow_event.js"],
4
+ "sourcesContent": ["import { Event } from './index.js';\nimport { workflow_event_names } from '../../enums/index.js';\n\n/**\n * Manages workflow-specific events by extending the base Event class.\n * @class WorkflowEvent\n * @extends Event\n */\nexport default class WorkflowEvent extends Event {\n event_names = workflow_event_names;\n\n /**\n * Creates a new WorkflowEvent instance and registers all workflow events.\n * @constructor\n */\n constructor() {\n super();\n this.registerWorkflowEvents();\n }\n\n /**\n * Registers all workflow event names defined in the workflow_event_names enum.\n * @returns {void}\n */\n registerWorkflowEvents() {\n this.registerEvents(this.event_names);\n }\n}\n"],
5
+ "mappings": "+EAAA,OAAS,SAAAA,MAAa,aACtB,OAAS,wBAAAC,MAA4B,uBAOrC,MAAOC,UAAoCF,CAAM,CARjD,MAQiD,CAAAG,EAAA,sBAC/C,YAAcF,EAMd,aAAc,CACZ,MAAM,EACN,KAAK,uBAAuB,CAC9B,CAMA,wBAAyB,CACvB,KAAK,eAAe,KAAK,WAAW,CACtC,CACF",
6
+ "names": ["Event", "workflow_event_names", "WorkflowEvent", "__name"]
7
+ }
@@ -0,0 +1,2 @@
1
+ export*from"./events/index.js";import{default as t}from"./base.js";import{default as a}from"./state.js";import{default as p}from"./workflow.js";export*from"./steps/index.js";export{t as Base,a as State,p as Workflow};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/classes/index.js"],
4
+ "sourcesContent": ["export * from './events/index.js';\nexport { default as Base } from './base.js';\nexport { default as State } from './state.js';\nexport { default as Workflow } from './workflow.js';\nexport * from './steps/index.js';\n"],
5
+ "mappings": "AAAA,WAAc,oBACd,OAAoB,WAAXA,MAAuB,YAChC,OAAoB,WAAXA,MAAwB,aACjC,OAAoB,WAAXA,MAA2B,gBACpC,WAAc",
6
+ "names": ["default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var T=Object.defineProperty;var m=(w,e)=>T(w,"name",{value:e,configurable:!0});import{errors as f,warnings as _}from"../enums/errors.js";import{StepEvent as y,WorkflowEvent as b,StateEvent as g}from"./events/index.js";import{base_types as h,conditional_step_comparators as O,state_event_names as A,step_event_names as v,step_statuses as k,step_types as j,sub_step_types as d,workflow_event_names as R,workflow_statuses as S}from"../enums/index.js";const E={messages:{errors:f,warnings:_},statuses:{workflow:S,step:k},event_names:{workflow:R,step:v,state:A},events:{workflow:new b,step:new y,state:new g},types:{base_types:h,step_types:j,sub_step_types:d},workflows:{},conditional_step_comparators:O};let s={...E};const n=s.events,c=s.event_names;class i{static{m(this,"State")}static delete(e){if(!e)throw new Error(f.INVALID_STATE_PATH);const a=i.parsePath(e);let r=s;for(let t=0;t<a.length-1;t++){const o=a[t];if(!Object.prototype.hasOwnProperty.call(r,o)||typeof r[o]!="object")return;r=r[o]}delete r[a[a.length-1]],n.state.emit(c.state.DELETED,{state:s})}static async each(e,a){const r=i.get(e);if(Array.isArray(r))for(const[t,o]of r.entries())n.state.emit(c.state.EACH,{state:s}),await a(o,t);else if(typeof r=="object"&&Object.prototype.toString.call(r)==="[object Object]")for(const t of Object.keys(r))n.state.emit(c.state.EACH,{state:s}),await a(r[t],t);else throw new Error(f.VALUE_NOT_ITERABLE)}static freeze(){const e=Object.freeze(s);return n.state.emit(c.state.FROZEN,{state:s}),e}static get(e,a=null,r=null){let t=s;if(!e||["*",""].includes(e))return n.state.emit(c.state.GET,{state:t??a}),t;if(t=i.getFromPropertyPath(e,!1)??a,r)try{switch(r){case"string":t=String(t);break;case"number":t=Number(t);break;case"boolean":t=!!t;break;default:break}}catch(o){console.error("Error converting state value: ",o)}return n.state.emit(c.state.GET,{state:t}),t??a}static getFromPropertyPath(e,a=!0){const r=i.parsePath(e);let t=s;for(const o of r)if(t&&Object.prototype.hasOwnProperty.call(t,o))t=t[o];else return;return a&&n.state.emit(c.state.GET_FROM_PROPERTY_PATH,{state:s}),t}static getState(){return n.state.emit(c.state.GET_STATE,{state:s}),s}static merge(e){return s={...s,...e},n.state.emit(c.state.MERGE,{state:s}),s}static parsePath(e){const a=e.match(/[^.[\]]+|(?<=\[)([^\]]+)(?=\])/g);return a?a.map(r=>r.replace(/^['"]|['"]$/g,"")):[]}static reset(){return s={...E},n.state.emit(c.state.RESET,{state:s}),s}static set(e,a){if(!e)throw new Error(f.INVALID_STATE_PATH);n.state.emit(c.state.SET,{state:s}),i.setToPropertyPath(e,a,!1)}static setToPropertyPath(e,a,r=!0){const t=i.parsePath(e);let o=s;for(let l=0;l<t.length-1;l++){const p=t[l],u=t[l+1];if(!Object.prototype.hasOwnProperty.call(o,p)||typeof o[p]!="object"){const P=/^\d+$/.test(u);o[p]=P?[]:{}}o=o[p]}r&&n.state.emit(c.state.SET_TO_PROPERTY_PATH,{state:s}),o[t[t.length-1]]=a}}var L=i;export{L as default};
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/classes/state.js"],
4
+ "sourcesContent": ["import { errors, warnings } from '../enums/errors.js';\nimport { StepEvent, WorkflowEvent, StateEvent } from './events/index.js';\nimport {\n base_types,\n conditional_step_comparators,\n state_event_names,\n step_event_names,\n step_statuses,\n step_types,\n sub_step_types,\n workflow_event_names,\n workflow_statuses,\n} from '../enums/index.js';\n\nconst defaultState = {\n messages: {\n errors,\n warnings,\n },\n statuses: {\n workflow: workflow_statuses,\n step: step_statuses\n },\n event_names: {\n workflow: workflow_event_names,\n step: step_event_names,\n state: state_event_names,\n },\n events: {\n workflow: new WorkflowEvent(),\n step: new StepEvent(),\n state: new StateEvent(),\n },\n types: {\n base_types,\n step_types,\n sub_step_types,\n },\n workflows: {},\n conditional_step_comparators\n};\n\nlet state = { ...defaultState };\n\n// Module-level shortcuts for events and event_names\nconst events = state.events;\nconst event_names = state.event_names;\n\n/**\n * Singleton class representing the global state for workflows, steps, and processes.\n * Provides methods for managing state with getter/setter functionality, nested path access,\n * and immutability options. The state is shared across all workflow and step instances.\n * \n * @class State\n */\nclass State {\n /**\n * Deletes a state property using dot-notation or bracket-notation path access.\n * \n * @param {string} path - The path of the state property to delete (e.g., \"user.profile.email\" or \"users[0].email\").\n * @returns {void}\n * @throws {Error} Throws if path is empty or invalid.\n */\n static delete(path) {\n if (!path) {\n throw new Error(errors.INVALID_STATE_PATH);\n }\n \n const parts = State.parsePath(path);\n let current = state;\n \n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n \n if (!Object.prototype.hasOwnProperty.call(current, part) || typeof current[part] !== 'object') {\n return;\n }\n \n current = current[part];\n }\n \n delete current[parts[parts.length - 1]];\n\n events.state.emit(event_names.state.DELETED, { state });\n }\n\n /**\n * Iterates over a collection (array or object) located at the specified state path,\n * executing a callback function for each item.\n * \n * @param {string} path - The path of the state property to iterate over.\n * @param {Function} callback - The function to execute for each item in the collection.\n * @throws {Error} Throws if the state property at the path is not an array or object.\n */\n static async each(path, callback) {\n const collection = State.get(path);\n \n if (Array.isArray(collection)) {\n for (const [index, item] of collection.entries()) {\n events.state.emit(event_names.state.EACH, { state });\n await callback(item, index);\n }\n } else if (\n typeof collection === 'object' &&\n Object.prototype.toString.call(collection) === '[object Object]'\n ) {\n for (const key of Object.keys(collection)) {\n events.state.emit(event_names.state.EACH, { state });\n await callback(collection[key], key);\n }\n } else {\n throw new Error(errors.VALUE_NOT_ITERABLE);\n }\n }\n\n /**\n * Freezes the entire state object, making it immutable.\n * @returns {void}\n */\n static freeze() {\n const frozenState = Object.freeze(state);\n events.state.emit(event_names.state.FROZEN, { state });\n return frozenState;\n }\n\n /**\n * Gets the value of a state property using dot-notation or bracket-notation path access.\n * \n * @param {string} path - The path of the state property to get. Supports both dot notation\n * (e.g., \"user.profile.name\") and bracket notation (e.g., \"users[0].name\" or \"data['key-name']\").\n * Special values:\n * - Falsy values (null, undefined, false, \"\"): Returns entire state object\n * - \"*\": Returns entire state object\n * @param {*} [defaultValue=null] - Default value to return if the path doesn't exist.\n * @param {string} [type='string'] - The output type to convert the value to.\n * Supported types: \"string\", \"number\", \"boolean\".\n * @returns {*} The value of the state property, or defaultValue if not found. null if not found\n * and no defaultValue provided.\n * @throws {Error} Throws if the value cannot be converted to the specified type.\n */\n static get(path, defaultValue = null, type = null) {\n let gotten = state;\n if (!path || ['*', ''].includes(path)) {\n events.state.emit(event_names.state.GET, { state: gotten ?? defaultValue });\n return gotten;\n }\n\n gotten = State.getFromPropertyPath(path, false) ?? defaultValue;\n\n if (type) {\n try {\n switch (type) {\n case 'string':\n gotten = String(gotten);\n break;\n case 'number':\n gotten = Number(gotten);\n break;\n case 'boolean':\n gotten = Boolean(gotten);\n break;\n default:\n break;\n }\n } catch (error) {\n console.error(\"Error converting state value: \", error);\n }\n }\n\n events.state.emit(event_names.state.GET, { state: gotten });\n\n return gotten ?? defaultValue;\n }\n\n /**\n * Resolves a nested property path within the state object.\n * Supports both dot notation and bracket notation.\n * \n * @param {string} path - The path to the property (e.g., \"user.profile.name\", \"users[0].name\", \"data['key-name']\").\n * @param {boolean} [emit=true] - Whether to emit the GET_FROM_PROPERTY_PATH event.\n * @returns {*} The value at the specified path, or undefined if not found.\n */\n static getFromPropertyPath(path, emit = true) {\n const parts = State.parsePath(path);\n let current = state;\n\n for (const part of parts) {\n if (current && Object.prototype.hasOwnProperty.call(current, part)) {\n current = current[part];\n } else {\n return undefined;\n }\n }\n\n if (emit) {\n events.state.emit(event_names.state.GET_FROM_PROPERTY_PATH, { state });\n }\n\n return current;\n }\n\n /**\n * Gets the entire state object.\n * @returns {Object} The entire state object.\n */\n static getState() {\n events.state.emit(event_names.state.GET_STATE, { state });\n return state;\n }\n\n /**\n * Merges an object into the current State.\n * @param {Object} newState - The object to merge into the current State.\n * @returns {object} The updated state object.\n */\n static merge(newState) {\n state = { ...state, ...newState };\n events.state.emit(event_names.state.MERGE, { state });\n return state;\n }\n\n /**\n * Parses a property path string into an array of keys, supporting both dot notation\n * and bracket notation.\n * \n * @param {string} path - The path to parse (e.g., \"user.profile.name\", \"users[0].name\", \"data['key-name']\").\n * @returns {string[]} Array of property keys.\n */\n static parsePath(path) {\n const matches = path.match(/[^.[\\]]+|(?<=\\[)([^\\]]+)(?=\\])/g);\n \n if (!matches) {\n return [];\n }\n\n return matches.map(part => part.replace(/^['\"]|['\"]$/g, ''));\n }\n\n /**\n * Resets the state to its default values.\n * @returns {object} The reset state object.\n */\n static reset() {\n state = { ...defaultState };\n events.state.emit(event_names.state.RESET, { state });\n return state;\n }\n\n /**\n * Sets the value of a state property using dot-notation or bracket-notation path access.\n * Creates intermediate objects if they don't exist.\n * \n * @param {string} path - The path of the state property to set. Supports both dot notation\n * (e.g., \"user.profile.name\") and bracket notation (e.g., \"users[0].name\" or \"data['key-name']\").\n * @param {*} value - The value to set for the state property.\n * @returns {void}\n * @throws {Error} Throws if path is empty or invalid.\n */\n static set(path, value) {\n if (!path) {\n throw new Error(errors.INVALID_STATE_PATH);\n }\n\n events.state.emit(event_names.state.SET, { state });\n\n State.setToPropertyPath(path, value, false);\n }\n\n /**\n * Sets a nested property value within the state object based on a path.\n * Supports both dot notation and bracket notation. Creates intermediate objects/arrays as needed.\n * \n * @param {string} path - The path to the property (e.g., \"user.profile.name\", \"users[0].name\", \"data['key-name']\").\n * @param {*} value - The value to set at the specified path.\n * @param {boolean} [emit=true] - Whether to emit the SET_TO_PROPERTY_PATH event.\n */\n static setToPropertyPath(path, value, emit = true) {\n const parts = State.parsePath(path);\n let current = state;\n \n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n const nextPart = parts[i + 1];\n \n if (!Object.prototype.hasOwnProperty.call(current, part) || typeof current[part] !== 'object') {\n // Determine if next part is an array index (numeric)\n const isNextPartNumeric = /^\\d+$/.test(nextPart);\n current[part] = isNextPartNumeric ? [] : {};\n }\n current = current[part];\n }\n \n if (emit) {\n events.state.emit(event_names.state.SET_TO_PROPERTY_PATH, { state });\n }\n\n current[parts[parts.length - 1]] = value;\n }\n}\n\nexport default State;\n"],
5
+ "mappings": "+EAAA,OAAS,UAAAA,EAAQ,YAAAC,MAAgB,qBACjC,OAAS,aAAAC,EAAW,iBAAAC,EAAe,cAAAC,MAAkB,oBACrD,OACE,cAAAC,EACA,gCAAAC,EACA,qBAAAC,EACA,oBAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,wBAAAC,EACA,qBAAAC,MACK,oBAEP,MAAMC,EAAe,CACnB,SAAU,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QE,CAAI,EAAIgB,EAAoB,CAAC,EAAI,CAAC,CAC5C,CACAlB,EAAUA,EAAQE,CAAI,CACxB,CAEIW,GACFnB,EAAO,MAAM,KAAKC,EAAY,MAAM,qBAAsB,CAAE,MAAAF,CAAM,CAAC,EAGrEO,EAAQD,EAAMA,EAAM,OAAS,CAAC,CAAC,EAAIiB,CACrC,CACF,CAEA,IAAOG,EAAQvB",
6
+ "names": ["errors", "warnings", "StepEvent", "WorkflowEvent", "StateEvent", "base_types", "conditional_step_comparators", "state_event_names", "step_event_names", "step_statuses", "step_types", "sub_step_types", "workflow_event_names", "workflow_statuses", "defaultState", "state", "events", "event_names", "State", "__name", "path", "parts", "current", "i", "part", "callback", "collection", "index", "item", "key", "frozenState", "defaultValue", "type", "gotten", "error", "emit", "newState", "matches", "value", "nextPart", "isNextPartNumeric", "state_default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var a=Object.defineProperty;var s=(n,t)=>a(n,"name",{value:t,configurable:!0});import r from"./logic_step.js";import"../../enums/index.js";class o extends r{static{s(this,"Case")}static step_name="case";constructor({name:t,conditional:e={subject:null,operator:null,value:null},callable:i=s(async()=>{},"callable"),force_subject_override:c=!1}){super({name:t,step_type:o.step_name,callable:i}),this.conditional=e,this.force_subject_override=c,this.is_matched=!1}set switch_subject(t){const e=t!=null,i=this.conditional.subject!==null&&this.conditional.subject!==void 0;if(!e&&!i)throw new Error(`No subject set for case step: ${this.name}, using default equality check`);if(e&&(!i||this.force_subject_override)&&(this.conditional.subject=t),!this.conditionalIsValid())throw new Error(`Invalid conditional configuration for case step: ${this.name}`)}}export{o as default};
2
+ //# sourceMappingURL=case.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/classes/steps/case.js"],
4
+ "sourcesContent": ["import LogicStep from './logic_step.js';\nimport { conditional_step_comparators } from '../../enums/index.js';\n\n/**\n * Case class representing a single case in a switch statement.\n * Used in conjunction with SwitchStep to create switch/case logic.\n * @class Case\n * @extends LogicStep\n */\nexport default class Case extends LogicStep {\n static step_name = 'case';\n\n /**\n * Creates a new Case instance.\n * Note: Plain LogicStep instances can be used in place of Case, but they MUST have conditional.subject set.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the case.\n * @param {Object} [options.conditional] - Conditional configuration.\n * @param {*} [options.conditional.subject=null] - Subject to evaluate (typically set by SwitchStep).\n * @param {conditional_step_comparators|string} [options.conditional.operator=null] - Comparison operator.\n * @param {*} [options.conditional.value=null] - Value to compare against.\n * @param {Function|Step|Workflow} [options.callable=async () => {}] - Function, Step, or Workflow to execute when case matches.\n * @param {boolean} [options.force_subject_override=false] - Force override of subject even if already set.\n */\n constructor({\n name,\n conditional = {\n subject: null,\n operator: null,\n value: null,\n },\n callable = async () => {},\n force_subject_override = false,\n }) {\n super({\n name,\n step_type: Case.step_name,\n callable,\n });\n\n this.conditional = conditional;\n this.force_subject_override = force_subject_override;\n\n this.is_matched = false;\n }\n\n /**\n * Sets the switch subject from the parent SwitchStep.\n * Automatically sets the conditional subject if not already set or if force_subject_override is true.\n * @param {*} subject - The subject value from the SwitchStep.\n * @throws {Error} If no subject is provided and conditional.subject is not set.\n * @throws {Error} If the resulting conditional configuration is invalid.\n */\n set switch_subject(subject) {\n const subjectProvided = subject !== null && subject !== undefined;\n const hasExistingSubject = this.conditional.subject !== null && this.conditional.subject !== undefined;\n\n if (!subjectProvided && !hasExistingSubject) {\n throw new Error(`No subject set for case step: ${this.name}, using default equality check`);\n }\n\n if (subjectProvided && (!hasExistingSubject || this.force_subject_override)) {\n this.conditional.subject = subject;\n }\n\n if (!this.conditionalIsValid()) {\n throw new Error(`Invalid conditional configuration for case step: ${this.name}`);\n }\n }\n}\n"],
5
+ "mappings": "+EAAA,OAAOA,MAAe,kBACtB,MAA6C,uBAQ7C,MAAOC,UAA2BD,CAAU,CAT5C,MAS4C,CAAAE,EAAA,aAC1C,OAAO,UAAY,OAcnB,YAAY,CACV,KAAAC,EACA,YAAAC,EAAc,CACZ,QAAS,KACT,SAAU,KACV,MAAO,IACT,EACA,SAAAC,EAAWH,EAAA,SAAY,CAAC,EAAb,YACX,uBAAAI,EAAyB,EAC3B,EAAG,CACD,MAAM,CACJ,KAAAH,EACA,UAAWF,EAAK,UAChB,SAAAI,CACF,CAAC,EAED,KAAK,YAAcD,EACnB,KAAK,uBAAyBE,EAE9B,KAAK,WAAa,EACpB,CASA,IAAI,eAAeC,EAAS,CAC1B,MAAMC,EAAkBD,GAAY,KAC9BE,EAAqB,KAAK,YAAY,UAAY,MAAQ,KAAK,YAAY,UAAY,OAE7F,GAAI,CAACD,GAAmB,CAACC,EACvB,MAAM,IAAI,MAAM,iCAAiC,KAAK,IAAI,gCAAgC,EAO5F,GAJID,IAAoB,CAACC,GAAsB,KAAK,0BAClD,KAAK,YAAY,QAAUF,GAGzB,CAAC,KAAK,mBAAmB,EAC3B,MAAM,IAAI,MAAM,oDAAoD,KAAK,IAAI,EAAE,CAEnF,CACF",
6
+ "names": ["LogicStep", "Case", "__name", "name", "conditional", "callable", "force_subject_override", "subject", "subjectProvided", "hasExistingSubject"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var i=Object.defineProperty;var l=(n,t)=>i(n,"name",{value:t,configurable:!0});import s from"./logic_step.js";import"../../enums/index.js";class r extends s{static{l(this,"ConditionalStep")}static step_name="conditional";constructor({name:t,conditional:e={subject:null,operator:null,value:null},true_callable:a=l(async()=>{},"true_callable"),false_callable:o=l(async()=>{},"false_callable")}){super({name:t,conditional:e}),this.true_callable=a,this.false_callable=o,this.callable=this.conditional.bind(this)}async conditional(){const t=this.true_callable;t.parentWorkflowId=this.parentWorkflowId;const e=this.false_callable;e.parentWorkflowId=this.parentWorkflowId;let a=null;return this.checkCondition()?(this.log(this.getState("events.step.event_names.CONDITIONAL_TRUE_BRANCH_EXECUTED"),`Condition met for step: ${this.name}, executing true branch`),typeof t=="function"?a=await t():(t.parentWorkflowId=this.parentWorkflowId,a=await t.execute())):(this.log(this.getState("events.step.event_names.CONDITIONAL_FALSE_BRANCH_EXECUTED"),`Condition not met for step: ${this.name}, executing false branch`),typeof e=="function"?a=await e():(e.parentWorkflowId=this.parentWorkflowId,a=await e.execute())),{message:`Conditional step ${this.name} completed`,result:a}}}export{r as default};
2
+ //# sourceMappingURL=conditional_step.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/classes/steps/conditional_step.js"],
4
+ "sourcesContent": ["import LogicStep from './logic_step.js';\nimport { conditional_step_comparators } from '../../enums/index.js';\n\n/**\n * ConditionalStep class for branching logic based on conditions.\n * @class ConditionalStep\n * @extends LogicStep\n */\nexport default class ConditionalStep extends LogicStep {\n static step_name = 'conditional';\n\n /**\n * Creates a new ConditionalStep 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 {*} [options.conditional.subject] - Subject to evaluate.\n * @param {conditional_step_comparators|string} [options.conditional.operator] - Comparison operator.\n * @param {*} [options.conditional.value] - Value to compare against.\n * @param {Function|Step|Workflow} [options.true_callable=async () => {}] - Callable to execute if condition is true.\n * @param {Function|Step|Workflow} [options.false_callable=async () => {}] - Callable to execute if condition is false.\n */\n constructor({\n name,\n conditional = {\n subject: null,\n operator: null,\n value: null,\n },\n true_callable = async () => {},\n false_callable = async () => {},\n }) {\n super({\n name,\n conditional\n });\n\n this.true_callable = true_callable;\n this.false_callable = false_callable;\n\n this.callable = this.conditional.bind(this);\n }\n\n /**\n * Executes the appropriate branch based on the condition evaluation.\n * @async\n * @returns {Promise<*>} The result of the executed branch.\n */\n async conditional() {\n const true_callable = this.true_callable;\n true_callable.parentWorkflowId = this.parentWorkflowId;\n\n const false_callable = this.false_callable;\n false_callable.parentWorkflowId = this.parentWorkflowId;\n\n let result = null;\n\n if (this.checkCondition()) {\n this.log(\n this.getState('events.step.event_names.CONDITIONAL_TRUE_BRANCH_EXECUTED'),\n `Condition met for step: ${this.name}, executing true branch`\n );\n\n // Normally, the callable is automatically set according to its type\n // Here, they are set separately, so we need to account for types\n if (typeof true_callable === 'function') {\n result = await true_callable();\n } else {\n true_callable.parentWorkflowId = this.parentWorkflowId;\n result = await true_callable.execute();\n }\n } else {\n this.log(\n this.getState('events.step.event_names.CONDITIONAL_FALSE_BRANCH_EXECUTED'),\n `Condition not met for step: ${this.name}, executing false branch`\n );\n\n // Normally, the callable is automatically set according to its type\n // Here, they are set separately, so we need to account for types\n if (typeof false_callable === 'function') {\n result = await false_callable();\n } else {\n false_callable.parentWorkflowId = this.parentWorkflowId;\n result = await false_callable.execute();\n }\n }\n\n return { message: `Conditional step ${this.name} completed`, result };\n }\n}\n"],
5
+ "mappings": "+EAAA,OAAOA,MAAe,kBACtB,MAA6C,uBAO7C,MAAOC,UAAsCD,CAAU,CARvD,MAQuD,CAAAE,EAAA,wBACrD,OAAO,UAAY,cAanB,YAAY,CACV,KAAAC,EACA,YAAAC,EAAc,CACZ,QAAS,KACT,SAAU,KACV,MAAO,IACT,EACA,cAAAC,EAAgBH,EAAA,SAAY,CAAC,EAAb,iBAChB,eAAAI,EAAiBJ,EAAA,SAAY,CAAC,EAAb,iBACnB,EAAG,CACD,MAAM,CACJ,KAAAC,EACA,YAAAC,CACF,CAAC,EAED,KAAK,cAAgBC,EACrB,KAAK,eAAiBC,EAEtB,KAAK,SAAW,KAAK,YAAY,KAAK,IAAI,CAC5C,CAOA,MAAM,aAAc,CAClB,MAAMD,EAAgB,KAAK,cAC3BA,EAAc,iBAAmB,KAAK,iBAEtC,MAAMC,EAAiB,KAAK,eAC5BA,EAAe,iBAAmB,KAAK,iBAEvC,IAAIC,EAAS,KAEb,OAAI,KAAK,eAAe,GACtB,KAAK,IACH,KAAK,SAAS,0DAA0D,EACxE,2BAA2B,KAAK,IAAI,yBACtC,EAII,OAAOF,GAAkB,WAC3BE,EAAS,MAAMF,EAAc,GAE7BA,EAAc,iBAAmB,KAAK,iBACtCE,EAAS,MAAMF,EAAc,QAAQ,KAGvC,KAAK,IACH,KAAK,SAAS,2DAA2D,EACzE,+BAA+B,KAAK,IAAI,0BAC1C,EAII,OAAOC,GAAmB,WAC5BC,EAAS,MAAMD,EAAe,GAE9BA,EAAe,iBAAmB,KAAK,iBACvCC,EAAS,MAAMD,EAAe,QAAQ,IAInC,CAAE,QAAS,oBAAoB,KAAK,IAAI,aAAc,OAAAC,CAAO,CACtE,CACF",
6
+ "names": ["LogicStep", "ConditionalStep", "__name", "name", "conditional", "true_callable", "false_callable", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var o=Object.defineProperty;var n=(i,e)=>o(i,"name",{value:e,configurable:!0});import l from"./step.js";import{delay_types as h,step_types as r}from"../../enums/index.js";import p from"node-schedule";import{addMilliseconds as _}from"date-fns";class m extends l{static{n(this,"DelayStep")}static step_name="delay";constructor({name:e,absolute_timestamp:t=new Date,relative_delay_ms:s=0,delay_type:a=h.RELATIVE}){super({name:e,step_type:r.DELAY}),this.delay_type=a,this.absolute_timestamp=new Date(t),this.relative_delay_ms=s,this.callable=this[a].bind(this)}async absolute(){const e=new Date;return this.absolute_timestamp.getTime()<=e.getTime()?(this.log(this.getState("events.step.event_names.DELAY_STEP_ABSOLUTE_COMPLETE"),`No delay for step: ${this.name}. Continuing.`),this):this.delay(this.absolute_timestamp)}async delay(e){return new Promise(t=>{this.log(this.getState(`events.step.event_names.DELAY_STEP_${this.delay_type.toUpperCase()}_SCHEDULED`),`Delay scheduled for step: ${this.name} until ${e.toISOString()}`);const s=p.scheduleJob(e,()=>{this.log(this.getState(`events.step.event_names.DELAY_STEP_${this.delay_type.toUpperCase()}_COMPLETE`),`Delay complete for step: ${this.name}. Continuing.`),t(this)});this.scheduled_job=s})}async relative(){if(this.relative_delay_ms<=0)return this.log(this.getState("events.step.event_names.DELAY_STEP_RELATIVE_COMPLETE"),`No delay for step: ${this.name}. Continuing.`),this;const e=_(new Date,this.relative_delay_ms);return this.delay(e)}}export{m as default};
2
+ //# sourceMappingURL=delay_step.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/classes/steps/delay_step.js"],
4
+ "sourcesContent": ["import Step from './step.js';\nimport { delay_types, step_types } from '../../enums/index.js';\nimport schedule from 'node-schedule';\nimport { addMilliseconds } from 'date-fns';\n\n/**\n * DelayStep class for introducing delays in workflow execution.\n * Supports both absolute and relative delays.\n * @class DelayStep\n * @extends Step\n */\nexport default class DelayStep extends Step {\n static step_name = 'delay';\n\n /**\n * Creates a new DelayStep instance.\n * @param {Object} options - Configuration options.\n * @param {string} [options.name] - Name of the step.\n * @param {Date|string} [options.absolute_timestamp=new Date()] - Absolute timestamp to delay until.\n * @param {number} [options.relative_delay_ms=0] - Relative delay in milliseconds.\n * @param {string} [options.delay_type=delay_types.RELATIVE] - Type of delay ('absolute' or 'relative').\n */\n constructor({\n name,\n absolute_timestamp = new Date(),\n relative_delay_ms = 0,\n delay_type = delay_types.RELATIVE\n }) {\n super({\n name,\n step_type: step_types.DELAY,\n });\n\n this.delay_type = delay_type;\n this.absolute_timestamp = new Date(absolute_timestamp);\n this.relative_delay_ms = relative_delay_ms;\n\n this.callable = this[delay_type].bind(this);\n }\n\n /**\n * Executes an absolute delay until the specified timestamp. If the timestamp is in the past, it continues immediately.\n * @returns {Promise<Object>} Resolves with a message object when delay completes.\n */\n async absolute() {\n const now = new Date();\n\n if (this.absolute_timestamp.getTime() <= now.getTime()) {\n this.log(\n this.getState('events.step.event_names.DELAY_STEP_ABSOLUTE_COMPLETE'),\n `No delay for step: ${this.name}. Continuing.`\n );\n return this;\n }\n\n return this.delay(this.absolute_timestamp);\n }\n\n /** Schedules a delay until the specified date and time.\n * @param {Date} delay_until - The date and time to delay until.\n * @returns {Promise<DelayStep>} Resolves with the DelayStep instance when delay completes.\n */\n async delay(delay_until) {\n return new Promise((resolve) => {\n this.log(\n this.getState(\n `events.step.event_names.DELAY_STEP_${this.delay_type.toUpperCase()}_SCHEDULED`\n ),\n `Delay scheduled for step: ${this.name} until ${delay_until.toISOString()}`\n );\n\n const job = schedule.scheduleJob(delay_until, () => {\n this.log(\n this.getState(\n `events.step.event_names.DELAY_STEP_${this.delay_type.toUpperCase()}_COMPLETE`\n ),\n `Delay complete for step: ${this.name}. Continuing.`\n );\n resolve(this);\n });\n\n this.scheduled_job = job;\n });\n }\n\n /**\n * Executes a relative delay for the specified duration. If the delay duration is zero or negative, it continues immediately.\n * @returns {Promise<Object>} Resolves with a message object when delay completes.\n */\n async relative() {\n if (this.relative_delay_ms <= 0) {\n this.log(\n this.getState('events.step.event_names.DELAY_STEP_RELATIVE_COMPLETE'),\n `No delay for step: ${this.name}. Continuing.`\n );\n return this;\n }\n\n const delay_until = addMilliseconds(new Date(), this.relative_delay_ms);\n\n return this.delay(delay_until);\n }\n}\n"],
5
+ "mappings": "+EAAA,OAAOA,MAAU,YACjB,OAAS,eAAAC,EAAa,cAAAC,MAAkB,uBACxC,OAAOC,MAAc,gBACrB,OAAS,mBAAAC,MAAuB,WAQhC,MAAOC,UAAgCL,CAAK,CAX5C,MAW4C,CAAAM,EAAA,kBAC1C,OAAO,UAAY,QAUnB,YAAY,CACV,KAAAC,EACA,mBAAAC,EAAqB,IAAI,KACzB,kBAAAC,EAAoB,EACpB,WAAAC,EAAaT,EAAY,QAC3B,EAAG,CACD,MAAM,CACJ,KAAAM,EACA,UAAWL,EAAW,KACxB,CAAC,EAED,KAAK,WAAaQ,EAClB,KAAK,mBAAqB,IAAI,KAAKF,CAAkB,EACrD,KAAK,kBAAoBC,EAEzB,KAAK,SAAW,KAAKC,CAAU,EAAE,KAAK,IAAI,CAC5C,CAMA,MAAM,UAAW,CACf,MAAMC,EAAM,IAAI,KAEhB,OAAI,KAAK,mBAAmB,QAAQ,GAAKA,EAAI,QAAQ,GACnD,KAAK,IACH,KAAK,SAAS,sDAAsD,EACpE,sBAAsB,KAAK,IAAI,eACjC,EACO,MAGF,KAAK,MAAM,KAAK,kBAAkB,CAC3C,CAMA,MAAM,MAAMC,EAAa,CACvB,OAAO,IAAI,QAASC,GAAY,CAC9B,KAAK,IACH,KAAK,SACH,sCAAsC,KAAK,WAAW,YAAY,CAAC,YACrE,EACA,6BAA6B,KAAK,IAAI,UAAUD,EAAY,YAAY,CAAC,EAC3E,EAEA,MAAME,EAAMX,EAAS,YAAYS,EAAa,IAAM,CAClD,KAAK,IACH,KAAK,SACH,sCAAsC,KAAK,WAAW,YAAY,CAAC,WACrE,EACA,4BAA4B,KAAK,IAAI,eACvC,EACAC,EAAQ,IAAI,CACd,CAAC,EAED,KAAK,cAAgBC,CACvB,CAAC,CACH,CAMA,MAAM,UAAW,CACf,GAAI,KAAK,mBAAqB,EAC5B,YAAK,IACH,KAAK,SAAS,sDAAsD,EACpE,sBAAsB,KAAK,IAAI,eACjC,EACO,KAGT,MAAMF,EAAcR,EAAgB,IAAI,KAAQ,KAAK,iBAAiB,EAEtE,OAAO,KAAK,MAAMQ,CAAW,CAC/B,CACF",
6
+ "names": ["Step", "delay_types", "step_types", "schedule", "addMilliseconds", "DelayStep", "__name", "name", "absolute_timestamp", "relative_delay_ms", "delay_type", "now", "delay_until", "resolve", "job"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var n=Object.defineProperty;var s=(o,t)=>n(o,"name",{value:t,configurable:!0});import{LogicStep as i}from"./index.js";import l from"../../enums/flow_control_types.js";import"../../enums/index.js";class a extends i{static{s(this,"FlowControlStep")}static step_name="flow_control";constructor({conditional:t={subject:null,operator:null,value:null},name:r,flow_control_type:e=l.BREAK}){if(super({name:r,conditional:t}),!Object.values(l).includes(e))throw new Error(`Invalid flow control type: ${e}`);this.flow_control_type=e,this.callable=this.shouldFlowControl.bind(this)}async shouldFlowControl(){return this.checkCondition()?(this.log(this.getState("events.step.event_names.CONDITIONAL_TRUE_BRANCH_EXECUTED"),`Break condition met for step: ${this.name}`),this.setParentWorkflowValue(this.parentWorkflowId,`should_${this.flow_control_type}`,!0),!0):(this.log(this.getState("events.step.event_names.CONDITIONAL_FALSE_BRANCH_EXECUTED"),`Break condition not met for step: ${this.name}`),this.setParentWorkflowValue(this.parentWorkflowId,`should_${this.flow_control_type}`,!1),!1)}}export{a as default};
2
+ //# sourceMappingURL=flow_control_step.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/classes/steps/flow_control_step.js"],
4
+ "sourcesContent": ["import { LogicStep } from './index.js';\nimport flow_control_types from '../../enums/flow_control_types.js';\nimport { conditional_step_comparators } from '../../enums/index.js';\n\n/**\n * FlowControlStep class for controlling workflow execution flow (break, continue, skip, pause).\n * @class FlowControlStep\n * @extends LogicStep\n */\nexport default class FlowControlStep extends LogicStep {\n static step_name = 'flow_control';\n\n /**\n * Creates a new FlowControlStep instance.\n * @param {Object} options - Configuration options.\n * @param {Object} [options.conditional] - Conditional configuration.\n * @param {*} [options.conditional.subject] - Subject to evaluate.\n * @param {conditional_step_comparators|string} [options.conditional.operator] - Comparison operator.\n * @param {*} [options.conditional.value] - Value to compare against.\n * @param {string} [options.name] - Name of the step.\n * @param {string} [options.flow_control_type=flow_control_types.BREAK] - Type of flow control.\n * @throws {Error} Throws if flow_control_type is invalid.\n */\n constructor({\n conditional = {\n subject: null,\n operator: null,\n value: null,\n },\n name,\n flow_control_type = flow_control_types.BREAK,\n }) {\n super({\n name,\n conditional\n });\n\n if (!Object.values(flow_control_types).includes(flow_control_type)) {\n throw new Error(`Invalid flow control type: ${flow_control_type}`);\n }\n\n this.flow_control_type = flow_control_type;\n this.callable = this.shouldFlowControl.bind(this);\n }\n\n /**\n * Evaluates the condition and sets the appropriate flow control flag.\n * @async\n * @returns {Promise<boolean>} True if the flow control should be activated.\n */\n async shouldFlowControl() {\n if (this.checkCondition()) {\n this.log(\n this.getState('events.step.event_names.CONDITIONAL_TRUE_BRANCH_EXECUTED'),\n `Break condition met for step: ${this.name}`\n );\n this.setParentWorkflowValue(this.parentWorkflowId, `should_${this.flow_control_type}`, true);\n\n return true;\n } else {\n this.log(\n this.getState('events.step.event_names.CONDITIONAL_FALSE_BRANCH_EXECUTED'),\n `Break condition not met for step: ${this.name}`\n );\n this.setParentWorkflowValue(this.parentWorkflowId, `should_${this.flow_control_type}`, false);\n\n return false;\n }\n }\n}\n"],
5
+ "mappings": "+EAAA,OAAS,aAAAA,MAAiB,aAC1B,OAAOC,MAAwB,oCAC/B,MAA6C,uBAO7C,MAAOC,UAAsCF,CAAU,CATvD,MASuD,CAAAG,EAAA,wBACrD,OAAO,UAAY,eAanB,YAAY,CACV,YAAAC,EAAc,CACZ,QAAS,KACT,SAAU,KACV,MAAO,IACT,EACA,KAAAC,EACA,kBAAAC,EAAoBL,EAAmB,KACzC,EAAG,CAMD,GALA,MAAM,CACJ,KAAAI,EACA,YAAAD,CACF,CAAC,EAEG,CAAC,OAAO,OAAOH,CAAkB,EAAE,SAASK,CAAiB,EAC/D,MAAM,IAAI,MAAM,8BAA8BA,CAAiB,EAAE,EAGnE,KAAK,kBAAoBA,EACzB,KAAK,SAAW,KAAK,kBAAkB,KAAK,IAAI,CAClD,CAOA,MAAM,mBAAoB,CACxB,OAAI,KAAK,eAAe,GACtB,KAAK,IACH,KAAK,SAAS,0DAA0D,EACxE,iCAAiC,KAAK,IAAI,EAC5C,EACA,KAAK,uBAAuB,KAAK,iBAAkB,UAAU,KAAK,iBAAiB,GAAI,EAAI,EAEpF,KAEP,KAAK,IACH,KAAK,SAAS,2DAA2D,EACzE,qCAAqC,KAAK,IAAI,EAChD,EACA,KAAK,uBAAuB,KAAK,iBAAkB,UAAU,KAAK,iBAAiB,GAAI,EAAK,EAErF,GAEX,CACF",
6
+ "names": ["LogicStep", "flow_control_types", "FlowControlStep", "__name", "conditional", "name", "flow_control_type"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{default as o}from"./case.js";import{default as r}from"./conditional_step.js";import{default as p}from"./delay_step.js";import{default as d}from"./flow_control_step.js";import{default as m}from"./logic_step.js";import{default as x}from"./loop_step.js";import{default as i}from"./step.js";import{default as C}from"./switch_step.js";export{o as Case,r as ConditionalStep,p as DelayStep,d as FlowControlStep,m as LogicStep,x as LoopStep,i as Step,C as SwitchStep};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/classes/steps/index.js"],
4
+ "sourcesContent": ["export { 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 LogicStep } from './logic_step.js';\nexport { default as LoopStep } from './loop_step.js';\nexport { default as Step } from './step.js';\nexport { default as SwitchStep } from './switch_step.js';\n"],
5
+ "mappings": "AAAA,OAAoB,WAAXA,MAAuB,YAChC,OAAoB,WAAXA,MAAkC,wBAC3C,OAAoB,WAAXA,MAA4B,kBACrC,OAAoB,WAAXA,MAAkC,yBAC3C,OAAoB,WAAXA,MAA4B,kBACrC,OAAoB,WAAXA,MAA2B,iBACpC,OAAoB,WAAXA,MAAuB,YAChC,OAAoB,WAAXA,MAA6B",
6
+ "names": ["default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var n=Object.defineProperty;var o=(s,t)=>n(s,"name",{value:t,configurable:!0});import i from"./step.js";import{step_types as r}from"../../enums/index.js";class c extends i{static{o(this,"LogicStep")}static step_name="logic";constructor({name:t,callable:a=o(async()=>{},"callable"),conditional:e={operator:null,subject:null,value:null}}){super({name:t,base_type:r.LOGIC,callable:a}),this.setConditional(e)}checkCondition(){const t=this.conditional.subject,a=this.conditional.operator,e=this.conditional.value;switch(a){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"):case this.getState("conditional_step_comparators.IN"):return(Array.isArray(t)||typeof t=="string")&&t.includes(e);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"):case this.getState("conditional_step_comparators.NOT_IN"):return(Array.isArray(t)||typeof t=="string")&&!t.includes(e);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: ${a}`)}}conditionalIsValid(){return this.conditional.subject!==null&&this.conditional.subject!==void 0&&this.conditional.operator!==null&&this.conditional.operator!==void 0&&this.conditional.value!==null&&this.conditional.value!==void 0}setConditional(t){this.conditional={subject:t.subject,operator:t.operator,value:t.value}}}export{c 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 {*} [options.conditional.subject] - Subject to evaluate.\n * @param {conditional_step_comparators|string} [options.conditional.operator] - Comparison operator.\n * @param {*} [options.conditional.value] - Value to compare against.\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 base_type: step_types.LOGIC,\n callable\n });\n\n this.setConditional(conditional);\n }\n\n /**\n * Evaluates the conditional expression.\n * @returns {boolean} True if the condition is met.\n * @throws {Error} Throws if operator is unknown.\n */\n checkCondition() {\n const subject = this.conditional.subject;\n const operator = this.conditional.operator;\n const value = this.conditional.value;\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 case this.getState('conditional_step_comparators.IN'):\n return (Array.isArray(subject) || typeof subject === 'string') && subject.includes(value);\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 case this.getState('conditional_step_comparators.NOT_IN'):\n return (Array.isArray(subject) || typeof subject === 'string') && !subject.includes(value);\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 * @returns {boolean} True if conditional is valid.\n */\n conditionalIsValid() {\n return (\n this.conditional.subject !== null &&\n this.conditional.subject !== undefined &&\n this.conditional.operator !== null &&\n this.conditional.operator !== undefined &&\n this.conditional.value !== null &&\n this.conditional.value !== undefined\n );\n }\n\n /**\n * Sets the conditional properties.\n * @param {Object} conditional - Conditional configuration object.\n * @throws {Error} Throws if conditional is invalid.\n */\n setConditional(conditional) {\n this.conditional = { 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,CA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AAS,0CAA0C,EAC3D,OAAO,OAAOF,IAAYE,EAC5B,KAAK,KAAK,SAAS,8CAA8C,EAC/D,GAAI,OAAOA,GAAU,WACnB,MAAM,IAAI,MAAM,4BAA4BA,CAAK,EAAE,EAErD,OAAOA,EAAMF,CAAO,EACtB,QACE,MAAM,IAAI,MAAM,qBAAqBC,CAAQ,EAAE,CACnD,CACF,CAMA,oBAAqB,CACnB,OACE,KAAK,YAAY,UAAY,MAC7B,KAAK,YAAY,UAAY,QAC7B,KAAK,YAAY,WAAa,MAC9B,KAAK,YAAY,WAAa,QAC9B,KAAK,YAAY,QAAU,MAC3B,KAAK,YAAY,QAAU,MAE/B,CAOA,eAAeF,EAAa,CAC1B,KAAK,YAAc,CAAE,QAASA,EAAY,QAAS,SAAUA,EAAY,SAAU,MAAOA,EAAY,KAAM,CAC9G,CACF",
6
+ "names": ["Step", "step_types", "LogicStep", "__name", "name", "callable", "conditional", "subject", "operator", "value"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var h=Object.defineProperty;var r=(o,t)=>h(o,"name",{value:t,configurable:!0});import{loop_types as c,step_types as u}from"../../enums/index.js";import p from"./logic_step.js";import"../../enums/index.js";class f extends p{static{r(this,"LoopStep")}static step_name=u.LOOP;constructor({name:t,iterable:e,callable:s=r(async()=>{},"callable"),conditional:n={operator:null,subject:null,value:null},loop_type:l=c.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,this.callable=this[`${l}_loop`].bind(this),this.callable_type=this.getCallableType(s),this._callable=this.callable_type==="function"?s.bind(this):s.execute.bind(s)}async generator(){if(!this._callable.constructor.name.includes("Generator"))throw new Error("Iterable must be a generator function for generator loops");let t=0;for(const e of await this._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._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._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._callable());return{message:`While loop ${this.name} completed after ${t} iterations`,result:this.results}}}export{f 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 {*} [options.conditional.subject] - Subject to evaluate.\n * @param {conditional_step_comparators|string} [options.conditional.operator] - Comparison operator.\n * @param {*} [options.conditional.value] - Value to compare against.\n * @param {string} [options.loop_type=loop_types.FOR_EACH] - Type of loop ('for', 'for_each', 'while', or 'generator').\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 this.callable = this[`${loop_type}_loop`].bind(this);\n\n // When this.callable is set, it binds the callable function to this instance\n // so that it can access instance properties like current_item.\n // Because we're using a local method instead, we bind it here.\n this.callable_type = this.getCallableType(callable);\n this._callable = this.callable_type === 'function'\n ? callable.bind(this)\n : callable.execute.bind(callable);\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() {\n if (!this._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 for (const item of await this._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._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._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._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,KAe9B,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,CAAC,EAChB,KAAK,aAAe,KAEpB,KAAK,SAAW,KAAK,GAAGF,CAAS,OAAO,EAAE,KAAK,IAAI,EAKnD,KAAK,cAAgB,KAAK,gBAAgBF,CAAQ,EAClD,KAAK,UAAY,KAAK,gBAAkB,WACpCA,EAAS,KAAK,IAAI,EAClBA,EAAS,QAAQ,KAAKA,CAAQ,CACpC,CAOA,MAAM,WAAY,CAChB,GAAI,CAAC,KAAK,UAAU,YAAY,KAAK,SAAS,WAAW,EACvD,MAAM,IAAI,MAAM,2DAA2D,EAG7E,IAAIG,EAAa,EACjB,UAAWE,KAAQ,MAAM,KAAK,UAAU,EAGtC,GAFA,KAAK,QAAQ,KAAKA,CAAI,EAElB,EAAEF,GAAc,KAAK,eACvB,MAIJ,MAAO,CACL,QAAS,kBAAkB,KAAK,IAAI,oBAAoBA,CAAU,cAClE,OAAQ,KAAK,OACf,CACF,CAMA,MAAM,UAAW,CACf,IAAIG,EAAI,EACR,KAAOA,EAAI,KAAK,WAAYA,IAC1B,KAAK,QAAQ,KAAK,MAAM,KAAK,UAAU,CAAC,EAG1C,MAAO,CACL,QAAS,YAAY,KAAK,IAAI,oBAAoBA,CAAC,cACnD,OAAQ,KAAK,OACf,CACF,CAOA,MAAM,eAAgB,CACpB,GAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,yCAAyC,EAGvD,OAAO,KAAK,UAAa,aAC3B,KAAK,SAAW,KAAK,SAAS,GAGhC,IAAIH,EAAa,EACjB,UAAWE,KAAQ,KAAK,SACtBF,IACA,KAAK,aAAeE,EACpB,KAAK,QAAQ,KAAK,MAAM,KAAK,UAAU,CAAC,EAG1C,MAAO,CACL,QAAS,iBAAiB,KAAK,IAAI,oBAAoBF,CAAU,cACjE,OAAQ,KAAK,OACf,CACF,CAOA,MAAM,YAAa,CACjB,GAAI,CAAC,KAAK,mBAAmB,EAC3B,MAAM,IAAI,MAAM,+CAA+C,EAGjE,IAAIA,EAAa,EACjB,KAAO,KAAK,eAAe,GAAKA,EAAa,KAAK,gBAChDA,IACA,KAAK,QAAQ,KAAK,MAAM,KAAK,UAAU,CAAC,EAG1C,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", "item", "i"]
7
+ }
@@ -0,0 +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};
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 {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 {string} [options.sub_step_type=null] - Sub-type of the step.\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"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var o=Object.defineProperty;var s=(a,t)=>o(a,"name",{value:t,configurable:!0});import l from"./step.js";class i extends l{static{s(this,"SwitchStep")}static step_name="switch";constructor({name:t,cases:c=[],default_callable:e=s(async()=>{},"default_callable"),subject:n=null}){super({name:t,step_type:i.step_name}),this.cases=c;const h=this.getCallableType(e);this.default_callable=h==="function"?e.bind(this):e.execute.bind(e),this.subject=n,this.callable=this.switch.bind(this)}async switch(){for(const t of this.cases)if(t.switch_subject=this.subject,await t.checkCondition())return this.log(this.getState("events.step.event_names.SWITCH_CASE_MATCHED"),`Case matched for step: ${this.name}, executing case callable`),t.execute();return this.default_callable()}}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 {*} [options.subject=null] - Subject value to evaluate against each case.\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 const defaultCallableType = this.getCallableType(default_callable);\n this.default_callable = defaultCallableType === '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 for (const switch_case of this.cases) {\n switch_case.switch_subject = this.subject;\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 switch_case.execute();\n }\n }\n\n return this.default_callable();\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,MAAMG,EAAsB,KAAK,gBAAgBF,CAAgB,EACjE,KAAK,iBAAmBE,IAAwB,WAC5CF,EAAiB,KAAK,IAAI,EAC1BA,EAAiB,QAAQ,KAAKA,CAAgB,EAClD,KAAK,QAAUC,EAEf,KAAK,SAAW,KAAK,OAAO,KAAK,IAAI,CACvC,CAOA,MAAM,QAAS,CACb,UAAWE,KAAe,KAAK,MAK7B,GAJAA,EAAY,eAAiB,KAAK,QAEf,MAAMA,EAAY,eAAe,EAGlD,YAAK,IACH,KAAK,SAAS,6CAA6C,EAC3D,0BAA0B,KAAK,IAAI,2BACrC,EAEOA,EAAY,QAAQ,EAI/B,OAAO,KAAK,iBAAiB,CAC/B,CACF",
6
+ "names": ["Step", "SwitchStep", "__name", "name", "cases", "default_callable", "subject", "defaultCallableType", "switch_case"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var a=Object.defineProperty;var h=(i,t)=>a(i,"name",{value:t,configurable:!0});import{Base as o}from"./index.js";import{base_types as n}from"../enums/index.js";class p extends o{static{h(this,"Workflow")}constructor({name:t,exit_on_error:e=!1,steps:s=[],throw_on_empty:r=!1}){super({name:t,base_type:n.WORKFLOW}),this.initializeWorkflowState(),this.addSteps(s),this.exit_on_error=e,this.throw_on_empty=r}async execute(){if(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_pause)return this.markAsPaused(),this.should_pause=!1,this;if(this.should_break){this.should_break=!1,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 e=await this.step();this.prepareResult("Success",e)}catch(e){if(this.markAsFailed(),this.prepareResult(`Workflow execution failed at step ${this.steps_by_id[this.current_step].name} - ${this.current_step}`,{error:e}),this.exit_on_error)return 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 e=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 e}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,e){t.parentWorkflowId=this.id,this._steps.splice(e,0,t)}addSteps(t){t.forEach(e=>this.addStep(e))}clearSteps(){this._steps=[]}deleteStep(t){this._steps=this._steps.filter(e=>e.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}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}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,e){const[s]=this._steps.splice(t,1);this._steps.splice(e,0,s),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,e){this.results.push({message:t,data:e})}pushStep(t){this.addStep(t)}pushSteps(t){t.forEach(e=>this.addStep(e))}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((e,s)=>{if(typeof e.getCallableType!="function")throw new Error(`Invalid step type. Step at index ${s} is not an instance of Step.`)}),this.addSteps(t)}}export{p as default};
2
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/classes/workflow.js"],
4
+ "sourcesContent": ["import { Base } from './index.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 }\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.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_pause) {\n this.markAsPaused();\n this.should_pause = false;\n return this;\n }\n \n if (this.should_break) {\n this.should_break = false;\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\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 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 * 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 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 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,OAAS,QAAAA,MAAY,aACrB,OAAS,cAAAC,MAAkB,oBAO3B,MAAOC,UAA+BF,CAAK,CAR3C,MAQ2C,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,CACxB,CAQA,MAAM,SAAU,CACd,GAAI,KAAK,QAAQ,EAAG,CAClB,GAAI,KAAK,eACP,MAAM,IAAI,MAAM,kCAAkC,EAGpD,YAAK,eAAe,EACpB,KAAK,cAAc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C,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": ["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,MAAc,gBACrB,OAAOC,MAAU,kBACjB,OAAOC,MAAW,aAClB,OAAqB,cAAAC,MAAkB,oBAEvCT,EAAS,WAAY,IAAM,CACzB,IAAIU,EACAC,EACAC,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,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,2 @@
1
+ const e={STEP:"step",WORKFLOW:"workflow"};var t=e;export{t as default};
2
+ //# sourceMappingURL=base_types.js.map
@@ -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,2 @@
1
+ const e={ABSOLUTE:"absolute",RELATIVE:"relative"};var t=e;export{t as default};
2
+ //# sourceMappingURL=delay_types.js.map
@@ -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
+ }