@ductape/sdk 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -53
- package/dist/agents/agent-context.d.ts +100 -0
- package/dist/agents/agent-context.js +604 -0
- package/dist/agents/agent-context.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +180 -0
- package/dist/agents/agent-executor.js +715 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/agents.service.d.ts +310 -0
- package/dist/agents/agents.service.js +1253 -0
- package/dist/agents/agents.service.js.map +1 -0
- package/dist/agents/index.d.ts +55 -0
- package/dist/agents/index.js +110 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/memory-manager.d.ts +182 -0
- package/dist/agents/memory-manager.js +383 -0
- package/dist/agents/memory-manager.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +141 -0
- package/dist/agents/tool-registry.js +355 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/agents/types/agents.types.d.ts +1240 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.d.ts +51 -5
- package/dist/api/services/appApi.service.js +116 -9
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/logsApi.service.d.ts +51 -0
- package/dist/api/services/logsApi.service.js +19 -2
- package/dist/api/services/logsApi.service.js.map +1 -1
- package/dist/api/services/pricingApi.service.d.ts +10 -0
- package/dist/api/services/pricingApi.service.js +34 -0
- package/dist/api/services/pricingApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +900 -2
- package/dist/api/services/processorApi.service.js +665 -12
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +130 -1
- package/dist/api/services/productsApi.service.js +198 -11
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +50 -0
- package/dist/api/services/secretsApi.service.js +113 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/webhooksApi.service.js +13 -6
- package/dist/api/services/webhooksApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +201 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.d.ts +8 -0
- package/dist/api/services/workspaceApi.service.js +20 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +92 -1
- package/dist/api/urls.js +118 -18
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/auth.utils.d.ts +1 -3
- package/dist/api/utils/auth.utils.js.map +1 -1
- package/dist/api/utils/cache.utils.d.ts +1 -1
- package/dist/api/utils/cache.utils.js +2 -2
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/api/utils/strings.utils.d.ts +2 -0
- package/dist/api/utils/strings.utils.js +14 -0
- package/dist/api/utils/strings.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +42 -33
- package/dist/apps/services/app.service.js +574 -223
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +429 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js +22 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.app.validator.js +2 -0
- package/dist/apps/validators/joi-validators/update.app.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +23 -2
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +435 -0
- package/dist/brokers/brokers.service.js +1205 -0
- package/dist/brokers/brokers.service.js.map +1 -0
- package/dist/brokers/index.d.ts +46 -0
- package/dist/brokers/index.js +83 -0
- package/dist/brokers/index.js.map +1 -0
- package/dist/brokers/types/index.d.ts +567 -0
- package/dist/brokers/types/index.js +8 -0
- package/dist/brokers/types/index.js.map +1 -0
- package/dist/brokers/utils/broker.util.d.ts +33 -0
- package/dist/brokers/utils/broker.util.js +125 -0
- package/dist/brokers/utils/broker.util.js.map +1 -0
- package/dist/{processor/services/messagebrokers → brokers/utils/providers}/aws-sqs.service.d.ts +3 -2
- package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
- package/dist/{processor/services/messagebrokers → brokers/utils/providers}/google-pubsub.service.d.ts +2 -2
- package/dist/{processor/services/messagebrokers → brokers/utils/providers}/google-pubsub.service.js +16 -7
- package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
- package/dist/brokers/utils/providers/index.d.ts +6 -0
- package/dist/brokers/utils/providers/index.js +16 -0
- package/dist/brokers/utils/providers/index.js.map +1 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +23 -0
- package/dist/brokers/utils/providers/kafka.service.js +131 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +25 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +138 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/{processor/services/messagebrokers → brokers/utils/providers}/redis.service.d.ts +3 -3
- package/dist/{processor/services/messagebrokers → brokers/utils/providers}/redis.service.js +25 -14
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +308 -0
- package/dist/cache/cache.manager.js +900 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +191 -0
- package/dist/cache/cache.service.js +594 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +81 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +110 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.js.map +1 -0
- package/dist/clients/apps.client.js +1 -1
- package/dist/clients/apps.client.js.map +1 -1
- package/dist/clients/pricing.client.d.ts +3 -0
- package/dist/clients/pricing.client.js +33 -0
- package/dist/clients/pricing.client.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +423 -0
- package/dist/database/adapters/base.adapter.js +260 -0
- package/dist/database/adapters/base.adapter.js.map +1 -0
- package/dist/database/adapters/cassandra.adapter.d.ts +92 -0
- package/dist/database/adapters/cassandra.adapter.js +1091 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +110 -0
- package/dist/database/adapters/dynamodb.adapter.js +1564 -0
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +121 -0
- package/dist/database/adapters/mongodb.adapter.js +1284 -0
- package/dist/database/adapters/mongodb.adapter.js.map +1 -0
- package/dist/database/adapters/mysql.adapter.d.ts +86 -0
- package/dist/database/adapters/mysql.adapter.js +1371 -0
- package/dist/database/adapters/mysql.adapter.js.map +1 -0
- package/dist/database/adapters/postgresql.adapter.d.ts +90 -0
- package/dist/database/adapters/postgresql.adapter.js +1487 -0
- package/dist/database/adapters/postgresql.adapter.js.map +1 -0
- package/dist/database/databases.service.d.ts +1476 -0
- package/dist/database/databases.service.js +3068 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +46 -0
- package/dist/database/index.js +109 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +136 -0
- package/dist/database/migrations/migration-engine.js +1421 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +67 -0
- package/dist/database/operators/aggregation-builder.js +841 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +69 -0
- package/dist/database/operators/query-builder.js +447 -0
- package/dist/database/operators/query-builder.js.map +1 -0
- package/dist/database/presave/decrypt.d.ts +25 -0
- package/dist/database/presave/decrypt.js +146 -0
- package/dist/database/presave/decrypt.js.map +1 -0
- package/dist/database/presave/index.d.ts +9 -0
- package/dist/database/presave/index.js +18 -0
- package/dist/database/presave/index.js.map +1 -0
- package/dist/database/presave/presave-processor.d.ts +148 -0
- package/dist/database/presave/presave-processor.js +702 -0
- package/dist/database/presave/presave-processor.js.map +1 -0
- package/dist/database/schema/index.d.ts +7 -0
- package/dist/database/schema/index.js +13 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/database/schema/schema-manager.d.ts +258 -0
- package/dist/database/schema/schema-manager.js +638 -0
- package/dist/database/schema/schema-manager.js.map +1 -0
- package/dist/database/transactions/index.d.ts +6 -0
- package/dist/database/transactions/index.js +13 -0
- package/dist/database/transactions/index.js.map +1 -0
- package/dist/database/transactions/transaction-manager.d.ts +113 -0
- package/dist/database/transactions/transaction-manager.js +344 -0
- package/dist/database/transactions/transaction-manager.js.map +1 -0
- package/dist/database/triggers/index.d.ts +7 -0
- package/dist/database/triggers/index.js +14 -0
- package/dist/database/triggers/index.js.map +1 -0
- package/dist/database/triggers/trigger-processor.d.ts +239 -0
- package/dist/database/triggers/trigger-processor.js +1034 -0
- package/dist/database/triggers/trigger-processor.js.map +1 -0
- package/dist/database/types/action.interface.d.ts +148 -0
- package/dist/database/types/action.interface.js +6 -0
- package/dist/database/types/action.interface.js.map +1 -0
- package/dist/database/types/aggregation.interface.d.ts +185 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/dashboard.interface.d.ts +74 -0
- package/dist/database/types/dashboard.interface.js +7 -0
- package/dist/database/types/dashboard.interface.js.map +1 -0
- package/dist/database/types/enums.d.ts +195 -0
- package/dist/database/types/enums.js +244 -0
- package/dist/database/types/enums.js.map +1 -0
- package/dist/database/types/index.d.ts +15 -0
- package/dist/database/types/index.js +31 -0
- package/dist/database/types/index.js.map +1 -0
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +205 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +412 -0
- package/dist/database/types/schema.interface.js +6 -0
- package/dist/database/types/schema.interface.js.map +1 -0
- package/dist/database/types/transaction.interface.d.ts +84 -0
- package/dist/database/types/transaction.interface.js +6 -0
- package/dist/database/types/transaction.interface.js.map +1 -0
- package/dist/database/types/trigger.interface.d.ts +612 -0
- package/dist/database/types/trigger.interface.js +121 -0
- package/dist/database/types/trigger.interface.js.map +1 -0
- package/dist/database/types/write.interface.d.ts +216 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +86 -0
- package/dist/graph/adapters/arangodb.adapter.js +1588 -0
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
- package/dist/graph/adapters/base.adapter.d.ts +264 -0
- package/dist/graph/adapters/base.adapter.js +156 -0
- package/dist/graph/adapters/base.adapter.js.map +1 -0
- package/dist/graph/adapters/index.d.ts +11 -0
- package/dist/graph/adapters/index.js +21 -0
- package/dist/graph/adapters/index.js.map +1 -0
- package/dist/graph/adapters/memgraph.adapter.d.ts +110 -0
- package/dist/graph/adapters/memgraph.adapter.js +1452 -0
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
- package/dist/graph/adapters/neo4j.adapter.d.ts +81 -0
- package/dist/graph/adapters/neo4j.adapter.js +1317 -0
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
- package/dist/graph/adapters/neptune.adapter.d.ts +82 -0
- package/dist/graph/adapters/neptune.adapter.js +1369 -0
- package/dist/graph/adapters/neptune.adapter.js.map +1 -0
- package/dist/graph/graphs.service.d.ts +606 -0
- package/dist/graph/graphs.service.js +2434 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +57 -0
- package/dist/graph/index.js +77 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +149 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +13 -0
- package/dist/graph/types/index.js +20 -0
- package/dist/graph/types/index.js.map +1 -0
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +175 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/imports/imports.service.d.ts +3 -3
- package/dist/imports/imports.service.js +8 -7
- package/dist/imports/imports.service.js.map +1 -1
- package/dist/imports/imports.types.d.ts +8 -0
- package/dist/imports/repos/openApi.repo.d.ts +1 -2
- package/dist/imports/repos/openApi.repo.js +409 -70
- package/dist/imports/repos/openApi.repo.js.map +1 -1
- package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
- package/dist/imports/repos/postmanV21.repo.js +126 -83
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +3926 -269
- package/dist/index.js +5475 -682
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/{processor/services/messagebrokers/messagebrokers.type.js → init.interface.js} +1 -1
- package/dist/init.interface.js.map +1 -0
- package/dist/inputs/inputs.service.d.ts +1 -1
- package/dist/inputs/inputs.service.js +2 -2
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/inputs/utils/inputs.utils.create.js +1 -1
- package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.service.js +6 -1
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/logs/logs.types.d.ts +33 -1
- package/dist/logs/logs.types.js +17 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +268 -0
- package/dist/notifications/notifications.service.js +905 -0
- package/dist/notifications/notifications.service.js.map +1 -0
- package/dist/notifications/types/index.d.ts +4 -0
- package/dist/notifications/types/index.js +21 -0
- package/dist/notifications/types/index.js.map +1 -0
- package/dist/notifications/types/notifications.types.d.ts +452 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +27 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
- package/dist/parsers/pipelines/postman.pipelines.js +103 -0
- package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
- package/dist/parsers/types/postman.types.d.ts +200 -0
- package/dist/parsers/types/postman.types.js +3 -0
- package/dist/parsers/types/postman.types.js.map +1 -0
- package/dist/parsers/utils/postman.utils.d.ts +12 -0
- package/dist/parsers/utils/postman.utils.js +116 -0
- package/dist/parsers/utils/postman.utils.js.map +1 -0
- package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
- package/dist/parsers/validators/postman-auth.validators.js +127 -0
- package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
- package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-request.validators.js +139 -0
- package/dist/parsers/validators/postman-request.validators.js.map +1 -0
- package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-response.validators.js +150 -0
- package/dist/parsers/validators/postman-response.validators.js.map +1 -0
- package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
- package/dist/parsers/validators/postman-variable.validators.js +163 -0
- package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
- package/dist/pricing/pricing.repo.js +1 -0
- package/dist/pricing/pricing.repo.js.map +1 -0
- package/dist/pricing/pricing.service.d.ts +24 -0
- package/dist/pricing/pricing.service.js +51 -0
- package/dist/pricing/pricing.service.js.map +1 -0
- package/dist/pricing/pricing.types.d.ts +76 -0
- package/dist/pricing/pricing.types.js +21 -0
- package/dist/pricing/pricing.types.js.map +1 -0
- package/dist/pricing/utils/string.utils.d.ts +1 -0
- package/dist/pricing/utils/string.utils.js +9 -0
- package/dist/pricing/utils/string.utils.js.map +1 -0
- package/dist/processor/repos/sms.repo.d.ts +4 -4
- package/dist/processor/repos/sms.repo.js +23 -10
- package/dist/processor/repos/sms.repo.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +251 -78
- package/dist/processor/services/processor.service.js +2803 -1495
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/request.service.d.ts +36 -0
- package/dist/processor/services/request.service.js +304 -0
- package/dist/processor/services/request.service.js.map +1 -0
- package/dist/processor/types/request.types.d.ts +14 -0
- package/dist/processor/types/request.types.js +3 -0
- package/dist/processor/types/request.types.js.map +1 -0
- package/dist/processor/utils/processor.utils.d.ts +8 -0
- package/dist/processor/utils/processor.utils.js +152 -12
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/processor/utils/request.utils.d.ts +20 -0
- package/dist/processor/utils/request.utils.js +113 -0
- package/dist/processor/utils/request.utils.js.map +1 -0
- package/dist/processor/utils/storage.util.js +63 -40
- package/dist/processor/utils/storage.util.js.map +1 -1
- package/dist/products/services/products.service.d.ts +386 -76
- package/dist/products/services/products.service.js +3221 -419
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/utils/string.utils.d.ts +1 -1
- package/dist/products/utils/string.utils.js +14 -2
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +7 -1
- package/dist/products/validators/index.js +16 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +266 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productApp.validator.js +2 -2
- package/dist/products/validators/joi-validators/create.productApp.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productFeature.validator.js +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +89 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
- package/dist/{processor/services/messagebrokers/rabbitmq.service.js → products/validators/joi-validators/create.productHealthcheck.validator.js} +23 -32
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productJob.validator.js +2 -2
- package/dist/products/validators/joi-validators/create.productJob.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +81 -25
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +150 -51
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
- package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js +136 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.dataValue.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
- package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +88 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +141 -0
- package/dist/resilience/fallback.service.js +766 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +159 -0
- package/dist/resilience/healthcheck.service.js +943 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +83 -0
- package/dist/resilience/quota.service.js +518 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +98 -0
- package/dist/resilience/resilience.service.js +560 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +513 -0
- package/dist/resilience/types/index.js +29 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +236 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +93 -0
- package/dist/secrets/secrets.service.js +246 -0
- package/dist/secrets/secrets.service.js.map +1 -0
- package/dist/secrets/secrets.types.d.ts +188 -0
- package/dist/secrets/secrets.types.js +87 -0
- package/dist/secrets/secrets.types.js.map +1 -0
- package/dist/sessions/index.d.ts +50 -0
- package/dist/sessions/index.js +96 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +88 -0
- package/dist/sessions/sessions.helper.js +133 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +188 -0
- package/dist/sessions/sessions.resolver.js +603 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +194 -0
- package/dist/sessions/sessions.service.js +987 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +342 -0
- package/dist/sessions/types/index.js +6 -0
- package/dist/sessions/types/index.js.map +1 -0
- package/dist/storage/index.d.ts +66 -0
- package/dist/storage/index.js +99 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +177 -0
- package/dist/storage/storage.service.js +897 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +267 -0
- package/dist/storage/types/index.js +6 -0
- package/dist/storage/types/index.js.map +1 -0
- package/dist/storage/utils/storage.util.d.ts +62 -0
- package/dist/storage/utils/storage.util.js +593 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +13 -14
- package/dist/types/enums.d.ts +11 -1
- package/dist/types/enums.js +10 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +9 -4
- package/dist/types/index.types.js +0 -1
- package/dist/types/index.types.js.map +1 -1
- package/dist/types/inputs.types.d.ts +1 -0
- package/dist/types/inputs.types.js +4 -3
- package/dist/types/inputs.types.js.map +1 -1
- package/dist/types/pricing.types.d.ts +4 -0
- package/dist/types/pricing.types.js +3 -0
- package/dist/types/pricing.types.js.map +1 -0
- package/dist/types/processor.types.d.ts +324 -18
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +1007 -23
- package/dist/types/productsBuilder.types.js +216 -2
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/request-tracker.interface.js +1 -0
- package/dist/types/request-tracker.interface.js.map +1 -0
- package/dist/types/requests.types.d.ts +2 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +24 -52
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/actions/action-manager.d.ts +140 -0
- package/dist/vector/actions/action-manager.js +356 -0
- package/dist/vector/actions/action-manager.js.map +1 -0
- package/dist/vector/adapters/base.adapter.d.ts +169 -0
- package/dist/vector/adapters/base.adapter.js +218 -0
- package/dist/vector/adapters/base.adapter.js.map +1 -0
- package/dist/vector/adapters/index.d.ts +10 -0
- package/dist/vector/adapters/index.js +19 -0
- package/dist/vector/adapters/index.js.map +1 -0
- package/dist/vector/adapters/memory.adapter.d.ts +85 -0
- package/dist/vector/adapters/memory.adapter.js +505 -0
- package/dist/vector/adapters/memory.adapter.js.map +1 -0
- package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
- package/dist/vector/adapters/pinecone.adapter.js +433 -0
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
- package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
- package/dist/vector/adapters/qdrant.adapter.js +442 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +68 -0
- package/dist/vector/adapters/weaviate.adapter.js +661 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +36 -0
- package/dist/vector/index.js +70 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/types/action.interface.d.ts +195 -0
- package/dist/vector/types/action.interface.js +100 -0
- package/dist/vector/types/action.interface.js.map +1 -0
- package/dist/vector/types/connection.interface.d.ts +151 -0
- package/dist/vector/types/connection.interface.js +8 -0
- package/dist/vector/types/connection.interface.js.map +1 -0
- package/dist/vector/types/embedding.interface.d.ts +144 -0
- package/dist/vector/types/embedding.interface.js +8 -0
- package/dist/vector/types/embedding.interface.js.map +1 -0
- package/dist/vector/types/enums.d.ts +104 -0
- package/dist/vector/types/enums.js +113 -0
- package/dist/vector/types/enums.js.map +1 -0
- package/dist/vector/types/index.d.ts +11 -0
- package/dist/vector/types/index.js +23 -0
- package/dist/vector/types/index.js.map +1 -0
- package/dist/vector/types/vector.interface.d.ts +315 -0
- package/dist/vector/types/vector.interface.js +8 -0
- package/dist/vector/types/vector.interface.js.map +1 -0
- package/dist/vector/utils/index.d.ts +6 -0
- package/dist/vector/utils/index.js +11 -0
- package/dist/vector/utils/index.js.map +1 -0
- package/dist/vector/utils/vector-error.d.ts +69 -0
- package/dist/vector/utils/vector-error.js +116 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +476 -0
- package/dist/vector/vector-database.service.js +892 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +283 -0
- package/dist/vector/vector.service.js +544 -0
- package/dist/vector/vector.service.js.map +1 -0
- package/dist/warehouse/executor/index.d.ts +5 -0
- package/dist/warehouse/executor/index.js +12 -0
- package/dist/warehouse/executor/index.js.map +1 -0
- package/dist/warehouse/executor/joins/index.d.ts +5 -0
- package/dist/warehouse/executor/joins/index.js +11 -0
- package/dist/warehouse/executor/joins/index.js.map +1 -0
- package/dist/warehouse/executor/joins/join-executor.d.ts +101 -0
- package/dist/warehouse/executor/joins/join-executor.js +493 -0
- package/dist/warehouse/executor/joins/join-executor.js.map +1 -0
- package/dist/warehouse/executor/joins/semantic-join.d.ts +64 -0
- package/dist/warehouse/executor/joins/semantic-join.js +241 -0
- package/dist/warehouse/executor/joins/semantic-join.js.map +1 -0
- package/dist/warehouse/executor/single-source-executor.d.ts +155 -0
- package/dist/warehouse/executor/single-source-executor.js +573 -0
- package/dist/warehouse/executor/single-source-executor.js.map +1 -0
- package/dist/warehouse/index.d.ts +79 -0
- package/dist/warehouse/index.js +111 -0
- package/dist/warehouse/index.js.map +1 -0
- package/dist/warehouse/parser/index.d.ts +4 -0
- package/dist/warehouse/parser/index.js +10 -0
- package/dist/warehouse/parser/index.js.map +1 -0
- package/dist/warehouse/parser/query-parser.d.ts +181 -0
- package/dist/warehouse/parser/query-parser.js +415 -0
- package/dist/warehouse/parser/query-parser.js.map +1 -0
- package/dist/warehouse/registry/data-source-registry.d.ts +207 -0
- package/dist/warehouse/registry/data-source-registry.js +396 -0
- package/dist/warehouse/registry/data-source-registry.js.map +1 -0
- package/dist/warehouse/registry/index.d.ts +4 -0
- package/dist/warehouse/registry/index.js +9 -0
- package/dist/warehouse/registry/index.js.map +1 -0
- package/dist/warehouse/transactions/index.d.ts +4 -0
- package/dist/warehouse/transactions/index.js +9 -0
- package/dist/warehouse/transactions/index.js.map +1 -0
- package/dist/warehouse/transactions/saga-orchestrator.d.ts +92 -0
- package/dist/warehouse/transactions/saga-orchestrator.js +383 -0
- package/dist/warehouse/transactions/saga-orchestrator.js.map +1 -0
- package/dist/warehouse/types/index.d.ts +9 -0
- package/dist/warehouse/types/index.js +33 -0
- package/dist/warehouse/types/index.js.map +1 -0
- package/dist/warehouse/types/join.interface.d.ts +225 -0
- package/dist/warehouse/types/join.interface.js +87 -0
- package/dist/warehouse/types/join.interface.js.map +1 -0
- package/dist/warehouse/types/query.interface.d.ts +232 -0
- package/dist/warehouse/types/query.interface.js +9 -0
- package/dist/warehouse/types/query.interface.js.map +1 -0
- package/dist/warehouse/types/transaction.interface.d.ts +236 -0
- package/dist/warehouse/types/transaction.interface.js +74 -0
- package/dist/warehouse/types/transaction.interface.js.map +1 -0
- package/dist/warehouse/types/where.interface.d.ts +208 -0
- package/dist/warehouse/types/where.interface.js +89 -0
- package/dist/warehouse/types/where.interface.js.map +1 -0
- package/dist/warehouse/warehouse.service.d.ts +200 -0
- package/dist/warehouse/warehouse.service.js +470 -0
- package/dist/warehouse/warehouse.service.js.map +1 -0
- package/dist/workflows/index.d.ts +30 -0
- package/dist/workflows/index.js +64 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types/index.d.ts +6 -0
- package/dist/workflows/types/index.js +23 -0
- package/dist/workflows/types/index.js.map +1 -0
- package/dist/workflows/types/workflows.types.d.ts +1095 -0
- package/dist/workflows/types/workflows.types.js +13 -0
- package/dist/workflows/types/workflows.types.js.map +1 -0
- package/dist/workflows/workflow-builder.d.ts +70 -0
- package/dist/workflows/workflow-builder.js +353 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +287 -0
- package/dist/workflows/workflow-executor.js +2399 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +412 -0
- package/dist/workflows/workflows.service.js +2188 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +83 -11
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.d.ts +0 -0
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/services/fallback.service.d.ts +0 -5
- package/dist/processor/services/fallback.service.js +0 -43
- package/dist/processor/services/fallback.service.js.map +0 -1
- package/dist/processor/services/messagebrokers/aws-sqs.service.js +0 -77
- package/dist/processor/services/messagebrokers/aws-sqs.service.js.map +0 -1
- package/dist/processor/services/messagebrokers/google-pubsub.service.js.map +0 -1
- package/dist/processor/services/messagebrokers/index.d.ts +0 -3
- package/dist/processor/services/messagebrokers/index.js +0 -26
- package/dist/processor/services/messagebrokers/index.js.map +0 -1
- package/dist/processor/services/messagebrokers/kafka.service.d.ts +0 -14
- package/dist/processor/services/messagebrokers/kafka.service.js +0 -45
- package/dist/processor/services/messagebrokers/kafka.service.js.map +0 -1
- package/dist/processor/services/messagebrokers/messagebrokers.type.d.ts +0 -6
- package/dist/processor/services/messagebrokers/messagebrokers.type.js.map +0 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +0 -14
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +0 -1
- package/dist/processor/services/messagebrokers/redis.service.js.map +0 -1
- package/dist/processor/services/quota.service.d.ts +0 -15
- package/dist/processor/services/quota.service.js +0 -63
- package/dist/processor/services/quota.service.js.map +0 -1
- package/dist/processor/utils/mongo.util.d.ts +0 -0
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -16
- package/dist/test/test.appBuilder.js.map +0 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1460
- package/dist/test/test.import.js.map +0 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -76
- package/dist/test/test.import.openapi.js.map +0 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -62
- package/dist/test/test.imports.js.map +0 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -18
- package/dist/test/test.logs.js.map +0 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -123
- package/dist/test/test.processor.js.map +0 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -661
- package/dist/test/test.productBuilder.js.map +0 -1
- package/dist/test.appBuilder.d.ts +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- package/dist/test.import.d.ts +0 -0
- package/dist/test.import.js +0 -24
- package/dist/test.import.js.map +0 -1
- package/dist/test.imports.d.ts +0 -1
- package/dist/test.imports.js +0 -28
- package/dist/test.imports.js.map +0 -1
- package/dist/test.integrationBuilder.d.ts +0 -1
- package/dist/test.integrationBuilder.js +0 -276
- package/dist/test.integrationBuilder.js.map +0 -1
- package/dist/test.processor.d.ts +0 -1
- package/dist/test.processor.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.d.ts +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{actions/actions.repo.d.ts → pricing/pricing.repo.d.ts} +0 -0
- /package/dist/{appBuilder/validators/joi-validators/create.app.validator.d.ts → products/validators/joi-validators/create.productGraph.validator.d.ts} +0 -0
- /package/dist/{appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts → products/validators/joi-validators/update.productGraph.validator.d.ts} +0 -0
- /package/dist/{actions/actions.service.d.ts → types/request-tracker.interface.d.ts} +0 -0
|
@@ -0,0 +1,2399 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WorkflowExecutor - Executes workflow steps and manages rollbacks
|
|
4
|
+
*
|
|
5
|
+
* Handles the actual execution of workflow steps, including:
|
|
6
|
+
* - Processing each step type (action, database, notification, etc.)
|
|
7
|
+
* - Managing rollback on failure
|
|
8
|
+
* - Tracking workflow state and completed steps
|
|
9
|
+
* - Handling signals and checkpoints
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var _a, _b;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.WorkflowExecutor = void 0;
|
|
17
|
+
const crypto_1 = require("crypto");
|
|
18
|
+
const processor_service_1 = __importDefault(require("../processor/services/processor.service"));
|
|
19
|
+
const products_service_1 = __importDefault(require("../products/services/products.service"));
|
|
20
|
+
const processorApi_service_1 = require("../api/services/processorApi.service");
|
|
21
|
+
const workflowApi_service_1 = require("../api/services/workflowApi.service");
|
|
22
|
+
const graph_1 = require("../graph");
|
|
23
|
+
const database_1 = require("../database");
|
|
24
|
+
const brokers_1 = require("../brokers");
|
|
25
|
+
const storage_1 = require("../storage");
|
|
26
|
+
const vector_1 = require("../vector");
|
|
27
|
+
const resilience_1 = require("../resilience");
|
|
28
|
+
const logs_service_1 = __importDefault(require("../logs/logs.service"));
|
|
29
|
+
const logs_types_1 = require("../logs/logs.types");
|
|
30
|
+
const types_1 = require("../types");
|
|
31
|
+
const inputs_types_1 = require("../types/inputs.types");
|
|
32
|
+
const processor_utils_1 = require("../processor/utils/processor.utils");
|
|
33
|
+
const productsBuilder_types_1 = require("../types/productsBuilder.types");
|
|
34
|
+
const date_fns_1 = require("date-fns");
|
|
35
|
+
/** Only log when DUCTAPE_DEBUG is set to avoid sync I/O and serialization cost in hot path */
|
|
36
|
+
const debugLog = typeof process !== 'undefined' && (((_a = process.env) === null || _a === void 0 ? void 0 : _a.DUCTAPE_DEBUG) === 'true' || ((_b = process.env) === null || _b === void 0 ? void 0 : _b.DUCTAPE_DEBUG) === '1')
|
|
37
|
+
? (...args) => console.log(...args)
|
|
38
|
+
: () => { };
|
|
39
|
+
/** Always-on step/summary logging for visibility in tests and support */
|
|
40
|
+
const stepLog = typeof process !== 'undefined'
|
|
41
|
+
? (msg, data) => {
|
|
42
|
+
if (data != null && Object.keys(data).length > 0) {
|
|
43
|
+
console.log(`[WorkflowExecutor] ${msg}`, data);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.log(`[WorkflowExecutor] ${msg}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
: () => { };
|
|
50
|
+
/** Normalize error to a string and extract HTTP details when present (e.g. Axios) */
|
|
51
|
+
function formatErrorDetails(error) {
|
|
52
|
+
var _a, _b, _c, _d;
|
|
53
|
+
const err = error;
|
|
54
|
+
const message = (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : String(error);
|
|
55
|
+
const out = { message };
|
|
56
|
+
if (err === null || err === void 0 ? void 0 : err.stack)
|
|
57
|
+
out.stack = err.stack;
|
|
58
|
+
if (err === null || err === void 0 ? void 0 : err.response) {
|
|
59
|
+
out.status = (_b = err.response) === null || _b === void 0 ? void 0 : _b.status;
|
|
60
|
+
const data = (_c = err.response) === null || _c === void 0 ? void 0 : _c.data;
|
|
61
|
+
out.responseBody = data;
|
|
62
|
+
// Prefer API error reason over generic "Request failed with status code N"
|
|
63
|
+
const apiErrors = data === null || data === void 0 ? void 0 : data.errors;
|
|
64
|
+
if (apiErrors != null) {
|
|
65
|
+
out.reason = typeof apiErrors === 'string' ? apiErrors : ((_d = apiErrors === null || apiErrors === void 0 ? void 0 : apiErrors.message) !== null && _d !== void 0 ? _d : JSON.stringify(apiErrors));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* WorkflowExecutor handles the execution of workflow steps
|
|
72
|
+
*/
|
|
73
|
+
class WorkflowExecutor {
|
|
74
|
+
constructor(config, workflow, options, private_key, sessionLogFields, preInitializedBuilder) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
this._processorService = null;
|
|
77
|
+
this._graphService = null;
|
|
78
|
+
this._databaseService = null;
|
|
79
|
+
this._brokersService = null;
|
|
80
|
+
this._storageService = null;
|
|
81
|
+
this._vectorService = null;
|
|
82
|
+
this._quotaService = null;
|
|
83
|
+
this._fallbackService = null;
|
|
84
|
+
this.productId = null;
|
|
85
|
+
/** Pending signals waiting to be resolved */
|
|
86
|
+
this.pendingSignals = new Map();
|
|
87
|
+
/** Signal polling interval (ms) */
|
|
88
|
+
this.signalPollInterval = 2000;
|
|
89
|
+
/** Signal polling timer */
|
|
90
|
+
this.signalPollTimer = null;
|
|
91
|
+
/** Session log fields for logging */
|
|
92
|
+
this.sessionLogFields = {};
|
|
93
|
+
/** LogService instance for logging operations */
|
|
94
|
+
this.logService = null;
|
|
95
|
+
/** Base log fields inherited by all step logs */
|
|
96
|
+
this.baseLogs = null;
|
|
97
|
+
/** Set when a graph step runs; we disconnect once at end of execute() instead of per-step. */
|
|
98
|
+
this.graphConnectionUsed = false;
|
|
99
|
+
/** Pre-fetched bootstrap data per step tag (workflow batch prefetch). */
|
|
100
|
+
this.stepBootstrapCache = new Map();
|
|
101
|
+
debugLog('[WorkflowExecutor] constructor ENTRY', {
|
|
102
|
+
workflow_tag: workflow.tag,
|
|
103
|
+
product: options.product,
|
|
104
|
+
env: options.env,
|
|
105
|
+
hasSessionFields: !!sessionLogFields && Object.keys(sessionLogFields).length > 0,
|
|
106
|
+
});
|
|
107
|
+
this.config = config;
|
|
108
|
+
this.workflow = workflow;
|
|
109
|
+
this.sessionLogFields = sessionLogFields || {};
|
|
110
|
+
this._privateKey = private_key || '';
|
|
111
|
+
this.preInitializedProduct = Boolean(preInitializedBuilder);
|
|
112
|
+
// Use pre-initialized builder from WorkflowService when provided to avoid duplicate initProduct API call
|
|
113
|
+
this.productBuilder = preInitializedBuilder !== null && preInitializedBuilder !== void 0 ? preInitializedBuilder : new products_service_1.default({
|
|
114
|
+
workspace_id: config.workspace_id,
|
|
115
|
+
public_key: config.public_key,
|
|
116
|
+
user_id: config.user_id,
|
|
117
|
+
token: config.token,
|
|
118
|
+
env_type: config.env_type,
|
|
119
|
+
access_key: config.access_key,
|
|
120
|
+
workspace_private_key: this._privateKey || undefined,
|
|
121
|
+
});
|
|
122
|
+
// Lightweight API services (created up front)
|
|
123
|
+
this.processorApiService = new processorApi_service_1.ProcessorApiService(config.env_type);
|
|
124
|
+
this.workflowApiService = new workflowApi_service_1.WorkflowApiService(config.env_type);
|
|
125
|
+
// Heavy services are lazy-initialized on first use (getProcessorService, getGraphService, etc.)
|
|
126
|
+
// Initialize workflow state
|
|
127
|
+
this.state = {
|
|
128
|
+
workflow_id: (0, crypto_1.randomUUID)(),
|
|
129
|
+
workflow_tag: workflow.tag,
|
|
130
|
+
product: options.product,
|
|
131
|
+
env: options.env,
|
|
132
|
+
input: options.input,
|
|
133
|
+
steps: {},
|
|
134
|
+
completed_steps: [],
|
|
135
|
+
step_timings: [],
|
|
136
|
+
state: {},
|
|
137
|
+
status: types_1.WorkflowStatus.PENDING,
|
|
138
|
+
started_at: Date.now(),
|
|
139
|
+
};
|
|
140
|
+
debugLog('[WorkflowExecutor] constructor DONE', {
|
|
141
|
+
workflow_id: this.state.workflow_id,
|
|
142
|
+
workflow_tag: this.state.workflow_tag,
|
|
143
|
+
steps_count: (_b = (_a = workflow.steps) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get auth payload for API calls
|
|
148
|
+
*/
|
|
149
|
+
getAuthPayload() {
|
|
150
|
+
return {
|
|
151
|
+
user_id: this.config.user_id,
|
|
152
|
+
workspace_id: this.config.workspace_id,
|
|
153
|
+
public_key: this.config.public_key,
|
|
154
|
+
token: this.config.token,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** Lazy-initialized processor (shares productBuilder to avoid duplicate product init per step). */
|
|
158
|
+
getProcessorService() {
|
|
159
|
+
if (!this._processorService) {
|
|
160
|
+
this._processorService = new processor_service_1.default({
|
|
161
|
+
workspace_id: this.config.workspace_id,
|
|
162
|
+
public_key: this.config.public_key,
|
|
163
|
+
user_id: this.config.user_id,
|
|
164
|
+
token: this.config.token,
|
|
165
|
+
env_type: this.config.env_type,
|
|
166
|
+
private_key: this._privateKey,
|
|
167
|
+
access_key: this.config.access_key,
|
|
168
|
+
preInitializedProductBuilder: this.productBuilder,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return this._processorService;
|
|
172
|
+
}
|
|
173
|
+
/** Lazy-initialized graph service. */
|
|
174
|
+
getGraphService() {
|
|
175
|
+
if (!this._graphService) {
|
|
176
|
+
this._graphService = new graph_1.GraphService({
|
|
177
|
+
workspace_id: this.config.workspace_id,
|
|
178
|
+
public_key: this.config.public_key,
|
|
179
|
+
user_id: this.config.user_id,
|
|
180
|
+
token: this.config.token,
|
|
181
|
+
env_type: this.config.env_type,
|
|
182
|
+
private_key: this._privateKey,
|
|
183
|
+
access_key: this.config.access_key,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return this._graphService;
|
|
187
|
+
}
|
|
188
|
+
/** Lazy-initialized database service. */
|
|
189
|
+
getDatabaseService() {
|
|
190
|
+
if (!this._databaseService) {
|
|
191
|
+
this._databaseService = new database_1.DatabaseService({
|
|
192
|
+
workspace_id: this.config.workspace_id,
|
|
193
|
+
public_key: this.config.public_key,
|
|
194
|
+
user_id: this.config.user_id,
|
|
195
|
+
token: this.config.token,
|
|
196
|
+
env_type: this.config.env_type,
|
|
197
|
+
private_key: this._privateKey,
|
|
198
|
+
access_key: this.config.access_key,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return this._databaseService;
|
|
202
|
+
}
|
|
203
|
+
/** Lazy-initialized brokers service. Used for produce steps so ctx.messaging.produce uses the same path as ductape.messaging.produce (pool, tracking, cache). */
|
|
204
|
+
getBrokersService() {
|
|
205
|
+
if (!this._brokersService) {
|
|
206
|
+
this._brokersService = new brokers_1.BrokersService({
|
|
207
|
+
workspace_id: this.config.workspace_id,
|
|
208
|
+
public_key: this.config.public_key,
|
|
209
|
+
user_id: this.config.user_id,
|
|
210
|
+
token: this.config.token,
|
|
211
|
+
env_type: this.config.env_type,
|
|
212
|
+
access_key: this.config.access_key,
|
|
213
|
+
redis_client: this.config.redis_client,
|
|
214
|
+
preInitializedProductBuilder: this.productBuilder,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return this._brokersService;
|
|
218
|
+
}
|
|
219
|
+
/** Lazy-initialized storage service. Used for storage steps (upload/download/delete) instead of processor. */
|
|
220
|
+
getStorageService() {
|
|
221
|
+
if (!this._storageService) {
|
|
222
|
+
this._storageService = new storage_1.StorageService({
|
|
223
|
+
workspace_id: this.config.workspace_id,
|
|
224
|
+
public_key: this.config.public_key,
|
|
225
|
+
user_id: this.config.user_id,
|
|
226
|
+
token: this.config.token,
|
|
227
|
+
env_type: this.config.env_type,
|
|
228
|
+
redis_client: this.config.redis_client,
|
|
229
|
+
private_key: this._privateKey,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return this._storageService;
|
|
233
|
+
}
|
|
234
|
+
/** Lazy-initialized vector service. Used for vector steps (query/upsert/delete/execute action). */
|
|
235
|
+
getVectorService() {
|
|
236
|
+
if (!this._vectorService) {
|
|
237
|
+
this._vectorService = new vector_1.VectorDatabaseService({
|
|
238
|
+
workspace_id: this.config.workspace_id,
|
|
239
|
+
public_key: this.config.public_key,
|
|
240
|
+
user_id: this.config.user_id,
|
|
241
|
+
token: this.config.token,
|
|
242
|
+
env_type: this.config.env_type,
|
|
243
|
+
redis_client: this.config.redis_client,
|
|
244
|
+
private_key: this._privateKey,
|
|
245
|
+
access_key: this.config.access_key,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return this._vectorService;
|
|
249
|
+
}
|
|
250
|
+
/** Lazy-initialized quota service. */
|
|
251
|
+
getQuotaService() {
|
|
252
|
+
if (!this._quotaService) {
|
|
253
|
+
this._quotaService = new resilience_1.QuotaService({
|
|
254
|
+
workspace_id: this.config.workspace_id,
|
|
255
|
+
public_key: this.config.public_key,
|
|
256
|
+
user_id: this.config.user_id,
|
|
257
|
+
token: this.config.token,
|
|
258
|
+
env_type: this.config.env_type,
|
|
259
|
+
private_key: this._privateKey,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return this._quotaService;
|
|
263
|
+
}
|
|
264
|
+
/** Lazy-initialized fallback service. */
|
|
265
|
+
getFallbackService() {
|
|
266
|
+
if (!this._fallbackService) {
|
|
267
|
+
this._fallbackService = new resilience_1.FallbackService({
|
|
268
|
+
workspace_id: this.config.workspace_id,
|
|
269
|
+
public_key: this.config.public_key,
|
|
270
|
+
user_id: this.config.user_id,
|
|
271
|
+
token: this.config.token,
|
|
272
|
+
env_type: this.config.env_type,
|
|
273
|
+
private_key: this._privateKey,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return this._fallbackService;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Persist workflow execution result to backend
|
|
280
|
+
*/
|
|
281
|
+
async persistExecutionResult(status, output, error) {
|
|
282
|
+
debugLog('[WorkflowExecutor] persistExecutionResult ENTRY', {
|
|
283
|
+
workflow_id: this.state.workflow_id,
|
|
284
|
+
workflow_tag: this.state.workflow_tag,
|
|
285
|
+
status,
|
|
286
|
+
hasError: !!error,
|
|
287
|
+
});
|
|
288
|
+
try {
|
|
289
|
+
const resultData = {
|
|
290
|
+
workflow_tag: this.state.workflow_tag,
|
|
291
|
+
input: this.state.input,
|
|
292
|
+
output,
|
|
293
|
+
completed_steps: this.state.completed_steps,
|
|
294
|
+
failed_step: this.state.failed_step,
|
|
295
|
+
step_outputs: this.state.steps,
|
|
296
|
+
error,
|
|
297
|
+
};
|
|
298
|
+
const inputPayload = { product: this.state.product, env: this.state.env, event: this.state.workflow_tag, input: this.state.input };
|
|
299
|
+
const processorResult = {
|
|
300
|
+
process_id: this.state.workflow_id,
|
|
301
|
+
product_id: this.productId || null,
|
|
302
|
+
env: this.state.env,
|
|
303
|
+
component: types_1.LogEventTypes.WORKFLOW,
|
|
304
|
+
status,
|
|
305
|
+
start: this.state.started_at,
|
|
306
|
+
end: Date.now(),
|
|
307
|
+
retryable: true,
|
|
308
|
+
result: JSON.stringify(resultData),
|
|
309
|
+
feature_id: undefined,
|
|
310
|
+
input: JSON.stringify(inputPayload),
|
|
311
|
+
workflow_id: this.state.workflow_id,
|
|
312
|
+
workflow_tag: this.state.workflow_tag,
|
|
313
|
+
product_tag: this.state.product,
|
|
314
|
+
workspace_id: this.config.workspace_id,
|
|
315
|
+
};
|
|
316
|
+
await this.processorApiService.saveResult(processorResult, this.getAuthPayload());
|
|
317
|
+
debugLog('[WorkflowExecutor] persistExecutionResult SUCCESS', { workflow_id: this.state.workflow_id, status });
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
// Log error but don't throw - persistence failure shouldn't fail the workflow
|
|
321
|
+
debugLog('[WorkflowExecutor] persistExecutionResult FAILED', { workflow_id: this.state.workflow_id, status, error: err });
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Step processor results must always use component: 'workflow_step'.
|
|
326
|
+
* step_type is the step kind: action, notification, storage, produce, database_action, graph, vector, quota, fallback, child_workflow, sleep, wait_for_signal, checkpoint, feature.
|
|
327
|
+
*/
|
|
328
|
+
getStepTypeForResult(step) {
|
|
329
|
+
var _a;
|
|
330
|
+
if (step.type === types_1.WorkflowStepType.PUBLISH)
|
|
331
|
+
return 'produce';
|
|
332
|
+
return (_a = step.type) !== null && _a !== void 0 ? _a : 'action';
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Persist individual step execution to backend (input/output per step in processor result).
|
|
336
|
+
* Processor results for steps always have component: 'workflow_step' and step_type set to the step kind.
|
|
337
|
+
*/
|
|
338
|
+
async persistStepResult(step, status, output, error, duration, input) {
|
|
339
|
+
const resolvedInput = input !== null && input !== void 0 ? input : step.input;
|
|
340
|
+
const stepType = this.getStepTypeForResult(step);
|
|
341
|
+
debugLog('[WorkflowExecutor] persistStepResult ENTRY', {
|
|
342
|
+
workflow_id: this.state.workflow_id,
|
|
343
|
+
step_tag: step.tag,
|
|
344
|
+
step_type: stepType,
|
|
345
|
+
status,
|
|
346
|
+
durationMs: duration,
|
|
347
|
+
});
|
|
348
|
+
try {
|
|
349
|
+
// Persist result that matches the step's return shape (workflow definition step.output) when defined
|
|
350
|
+
const stepProcessId = `${this.state.workflow_id}:${step.tag}`;
|
|
351
|
+
let value;
|
|
352
|
+
if (status === types_1.LogEventStatus.SUCCESS) {
|
|
353
|
+
const out = output !== null && output !== void 0 ? output : {};
|
|
354
|
+
const raw = typeof out === 'object' && out !== null && 'output' in out
|
|
355
|
+
? out.output
|
|
356
|
+
: out;
|
|
357
|
+
const outputSchema = step.output;
|
|
358
|
+
if (outputSchema && typeof outputSchema === 'object' && !Array.isArray(outputSchema) && Object.keys(outputSchema).length > 0) {
|
|
359
|
+
try {
|
|
360
|
+
value = await this.resolveInput(outputSchema);
|
|
361
|
+
}
|
|
362
|
+
catch (_a) {
|
|
363
|
+
value = raw;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
value = raw;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
value = { error: error !== null && error !== void 0 ? error : 'Step failed' };
|
|
372
|
+
}
|
|
373
|
+
const resultPayload = { process_id: stepProcessId, result: value };
|
|
374
|
+
const stepResult = {
|
|
375
|
+
process_id: stepProcessId,
|
|
376
|
+
product_id: this.productId || null,
|
|
377
|
+
env: this.state.env,
|
|
378
|
+
component: types_1.LogEventTypes.WORKFLOW_STEP, // step results always workflow_step
|
|
379
|
+
status,
|
|
380
|
+
start: Date.now() - (duration || 0),
|
|
381
|
+
end: Date.now(),
|
|
382
|
+
retryable: true,
|
|
383
|
+
result: JSON.stringify(resultPayload),
|
|
384
|
+
feature_id: undefined,
|
|
385
|
+
input: JSON.stringify(resolvedInput),
|
|
386
|
+
workflow_id: this.state.workflow_id,
|
|
387
|
+
workflow_tag: this.state.workflow_tag,
|
|
388
|
+
product_tag: this.state.product,
|
|
389
|
+
workspace_id: this.config.workspace_id,
|
|
390
|
+
step_tag: step.tag,
|
|
391
|
+
step_type: stepType, // action | notification | storage | produce | database_action | graph | vector | quota | fallback | child_workflow | sleep | wait_for_signal | checkpoint | feature
|
|
392
|
+
step_error: error,
|
|
393
|
+
step_duration_ms: duration,
|
|
394
|
+
};
|
|
395
|
+
this.processorApiService.saveResult(stepResult, this.getAuthPayload()).then(() => debugLog('[WorkflowExecutor] persistStepResult SUCCESS', { workflow_id: this.state.workflow_id, step_tag: step.tag }), (err) => debugLog('[WorkflowExecutor] persistStepResult FAILED', { workflow_id: this.state.workflow_id, step_tag: step.tag, error: err }));
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
debugLog('[WorkflowExecutor] persistStepResult ENTRY FAILED', { workflow_id: this.state.workflow_id, step_tag: step.tag, error: err });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Initialize logging service and base log fields
|
|
403
|
+
*/
|
|
404
|
+
initializeLogging() {
|
|
405
|
+
if (!this.logService && this.productId) {
|
|
406
|
+
this.logService = new logs_service_1.default({
|
|
407
|
+
product_id: this.productId,
|
|
408
|
+
workspace_id: this.config.workspace_id,
|
|
409
|
+
public_key: this.config.public_key,
|
|
410
|
+
user_id: this.config.user_id,
|
|
411
|
+
token: this.config.token,
|
|
412
|
+
env_type: this.config.env_type,
|
|
413
|
+
});
|
|
414
|
+
// Set up base logs that all step logs inherit
|
|
415
|
+
this.baseLogs = Object.assign({ product_tag: this.state.product, workspace_id: this.config.workspace_id, env: this.state.env, process_id: this.state.workflow_id, type: logs_types_1.LogEventTypes.WORKFLOW, parent_tag: this.state.workflow_tag }, this.sessionLogFields);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Log a step execution event
|
|
420
|
+
*/
|
|
421
|
+
logStepEvent(step, message, status, additionalData) {
|
|
422
|
+
if (!this.logService || !this.baseLogs)
|
|
423
|
+
return;
|
|
424
|
+
const stepTypeDisplay = step.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : step.type;
|
|
425
|
+
const stepProcessId = `${this.state.workflow_id}:${step.tag}`;
|
|
426
|
+
this.logService.add(Object.assign(Object.assign({}, this.baseLogs), { process_id: stepProcessId, type: logs_types_1.LogEventTypes.WORKFLOW_STEP, child_tag: step.tag, message,
|
|
427
|
+
status, data: Object.assign({ workflow: this.state.workflow_tag, workflow_id: this.state.workflow_id, step: step.tag, step_type: stepTypeDisplay }, additionalData) }));
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Execute the workflow
|
|
431
|
+
*/
|
|
432
|
+
async execute() {
|
|
433
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
434
|
+
const startTime = Date.now();
|
|
435
|
+
debugLog('[WorkflowExecutor] execute ENTRY', {
|
|
436
|
+
workflow_id: this.state.workflow_id,
|
|
437
|
+
workflow_tag: this.state.workflow_tag,
|
|
438
|
+
product: this.state.product,
|
|
439
|
+
env: this.state.env,
|
|
440
|
+
});
|
|
441
|
+
try {
|
|
442
|
+
// Track phase so failures before first step are reported as (initialization)
|
|
443
|
+
this.state.current_step = '(initialization)';
|
|
444
|
+
// Skip product init when builder was pre-initialized by WorkflowService (avoids duplicate initProduct API call)
|
|
445
|
+
if (this.preInitializedProduct) {
|
|
446
|
+
this.productId = this.productBuilder.fetchProductId();
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
await this.productBuilder.initializeProductByTag(this.state.product);
|
|
450
|
+
this.productId = this.productBuilder.fetchProductId();
|
|
451
|
+
}
|
|
452
|
+
debugLog('[WorkflowExecutor] execute product initialized', { workflow_id: this.state.workflow_id, product_id: this.productId });
|
|
453
|
+
// Initialize logging after we have product ID
|
|
454
|
+
this.initializeLogging();
|
|
455
|
+
this.state.status = types_1.WorkflowStatus.RUNNING;
|
|
456
|
+
// Get steps in execution order (respecting dependencies)
|
|
457
|
+
const orderedSteps = this.getOrderedSteps();
|
|
458
|
+
stepLog('Ordered steps', {
|
|
459
|
+
count: orderedSteps.length,
|
|
460
|
+
steps: orderedSteps.map((s) => ({ tag: s.tag, type: s.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : s.type })),
|
|
461
|
+
});
|
|
462
|
+
debugLog('[WorkflowExecutor] execute ordered steps', {
|
|
463
|
+
workflow_id: this.state.workflow_id,
|
|
464
|
+
steps_count: orderedSteps.length,
|
|
465
|
+
step_tags: orderedSteps.map((s) => s.tag),
|
|
466
|
+
});
|
|
467
|
+
// Pre-fetch all action/notification/storage bootstrap data in one backend call (cached for step executors)
|
|
468
|
+
try {
|
|
469
|
+
await this.prefetchStepBootstrap(orderedSteps);
|
|
470
|
+
}
|
|
471
|
+
catch (prefetchErr) {
|
|
472
|
+
stepLog('Bootstrap prefetch failed (continuing without prefetch)', {
|
|
473
|
+
error: (_a = prefetchErr === null || prefetchErr === void 0 ? void 0 : prefetchErr.message) !== null && _a !== void 0 ? _a : String(prefetchErr),
|
|
474
|
+
});
|
|
475
|
+
this.stepBootstrapCache.clear();
|
|
476
|
+
}
|
|
477
|
+
// Execute each step
|
|
478
|
+
for (const step of orderedSteps) {
|
|
479
|
+
// Check step condition if present
|
|
480
|
+
if (step.condition && !(await this.evaluateCondition(step.condition))) {
|
|
481
|
+
debugLog('[WorkflowExecutor] execute step SKIPPED (condition)', { workflow_id: this.state.workflow_id, step_tag: step.tag });
|
|
482
|
+
this.logStepEvent(step, `Step ${step.tag} - skipped (condition not met)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
|
|
483
|
+
continue; // Skip step if condition not met
|
|
484
|
+
}
|
|
485
|
+
this.state.current_step = step.tag;
|
|
486
|
+
stepLog('Step start', { tag: step.tag, type: step.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : step.type });
|
|
487
|
+
debugLog('[WorkflowExecutor] execute step START', { workflow_id: this.state.workflow_id, step_tag: step.tag, step_type: step.type });
|
|
488
|
+
// Log step start
|
|
489
|
+
this.logStepEvent(step, `Step ${step.tag} - started`, logs_types_1.LogEventStatus.PROCESSING);
|
|
490
|
+
const result = await this.executeStep(step);
|
|
491
|
+
stepLog('Step end', Object.assign({ tag: step.tag, type: step.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : step.type, success: result.success, duration_ms: result.duration }, (result.error && { error: result.error })));
|
|
492
|
+
console.warn(`[WorkflowExecutor] Step "${step.tag}" output:`, result.output);
|
|
493
|
+
if (result.error) {
|
|
494
|
+
console.warn(`[WorkflowExecutor] Step "${step.tag}" error:`, result.error);
|
|
495
|
+
}
|
|
496
|
+
debugLog('[WorkflowExecutor] execute step END', {
|
|
497
|
+
workflow_id: this.state.workflow_id,
|
|
498
|
+
step_tag: step.tag,
|
|
499
|
+
success: result.success,
|
|
500
|
+
durationMs: result.duration,
|
|
501
|
+
hasError: !!result.error,
|
|
502
|
+
input: result.input,
|
|
503
|
+
output: result.output,
|
|
504
|
+
});
|
|
505
|
+
// Log step completion
|
|
506
|
+
this.logStepEvent(step, result.success ? `Step ${step.tag} - completed` : `Step ${step.tag} - failed`, result.success ? logs_types_1.LogEventStatus.SUCCESS : logs_types_1.LogEventStatus.FAIL, { duration: result.duration, error: result.error });
|
|
507
|
+
// Persist step result to backend
|
|
508
|
+
await this.persistStepResult(step, result.success ? types_1.LogEventStatus.SUCCESS : types_1.LogEventStatus.FAIL, result.output, result.error, result.duration, result.input);
|
|
509
|
+
this.state.step_timings.push({
|
|
510
|
+
tag: step.tag,
|
|
511
|
+
duration_ms: result.duration,
|
|
512
|
+
success: result.success,
|
|
513
|
+
});
|
|
514
|
+
if (!result.success) {
|
|
515
|
+
this.state.failed_step = step.tag;
|
|
516
|
+
stepLog('Step failed', { tag: step.tag, error: result.error, allow_fail: (_b = step.options) === null || _b === void 0 ? void 0 : _b.allow_fail, optional: (_c = step.options) === null || _c === void 0 ? void 0 : _c.optional });
|
|
517
|
+
debugLog('[WorkflowExecutor] execute step FAILED', {
|
|
518
|
+
workflow_id: this.state.workflow_id,
|
|
519
|
+
step_tag: step.tag,
|
|
520
|
+
error: result.error,
|
|
521
|
+
allow_fail: (_d = step.options) === null || _d === void 0 ? void 0 : _d.allow_fail,
|
|
522
|
+
optional: (_e = step.options) === null || _e === void 0 ? void 0 : _e.optional,
|
|
523
|
+
});
|
|
524
|
+
// Check if step allows failure
|
|
525
|
+
if ((_f = step.options) === null || _f === void 0 ? void 0 : _f.allow_fail) {
|
|
526
|
+
// Store error but continue
|
|
527
|
+
this.state.steps[step.tag] = { error: result.error };
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
// Check if step is optional
|
|
531
|
+
if ((_g = step.options) === null || _g === void 0 ? void 0 : _g.optional) {
|
|
532
|
+
// Don't trigger rollback, just continue
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
// Trigger rollback
|
|
536
|
+
this.state.status = types_1.WorkflowStatus.ROLLING_BACK;
|
|
537
|
+
debugLog('[WorkflowExecutor] execute ROLLBACK START', { workflow_id: this.state.workflow_id, failed_step: step.tag, reason: result.error });
|
|
538
|
+
const rollbackResult = await this.executeRollback(step.tag, result.error || 'Step failed');
|
|
539
|
+
debugLog('[WorkflowExecutor] execute ROLLBACK END', {
|
|
540
|
+
workflow_id: this.state.workflow_id,
|
|
541
|
+
success: rollbackResult.success,
|
|
542
|
+
rolled_back_steps: rollbackResult.rolled_back_steps,
|
|
543
|
+
failed_rollbacks: (_j = (_h = rollbackResult.failed_steps) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0,
|
|
544
|
+
});
|
|
545
|
+
// Persist failed workflow result
|
|
546
|
+
await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, result.error);
|
|
547
|
+
stepLog('Run finished (rollback)', {
|
|
548
|
+
status: types_1.WorkflowStatus.ROLLED_BACK,
|
|
549
|
+
failed_step: step.tag,
|
|
550
|
+
error: result.error,
|
|
551
|
+
completed_steps: this.state.completed_steps,
|
|
552
|
+
step_timings: this.state.step_timings,
|
|
553
|
+
});
|
|
554
|
+
await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
|
|
555
|
+
if (this.graphConnectionUsed) {
|
|
556
|
+
await this.getGraphService().disconnect().catch(() => { });
|
|
557
|
+
await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
|
|
558
|
+
if (this._brokersService)
|
|
559
|
+
await this._brokersService.disconnectAll().catch(() => { });
|
|
560
|
+
await this.getProcessorService().disconnectMailTransporters().catch(() => { });
|
|
561
|
+
await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
|
|
562
|
+
await this.getProcessorService().disconnectSmsClients().catch(() => { });
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
status: types_1.WorkflowStatus.ROLLED_BACK,
|
|
566
|
+
workflow_id: this.state.workflow_id,
|
|
567
|
+
error: result.error,
|
|
568
|
+
execution_time: Date.now() - startTime,
|
|
569
|
+
completed_steps: this.state.completed_steps,
|
|
570
|
+
step_timings: this.state.step_timings,
|
|
571
|
+
failed_step: step.tag,
|
|
572
|
+
rollback_info: {
|
|
573
|
+
triggered_by: step.tag,
|
|
574
|
+
reason: result.error || 'Step failed',
|
|
575
|
+
rolled_back_steps: rollbackResult.rolled_back_steps,
|
|
576
|
+
failed_rollbacks: rollbackResult.failed_steps,
|
|
577
|
+
},
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
// Store step output and mark as completed
|
|
581
|
+
this.state.steps[step.tag] = result.output;
|
|
582
|
+
this.state.completed_steps.push(step.tag);
|
|
583
|
+
}
|
|
584
|
+
this.state.status = types_1.WorkflowStatus.COMPLETED;
|
|
585
|
+
this.state.ended_at = Date.now();
|
|
586
|
+
// Determine output - use last step output or aggregate (resolves $ operators)
|
|
587
|
+
const output = await this.determineWorkflowOutput();
|
|
588
|
+
stepLog('Run finished (completed)', {
|
|
589
|
+
status: types_1.WorkflowStatus.COMPLETED,
|
|
590
|
+
completed_steps: this.state.completed_steps,
|
|
591
|
+
step_timings: this.state.step_timings,
|
|
592
|
+
execution_time_ms: Date.now() - startTime,
|
|
593
|
+
});
|
|
594
|
+
debugLog('[WorkflowExecutor] execute COMPLETED', {
|
|
595
|
+
workflow_id: this.state.workflow_id,
|
|
596
|
+
workflow_tag: this.state.workflow_tag,
|
|
597
|
+
completed_steps: this.state.completed_steps.length,
|
|
598
|
+
execution_time_ms: Date.now() - startTime,
|
|
599
|
+
});
|
|
600
|
+
// Persist successful workflow result
|
|
601
|
+
await this.persistExecutionResult(types_1.LogEventStatus.SUCCESS, output);
|
|
602
|
+
// Fire-and-forget log publish on success so we don't block on log upload
|
|
603
|
+
(_l = this.logService) === null || _l === void 0 ? void 0 : _l.publish().catch(() => { });
|
|
604
|
+
if (this.graphConnectionUsed) {
|
|
605
|
+
await this.getGraphService().disconnect().catch(() => { });
|
|
606
|
+
await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
|
|
607
|
+
if (this._brokersService)
|
|
608
|
+
await this._brokersService.disconnectAll().catch(() => { });
|
|
609
|
+
await this.getProcessorService().disconnectMailTransporters().catch(() => { });
|
|
610
|
+
await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
|
|
611
|
+
await this.getProcessorService().disconnectSmsClients().catch(() => { });
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
status: types_1.WorkflowStatus.COMPLETED,
|
|
615
|
+
workflow_id: this.state.workflow_id,
|
|
616
|
+
output: output,
|
|
617
|
+
execution_time: Date.now() - startTime,
|
|
618
|
+
completed_steps: this.state.completed_steps,
|
|
619
|
+
step_timings: this.state.step_timings,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
this.state.status = types_1.WorkflowStatus.FAILED;
|
|
624
|
+
this.state.ended_at = Date.now();
|
|
625
|
+
const details = formatErrorDetails(error);
|
|
626
|
+
const failedAt = (_m = this.state.current_step) !== null && _m !== void 0 ? _m : '(unknown)';
|
|
627
|
+
debugLog('[WorkflowExecutor] execute FAILED (exception)', Object.assign(Object.assign({ workflow_id: this.state.workflow_id, workflow_tag: this.state.workflow_tag, failed_at: failedAt, completed_steps: this.state.completed_steps, error: details.message }, (details.status != null && { http_status: details.status })), (details.responseBody != null && { response_body: details.responseBody })));
|
|
628
|
+
if (details.stack) {
|
|
629
|
+
debugLog('[WorkflowExecutor] execute FAILED stack', details.stack);
|
|
630
|
+
}
|
|
631
|
+
// Persist failed workflow result with clear failure reason
|
|
632
|
+
const errorSummary = details.status != null
|
|
633
|
+
? `Failed at ${failedAt}: ${details.message} (HTTP ${details.status})`
|
|
634
|
+
: `Failed at ${failedAt}: ${details.message}`;
|
|
635
|
+
stepLog('Run finished (failed - exception)', Object.assign({ status: types_1.WorkflowStatus.FAILED, failed_step: failedAt, error: errorSummary, completed_steps: this.state.completed_steps, step_timings: this.state.step_timings }, (details.reason && { reason: details.reason })));
|
|
636
|
+
await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, errorSummary);
|
|
637
|
+
await ((_o = this.logService) === null || _o === void 0 ? void 0 : _o.publish());
|
|
638
|
+
if (this.graphConnectionUsed) {
|
|
639
|
+
await this.getGraphService().disconnect().catch(() => { });
|
|
640
|
+
await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
|
|
641
|
+
if (this._brokersService)
|
|
642
|
+
await this._brokersService.disconnectAll().catch(() => { });
|
|
643
|
+
await this.getProcessorService().disconnectMailTransporters().catch(() => { });
|
|
644
|
+
await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
|
|
645
|
+
await this.getProcessorService().disconnectSmsClients().catch(() => { });
|
|
646
|
+
}
|
|
647
|
+
return {
|
|
648
|
+
status: types_1.WorkflowStatus.FAILED,
|
|
649
|
+
workflow_id: this.state.workflow_id,
|
|
650
|
+
error: errorSummary,
|
|
651
|
+
execution_time: Date.now() - startTime,
|
|
652
|
+
completed_steps: this.state.completed_steps,
|
|
653
|
+
step_timings: this.state.step_timings,
|
|
654
|
+
failed_step: this.state.current_step,
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Execute a single step
|
|
660
|
+
*/
|
|
661
|
+
async executeStep(step) {
|
|
662
|
+
const startTime = Date.now();
|
|
663
|
+
debugLog('[WorkflowExecutor] executeStep ENTRY', {
|
|
664
|
+
workflow_id: this.state.workflow_id,
|
|
665
|
+
step_tag: step.tag,
|
|
666
|
+
step_type: step.type,
|
|
667
|
+
});
|
|
668
|
+
let resolvedInput = {};
|
|
669
|
+
try {
|
|
670
|
+
// Resolve input with data references and all $ operators
|
|
671
|
+
resolvedInput = (await this.resolveInput(step.input || {}));
|
|
672
|
+
debugLog('[WorkflowExecutor] executeStep input', {
|
|
673
|
+
workflow_id: this.state.workflow_id,
|
|
674
|
+
step_tag: step.tag,
|
|
675
|
+
input: resolvedInput,
|
|
676
|
+
});
|
|
677
|
+
let output;
|
|
678
|
+
// Route steps to dedicated services; only action and notification use ProcessorService.
|
|
679
|
+
switch (step.type) {
|
|
680
|
+
case types_1.WorkflowStepType.ACTION:
|
|
681
|
+
output = await this.executeActionStep(step, resolvedInput);
|
|
682
|
+
break;
|
|
683
|
+
case types_1.WorkflowStepType.DATABASE_ACTION:
|
|
684
|
+
output = await this.executeDatabaseStep(step, resolvedInput);
|
|
685
|
+
break;
|
|
686
|
+
case types_1.WorkflowStepType.NOTIFICATION:
|
|
687
|
+
output = await this.executeNotificationStep(step, resolvedInput);
|
|
688
|
+
break;
|
|
689
|
+
case types_1.WorkflowStepType.STORAGE:
|
|
690
|
+
output = await this.executeStorageStep(step, resolvedInput);
|
|
691
|
+
break;
|
|
692
|
+
case types_1.WorkflowStepType.PUBLISH:
|
|
693
|
+
case types_1.WorkflowStepType.PRODUCE:
|
|
694
|
+
output = await this.executeProduceStep(step, resolvedInput);
|
|
695
|
+
break;
|
|
696
|
+
case types_1.WorkflowStepType.GRAPH:
|
|
697
|
+
output = await this.executeGraphStep(step, resolvedInput);
|
|
698
|
+
break;
|
|
699
|
+
case types_1.WorkflowStepType.VECTOR:
|
|
700
|
+
output = await this.executeVectorStep(step, resolvedInput);
|
|
701
|
+
break;
|
|
702
|
+
case types_1.WorkflowStepType.QUOTA:
|
|
703
|
+
output = await this.executeQuotaStep(step, resolvedInput);
|
|
704
|
+
break;
|
|
705
|
+
case types_1.WorkflowStepType.FALLBACK:
|
|
706
|
+
output = await this.executeFallbackStep(step, resolvedInput);
|
|
707
|
+
break;
|
|
708
|
+
case types_1.WorkflowStepType.CHILD_WORKFLOW:
|
|
709
|
+
output = await this.executeChildWorkflowStep(step, resolvedInput);
|
|
710
|
+
break;
|
|
711
|
+
case types_1.WorkflowStepType.SLEEP:
|
|
712
|
+
await this.executeSleepStep(step, resolvedInput);
|
|
713
|
+
output = { slept: true };
|
|
714
|
+
break;
|
|
715
|
+
case types_1.WorkflowStepType.WAIT_FOR_SIGNAL:
|
|
716
|
+
output = await this.executeWaitForSignalStep(step, resolvedInput);
|
|
717
|
+
break;
|
|
718
|
+
case types_1.WorkflowStepType.CHECKPOINT:
|
|
719
|
+
await this.executeCheckpointStep(step, resolvedInput);
|
|
720
|
+
output = { checkpoint: step.tag };
|
|
721
|
+
break;
|
|
722
|
+
default:
|
|
723
|
+
stepLog('Step type not implemented (passthrough)', { tag: step.tag, type: step.type });
|
|
724
|
+
debugLog('[WorkflowExecutor] executeStep unknown step type (passthrough)', { step_tag: step.tag, step_type: step.type });
|
|
725
|
+
output = resolvedInput;
|
|
726
|
+
}
|
|
727
|
+
const duration = Date.now() - startTime;
|
|
728
|
+
debugLog('[WorkflowExecutor] executeStep output', {
|
|
729
|
+
workflow_id: this.state.workflow_id,
|
|
730
|
+
step_tag: step.tag,
|
|
731
|
+
output,
|
|
732
|
+
durationMs: duration,
|
|
733
|
+
});
|
|
734
|
+
return {
|
|
735
|
+
success: true,
|
|
736
|
+
input: resolvedInput,
|
|
737
|
+
output,
|
|
738
|
+
duration,
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
catch (error) {
|
|
742
|
+
const duration = Date.now() - startTime;
|
|
743
|
+
const details = formatErrorDetails(error);
|
|
744
|
+
// Use API reason when present so we log why it failed (e.g. "Notification X not found") not just "Request failed with status code 500"
|
|
745
|
+
const stepErrorMsg = details.reason != null
|
|
746
|
+
? (details.status != null ? `${details.reason} (HTTP ${details.status})` : details.reason)
|
|
747
|
+
: (details.status != null ? `${details.message} (HTTP ${details.status})` : details.message);
|
|
748
|
+
debugLog('[WorkflowExecutor] executeStep FAILED', Object.assign(Object.assign({ workflow_id: this.state.workflow_id, step_tag: step.tag, step_type: step.type, durationMs: duration, input: resolvedInput, error: stepErrorMsg }, (details.status != null && { http_status: details.status })), (details.responseBody != null && { response_body: details.responseBody })));
|
|
749
|
+
return {
|
|
750
|
+
success: false,
|
|
751
|
+
input: resolvedInput,
|
|
752
|
+
error: stepErrorMsg,
|
|
753
|
+
duration,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Execute an action step
|
|
759
|
+
*/
|
|
760
|
+
async executeActionStep(step, input) {
|
|
761
|
+
var _a, _b;
|
|
762
|
+
debugLog('[WorkflowExecutor] executeActionStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, app: step.app });
|
|
763
|
+
// Step that only returns (no component call): no app → passthrough, output = resolved input
|
|
764
|
+
if (!step.app) {
|
|
765
|
+
return input;
|
|
766
|
+
}
|
|
767
|
+
return this.getProcessorService().processAction({
|
|
768
|
+
product: this.state.product,
|
|
769
|
+
env: this.state.env,
|
|
770
|
+
app: step.app,
|
|
771
|
+
action: step.event,
|
|
772
|
+
input: input,
|
|
773
|
+
retries: ((_a = step.options) === null || _a === void 0 ? void 0 : _a.retries) || 0,
|
|
774
|
+
cache: (_b = step.options) === null || _b === void 0 ? void 0 : _b.cache,
|
|
775
|
+
preloadedBootstrap: this.stepBootstrapCache.get(step.tag),
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Execute a database step: use query/insert/update/delete/upsert for DB operations, execute() for named actions.
|
|
780
|
+
*/
|
|
781
|
+
async executeDatabaseStep(step, input) {
|
|
782
|
+
const database = step.database;
|
|
783
|
+
const product = this.state.product;
|
|
784
|
+
const env = this.state.env;
|
|
785
|
+
const event = (step.event || '').toLowerCase();
|
|
786
|
+
const db = this.getDatabaseService();
|
|
787
|
+
const opts = Object.assign({ product, env, database }, input);
|
|
788
|
+
debugLog('[WorkflowExecutor] executeDatabaseStep', {
|
|
789
|
+
workflow_id: this.state.workflow_id,
|
|
790
|
+
step_tag: step.tag,
|
|
791
|
+
database,
|
|
792
|
+
event,
|
|
793
|
+
});
|
|
794
|
+
switch (event) {
|
|
795
|
+
case 'query':
|
|
796
|
+
return db.query(opts);
|
|
797
|
+
case 'insert':
|
|
798
|
+
return db.insert(opts);
|
|
799
|
+
case 'update':
|
|
800
|
+
return db.update(opts);
|
|
801
|
+
case 'delete':
|
|
802
|
+
return db.delete(opts);
|
|
803
|
+
case 'upsert':
|
|
804
|
+
return db.upsert(opts);
|
|
805
|
+
default:
|
|
806
|
+
return db.execute({
|
|
807
|
+
product,
|
|
808
|
+
env,
|
|
809
|
+
database,
|
|
810
|
+
action: step.event,
|
|
811
|
+
input: input,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Execute a notification step
|
|
817
|
+
*/
|
|
818
|
+
async executeNotificationStep(step, input) {
|
|
819
|
+
var _a;
|
|
820
|
+
const event = `${step.notification}:${step.event}`;
|
|
821
|
+
debugLog('[WorkflowExecutor] executeNotificationStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, event });
|
|
822
|
+
return this.getProcessorService().processNotification({
|
|
823
|
+
product: this.state.product,
|
|
824
|
+
env: this.state.env,
|
|
825
|
+
event,
|
|
826
|
+
input: input,
|
|
827
|
+
retries: ((_a = step.options) === null || _a === void 0 ? void 0 : _a.retries) || 0,
|
|
828
|
+
preloadedBootstrap: this.stepBootstrapCache.get(step.tag),
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Execute a storage step using StorageService (upload, download, or delete by input shape).
|
|
833
|
+
*/
|
|
834
|
+
async executeStorageStep(step, input) {
|
|
835
|
+
var _a, _b;
|
|
836
|
+
const product = this.state.product;
|
|
837
|
+
const env = this.state.env;
|
|
838
|
+
const storage = step.storage;
|
|
839
|
+
const opts = { product, env, storage };
|
|
840
|
+
debugLog('[WorkflowExecutor] executeStorageStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, storage, event: step.event });
|
|
841
|
+
const inp = input;
|
|
842
|
+
if (inp.buffer != null && inp.fileName != null) {
|
|
843
|
+
return this.getStorageService().upload(Object.assign(Object.assign({}, opts), { fileName: String(inp.fileName), buffer: inp.buffer, mimeType: inp.mimeType != null ? String(inp.mimeType) : undefined }));
|
|
844
|
+
}
|
|
845
|
+
if (inp.file_key != null) {
|
|
846
|
+
return this.getStorageService().delete(Object.assign(Object.assign({}, opts), { fileName: String(inp.file_key) }));
|
|
847
|
+
}
|
|
848
|
+
return this.getStorageService().download(Object.assign(Object.assign({}, opts), { fileName: String((_b = (_a = inp.fileName) !== null && _a !== void 0 ? _a : inp.file_key) !== null && _b !== void 0 ? _b : '') }));
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Execute a produce step (message broker produce to topic).
|
|
852
|
+
* Uses BrokersService so ctx.messaging.produce has the same behavior as ductape.messaging.produce (pool, tracking, cache).
|
|
853
|
+
*/
|
|
854
|
+
async executeProduceStep(step, input) {
|
|
855
|
+
const event = `${step.broker}:${step.event}`;
|
|
856
|
+
const message = (input && input.message != null) ? input.message : (input || {});
|
|
857
|
+
debugLog('[WorkflowExecutor] executeProduceStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, event });
|
|
858
|
+
return this.getBrokersService().publish({
|
|
859
|
+
product: this.state.product,
|
|
860
|
+
env: this.state.env,
|
|
861
|
+
event,
|
|
862
|
+
message: message,
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Execute a graph step
|
|
867
|
+
* Supports: execute (custom action), createNode, updateNode, deleteNode,
|
|
868
|
+
* createRelationship, deleteRelationship, query
|
|
869
|
+
*/
|
|
870
|
+
async executeGraphStep(step, input) {
|
|
871
|
+
const graphTag = step.graph;
|
|
872
|
+
const action = step.event;
|
|
873
|
+
debugLog('[WorkflowExecutor] executeGraphStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, graph: graphTag, action });
|
|
874
|
+
this.graphConnectionUsed = true;
|
|
875
|
+
await this.getGraphService().connect({
|
|
876
|
+
env: this.state.env,
|
|
877
|
+
product: this.state.product,
|
|
878
|
+
graph: graphTag,
|
|
879
|
+
});
|
|
880
|
+
try {
|
|
881
|
+
// Handle different graph operations based on action
|
|
882
|
+
switch (action) {
|
|
883
|
+
case 'createNode': {
|
|
884
|
+
const result = await this.getGraphService().createNode({
|
|
885
|
+
labels: input.labels,
|
|
886
|
+
properties: input.properties,
|
|
887
|
+
});
|
|
888
|
+
return result;
|
|
889
|
+
}
|
|
890
|
+
case 'updateNode': {
|
|
891
|
+
const result = await this.getGraphService().updateNode({
|
|
892
|
+
id: input.id,
|
|
893
|
+
properties: input.properties,
|
|
894
|
+
});
|
|
895
|
+
return result;
|
|
896
|
+
}
|
|
897
|
+
case 'deleteNode': {
|
|
898
|
+
const result = await this.getGraphService().deleteNode({
|
|
899
|
+
id: input.id,
|
|
900
|
+
detach: input.detach,
|
|
901
|
+
});
|
|
902
|
+
return result;
|
|
903
|
+
}
|
|
904
|
+
case 'createRelationship': {
|
|
905
|
+
const result = await this.getGraphService().createRelationship({
|
|
906
|
+
startNodeId: input.startNodeId || input.from,
|
|
907
|
+
endNodeId: input.endNodeId || input.to,
|
|
908
|
+
type: input.type,
|
|
909
|
+
properties: input.properties,
|
|
910
|
+
});
|
|
911
|
+
return result;
|
|
912
|
+
}
|
|
913
|
+
case 'deleteRelationship': {
|
|
914
|
+
const result = await this.getGraphService().deleteRelationship({
|
|
915
|
+
id: input.id,
|
|
916
|
+
});
|
|
917
|
+
return result;
|
|
918
|
+
}
|
|
919
|
+
case 'query': {
|
|
920
|
+
const result = await this.getGraphService().query(input.query, input.params);
|
|
921
|
+
return result;
|
|
922
|
+
}
|
|
923
|
+
case 'findNodes': {
|
|
924
|
+
const result = await this.getGraphService().findNodes({
|
|
925
|
+
labels: input.labels,
|
|
926
|
+
where: input.where,
|
|
927
|
+
limit: input.limit,
|
|
928
|
+
skip: input.skip,
|
|
929
|
+
});
|
|
930
|
+
return result;
|
|
931
|
+
}
|
|
932
|
+
case 'traverse': {
|
|
933
|
+
const result = await this.getGraphService().traverse({
|
|
934
|
+
startNodeId: input.startNodeId,
|
|
935
|
+
relationshipTypes: input.relationshipTypes,
|
|
936
|
+
direction: input.direction,
|
|
937
|
+
maxDepth: input.maxDepth,
|
|
938
|
+
});
|
|
939
|
+
return result;
|
|
940
|
+
}
|
|
941
|
+
default: {
|
|
942
|
+
// Execute a custom graph action
|
|
943
|
+
const result = await this.getGraphService().execute({
|
|
944
|
+
product: this.state.product,
|
|
945
|
+
env: this.state.env,
|
|
946
|
+
graph: graphTag,
|
|
947
|
+
action,
|
|
948
|
+
input,
|
|
949
|
+
});
|
|
950
|
+
return result;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
finally {
|
|
955
|
+
// Disconnect is done once at end of execute() when graphConnectionUsed (see 2.8 optimization)
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Execute a vector step (query, upsert, deleteVectors, or custom action via execute).
|
|
960
|
+
*/
|
|
961
|
+
async executeVectorStep(step, input) {
|
|
962
|
+
var _a;
|
|
963
|
+
const vectorTag = step.vector;
|
|
964
|
+
if (!vectorTag) {
|
|
965
|
+
throw new Error(`Vector step "${step.tag}" has no vector tag`);
|
|
966
|
+
}
|
|
967
|
+
const product = this.state.product;
|
|
968
|
+
const env = this.state.env;
|
|
969
|
+
const event = (step.event || '').toLowerCase();
|
|
970
|
+
const svc = this.getVectorService();
|
|
971
|
+
debugLog('[WorkflowExecutor] executeVectorStep', {
|
|
972
|
+
workflow_id: this.state.workflow_id,
|
|
973
|
+
step_tag: step.tag,
|
|
974
|
+
vector: vectorTag,
|
|
975
|
+
event,
|
|
976
|
+
});
|
|
977
|
+
switch (event) {
|
|
978
|
+
case 'query': {
|
|
979
|
+
const result = await svc.query(Object.assign({ product,
|
|
980
|
+
env, tag: vectorTag }, input));
|
|
981
|
+
return result;
|
|
982
|
+
}
|
|
983
|
+
case 'upsert': {
|
|
984
|
+
const result = await svc.upsert(Object.assign({ product,
|
|
985
|
+
env, tag: vectorTag }, input));
|
|
986
|
+
return result;
|
|
987
|
+
}
|
|
988
|
+
case 'delete':
|
|
989
|
+
case 'deletevectors': {
|
|
990
|
+
const result = await svc.deleteVectors(Object.assign({ product,
|
|
991
|
+
env, tag: vectorTag }, input));
|
|
992
|
+
return result;
|
|
993
|
+
}
|
|
994
|
+
default: {
|
|
995
|
+
// Custom vector action: resolve template then execute (resolve returns options for query/upsert/delete)
|
|
996
|
+
const resolved = await svc.actions.resolve({
|
|
997
|
+
product,
|
|
998
|
+
env,
|
|
999
|
+
vector: vectorTag,
|
|
1000
|
+
action: step.event,
|
|
1001
|
+
input: input,
|
|
1002
|
+
});
|
|
1003
|
+
const op = (_a = resolved === null || resolved === void 0 ? void 0 : resolved._operation) !== null && _a !== void 0 ? _a : resolved === null || resolved === void 0 ? void 0 : resolved.operation;
|
|
1004
|
+
const opts = Object.assign({ product, env, tag: vectorTag }, resolved);
|
|
1005
|
+
if (op === 'query' || !op) {
|
|
1006
|
+
return svc.query(opts);
|
|
1007
|
+
}
|
|
1008
|
+
if (op === 'upsert') {
|
|
1009
|
+
return svc.upsert(opts);
|
|
1010
|
+
}
|
|
1011
|
+
if (op === 'delete' || op === 'deleteVectors') {
|
|
1012
|
+
return svc.deleteVectors(opts);
|
|
1013
|
+
}
|
|
1014
|
+
return svc.query(opts);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Execute a quota step
|
|
1020
|
+
*/
|
|
1021
|
+
async executeQuotaStep(step, input) {
|
|
1022
|
+
debugLog('[WorkflowExecutor] executeQuotaStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, quota: step.quota });
|
|
1023
|
+
return this.getQuotaService().run({
|
|
1024
|
+
product: this.state.product,
|
|
1025
|
+
env: this.state.env,
|
|
1026
|
+
tag: step.quota,
|
|
1027
|
+
input,
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Execute a fallback step
|
|
1032
|
+
*/
|
|
1033
|
+
async executeFallbackStep(step, input) {
|
|
1034
|
+
debugLog('[WorkflowExecutor] executeFallbackStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, fallback: step.fallback });
|
|
1035
|
+
return this.getFallbackService().run({
|
|
1036
|
+
product: this.state.product,
|
|
1037
|
+
env: this.state.env,
|
|
1038
|
+
tag: step.fallback,
|
|
1039
|
+
input,
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Execute a child workflow step
|
|
1044
|
+
*/
|
|
1045
|
+
async executeChildWorkflowStep(step, input) {
|
|
1046
|
+
debugLog('[WorkflowExecutor] executeChildWorkflowStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, child_workflow: step.workflow });
|
|
1047
|
+
// Create a new executor for the child workflow
|
|
1048
|
+
const childWorkflow = await this.productBuilder.fetchWorkflow(step.workflow);
|
|
1049
|
+
if (!childWorkflow) {
|
|
1050
|
+
debugLog('[WorkflowExecutor] executeChildWorkflowStep child not found', { step_tag: step.tag, child_workflow: step.workflow });
|
|
1051
|
+
throw new Error(`Child workflow ${step.workflow} not found`);
|
|
1052
|
+
}
|
|
1053
|
+
const childExecutor = new WorkflowExecutor(this.config, childWorkflow, {
|
|
1054
|
+
product: this.state.product,
|
|
1055
|
+
env: this.state.env,
|
|
1056
|
+
tag: step.workflow,
|
|
1057
|
+
input,
|
|
1058
|
+
}, this._privateKey);
|
|
1059
|
+
const result = await childExecutor.execute();
|
|
1060
|
+
debugLog('[WorkflowExecutor] executeChildWorkflowStep result', {
|
|
1061
|
+
workflow_id: this.state.workflow_id,
|
|
1062
|
+
step_tag: step.tag,
|
|
1063
|
+
child_status: result.status,
|
|
1064
|
+
});
|
|
1065
|
+
if (result.status !== types_1.WorkflowStatus.COMPLETED) {
|
|
1066
|
+
throw new Error(`Child workflow failed: ${result.error}`);
|
|
1067
|
+
}
|
|
1068
|
+
return result.output;
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Execute a sleep step
|
|
1072
|
+
*/
|
|
1073
|
+
async executeSleepStep(step, input) {
|
|
1074
|
+
var _a;
|
|
1075
|
+
const duration = input.duration || ((_a = step.options) === null || _a === void 0 ? void 0 : _a.timeout) || 1000;
|
|
1076
|
+
debugLog('[WorkflowExecutor] executeSleepStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, durationMs: duration });
|
|
1077
|
+
await this.sleep(duration);
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Execute a wait for signal step
|
|
1081
|
+
* Polls the backend API for signal delivery until received or timeout
|
|
1082
|
+
*/
|
|
1083
|
+
async executeWaitForSignalStep(step, input) {
|
|
1084
|
+
var _a;
|
|
1085
|
+
const signalName = step.event;
|
|
1086
|
+
const signals = input.signals || [signalName];
|
|
1087
|
+
const timeout = ((_a = step.options) === null || _a === void 0 ? void 0 : _a.timeout) || 300000; // 5 min default
|
|
1088
|
+
const startTime = Date.now();
|
|
1089
|
+
debugLog('[WorkflowExecutor] executeWaitForSignalStep', {
|
|
1090
|
+
workflow_id: this.state.workflow_id,
|
|
1091
|
+
step_tag: step.tag,
|
|
1092
|
+
signals,
|
|
1093
|
+
timeoutMs: timeout,
|
|
1094
|
+
});
|
|
1095
|
+
// Store that we're waiting for these signals in state
|
|
1096
|
+
this.state.state[`waiting_for_signal:${step.tag}`] = {
|
|
1097
|
+
signals,
|
|
1098
|
+
started_at: startTime,
|
|
1099
|
+
timeout,
|
|
1100
|
+
};
|
|
1101
|
+
// Persist the waiting state to backend
|
|
1102
|
+
await this.persistExecutionResult(types_1.LogEventStatus.WAITING);
|
|
1103
|
+
return new Promise((resolve, reject) => {
|
|
1104
|
+
// Create pending signal entry
|
|
1105
|
+
const pendingSignal = {
|
|
1106
|
+
signal: signalName,
|
|
1107
|
+
resolve,
|
|
1108
|
+
reject,
|
|
1109
|
+
};
|
|
1110
|
+
// Store for each signal we're waiting for
|
|
1111
|
+
for (const sig of signals) {
|
|
1112
|
+
this.pendingSignals.set(sig, pendingSignal);
|
|
1113
|
+
}
|
|
1114
|
+
// Set up timeout
|
|
1115
|
+
if (timeout > 0) {
|
|
1116
|
+
pendingSignal.timeout = setTimeout(() => {
|
|
1117
|
+
// Clean up pending signals
|
|
1118
|
+
for (const sig of signals) {
|
|
1119
|
+
this.pendingSignals.delete(sig);
|
|
1120
|
+
}
|
|
1121
|
+
this.stopSignalPolling();
|
|
1122
|
+
// Update state
|
|
1123
|
+
delete this.state.state[`waiting_for_signal:${step.tag}`];
|
|
1124
|
+
this.state.state[`signal_timeout:${step.tag}`] = {
|
|
1125
|
+
signals,
|
|
1126
|
+
timed_out_at: Date.now(),
|
|
1127
|
+
};
|
|
1128
|
+
reject(new Error(`Signal wait timed out after ${timeout}ms waiting for: ${signals.join(', ')}`));
|
|
1129
|
+
}, timeout);
|
|
1130
|
+
}
|
|
1131
|
+
// Start polling for signals
|
|
1132
|
+
this.startSignalPolling(signals, step.tag);
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Start polling the backend for signal delivery
|
|
1137
|
+
*/
|
|
1138
|
+
startSignalPolling(signals, stepTag) {
|
|
1139
|
+
// Don't start multiple pollers
|
|
1140
|
+
if (this.signalPollTimer)
|
|
1141
|
+
return;
|
|
1142
|
+
debugLog('[WorkflowExecutor] startSignalPolling', { workflow_id: this.state.workflow_id, stepTag, signals });
|
|
1143
|
+
const poll = async () => {
|
|
1144
|
+
var _a;
|
|
1145
|
+
try {
|
|
1146
|
+
// Get workflow status from backend to check for received signals
|
|
1147
|
+
const status = await this.workflowApiService.getStatus(this.state.workflow_id, this.state.product, this.state.env, this.getAuthPayload());
|
|
1148
|
+
if (status) {
|
|
1149
|
+
// Check if any of the signals we're waiting for have been received
|
|
1150
|
+
const receivedSignals = ((_a = status.state) === null || _a === void 0 ? void 0 : _a.received_signals) || {};
|
|
1151
|
+
for (const signalName of signals) {
|
|
1152
|
+
const signalKey = `signal:${signalName}`;
|
|
1153
|
+
if (receivedSignals[signalKey]) {
|
|
1154
|
+
const signalData = receivedSignals[signalKey];
|
|
1155
|
+
const pendingSignal = this.pendingSignals.get(signalName);
|
|
1156
|
+
if (pendingSignal) {
|
|
1157
|
+
// Clear timeout
|
|
1158
|
+
if (pendingSignal.timeout) {
|
|
1159
|
+
clearTimeout(pendingSignal.timeout);
|
|
1160
|
+
}
|
|
1161
|
+
// Clean up
|
|
1162
|
+
for (const sig of signals) {
|
|
1163
|
+
this.pendingSignals.delete(sig);
|
|
1164
|
+
}
|
|
1165
|
+
this.stopSignalPolling();
|
|
1166
|
+
// Update state
|
|
1167
|
+
delete this.state.state[`waiting_for_signal:${stepTag}`];
|
|
1168
|
+
this.state.state[`signal_received:${stepTag}`] = {
|
|
1169
|
+
signal: signalName,
|
|
1170
|
+
payload: signalData,
|
|
1171
|
+
received_at: Date.now(),
|
|
1172
|
+
};
|
|
1173
|
+
// Resolve the promise
|
|
1174
|
+
pendingSignal.resolve({
|
|
1175
|
+
signal: signalName,
|
|
1176
|
+
payload: signalData,
|
|
1177
|
+
received_at: Date.now(),
|
|
1178
|
+
});
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
catch (error) {
|
|
1186
|
+
// Log but continue polling - transient errors shouldn't stop us
|
|
1187
|
+
debugLog('[WorkflowExecutor] Signal polling error', { workflow_id: this.state.workflow_id, error });
|
|
1188
|
+
}
|
|
1189
|
+
// Schedule next poll if we still have pending signals
|
|
1190
|
+
if (this.pendingSignals.size > 0) {
|
|
1191
|
+
this.signalPollTimer = setTimeout(poll, this.signalPollInterval);
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
// Start polling
|
|
1195
|
+
poll();
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Stop the signal polling timer
|
|
1199
|
+
*/
|
|
1200
|
+
stopSignalPolling() {
|
|
1201
|
+
if (this.signalPollTimer) {
|
|
1202
|
+
clearTimeout(this.signalPollTimer);
|
|
1203
|
+
this.signalPollTimer = null;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Deliver a signal to this workflow (called by external signal handler)
|
|
1208
|
+
*/
|
|
1209
|
+
deliverSignal(signalName, payload) {
|
|
1210
|
+
debugLog('[WorkflowExecutor] deliverSignal', { workflow_id: this.state.workflow_id, signalName, hasPayload: payload !== undefined });
|
|
1211
|
+
const pendingSignal = this.pendingSignals.get(signalName);
|
|
1212
|
+
if (!pendingSignal) {
|
|
1213
|
+
debugLog('[WorkflowExecutor] deliverSignal no pending signal', { workflow_id: this.state.workflow_id, signalName });
|
|
1214
|
+
return false;
|
|
1215
|
+
}
|
|
1216
|
+
// Clear timeout
|
|
1217
|
+
if (pendingSignal.timeout) {
|
|
1218
|
+
clearTimeout(pendingSignal.timeout);
|
|
1219
|
+
}
|
|
1220
|
+
// Clean up all related pending signals
|
|
1221
|
+
// (in case we were waiting for multiple signals)
|
|
1222
|
+
for (const [key, value] of this.pendingSignals.entries()) {
|
|
1223
|
+
if (value === pendingSignal) {
|
|
1224
|
+
this.pendingSignals.delete(key);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
this.stopSignalPolling();
|
|
1228
|
+
// Resolve with the signal data
|
|
1229
|
+
pendingSignal.resolve({
|
|
1230
|
+
signal: signalName,
|
|
1231
|
+
payload,
|
|
1232
|
+
received_at: Date.now(),
|
|
1233
|
+
});
|
|
1234
|
+
return true;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Execute a checkpoint step
|
|
1238
|
+
*/
|
|
1239
|
+
async executeCheckpointStep(step, input) {
|
|
1240
|
+
debugLog('[WorkflowExecutor] executeCheckpointStep', { workflow_id: this.state.workflow_id, step_tag: step.tag });
|
|
1241
|
+
// Store checkpoint data in workflow state
|
|
1242
|
+
this.state.state[`checkpoint:${step.tag}`] = {
|
|
1243
|
+
timestamp: Date.now(),
|
|
1244
|
+
completed_steps: [...this.state.completed_steps],
|
|
1245
|
+
data: input,
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Execute rollback for completed steps
|
|
1250
|
+
*/
|
|
1251
|
+
async executeRollback(failedStep, reason) {
|
|
1252
|
+
var _a;
|
|
1253
|
+
const rolledBackSteps = [];
|
|
1254
|
+
const failedRollbacks = [];
|
|
1255
|
+
// Get rollback strategy
|
|
1256
|
+
const strategy = ((_a = this.workflow.options) === null || _a === void 0 ? void 0 : _a.rollback_strategy) || types_1.WorkflowRollbackStrategy.REVERSE_ALL;
|
|
1257
|
+
debugLog('[WorkflowExecutor] executeRollback ENTRY', {
|
|
1258
|
+
workflow_id: this.state.workflow_id,
|
|
1259
|
+
failedStep,
|
|
1260
|
+
reason,
|
|
1261
|
+
strategy,
|
|
1262
|
+
completed_steps: this.state.completed_steps,
|
|
1263
|
+
});
|
|
1264
|
+
// Determine which steps to rollback
|
|
1265
|
+
let stepsToRollback = [];
|
|
1266
|
+
switch (strategy) {
|
|
1267
|
+
case types_1.WorkflowRollbackStrategy.REVERSE_ALL:
|
|
1268
|
+
// Rollback all completed steps in reverse order
|
|
1269
|
+
stepsToRollback = this.state.completed_steps
|
|
1270
|
+
.slice()
|
|
1271
|
+
.reverse()
|
|
1272
|
+
.map((tag) => this.findStep(tag))
|
|
1273
|
+
.filter((step) => step !== undefined);
|
|
1274
|
+
break;
|
|
1275
|
+
case types_1.WorkflowRollbackStrategy.REVERSE_CRITICAL:
|
|
1276
|
+
// Only rollback steps marked as critical
|
|
1277
|
+
stepsToRollback = this.state.completed_steps
|
|
1278
|
+
.slice()
|
|
1279
|
+
.reverse()
|
|
1280
|
+
.map((tag) => this.findStep(tag))
|
|
1281
|
+
.filter((step) => { var _a; return step !== undefined && ((_a = step.options) === null || _a === void 0 ? void 0 : _a.critical) === true; });
|
|
1282
|
+
break;
|
|
1283
|
+
case types_1.WorkflowRollbackStrategy.NONE:
|
|
1284
|
+
// No rollback
|
|
1285
|
+
debugLog('[WorkflowExecutor] executeRollback NONE strategy', { workflow_id: this.state.workflow_id });
|
|
1286
|
+
return { success: true, rolled_back_steps: [], reason };
|
|
1287
|
+
}
|
|
1288
|
+
debugLog('[WorkflowExecutor] executeRollback steps to rollback', {
|
|
1289
|
+
workflow_id: this.state.workflow_id,
|
|
1290
|
+
count: stepsToRollback.length,
|
|
1291
|
+
tags: stepsToRollback.map((s) => s.tag),
|
|
1292
|
+
});
|
|
1293
|
+
// Execute rollback for each step
|
|
1294
|
+
for (const step of stepsToRollback) {
|
|
1295
|
+
if (!step.rollback) {
|
|
1296
|
+
debugLog('[WorkflowExecutor] executeRollback step has no rollback', { step_tag: step.tag });
|
|
1297
|
+
continue; // No rollback defined for this step
|
|
1298
|
+
}
|
|
1299
|
+
try {
|
|
1300
|
+
const stepOutput = this.state.steps[step.tag];
|
|
1301
|
+
await this.executeRollbackHandler(step.rollback, stepOutput);
|
|
1302
|
+
rolledBackSteps.push(step.tag);
|
|
1303
|
+
debugLog('[WorkflowExecutor] executeRollback step rolled back', { workflow_id: this.state.workflow_id, step_tag: step.tag });
|
|
1304
|
+
}
|
|
1305
|
+
catch (error) {
|
|
1306
|
+
debugLog('[WorkflowExecutor] executeRollback step failed', { workflow_id: this.state.workflow_id, step_tag: step.tag, error: error === null || error === void 0 ? void 0 : error.message });
|
|
1307
|
+
if (!step.rollback.continue_on_failure) {
|
|
1308
|
+
failedRollbacks.push({ tag: step.tag, error: error.message });
|
|
1309
|
+
// Stop rollback if continue_on_failure is not set
|
|
1310
|
+
break;
|
|
1311
|
+
}
|
|
1312
|
+
failedRollbacks.push({ tag: step.tag, error: error.message });
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
const rollbackResult = {
|
|
1316
|
+
success: failedRollbacks.length === 0,
|
|
1317
|
+
rolled_back_steps: rolledBackSteps,
|
|
1318
|
+
failed_steps: failedRollbacks.length > 0 ? failedRollbacks : undefined,
|
|
1319
|
+
reason,
|
|
1320
|
+
};
|
|
1321
|
+
debugLog('[WorkflowExecutor] executeRollback DONE', {
|
|
1322
|
+
workflow_id: this.state.workflow_id,
|
|
1323
|
+
success: rollbackResult.success,
|
|
1324
|
+
rolled_back_count: rolledBackSteps.length,
|
|
1325
|
+
failed_count: failedRollbacks.length,
|
|
1326
|
+
});
|
|
1327
|
+
return rollbackResult;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Execute a rollback handler
|
|
1331
|
+
*/
|
|
1332
|
+
async executeRollbackHandler(rollback, stepOutput) {
|
|
1333
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1334
|
+
if (!rollback)
|
|
1335
|
+
return;
|
|
1336
|
+
debugLog('[WorkflowExecutor] executeRollbackHandler', { workflow_id: this.state.workflow_id, rollback_type: rollback.type });
|
|
1337
|
+
// Resolve rollback input, including step output references
|
|
1338
|
+
const resolvedInput = await this.resolveInput(rollback.input || {}, stepOutput);
|
|
1339
|
+
switch (rollback.type) {
|
|
1340
|
+
case types_1.WorkflowStepType.ACTION:
|
|
1341
|
+
await this.getProcessorService().processAction({
|
|
1342
|
+
product: this.state.product,
|
|
1343
|
+
env: this.state.env,
|
|
1344
|
+
app: rollback.app,
|
|
1345
|
+
action: rollback.event,
|
|
1346
|
+
input: resolvedInput,
|
|
1347
|
+
retries: (_a = rollback.retries) !== null && _a !== void 0 ? _a : 0,
|
|
1348
|
+
});
|
|
1349
|
+
break;
|
|
1350
|
+
case types_1.WorkflowStepType.DATABASE_ACTION: {
|
|
1351
|
+
const db = this.getDatabaseService();
|
|
1352
|
+
const product = this.state.product;
|
|
1353
|
+
const env = this.state.env;
|
|
1354
|
+
const database = rollback.database;
|
|
1355
|
+
const event = ((_b = rollback.event) !== null && _b !== void 0 ? _b : '').toLowerCase();
|
|
1356
|
+
const opts = Object.assign({ product, env, database }, resolvedInput);
|
|
1357
|
+
if (event === 'query')
|
|
1358
|
+
await db.query(opts);
|
|
1359
|
+
else if (event === 'insert')
|
|
1360
|
+
await db.insert(opts);
|
|
1361
|
+
else if (event === 'update')
|
|
1362
|
+
await db.update(opts);
|
|
1363
|
+
else if (event === 'delete')
|
|
1364
|
+
await db.delete(opts);
|
|
1365
|
+
else if (event === 'upsert')
|
|
1366
|
+
await db.upsert(opts);
|
|
1367
|
+
else
|
|
1368
|
+
await db.execute({
|
|
1369
|
+
product,
|
|
1370
|
+
env,
|
|
1371
|
+
database,
|
|
1372
|
+
action: rollback.event,
|
|
1373
|
+
input: resolvedInput,
|
|
1374
|
+
});
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
case types_1.WorkflowStepType.NOTIFICATION:
|
|
1378
|
+
const notifEvent = `${rollback.notification}:${rollback.event}`;
|
|
1379
|
+
await this.getProcessorService().processNotification({
|
|
1380
|
+
product: this.state.product,
|
|
1381
|
+
env: this.state.env,
|
|
1382
|
+
event: notifEvent,
|
|
1383
|
+
input: resolvedInput,
|
|
1384
|
+
retries: (_c = rollback.retries) !== null && _c !== void 0 ? _c : 0,
|
|
1385
|
+
});
|
|
1386
|
+
break;
|
|
1387
|
+
case types_1.WorkflowStepType.STORAGE: {
|
|
1388
|
+
const product = this.state.product;
|
|
1389
|
+
const env = this.state.env;
|
|
1390
|
+
const storage = rollback.storage;
|
|
1391
|
+
const opts = { product, env, storage };
|
|
1392
|
+
const inp = resolvedInput;
|
|
1393
|
+
if (inp.buffer != null && inp.fileName != null) {
|
|
1394
|
+
await this.getStorageService().upload(Object.assign(Object.assign({}, opts), { fileName: String(inp.fileName), buffer: inp.buffer, mimeType: inp.mimeType != null ? String(inp.mimeType) : undefined }));
|
|
1395
|
+
}
|
|
1396
|
+
else if (inp.file_key != null) {
|
|
1397
|
+
await this.getStorageService().delete(Object.assign(Object.assign({}, opts), { fileName: String(inp.file_key) }));
|
|
1398
|
+
}
|
|
1399
|
+
else {
|
|
1400
|
+
await this.getStorageService().download(Object.assign(Object.assign({}, opts), { fileName: String((_e = (_d = inp.fileName) !== null && _d !== void 0 ? _d : inp.file_key) !== null && _e !== void 0 ? _e : '') }));
|
|
1401
|
+
}
|
|
1402
|
+
break;
|
|
1403
|
+
}
|
|
1404
|
+
case types_1.WorkflowStepType.VECTOR: {
|
|
1405
|
+
const product = this.state.product;
|
|
1406
|
+
const env = this.state.env;
|
|
1407
|
+
const vectorTag = rollback.vector;
|
|
1408
|
+
const inp = resolvedInput;
|
|
1409
|
+
const event = ((_f = rollback.event) !== null && _f !== void 0 ? _f : '').toLowerCase();
|
|
1410
|
+
const svc = this.getVectorService();
|
|
1411
|
+
if (event === 'query') {
|
|
1412
|
+
await svc.query(Object.assign({ product, env, tag: vectorTag }, inp));
|
|
1413
|
+
}
|
|
1414
|
+
else if (event === 'upsert') {
|
|
1415
|
+
await svc.upsert(Object.assign({ product, env, tag: vectorTag }, inp));
|
|
1416
|
+
}
|
|
1417
|
+
else if (event === 'delete' || event === 'deletevectors') {
|
|
1418
|
+
await svc.deleteVectors(Object.assign({ product, env, tag: vectorTag }, inp));
|
|
1419
|
+
}
|
|
1420
|
+
else {
|
|
1421
|
+
const resolved = await svc.actions.resolve({
|
|
1422
|
+
product,
|
|
1423
|
+
env,
|
|
1424
|
+
vector: vectorTag,
|
|
1425
|
+
action: rollback.event,
|
|
1426
|
+
input: inp,
|
|
1427
|
+
});
|
|
1428
|
+
const op = (_g = resolved === null || resolved === void 0 ? void 0 : resolved._operation) !== null && _g !== void 0 ? _g : resolved === null || resolved === void 0 ? void 0 : resolved.operation;
|
|
1429
|
+
const opts = Object.assign({ product, env, tag: vectorTag }, resolved);
|
|
1430
|
+
if (op === 'upsert')
|
|
1431
|
+
await svc.upsert(opts);
|
|
1432
|
+
else if (op === 'delete' || op === 'deleteVectors')
|
|
1433
|
+
await svc.deleteVectors(opts);
|
|
1434
|
+
else
|
|
1435
|
+
await svc.query(opts);
|
|
1436
|
+
}
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
case types_1.WorkflowStepType.PUBLISH:
|
|
1440
|
+
case types_1.WorkflowStepType.PRODUCE:
|
|
1441
|
+
const pubEvent = `${rollback.broker}:${rollback.event}`;
|
|
1442
|
+
await this.getProcessorService().processMessageBrokerPublish({
|
|
1443
|
+
product: this.state.product,
|
|
1444
|
+
env: this.state.env,
|
|
1445
|
+
event: pubEvent,
|
|
1446
|
+
input: resolvedInput,
|
|
1447
|
+
});
|
|
1448
|
+
break;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Resolve input by replacing data references and all $ operators (per docs/operators).
|
|
1453
|
+
* Top-level keys are resolved in parallel for better performance.
|
|
1454
|
+
*/
|
|
1455
|
+
async resolveInput(input, stepOutput) {
|
|
1456
|
+
const entries = Object.entries(input);
|
|
1457
|
+
const resolvedValues = await Promise.all(entries.map(([, value]) => this.resolveValue(value, stepOutput)));
|
|
1458
|
+
const resolved = {};
|
|
1459
|
+
entries.forEach(([key], i) => {
|
|
1460
|
+
resolved[key] = resolvedValues[i];
|
|
1461
|
+
});
|
|
1462
|
+
return resolved;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Resolve a single value: refs ($Input{}, $Step{}, etc.) and operators ($Add, $Concat, etc.)
|
|
1466
|
+
*/
|
|
1467
|
+
async resolveValue(value, stepOutput) {
|
|
1468
|
+
if (typeof value === 'string') {
|
|
1469
|
+
return this.resolveStringValue(value, stepOutput);
|
|
1470
|
+
}
|
|
1471
|
+
if (Array.isArray(value)) {
|
|
1472
|
+
return Promise.all(value.map((item) => this.resolveValue(item, stepOutput)));
|
|
1473
|
+
}
|
|
1474
|
+
if (value && typeof value === 'object') {
|
|
1475
|
+
return this.resolveInput(value, stepOutput);
|
|
1476
|
+
}
|
|
1477
|
+
return value;
|
|
1478
|
+
}
|
|
1479
|
+
/** Strip surrounding quotes from a string literal (e.g. '"foo"' -> 'foo') */
|
|
1480
|
+
unquote(part) {
|
|
1481
|
+
const t = part.trim();
|
|
1482
|
+
if ((t.startsWith('"') && t.endsWith('"')) || (t.startsWith("'") && t.endsWith("'"))) {
|
|
1483
|
+
return t.slice(1, -1);
|
|
1484
|
+
}
|
|
1485
|
+
return t;
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* Resolve string value: data references and all $ operators from docs/operators
|
|
1489
|
+
* Supports: $Input{}, $Step{}, $Sequence{}, $State{}, $StepOutput{}, $Now,
|
|
1490
|
+
* $Add, $Subtract, $Concat, $Substring, $Trim, $Split, $Pick, $Join,
|
|
1491
|
+
* $Uppercase, $Lowercase, $Dateformat, $Replace, $Filter, $Find, $Size, $Length
|
|
1492
|
+
*/
|
|
1493
|
+
async resolveStringValue(value, stepOutput) {
|
|
1494
|
+
var _a;
|
|
1495
|
+
const v = value.trim();
|
|
1496
|
+
// --- Data references (exact match) ---
|
|
1497
|
+
if (v === '$Now' || v === '$Now()')
|
|
1498
|
+
return Date.now();
|
|
1499
|
+
const inputMatch = v.match(/^\$Input\{(.+)\}$/);
|
|
1500
|
+
if (inputMatch)
|
|
1501
|
+
return this.getNestedValue(this.state.input, inputMatch[1]);
|
|
1502
|
+
const sequenceMatch = v.match(/^\$Sequence\{main\}\{([^}]+)\}\{(.+)\}$/);
|
|
1503
|
+
if (sequenceMatch) {
|
|
1504
|
+
const stepData = this.state.steps[sequenceMatch[1]];
|
|
1505
|
+
if (stepData)
|
|
1506
|
+
return this.getNestedValue(stepData, sequenceMatch[2]);
|
|
1507
|
+
return undefined;
|
|
1508
|
+
}
|
|
1509
|
+
const stepMatch = v.match(/^\$Step\{(.+)\}\{(.+)\}$/);
|
|
1510
|
+
if (stepMatch) {
|
|
1511
|
+
const stepData = this.state.steps[stepMatch[1]];
|
|
1512
|
+
if (stepData)
|
|
1513
|
+
return this.getNestedValue(stepData, stepMatch[2]);
|
|
1514
|
+
return undefined;
|
|
1515
|
+
}
|
|
1516
|
+
const stateMatch = v.match(/^\$State\{(.+)\}$/);
|
|
1517
|
+
if (stateMatch)
|
|
1518
|
+
return this.state.state[stateMatch[1]];
|
|
1519
|
+
const outputMatch = v.match(/^\$StepOutput\{(.+)\}$/);
|
|
1520
|
+
if (outputMatch && stepOutput)
|
|
1521
|
+
return this.getNestedValue(stepOutput, outputMatch[1]);
|
|
1522
|
+
// --- $Size{ref} / $Length{ref} ---
|
|
1523
|
+
const sizeMatch = v.match(/^\$Size\{(.+)\}$/);
|
|
1524
|
+
if (sizeMatch) {
|
|
1525
|
+
const inner = await this.resolveValue(sizeMatch[1].trim(), stepOutput);
|
|
1526
|
+
if (inner != null && typeof inner === 'object' && !Array.isArray(inner))
|
|
1527
|
+
return Object.keys(inner).length;
|
|
1528
|
+
return 0;
|
|
1529
|
+
}
|
|
1530
|
+
const lengthMatch = v.match(/^\$Length\{(.+)\}$/);
|
|
1531
|
+
if (lengthMatch) {
|
|
1532
|
+
const inner = await this.resolveValue(lengthMatch[1].trim(), stepOutput);
|
|
1533
|
+
if (Array.isArray(inner))
|
|
1534
|
+
return inner.length;
|
|
1535
|
+
if (typeof inner === 'string')
|
|
1536
|
+
return inner.length;
|
|
1537
|
+
return 0;
|
|
1538
|
+
}
|
|
1539
|
+
// --- Operators (whole-string forms) ---
|
|
1540
|
+
// $Add(...) or $Add{...}
|
|
1541
|
+
const addMatch = v.match(/^\$Add\(([^)]*)\)$/) || v.match(/^\$Add\{([^}]*)\}$/);
|
|
1542
|
+
if (addMatch) {
|
|
1543
|
+
const parts = addMatch[1].split(',').map((s) => this.unquote(s.trim()));
|
|
1544
|
+
const nums = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
|
|
1545
|
+
return nums.reduce((sum, n) => sum + Number(n), 0);
|
|
1546
|
+
}
|
|
1547
|
+
// $Subtract(...) / $Substract(...) (typo) and $Subtract{...}
|
|
1548
|
+
const subMatch = v.match(/^\$Subtract?\(([^)]*)\)$/) || v.match(/^\$Subtract?\{([^}]*)\}$/);
|
|
1549
|
+
if (subMatch) {
|
|
1550
|
+
const parts = subMatch[1].split(',').map((s) => this.unquote(s.trim()));
|
|
1551
|
+
const nums = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
|
|
1552
|
+
const n = nums.map((x) => Number(x));
|
|
1553
|
+
return n.length ? n.reduce((a, b) => a - b) : 0;
|
|
1554
|
+
}
|
|
1555
|
+
// $Concat([...], "sep")
|
|
1556
|
+
const concatMatch = v.match(inputs_types_1.concatRegex);
|
|
1557
|
+
if (concatMatch) {
|
|
1558
|
+
const arrContent = concatMatch[1];
|
|
1559
|
+
const separator = concatMatch[2];
|
|
1560
|
+
const parts = arrContent.split(',').map((s) => this.unquote(s.trim()));
|
|
1561
|
+
const resolvedParts = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
|
|
1562
|
+
return resolvedParts.map((x) => (x == null ? '' : String(x))).join(separator);
|
|
1563
|
+
}
|
|
1564
|
+
// $Substring(str, start, end)
|
|
1565
|
+
const substrMatch = v.match(inputs_types_1.substringRegex);
|
|
1566
|
+
if (substrMatch) {
|
|
1567
|
+
const str = await this.resolveValue(this.unquote(substrMatch[1]), stepOutput);
|
|
1568
|
+
const start = Number(substrMatch[2]);
|
|
1569
|
+
const end = Number(substrMatch[3]);
|
|
1570
|
+
if (typeof str !== 'string')
|
|
1571
|
+
return '';
|
|
1572
|
+
return str.substring(start, end);
|
|
1573
|
+
}
|
|
1574
|
+
// $Trim(str)
|
|
1575
|
+
const trimMatch = v.match(inputs_types_1.trimRegex);
|
|
1576
|
+
if (trimMatch) {
|
|
1577
|
+
const str = await this.resolveValue(this.unquote(trimMatch[1]), stepOutput);
|
|
1578
|
+
return typeof str === 'string' ? str.trim() : String(str !== null && str !== void 0 ? str : '').trim();
|
|
1579
|
+
}
|
|
1580
|
+
// $Uppercase(str)
|
|
1581
|
+
const upperMatch = v.match(inputs_types_1.uppercaseRegex);
|
|
1582
|
+
if (upperMatch) {
|
|
1583
|
+
const str = await this.resolveValue(this.unquote(upperMatch[1]), stepOutput);
|
|
1584
|
+
return typeof str === 'string' ? str.toUpperCase() : String(str !== null && str !== void 0 ? str : '').toUpperCase();
|
|
1585
|
+
}
|
|
1586
|
+
// $Lowercase(str)
|
|
1587
|
+
const lowerMatch = v.match(inputs_types_1.lowercaseRegex);
|
|
1588
|
+
if (lowerMatch) {
|
|
1589
|
+
const str = await this.resolveValue(this.unquote(lowerMatch[1]), stepOutput);
|
|
1590
|
+
return typeof str === 'string' ? str.toLowerCase() : String(str !== null && str !== void 0 ? str : '').toLowerCase();
|
|
1591
|
+
}
|
|
1592
|
+
// $Dateformat(date, "format")
|
|
1593
|
+
const dateMatch = v.match(inputs_types_1.dateFormatRegex);
|
|
1594
|
+
if (dateMatch) {
|
|
1595
|
+
const dateVal = await this.resolveValue(this.unquote(dateMatch[1]), stepOutput);
|
|
1596
|
+
const formatStr = dateMatch[3];
|
|
1597
|
+
const d = typeof dateVal === 'string' ? (0, date_fns_1.parseISO)(dateVal) : new Date(dateVal);
|
|
1598
|
+
if (isNaN(d.getTime()))
|
|
1599
|
+
return '';
|
|
1600
|
+
return (0, date_fns_1.format)(d, formatStr);
|
|
1601
|
+
}
|
|
1602
|
+
// $Replace(str, search, replace)
|
|
1603
|
+
const replaceMatch = v.match(inputs_types_1.replaceRegex);
|
|
1604
|
+
if (replaceMatch) {
|
|
1605
|
+
const str = await this.resolveValue(this.unquote(replaceMatch[1]), stepOutput);
|
|
1606
|
+
const search = replaceMatch[3];
|
|
1607
|
+
const repl = replaceMatch[5];
|
|
1608
|
+
return typeof str === 'string' ? str.split(search).join(repl) : String(str !== null && str !== void 0 ? str : '');
|
|
1609
|
+
}
|
|
1610
|
+
// $Pick(value, index)
|
|
1611
|
+
const pickMatch = v.match(inputs_types_1.pickRegex);
|
|
1612
|
+
if (pickMatch) {
|
|
1613
|
+
const val = await this.resolveValue(this.unquote(pickMatch[1]), stepOutput);
|
|
1614
|
+
const idx = Number(pickMatch[2]);
|
|
1615
|
+
if (typeof val === 'string' || Array.isArray(val))
|
|
1616
|
+
return (_a = val[idx]) !== null && _a !== void 0 ? _a : '';
|
|
1617
|
+
return '';
|
|
1618
|
+
}
|
|
1619
|
+
// $Filter(array, "op", value)
|
|
1620
|
+
const filterMatch = v.match(inputs_types_1.filterRegex);
|
|
1621
|
+
if (filterMatch) {
|
|
1622
|
+
const arr = await this.resolveValue(this.unquote(filterMatch[1]), stepOutput);
|
|
1623
|
+
const op = filterMatch[2].trim();
|
|
1624
|
+
const compareVal = await this.resolveValue(this.unquote(filterMatch[3]), stepOutput);
|
|
1625
|
+
if (!productsBuilder_types_1.ValidOperators.includes(op) || !Array.isArray(arr))
|
|
1626
|
+
return [];
|
|
1627
|
+
return arr.filter((item) => (0, processor_utils_1.compareValues)(item, op, compareVal));
|
|
1628
|
+
}
|
|
1629
|
+
// $Find(array, "op", value)
|
|
1630
|
+
const findMatch = v.match(inputs_types_1.findRegex);
|
|
1631
|
+
if (findMatch) {
|
|
1632
|
+
const arr = await this.resolveValue(this.unquote(findMatch[1]), stepOutput);
|
|
1633
|
+
const op = findMatch[2].trim();
|
|
1634
|
+
const compareVal = await this.resolveValue(this.unquote(findMatch[3]), stepOutput);
|
|
1635
|
+
if (!productsBuilder_types_1.ValidOperators.includes(op) || !Array.isArray(arr))
|
|
1636
|
+
return undefined;
|
|
1637
|
+
return arr.find((item) => (0, processor_utils_1.compareValues)(item, op, compareVal));
|
|
1638
|
+
}
|
|
1639
|
+
// $Split(str, "sep")
|
|
1640
|
+
const splitMatch = v.match(inputs_types_1.splitRegex);
|
|
1641
|
+
if (splitMatch) {
|
|
1642
|
+
const str = await this.resolveValue(this.unquote(splitMatch[1]), stepOutput);
|
|
1643
|
+
const sep = splitMatch[2];
|
|
1644
|
+
return typeof str === 'string' ? str.split(sep) : [];
|
|
1645
|
+
}
|
|
1646
|
+
// $Join([[...], [...]]) - inner can be refs like $Sequence{main}{a}{data}
|
|
1647
|
+
const joinMatch = v.match(inputs_types_1.joinRegex);
|
|
1648
|
+
if (joinMatch) {
|
|
1649
|
+
const innerStr = joinMatch[1].trim();
|
|
1650
|
+
const parts = innerStr.slice(1, -1).split(',').map((s) => s.trim());
|
|
1651
|
+
const resolved = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
|
|
1652
|
+
return resolved.reduce((acc, current) => {
|
|
1653
|
+
if (Array.isArray(current))
|
|
1654
|
+
return acc.concat(current);
|
|
1655
|
+
return acc;
|
|
1656
|
+
}, []);
|
|
1657
|
+
}
|
|
1658
|
+
// --- Inline references (string contains $Input{}, $Step{}, $Now, etc.) ---
|
|
1659
|
+
let out = value;
|
|
1660
|
+
out = out.replace(/\$Now(?:\(\))?/g, () => String(Date.now()));
|
|
1661
|
+
out = out.replace(/\$Input\{([^}]+)\}/g, (_, field) => {
|
|
1662
|
+
const val = this.getNestedValue(this.state.input, field);
|
|
1663
|
+
return String(val !== null && val !== void 0 ? val : '');
|
|
1664
|
+
});
|
|
1665
|
+
out = out.replace(/\$Sequence\{main\}\{([^}]+)\}\{([^}]+)\}/g, (_, stepTag, field) => {
|
|
1666
|
+
const stepData = this.state.steps[stepTag];
|
|
1667
|
+
if (stepData) {
|
|
1668
|
+
const val = this.getNestedValue(stepData, field);
|
|
1669
|
+
return String(val !== null && val !== void 0 ? val : '');
|
|
1670
|
+
}
|
|
1671
|
+
return '';
|
|
1672
|
+
});
|
|
1673
|
+
out = out.replace(/\$Step\{([^}]+)\}\{([^}]+)\}/g, (_, stepTag, field) => {
|
|
1674
|
+
const stepData = this.state.steps[stepTag];
|
|
1675
|
+
if (stepData) {
|
|
1676
|
+
const val = this.getNestedValue(stepData, field);
|
|
1677
|
+
return String(val !== null && val !== void 0 ? val : '');
|
|
1678
|
+
}
|
|
1679
|
+
return '';
|
|
1680
|
+
});
|
|
1681
|
+
return out;
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Get nested value from object using dot notation
|
|
1685
|
+
*/
|
|
1686
|
+
getNestedValue(obj, path) {
|
|
1687
|
+
const keys = path.split('.');
|
|
1688
|
+
let current = obj;
|
|
1689
|
+
for (const key of keys) {
|
|
1690
|
+
if (current === null || current === undefined) {
|
|
1691
|
+
return undefined;
|
|
1692
|
+
}
|
|
1693
|
+
current = current[key];
|
|
1694
|
+
}
|
|
1695
|
+
return current;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Get ordered steps respecting dependencies
|
|
1699
|
+
*/
|
|
1700
|
+
getOrderedSteps() {
|
|
1701
|
+
const steps = this.workflow.steps;
|
|
1702
|
+
const ordered = [];
|
|
1703
|
+
const visited = new Set();
|
|
1704
|
+
const visiting = new Set();
|
|
1705
|
+
const visit = (step) => {
|
|
1706
|
+
if (visited.has(step.tag))
|
|
1707
|
+
return;
|
|
1708
|
+
if (visiting.has(step.tag)) {
|
|
1709
|
+
throw new Error(`Circular dependency detected at step ${step.tag}`);
|
|
1710
|
+
}
|
|
1711
|
+
visiting.add(step.tag);
|
|
1712
|
+
// Visit dependencies first
|
|
1713
|
+
if (step.depends_on) {
|
|
1714
|
+
for (const depTag of step.depends_on) {
|
|
1715
|
+
const depStep = steps.find((s) => s.tag === depTag);
|
|
1716
|
+
if (depStep) {
|
|
1717
|
+
visit(depStep);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
visiting.delete(step.tag);
|
|
1722
|
+
visited.add(step.tag);
|
|
1723
|
+
ordered.push(step);
|
|
1724
|
+
};
|
|
1725
|
+
for (const step of steps) {
|
|
1726
|
+
visit(step);
|
|
1727
|
+
}
|
|
1728
|
+
return ordered;
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Pre-fetch all action/notification/storage bootstrap data for the given steps in one backend call.
|
|
1732
|
+
* Results are cached in stepBootstrapCache by step tag so step executors can skip their own bootstrap calls.
|
|
1733
|
+
*/
|
|
1734
|
+
async prefetchStepBootstrap(steps) {
|
|
1735
|
+
this.stepBootstrapCache.clear();
|
|
1736
|
+
const product = this.state.product;
|
|
1737
|
+
const env = this.state.env;
|
|
1738
|
+
const workflowSteps = [];
|
|
1739
|
+
for (const step of steps) {
|
|
1740
|
+
if (step.type === types_1.WorkflowStepType.ACTION && step.app) {
|
|
1741
|
+
workflowSteps.push({
|
|
1742
|
+
step_tag: step.tag,
|
|
1743
|
+
type: 'action',
|
|
1744
|
+
access_tag: step.app,
|
|
1745
|
+
action_tag: step.event,
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
else if (step.type === types_1.WorkflowStepType.NOTIFICATION && step.notification && step.event) {
|
|
1749
|
+
workflowSteps.push({
|
|
1750
|
+
step_tag: step.tag,
|
|
1751
|
+
type: 'notification',
|
|
1752
|
+
notification_tag: step.notification,
|
|
1753
|
+
message_tag: step.event,
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
else if (step.type === types_1.WorkflowStepType.STORAGE && step.storage && step.event) {
|
|
1757
|
+
workflowSteps.push({
|
|
1758
|
+
step_tag: step.tag,
|
|
1759
|
+
type: 'storage',
|
|
1760
|
+
storage_tag: step.storage,
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
if (workflowSteps.length > 0) {
|
|
1765
|
+
stepLog('Bootstrap workflow API call (single request)', {
|
|
1766
|
+
product_tag: product,
|
|
1767
|
+
env_slug: env,
|
|
1768
|
+
steps_count: workflowSteps.length,
|
|
1769
|
+
step_tags: workflowSteps.map((s) => s.step_tag),
|
|
1770
|
+
});
|
|
1771
|
+
const bootstraps = await this.productBuilder.bootstrapWorkflow({
|
|
1772
|
+
product_tag: product,
|
|
1773
|
+
env_slug: env,
|
|
1774
|
+
steps: workflowSteps,
|
|
1775
|
+
});
|
|
1776
|
+
stepLog('Bootstrap workflow API response', {
|
|
1777
|
+
received_keys: Object.keys(bootstraps),
|
|
1778
|
+
keys_count: Object.keys(bootstraps).length,
|
|
1779
|
+
});
|
|
1780
|
+
for (const [stepTag, data] of Object.entries(bootstraps)) {
|
|
1781
|
+
if (data != null) {
|
|
1782
|
+
this.stepBootstrapCache.set(stepTag, data);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
// Pre-fetch message brokers for produce steps so runBrokerPublish has broker/topic in cache
|
|
1787
|
+
const brokerTags = new Set();
|
|
1788
|
+
for (const step of steps) {
|
|
1789
|
+
if ((step.type === types_1.WorkflowStepType.PUBLISH || step.type === types_1.WorkflowStepType.PRODUCE) && step.broker) {
|
|
1790
|
+
brokerTags.add(step.broker);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
if (brokerTags.size > 0) {
|
|
1794
|
+
stepLog('Fetching message brokers for produce steps', { broker_tags: [...brokerTags] });
|
|
1795
|
+
await Promise.all([...brokerTags].map(async (tag) => {
|
|
1796
|
+
var _a;
|
|
1797
|
+
try {
|
|
1798
|
+
const broker = await this.productBuilder.fetchMessageBroker(tag);
|
|
1799
|
+
return { tag, found: !!broker };
|
|
1800
|
+
}
|
|
1801
|
+
catch (e) {
|
|
1802
|
+
stepLog('Broker fetch failed (step may fail later)', { broker_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1803
|
+
return { tag, found: false };
|
|
1804
|
+
}
|
|
1805
|
+
}));
|
|
1806
|
+
}
|
|
1807
|
+
// Pre-fetch databases for DATABASE_ACTION steps
|
|
1808
|
+
const databaseTags = new Set();
|
|
1809
|
+
for (const step of steps) {
|
|
1810
|
+
if (step.type === types_1.WorkflowStepType.DATABASE_ACTION && step.database) {
|
|
1811
|
+
databaseTags.add(step.database);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
if (databaseTags.size > 0) {
|
|
1815
|
+
stepLog('Fetching databases for database steps', { database_tags: [...databaseTags] });
|
|
1816
|
+
await Promise.all([...databaseTags].map(async (tag) => {
|
|
1817
|
+
var _a;
|
|
1818
|
+
try {
|
|
1819
|
+
const db = await this.productBuilder.fetchDatabase(tag);
|
|
1820
|
+
return { tag, found: !!db };
|
|
1821
|
+
}
|
|
1822
|
+
catch (e) {
|
|
1823
|
+
stepLog('Database fetch failed (step may fail later)', { database_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1824
|
+
return { tag, found: false };
|
|
1825
|
+
}
|
|
1826
|
+
}));
|
|
1827
|
+
}
|
|
1828
|
+
// Pre-fetch graphs for GRAPH steps
|
|
1829
|
+
const graphTags = new Set();
|
|
1830
|
+
for (const step of steps) {
|
|
1831
|
+
if (step.type === types_1.WorkflowStepType.GRAPH && step.graph) {
|
|
1832
|
+
graphTags.add(step.graph);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
if (graphTags.size > 0) {
|
|
1836
|
+
stepLog('Fetching graphs for graph steps', { graph_tags: [...graphTags] });
|
|
1837
|
+
await Promise.all([...graphTags].map(async (tag) => {
|
|
1838
|
+
var _a;
|
|
1839
|
+
try {
|
|
1840
|
+
const graph = await this.productBuilder.fetchGraph(tag);
|
|
1841
|
+
return { tag, found: !!graph };
|
|
1842
|
+
}
|
|
1843
|
+
catch (e) {
|
|
1844
|
+
stepLog('Graph fetch failed (step may fail later)', { graph_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1845
|
+
return { tag, found: false };
|
|
1846
|
+
}
|
|
1847
|
+
}));
|
|
1848
|
+
}
|
|
1849
|
+
const vectorTags = new Set();
|
|
1850
|
+
for (const step of steps) {
|
|
1851
|
+
if (step.type === types_1.WorkflowStepType.VECTOR && step.vector) {
|
|
1852
|
+
vectorTags.add(step.vector);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
if (vectorTags.size > 0) {
|
|
1856
|
+
stepLog('Fetching vectors for vector steps', { vector_tags: [...vectorTags] });
|
|
1857
|
+
await Promise.all([...vectorTags].map(async (tag) => {
|
|
1858
|
+
var _a;
|
|
1859
|
+
try {
|
|
1860
|
+
const vec = await this.productBuilder.fetchVector(tag);
|
|
1861
|
+
return { tag, found: !!vec };
|
|
1862
|
+
}
|
|
1863
|
+
catch (e) {
|
|
1864
|
+
stepLog('Vector fetch failed (step may fail later)', { vector_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1865
|
+
return { tag, found: false };
|
|
1866
|
+
}
|
|
1867
|
+
}));
|
|
1868
|
+
}
|
|
1869
|
+
// Pre-fetch quotas for QUOTA steps
|
|
1870
|
+
const quotaTags = new Set();
|
|
1871
|
+
for (const step of steps) {
|
|
1872
|
+
if (step.type === types_1.WorkflowStepType.QUOTA && step.quota) {
|
|
1873
|
+
quotaTags.add(step.quota);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
if (quotaTags.size > 0) {
|
|
1877
|
+
stepLog('Fetching quotas for quota steps', { quota_tags: [...quotaTags] });
|
|
1878
|
+
await Promise.all([...quotaTags].map(async (tag) => {
|
|
1879
|
+
var _a;
|
|
1880
|
+
try {
|
|
1881
|
+
const quota = await this.productBuilder.fetchQuota(tag);
|
|
1882
|
+
return { tag, found: !!quota };
|
|
1883
|
+
}
|
|
1884
|
+
catch (e) {
|
|
1885
|
+
stepLog('Quota fetch failed (step may fail later)', { quota_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1886
|
+
return { tag, found: false };
|
|
1887
|
+
}
|
|
1888
|
+
}));
|
|
1889
|
+
}
|
|
1890
|
+
// Pre-fetch fallbacks for FALLBACK steps
|
|
1891
|
+
const fallbackTags = new Set();
|
|
1892
|
+
for (const step of steps) {
|
|
1893
|
+
if (step.type === types_1.WorkflowStepType.FALLBACK && step.fallback) {
|
|
1894
|
+
fallbackTags.add(step.fallback);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
if (fallbackTags.size > 0) {
|
|
1898
|
+
stepLog('Fetching fallbacks for fallback steps', { fallback_tags: [...fallbackTags] });
|
|
1899
|
+
await Promise.all([...fallbackTags].map(async (tag) => {
|
|
1900
|
+
var _a;
|
|
1901
|
+
try {
|
|
1902
|
+
const fallback = await this.productBuilder.fetchFallback(tag);
|
|
1903
|
+
return { tag, found: !!fallback };
|
|
1904
|
+
}
|
|
1905
|
+
catch (e) {
|
|
1906
|
+
stepLog('Fallback fetch failed (step may fail later)', { fallback_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1907
|
+
return { tag, found: false };
|
|
1908
|
+
}
|
|
1909
|
+
}));
|
|
1910
|
+
}
|
|
1911
|
+
// Pre-fetch features for FEATURE steps (step.event is the feature tag)
|
|
1912
|
+
const featureTags = new Set();
|
|
1913
|
+
for (const step of steps) {
|
|
1914
|
+
if (step.type === types_1.WorkflowStepType.FEATURE && step.event) {
|
|
1915
|
+
featureTags.add(step.event);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
if (featureTags.size > 0) {
|
|
1919
|
+
stepLog('Fetching features for feature steps', { feature_tags: [...featureTags] });
|
|
1920
|
+
await Promise.all([...featureTags].map(async (tag) => {
|
|
1921
|
+
var _a;
|
|
1922
|
+
try {
|
|
1923
|
+
const feature = await this.productBuilder.fetchFeature(tag);
|
|
1924
|
+
return { tag, found: !!feature };
|
|
1925
|
+
}
|
|
1926
|
+
catch (e) {
|
|
1927
|
+
stepLog('Feature fetch failed (step may fail later)', { feature_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1928
|
+
return { tag, found: false };
|
|
1929
|
+
}
|
|
1930
|
+
}));
|
|
1931
|
+
}
|
|
1932
|
+
// Pre-fetch child workflows for CHILD_WORKFLOW steps
|
|
1933
|
+
const workflowTags = new Set();
|
|
1934
|
+
for (const step of steps) {
|
|
1935
|
+
if (step.type === types_1.WorkflowStepType.CHILD_WORKFLOW && step.workflow) {
|
|
1936
|
+
workflowTags.add(step.workflow);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
if (workflowTags.size > 0) {
|
|
1940
|
+
stepLog('Fetching child workflows for child_workflow steps', { workflow_tags: [...workflowTags] });
|
|
1941
|
+
await Promise.all([...workflowTags].map(async (tag) => {
|
|
1942
|
+
var _a;
|
|
1943
|
+
try {
|
|
1944
|
+
const workflow = await this.productBuilder.fetchWorkflow(tag);
|
|
1945
|
+
return { tag, found: !!workflow };
|
|
1946
|
+
}
|
|
1947
|
+
catch (e) {
|
|
1948
|
+
stepLog('Child workflow fetch failed (step may fail later)', { workflow_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
|
|
1949
|
+
return { tag, found: false };
|
|
1950
|
+
}
|
|
1951
|
+
}));
|
|
1952
|
+
}
|
|
1953
|
+
// Pre-connect brokers, graphs, and databases so step execution reuses connections.
|
|
1954
|
+
// Security: product/env from this.state (same execution context). No connection URLs, config, or
|
|
1955
|
+
// credentials are ever logged. On pre-connect failure we log only tags and a generic message.
|
|
1956
|
+
if (brokerTags.size > 0) {
|
|
1957
|
+
stepLog('Pre-warming broker connections', { broker_tags: [...brokerTags] });
|
|
1958
|
+
try {
|
|
1959
|
+
await this.getBrokersService().warmBrokerConnections({ product, env, brokerTags: [...brokerTags] });
|
|
1960
|
+
}
|
|
1961
|
+
catch (_a) {
|
|
1962
|
+
stepLog('Broker pre-warm failed (steps may connect on first use)', { broker_tags: [...brokerTags] });
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
if (graphTags.size > 0) {
|
|
1966
|
+
stepLog('Pre-connecting graph connections', { graph_tags: [...graphTags] });
|
|
1967
|
+
await Promise.all([...graphTags].map((tag) => this.getGraphService()
|
|
1968
|
+
.connect({ product, env, graph: tag })
|
|
1969
|
+
.catch(() => {
|
|
1970
|
+
stepLog('Graph pre-connect failed (step may connect on first use)', { graph_tag: tag });
|
|
1971
|
+
})));
|
|
1972
|
+
}
|
|
1973
|
+
if (databaseTags.size > 0) {
|
|
1974
|
+
stepLog('Pre-connecting database connections', { database_tags: [...databaseTags] });
|
|
1975
|
+
await Promise.all([...databaseTags].map((tag) => this.getDatabaseService()
|
|
1976
|
+
.connect({ product, env, database: tag })
|
|
1977
|
+
.catch(() => {
|
|
1978
|
+
stepLog('Database pre-connect failed (step may connect on first use)', { database_tag: tag });
|
|
1979
|
+
})));
|
|
1980
|
+
}
|
|
1981
|
+
if (vectorTags.size > 0) {
|
|
1982
|
+
stepLog('Pre-connecting vector connections', { vector_tags: [...vectorTags] });
|
|
1983
|
+
await Promise.all([...vectorTags].map((tag) => this.getVectorService()
|
|
1984
|
+
.connect({ product, env, vector: tag })
|
|
1985
|
+
.catch(() => {
|
|
1986
|
+
stepLog('Vector pre-connect failed (step may connect on first use)', { vector_tag: tag });
|
|
1987
|
+
})));
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Find a step by tag
|
|
1992
|
+
*/
|
|
1993
|
+
findStep(tag) {
|
|
1994
|
+
return this.workflow.steps.find((s) => s.tag === tag);
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Evaluate a condition string.
|
|
1998
|
+
* Supports: (cond1) || (cond2), (cond1) && (cond2), and in each part: ==, ===, !=, !==, >, <, >=, <=.
|
|
1999
|
+
* Left/right can be $Step{}, $Input{}, etc. (resolved before comparison).
|
|
2000
|
+
*/
|
|
2001
|
+
async evaluateCondition(condition) {
|
|
2002
|
+
try {
|
|
2003
|
+
const orParts = condition.split(/\s*\|\|\s*/).map((p) => p.trim());
|
|
2004
|
+
for (const orPart of orParts) {
|
|
2005
|
+
const trimmed = orPart.replace(/^\(|\)$/g, '').trim();
|
|
2006
|
+
const andParts = trimmed.split(/\s*&&\s*/).map((p) => p.trim());
|
|
2007
|
+
let andResult = true;
|
|
2008
|
+
for (const andPart of andParts) {
|
|
2009
|
+
if (!(await this.evaluateConditionPart(andPart))) {
|
|
2010
|
+
andResult = false;
|
|
2011
|
+
break;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
if (andResult)
|
|
2015
|
+
return true;
|
|
2016
|
+
}
|
|
2017
|
+
return false;
|
|
2018
|
+
}
|
|
2019
|
+
catch (_a) {
|
|
2020
|
+
return false;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* Coerce a trimmed condition literal (after resolve) to a comparable value: boolean, number, or string.
|
|
2025
|
+
*/
|
|
2026
|
+
conditionLiteral(val) {
|
|
2027
|
+
const s = val.replace(/^["']|["']$/g, '').trim();
|
|
2028
|
+
if (s === 'true')
|
|
2029
|
+
return true;
|
|
2030
|
+
if (s === 'false')
|
|
2031
|
+
return false;
|
|
2032
|
+
if (s === 'null')
|
|
2033
|
+
return null;
|
|
2034
|
+
const n = Number(s);
|
|
2035
|
+
if (s !== '' && !Number.isNaN(n))
|
|
2036
|
+
return n;
|
|
2037
|
+
return s;
|
|
2038
|
+
}
|
|
2039
|
+
async evaluateConditionPart(condition) {
|
|
2040
|
+
try {
|
|
2041
|
+
const resolved = await this.resolveStringValue(condition);
|
|
2042
|
+
if (typeof resolved !== 'string') {
|
|
2043
|
+
return Boolean(resolved);
|
|
2044
|
+
}
|
|
2045
|
+
const match = resolved.match(WorkflowExecutor.CONDITION_OP_REGEX);
|
|
2046
|
+
if (!match) {
|
|
2047
|
+
return Boolean(this.conditionLiteral(resolved.trim()));
|
|
2048
|
+
}
|
|
2049
|
+
const [, leftStr, op, rightStr] = match;
|
|
2050
|
+
const left = this.conditionLiteral(leftStr.trim());
|
|
2051
|
+
const right = this.conditionLiteral(rightStr.trim());
|
|
2052
|
+
switch (op) {
|
|
2053
|
+
case '==':
|
|
2054
|
+
case '===':
|
|
2055
|
+
return this.compareLooseEqual(left, right);
|
|
2056
|
+
case '!=':
|
|
2057
|
+
case '!==':
|
|
2058
|
+
return !this.compareLooseEqual(left, right);
|
|
2059
|
+
case '>':
|
|
2060
|
+
return this.compareOrdered(left, right, (a, b) => a > b);
|
|
2061
|
+
case '<':
|
|
2062
|
+
return this.compareOrdered(left, right, (a, b) => a < b);
|
|
2063
|
+
case '>=':
|
|
2064
|
+
return this.compareOrdered(left, right, (a, b) => a >= b);
|
|
2065
|
+
case '<=':
|
|
2066
|
+
return this.compareOrdered(left, right, (a, b) => a <= b);
|
|
2067
|
+
default:
|
|
2068
|
+
return false;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
catch (_a) {
|
|
2072
|
+
return false;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
compareLooseEqual(a, b) {
|
|
2076
|
+
if (a === b)
|
|
2077
|
+
return true;
|
|
2078
|
+
if (a == null && b == null)
|
|
2079
|
+
return true;
|
|
2080
|
+
if (typeof a === 'boolean' && typeof b === 'boolean')
|
|
2081
|
+
return a === b;
|
|
2082
|
+
if (typeof a === 'number' && typeof b === 'number')
|
|
2083
|
+
return a === b;
|
|
2084
|
+
return String(a) === String(b);
|
|
2085
|
+
}
|
|
2086
|
+
/**
|
|
2087
|
+
* Compare for ordering (>, <, >=, <=). Uses numeric comparison when both sides are numeric, else string.
|
|
2088
|
+
*/
|
|
2089
|
+
compareOrdered(left, right, cmp) {
|
|
2090
|
+
const l = typeof left === 'number' ? left : Number(left);
|
|
2091
|
+
const r = typeof right === 'number' ? right : Number(right);
|
|
2092
|
+
const bothNumeric = !Number.isNaN(l) && !Number.isNaN(r);
|
|
2093
|
+
if (bothNumeric)
|
|
2094
|
+
return cmp(l, r);
|
|
2095
|
+
return cmp(String(left !== null && left !== void 0 ? left : ''), String(right !== null && right !== void 0 ? right : ''));
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* Returns true if the value tree contains any $ operator reference ($Input{}, $Step{}, $Sequence{}, etc.).
|
|
2099
|
+
* Used to distinguish output templates (to resolve) from type-only schemas (to ignore for persistence).
|
|
2100
|
+
*/
|
|
2101
|
+
hasOperatorRefsInOutput(value) {
|
|
2102
|
+
if (typeof value === 'string') {
|
|
2103
|
+
const v = value.trim();
|
|
2104
|
+
return /^\$((Input|Step|Sequence|State|StepOutput|Now|Add|Subtract|Concat|Size|Length|Pick|Filter|Find|Join|Split|Replace|Substring|Trim|Uppercase|Lowercase|Dateformat)\{|[A-Za-z]+\()/.test(v);
|
|
2105
|
+
}
|
|
2106
|
+
if (Array.isArray(value)) {
|
|
2107
|
+
return value.some((item) => this.hasOperatorRefsInOutput(item));
|
|
2108
|
+
}
|
|
2109
|
+
if (value && typeof value === 'object') {
|
|
2110
|
+
return Object.values(value).some((v) => this.hasOperatorRefsInOutput(v));
|
|
2111
|
+
}
|
|
2112
|
+
return false;
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Returns true if the object looks like a workflow output type schema (e.g. { orderId: { type: 'string' }, ... })
|
|
2116
|
+
* rather than a template with $ operators or literal values.
|
|
2117
|
+
*/
|
|
2118
|
+
isOutputTypeSchema(output) {
|
|
2119
|
+
if (Object.keys(output).length === 0)
|
|
2120
|
+
return false;
|
|
2121
|
+
return Object.values(output).every((v) => {
|
|
2122
|
+
if (v != null && typeof v === 'object' && !Array.isArray(v)) {
|
|
2123
|
+
const o = v;
|
|
2124
|
+
return 'type' in o && typeof o.type === 'string';
|
|
2125
|
+
}
|
|
2126
|
+
return false;
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Determine workflow output for persistence and return value.
|
|
2131
|
+
* - If workflow.output has $ operator refs: resolve template to actual values (matches definition).
|
|
2132
|
+
* - If workflow.output is a type-only schema: use execution result (last step or step_outputs) so stored result matches runtime output, not the schema.
|
|
2133
|
+
* - If no workflow.output: use last step result or {}.
|
|
2134
|
+
*/
|
|
2135
|
+
async determineWorkflowOutput() {
|
|
2136
|
+
const outputDef = this.workflow.output;
|
|
2137
|
+
if (!outputDef || Object.keys(outputDef).length === 0) {
|
|
2138
|
+
const lastStep = this.state.completed_steps[this.state.completed_steps.length - 1];
|
|
2139
|
+
return lastStep ? this.state.steps[lastStep] : {};
|
|
2140
|
+
}
|
|
2141
|
+
const hasRefs = this.hasOperatorRefsInOutput(outputDef);
|
|
2142
|
+
if (hasRefs) {
|
|
2143
|
+
return this.resolveInput(outputDef);
|
|
2144
|
+
}
|
|
2145
|
+
if (this.isOutputTypeSchema(outputDef)) {
|
|
2146
|
+
const out = this.buildOutputFromStepsToMatchDefinition(outputDef);
|
|
2147
|
+
return Object.keys(out).length > 0 ? out : {};
|
|
2148
|
+
}
|
|
2149
|
+
return this.resolveInput(outputDef);
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Build output with same keys as workflow definition, values from step_outputs (last step first, then others).
|
|
2153
|
+
* Ensures persisted result shape matches the workflow definition output shape.
|
|
2154
|
+
*/
|
|
2155
|
+
buildOutputFromStepsToMatchDefinition(definitionKeys) {
|
|
2156
|
+
var _a;
|
|
2157
|
+
const keys = Object.keys(definitionKeys);
|
|
2158
|
+
if (keys.length === 0)
|
|
2159
|
+
return {};
|
|
2160
|
+
const out = {};
|
|
2161
|
+
const stepsReversed = [...this.state.completed_steps].reverse();
|
|
2162
|
+
for (const key of keys) {
|
|
2163
|
+
for (const stepTag of stepsReversed) {
|
|
2164
|
+
const stepData = this.state.steps[stepTag];
|
|
2165
|
+
if (stepData == null || typeof stepData !== 'object')
|
|
2166
|
+
continue;
|
|
2167
|
+
const rec = stepData;
|
|
2168
|
+
if (key in rec) {
|
|
2169
|
+
out[key] = rec[key];
|
|
2170
|
+
break;
|
|
2171
|
+
}
|
|
2172
|
+
const nested = (_a = rec.output) !== null && _a !== void 0 ? _a : rec.result;
|
|
2173
|
+
if (nested != null && typeof nested === 'object' && key in nested) {
|
|
2174
|
+
out[key] = nested[key];
|
|
2175
|
+
break;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
if (Object.keys(out).length === 0 && this.state.completed_steps.length > 0) {
|
|
2180
|
+
const lastStep = this.state.completed_steps[this.state.completed_steps.length - 1];
|
|
2181
|
+
const lastOutput = this.state.steps[lastStep];
|
|
2182
|
+
return lastOutput != null && typeof lastOutput === 'object' ? lastOutput : {};
|
|
2183
|
+
}
|
|
2184
|
+
return out;
|
|
2185
|
+
}
|
|
2186
|
+
/**
|
|
2187
|
+
* Sleep for specified duration
|
|
2188
|
+
*/
|
|
2189
|
+
sleep(ms) {
|
|
2190
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Resume a workflow from a previous state
|
|
2194
|
+
*
|
|
2195
|
+
* @param options - Resume options including completed steps, state, and starting point
|
|
2196
|
+
*/
|
|
2197
|
+
async resume(options) {
|
|
2198
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
2199
|
+
const startTime = Date.now();
|
|
2200
|
+
debugLog('[WorkflowExecutor] resume ENTRY', {
|
|
2201
|
+
workflow_id: this.state.workflow_id,
|
|
2202
|
+
workflow_tag: this.state.workflow_tag,
|
|
2203
|
+
completed_steps_count: (_b = (_a = options.completed_steps) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
2204
|
+
from_checkpoint: options.from_checkpoint,
|
|
2205
|
+
from_step: options.from_step,
|
|
2206
|
+
skip_steps: (_d = (_c = options.skip_steps) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
2207
|
+
});
|
|
2208
|
+
try {
|
|
2209
|
+
// Track phase so failures before first step are reported as (initialization)
|
|
2210
|
+
this.state.current_step = '(initialization)';
|
|
2211
|
+
// Initialize product builder with the product
|
|
2212
|
+
await this.productBuilder.initializeProductByTag(this.state.product);
|
|
2213
|
+
this.productId = this.productBuilder.fetchProductId();
|
|
2214
|
+
// Initialize logging after we have product ID
|
|
2215
|
+
this.initializeLogging();
|
|
2216
|
+
// Restore previous state
|
|
2217
|
+
this.state.completed_steps = options.completed_steps || [];
|
|
2218
|
+
this.state.state = options.state || {};
|
|
2219
|
+
// Restore step outputs if provided
|
|
2220
|
+
if (options.step_outputs) {
|
|
2221
|
+
this.state.steps = Object.assign(Object.assign({}, this.state.steps), options.step_outputs);
|
|
2222
|
+
}
|
|
2223
|
+
this.state.status = types_1.WorkflowStatus.RUNNING;
|
|
2224
|
+
// Get steps in execution order
|
|
2225
|
+
const orderedSteps = this.getOrderedSteps();
|
|
2226
|
+
// Find starting point
|
|
2227
|
+
let startIndex = 0;
|
|
2228
|
+
if (options.from_checkpoint) {
|
|
2229
|
+
// Find the step after the checkpoint
|
|
2230
|
+
const checkpointIndex = orderedSteps.findIndex((s) => s.type === types_1.WorkflowStepType.CHECKPOINT && s.tag === options.from_checkpoint);
|
|
2231
|
+
if (checkpointIndex >= 0) {
|
|
2232
|
+
startIndex = checkpointIndex + 1;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
else if (options.from_step) {
|
|
2236
|
+
// Start from the specified step
|
|
2237
|
+
startIndex = orderedSteps.findIndex((s) => s.tag === options.from_step);
|
|
2238
|
+
if (startIndex === -1) {
|
|
2239
|
+
throw new Error(`Step ${options.from_step} not found`);
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
else {
|
|
2243
|
+
// Start after last completed step
|
|
2244
|
+
const lastCompleted = this.state.completed_steps[this.state.completed_steps.length - 1];
|
|
2245
|
+
if (lastCompleted) {
|
|
2246
|
+
const lastIndex = orderedSteps.findIndex((s) => s.tag === lastCompleted);
|
|
2247
|
+
startIndex = lastIndex + 1;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
debugLog('[WorkflowExecutor] resume starting from step index', {
|
|
2251
|
+
workflow_id: this.state.workflow_id,
|
|
2252
|
+
startIndex,
|
|
2253
|
+
total_steps: orderedSteps.length,
|
|
2254
|
+
steps_to_run: orderedSteps.slice(startIndex).map((s) => s.tag),
|
|
2255
|
+
});
|
|
2256
|
+
// Execute remaining steps
|
|
2257
|
+
for (let i = startIndex; i < orderedSteps.length; i++) {
|
|
2258
|
+
const step = orderedSteps[i];
|
|
2259
|
+
// Skip if already completed or in skip list
|
|
2260
|
+
if (this.state.completed_steps.includes(step.tag)) {
|
|
2261
|
+
this.logStepEvent(step, `Step ${step.tag} - skipped (already completed)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
|
|
2262
|
+
continue;
|
|
2263
|
+
}
|
|
2264
|
+
if ((_e = options.skip_steps) === null || _e === void 0 ? void 0 : _e.includes(step.tag)) {
|
|
2265
|
+
this.logStepEvent(step, `Step ${step.tag} - skipped (in skip list)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
|
|
2266
|
+
continue;
|
|
2267
|
+
}
|
|
2268
|
+
// Check step condition if present
|
|
2269
|
+
if (step.condition && !(await this.evaluateCondition(step.condition))) {
|
|
2270
|
+
this.logStepEvent(step, `Step ${step.tag} - skipped (condition not met)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
|
|
2271
|
+
continue;
|
|
2272
|
+
}
|
|
2273
|
+
this.state.current_step = step.tag;
|
|
2274
|
+
// Log step start
|
|
2275
|
+
this.logStepEvent(step, `Step ${step.tag} - started`, logs_types_1.LogEventStatus.PROCESSING);
|
|
2276
|
+
const result = await this.executeStep(step);
|
|
2277
|
+
// Log step completion
|
|
2278
|
+
this.logStepEvent(step, result.success ? `Step ${step.tag} - completed` : `Step ${step.tag} - failed`, result.success ? logs_types_1.LogEventStatus.SUCCESS : logs_types_1.LogEventStatus.FAIL, { duration: result.duration, error: result.error });
|
|
2279
|
+
// Persist step result to backend
|
|
2280
|
+
await this.persistStepResult(step, result.success ? types_1.LogEventStatus.SUCCESS : types_1.LogEventStatus.FAIL, result.output, result.error, result.duration, result.input);
|
|
2281
|
+
this.state.step_timings.push({
|
|
2282
|
+
tag: step.tag,
|
|
2283
|
+
duration_ms: result.duration,
|
|
2284
|
+
success: result.success,
|
|
2285
|
+
});
|
|
2286
|
+
if (!result.success) {
|
|
2287
|
+
this.state.failed_step = step.tag;
|
|
2288
|
+
// Check if step allows failure
|
|
2289
|
+
if ((_f = step.options) === null || _f === void 0 ? void 0 : _f.allow_fail) {
|
|
2290
|
+
this.state.steps[step.tag] = { error: result.error };
|
|
2291
|
+
continue;
|
|
2292
|
+
}
|
|
2293
|
+
// Check if step is optional
|
|
2294
|
+
if ((_g = step.options) === null || _g === void 0 ? void 0 : _g.optional) {
|
|
2295
|
+
continue;
|
|
2296
|
+
}
|
|
2297
|
+
// Trigger rollback
|
|
2298
|
+
this.state.status = types_1.WorkflowStatus.ROLLING_BACK;
|
|
2299
|
+
const rollbackResult = await this.executeRollback(step.tag, result.error || 'Step failed');
|
|
2300
|
+
await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, result.error);
|
|
2301
|
+
await ((_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish());
|
|
2302
|
+
if (this.graphConnectionUsed) {
|
|
2303
|
+
await this.getGraphService().disconnect().catch(() => { });
|
|
2304
|
+
await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
|
|
2305
|
+
if (this._brokersService)
|
|
2306
|
+
await this._brokersService.disconnectAll().catch(() => { });
|
|
2307
|
+
await this.getProcessorService().disconnectMailTransporters().catch(() => { });
|
|
2308
|
+
await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
|
|
2309
|
+
await this.getProcessorService().disconnectSmsClients().catch(() => { });
|
|
2310
|
+
}
|
|
2311
|
+
return {
|
|
2312
|
+
status: types_1.WorkflowStatus.ROLLED_BACK,
|
|
2313
|
+
workflow_id: this.state.workflow_id,
|
|
2314
|
+
error: result.error,
|
|
2315
|
+
execution_time: Date.now() - startTime,
|
|
2316
|
+
completed_steps: this.state.completed_steps,
|
|
2317
|
+
step_timings: this.state.step_timings,
|
|
2318
|
+
failed_step: step.tag,
|
|
2319
|
+
rollback_info: {
|
|
2320
|
+
triggered_by: step.tag,
|
|
2321
|
+
reason: result.error || 'Step failed',
|
|
2322
|
+
rolled_back_steps: rollbackResult.rolled_back_steps,
|
|
2323
|
+
failed_rollbacks: rollbackResult.failed_steps,
|
|
2324
|
+
},
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
// Store step output and mark as completed
|
|
2328
|
+
this.state.steps[step.tag] = result.output;
|
|
2329
|
+
this.state.completed_steps.push(step.tag);
|
|
2330
|
+
}
|
|
2331
|
+
this.state.status = types_1.WorkflowStatus.COMPLETED;
|
|
2332
|
+
this.state.ended_at = Date.now();
|
|
2333
|
+
const output = await this.determineWorkflowOutput();
|
|
2334
|
+
debugLog('[WorkflowExecutor] resume COMPLETED', {
|
|
2335
|
+
workflow_id: this.state.workflow_id,
|
|
2336
|
+
workflow_tag: this.state.workflow_tag,
|
|
2337
|
+
completed_steps: this.state.completed_steps.length,
|
|
2338
|
+
execution_time_ms: Date.now() - startTime,
|
|
2339
|
+
});
|
|
2340
|
+
await this.persistExecutionResult(types_1.LogEventStatus.SUCCESS, output);
|
|
2341
|
+
await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
|
|
2342
|
+
if (this.graphConnectionUsed) {
|
|
2343
|
+
await this.getGraphService().disconnect().catch(() => { });
|
|
2344
|
+
await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
|
|
2345
|
+
if (this._brokersService)
|
|
2346
|
+
await this._brokersService.disconnectAll().catch(() => { });
|
|
2347
|
+
await this.getProcessorService().disconnectMailTransporters().catch(() => { });
|
|
2348
|
+
await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
|
|
2349
|
+
await this.getProcessorService().disconnectSmsClients().catch(() => { });
|
|
2350
|
+
}
|
|
2351
|
+
return {
|
|
2352
|
+
status: types_1.WorkflowStatus.COMPLETED,
|
|
2353
|
+
workflow_id: this.state.workflow_id,
|
|
2354
|
+
output: output,
|
|
2355
|
+
execution_time: Date.now() - startTime,
|
|
2356
|
+
completed_steps: this.state.completed_steps,
|
|
2357
|
+
step_timings: this.state.step_timings,
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2360
|
+
catch (error) {
|
|
2361
|
+
this.state.status = types_1.WorkflowStatus.FAILED;
|
|
2362
|
+
this.state.ended_at = Date.now();
|
|
2363
|
+
const details = formatErrorDetails(error);
|
|
2364
|
+
const failedAt = (_k = this.state.current_step) !== null && _k !== void 0 ? _k : '(unknown)';
|
|
2365
|
+
debugLog('[WorkflowExecutor] resume FAILED (exception)', Object.assign(Object.assign({ workflow_id: this.state.workflow_id, workflow_tag: this.state.workflow_tag, failed_at: failedAt, completed_steps: this.state.completed_steps, error: details.message }, (details.status != null && { http_status: details.status })), (details.responseBody != null && { response_body: details.responseBody })));
|
|
2366
|
+
if (details.stack) {
|
|
2367
|
+
debugLog('[WorkflowExecutor] resume FAILED stack', details.stack);
|
|
2368
|
+
}
|
|
2369
|
+
const errorSummary = details.status != null
|
|
2370
|
+
? `Failed at ${failedAt}: ${details.message} (HTTP ${details.status})`
|
|
2371
|
+
: `Failed at ${failedAt}: ${details.message}`;
|
|
2372
|
+
await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, errorSummary);
|
|
2373
|
+
await ((_l = this.logService) === null || _l === void 0 ? void 0 : _l.publish());
|
|
2374
|
+
if (this.graphConnectionUsed) {
|
|
2375
|
+
await this.getGraphService().disconnect().catch(() => { });
|
|
2376
|
+
await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
|
|
2377
|
+
if (this._brokersService)
|
|
2378
|
+
await this._brokersService.disconnectAll().catch(() => { });
|
|
2379
|
+
await this.getProcessorService().disconnectMailTransporters().catch(() => { });
|
|
2380
|
+
await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
|
|
2381
|
+
await this.getProcessorService().disconnectSmsClients().catch(() => { });
|
|
2382
|
+
}
|
|
2383
|
+
return {
|
|
2384
|
+
status: types_1.WorkflowStatus.FAILED,
|
|
2385
|
+
workflow_id: this.state.workflow_id,
|
|
2386
|
+
error: errorSummary,
|
|
2387
|
+
execution_time: Date.now() - startTime,
|
|
2388
|
+
completed_steps: this.state.completed_steps,
|
|
2389
|
+
step_timings: this.state.step_timings,
|
|
2390
|
+
failed_step: this.state.current_step,
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
exports.WorkflowExecutor = WorkflowExecutor;
|
|
2396
|
+
/** Comparison operators in parse order (multi-char before single-char). */
|
|
2397
|
+
WorkflowExecutor.CONDITION_OP_REGEX = /^\s*(.+?)\s*(!==|===|==|>=|<=|!=|>|<)\s*(.+)\s*$/;
|
|
2398
|
+
exports.default = WorkflowExecutor;
|
|
2399
|
+
//# sourceMappingURL=workflow-executor.js.map
|