@ductape/sdk 0.0.4-v51 → 0.0.4-v52
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 +1 -1
- package/dist/agents/agent-context.d.ts +98 -0
- package/dist/agents/agent-context.js +588 -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 +304 -0
- package/dist/agents/agents.service.js +1244 -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 +1225 -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.js +4 -5
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +322 -0
- package/dist/api/services/processorApi.service.js +252 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +69 -1
- package/dist/api/services/productsApi.service.js +67 -31
- 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 +38 -0
- package/dist/api/services/secretsApi.service.js +96 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/userApi.service.js +0 -1
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +183 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.js +0 -1
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +57 -0
- package/dist/api/urls.js +68 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.js +4 -10
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +0 -10
- package/dist/apps/services/app.service.js +74 -30
- 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 +405 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.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 +257 -0
- package/dist/brokers/brokers.service.js +604 -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 +288 -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/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
- 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/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
- 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 +16 -0
- package/dist/brokers/utils/providers/kafka.service.js +52 -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 +14 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
- package/dist/brokers/utils/providers/redis.service.js +93 -0
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +159 -0
- package/dist/cache/cache.manager.js +265 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +186 -0
- package/dist/cache/cache.service.js +437 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +79 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +106 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.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 +307 -90
- package/dist/database/adapters/base.adapter.js +139 -20
- package/dist/database/adapters/base.adapter.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
- package/dist/database/adapters/cassandra.adapter.js +1019 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
- package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- 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 +105 -57
- package/dist/database/adapters/mongodb.adapter.js +941 -838
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +76 -138
- package/dist/database/adapters/mysql.adapter.js +990 -1246
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
- package/dist/database/adapters/postgresql.adapter.js +1076 -1346
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +1374 -0
- package/dist/database/databases.service.js +2680 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +41 -13
- package/dist/database/index.js +97 -86
- package/dist/database/index.js.map +1 -1
- 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 +132 -0
- package/dist/database/migrations/migration-engine.js +1356 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +64 -0
- package/dist/database/operators/aggregation-builder.js +746 -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 +55 -0
- package/dist/database/operators/query-builder.js +365 -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 +637 -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 +179 -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/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 +12 -10
- package/dist/database/types/index.js +26 -32
- package/dist/database/types/index.js.map +1 -1
- 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 +199 -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 +398 -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 +208 -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 +78 -72
- package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/base.adapter.d.ts +135 -118
- package/dist/graph/adapters/base.adapter.js +46 -20
- package/dist/graph/adapters/base.adapter.js.map +1 -1
- package/dist/graph/adapters/index.d.ts +5 -4
- package/dist/graph/adapters/index.js +6 -8
- package/dist/graph/adapters/index.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
- package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
- package/dist/graph/adapters/neo4j.adapter.js +912 -1605
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
- package/dist/graph/adapters/neptune.adapter.js +1095 -1228
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +524 -0
- package/dist/graph/graphs.service.js +1683 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +54 -8
- package/dist/graph/index.js +67 -32
- package/dist/graph/index.js.map +1 -1
- 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 +141 -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 +11 -9
- package/dist/graph/types/index.js +15 -30
- package/dist/graph/types/index.js.map +1 -1
- 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 +168 -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/index.d.ts +1905 -875
- package/dist/index.js +3063 -1282
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/init.interface.js +3 -0
- package/dist/init.interface.js.map +1 -0
- 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.types.d.ts +12 -2
- package/dist/logs/logs.types.js +5 -1
- 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 +252 -0
- package/dist/notifications/notifications.service.js +654 -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 +400 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +86 -70
- package/dist/processor/services/processor.service.js +1353 -1259
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +5 -1
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/services/products.service.d.ts +167 -25
- package/dist/products/services/products.service.js +1248 -412
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +6 -3
- package/dist/products/validators/index.js +14 -5
- 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 +218 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- 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.productDatabaseAction.validator.d.ts +4 -15
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
- 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 +135 -50
- 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 +135 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- 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.productDatabaseAction.validator.d.ts +0 -6
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +88 -0
- package/dist/resilience/fallback.service.js +511 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +106 -0
- package/dist/resilience/healthcheck.service.js +379 -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 +90 -0
- package/dist/resilience/quota.service.js +519 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +95 -0
- package/dist/resilience/resilience.service.js +525 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +479 -0
- package/dist/resilience/types/index.js +26 -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 +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +83 -0
- package/dist/secrets/secrets.service.js +159 -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 +93 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +68 -0
- package/dist/sessions/sessions.helper.js +116 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +150 -0
- package/dist/sessions/sessions.resolver.js +356 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +170 -0
- package/dist/sessions/sessions.service.js +736 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +290 -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 +98 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +123 -0
- package/dist/storage/storage.service.js +478 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +207 -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 +51 -0
- package/dist/storage/utils/storage.util.js +402 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +13 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -15
- package/dist/test/test.appBuilder.js.map +1 -1
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.health.d.ts +0 -1
- package/dist/test/test.health.js +0 -48
- package/dist/test/test.health.js.map +1 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1506
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -75
- package/dist/test/test.import.openapi.js.map +1 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -76
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -17
- package/dist/test/test.logs.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +0 -1
- package/dist/test/test.notifiers.js +0 -84
- package/dist/test/test.notifiers.js.map +1 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -37
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -660
- package/dist/test/test.productBuilder.js.map +1 -1
- package/dist/test/test.products.d.ts +0 -1
- package/dist/test/test.products.js +0 -48
- package/dist/test/test.products.js.map +1 -1
- package/dist/test/test.storage.js +332 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/dist/types/enums.d.ts +6 -1
- package/dist/types/enums.js +5 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/processor.types.d.ts +197 -35
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +837 -75
- package/dist/types/productsBuilder.types.js +168 -62
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +2 -49
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +152 -0
- package/dist/vector/adapters/base.adapter.js +137 -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 +400 -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 +392 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
- package/dist/vector/adapters/weaviate.adapter.js +478 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +47 -0
- package/dist/vector/index.js +72 -0
- package/dist/vector/index.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 +9 -0
- package/dist/vector/types/index.js +16 -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 +117 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +405 -0
- package/dist/vector/vector-database.service.js +544 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +245 -0
- package/dist/vector/vector.service.js +381 -0
- package/dist/vector/vector.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 +1035 -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 +338 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +205 -0
- package/dist/workflows/workflow-executor.js +1186 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +398 -0
- package/dist/workflows/workflows.service.js +1595 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +16 -13
- package/dist/actions/actions.repo.d.ts +0 -0
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.d.ts +0 -0
- 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/api/services/workspaceSecretsApi.service.d.ts +0 -75
- package/dist/api/services/workspaceSecretsApi.service.js +0 -62
- package/dist/api/services/workspaceSecretsApi.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.d.ts +0 -3
- 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.d.ts +0 -3
- 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/database/database.service.d.ts +0 -232
- package/dist/database/database.service.js +0 -802
- package/dist/database/database.service.js.map +0 -1
- package/dist/database/types/aggregation.types.d.ts +0 -261
- package/dist/database/types/aggregation.types.js +0 -21
- package/dist/database/types/aggregation.types.js.map +0 -1
- package/dist/database/types/connection.types.d.ts +0 -132
- package/dist/database/types/connection.types.js +0 -6
- package/dist/database/types/connection.types.js.map +0 -1
- package/dist/database/types/database.types.d.ts +0 -175
- package/dist/database/types/database.types.js +0 -75
- package/dist/database/types/database.types.js.map +0 -1
- package/dist/database/types/index.types.d.ts +0 -220
- package/dist/database/types/index.types.js +0 -27
- package/dist/database/types/index.types.js.map +0 -1
- package/dist/database/types/migration.types.d.ts +0 -205
- package/dist/database/types/migration.types.js +0 -44
- package/dist/database/types/migration.types.js.map +0 -1
- package/dist/database/types/query.types.d.ts +0 -305
- package/dist/database/types/query.types.js +0 -57
- package/dist/database/types/query.types.js.map +0 -1
- package/dist/database/types/result.types.d.ts +0 -220
- package/dist/database/types/result.types.js +0 -6
- package/dist/database/types/result.types.js.map +0 -1
- package/dist/database/types/schema.types.d.ts +0 -190
- package/dist/database/types/schema.types.js +0 -69
- package/dist/database/types/schema.types.js.map +0 -1
- package/dist/database/utils/helpers.d.ts +0 -66
- package/dist/database/utils/helpers.js +0 -501
- package/dist/database/utils/helpers.js.map +0 -1
- package/dist/database/utils/migration.utils.d.ts +0 -151
- package/dist/database/utils/migration.utils.js +0 -476
- package/dist/database/utils/migration.utils.js.map +0 -1
- package/dist/database/utils/transaction.d.ts +0 -64
- package/dist/database/utils/transaction.js +0 -130
- package/dist/database/utils/transaction.js.map +0 -1
- package/dist/database/validators/connection.validator.d.ts +0 -20
- package/dist/database/validators/connection.validator.js +0 -267
- package/dist/database/validators/connection.validator.js.map +0 -1
- package/dist/database/validators/query.validator.d.ts +0 -31
- package/dist/database/validators/query.validator.js +0 -305
- package/dist/database/validators/query.validator.js.map +0 -1
- package/dist/database/validators/schema.validator.d.ts +0 -31
- package/dist/database/validators/schema.validator.js +0 -334
- package/dist/database/validators/schema.validator.js.map +0 -1
- package/dist/graph/graph.service.d.ts +0 -278
- package/dist/graph/graph.service.js +0 -687
- package/dist/graph/graph.service.js.map +0 -1
- package/dist/graph/types/connection.types.d.ts +0 -158
- package/dist/graph/types/connection.types.js +0 -43
- package/dist/graph/types/connection.types.js.map +0 -1
- package/dist/graph/types/graph.types.d.ts +0 -144
- package/dist/graph/types/graph.types.js +0 -84
- package/dist/graph/types/graph.types.js.map +0 -1
- package/dist/graph/types/node.types.d.ts +0 -193
- package/dist/graph/types/node.types.js +0 -49
- package/dist/graph/types/node.types.js.map +0 -1
- package/dist/graph/types/path.types.d.ts +0 -224
- package/dist/graph/types/path.types.js +0 -38
- package/dist/graph/types/path.types.js.map +0 -1
- package/dist/graph/types/query.types.d.ts +0 -247
- package/dist/graph/types/query.types.js +0 -23
- package/dist/graph/types/query.types.js.map +0 -1
- package/dist/graph/types/relationship.types.d.ts +0 -224
- package/dist/graph/types/relationship.types.js +0 -35
- package/dist/graph/types/relationship.types.js.map +0 -1
- package/dist/graph/types/result.types.d.ts +0 -237
- package/dist/graph/types/result.types.js +0 -7
- package/dist/graph/types/result.types.js.map +0 -1
- package/dist/graph/validators/index.d.ts +0 -81
- package/dist/graph/validators/index.js +0 -243
- package/dist/graph/validators/index.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/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/services/utils/crypt.utils.d.ts +0 -1
- package/dist/products/services/utils/crypt.utils.js +0 -17
- package/dist/products/services/utils/crypt.utils.js.map +0 -1
- package/dist/products/services/utils/functions.utils.d.ts +0 -13
- package/dist/products/services/utils/functions.utils.js +0 -289
- package/dist/products/services/utils/functions.utils.js.map +0 -1
- package/dist/products/services/utils/objects.utils.d.ts +0 -13
- package/dist/products/services/utils/objects.utils.js +0 -89
- package/dist/products/services/utils/objects.utils.js.map +0 -1
- package/dist/products/services/utils/string.utils.d.ts +0 -12
- package/dist/products/services/utils/string.utils.js +0 -168
- package/dist/products/services/utils/string.utils.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/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +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.js +0 -28
- package/dist/test.imports.js.map +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/tsconfig.tsbuildinfo +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/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
|
@@ -0,0 +1,1595 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Workflow Service
|
|
4
|
+
*
|
|
5
|
+
* Main service class for workflow operations.
|
|
6
|
+
* Provides CRUD operations and execution for Ductape Workflows.
|
|
7
|
+
*
|
|
8
|
+
* Based on Ductape Workflows Code-First API documentation.
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.workflowService = exports.WorkflowService = exports.WorkflowError = void 0;
|
|
48
|
+
const crypto_1 = require("crypto");
|
|
49
|
+
const products_service_1 = __importDefault(require("../products/services/products.service"));
|
|
50
|
+
const processor_service_1 = __importDefault(require("../processor/services/processor.service"));
|
|
51
|
+
const workflowApi_service_1 = require("../api/services/workflowApi.service");
|
|
52
|
+
const logs_service_1 = __importDefault(require("../logs/logs.service"));
|
|
53
|
+
const logs_types_1 = require("../logs/logs.types");
|
|
54
|
+
const processor_utils_1 = require("../processor/utils/processor.utils");
|
|
55
|
+
const productsBuilder_types_1 = require("../types/productsBuilder.types");
|
|
56
|
+
const workflow_executor_1 = require("./workflow-executor");
|
|
57
|
+
/**
|
|
58
|
+
* Error class for workflow-related errors
|
|
59
|
+
*/
|
|
60
|
+
class WorkflowError extends Error {
|
|
61
|
+
constructor(message, code, details) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.code = code;
|
|
64
|
+
this.details = details;
|
|
65
|
+
this.name = 'WorkflowError';
|
|
66
|
+
}
|
|
67
|
+
static configurationError(message) {
|
|
68
|
+
return new WorkflowError(message, 'CONFIGURATION_ERROR');
|
|
69
|
+
}
|
|
70
|
+
static validationError(message, details) {
|
|
71
|
+
return new WorkflowError(message, 'VALIDATION_ERROR', details);
|
|
72
|
+
}
|
|
73
|
+
static notFoundError(message) {
|
|
74
|
+
return new WorkflowError(message, 'NOT_FOUND');
|
|
75
|
+
}
|
|
76
|
+
static executionError(message, details) {
|
|
77
|
+
return new WorkflowError(message, 'EXECUTION_ERROR', details);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.WorkflowError = WorkflowError;
|
|
81
|
+
/**
|
|
82
|
+
* Main Workflow Service class
|
|
83
|
+
* Provides unified interface for workflow management and execution
|
|
84
|
+
*/
|
|
85
|
+
class WorkflowService {
|
|
86
|
+
/**
|
|
87
|
+
* Create a new WorkflowService instance
|
|
88
|
+
* @param config - Optional configuration for authentication and workspace context
|
|
89
|
+
*/
|
|
90
|
+
constructor(config) {
|
|
91
|
+
/** Service configuration */
|
|
92
|
+
this.config = null;
|
|
93
|
+
/** ProductBuilder instances cache (keyed by product tag) */
|
|
94
|
+
this.productBuilders = new Map();
|
|
95
|
+
/** Local workflow configurations */
|
|
96
|
+
this.localConfigs = new Map();
|
|
97
|
+
/** Workflow API service for backend communication */
|
|
98
|
+
this.workflowApiService = null;
|
|
99
|
+
/** LogService instance for logging operations */
|
|
100
|
+
this.logService = null;
|
|
101
|
+
/** Current product ID for logging */
|
|
102
|
+
this.productId = '';
|
|
103
|
+
this.config = config || null;
|
|
104
|
+
if (config) {
|
|
105
|
+
this.workflowApiService = new workflowApi_service_1.WorkflowApiService(config.env_type);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// ==================== CONFIGURATION ====================
|
|
109
|
+
/**
|
|
110
|
+
* Update service configuration
|
|
111
|
+
*/
|
|
112
|
+
updateConfig(config) {
|
|
113
|
+
this.config = config;
|
|
114
|
+
this.workflowApiService = new workflowApi_service_1.WorkflowApiService(config.env_type);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get auth payload for API calls
|
|
118
|
+
*/
|
|
119
|
+
getAuthPayload() {
|
|
120
|
+
if (!this.config) {
|
|
121
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
user_id: this.config.user_id,
|
|
125
|
+
workspace_id: this.config.workspace_id,
|
|
126
|
+
public_key: this.config.public_key,
|
|
127
|
+
token: this.config.token,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Ensure WorkflowApiService is initialized
|
|
132
|
+
*/
|
|
133
|
+
ensureApiService() {
|
|
134
|
+
if (!this.workflowApiService) {
|
|
135
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
136
|
+
}
|
|
137
|
+
return this.workflowApiService;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get service configuration
|
|
141
|
+
*/
|
|
142
|
+
getConfig() {
|
|
143
|
+
return this.config;
|
|
144
|
+
}
|
|
145
|
+
// ==================== PRODUCT BUILDER MANAGEMENT ====================
|
|
146
|
+
/**
|
|
147
|
+
* Create a new ProductBuilder instance
|
|
148
|
+
*/
|
|
149
|
+
createNewProductBuilder() {
|
|
150
|
+
if (!this.config) {
|
|
151
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
152
|
+
}
|
|
153
|
+
return new products_service_1.default({
|
|
154
|
+
workspace_id: this.config.workspace_id,
|
|
155
|
+
public_key: this.config.public_key,
|
|
156
|
+
user_id: this.config.user_id,
|
|
157
|
+
token: this.config.token,
|
|
158
|
+
env_type: this.config.env_type,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get or create a ProductBuilder instance for the given product tag
|
|
163
|
+
*/
|
|
164
|
+
async getProductBuilder(productTag) {
|
|
165
|
+
let builder = this.productBuilders.get(productTag);
|
|
166
|
+
if (!builder) {
|
|
167
|
+
builder = this.createNewProductBuilder();
|
|
168
|
+
await builder.initializeProductByTag(productTag);
|
|
169
|
+
this.productBuilders.set(productTag, builder);
|
|
170
|
+
// Update productId for logging
|
|
171
|
+
this.productId = builder.fetchProductId() || '';
|
|
172
|
+
}
|
|
173
|
+
return builder;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Initialize logging service
|
|
177
|
+
*/
|
|
178
|
+
initializeLogService() {
|
|
179
|
+
if (!this.logService && this.config) {
|
|
180
|
+
this.logService = new logs_service_1.default({
|
|
181
|
+
product_id: this.productId,
|
|
182
|
+
workspace_id: this.config.workspace_id,
|
|
183
|
+
public_key: this.config.public_key,
|
|
184
|
+
user_id: this.config.user_id,
|
|
185
|
+
token: this.config.token,
|
|
186
|
+
env_type: this.config.env_type,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Create a new ProcessorService instance for job scheduling
|
|
192
|
+
*/
|
|
193
|
+
createNewProcessor() {
|
|
194
|
+
if (!this.config) {
|
|
195
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
196
|
+
}
|
|
197
|
+
return new processor_service_1.default({
|
|
198
|
+
workspace_id: this.config.workspace_id,
|
|
199
|
+
public_key: this.config.public_key,
|
|
200
|
+
user_id: this.config.user_id,
|
|
201
|
+
token: this.config.token,
|
|
202
|
+
env_type: this.config.env_type,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// ==================== WORKFLOW CRUD OPERATIONS ====================
|
|
206
|
+
/**
|
|
207
|
+
* Create a new workflow from JSON schema
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* await ductape.workflows.create('my-product', {
|
|
212
|
+
* tag: 'order-fulfillment',
|
|
213
|
+
* name: 'Order Fulfillment',
|
|
214
|
+
* steps: [
|
|
215
|
+
* { tag: 'validate', type: 'action', app: 'orders', event: 'validate', input: {} },
|
|
216
|
+
* { tag: 'process', type: 'database_action', database: 'orders-db', event: 'create', input: {} },
|
|
217
|
+
* ],
|
|
218
|
+
* envs: [{ slug: 'prd' }],
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
async create(productTag, workflowData) {
|
|
223
|
+
var _a;
|
|
224
|
+
// Validate required fields
|
|
225
|
+
if (!workflowData.name || !workflowData.tag || !((_a = workflowData.steps) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
226
|
+
throw WorkflowError.validationError('Workflow requires name, tag, and at least one step');
|
|
227
|
+
}
|
|
228
|
+
// Persist to backend using ProductBuilder
|
|
229
|
+
const builder = await this.getProductBuilder(productTag);
|
|
230
|
+
await builder.createWorkflow(workflowData);
|
|
231
|
+
// Store locally
|
|
232
|
+
const localConfig = {
|
|
233
|
+
name: workflowData.name,
|
|
234
|
+
tag: workflowData.tag,
|
|
235
|
+
description: workflowData.description,
|
|
236
|
+
input: workflowData.input,
|
|
237
|
+
output: workflowData.output,
|
|
238
|
+
steps: workflowData.steps,
|
|
239
|
+
signals: workflowData.signals,
|
|
240
|
+
queries: workflowData.queries,
|
|
241
|
+
options: workflowData.options,
|
|
242
|
+
envs: workflowData.envs,
|
|
243
|
+
};
|
|
244
|
+
this.localConfigs.set(workflowData.tag, localConfig);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Fetch all workflows for a product
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* const workflows = await ductape.workflows.fetchAll('my-product');
|
|
252
|
+
* workflows.forEach(wf => console.log(wf.name, wf.tag));
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
async fetchAll(productTag) {
|
|
256
|
+
// Return local configs if no product tag
|
|
257
|
+
if (!productTag) {
|
|
258
|
+
return Array.from(this.localConfigs.values());
|
|
259
|
+
}
|
|
260
|
+
// Fetch from API using ProductBuilder
|
|
261
|
+
try {
|
|
262
|
+
const builder = await this.getProductBuilder(productTag);
|
|
263
|
+
const workflows = await builder.fetchWorkflows();
|
|
264
|
+
// Convert IProductWorkflow[] to IWorkflowConfig[]
|
|
265
|
+
return workflows.map((wf) => this.productWorkflowToConfig(wf));
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
// Fall back to local configs if API fails
|
|
269
|
+
return Array.from(this.localConfigs.values());
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Fetch a specific workflow by tag
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* const workflow = await ductape.workflows.fetch('order-fulfillment', 'my-product');
|
|
278
|
+
* console.log(workflow?.name, workflow?.steps.length);
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
async fetch(workflowTag, productTag) {
|
|
282
|
+
// If productTag is provided, fetch from API
|
|
283
|
+
if (productTag) {
|
|
284
|
+
try {
|
|
285
|
+
const builder = await this.getProductBuilder(productTag);
|
|
286
|
+
const workflow = await builder.fetchWorkflow(workflowTag);
|
|
287
|
+
if (workflow) {
|
|
288
|
+
const config = this.productWorkflowToConfig(workflow);
|
|
289
|
+
// Update local cache
|
|
290
|
+
this.localConfigs.set(workflowTag, config);
|
|
291
|
+
return config;
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
// Fall back to local config
|
|
297
|
+
return this.localConfigs.get(workflowTag) || null;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return this.localConfigs.get(workflowTag) || null;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Update a workflow
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* await ductape.workflows.update('order-fulfillment', 'my-product', {
|
|
308
|
+
* description: 'Updated description',
|
|
309
|
+
* options: { timeout: 3600000 },
|
|
310
|
+
* });
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
async update(workflowTag, productTag, updates) {
|
|
314
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
315
|
+
// Update in backend
|
|
316
|
+
const builder = await this.getProductBuilder(productTag);
|
|
317
|
+
await builder.updateWorkflow(workflowTag, updates);
|
|
318
|
+
// Update local cache
|
|
319
|
+
const existing = this.localConfigs.get(workflowTag);
|
|
320
|
+
if (existing) {
|
|
321
|
+
const updated = Object.assign(Object.assign({}, existing), { name: updates.name || existing.name, description: (_a = updates.description) !== null && _a !== void 0 ? _a : existing.description, input: (_b = updates.input) !== null && _b !== void 0 ? _b : existing.input, output: (_c = updates.output) !== null && _c !== void 0 ? _c : existing.output, steps: updates.steps || existing.steps, signals: (_d = updates.signals) !== null && _d !== void 0 ? _d : existing.signals, queries: (_e = updates.queries) !== null && _e !== void 0 ? _e : existing.queries, options: (_f = updates.options) !== null && _f !== void 0 ? _f : existing.options, envs: (_g = updates.envs) !== null && _g !== void 0 ? _g : existing.envs });
|
|
322
|
+
this.localConfigs.set(workflowTag, updated);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Delete a workflow
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* await ductape.workflows.delete('order-fulfillment', 'my-product');
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
async delete(workflowTag, productTag) {
|
|
334
|
+
// Delete from backend
|
|
335
|
+
const builder = await this.getProductBuilder(productTag);
|
|
336
|
+
await builder.deleteWorkflow(workflowTag);
|
|
337
|
+
// Remove from local cache
|
|
338
|
+
this.localConfigs.delete(workflowTag);
|
|
339
|
+
}
|
|
340
|
+
// ==================== CODE-FIRST API ====================
|
|
341
|
+
/**
|
|
342
|
+
* Define a workflow using the code-first API
|
|
343
|
+
* Compiles the handler to JSON schema and creates the workflow in one step
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* const orderWorkflow = await ductape.workflows.define({
|
|
348
|
+
* product: 'my-product',
|
|
349
|
+
* tag: 'order-fulfillment',
|
|
350
|
+
* name: 'Order Fulfillment',
|
|
351
|
+
* handler: async (ctx) => {
|
|
352
|
+
* const validation = await ctx.step('validate', async () => {
|
|
353
|
+
* return ctx.action.run({
|
|
354
|
+
* app: 'inventory-service',
|
|
355
|
+
* event: 'validate-order',
|
|
356
|
+
* input: { body: ctx.input },
|
|
357
|
+
* });
|
|
358
|
+
* });
|
|
359
|
+
*
|
|
360
|
+
* if (!validation.valid) {
|
|
361
|
+
* return { success: false, error: validation.reason };
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* return { success: true };
|
|
365
|
+
* },
|
|
366
|
+
* });
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
async define(options) {
|
|
370
|
+
// Validate required fields
|
|
371
|
+
if (!options.tag || !options.name || !options.handler) {
|
|
372
|
+
throw WorkflowError.validationError('Workflow definition requires tag, name, and handler');
|
|
373
|
+
}
|
|
374
|
+
// Create a workflow compiler instance
|
|
375
|
+
const compiler = new WorkflowCompiler(options);
|
|
376
|
+
// Compile the handler to JSON schema
|
|
377
|
+
const schema = compiler.compile();
|
|
378
|
+
// If product is specified, create the workflow
|
|
379
|
+
if (options.product) {
|
|
380
|
+
await this.create(options.product, schema);
|
|
381
|
+
}
|
|
382
|
+
// Store locally
|
|
383
|
+
const localConfig = {
|
|
384
|
+
name: schema.name,
|
|
385
|
+
tag: schema.tag,
|
|
386
|
+
description: schema.description,
|
|
387
|
+
input: schema.input,
|
|
388
|
+
output: schema.output,
|
|
389
|
+
steps: schema.steps,
|
|
390
|
+
signals: schema.signals,
|
|
391
|
+
queries: schema.queries,
|
|
392
|
+
options: schema.options,
|
|
393
|
+
envs: schema.envs,
|
|
394
|
+
};
|
|
395
|
+
this.localConfigs.set(schema.tag, localConfig);
|
|
396
|
+
// Return the defined workflow with compile method
|
|
397
|
+
return {
|
|
398
|
+
tag: options.tag,
|
|
399
|
+
name: options.name,
|
|
400
|
+
handler: options.handler,
|
|
401
|
+
compile: () => schema,
|
|
402
|
+
schema,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
// ==================== WORKFLOW EXECUTION ====================
|
|
406
|
+
/**
|
|
407
|
+
* Execute a workflow
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* const result = await ductape.workflows.execute({
|
|
412
|
+
* product: 'my-product',
|
|
413
|
+
* env: 'production',
|
|
414
|
+
* tag: 'order-fulfillment',
|
|
415
|
+
* input: {
|
|
416
|
+
* order_id: 'ORD-12345',
|
|
417
|
+
* items: [{ product_id: 'PROD-1', quantity: 2 }],
|
|
418
|
+
* },
|
|
419
|
+
* });
|
|
420
|
+
*
|
|
421
|
+
* console.log(result.status); // 'completed' | 'failed' | 'rolled_back'
|
|
422
|
+
* console.log(result.output);
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
async execute(options) {
|
|
426
|
+
var _a, _b, _c, _d, _e;
|
|
427
|
+
if (!this.config) {
|
|
428
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
429
|
+
}
|
|
430
|
+
const process_id = (0, processor_utils_1.generateObjectId)();
|
|
431
|
+
// Session log fields (will be populated if session is provided)
|
|
432
|
+
let sessionLogFields = {};
|
|
433
|
+
let resolvedOptions = options;
|
|
434
|
+
// Fetch the workflow configuration from backend
|
|
435
|
+
const builder = await this.getProductBuilder(options.product);
|
|
436
|
+
const workflow = await builder.fetchWorkflow(options.tag);
|
|
437
|
+
if (!workflow) {
|
|
438
|
+
throw WorkflowError.notFoundError(`Workflow ${options.tag} not found`);
|
|
439
|
+
}
|
|
440
|
+
// Process session if provided - verify and resolve $Session{} references
|
|
441
|
+
if (options.session) {
|
|
442
|
+
const privateKey = builder.fetchPrivateKey();
|
|
443
|
+
if (privateKey) {
|
|
444
|
+
const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
|
|
445
|
+
const sessionResult = await processSessionForExecution(options.session, privateKey, options, options.env);
|
|
446
|
+
if (sessionResult.error) {
|
|
447
|
+
throw WorkflowError.executionError(`Session validation failed: ${sessionResult.error}`);
|
|
448
|
+
}
|
|
449
|
+
resolvedOptions = sessionResult.input;
|
|
450
|
+
sessionLogFields = sessionResult.logFields;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// Initialize logging
|
|
454
|
+
this.initializeLogService();
|
|
455
|
+
const baseLogs = Object.assign({ product_tag: options.product, workspace_id: this.config.workspace_id, env: options.env, process_id, type: logs_types_1.LogEventTypes.WORKFLOW, parent_tag: options.tag, data: { workflow: options.tag, operation: 'execute' } }, sessionLogFields);
|
|
456
|
+
(_a = this.logService) === null || _a === void 0 ? void 0 : _a.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow execute - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
|
|
457
|
+
try {
|
|
458
|
+
// Create and run the workflow executor with resolved options and session context
|
|
459
|
+
const executor = new workflow_executor_1.WorkflowExecutor(this.config, workflow, resolvedOptions, sessionLogFields);
|
|
460
|
+
const result = await executor.execute();
|
|
461
|
+
(_b = this.logService) === null || _b === void 0 ? void 0 : _b.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow execute - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
|
|
462
|
+
(_c = this.logService) === null || _c === void 0 ? void 0 : _c.publish();
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
catch (error) {
|
|
466
|
+
(_d = this.logService) === null || _d === void 0 ? void 0 : _d.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow execute - failed', failed_execution: true, data: { workflow: options.tag, operation: 'execute', error: error.message || String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
|
|
467
|
+
await ((_e = this.logService) === null || _e === void 0 ? void 0 : _e.publish());
|
|
468
|
+
throw error;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
// ==================== WORKFLOW DISPATCH ====================
|
|
472
|
+
/**
|
|
473
|
+
* Dispatch a workflow to run as a scheduled job
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* // Schedule a workflow to run in 1 hour
|
|
478
|
+
* const result = await ductape.workflows.dispatch({
|
|
479
|
+
* product: 'my-product',
|
|
480
|
+
* env: 'production',
|
|
481
|
+
* workflow: 'order-fulfillment',
|
|
482
|
+
* input: { order_id: 'ORD-123' },
|
|
483
|
+
* schedule: { start_at: Date.now() + 3600000 },
|
|
484
|
+
* });
|
|
485
|
+
*
|
|
486
|
+
* // Run on a cron schedule
|
|
487
|
+
* const result = await ductape.workflows.dispatch({
|
|
488
|
+
* product: 'my-product',
|
|
489
|
+
* env: 'production',
|
|
490
|
+
* workflow: 'daily-report',
|
|
491
|
+
* input: {},
|
|
492
|
+
* schedule: { cron: '0 0 * * *' }, // Daily at midnight
|
|
493
|
+
* });
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
async dispatch(data) {
|
|
497
|
+
var _a, _b, _c, _d, _e, _f;
|
|
498
|
+
const process_id = (0, processor_utils_1.generateObjectId)();
|
|
499
|
+
const processorService = this.createNewProcessor();
|
|
500
|
+
const productBuilder = await this.getProductBuilder(data.product);
|
|
501
|
+
const schedule = data.schedule || {};
|
|
502
|
+
const startAt = typeof schedule.start_at === 'string'
|
|
503
|
+
? new Date(schedule.start_at).getTime()
|
|
504
|
+
: schedule.start_at || Date.now();
|
|
505
|
+
// Generate job tag based on workflow
|
|
506
|
+
const jobTag = `workflow:${data.workflow}`;
|
|
507
|
+
// Initialize logging
|
|
508
|
+
this.initializeLogService();
|
|
509
|
+
const baseLogs = {
|
|
510
|
+
product_tag: data.product,
|
|
511
|
+
workspace_id: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) || '',
|
|
512
|
+
env: data.env,
|
|
513
|
+
process_id,
|
|
514
|
+
type: logs_types_1.LogEventTypes.WORKFLOW,
|
|
515
|
+
parent_tag: data.workflow,
|
|
516
|
+
data: { workflow: data.workflow, operation: 'dispatch' },
|
|
517
|
+
};
|
|
518
|
+
(_b = this.logService) === null || _b === void 0 ? void 0 : _b.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow dispatch - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
|
|
519
|
+
try {
|
|
520
|
+
// Check if job exists, if not create it
|
|
521
|
+
const existingJob = await productBuilder.fetchJob(jobTag);
|
|
522
|
+
if (!existingJob) {
|
|
523
|
+
await productBuilder.createJob({
|
|
524
|
+
tag: jobTag,
|
|
525
|
+
name: `Workflow: ${data.workflow}`,
|
|
526
|
+
description: `Auto-created job for workflow ${data.workflow}`,
|
|
527
|
+
type: productsBuilder_types_1.JobEventTypes.WORKFLOW, // Use workflow job type
|
|
528
|
+
app: data.workflow,
|
|
529
|
+
event: 'execute',
|
|
530
|
+
executions: 0,
|
|
531
|
+
intervals: schedule.every || 0,
|
|
532
|
+
start_at: startAt,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
const jobInput = {
|
|
536
|
+
product: data.product,
|
|
537
|
+
env: data.env,
|
|
538
|
+
event: jobTag,
|
|
539
|
+
input: data.input,
|
|
540
|
+
retries: data.retries || 0,
|
|
541
|
+
start_at: startAt,
|
|
542
|
+
session: data.session,
|
|
543
|
+
cache: data.cache,
|
|
544
|
+
repeat: schedule.cron || schedule.every
|
|
545
|
+
? {
|
|
546
|
+
cron: schedule.cron,
|
|
547
|
+
every: schedule.every,
|
|
548
|
+
limit: schedule.limit,
|
|
549
|
+
endDate: schedule.endDate,
|
|
550
|
+
tz: schedule.tz,
|
|
551
|
+
}
|
|
552
|
+
: undefined,
|
|
553
|
+
};
|
|
554
|
+
await processorService.processJob(jobInput);
|
|
555
|
+
const isRecurring = !!(schedule.cron || schedule.every);
|
|
556
|
+
let nextRunAt;
|
|
557
|
+
if (isRecurring && schedule.every) {
|
|
558
|
+
nextRunAt = startAt + schedule.every;
|
|
559
|
+
}
|
|
560
|
+
const job_id = (0, crypto_1.randomUUID)();
|
|
561
|
+
(_c = this.logService) === null || _c === void 0 ? void 0 : _c.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow dispatch - success', successful_execution: true, data: { workflow: data.workflow, operation: 'dispatch', job_id }, status: logs_types_1.LogEventStatus.SUCCESS }));
|
|
562
|
+
(_d = this.logService) === null || _d === void 0 ? void 0 : _d.publish();
|
|
563
|
+
return {
|
|
564
|
+
job_id,
|
|
565
|
+
status: startAt > Date.now() ? 'scheduled' : 'queued',
|
|
566
|
+
scheduled_at: startAt,
|
|
567
|
+
recurring: isRecurring,
|
|
568
|
+
next_run_at: nextRunAt,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
catch (error) {
|
|
572
|
+
(_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow dispatch - failed', failed_execution: true, data: { workflow: data.workflow, operation: 'dispatch', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
|
|
573
|
+
await ((_f = this.logService) === null || _f === void 0 ? void 0 : _f.publish());
|
|
574
|
+
throw error;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
// ==================== SIGNAL & QUERY ====================
|
|
578
|
+
/**
|
|
579
|
+
* Send a signal to a running workflow
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```ts
|
|
583
|
+
* await ductape.workflows.signal({
|
|
584
|
+
* product: 'my-product',
|
|
585
|
+
* env: 'production',
|
|
586
|
+
* workflow_id: 'wf-123',
|
|
587
|
+
* signal: 'approve',
|
|
588
|
+
* payload: { approver_id: 'user-456', comments: 'Approved' },
|
|
589
|
+
* });
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
async signal(options) {
|
|
593
|
+
var _a, _b, _c, _d, _e, _f;
|
|
594
|
+
const process_id = (0, processor_utils_1.generateObjectId)();
|
|
595
|
+
// Initialize logging
|
|
596
|
+
if (options.product) {
|
|
597
|
+
await this.getProductBuilder(options.product);
|
|
598
|
+
}
|
|
599
|
+
this.initializeLogService();
|
|
600
|
+
const baseLogs = {
|
|
601
|
+
product_tag: options.product,
|
|
602
|
+
workspace_id: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) || '',
|
|
603
|
+
env: options.env,
|
|
604
|
+
process_id,
|
|
605
|
+
type: logs_types_1.LogEventTypes.WORKFLOW,
|
|
606
|
+
parent_tag: options.workflow_id,
|
|
607
|
+
child_tag: options.signal,
|
|
608
|
+
data: { workflow_id: options.workflow_id, signal: options.signal, operation: 'signal' },
|
|
609
|
+
};
|
|
610
|
+
(_b = this.logService) === null || _b === void 0 ? void 0 : _b.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow signal - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
|
|
611
|
+
try {
|
|
612
|
+
const apiService = this.ensureApiService();
|
|
613
|
+
const auth = this.getAuthPayload();
|
|
614
|
+
await apiService.sendSignal(options.workflow_id, {
|
|
615
|
+
product: options.product,
|
|
616
|
+
env: options.env,
|
|
617
|
+
signal: options.signal,
|
|
618
|
+
payload: options.payload,
|
|
619
|
+
}, auth);
|
|
620
|
+
(_c = this.logService) === null || _c === void 0 ? void 0 : _c.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow signal - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
|
|
621
|
+
(_d = this.logService) === null || _d === void 0 ? void 0 : _d.publish();
|
|
622
|
+
}
|
|
623
|
+
catch (error) {
|
|
624
|
+
(_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow signal - failed', failed_execution: true, data: { workflow_id: options.workflow_id, signal: options.signal, operation: 'signal', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
|
|
625
|
+
await ((_f = this.logService) === null || _f === void 0 ? void 0 : _f.publish());
|
|
626
|
+
throw error;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Query a running workflow
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```ts
|
|
634
|
+
* const status = await ductape.workflows.query({
|
|
635
|
+
* product: 'my-product',
|
|
636
|
+
* env: 'production',
|
|
637
|
+
* workflow_id: 'wf-123',
|
|
638
|
+
* query: 'getStatus',
|
|
639
|
+
* });
|
|
640
|
+
*
|
|
641
|
+
* console.log(status.current_step, status.progress);
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
async query(options) {
|
|
645
|
+
// Query is handled by getting workflow status and extracting query result
|
|
646
|
+
const status = await this.status({
|
|
647
|
+
product: options.product,
|
|
648
|
+
env: options.env,
|
|
649
|
+
workflow_id: options.workflow_id,
|
|
650
|
+
});
|
|
651
|
+
if (!status) {
|
|
652
|
+
throw WorkflowError.notFoundError(`Workflow ${options.workflow_id} not found`);
|
|
653
|
+
}
|
|
654
|
+
// Return the state which contains query results
|
|
655
|
+
return (status.state[options.query] || status);
|
|
656
|
+
}
|
|
657
|
+
// ==================== REPLAY, RESTART & RESUME ====================
|
|
658
|
+
/**
|
|
659
|
+
* Replay a workflow with the same input
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```ts
|
|
663
|
+
* const result = await ductape.workflows.replay({
|
|
664
|
+
* product: 'my-product',
|
|
665
|
+
* env: 'production',
|
|
666
|
+
* workflow_id: 'wf-123',
|
|
667
|
+
* reason: 'Debugging payment failure',
|
|
668
|
+
* });
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
671
|
+
async replay(options) {
|
|
672
|
+
var _a, _b, _c, _d, _e, _f;
|
|
673
|
+
const process_id = (0, processor_utils_1.generateObjectId)();
|
|
674
|
+
if (!this.config) {
|
|
675
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
676
|
+
}
|
|
677
|
+
// Initialize logging
|
|
678
|
+
await this.getProductBuilder(options.product);
|
|
679
|
+
this.initializeLogService();
|
|
680
|
+
const baseLogs = {
|
|
681
|
+
product_tag: options.product,
|
|
682
|
+
workspace_id: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) || '',
|
|
683
|
+
env: options.env,
|
|
684
|
+
process_id,
|
|
685
|
+
type: logs_types_1.LogEventTypes.WORKFLOW,
|
|
686
|
+
parent_tag: options.workflow_id,
|
|
687
|
+
data: { workflow_id: options.workflow_id, operation: 'replay' },
|
|
688
|
+
};
|
|
689
|
+
(_b = this.logService) === null || _b === void 0 ? void 0 : _b.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow replay - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
|
|
690
|
+
try {
|
|
691
|
+
// Get original workflow execution state from backend
|
|
692
|
+
const originalStatus = await this.status({
|
|
693
|
+
product: options.product,
|
|
694
|
+
env: options.env,
|
|
695
|
+
workflow_id: options.workflow_id,
|
|
696
|
+
});
|
|
697
|
+
if (!originalStatus) {
|
|
698
|
+
throw WorkflowError.notFoundError(`Workflow ${options.workflow_id} not found`);
|
|
699
|
+
}
|
|
700
|
+
// Execute with the same input
|
|
701
|
+
const result = await this.execute({
|
|
702
|
+
product: options.product,
|
|
703
|
+
env: options.env,
|
|
704
|
+
tag: originalStatus.workflow_tag,
|
|
705
|
+
input: originalStatus.input || {},
|
|
706
|
+
idempotency_key: options.idempotency_key,
|
|
707
|
+
});
|
|
708
|
+
(_c = this.logService) === null || _c === void 0 ? void 0 : _c.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow replay - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
|
|
709
|
+
(_d = this.logService) === null || _d === void 0 ? void 0 : _d.publish();
|
|
710
|
+
return Object.assign(Object.assign({}, result), { replayed_from: options.workflow_id });
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
(_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { message: 'Workflow replay - failed', failed_execution: true, data: { workflow_id: options.workflow_id, operation: 'replay', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
|
|
714
|
+
await ((_f = this.logService) === null || _f === void 0 ? void 0 : _f.publish());
|
|
715
|
+
throw error;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Restart a workflow with new or modified input
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```ts
|
|
723
|
+
* const result = await ductape.workflows.restart({
|
|
724
|
+
* product: 'my-product',
|
|
725
|
+
* env: 'production',
|
|
726
|
+
* workflow_id: 'wf-123',
|
|
727
|
+
* input: { email: 'corrected@email.com' },
|
|
728
|
+
* reason: 'Customer email was incorrect',
|
|
729
|
+
* });
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
async restart(options) {
|
|
733
|
+
if (!this.config) {
|
|
734
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
735
|
+
}
|
|
736
|
+
// Get original workflow execution state from backend
|
|
737
|
+
const originalStatus = await this.status({
|
|
738
|
+
product: options.product,
|
|
739
|
+
env: options.env,
|
|
740
|
+
workflow_id: options.workflow_id,
|
|
741
|
+
});
|
|
742
|
+
if (!originalStatus) {
|
|
743
|
+
throw WorkflowError.notFoundError(`Workflow ${options.workflow_id} not found`);
|
|
744
|
+
}
|
|
745
|
+
// Determine the new input
|
|
746
|
+
let newInput;
|
|
747
|
+
if (options.input) {
|
|
748
|
+
newInput = options.input;
|
|
749
|
+
}
|
|
750
|
+
else if (options.input_override && options.merge_input) {
|
|
751
|
+
newInput = Object.assign(Object.assign({}, (originalStatus.input || {})), options.input_override);
|
|
752
|
+
}
|
|
753
|
+
else if (options.input_override) {
|
|
754
|
+
newInput = options.input_override;
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
newInput = originalStatus.input || {};
|
|
758
|
+
}
|
|
759
|
+
// Execute with the new input
|
|
760
|
+
const result = await this.execute({
|
|
761
|
+
product: options.product,
|
|
762
|
+
env: options.env,
|
|
763
|
+
tag: originalStatus.workflow_tag,
|
|
764
|
+
input: newInput,
|
|
765
|
+
});
|
|
766
|
+
return Object.assign(Object.assign({}, result), { restarted_from: options.workflow_id });
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Resume a paused or failed workflow from where it stopped
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* ```ts
|
|
773
|
+
* const result = await ductape.workflows.resume({
|
|
774
|
+
* product: 'my-product',
|
|
775
|
+
* env: 'production',
|
|
776
|
+
* workflow_id: 'wf-123',
|
|
777
|
+
* from_checkpoint: 'payment-complete',
|
|
778
|
+
* });
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
async resume(options) {
|
|
782
|
+
if (!this.config) {
|
|
783
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
784
|
+
}
|
|
785
|
+
// Get original workflow execution state from backend
|
|
786
|
+
const originalStatus = await this.status({
|
|
787
|
+
product: options.product,
|
|
788
|
+
env: options.env,
|
|
789
|
+
workflow_id: options.workflow_id,
|
|
790
|
+
});
|
|
791
|
+
if (!originalStatus) {
|
|
792
|
+
throw WorkflowError.notFoundError(`Workflow ${options.workflow_id} not found`);
|
|
793
|
+
}
|
|
794
|
+
// Fetch the workflow configuration
|
|
795
|
+
const builder = await this.getProductBuilder(options.product);
|
|
796
|
+
const workflow = await builder.fetchWorkflow(originalStatus.workflow_tag);
|
|
797
|
+
if (!workflow) {
|
|
798
|
+
throw WorkflowError.notFoundError(`Workflow ${originalStatus.workflow_tag} not found`);
|
|
799
|
+
}
|
|
800
|
+
// Create executor with resume options
|
|
801
|
+
const executor = new workflow_executor_1.WorkflowExecutor(this.config, workflow, {
|
|
802
|
+
product: options.product,
|
|
803
|
+
env: options.env,
|
|
804
|
+
tag: originalStatus.workflow_tag,
|
|
805
|
+
input: Object.assign(Object.assign({}, (originalStatus.input || {})), (options.input || {})),
|
|
806
|
+
});
|
|
807
|
+
// Resume execution (executor handles skipping completed steps)
|
|
808
|
+
const result = await executor.resume({
|
|
809
|
+
completed_steps: originalStatus.completed_steps,
|
|
810
|
+
state: originalStatus.state,
|
|
811
|
+
from_checkpoint: options.from_checkpoint,
|
|
812
|
+
from_step: options.from_step,
|
|
813
|
+
skip_steps: options.skip_steps,
|
|
814
|
+
});
|
|
815
|
+
return Object.assign(Object.assign({}, result), { resumed_from: options.workflow_id, resumed_checkpoint: options.from_checkpoint });
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Replay a workflow starting from a specific step
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```ts
|
|
822
|
+
* const result = await ductape.workflows.replayFromStep({
|
|
823
|
+
* product: 'my-product',
|
|
824
|
+
* env: 'production',
|
|
825
|
+
* workflow_id: 'wf-123',
|
|
826
|
+
* from_step: 'process-payment',
|
|
827
|
+
* });
|
|
828
|
+
* ```
|
|
829
|
+
*/
|
|
830
|
+
async replayFromStep(options) {
|
|
831
|
+
if (!this.config) {
|
|
832
|
+
throw WorkflowError.configurationError('WorkflowService not configured. Please provide config when initializing.');
|
|
833
|
+
}
|
|
834
|
+
// Get original workflow execution state
|
|
835
|
+
const originalStatus = await this.status({
|
|
836
|
+
product: options.product,
|
|
837
|
+
env: options.env,
|
|
838
|
+
workflow_id: options.workflow_id,
|
|
839
|
+
});
|
|
840
|
+
if (!originalStatus) {
|
|
841
|
+
throw WorkflowError.notFoundError(`Workflow ${options.workflow_id} not found`);
|
|
842
|
+
}
|
|
843
|
+
// Fetch the workflow configuration
|
|
844
|
+
const builder = await this.getProductBuilder(options.product);
|
|
845
|
+
const workflow = await builder.fetchWorkflow(originalStatus.workflow_tag);
|
|
846
|
+
if (!workflow) {
|
|
847
|
+
throw WorkflowError.notFoundError(`Workflow ${originalStatus.workflow_tag} not found`);
|
|
848
|
+
}
|
|
849
|
+
// Find steps before from_step to mark as completed
|
|
850
|
+
const stepIndex = workflow.steps.findIndex((s) => s.tag === options.from_step);
|
|
851
|
+
if (stepIndex === -1) {
|
|
852
|
+
throw WorkflowError.validationError(`Step ${options.from_step} not found in workflow`);
|
|
853
|
+
}
|
|
854
|
+
const completedSteps = workflow.steps.slice(0, stepIndex).map((s) => s.tag);
|
|
855
|
+
// Create executor with partial state
|
|
856
|
+
const executor = new workflow_executor_1.WorkflowExecutor(this.config, workflow, {
|
|
857
|
+
product: options.product,
|
|
858
|
+
env: options.env,
|
|
859
|
+
tag: originalStatus.workflow_tag,
|
|
860
|
+
input: originalStatus.input || {},
|
|
861
|
+
});
|
|
862
|
+
// Resume from the specified step with overridden outputs
|
|
863
|
+
const result = await executor.resume({
|
|
864
|
+
completed_steps: completedSteps,
|
|
865
|
+
state: originalStatus.state,
|
|
866
|
+
step_outputs: options.step_outputs,
|
|
867
|
+
});
|
|
868
|
+
return Object.assign(Object.assign({}, result), { replayed_from: options.workflow_id });
|
|
869
|
+
}
|
|
870
|
+
// ==================== STATUS & MANAGEMENT ====================
|
|
871
|
+
/**
|
|
872
|
+
* Get the status of a workflow execution
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```ts
|
|
876
|
+
* const status = await ductape.workflows.status({
|
|
877
|
+
* product: 'my-product',
|
|
878
|
+
* env: 'production',
|
|
879
|
+
* workflow_id: 'wf-123',
|
|
880
|
+
* });
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
async status(options) {
|
|
884
|
+
const apiService = this.ensureApiService();
|
|
885
|
+
const auth = this.getAuthPayload();
|
|
886
|
+
const response = await apiService.getStatus(options.workflow_id, options.product, options.env, auth);
|
|
887
|
+
if (!response) {
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
return {
|
|
891
|
+
workflow_id: response.workflow_id,
|
|
892
|
+
workflow_tag: response.workflow_tag,
|
|
893
|
+
status: response.status,
|
|
894
|
+
current_step: response.current_step,
|
|
895
|
+
completed_steps: response.completed_steps,
|
|
896
|
+
state: response.state,
|
|
897
|
+
started_at: response.started_at,
|
|
898
|
+
updated_at: response.updated_at,
|
|
899
|
+
input: response.input,
|
|
900
|
+
output: response.output,
|
|
901
|
+
error: response.error,
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Cancel a running workflow
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```ts
|
|
909
|
+
* const result = await ductape.workflows.cancel({
|
|
910
|
+
* product: 'my-product',
|
|
911
|
+
* env: 'production',
|
|
912
|
+
* workflow_id: 'wf-123',
|
|
913
|
+
* reason: 'User requested cancellation',
|
|
914
|
+
* });
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
async cancel(options) {
|
|
918
|
+
const apiService = this.ensureApiService();
|
|
919
|
+
const auth = this.getAuthPayload();
|
|
920
|
+
const response = await apiService.cancel(options.workflow_id, options.product, options.env, options.reason || 'Cancelled by user', auth);
|
|
921
|
+
return {
|
|
922
|
+
cancelled: response.cancelled,
|
|
923
|
+
rolled_back_steps: response.rolled_back_steps,
|
|
924
|
+
failed_rollbacks: response.failed_rollbacks,
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Get the execution history of a workflow
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* ```ts
|
|
932
|
+
* const history = await ductape.workflows.history({
|
|
933
|
+
* product: 'my-product',
|
|
934
|
+
* env: 'production',
|
|
935
|
+
* workflow_id: 'wf-123',
|
|
936
|
+
* });
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
async history(options) {
|
|
940
|
+
const apiService = this.ensureApiService();
|
|
941
|
+
const auth = this.getAuthPayload();
|
|
942
|
+
const response = await apiService.getHistory(options.workflow_id, options.product, options.env, auth);
|
|
943
|
+
return {
|
|
944
|
+
workflow_id: response.workflow_id,
|
|
945
|
+
workflow_tag: response.workflow_tag,
|
|
946
|
+
status: response.status,
|
|
947
|
+
events: response.events.map(e => ({
|
|
948
|
+
type: e.type,
|
|
949
|
+
timestamp: e.timestamp,
|
|
950
|
+
data: e.data,
|
|
951
|
+
})),
|
|
952
|
+
checkpoints: response.checkpoints,
|
|
953
|
+
replays: response.replays,
|
|
954
|
+
restarts: response.restarts,
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Get detailed information about a specific step
|
|
959
|
+
*
|
|
960
|
+
* @example
|
|
961
|
+
* ```ts
|
|
962
|
+
* const detail = await ductape.workflows.stepDetail({
|
|
963
|
+
* product: 'my-product',
|
|
964
|
+
* env: 'production',
|
|
965
|
+
* workflow_id: 'wf-123',
|
|
966
|
+
* step_tag: 'process-payment',
|
|
967
|
+
* });
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
async stepDetail(options) {
|
|
971
|
+
const apiService = this.ensureApiService();
|
|
972
|
+
const auth = this.getAuthPayload();
|
|
973
|
+
const response = await apiService.getStepDetail(options.workflow_id, options.step_tag, options.product, options.env, auth);
|
|
974
|
+
if (!response) {
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
return {
|
|
978
|
+
tag: response.tag,
|
|
979
|
+
name: response.name,
|
|
980
|
+
status: response.status,
|
|
981
|
+
input: response.input,
|
|
982
|
+
output: response.output,
|
|
983
|
+
error: response.error,
|
|
984
|
+
attempts: response.attempts,
|
|
985
|
+
start_time: response.start_time,
|
|
986
|
+
end_time: response.end_time,
|
|
987
|
+
duration: response.duration,
|
|
988
|
+
rollback_status: response.rollback_status,
|
|
989
|
+
rollback_error: response.rollback_error,
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* List all related executions (replays, restarts, resumes)
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* ```ts
|
|
997
|
+
* const related = await ductape.workflows.relatedExecutions({
|
|
998
|
+
* product: 'my-product',
|
|
999
|
+
* env: 'production',
|
|
1000
|
+
* workflow_id: 'wf-123',
|
|
1001
|
+
* });
|
|
1002
|
+
* ```
|
|
1003
|
+
*/
|
|
1004
|
+
async relatedExecutions(options) {
|
|
1005
|
+
const apiService = this.ensureApiService();
|
|
1006
|
+
const auth = this.getAuthPayload();
|
|
1007
|
+
const response = await apiService.getRelatedExecutions(options.workflow_id, options.product, options.env, auth);
|
|
1008
|
+
return {
|
|
1009
|
+
original: response.original,
|
|
1010
|
+
executions: response.executions.map(e => ({
|
|
1011
|
+
workflow_id: e.workflow_id,
|
|
1012
|
+
type: e.type,
|
|
1013
|
+
status: e.status,
|
|
1014
|
+
created_at: e.created_at,
|
|
1015
|
+
replayed_from: e.replayed_from,
|
|
1016
|
+
restarted_from: e.restarted_from,
|
|
1017
|
+
resumed_from: e.resumed_from,
|
|
1018
|
+
})),
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Compare two workflow executions
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```ts
|
|
1026
|
+
* const comparison = await ductape.workflows.compare({
|
|
1027
|
+
* product: 'my-product',
|
|
1028
|
+
* env: 'production',
|
|
1029
|
+
* workflow_ids: ['wf-123', 'wf-456'],
|
|
1030
|
+
* });
|
|
1031
|
+
* ```
|
|
1032
|
+
*/
|
|
1033
|
+
async compare(options) {
|
|
1034
|
+
const apiService = this.ensureApiService();
|
|
1035
|
+
const auth = this.getAuthPayload();
|
|
1036
|
+
const response = await apiService.compareExecutions(options.workflow_ids, options.product, options.env, auth);
|
|
1037
|
+
return {
|
|
1038
|
+
workflows: response.workflows,
|
|
1039
|
+
input_diff: response.input_diff,
|
|
1040
|
+
step_diffs: response.step_diffs,
|
|
1041
|
+
outcome_diff: response.outcome_diff,
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
// ==================== HELPER METHODS ====================
|
|
1045
|
+
/**
|
|
1046
|
+
* Convert IProductWorkflow to IWorkflowConfig
|
|
1047
|
+
*/
|
|
1048
|
+
productWorkflowToConfig(workflow) {
|
|
1049
|
+
return {
|
|
1050
|
+
name: workflow.name,
|
|
1051
|
+
tag: workflow.tag,
|
|
1052
|
+
description: workflow.description,
|
|
1053
|
+
input: workflow.input,
|
|
1054
|
+
output: workflow.output,
|
|
1055
|
+
steps: workflow.steps,
|
|
1056
|
+
signals: workflow.signals,
|
|
1057
|
+
queries: workflow.queries,
|
|
1058
|
+
options: workflow.options,
|
|
1059
|
+
envs: workflow.envs,
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
exports.WorkflowService = WorkflowService;
|
|
1064
|
+
// ==================== WORKFLOW COMPILER ====================
|
|
1065
|
+
/**
|
|
1066
|
+
* Recording context that captures step definitions during handler execution
|
|
1067
|
+
*/
|
|
1068
|
+
class RecordingContext {
|
|
1069
|
+
constructor(_input, _workflowTag) {
|
|
1070
|
+
this._input = _input;
|
|
1071
|
+
this._workflowTag = _workflowTag;
|
|
1072
|
+
this._steps = [];
|
|
1073
|
+
this._stepOrder = 0;
|
|
1074
|
+
this._currentStepTag = null;
|
|
1075
|
+
this._pendingRollback = null;
|
|
1076
|
+
}
|
|
1077
|
+
// Readonly workflow metadata
|
|
1078
|
+
get input() { return this._input; }
|
|
1079
|
+
get workflow_id() { return `compile-${this._workflowTag}`; }
|
|
1080
|
+
get workflow_tag() { return this._workflowTag; }
|
|
1081
|
+
get env() { return 'compile'; }
|
|
1082
|
+
get product() { return 'compile'; }
|
|
1083
|
+
get context() { return {}; }
|
|
1084
|
+
get state() { return {}; }
|
|
1085
|
+
get steps() { return {}; }
|
|
1086
|
+
get completed_steps() { return []; }
|
|
1087
|
+
get current_step() { return this._currentStepTag; }
|
|
1088
|
+
/**
|
|
1089
|
+
* Record a step definition
|
|
1090
|
+
*/
|
|
1091
|
+
async step(tag, handler, rollback, options) {
|
|
1092
|
+
this._currentStepTag = tag;
|
|
1093
|
+
this._stepOrder++;
|
|
1094
|
+
// Create step placeholder - will be updated by component calls
|
|
1095
|
+
const step = {
|
|
1096
|
+
tag,
|
|
1097
|
+
type: productsBuilder_types_1.WorkflowStepType.ACTION,
|
|
1098
|
+
event: '',
|
|
1099
|
+
input: {},
|
|
1100
|
+
options,
|
|
1101
|
+
};
|
|
1102
|
+
// Execute handler to capture component calls
|
|
1103
|
+
try {
|
|
1104
|
+
await handler();
|
|
1105
|
+
}
|
|
1106
|
+
catch (e) {
|
|
1107
|
+
// Ignore errors during compilation - we're just tracing
|
|
1108
|
+
}
|
|
1109
|
+
// If rollback was provided, try to capture it
|
|
1110
|
+
if (rollback && this._pendingRollback) {
|
|
1111
|
+
step.rollback = this._pendingRollback;
|
|
1112
|
+
this._pendingRollback = null;
|
|
1113
|
+
}
|
|
1114
|
+
// Only add if step type was set by a component call
|
|
1115
|
+
if (step.event) {
|
|
1116
|
+
this._steps.push(step);
|
|
1117
|
+
}
|
|
1118
|
+
this._currentStepTag = null;
|
|
1119
|
+
// Return mock result
|
|
1120
|
+
return {};
|
|
1121
|
+
}
|
|
1122
|
+
// ==================== COMPONENT CONTEXTS ====================
|
|
1123
|
+
get action() {
|
|
1124
|
+
return {
|
|
1125
|
+
run: async (options) => {
|
|
1126
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.ACTION, options.action, {
|
|
1127
|
+
app: options.app,
|
|
1128
|
+
input: options.input,
|
|
1129
|
+
options: { retries: options.retries, timeout: options.timeout },
|
|
1130
|
+
});
|
|
1131
|
+
return {};
|
|
1132
|
+
return {};
|
|
1133
|
+
},
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
get database() {
|
|
1137
|
+
return {
|
|
1138
|
+
execute: async (options) => {
|
|
1139
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.DATABASE_ACTION, options.event, {
|
|
1140
|
+
database: options.database,
|
|
1141
|
+
input: options.input,
|
|
1142
|
+
options: { retries: options.retries, timeout: options.timeout },
|
|
1143
|
+
});
|
|
1144
|
+
return {};
|
|
1145
|
+
},
|
|
1146
|
+
query: async (options) => {
|
|
1147
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.DATABASE_ACTION, options.event, {
|
|
1148
|
+
database: options.database,
|
|
1149
|
+
input: options.params || {},
|
|
1150
|
+
});
|
|
1151
|
+
return [];
|
|
1152
|
+
},
|
|
1153
|
+
insert: async (options) => {
|
|
1154
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.DATABASE_ACTION, options.event, {
|
|
1155
|
+
database: options.database,
|
|
1156
|
+
input: { data: options.data },
|
|
1157
|
+
});
|
|
1158
|
+
return {};
|
|
1159
|
+
},
|
|
1160
|
+
update: async (options) => {
|
|
1161
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.DATABASE_ACTION, options.event, {
|
|
1162
|
+
database: options.database,
|
|
1163
|
+
input: { data: options.data, where: options.where },
|
|
1164
|
+
});
|
|
1165
|
+
return {};
|
|
1166
|
+
},
|
|
1167
|
+
delete: async (options) => {
|
|
1168
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.DATABASE_ACTION, options.event, {
|
|
1169
|
+
database: options.database,
|
|
1170
|
+
input: { where: options.where },
|
|
1171
|
+
});
|
|
1172
|
+
return true;
|
|
1173
|
+
},
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
get graph() {
|
|
1177
|
+
return {
|
|
1178
|
+
execute: async (options) => {
|
|
1179
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, options.action, {
|
|
1180
|
+
graph: options.graph,
|
|
1181
|
+
input: options.input,
|
|
1182
|
+
});
|
|
1183
|
+
return {};
|
|
1184
|
+
},
|
|
1185
|
+
createNode: async (options) => {
|
|
1186
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, 'createNode', {
|
|
1187
|
+
graph: options.graph,
|
|
1188
|
+
input: { labels: options.labels, properties: options.properties },
|
|
1189
|
+
});
|
|
1190
|
+
return {};
|
|
1191
|
+
},
|
|
1192
|
+
updateNode: async (options) => {
|
|
1193
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, 'updateNode', {
|
|
1194
|
+
graph: options.graph,
|
|
1195
|
+
input: { id: options.id, properties: options.properties },
|
|
1196
|
+
});
|
|
1197
|
+
return {};
|
|
1198
|
+
},
|
|
1199
|
+
deleteNode: async (options) => {
|
|
1200
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, 'deleteNode', {
|
|
1201
|
+
graph: options.graph,
|
|
1202
|
+
input: { id: options.id },
|
|
1203
|
+
});
|
|
1204
|
+
},
|
|
1205
|
+
createRelationship: async (options) => {
|
|
1206
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, 'createRelationship', {
|
|
1207
|
+
graph: options.graph,
|
|
1208
|
+
input: { from: options.from, to: options.to, type: options.type, properties: options.properties },
|
|
1209
|
+
});
|
|
1210
|
+
return {};
|
|
1211
|
+
},
|
|
1212
|
+
deleteRelationship: async (options) => {
|
|
1213
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, 'deleteRelationship', {
|
|
1214
|
+
graph: options.graph,
|
|
1215
|
+
input: { id: options.id },
|
|
1216
|
+
});
|
|
1217
|
+
},
|
|
1218
|
+
query: async (options) => {
|
|
1219
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.GRAPH, options.action, {
|
|
1220
|
+
graph: options.graph,
|
|
1221
|
+
input: options.params || {},
|
|
1222
|
+
});
|
|
1223
|
+
return [];
|
|
1224
|
+
},
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
get notification() {
|
|
1228
|
+
return {
|
|
1229
|
+
send: async (options) => {
|
|
1230
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.NOTIFICATION, options.event, {
|
|
1231
|
+
notification: options.notification,
|
|
1232
|
+
input: options.input,
|
|
1233
|
+
options: { retries: options.retries },
|
|
1234
|
+
});
|
|
1235
|
+
},
|
|
1236
|
+
email: async (options) => {
|
|
1237
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.NOTIFICATION, options.event, {
|
|
1238
|
+
notification: options.notification,
|
|
1239
|
+
input: { recipients: options.recipients, subject: options.subject, template: options.template },
|
|
1240
|
+
});
|
|
1241
|
+
},
|
|
1242
|
+
push: async (options) => {
|
|
1243
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.NOTIFICATION, options.event, {
|
|
1244
|
+
notification: options.notification,
|
|
1245
|
+
input: { tokens: options.tokens, title: options.title, body: options.body, data: options.data },
|
|
1246
|
+
});
|
|
1247
|
+
},
|
|
1248
|
+
sms: async (options) => {
|
|
1249
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.NOTIFICATION, options.event, {
|
|
1250
|
+
notification: options.notification,
|
|
1251
|
+
input: { phones: options.phones, message: options.message },
|
|
1252
|
+
});
|
|
1253
|
+
},
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
get storage() {
|
|
1257
|
+
return {
|
|
1258
|
+
upload: async (options) => {
|
|
1259
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.STORAGE, options.event, {
|
|
1260
|
+
storage: options.storage,
|
|
1261
|
+
input: options.input,
|
|
1262
|
+
options: { retries: options.retries },
|
|
1263
|
+
});
|
|
1264
|
+
return { file_key: '', url: '' };
|
|
1265
|
+
},
|
|
1266
|
+
download: async (options) => {
|
|
1267
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.STORAGE, options.event, {
|
|
1268
|
+
storage: options.storage,
|
|
1269
|
+
input: options.input,
|
|
1270
|
+
});
|
|
1271
|
+
return { content: '', content_type: '', size: 0 };
|
|
1272
|
+
},
|
|
1273
|
+
delete: async (options) => {
|
|
1274
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.STORAGE, options.event, {
|
|
1275
|
+
storage: options.storage,
|
|
1276
|
+
input: options.input,
|
|
1277
|
+
});
|
|
1278
|
+
},
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
get publish() {
|
|
1282
|
+
return {
|
|
1283
|
+
send: async (options) => {
|
|
1284
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.PUBLISH, options.event, {
|
|
1285
|
+
broker: options.broker,
|
|
1286
|
+
input: options.input,
|
|
1287
|
+
options: { retries: options.retries },
|
|
1288
|
+
});
|
|
1289
|
+
},
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
get feature() {
|
|
1293
|
+
return {
|
|
1294
|
+
run: async (options) => {
|
|
1295
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.FEATURE, options.feature, {
|
|
1296
|
+
input: options.input,
|
|
1297
|
+
options: { retries: options.retries, timeout: options.timeout },
|
|
1298
|
+
});
|
|
1299
|
+
return {};
|
|
1300
|
+
},
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
get quota() {
|
|
1304
|
+
return {
|
|
1305
|
+
execute: async (options) => {
|
|
1306
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.QUOTA, 'execute', {
|
|
1307
|
+
quota: options.quota,
|
|
1308
|
+
input: options.input,
|
|
1309
|
+
options: { timeout: options.timeout },
|
|
1310
|
+
});
|
|
1311
|
+
return {};
|
|
1312
|
+
},
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
get fallback() {
|
|
1316
|
+
return {
|
|
1317
|
+
execute: async (options) => {
|
|
1318
|
+
this._updateCurrentStep(productsBuilder_types_1.WorkflowStepType.FALLBACK, 'execute', {
|
|
1319
|
+
fallback: options.fallback,
|
|
1320
|
+
input: options.input,
|
|
1321
|
+
options: { timeout: options.timeout },
|
|
1322
|
+
});
|
|
1323
|
+
return {};
|
|
1324
|
+
},
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
get healthcheck() {
|
|
1328
|
+
return {
|
|
1329
|
+
getStatus: async (tag) => {
|
|
1330
|
+
return { status: 'available', lastChecked: new Date().toISOString(), lastLatency: 0 };
|
|
1331
|
+
},
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
get transform() {
|
|
1335
|
+
return {
|
|
1336
|
+
size: (obj) => Object.keys(obj).length,
|
|
1337
|
+
length: (arr) => arr.length,
|
|
1338
|
+
parseJson: (str) => JSON.parse(str),
|
|
1339
|
+
stringify: (obj) => JSON.stringify(obj),
|
|
1340
|
+
upper: (str) => str.toUpperCase(),
|
|
1341
|
+
lower: (str) => str.toLowerCase(),
|
|
1342
|
+
trim: (str) => str.trim(),
|
|
1343
|
+
split: (str, separator) => str.split(separator),
|
|
1344
|
+
join: (arr, separator) => arr.join(separator),
|
|
1345
|
+
now: () => Date.now(),
|
|
1346
|
+
formatDate: (date, format) => new Date(date).toISOString(),
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
// ==================== DATA REFERENCES ====================
|
|
1350
|
+
variable(app, key) {
|
|
1351
|
+
return `$Variable{${app}}{${key}}`;
|
|
1352
|
+
}
|
|
1353
|
+
constant(app, key) {
|
|
1354
|
+
return `$Constant{${app}}{${key}}`;
|
|
1355
|
+
}
|
|
1356
|
+
token(key) {
|
|
1357
|
+
return `$Secret{${key}}`;
|
|
1358
|
+
}
|
|
1359
|
+
get auth() {
|
|
1360
|
+
return {};
|
|
1361
|
+
}
|
|
1362
|
+
default(value, fallback) {
|
|
1363
|
+
return value !== null && value !== void 0 ? value : fallback;
|
|
1364
|
+
}
|
|
1365
|
+
// ==================== CONTROL FLOW ====================
|
|
1366
|
+
async sleep(duration) {
|
|
1367
|
+
const ms = typeof duration === 'string' ? this._parseDuration(duration) : duration;
|
|
1368
|
+
this._addControlStep(productsBuilder_types_1.WorkflowStepType.SLEEP, 'sleep', { duration: ms });
|
|
1369
|
+
}
|
|
1370
|
+
async waitForSignal(signal, options) {
|
|
1371
|
+
const signals = Array.isArray(signal) ? signal : [signal];
|
|
1372
|
+
const timeout = (options === null || options === void 0 ? void 0 : options.timeout)
|
|
1373
|
+
? typeof options.timeout === 'string'
|
|
1374
|
+
? this._parseDuration(options.timeout)
|
|
1375
|
+
: options.timeout
|
|
1376
|
+
: undefined;
|
|
1377
|
+
this._addControlStep(productsBuilder_types_1.WorkflowStepType.WAIT_FOR_SIGNAL, signals[0], {
|
|
1378
|
+
signals,
|
|
1379
|
+
options: timeout ? { timeout } : undefined,
|
|
1380
|
+
});
|
|
1381
|
+
return {};
|
|
1382
|
+
}
|
|
1383
|
+
async checkpoint(name, metadata) {
|
|
1384
|
+
this._addControlStep(productsBuilder_types_1.WorkflowStepType.CHECKPOINT, name, { metadata });
|
|
1385
|
+
}
|
|
1386
|
+
// ==================== STATE MANAGEMENT ====================
|
|
1387
|
+
setState(key, value) {
|
|
1388
|
+
// No-op during compilation
|
|
1389
|
+
}
|
|
1390
|
+
getState(key) {
|
|
1391
|
+
return undefined;
|
|
1392
|
+
}
|
|
1393
|
+
// ==================== LOGGING ====================
|
|
1394
|
+
get log() {
|
|
1395
|
+
return {
|
|
1396
|
+
debug: (message, data) => { },
|
|
1397
|
+
info: (message, data) => { },
|
|
1398
|
+
warn: (message, data) => { },
|
|
1399
|
+
error: (message, data) => { },
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
// ==================== CHILD WORKFLOWS ====================
|
|
1403
|
+
async workflow(childId, tag, input, options) {
|
|
1404
|
+
this._addControlStep(productsBuilder_types_1.WorkflowStepType.CHILD_WORKFLOW, 'execute', {
|
|
1405
|
+
workflow: tag,
|
|
1406
|
+
input,
|
|
1407
|
+
options: options ? {
|
|
1408
|
+
timeout: options.timeout
|
|
1409
|
+
? typeof options.timeout === 'string'
|
|
1410
|
+
? this._parseDuration(options.timeout)
|
|
1411
|
+
: options.timeout
|
|
1412
|
+
: undefined,
|
|
1413
|
+
retries: options.retries,
|
|
1414
|
+
} : undefined,
|
|
1415
|
+
});
|
|
1416
|
+
return {};
|
|
1417
|
+
}
|
|
1418
|
+
// ==================== ROLLBACK ====================
|
|
1419
|
+
async triggerRollback(reason) {
|
|
1420
|
+
return { success: true, rolled_back_steps: [], reason };
|
|
1421
|
+
}
|
|
1422
|
+
// ==================== INTERNAL HELPERS ====================
|
|
1423
|
+
_updateCurrentStep(type, event, data) {
|
|
1424
|
+
if (!this._currentStepTag)
|
|
1425
|
+
return;
|
|
1426
|
+
// Find or create the step
|
|
1427
|
+
let step = this._steps.find(s => s.tag === this._currentStepTag);
|
|
1428
|
+
if (!step) {
|
|
1429
|
+
step = {
|
|
1430
|
+
tag: this._currentStepTag,
|
|
1431
|
+
type,
|
|
1432
|
+
event,
|
|
1433
|
+
input: data.input || {},
|
|
1434
|
+
};
|
|
1435
|
+
this._steps.push(step);
|
|
1436
|
+
}
|
|
1437
|
+
// Update step properties
|
|
1438
|
+
step.type = type;
|
|
1439
|
+
step.event = event;
|
|
1440
|
+
if (data.app)
|
|
1441
|
+
step.app = data.app;
|
|
1442
|
+
if (data.database)
|
|
1443
|
+
step.database = data.database;
|
|
1444
|
+
if (data.graph)
|
|
1445
|
+
step.graph = data.graph;
|
|
1446
|
+
if (data.storage)
|
|
1447
|
+
step.storage = data.storage;
|
|
1448
|
+
if (data.notification)
|
|
1449
|
+
step.notification = data.notification;
|
|
1450
|
+
if (data.broker)
|
|
1451
|
+
step.broker = data.broker;
|
|
1452
|
+
if (data.quota)
|
|
1453
|
+
step.quota = data.quota;
|
|
1454
|
+
if (data.fallback)
|
|
1455
|
+
step.fallback = data.fallback;
|
|
1456
|
+
if (data.workflow)
|
|
1457
|
+
step.workflow = data.workflow;
|
|
1458
|
+
if (data.input)
|
|
1459
|
+
step.input = data.input;
|
|
1460
|
+
if (data.options)
|
|
1461
|
+
step.options = Object.assign(Object.assign({}, step.options), data.options);
|
|
1462
|
+
}
|
|
1463
|
+
_addControlStep(type, event, data) {
|
|
1464
|
+
const tag = `${type}-${this._stepOrder++}`;
|
|
1465
|
+
this._steps.push({
|
|
1466
|
+
tag,
|
|
1467
|
+
type,
|
|
1468
|
+
event,
|
|
1469
|
+
input: data,
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
_parseDuration(duration) {
|
|
1473
|
+
const match = duration.match(/^(\d+)(ms|s|m|h|d)$/);
|
|
1474
|
+
if (!match)
|
|
1475
|
+
return parseInt(duration, 10) || 0;
|
|
1476
|
+
const value = parseInt(match[1], 10);
|
|
1477
|
+
const unit = match[2];
|
|
1478
|
+
switch (unit) {
|
|
1479
|
+
case 'ms': return value;
|
|
1480
|
+
case 's': return value * 1000;
|
|
1481
|
+
case 'm': return value * 60 * 1000;
|
|
1482
|
+
case 'h': return value * 60 * 60 * 1000;
|
|
1483
|
+
case 'd': return value * 24 * 60 * 60 * 1000;
|
|
1484
|
+
default: return value;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
/** Get collected steps */
|
|
1488
|
+
getSteps() {
|
|
1489
|
+
return this._steps;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Compiles code-first workflow definitions to JSON schema
|
|
1494
|
+
* Uses runtime handler tracing to capture step definitions
|
|
1495
|
+
*/
|
|
1496
|
+
class WorkflowCompiler {
|
|
1497
|
+
constructor(options) {
|
|
1498
|
+
this.options = options;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Compile the workflow definition to JSON schema
|
|
1502
|
+
* Executes the handler with a recording context to capture step definitions
|
|
1503
|
+
*/
|
|
1504
|
+
compile() {
|
|
1505
|
+
// Create recording context with mock input
|
|
1506
|
+
const mockInput = {};
|
|
1507
|
+
const recordingCtx = new RecordingContext(mockInput, this.options.tag);
|
|
1508
|
+
// Execute handler to trace step definitions
|
|
1509
|
+
try {
|
|
1510
|
+
// Run the handler synchronously to capture all step calls
|
|
1511
|
+
// Note: This won't await async operations, but will capture the step structure
|
|
1512
|
+
const handlerPromise = this.options.handler(recordingCtx);
|
|
1513
|
+
// For synchronous tracing, we don't need to await
|
|
1514
|
+
// The recording context captures calls as they're made
|
|
1515
|
+
if (handlerPromise && typeof handlerPromise.then === 'function') {
|
|
1516
|
+
// Handler is async - we capture what we can synchronously
|
|
1517
|
+
// For full async tracing, use compileAsync()
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
catch (e) {
|
|
1521
|
+
// Ignore errors during compilation - we're tracing structure, not executing
|
|
1522
|
+
}
|
|
1523
|
+
return {
|
|
1524
|
+
name: this.options.name,
|
|
1525
|
+
tag: this.options.tag,
|
|
1526
|
+
description: this.options.description,
|
|
1527
|
+
input: {},
|
|
1528
|
+
output: {},
|
|
1529
|
+
steps: recordingCtx.getSteps(),
|
|
1530
|
+
signals: this.options.signals
|
|
1531
|
+
? Object.fromEntries(Object.entries(this.options.signals).map(([name, config]) => [
|
|
1532
|
+
name,
|
|
1533
|
+
{ name, input: config.input },
|
|
1534
|
+
]))
|
|
1535
|
+
: undefined,
|
|
1536
|
+
queries: this.options.queries
|
|
1537
|
+
? Object.fromEntries(Object.entries(this.options.queries).map(([name, config]) => {
|
|
1538
|
+
var _a;
|
|
1539
|
+
return [
|
|
1540
|
+
name,
|
|
1541
|
+
{ name, handler: (_a = config.handler) === null || _a === void 0 ? void 0 : _a.toString() },
|
|
1542
|
+
];
|
|
1543
|
+
}))
|
|
1544
|
+
: undefined,
|
|
1545
|
+
options: this.options.options,
|
|
1546
|
+
envs: this.options.envs,
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Compile the workflow definition asynchronously
|
|
1551
|
+
* Fully awaits the handler to capture all step definitions
|
|
1552
|
+
*/
|
|
1553
|
+
async compileAsync() {
|
|
1554
|
+
// Create recording context with mock input
|
|
1555
|
+
const mockInput = {};
|
|
1556
|
+
const recordingCtx = new RecordingContext(mockInput, this.options.tag);
|
|
1557
|
+
// Execute handler to trace step definitions
|
|
1558
|
+
try {
|
|
1559
|
+
await this.options.handler(recordingCtx);
|
|
1560
|
+
}
|
|
1561
|
+
catch (e) {
|
|
1562
|
+
// Ignore errors during compilation - we're tracing structure, not executing
|
|
1563
|
+
}
|
|
1564
|
+
return {
|
|
1565
|
+
name: this.options.name,
|
|
1566
|
+
tag: this.options.tag,
|
|
1567
|
+
description: this.options.description,
|
|
1568
|
+
input: {},
|
|
1569
|
+
output: {},
|
|
1570
|
+
steps: recordingCtx.getSteps(),
|
|
1571
|
+
signals: this.options.signals
|
|
1572
|
+
? Object.fromEntries(Object.entries(this.options.signals).map(([name, config]) => [
|
|
1573
|
+
name,
|
|
1574
|
+
{ name, input: config.input },
|
|
1575
|
+
]))
|
|
1576
|
+
: undefined,
|
|
1577
|
+
queries: this.options.queries
|
|
1578
|
+
? Object.fromEntries(Object.entries(this.options.queries).map(([name, config]) => {
|
|
1579
|
+
var _a;
|
|
1580
|
+
return [
|
|
1581
|
+
name,
|
|
1582
|
+
{ name, handler: (_a = config.handler) === null || _a === void 0 ? void 0 : _a.toString() },
|
|
1583
|
+
];
|
|
1584
|
+
}))
|
|
1585
|
+
: undefined,
|
|
1586
|
+
options: this.options.options,
|
|
1587
|
+
envs: this.options.envs,
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
// Export singleton instance for convenience
|
|
1592
|
+
exports.workflowService = new WorkflowService();
|
|
1593
|
+
// Default export
|
|
1594
|
+
exports.default = WorkflowService;
|
|
1595
|
+
//# sourceMappingURL=workflows.service.js.map
|