{"_id":"@4o/operator","_rev":"7-38d95f215ffa25e49b1222afb5287371","name":"@4o/operator","dist-tags":{"latest":"2.0.0-alpha.1"},"versions":{"1.0.0":{"name":"@4o/operator","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@4o/operator@1.0.0","maintainers":[{"name":"ericksatelite","email":"erick.ruano@satelite.digital"}],"dist":{"shasum":"6085b6312688a693c7606678b4cebc1d542fc773","tarball":"https://registry.npmjs.org/@4o/operator/-/operator-1.0.0.tgz","fileCount":19,"integrity":"sha512-bQTYPSuYcy7+fM6eYiGTNBhYJOkgmpU5YN9ih7aP0hTxz2HzNOvw7y1XiuyMwh/ujLFNiimg8hEIVOdqTdmmeQ==","signatures":[{"sig":"MEUCIQCwTYWtpvfaEe7a1KlMEeQbZPtdDtahFtwDTnBzBZV/awIgKtNtQOr/n6gCZvIiH5oE/j8MKDW4EFVnsgdbDPseSPM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":237288},"main":"./dist/index.js","type":"module","module":"./dist/index.esm.js","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"}},"gitHead":"0504e83df6cef27241b0060a1d0d349a8e17bac1","scripts":{"lint":"eslint \"src/**/*.js\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js","build":"rollup -c","format":"prettier --write \"src/**/*.js\"","prepare":"yarn build","lint:fix":"eslint \"src/**/*.js\" --fix","test:watch":"jest --watch"},"_npmUser":{"name":"ericksatelite","email":"erick.ruano@satelite.digital"},"_npmVersion":"10.1.0","description":"A flexible and powerful workflow execution engine for JavaScript that enables you to define and run complex workflows with state management, custom actions, and plugin support.","directories":{},"_nodeVersion":"20.8.1","browserslist":["defaults","not IE 11"],"dependencies":{"json-logic-js":"^2.0.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^8.0.0","eslint":"^9.13.0","rollup":"^4.12.0","prettier":"^3.2.0","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","@rollup/plugin-babel":"^6.0.4","@semantic-release/npm":"^12.0.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","@rollup/plugin-commonjs":"^28.0.1","@rollup/plugin-node-resolve":"^15.3.0","@babel/plugin-proposal-optional-chaining":"^7.21.0"},"_npmOperationalInternal":{"tmp":"tmp/operator_1.0.0_1733803749131_0.4834193756145799","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@4o/operator","version":"1.0.1","keywords":[],"author":"","license":"ISC","_id":"@4o/operator@1.0.1","maintainers":[{"name":"ericksatelite","email":"erick.ruano@satelite.digital"}],"dist":{"shasum":"c335347cfc8c27d1fb003eef747ea727658ebea6","tarball":"https://registry.npmjs.org/@4o/operator/-/operator-1.0.1.tgz","fileCount":19,"integrity":"sha512-rF3Xxebwq3hVIz9nFrBY3nAQxsdRmXfkVeu85unZCHqAaanuXGhQnUDq6yauSHJQYTbPWTV5lC1jh9wzSKN3zg==","signatures":[{"sig":"MEYCIQCRwRCkV4WbMepaCmvCphDawYisyqgsGwPj52saw3hHhQIhANKYcbGGqQmHzRyExO/2ybEBwGa5t2/XnKG5YL5v8kF5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":237288},"main":"./dist/index.js","type":"module","module":"./dist/index.esm.js","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"}},"gitHead":"0504e83df6cef27241b0060a1d0d349a8e17bac1","scripts":{"lint":"eslint \"src/**/*.js\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js","build":"rollup -c","format":"prettier --write \"src/**/*.js\"","prepare":"yarn build","lint:fix":"eslint \"src/**/*.js\" --fix","test:watch":"jest --watch"},"_npmUser":{"name":"ericksatelite","email":"erick.ruano@satelite.digital"},"_npmVersion":"10.1.0","description":"A flexible and powerful workflow execution engine for JavaScript that enables you to define and run complex workflows with state management, custom actions, and plugin support.","directories":{},"_nodeVersion":"20.8.1","browserslist":["defaults","not IE 11"],"dependencies":{"json-logic-js":"^2.0.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^8.0.0","eslint":"^9.13.0","rollup":"^4.12.0","prettier":"^3.2.0","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","@rollup/plugin-babel":"^6.0.4","@semantic-release/npm":"^12.0.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","@rollup/plugin-commonjs":"^28.0.1","@rollup/plugin-node-resolve":"^15.3.0","@babel/plugin-proposal-optional-chaining":"^7.21.0"},"_npmOperationalInternal":{"tmp":"tmp/operator_1.0.1_1733804098161_0.5564757190709657","host":"s3://npm-registry-packages-npm-production"}},"2.0.0-alpha":{"name":"@4o/operator","version":"2.0.0-alpha","keywords":[],"author":"","license":"ISC","_id":"@4o/operator@2.0.0-alpha","maintainers":[{"name":"ericksatelite","email":"erick.ruano@satelite.digital"}],"dist":{"shasum":"93ab8978338d1cdfdd9876cc1f3ff5cd160405ca","tarball":"https://registry.npmjs.org/@4o/operator/-/operator-2.0.0-alpha.tgz","fileCount":19,"integrity":"sha512-0os2AbV0FXWhIHnZ41+vvIjGrPbmQ7GavrvjldgyR2bglB6yZny1lVXWoey3iV0f4YLA1HFJnOsH4lDaXU/P5w==","signatures":[{"sig":"MEUCIQDFZAPal8fseHUcA/zHg8ilSE5jeccAle5q3J0xPe2DcAIgE3933gAqkXeSwlnzp8/EgO38KH/UrEUuSOOP2MMO0Qs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":283116},"main":"./dist/index.js","type":"module","module":"./dist/index.esm.js","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"}},"gitHead":"17fd6a2a144b253a6ec20f87c0b60d277863344b","scripts":{"lint":"eslint \"src/**/*.js\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js","build":"rollup -c","format":"prettier --write \"src/**/*.js\"","prepare":"yarn build","lint:fix":"eslint \"src/**/*.js\" --fix","test:watch":"jest --watch"},"_npmUser":{"name":"ericksatelite","email":"erick.ruano@satelite.digital"},"_npmVersion":"10.1.0","description":"A flexible and powerful workflow execution engine for JavaScript that enables you to define and run complex workflows with state management, custom actions, and plugin support.","directories":{},"_nodeVersion":"20.8.1","browserslist":["defaults","not IE 11"],"dependencies":{"signale":"^1.4.0","json-logic-js":"^2.0.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^8.0.0","eslint":"^9.13.0","rollup":"^4.12.0","prettier":"^3.2.0","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","@rollup/plugin-babel":"^6.0.4","@semantic-release/npm":"^12.0.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","@rollup/plugin-commonjs":"^28.0.1","@rollup/plugin-node-resolve":"^15.3.0","@babel/plugin-proposal-optional-chaining":"^7.21.0"},"_npmOperationalInternal":{"tmp":"tmp/operator_2.0.0-alpha_1742975935310_0.6548463814180925","host":"s3://npm-registry-packages-npm-production"}},"2.0.0-alpha.1":{"name":"@4o/operator","version":"2.0.0-alpha.1","description":"A flexible and powerful workflow execution engine for JavaScript that enables you to define and run complex workflows with state management, custom actions, and plugin support.","main":"./dist/index.js","module":"./dist/index.esm.js","type":"module","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"}},"publishConfig":{"access":"public"},"scripts":{"build":"rollup -c","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js","test:watch":"jest --watch","lint":"eslint \"src/**/*.js\"","lint:fix":"eslint \"src/**/*.js\" --fix","format":"prettier --write \"src/**/*.js\"","prepare":"yarn build"},"keywords":[],"author":"","license":"ISC","dependencies":{"json-logic-js":"^2.0.5","p-throttle":"^7.0.0","signale":"^1.4.0"},"browserslist":["defaults","not IE 11"],"devDependencies":{"@babel/core":"^7.26.0","@babel/plugin-proposal-optional-chaining":"^7.21.0","@babel/preset-env":"^7.26.0","@rollup/plugin-babel":"^6.0.4","@rollup/plugin-commonjs":"^28.0.1","@rollup/plugin-node-resolve":"^15.3.0","@semantic-release/npm":"^12.0.1","eslint":"^9.13.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","husky":"^8.0.0","jest":"^29.7.0","prettier":"^3.2.0","rollup":"^4.12.0"},"_id":"@4o/operator@2.0.0-alpha.1","gitHead":"d243589e38f3cf1fcffbafa35676508feb92335e","_nodeVersion":"20.8.1","_npmVersion":"10.1.0","dist":{"integrity":"sha512-R6q9sf7jCZbLb96JD8I2A8C06VUbDsXXvOlU7VJQ6QkmdvckvRzkaQAi7Prs5Y3qghpipaAS7GoBDZgcZAB4Tw==","shasum":"647dd9986d087b4ccb04d98d37dbd0761c570c10","tarball":"https://registry.npmjs.org/@4o/operator/-/operator-2.0.0-alpha.1.tgz","fileCount":19,"unpackedSize":304265,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDgj5ijVjEyU3L3CrdFvbaXHV+a+yYboCkTaEm5uQnkCwIhAIGQqNe178zc8zCXQFAK+nDFZqD3QsjI123E9SAhoHwF"}]},"_npmUser":{"name":"ericksatelite","email":"erick.ruano@satelite.digital"},"directories":{},"maintainers":[{"name":"ericksatelite","email":"erick.ruano@satelite.digital"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/operator_2.0.0-alpha.1_1742984423485_0.6427895200661105"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-10T04:09:09.025Z","modified":"2025-03-26T10:20:23.844Z","0.0.0":"2024-11-28T11:13:37.161Z","0.0.1":"2024-11-28T11:32:30.596Z","1.0.0":"2024-12-10T04:09:09.360Z","1.0.1":"2024-12-10T04:14:58.422Z","2.0.0-alpha":"2025-03-26T07:58:55.570Z","2.0.0-alpha.1":"2025-03-26T10:20:23.676Z"},"license":"ISC","keywords":[],"description":"A flexible and powerful workflow execution engine for JavaScript that enables you to define and run complex workflows with state management, custom actions, and plugin support.","maintainers":[{"name":"ericksatelite","email":"erick.ruano@satelite.digital"}],"readme":"# Operator\r\n\r\nA flexible and powerful workflow execution engine for JavaScript that enables you to define and run complex workflows with state management, custom actions, and plugin support.\r\n\r\n## Overview\r\n\r\nOperator is a sophisticated JavaScript library for building complex, extensible workflows with advanced state management, plugin support, and dynamic execution capabilities. It provides a flexible framework for creating multi-step processes with intricate logic and customizable behavior.\r\n\r\n## Features\r\n\r\n- 🔄 **Workflow Orchestration**: Define and execute multi-step workflows with complex state management\r\n- 🧩 **Plugin System**: Extend functionality through a robust plugin architecture\r\n- 🎯 **Custom Actions**: Register and use custom actions with namespaced organization\r\n- 🔄 **Iteration Support**: Execute steps sequentially or in parallel over collections\r\n- 🔀 **Conditional Flow**: Dynamic workflow paths based on state using JSON Logic\r\n- 📦 **State Management**: Sophisticated state handling with dot notation support\r\n- 🔌 **Extensible**: Easy to extend with custom plugins and actions\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install operator-engine\r\n```\r\n\r\n## Quick Start\r\n\r\n```javascript\r\nimport Operator from 'operator-engine';\r\n\r\n// Define your workflow\r\nconst workflow = {\r\n  initialState: {\r\n    users: ['Alice', 'Bob', 'Charlie']\r\n  },\r\n  steps: [\r\n    {\r\n      id: 'greet',\r\n      task: {\r\n        from: 'greeting',\r\n        use: 'sayHello'\r\n      },\r\n      iterate: {\r\n        source: 'users',\r\n        itemAs: '$user'\r\n      },\r\n      output: {\r\n        to: 'greetings',\r\n        mode: 'push'\r\n      }\r\n    }\r\n  ]\r\n};\r\n\r\n// Create operator instance\r\nconst operator = new Operator();\r\n\r\n// Register custom actions\r\nOperator.registerAction('greeting', {\r\n  sayHello: async (name) => `Hello, ${name}!`\r\n});\r\n\r\n// Execute workflow\r\nconst result = await operator.run(workflow);\r\n```\r\n\r\n## Core Concepts\r\n\r\n### Workflow Structure\r\n\r\nA workflow is defined by an instructions object with the following structure:\r\n\r\n```javascript\r\n{\r\n  initialState: Object,    // Initial state data\r\n  steps: Array,           // Array of step definitions\r\n  plugins: Array,         // Optional array of plugin names\r\n  options: Object         // Optional configuration object\r\n}\r\n```\r\n\r\n### Steps\r\n\r\nSteps are the building blocks of your workflow. Each step represents a single unit of work:\r\n\r\n```javascript\r\n{\r\n  id: 'stepId',          // Unique step identifier\r\n  task: {                // Task definition\r\n    from: 'namespace',   // Action namespace\r\n    use: 'actionName'    // Action function name\r\n  },\r\n  input: {               // Input configuration\r\n    args: []            // Array of argument specifications\r\n  },\r\n  output: {              // Output configuration\r\n    to: 'resultPath',   // State path for result\r\n    mode: 'merge',      // Output mode (merge/push/append)\r\n    transform: {}       // Optional transformation spec\r\n  },\r\n  iterate: {             // Optional iteration configuration\r\n    source: 'arrayPath', // Path to source array\r\n    itemAs: '$item',     // Item variable name\r\n    indexAs: '$index',   // Index variable name\r\n    parallel: false      // Parallel execution flag\r\n  },\r\n  next: 'nextStepId'     // Next step specification\r\n}\r\n```\r\n\r\n### Custom Actions\r\n\r\nRegister custom actions to extend functionality:\r\n\r\n```javascript\r\nOperator.registerAction('math', {\r\n  add: async (a, b) => a + b,\r\n  multiply: async (a, b) => a * b\r\n});\r\n```\r\n\r\n### Plugins\r\n\r\nCreate plugins to add cross-cutting concerns:\r\n\r\n```javascript\r\nclass LoggingPlugin {\r\n  onBeforeAll(state) {\r\n    console.log('Workflow starting', state);\r\n  }\r\n  \r\n  onBeforeEach(stepId, state) {\r\n    console.log(`Executing step: ${stepId}`);\r\n  }\r\n  \r\n  onAfterEach(stepId, state) {\r\n    console.log(`Completed step: ${stepId}`);\r\n  }\r\n  \r\n  onAfterAll(state) {\r\n    console.log('Workflow completed', state);\r\n  }\r\n}\r\n\r\nOperator.registerPlugin(LoggingPlugin);\r\n```\r\n\r\n## Advanced Features\r\n\r\n### JSON Logic Integration\r\n\r\nUse JSON Logic expressions for dynamic values and conditions:\r\n\r\n```javascript\r\n{\r\n  id: 'conditional',\r\n  next: {\r\n    if: [\r\n      { \">\": [{ var: \"user.age\" }, 18] },\r\n      \"adult-flow\",\r\n      \"minor-flow\"\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\n### Iteration Modes\r\n\r\nExecute iterations sequentially or in parallel:\r\n\r\n```javascript\r\n{\r\n  id: 'process-users',\r\n  iterate: {\r\n    source: 'users',\r\n    itemAs: '$user',\r\n    parallel: true  // Enable parallel execution\r\n  }\r\n}\r\n```\r\n\r\n### Nested Workflows\r\n\r\nExecute workflows within workflows using the built-in `runInstructions` action:\r\n\r\n```javascript\r\n{\r\n  id: 'nested-workflow',\r\n  task: {\r\n    from: 'operator',\r\n    use: 'runInstructions'\r\n  },\r\n  input: {\r\n    args: [{\r\n      initialState: { /* ... */ },\r\n      steps: [ /* ... */ ]\r\n    }]\r\n  }\r\n}\r\n```\r\n\r\n## Performance Considerations\r\n\r\n- Supports both sequential and parallel execution of iterations\r\n- Lightweight JSON Logic evaluation\r\n- Minimal overhead for workflow definition and execution\r\n\r\n## Error Handling\r\n\r\nThe Operator engine provides detailed error messages for common issues:\r\n- Invalid step configurations\r\n- Missing actions or plugins\r\n- State path errors\r\n- Invalid JSON Logic expressions\r\n\r\n## Best Practices\r\n\r\n1. **Organize Actions**: Group related actions under meaningful namespaces\r\n2. **State Structure**: Plan your state structure carefully and use dot notation paths consistently\r\n3. **Step Isolation**: Keep steps focused on single responsibilities\r\n4. **Plugin Hooks**: Use plugin hooks for cross-cutting concerns rather than mixing them into steps\r\n5. **Error Handling**: Implement proper error handling in your actions and plugins\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## Support\r\n\r\nFor issues, feature requests, or discussions, please open an issue on our GitHub repository.\r\n\r\n## License\r\n\r\nMIT","readmeFilename":"README.md"}