@ductape/sdk 0.0.4-v51 → 0.0.4-v53
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
|
@@ -22,13 +22,13 @@ const inputs_utils_create_1 = require("../../inputs/utils/inputs.utils.create");
|
|
|
22
22
|
const enums_1 = require("../../types/enums");
|
|
23
23
|
const productsBuilder_types_1 = require("../../types/productsBuilder.types");
|
|
24
24
|
const validators_1 = require("../validators");
|
|
25
|
-
const objects_utils_1 = require("
|
|
25
|
+
const objects_utils_1 = require("../utils/objects.utils");
|
|
26
26
|
const processor_utils_1 = require("../../processor/utils/processor.utils");
|
|
27
|
-
const create_productDatabaseAction_validator_1 =
|
|
28
|
-
const update_productDatabaseAction_validator_1 =
|
|
27
|
+
const create_productDatabaseAction_validator_1 = require("../validators/joi-validators/create.productDatabaseAction.validator");
|
|
28
|
+
const update_productDatabaseAction_validator_1 = require("../validators/joi-validators/update.productDatabaseAction.validator");
|
|
29
29
|
const create_productStorage_validator_1 = require("../validators/joi-validators/create.productStorage.validator");
|
|
30
30
|
const inputs_types_1 = require("../../types/inputs.types");
|
|
31
|
-
const string_utils_1 = require("
|
|
31
|
+
const string_utils_1 = require("../utils/string.utils");
|
|
32
32
|
const workspaceApi_service_1 = require("../../api/services/workspaceApi.service");
|
|
33
33
|
const string_utils_2 = require("../../apps/utils/string.utils");
|
|
34
34
|
const create_productDatabaseMigration_validator_1 = __importDefault(require("../validators/joi-validators/create.productDatabaseMigration.validator"));
|
|
@@ -36,11 +36,9 @@ const update_productDatabaseMigration_validator_1 = __importDefault(require("../
|
|
|
36
36
|
const create_productNotificationMessage_validator_1 = __importDefault(require("../validators/joi-validators/create.productNotificationMessage.validator"));
|
|
37
37
|
const create_productMessageBrokerTopic_validator_1 = __importDefault(require("../validators/joi-validators/create.productMessageBrokerTopic.validator"));
|
|
38
38
|
const update_productMessageBrokerTopic_validator_1 = __importDefault(require("../validators/joi-validators/update.productMessageBrokerTopic.validator"));
|
|
39
|
-
const create_productGraphAction_validator_1 = __importDefault(require("../validators/joi-validators/create.productGraphAction.validator"));
|
|
40
|
-
const update_productGraphAction_validator_1 = __importDefault(require("../validators/joi-validators/update.productGraphAction.validator"));
|
|
41
39
|
const update_productNotificationMessage_validator_1 = __importDefault(require("../validators/joi-validators/update.productNotificationMessage.validator"));
|
|
42
40
|
const create_productNotification_validator_1 = require("../validators/joi-validators/create.productNotification.validator");
|
|
43
|
-
const functions_utils_1 = require("
|
|
41
|
+
const functions_utils_1 = require("../utils/functions.utils");
|
|
44
42
|
const objects_utils_2 = require("../../apps/utils/objects.utils");
|
|
45
43
|
const webhooksApi_service_1 = require("../../api/services/webhooksApi.service");
|
|
46
44
|
class ProductsBuilderService {
|
|
@@ -96,24 +94,24 @@ class ProductsBuilderService {
|
|
|
96
94
|
}
|
|
97
95
|
await this.validateActionDataInput({ input: env.input }, event, env.input, 0, 0);
|
|
98
96
|
env.input = (0, processor_utils_1.encrypt)(JSON.stringify(env.input), this.product.private_key);
|
|
99
|
-
console.log(
|
|
97
|
+
console.log('INPUT', env);
|
|
100
98
|
return env;
|
|
101
99
|
}));
|
|
102
100
|
const envs = await this.fetchEnvs();
|
|
103
|
-
console.log(
|
|
104
|
-
console.log(
|
|
101
|
+
console.log('ENVS ===>>>>', envs);
|
|
102
|
+
console.log('DBENVS ====>>>>', data.envs);
|
|
105
103
|
envs.map((env) => {
|
|
106
104
|
const exists = data.envs.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
107
105
|
if (exists === -1) {
|
|
108
106
|
throw new Error(`Product env ${env.slug} is not defined, please provide details`);
|
|
109
107
|
}
|
|
110
108
|
});
|
|
111
|
-
console.log(
|
|
109
|
+
console.log('UPDATING VALUE', data);
|
|
112
110
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { action: enums_1.RequestAction.CREATE, component: enums_1.ProductComponents.HEALTHCHECK }), this.getUserAccess());
|
|
113
111
|
data.envs.map(async (env) => {
|
|
114
112
|
const payload = {
|
|
115
113
|
app: data.app,
|
|
116
|
-
|
|
114
|
+
action: data.event,
|
|
117
115
|
input: env.input,
|
|
118
116
|
env: env.slug,
|
|
119
117
|
product: this.product.tag,
|
|
@@ -143,7 +141,7 @@ class ProductsBuilderService {
|
|
|
143
141
|
// 2. Validate the incoming data
|
|
144
142
|
await validators_1.CreateProductHealthcheckSchema.validateAsync(data); // No Update schema, use Create
|
|
145
143
|
// 3. Check for tag conflicts
|
|
146
|
-
if (data.tag && data.tag !== tag && await this.fetchHealthcheck(data.app, data.tag)) {
|
|
144
|
+
if (data.tag && data.tag !== tag && (await this.fetchHealthcheck(data.app, data.tag))) {
|
|
147
145
|
throw new Error(`Healthcheck with tag ${data.tag} already exists`);
|
|
148
146
|
}
|
|
149
147
|
// 4. Validate and process envs
|
|
@@ -294,7 +292,7 @@ class ProductsBuilderService {
|
|
|
294
292
|
}
|
|
295
293
|
async initializeProduct(product_id) {
|
|
296
294
|
try {
|
|
297
|
-
this.product = await this.productApi.initProduct(product_id, this.getUserAccess());
|
|
295
|
+
this.product = (await this.productApi.initProduct(product_id, this.getUserAccess()));
|
|
298
296
|
this.product_id = product_id;
|
|
299
297
|
}
|
|
300
298
|
catch (e) {
|
|
@@ -303,7 +301,7 @@ class ProductsBuilderService {
|
|
|
303
301
|
}
|
|
304
302
|
async initializeProductByTag(tag) {
|
|
305
303
|
try {
|
|
306
|
-
this.product = await this.productApi.initProduct(tag, this.getUserAccess());
|
|
304
|
+
this.product = (await this.productApi.initProduct(tag, this.getUserAccess()));
|
|
307
305
|
if (!this.product) {
|
|
308
306
|
throw new Error(`Product with tag "${tag}" not found or failed to fetch`);
|
|
309
307
|
}
|
|
@@ -313,6 +311,48 @@ class ProductsBuilderService {
|
|
|
313
311
|
throw e;
|
|
314
312
|
}
|
|
315
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Bootstrap action - ultra-lightweight API call to fetch action data needed for processAction
|
|
316
|
+
* Replaces 5+ separate API calls: initializeProduct, fetchApp, fetchThirdPartyApp, fetchEnv, initializePricing
|
|
317
|
+
* Returns only the minimal action data needed to execute
|
|
318
|
+
*/
|
|
319
|
+
async bootstrapAction(params) {
|
|
320
|
+
try {
|
|
321
|
+
const result = await this.productApi.bootstrapAction(params, this.getUserAccess());
|
|
322
|
+
// Initialize minimal product data
|
|
323
|
+
if (result.product_id) {
|
|
324
|
+
this.product_id = result.product_id;
|
|
325
|
+
}
|
|
326
|
+
return result;
|
|
327
|
+
}
|
|
328
|
+
catch (e) {
|
|
329
|
+
throw e;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
async bootstrapNotification(params) {
|
|
333
|
+
try {
|
|
334
|
+
const result = await this.productApi.bootstrapNotification(params, this.getUserAccess());
|
|
335
|
+
if (result.product_id) {
|
|
336
|
+
this.product_id = result.product_id;
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
throw e;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async bootstrapStorage(params) {
|
|
345
|
+
try {
|
|
346
|
+
const result = await this.productApi.bootstrapStorage(params, this.getUserAccess());
|
|
347
|
+
if (result.product_id) {
|
|
348
|
+
this.product_id = result.product_id;
|
|
349
|
+
}
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
throw e;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
316
356
|
async updateProduct(data) {
|
|
317
357
|
try {
|
|
318
358
|
if (!this.app_id)
|
|
@@ -362,15 +402,13 @@ class ProductsBuilderService {
|
|
|
362
402
|
throw new Error(`${data.selector} not found in event sample`);
|
|
363
403
|
}
|
|
364
404
|
}
|
|
365
|
-
if (current === null ||
|
|
366
|
-
|
|
367
|
-
typeof current === "object") {
|
|
368
|
-
throw new Error("Selector value is not allowed to be an object|array|null|undefined");
|
|
405
|
+
if (current === null || typeof current === 'undefined' || typeof current === 'object') {
|
|
406
|
+
throw new Error('Selector value is not allowed to be an object|array|null|undefined');
|
|
369
407
|
}
|
|
370
|
-
data.schema_data = await this.inputsService.parseJson({
|
|
408
|
+
data.schema_data = (await this.inputsService.parseJson({
|
|
371
409
|
data: data.schema,
|
|
372
|
-
expected: inputs_types_1.ExpectedValues.PARSESAMPLE
|
|
373
|
-
});
|
|
410
|
+
expected: inputs_types_1.ExpectedValues.PARSESAMPLE,
|
|
411
|
+
}));
|
|
374
412
|
data.selectorValue = current;
|
|
375
413
|
const payload = Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.SESSION, action: enums_1.RequestAction.CREATE });
|
|
376
414
|
await this.productApi.updateProduct(this.product_id, payload, this.getUserAccess());
|
|
@@ -419,10 +457,8 @@ class ProductsBuilderService {
|
|
|
419
457
|
throw new Error(`${data.selector} not found in event sample`);
|
|
420
458
|
}
|
|
421
459
|
}
|
|
422
|
-
if (current === null ||
|
|
423
|
-
|
|
424
|
-
typeof current === "object") {
|
|
425
|
-
throw new Error("Selector value is not allowed to be an object|array|null|undefined");
|
|
460
|
+
if (current === null || typeof current === 'undefined' || typeof current === 'object') {
|
|
461
|
+
throw new Error('Selector value is not allowed to be an object|array|null|undefined');
|
|
426
462
|
}
|
|
427
463
|
}
|
|
428
464
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, Object.assign(Object.assign({}, session), data)), { component: enums_1.ProductComponents.SESSION, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
@@ -431,7 +467,7 @@ class ProductsBuilderService {
|
|
|
431
467
|
throw e;
|
|
432
468
|
}
|
|
433
469
|
}
|
|
434
|
-
async fetchSessions() {
|
|
470
|
+
async fetchSessions(version) {
|
|
435
471
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'session', this.getUserAccess());
|
|
436
472
|
return components;
|
|
437
473
|
}
|
|
@@ -439,6 +475,22 @@ class ProductsBuilderService {
|
|
|
439
475
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'session', tag, this.getUserAccess());
|
|
440
476
|
return component;
|
|
441
477
|
}
|
|
478
|
+
async deleteSession(tag) {
|
|
479
|
+
try {
|
|
480
|
+
const session = await this.fetchSession(tag);
|
|
481
|
+
if (!session) {
|
|
482
|
+
throw new Error(`Session with tag: ${tag} not found`);
|
|
483
|
+
}
|
|
484
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
485
|
+
tag,
|
|
486
|
+
component: enums_1.ProductComponents.SESSION,
|
|
487
|
+
action: enums_1.RequestAction.DELETE,
|
|
488
|
+
}, this.getUserAccess());
|
|
489
|
+
}
|
|
490
|
+
catch (e) {
|
|
491
|
+
throw e;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
442
494
|
async createMessageBrokerTopic(data, throwErrorIfExists = false) {
|
|
443
495
|
try {
|
|
444
496
|
if (!data.tag) {
|
|
@@ -512,7 +564,7 @@ class ProductsBuilderService {
|
|
|
512
564
|
if (!messageBrokerTag || !topicTag) {
|
|
513
565
|
throw new Error(`tag is expected to be defined as "messageBroker_tag:topic_tag"`);
|
|
514
566
|
}
|
|
515
|
-
const messageBroker =
|
|
567
|
+
const messageBroker = this.product.messageBrokers.find((data) => data.tag === messageBrokerTag);
|
|
516
568
|
if (!messageBroker)
|
|
517
569
|
throw new Error(`MessageBroker ${messageBrokerTag} not found`);
|
|
518
570
|
const topic = messageBroker.topics.find((data) => data.tag === topicTag);
|
|
@@ -521,7 +573,7 @@ class ProductsBuilderService {
|
|
|
521
573
|
return topic;
|
|
522
574
|
}
|
|
523
575
|
async fetchMessageBrokerTopics(messageBrokerTag) {
|
|
524
|
-
const messageBroker =
|
|
576
|
+
const messageBroker = this.product.messageBrokers.find((data) => data.tag === messageBrokerTag);
|
|
525
577
|
if (!messageBroker)
|
|
526
578
|
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
527
579
|
return messageBroker.topics;
|
|
@@ -741,7 +793,10 @@ class ProductsBuilderService {
|
|
|
741
793
|
if (!action) {
|
|
742
794
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
743
795
|
}
|
|
744
|
-
if (action.headers.data.length > 0 ||
|
|
796
|
+
if (action.headers.data.length > 0 ||
|
|
797
|
+
action.body.data.length > 0 ||
|
|
798
|
+
action.params.data.length > 0 ||
|
|
799
|
+
action.query.data.length > 0) {
|
|
745
800
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
746
801
|
}
|
|
747
802
|
}
|
|
@@ -787,7 +842,10 @@ class ProductsBuilderService {
|
|
|
787
842
|
if (!action) {
|
|
788
843
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
789
844
|
}
|
|
790
|
-
if (action.headers.data.length > 0 ||
|
|
845
|
+
if (action.headers.data.length > 0 ||
|
|
846
|
+
action.body.data.length > 0 ||
|
|
847
|
+
action.params.data.length > 0 ||
|
|
848
|
+
action.query.data.length > 0) {
|
|
791
849
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
792
850
|
}
|
|
793
851
|
}
|
|
@@ -807,14 +865,30 @@ class ProductsBuilderService {
|
|
|
807
865
|
throw e;
|
|
808
866
|
}
|
|
809
867
|
}
|
|
810
|
-
async fetchQuotas() {
|
|
868
|
+
async fetchQuotas(version) {
|
|
811
869
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'quota', this.getUserAccess());
|
|
812
870
|
return components;
|
|
813
871
|
}
|
|
814
|
-
async fetchQuota(tag) {
|
|
872
|
+
async fetchQuota(tag, version) {
|
|
815
873
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'quota', tag, this.getUserAccess());
|
|
816
874
|
return component;
|
|
817
875
|
}
|
|
876
|
+
async deleteQuota(tag) {
|
|
877
|
+
try {
|
|
878
|
+
const quota = await this.fetchQuota(tag);
|
|
879
|
+
if (!quota) {
|
|
880
|
+
throw new Error(`Quota with tag: ${tag} not found`);
|
|
881
|
+
}
|
|
882
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
883
|
+
tag,
|
|
884
|
+
component: enums_1.ProductComponents.QUOTA,
|
|
885
|
+
action: enums_1.RequestAction.DELETE,
|
|
886
|
+
}, this.getUserAccess());
|
|
887
|
+
}
|
|
888
|
+
catch (e) {
|
|
889
|
+
throw e;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
818
892
|
async createFallback(data) {
|
|
819
893
|
try {
|
|
820
894
|
if (!data.tag) {
|
|
@@ -842,7 +916,10 @@ class ProductsBuilderService {
|
|
|
842
916
|
if (!action) {
|
|
843
917
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
844
918
|
}
|
|
845
|
-
if (action.headers.data.length > 0 ||
|
|
919
|
+
if (action.headers.data.length > 0 ||
|
|
920
|
+
action.body.data.length > 0 ||
|
|
921
|
+
action.params.data.length > 0 ||
|
|
922
|
+
action.query.data.length > 0) {
|
|
846
923
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
847
924
|
}
|
|
848
925
|
}
|
|
@@ -885,7 +962,10 @@ class ProductsBuilderService {
|
|
|
885
962
|
if (!action) {
|
|
886
963
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
887
964
|
}
|
|
888
|
-
if (action.headers.data.length > 0 ||
|
|
965
|
+
if (action.headers.data.length > 0 ||
|
|
966
|
+
action.body.data.length > 0 ||
|
|
967
|
+
action.params.data.length > 0 ||
|
|
968
|
+
action.query.data.length > 0) {
|
|
889
969
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
890
970
|
}
|
|
891
971
|
}
|
|
@@ -905,14 +985,30 @@ class ProductsBuilderService {
|
|
|
905
985
|
throw e;
|
|
906
986
|
}
|
|
907
987
|
}
|
|
908
|
-
async fetchFallbacks() {
|
|
988
|
+
async fetchFallbacks(version) {
|
|
909
989
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'fallback', this.getUserAccess());
|
|
910
990
|
return components;
|
|
911
991
|
}
|
|
912
|
-
async fetchFallback(tag) {
|
|
992
|
+
async fetchFallback(tag, version) {
|
|
913
993
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'fallback', tag, this.getUserAccess());
|
|
914
994
|
return component;
|
|
915
995
|
}
|
|
996
|
+
async deleteFallback(tag) {
|
|
997
|
+
try {
|
|
998
|
+
const fallback = await this.fetchFallback(tag);
|
|
999
|
+
if (!fallback) {
|
|
1000
|
+
throw new Error(`Fallback with tag: ${tag} not found`);
|
|
1001
|
+
}
|
|
1002
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1003
|
+
tag,
|
|
1004
|
+
component: enums_1.ProductComponents.FALLBACK,
|
|
1005
|
+
action: enums_1.RequestAction.DELETE,
|
|
1006
|
+
}, this.getUserAccess());
|
|
1007
|
+
}
|
|
1008
|
+
catch (e) {
|
|
1009
|
+
throw e;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
916
1012
|
async createEnv(data, throwErrorIfExists = false) {
|
|
917
1013
|
try {
|
|
918
1014
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
@@ -949,14 +1045,31 @@ class ProductsBuilderService {
|
|
|
949
1045
|
throw e;
|
|
950
1046
|
}
|
|
951
1047
|
}
|
|
952
|
-
async fetchEnvs() {
|
|
1048
|
+
async fetchEnvs(version) {
|
|
953
1049
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'env', this.getUserAccess());
|
|
954
1050
|
return components;
|
|
955
1051
|
}
|
|
956
1052
|
async fetchEnv(slug) {
|
|
1053
|
+
console.log;
|
|
957
1054
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'env', slug, this.getUserAccess());
|
|
958
1055
|
return component;
|
|
959
1056
|
}
|
|
1057
|
+
async deleteEnv(slug) {
|
|
1058
|
+
try {
|
|
1059
|
+
const env = await this.fetchEnv(slug);
|
|
1060
|
+
if (!env) {
|
|
1061
|
+
throw new Error(`Environment with slug: ${slug} not found`);
|
|
1062
|
+
}
|
|
1063
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1064
|
+
slug,
|
|
1065
|
+
component: enums_1.ProductComponents.ENV,
|
|
1066
|
+
action: enums_1.RequestAction.DELETE,
|
|
1067
|
+
}, this.getUserAccess());
|
|
1068
|
+
}
|
|
1069
|
+
catch (e) {
|
|
1070
|
+
throw e;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
960
1073
|
async createMessageBroker(data, throwErrorIfExists = false) {
|
|
961
1074
|
if (!(await this.fetchMessageBroker(data.tag))) {
|
|
962
1075
|
await validators_1.CreateMessageBrokerSchema.validateAsync(data);
|
|
@@ -1045,27 +1158,29 @@ class ProductsBuilderService {
|
|
|
1045
1158
|
throw e;
|
|
1046
1159
|
}
|
|
1047
1160
|
}
|
|
1048
|
-
async fetchMessageBrokers() {
|
|
1161
|
+
async fetchMessageBrokers(version) {
|
|
1049
1162
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'message_broker', this.getUserAccess());
|
|
1050
|
-
components.map((broker) => {
|
|
1051
|
-
return broker.envs.map((env) => {
|
|
1052
|
-
if (typeof env.config === 'string') {
|
|
1053
|
-
env.config = JSON.parse((0, processor_utils_1.decrypt)(String(env.config), this.product.private_key));
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
});
|
|
1057
1163
|
return components;
|
|
1058
1164
|
}
|
|
1059
|
-
async fetchMessageBroker(tag) {
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1165
|
+
async fetchMessageBroker(tag, version) {
|
|
1166
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'message_broker', tag, this.getUserAccess());
|
|
1167
|
+
return component;
|
|
1168
|
+
}
|
|
1169
|
+
async deleteMessageBroker(tag) {
|
|
1170
|
+
try {
|
|
1171
|
+
const messageBroker = await this.fetchMessageBroker(tag);
|
|
1172
|
+
if (!messageBroker) {
|
|
1173
|
+
throw new Error(`Message broker with tag: ${tag} not found`);
|
|
1174
|
+
}
|
|
1175
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1176
|
+
tag,
|
|
1177
|
+
component: enums_1.ProductComponents.MESSAGEBROKER,
|
|
1178
|
+
action: enums_1.RequestAction.DELETE,
|
|
1179
|
+
}, this.getUserAccess());
|
|
1180
|
+
}
|
|
1181
|
+
catch (e) {
|
|
1182
|
+
throw e;
|
|
1067
1183
|
}
|
|
1068
|
-
return messageBroker;
|
|
1069
1184
|
}
|
|
1070
1185
|
async fetchStorageFiles(filter) {
|
|
1071
1186
|
try {
|
|
@@ -1081,7 +1196,7 @@ class ProductsBuilderService {
|
|
|
1081
1196
|
});
|
|
1082
1197
|
}
|
|
1083
1198
|
catch (e) {
|
|
1084
|
-
throw
|
|
1199
|
+
throw e;
|
|
1085
1200
|
}
|
|
1086
1201
|
}
|
|
1087
1202
|
async fetchSessionUsers(filter) {
|
|
@@ -1097,7 +1212,7 @@ class ProductsBuilderService {
|
|
|
1097
1212
|
});
|
|
1098
1213
|
}
|
|
1099
1214
|
catch (e) {
|
|
1100
|
-
throw
|
|
1215
|
+
throw e;
|
|
1101
1216
|
}
|
|
1102
1217
|
}
|
|
1103
1218
|
async createStorage(data, throwErrorIfExists = false) {
|
|
@@ -1193,133 +1308,521 @@ class ProductsBuilderService {
|
|
|
1193
1308
|
throw e;
|
|
1194
1309
|
}
|
|
1195
1310
|
}
|
|
1196
|
-
async fetchStorages() {
|
|
1311
|
+
async fetchStorages(version) {
|
|
1197
1312
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'storage', this.getUserAccess());
|
|
1198
|
-
components.map((storage) => {
|
|
1199
|
-
storage.envs.map((env) => {
|
|
1200
|
-
if (typeof env.config === 'string') {
|
|
1201
|
-
env.config = JSON.parse((0, processor_utils_1.decrypt)(String(env.config), this.product.private_key));
|
|
1202
|
-
}
|
|
1203
|
-
});
|
|
1204
|
-
});
|
|
1205
1313
|
return components;
|
|
1206
1314
|
}
|
|
1207
|
-
async fetchStorage(tag) {
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1210
|
-
storage.envs.map((store) => {
|
|
1211
|
-
if (typeof store.config === 'string') {
|
|
1212
|
-
store.config = JSON.parse((0, processor_utils_1.decrypt)(String(store.config), this.product.private_key));
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
return storage;
|
|
1217
|
-
}
|
|
1218
|
-
async validateAppData(appData, app) {
|
|
1219
|
-
// TODO:
|
|
1220
|
-
const { envs } = app;
|
|
1221
|
-
// const { envs: appEnvs, auths: appAuths } = appData
|
|
1222
|
-
const version = appData.versions.find((data) => (data.latest = true));
|
|
1223
|
-
app.envs = this.validateAppEnvs(envs, version);
|
|
1224
|
-
// await this.validateAppAuth(auth, appData);
|
|
1225
|
-
return app;
|
|
1315
|
+
async fetchStorage(tag, version) {
|
|
1316
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'storage', tag, this.getUserAccess());
|
|
1317
|
+
return component;
|
|
1226
1318
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1319
|
+
async deleteStorage(tag) {
|
|
1320
|
+
try {
|
|
1321
|
+
const storage = await this.fetchStorage(tag);
|
|
1322
|
+
if (!storage) {
|
|
1323
|
+
throw new Error(`Storage with tag: ${tag} not found`);
|
|
1324
|
+
}
|
|
1325
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1326
|
+
tag,
|
|
1327
|
+
component: enums_1.ProductComponents.STORAGE,
|
|
1328
|
+
action: enums_1.RequestAction.DELETE,
|
|
1329
|
+
}, this.getUserAccess());
|
|
1236
1330
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
if (!variables) {
|
|
1240
|
-
variables = [];
|
|
1331
|
+
catch (e) {
|
|
1332
|
+
throw e;
|
|
1241
1333
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1334
|
+
}
|
|
1335
|
+
// ==================== VECTOR DATABASE METHODS ====================
|
|
1336
|
+
/**
|
|
1337
|
+
* Create a new vector database configuration
|
|
1338
|
+
* @param data Vector database configuration
|
|
1339
|
+
* @param throwErrorIfExists Whether to throw error if vector config already exists
|
|
1340
|
+
*/
|
|
1341
|
+
async createVector(data, throwErrorIfExists = false) {
|
|
1342
|
+
if (!(await this.fetchVector(data.tag))) {
|
|
1343
|
+
await validators_1.CreateProductVectorSchema.validateAsync(data);
|
|
1344
|
+
const processedEnvs = [];
|
|
1345
|
+
for (const env of data.envs) {
|
|
1346
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1347
|
+
if (!exists) {
|
|
1348
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1249
1349
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1350
|
+
// Encrypt API key if provided
|
|
1351
|
+
if (env.apiKey) {
|
|
1352
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1353
|
+
}
|
|
1354
|
+
processedEnvs.push(env);
|
|
1355
|
+
}
|
|
1356
|
+
data.envs = processedEnvs;
|
|
1357
|
+
const envs = await this.fetchEnvs();
|
|
1358
|
+
for (const env of envs) {
|
|
1359
|
+
const exists = data.envs.findIndex((vecEnv) => vecEnv.slug === env.slug);
|
|
1360
|
+
if (exists === -1) {
|
|
1361
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide connection details`);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.VECTOR, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
if (throwErrorIfExists)
|
|
1368
|
+
throw new Error(`Vector ${data.tag} already exists`);
|
|
1252
1369
|
}
|
|
1253
1370
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1371
|
+
/**
|
|
1372
|
+
* Update an existing vector database configuration
|
|
1373
|
+
* @param tag Vector config tag
|
|
1374
|
+
* @param data Updated vector configuration
|
|
1375
|
+
*/
|
|
1376
|
+
async updateVector(tag, data) {
|
|
1377
|
+
try {
|
|
1378
|
+
const vector = await this.fetchVector(tag);
|
|
1379
|
+
if (!vector) {
|
|
1380
|
+
throw new Error(`Vector ${tag} not found`);
|
|
1262
1381
|
}
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
this.
|
|
1266
|
-
|
|
1267
|
-
env.auth.data = updates.data;
|
|
1382
|
+
const { _id, envs } = vector;
|
|
1383
|
+
await validators_1.UpdateProductVectorSchema.validateAsync(data);
|
|
1384
|
+
if (data.tag && (await this.fetchVector(data.tag))) {
|
|
1385
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
1268
1386
|
}
|
|
1269
|
-
if (
|
|
1270
|
-
|
|
1387
|
+
if (data.envs) {
|
|
1388
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
1389
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1390
|
+
if (!exists) {
|
|
1391
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1392
|
+
}
|
|
1393
|
+
// Encrypt API key if provided
|
|
1394
|
+
if (env.apiKey) {
|
|
1395
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1396
|
+
}
|
|
1397
|
+
return env;
|
|
1398
|
+
}));
|
|
1399
|
+
const overwrite = [];
|
|
1400
|
+
const newEnvs = [];
|
|
1401
|
+
data.envs.forEach((dataEnv) => {
|
|
1402
|
+
const existsIdx = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
1403
|
+
if (existsIdx === -1) {
|
|
1404
|
+
newEnvs.push(dataEnv);
|
|
1405
|
+
}
|
|
1406
|
+
else {
|
|
1407
|
+
overwrite.push(Object.assign(Object.assign({}, envs[existsIdx]), dataEnv));
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
const unchanged = [];
|
|
1411
|
+
envs.forEach((env) => {
|
|
1412
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1413
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1414
|
+
if (!newEnv && !overwriteEnv) {
|
|
1415
|
+
unchanged.push(env);
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1271
1419
|
}
|
|
1272
|
-
|
|
1273
|
-
}
|
|
1420
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({ _id }, vector), data), { component: enums_1.ProductComponents.VECTOR, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
1421
|
+
}
|
|
1422
|
+
catch (e) {
|
|
1423
|
+
throw e;
|
|
1424
|
+
}
|
|
1274
1425
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1426
|
+
/**
|
|
1427
|
+
* Fetch all vector database configurations
|
|
1428
|
+
* @param version Optional version
|
|
1429
|
+
*/
|
|
1430
|
+
async fetchVectors(version) {
|
|
1431
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'vector', this.getUserAccess());
|
|
1432
|
+
return components;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Fetch a specific vector database configuration by tag
|
|
1436
|
+
* @param tag Vector config tag
|
|
1437
|
+
* @param version Optional version
|
|
1438
|
+
*/
|
|
1439
|
+
async fetchVector(tag, version) {
|
|
1440
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'vector', tag, this.getUserAccess());
|
|
1441
|
+
return component;
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Delete a vector database configuration
|
|
1445
|
+
* @param tag Vector config tag
|
|
1446
|
+
*/
|
|
1447
|
+
async deleteVector(tag) {
|
|
1448
|
+
try {
|
|
1449
|
+
const vector = await this.fetchVector(tag);
|
|
1450
|
+
if (!vector) {
|
|
1451
|
+
throw new Error(`Vector with tag: ${tag} not found`);
|
|
1452
|
+
}
|
|
1453
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1454
|
+
tag,
|
|
1455
|
+
component: enums_1.ProductComponents.VECTOR,
|
|
1456
|
+
action: enums_1.RequestAction.DELETE,
|
|
1457
|
+
}, this.getUserAccess());
|
|
1280
1458
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
let headerSchema;
|
|
1284
|
-
let paramsSchema;
|
|
1285
|
-
let querySchema;
|
|
1286
|
-
let schema;
|
|
1287
|
-
if (exists.action_tag) {
|
|
1288
|
-
const action = actions.find((action) => action.tag === exists.action_tag);
|
|
1289
|
-
if (!action)
|
|
1290
|
-
throw new Error(`Auth action tag ${exists.action_tag} not found`);
|
|
1291
|
-
schema = action;
|
|
1459
|
+
catch (e) {
|
|
1460
|
+
throw e;
|
|
1292
1461
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1462
|
+
}
|
|
1463
|
+
// ==================== AGENT METHODS ====================
|
|
1464
|
+
/**
|
|
1465
|
+
* Create a new agent configuration
|
|
1466
|
+
* @param data Agent configuration data
|
|
1467
|
+
* @param throwErrorIfExists Whether to throw an error if agent already exists
|
|
1468
|
+
*/
|
|
1469
|
+
async createAgent(data, throwErrorIfExists = false) {
|
|
1470
|
+
if (!(await this.fetchAgent(data.tag))) {
|
|
1471
|
+
await validators_1.CreateProductAgentSchema.validateAsync(data);
|
|
1472
|
+
// Validate envs if provided
|
|
1473
|
+
if (data.envs) {
|
|
1474
|
+
for (const env of data.envs) {
|
|
1475
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1476
|
+
if (!exists) {
|
|
1477
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
// Validate that all product envs are configured
|
|
1482
|
+
const envs = await this.fetchEnvs();
|
|
1483
|
+
if (data.envs) {
|
|
1484
|
+
for (const env of envs) {
|
|
1485
|
+
const exists = data.envs.findIndex((agentEnv) => agentEnv.slug === env.slug);
|
|
1486
|
+
if (exists === -1) {
|
|
1487
|
+
// Auto-add missing envs with default config
|
|
1488
|
+
data.envs.push({ slug: env.slug, active: true });
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
else {
|
|
1493
|
+
// Initialize envs with all product envs
|
|
1494
|
+
data.envs = envs.map((env) => ({ slug: env.slug, active: true }));
|
|
1495
|
+
}
|
|
1496
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.AGENT, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1295
1497
|
}
|
|
1296
1498
|
else {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
bodySchema = schema.body;
|
|
1300
|
-
headerSchema = schema.headers;
|
|
1301
|
-
paramsSchema = schema.params;
|
|
1302
|
-
querySchema = schema.query;
|
|
1303
|
-
const { body, headers, params, query } = data;
|
|
1304
|
-
if (!body)
|
|
1305
|
-
throw new Error(`Auth body not allowed to be undefined. If empty set as {}`);
|
|
1306
|
-
if (!headers)
|
|
1307
|
-
throw new Error(`Auth headers not allowed to be undefined. If empty set as {}`);
|
|
1308
|
-
if (!params)
|
|
1309
|
-
throw new Error(`Auth params not allowed to be undefined. If empty set as {}`);
|
|
1310
|
-
if (!query)
|
|
1311
|
-
throw new Error(`Auth query not allowed to be undefined. If empty set as {}`);
|
|
1312
|
-
if (bodySchema && bodySchema.data) {
|
|
1313
|
-
const bodyValues = this.inputsService.parseData({
|
|
1314
|
-
data: body,
|
|
1315
|
-
category: enums_1.Categories.SETUP,
|
|
1316
|
-
expected: inputs_types_1.ExpectedValues.PARSEINPUT,
|
|
1317
|
-
type: enums_1.InputsTypes.JSON,
|
|
1318
|
-
});
|
|
1319
|
-
(0, inputs_utils_create_1.validateInputSchema)(bodyValues, bodySchema);
|
|
1499
|
+
if (throwErrorIfExists)
|
|
1500
|
+
throw new Error(`Agent ${data.tag} already exists`);
|
|
1320
1501
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Update an existing agent configuration
|
|
1505
|
+
* @param tag Agent tag
|
|
1506
|
+
* @param data Updated agent configuration
|
|
1507
|
+
*/
|
|
1508
|
+
async updateAgent(tag, data) {
|
|
1509
|
+
try {
|
|
1510
|
+
const agent = await this.fetchAgent(tag);
|
|
1511
|
+
if (!agent) {
|
|
1512
|
+
throw new Error(`Agent ${tag} not found`);
|
|
1513
|
+
}
|
|
1514
|
+
const { _id, envs } = agent;
|
|
1515
|
+
await validators_1.UpdateProductAgentSchema.validateAsync(data);
|
|
1516
|
+
if (data.tag && data.tag !== tag && (await this.fetchAgent(data.tag))) {
|
|
1517
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
1518
|
+
}
|
|
1519
|
+
if (data.envs) {
|
|
1520
|
+
// Validate that all provided envs exist
|
|
1521
|
+
for (const env of data.envs) {
|
|
1522
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1523
|
+
if (!exists) {
|
|
1524
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
const overwrite = [];
|
|
1528
|
+
const newEnvs = [];
|
|
1529
|
+
data.envs.forEach((dataEnv) => {
|
|
1530
|
+
var _a;
|
|
1531
|
+
const existsIdx = (_a = envs === null || envs === void 0 ? void 0 : envs.findIndex((env) => env.slug === dataEnv.slug)) !== null && _a !== void 0 ? _a : -1;
|
|
1532
|
+
if (existsIdx === -1) {
|
|
1533
|
+
newEnvs.push(dataEnv);
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
overwrite.push(Object.assign(Object.assign({}, envs[existsIdx]), dataEnv));
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
const unchanged = [];
|
|
1540
|
+
envs === null || envs === void 0 ? void 0 : envs.forEach((env) => {
|
|
1541
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1542
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1543
|
+
if (!newEnv && !overwriteEnv) {
|
|
1544
|
+
unchanged.push(env);
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1548
|
+
}
|
|
1549
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({ _id }, agent), data), { component: enums_1.ProductComponents.AGENT, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
1550
|
+
}
|
|
1551
|
+
catch (e) {
|
|
1552
|
+
throw e;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Fetch all agent configurations
|
|
1557
|
+
* @param version Optional version
|
|
1558
|
+
*/
|
|
1559
|
+
async fetchAgents(version) {
|
|
1560
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'agent', this.getUserAccess());
|
|
1561
|
+
return components;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Fetch a specific agent configuration by tag
|
|
1565
|
+
* @param tag Agent tag
|
|
1566
|
+
* @param version Optional version
|
|
1567
|
+
*/
|
|
1568
|
+
async fetchAgent(tag, version) {
|
|
1569
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'agent', tag, this.getUserAccess());
|
|
1570
|
+
return component;
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Delete an agent configuration
|
|
1574
|
+
* @param tag Agent tag
|
|
1575
|
+
*/
|
|
1576
|
+
async deleteAgent(tag) {
|
|
1577
|
+
try {
|
|
1578
|
+
const agent = await this.fetchAgent(tag);
|
|
1579
|
+
if (!agent) {
|
|
1580
|
+
throw new Error(`Agent with tag: ${tag} not found`);
|
|
1581
|
+
}
|
|
1582
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1583
|
+
tag,
|
|
1584
|
+
component: enums_1.ProductComponents.AGENT,
|
|
1585
|
+
action: enums_1.RequestAction.DELETE,
|
|
1586
|
+
}, this.getUserAccess());
|
|
1587
|
+
}
|
|
1588
|
+
catch (e) {
|
|
1589
|
+
throw e;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
// ==================== LLM MODEL METHODS ====================
|
|
1593
|
+
/**
|
|
1594
|
+
* Create a new LLM model configuration
|
|
1595
|
+
* API keys are automatically encrypted using the product's private key
|
|
1596
|
+
* @param data LLM model configuration
|
|
1597
|
+
* @param throwErrorIfExists Whether to throw error if model already exists
|
|
1598
|
+
*/
|
|
1599
|
+
async createModel(data, throwErrorIfExists = false) {
|
|
1600
|
+
if (!(await this.fetchModel(data.tag))) {
|
|
1601
|
+
await validators_1.CreateProductModelSchema.validateAsync(data);
|
|
1602
|
+
const processedEnvs = [];
|
|
1603
|
+
for (const env of data.envs) {
|
|
1604
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1605
|
+
if (!exists) {
|
|
1606
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1607
|
+
}
|
|
1608
|
+
// Encrypt API key if provided
|
|
1609
|
+
if (env.apiKey) {
|
|
1610
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1611
|
+
}
|
|
1612
|
+
processedEnvs.push(env);
|
|
1613
|
+
}
|
|
1614
|
+
data.envs = processedEnvs;
|
|
1615
|
+
const envs = await this.fetchEnvs();
|
|
1616
|
+
for (const env of envs) {
|
|
1617
|
+
const exists = data.envs.findIndex((modelEnv) => modelEnv.slug === env.slug);
|
|
1618
|
+
if (exists === -1) {
|
|
1619
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide API key configuration`);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.MODEL, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1623
|
+
}
|
|
1624
|
+
else {
|
|
1625
|
+
if (throwErrorIfExists)
|
|
1626
|
+
throw new Error(`Model ${data.tag} already exists`);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Update an existing LLM model configuration
|
|
1631
|
+
* @param tag Model tag
|
|
1632
|
+
* @param data Updated model configuration
|
|
1633
|
+
*/
|
|
1634
|
+
async updateModel(tag, data) {
|
|
1635
|
+
try {
|
|
1636
|
+
const model = await this.fetchModel(tag);
|
|
1637
|
+
if (!model) {
|
|
1638
|
+
throw new Error(`Model ${tag} not found`);
|
|
1639
|
+
}
|
|
1640
|
+
const { _id, envs } = model;
|
|
1641
|
+
await validators_1.UpdateProductModelSchema.validateAsync(data);
|
|
1642
|
+
if (data.tag && (await this.fetchModel(data.tag))) {
|
|
1643
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
1644
|
+
}
|
|
1645
|
+
if (data.envs) {
|
|
1646
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
1647
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1648
|
+
if (!exists) {
|
|
1649
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1650
|
+
}
|
|
1651
|
+
// Encrypt API key if provided
|
|
1652
|
+
if (env.apiKey) {
|
|
1653
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1654
|
+
}
|
|
1655
|
+
return env;
|
|
1656
|
+
}));
|
|
1657
|
+
const overwrite = [];
|
|
1658
|
+
const newEnvs = [];
|
|
1659
|
+
data.envs.forEach((dataEnv) => {
|
|
1660
|
+
const existsIdx = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
1661
|
+
if (existsIdx === -1) {
|
|
1662
|
+
newEnvs.push(dataEnv);
|
|
1663
|
+
}
|
|
1664
|
+
else {
|
|
1665
|
+
overwrite.push(Object.assign(Object.assign({}, envs[existsIdx]), dataEnv));
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
const unchanged = [];
|
|
1669
|
+
envs.forEach((env) => {
|
|
1670
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1671
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1672
|
+
if (!newEnv && !overwriteEnv) {
|
|
1673
|
+
unchanged.push(env);
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1677
|
+
}
|
|
1678
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({ _id }, model), data), { component: enums_1.ProductComponents.MODEL, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
1679
|
+
}
|
|
1680
|
+
catch (e) {
|
|
1681
|
+
throw e;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Fetch all LLM model configurations
|
|
1686
|
+
* @param version Optional version
|
|
1687
|
+
*/
|
|
1688
|
+
async fetchModels(version) {
|
|
1689
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'model', this.getUserAccess());
|
|
1690
|
+
return components;
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Fetch a specific LLM model configuration by tag
|
|
1694
|
+
* @param tag Model tag
|
|
1695
|
+
* @param version Optional version
|
|
1696
|
+
*/
|
|
1697
|
+
async fetchModel(tag, version) {
|
|
1698
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'model', tag, this.getUserAccess());
|
|
1699
|
+
return component;
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Delete an LLM model configuration
|
|
1703
|
+
* @param tag Model tag
|
|
1704
|
+
*/
|
|
1705
|
+
async deleteModel(tag) {
|
|
1706
|
+
try {
|
|
1707
|
+
const model = await this.fetchModel(tag);
|
|
1708
|
+
if (!model) {
|
|
1709
|
+
throw new Error(`Model with tag: ${tag} not found`);
|
|
1710
|
+
}
|
|
1711
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1712
|
+
tag,
|
|
1713
|
+
component: enums_1.ProductComponents.MODEL,
|
|
1714
|
+
action: enums_1.RequestAction.DELETE,
|
|
1715
|
+
}, this.getUserAccess());
|
|
1716
|
+
}
|
|
1717
|
+
catch (e) {
|
|
1718
|
+
throw e;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
async validateAppData(appData, app) {
|
|
1722
|
+
// TODO:
|
|
1723
|
+
const { envs } = app;
|
|
1724
|
+
// const { envs: appEnvs, auths: appAuths } = appData
|
|
1725
|
+
const version = appData.versions.find((data) => (data.latest = true));
|
|
1726
|
+
app.envs = this.validateAppEnvs(envs, version);
|
|
1727
|
+
// await this.validateAppAuth(auth, appData);
|
|
1728
|
+
return app;
|
|
1729
|
+
}
|
|
1730
|
+
validateVariablesSchema(variables, appVariables) {
|
|
1731
|
+
if (variables && variables.length) {
|
|
1732
|
+
variables.map((data) => {
|
|
1733
|
+
const appVar = appVariables.find((value) => value.key === data.key);
|
|
1734
|
+
if (!appVar) {
|
|
1735
|
+
throw new Error(`variable key: ${data.key} not found`);
|
|
1736
|
+
}
|
|
1737
|
+
// if()
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
validateVariablesValues(variables, appVariables) {
|
|
1742
|
+
if (!variables) {
|
|
1743
|
+
variables = [];
|
|
1744
|
+
}
|
|
1745
|
+
if (appVariables && appVariables.length) {
|
|
1746
|
+
appVariables.map((data) => {
|
|
1747
|
+
const find = variables.find((value) => value.key === data.key);
|
|
1748
|
+
if (data.required) {
|
|
1749
|
+
if (!find) {
|
|
1750
|
+
throw new Error(`variable key: ${data.key} is required`);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
this.inputsService.validateFeatureInputData(find, data);
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
validateAppEnvs(envs, version) {
|
|
1758
|
+
const { envs: appEnvs } = version;
|
|
1759
|
+
return envs.map((env) => {
|
|
1760
|
+
const { auth } = env;
|
|
1761
|
+
this.fetchEnv(env.product_env_slug);
|
|
1762
|
+
const appEnv = appEnvs.find((appEnv) => appEnv.slug === env.app_env_slug);
|
|
1763
|
+
if (!appEnv) {
|
|
1764
|
+
throw new Error(`app_slug ${env.app_env_slug} not found`);
|
|
1765
|
+
}
|
|
1766
|
+
const updates = this.validateAppAuth(auth, version);
|
|
1767
|
+
this.validateVariablesSchema(env.variables, version.variables);
|
|
1768
|
+
this.validateVariablesValues(env.variables, version.variables);
|
|
1769
|
+
if (updates && updates.data) {
|
|
1770
|
+
env.auth.data = updates.data;
|
|
1771
|
+
}
|
|
1772
|
+
if (updates && updates.values) {
|
|
1773
|
+
env.auth.values = updates.values;
|
|
1774
|
+
}
|
|
1775
|
+
return env;
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
validateAppAuth(auth, version) {
|
|
1779
|
+
const { auths: appAuth, actions } = version;
|
|
1780
|
+
const exists = appAuth.find((appAuth) => appAuth.tag === auth.auth_tag);
|
|
1781
|
+
if (!exists) {
|
|
1782
|
+
throw new Error(`app_auth ${auth.auth_tag} not found`);
|
|
1783
|
+
}
|
|
1784
|
+
const { data } = auth;
|
|
1785
|
+
let bodySchema;
|
|
1786
|
+
let headerSchema;
|
|
1787
|
+
let paramsSchema;
|
|
1788
|
+
let querySchema;
|
|
1789
|
+
let schema;
|
|
1790
|
+
if (exists.action_tag) {
|
|
1791
|
+
const action = actions.find((action) => action.tag === exists.action_tag);
|
|
1792
|
+
if (!action)
|
|
1793
|
+
throw new Error(`Auth action tag ${exists.action_tag} not found`);
|
|
1794
|
+
schema = action;
|
|
1795
|
+
}
|
|
1796
|
+
else if (exists.tokens) {
|
|
1797
|
+
schema = exists.tokens;
|
|
1798
|
+
}
|
|
1799
|
+
else {
|
|
1800
|
+
throw new Error('Invalid auth, create and use another');
|
|
1801
|
+
}
|
|
1802
|
+
bodySchema = schema.body;
|
|
1803
|
+
headerSchema = schema.headers;
|
|
1804
|
+
paramsSchema = schema.params;
|
|
1805
|
+
querySchema = schema.query;
|
|
1806
|
+
const { body, headers, params, query } = data;
|
|
1807
|
+
if (!body)
|
|
1808
|
+
throw new Error(`Auth body not allowed to be undefined. If empty set as {}`);
|
|
1809
|
+
if (!headers)
|
|
1810
|
+
throw new Error(`Auth headers not allowed to be undefined. If empty set as {}`);
|
|
1811
|
+
if (!params)
|
|
1812
|
+
throw new Error(`Auth params not allowed to be undefined. If empty set as {}`);
|
|
1813
|
+
if (!query)
|
|
1814
|
+
throw new Error(`Auth query not allowed to be undefined. If empty set as {}`);
|
|
1815
|
+
if (bodySchema && bodySchema.data) {
|
|
1816
|
+
const bodyValues = this.inputsService.parseData({
|
|
1817
|
+
data: body,
|
|
1818
|
+
category: enums_1.Categories.SETUP,
|
|
1819
|
+
expected: inputs_types_1.ExpectedValues.PARSEINPUT,
|
|
1820
|
+
type: enums_1.InputsTypes.JSON,
|
|
1821
|
+
});
|
|
1822
|
+
(0, inputs_utils_create_1.validateInputSchema)(bodyValues, bodySchema);
|
|
1823
|
+
}
|
|
1824
|
+
if (headerSchema && headerSchema.data) {
|
|
1825
|
+
const headerValues = this.inputsService.parseData({
|
|
1323
1826
|
data: headers,
|
|
1324
1827
|
category: enums_1.Categories.SETUP,
|
|
1325
1828
|
expected: inputs_types_1.ExpectedValues.PARSEINPUT,
|
|
@@ -1437,16 +1940,30 @@ class ProductsBuilderService {
|
|
|
1437
1940
|
}
|
|
1438
1941
|
}
|
|
1439
1942
|
async fetchApps() {
|
|
1440
|
-
|
|
1441
|
-
return app;
|
|
1943
|
+
return this.product.apps;
|
|
1442
1944
|
}
|
|
1443
1945
|
async fetchApp(tag, throwErrorIfExists = false) {
|
|
1444
|
-
const
|
|
1445
|
-
const app = apps.find((data) => data.app_tag === tag || data.access_tag === tag);
|
|
1946
|
+
const app = this.product.apps.find((data) => data.app_tag === tag || data.access_tag === tag);
|
|
1446
1947
|
if (!app && throwErrorIfExists)
|
|
1447
1948
|
throw new Error(`App ${tag} not found`);
|
|
1448
1949
|
return app;
|
|
1449
1950
|
}
|
|
1951
|
+
async deleteApp(tag) {
|
|
1952
|
+
try {
|
|
1953
|
+
const app = await this.fetchApp(tag, true);
|
|
1954
|
+
if (!app) {
|
|
1955
|
+
throw new Error(`App with tag: ${tag} not found`);
|
|
1956
|
+
}
|
|
1957
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1958
|
+
tag: app.access_tag,
|
|
1959
|
+
component: enums_1.ProductComponents.APP,
|
|
1960
|
+
action: enums_1.RequestAction.DELETE,
|
|
1961
|
+
}, this.getUserAccess());
|
|
1962
|
+
}
|
|
1963
|
+
catch (e) {
|
|
1964
|
+
throw e;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1450
1967
|
async createFunction(data, throwErrorIfExists = false) {
|
|
1451
1968
|
try {
|
|
1452
1969
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
@@ -1484,7 +2001,7 @@ class ProductsBuilderService {
|
|
|
1484
2001
|
}
|
|
1485
2002
|
const { _id } = func;
|
|
1486
2003
|
await validators_1.UpdateProductFunctionSchema.validateAsync(data); // Change to update;
|
|
1487
|
-
if (data.tag && await this.fetchFunction(data.tag)) {
|
|
2004
|
+
if (data.tag && (await this.fetchFunction(data.tag))) {
|
|
1488
2005
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
1489
2006
|
}
|
|
1490
2007
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({ _id }, func), data), { component: enums_1.ProductComponents.FUNCTION, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
@@ -1493,14 +2010,30 @@ class ProductsBuilderService {
|
|
|
1493
2010
|
throw e;
|
|
1494
2011
|
}
|
|
1495
2012
|
}
|
|
1496
|
-
async fetchFunctions() {
|
|
2013
|
+
async fetchFunctions(version) {
|
|
1497
2014
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'function', this.getUserAccess());
|
|
1498
2015
|
return components;
|
|
1499
2016
|
}
|
|
1500
|
-
async fetchFunction(tag) {
|
|
2017
|
+
async fetchFunction(tag, version) {
|
|
1501
2018
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'function', tag, this.getUserAccess());
|
|
1502
2019
|
return component;
|
|
1503
2020
|
}
|
|
2021
|
+
async deleteFunction(tag) {
|
|
2022
|
+
try {
|
|
2023
|
+
const func = await this.fetchFunction(tag);
|
|
2024
|
+
if (!func) {
|
|
2025
|
+
throw new Error(`Function with tag: ${tag} not found`);
|
|
2026
|
+
}
|
|
2027
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2028
|
+
tag,
|
|
2029
|
+
component: enums_1.ProductComponents.FUNCTION,
|
|
2030
|
+
action: enums_1.RequestAction.DELETE,
|
|
2031
|
+
}, this.getUserAccess());
|
|
2032
|
+
}
|
|
2033
|
+
catch (e) {
|
|
2034
|
+
throw e;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
1504
2037
|
async createCache(data, throwErrorIfExists = false) {
|
|
1505
2038
|
try {
|
|
1506
2039
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
@@ -1525,7 +2058,7 @@ class ProductsBuilderService {
|
|
|
1525
2058
|
}
|
|
1526
2059
|
const { _id } = cache;
|
|
1527
2060
|
await validators_1.UpdateProductCacheSchema.validateAsync(data); // Change to update;
|
|
1528
|
-
if (data.tag && await this.fetchCache(data.tag)) {
|
|
2061
|
+
if (data.tag && (await this.fetchCache(data.tag))) {
|
|
1529
2062
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
1530
2063
|
}
|
|
1531
2064
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id }, data), { component: enums_1.ProductComponents.CACHE, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
@@ -1534,14 +2067,30 @@ class ProductsBuilderService {
|
|
|
1534
2067
|
throw e;
|
|
1535
2068
|
}
|
|
1536
2069
|
}
|
|
1537
|
-
async fetchCaches() {
|
|
2070
|
+
async fetchCaches(version) {
|
|
1538
2071
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'cache', this.getUserAccess());
|
|
1539
2072
|
return components;
|
|
1540
2073
|
}
|
|
1541
|
-
async fetchCache(tag) {
|
|
2074
|
+
async fetchCache(tag, version) {
|
|
1542
2075
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'cache', tag, this.getUserAccess());
|
|
1543
2076
|
return component;
|
|
1544
2077
|
}
|
|
2078
|
+
async deleteCache(tag) {
|
|
2079
|
+
try {
|
|
2080
|
+
const cache = await this.fetchCache(tag);
|
|
2081
|
+
if (!cache) {
|
|
2082
|
+
throw new Error(`Cache with tag: ${tag} not found`);
|
|
2083
|
+
}
|
|
2084
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2085
|
+
tag,
|
|
2086
|
+
component: enums_1.ProductComponents.CACHE,
|
|
2087
|
+
action: enums_1.RequestAction.DELETE,
|
|
2088
|
+
}, this.getUserAccess());
|
|
2089
|
+
}
|
|
2090
|
+
catch (e) {
|
|
2091
|
+
throw e;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
1545
2094
|
async createNotification(data, throwErrorIfExists = false) {
|
|
1546
2095
|
try {
|
|
1547
2096
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
@@ -1565,9 +2114,7 @@ class ProductsBuilderService {
|
|
|
1565
2114
|
callbacks: data.envs[i].callbacks
|
|
1566
2115
|
? (0, processor_utils_1.encrypt)(JSON.stringify(data.envs[i].callbacks), this.product.private_key)
|
|
1567
2116
|
: undefined,
|
|
1568
|
-
sms: data.envs[i].sms
|
|
1569
|
-
? (0, processor_utils_1.encrypt)(JSON.stringify(data.envs[i].sms), this.product.private_key)
|
|
1570
|
-
: undefined,
|
|
2117
|
+
sms: data.envs[i].sms ? (0, processor_utils_1.encrypt)(JSON.stringify(data.envs[i].sms), this.product.private_key) : undefined,
|
|
1571
2118
|
};
|
|
1572
2119
|
data.envs[i] = Object.assign(Object.assign({}, data.envs[i]), updates);
|
|
1573
2120
|
}
|
|
@@ -1653,14 +2200,14 @@ class ProductsBuilderService {
|
|
|
1653
2200
|
return message;
|
|
1654
2201
|
}
|
|
1655
2202
|
async fetchNotificationMessages(notificationTag, throwErrorIfExists = false) {
|
|
1656
|
-
const notification =
|
|
2203
|
+
const notification = this.product.notifications.find((data) => data.tag === notificationTag);
|
|
1657
2204
|
if (!notification)
|
|
1658
2205
|
throw new Error(`Notification ${notificationTag} not found`);
|
|
1659
2206
|
return notification.messages;
|
|
1660
2207
|
}
|
|
1661
2208
|
async updateNotificationMessage(data) {
|
|
1662
2209
|
try {
|
|
1663
|
-
console.log(
|
|
2210
|
+
console.log('NOTIFICATION DATA!!', data);
|
|
1664
2211
|
await update_productNotificationMessage_validator_1.default.validateAsync(data);
|
|
1665
2212
|
if (!data.tag) {
|
|
1666
2213
|
throw new Error('tag field is required');
|
|
@@ -1770,48 +2317,32 @@ class ProductsBuilderService {
|
|
|
1770
2317
|
throw e;
|
|
1771
2318
|
}
|
|
1772
2319
|
}
|
|
1773
|
-
async fetchNotifications() {
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
return notification.envs.map((data) => {
|
|
1777
|
-
if (data.callbacks && typeof data.callbacks == 'string') {
|
|
1778
|
-
data.callbacks = JSON.parse((0, processor_utils_1.decrypt)(String(data.callbacks), this.product.private_key));
|
|
1779
|
-
}
|
|
1780
|
-
if (data.push_notifications && typeof data.push_notifications == 'string') {
|
|
1781
|
-
data.push_notifications = JSON.parse((0, processor_utils_1.decrypt)(String(data.push_notifications), this.product.private_key));
|
|
1782
|
-
}
|
|
1783
|
-
if (data.emails && typeof data.emails == 'string') {
|
|
1784
|
-
data.emails = JSON.parse((0, processor_utils_1.decrypt)(String(data.emails), this.product.private_key));
|
|
1785
|
-
}
|
|
1786
|
-
if (data.sms && typeof data.sms == 'string') {
|
|
1787
|
-
data.sms = JSON.parse((0, processor_utils_1.decrypt)(String(data.sms), this.product.private_key));
|
|
1788
|
-
}
|
|
1789
|
-
return data;
|
|
1790
|
-
});
|
|
1791
|
-
});
|
|
1792
|
-
return notifications;
|
|
2320
|
+
async fetchNotifications(version) {
|
|
2321
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'notification', this.getUserAccess());
|
|
2322
|
+
return components;
|
|
1793
2323
|
}
|
|
1794
|
-
async fetchNotification(tag) {
|
|
2324
|
+
async fetchNotification(tag, version) {
|
|
1795
2325
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'notification', tag, this.getUserAccess());
|
|
1796
|
-
component.envs.map((data) => {
|
|
1797
|
-
if (data.callbacks && typeof data.callbacks == 'string') {
|
|
1798
|
-
data.callbacks = JSON.parse((0, processor_utils_1.decrypt)(String(data.callbacks), this.product.private_key));
|
|
1799
|
-
}
|
|
1800
|
-
if (data.push_notifications && typeof data.push_notifications == 'string') {
|
|
1801
|
-
data.push_notifications = JSON.parse((0, processor_utils_1.decrypt)(String(data.push_notifications), this.product.private_key));
|
|
1802
|
-
}
|
|
1803
|
-
if (data.emails && typeof data.emails == 'string') {
|
|
1804
|
-
data.emails = JSON.parse((0, processor_utils_1.decrypt)(String(data.emails), this.product.private_key));
|
|
1805
|
-
}
|
|
1806
|
-
if (data.sms && typeof data.sms == 'string') {
|
|
1807
|
-
data.sms = JSON.parse((0, processor_utils_1.decrypt)(String(data.sms), this.product.private_key));
|
|
1808
|
-
}
|
|
1809
|
-
return data;
|
|
1810
|
-
});
|
|
1811
2326
|
return component;
|
|
1812
2327
|
}
|
|
1813
|
-
|
|
1814
|
-
|
|
2328
|
+
async deleteNotification(tag) {
|
|
2329
|
+
try {
|
|
2330
|
+
const notification = await this.fetchNotification(tag);
|
|
2331
|
+
if (!notification) {
|
|
2332
|
+
throw new Error(`Notification with tag: ${tag} not found`);
|
|
2333
|
+
}
|
|
2334
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2335
|
+
tag,
|
|
2336
|
+
component: enums_1.ProductComponents.NOTIFICATION,
|
|
2337
|
+
action: enums_1.RequestAction.DELETE,
|
|
2338
|
+
}, this.getUserAccess());
|
|
2339
|
+
}
|
|
2340
|
+
catch (e) {
|
|
2341
|
+
throw e;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
validateFeatureSequence(array) {
|
|
2345
|
+
// Validate uniqueness of sequence_tag
|
|
1815
2346
|
const uniqueTags = new Set();
|
|
1816
2347
|
for (const item of array) {
|
|
1817
2348
|
if (uniqueTags.has(item.tag)) {
|
|
@@ -1908,7 +2439,7 @@ class ProductsBuilderService {
|
|
|
1908
2439
|
await this.validateActionDataInput(data, action, event.input, event_index, sequence_index);
|
|
1909
2440
|
}
|
|
1910
2441
|
async checkAndValidateFunctionDataInput(data, sequence_index, event, event_index) {
|
|
1911
|
-
const func = await this.fetchFunction(event.event);
|
|
2442
|
+
const func = (await this.fetchFunction(event.event));
|
|
1912
2443
|
await this.validateActionDataInput(data, func, event.input, event_index, sequence_index);
|
|
1913
2444
|
}
|
|
1914
2445
|
async checkAndValidateDBActionDataInput(data, sequence_index, event, event_index) {
|
|
@@ -1959,9 +2490,6 @@ class ProductsBuilderService {
|
|
|
1959
2490
|
if (job.type === productsBuilder_types_1.JobEventTypes.PUBLISH) {
|
|
1960
2491
|
await this.checkAndValidatePublishDataInput(data, sequence_index, event, event_index);
|
|
1961
2492
|
}
|
|
1962
|
-
if (job.type === productsBuilder_types_1.JobEventTypes.FUNCTION) {
|
|
1963
|
-
await this.checkAndValidateFunctionDataInput(data, sequence_index, event, event_index);
|
|
1964
|
-
}
|
|
1965
2493
|
}
|
|
1966
2494
|
async checkAndValidateFallbackDataInput(data, sequence_index, event, event_index) { }
|
|
1967
2495
|
async validateEvent(data, sequence_index, event, event_index) {
|
|
@@ -2203,7 +2731,7 @@ class ProductsBuilderService {
|
|
|
2203
2731
|
throw new Error(`option event index ${optionIndex}, ${data.type} should not be ${obj}`);
|
|
2204
2732
|
}
|
|
2205
2733
|
}
|
|
2206
|
-
if (sequence &&
|
|
2734
|
+
if (sequence && Object.values(obj).length > 0 && ((_b = data.sample.data) === null || _b === void 0 ? void 0 : _b.length) === 0) {
|
|
2207
2735
|
if (!option) {
|
|
2208
2736
|
throw new Error(`sequence ${sequence.tag} event ${sequence.events[data.event_index].event} ${data.type} should be an empty object`);
|
|
2209
2737
|
}
|
|
@@ -2456,7 +2984,7 @@ class ProductsBuilderService {
|
|
|
2456
2984
|
}
|
|
2457
2985
|
const decrypted = JSON.parse((0, processor_utils_1.decrypt)(env.auth.values, this.product.private_key));
|
|
2458
2986
|
// Convert stages to string[] for findFaultyKeys
|
|
2459
|
-
const stringStages = stages.slice(1).map(stage => String(stage));
|
|
2987
|
+
const stringStages = stages.slice(1).map((stage) => String(stage));
|
|
2460
2988
|
const check = (0, objects_utils_1.findFaultyKeys)(stringStages, decrypted);
|
|
2461
2989
|
if (check.faultyKeys) {
|
|
2462
2990
|
throw new Error(`Auth Key(s) ${check.faultyKeys.join(', ')} is/are invalid, they do not exist in authorization for ${env.product_env_slug} on app ${access_tag}`);
|
|
@@ -2847,6 +3375,22 @@ class ProductsBuilderService {
|
|
|
2847
3375
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'feature', tag, this.getUserAccess());
|
|
2848
3376
|
return component;
|
|
2849
3377
|
}
|
|
3378
|
+
async deleteFeature(tag) {
|
|
3379
|
+
try {
|
|
3380
|
+
const feature = await this.fetchFeature(tag);
|
|
3381
|
+
if (!feature) {
|
|
3382
|
+
throw new Error(`Feature with tag: ${tag} not found`);
|
|
3383
|
+
}
|
|
3384
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3385
|
+
tag,
|
|
3386
|
+
component: enums_1.ProductComponents.FEATURE,
|
|
3387
|
+
action: enums_1.RequestAction.DELETE,
|
|
3388
|
+
}, this.getUserAccess());
|
|
3389
|
+
}
|
|
3390
|
+
catch (e) {
|
|
3391
|
+
throw e;
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
2850
3394
|
async createDatabase(data, throwErrorIfExists = false) {
|
|
2851
3395
|
try {
|
|
2852
3396
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
@@ -2936,21 +3480,42 @@ class ProductsBuilderService {
|
|
|
2936
3480
|
}
|
|
2937
3481
|
async fetchDatabases() {
|
|
2938
3482
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'database', this.getUserAccess());
|
|
2939
|
-
components.map((
|
|
2940
|
-
|
|
2941
|
-
|
|
3483
|
+
const decryptedComponents = components.map((component) => {
|
|
3484
|
+
const dbComponent = component;
|
|
3485
|
+
const decryptedEnvs = dbComponent.envs.map((env) => {
|
|
3486
|
+
return Object.assign(Object.assign({}, env), { connection_url: (0, processor_utils_1.decrypt)(env.connection_url, this.product.private_key) });
|
|
2942
3487
|
});
|
|
3488
|
+
return Object.assign(Object.assign({}, dbComponent), { envs: decryptedEnvs });
|
|
2943
3489
|
});
|
|
2944
|
-
return
|
|
3490
|
+
return decryptedComponents;
|
|
2945
3491
|
}
|
|
2946
3492
|
async fetchDatabase(tag) {
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
3493
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'database', tag, this.getUserAccess());
|
|
3494
|
+
if (component) {
|
|
3495
|
+
const decryptedEnvs = component.envs.map((env) => {
|
|
3496
|
+
return Object.assign(Object.assign({}, env), { connection_url: (0, processor_utils_1.decrypt)(env.connection_url, this.product.private_key) });
|
|
3497
|
+
});
|
|
3498
|
+
return Object.assign(Object.assign({}, component), { envs: decryptedEnvs });
|
|
3499
|
+
}
|
|
3500
|
+
return component;
|
|
2952
3501
|
}
|
|
2953
|
-
|
|
3502
|
+
async deleteDatabase(tag) {
|
|
3503
|
+
try {
|
|
3504
|
+
const database = await this.fetchDatabase(tag);
|
|
3505
|
+
if (!database) {
|
|
3506
|
+
throw new Error(`Database with tag: ${tag} not found`);
|
|
3507
|
+
}
|
|
3508
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3509
|
+
tag,
|
|
3510
|
+
component: enums_1.ProductComponents.DATABASE,
|
|
3511
|
+
action: enums_1.RequestAction.DELETE,
|
|
3512
|
+
}, this.getUserAccess());
|
|
3513
|
+
}
|
|
3514
|
+
catch (e) {
|
|
3515
|
+
throw e;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
// GRAPH CRUD METHODS
|
|
2954
3519
|
async createGraph(data, throwErrorIfExists = false) {
|
|
2955
3520
|
try {
|
|
2956
3521
|
if (!(await this.fetchGraph(data.tag))) {
|
|
@@ -2991,47 +3556,45 @@ class ProductsBuilderService {
|
|
|
2991
3556
|
}
|
|
2992
3557
|
const { _id, envs } = graph;
|
|
2993
3558
|
await validators_1.UpdateProductGraphSchema.validateAsync(data);
|
|
2994
|
-
if (data.tag &&
|
|
2995
|
-
throw new Error(`tag ${
|
|
3559
|
+
if (data.tag && this.fetchGraph(data.tag)) {
|
|
3560
|
+
throw new Error(`tag ${tag} is in use`);
|
|
2996
3561
|
}
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
if (
|
|
3016
|
-
|
|
3017
|
-
throw new Error(`connection_url is required for new env ${dataEnv.slug}`);
|
|
3018
|
-
}
|
|
3019
|
-
newEnvs.push(dataEnv);
|
|
3020
|
-
}
|
|
3021
|
-
else {
|
|
3022
|
-
overwrite.push(Object.assign(Object.assign({}, envs[existsIndex]), dataEnv));
|
|
3023
|
-
}
|
|
3024
|
-
});
|
|
3025
|
-
const unchanged = [];
|
|
3026
|
-
envs.map((env) => {
|
|
3027
|
-
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
3028
|
-
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
3029
|
-
if (!newEnv && !overwriteEnv) {
|
|
3030
|
-
unchanged.push(env);
|
|
3562
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
3563
|
+
const exists = await this.fetchEnv(env.slug);
|
|
3564
|
+
if (!exists) {
|
|
3565
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
3566
|
+
}
|
|
3567
|
+
if (env.connection_url) {
|
|
3568
|
+
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
3569
|
+
}
|
|
3570
|
+
return env;
|
|
3571
|
+
}));
|
|
3572
|
+
const overwrite = [];
|
|
3573
|
+
const newEnvs = [];
|
|
3574
|
+
data.envs.map((dataEnv) => {
|
|
3575
|
+
const exists = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
3576
|
+
if (!this.fetchEnv(dataEnv.slug)) {
|
|
3577
|
+
throw new Error(`Product Environment ${dataEnv.slug} doesn't exist`);
|
|
3578
|
+
}
|
|
3579
|
+
if (exists === -1) {
|
|
3580
|
+
if (!dataEnv.connection_url) {
|
|
3581
|
+
throw new Error(`connection_url is required for new env ${data.envs[exists].slug}`);
|
|
3031
3582
|
}
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3583
|
+
newEnvs.push(dataEnv);
|
|
3584
|
+
}
|
|
3585
|
+
else {
|
|
3586
|
+
overwrite.push(Object.assign(Object.assign({}, envs[exists]), dataEnv));
|
|
3587
|
+
}
|
|
3588
|
+
});
|
|
3589
|
+
const unchanged = [];
|
|
3590
|
+
envs.map((env) => {
|
|
3591
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
3592
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
3593
|
+
if (!newEnv && !overwriteEnv) {
|
|
3594
|
+
unchanged.push(env);
|
|
3595
|
+
}
|
|
3596
|
+
});
|
|
3597
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
3035
3598
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id }, data), { tag, component: enums_1.ProductComponents.GRAPH, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
3036
3599
|
}
|
|
3037
3600
|
catch (e) {
|
|
@@ -3040,126 +3603,129 @@ class ProductsBuilderService {
|
|
|
3040
3603
|
}
|
|
3041
3604
|
async fetchGraphs() {
|
|
3042
3605
|
const components = await this.productApi.fetchProductComponents(this.product_id, 'graph', this.getUserAccess());
|
|
3043
|
-
components.map((graph) => {
|
|
3044
|
-
graph.envs.map((env) => {
|
|
3045
|
-
env.connection_url = (0, processor_utils_1.decrypt)(env.connection_url, this.product.private_key);
|
|
3046
|
-
});
|
|
3047
|
-
});
|
|
3048
3606
|
return components;
|
|
3049
3607
|
}
|
|
3050
3608
|
async fetchGraph(tag) {
|
|
3051
|
-
const
|
|
3052
|
-
|
|
3053
|
-
graph.envs.map((env) => {
|
|
3054
|
-
env.connection_url = (0, processor_utils_1.decrypt)(env.connection_url, this.product.private_key);
|
|
3055
|
-
});
|
|
3056
|
-
}
|
|
3057
|
-
return graph;
|
|
3609
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'graph', tag, this.getUserAccess());
|
|
3610
|
+
return component;
|
|
3058
3611
|
}
|
|
3059
|
-
|
|
3060
|
-
async createGraphAction(data, throwErrorIfExists = false) {
|
|
3061
|
-
var _a;
|
|
3612
|
+
async deleteGraph(tag) {
|
|
3062
3613
|
try {
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
const [graphTag, tag] = data.tag.split(':');
|
|
3067
|
-
if (!graphTag || !tag) {
|
|
3068
|
-
throw new Error('tag should be formatted as graph_tag:action_tag');
|
|
3614
|
+
const graph = await this.fetchGraph(tag);
|
|
3615
|
+
if (!graph) {
|
|
3616
|
+
throw new Error(`Graph with tag: ${tag} not found`);
|
|
3069
3617
|
}
|
|
3618
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3619
|
+
tag,
|
|
3620
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
3621
|
+
action: enums_1.RequestAction.DELETE,
|
|
3622
|
+
}, this.getUserAccess());
|
|
3623
|
+
}
|
|
3624
|
+
catch (e) {
|
|
3625
|
+
throw e;
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
// ==================== GRAPH ACTIONS ====================
|
|
3629
|
+
async createGraphAction(graphTag, data) {
|
|
3630
|
+
try {
|
|
3070
3631
|
const graph = await this.fetchGraph(graphTag);
|
|
3071
3632
|
if (!graph) {
|
|
3072
|
-
throw new Error(`Graph ${graphTag} not found`);
|
|
3633
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
3634
|
+
}
|
|
3635
|
+
// Initialize actions array if it doesn't exist
|
|
3636
|
+
if (!graph.actions) {
|
|
3637
|
+
graph.actions = [];
|
|
3073
3638
|
}
|
|
3074
|
-
|
|
3639
|
+
// Check if action already exists
|
|
3640
|
+
const existingAction = graph.actions.find((a) => a.tag === data.tag);
|
|
3075
3641
|
if (existingAction) {
|
|
3076
|
-
|
|
3077
|
-
throw new Error(`Graph action ${data.tag} already exists`);
|
|
3078
|
-
}
|
|
3079
|
-
return;
|
|
3642
|
+
throw new Error(`Action with tag: ${data.tag} already exists`);
|
|
3080
3643
|
}
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
let filterData, filterTemplate;
|
|
3089
|
-
if (data.filterTemplate) {
|
|
3090
|
-
filterData = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.filterTemplate));
|
|
3091
|
-
filterTemplate = JSON.stringify(data.filterTemplate);
|
|
3092
|
-
}
|
|
3093
|
-
const actionData = Object.assign(Object.assign({}, data), { tag, data: values, template,
|
|
3094
|
-
filterData,
|
|
3095
|
-
filterTemplate });
|
|
3096
|
-
graph.actions = graph.actions || [];
|
|
3097
|
-
graph.actions.push(actionData);
|
|
3098
|
-
await this.updateGraph(graphTag, { actions: graph.actions });
|
|
3644
|
+
graph.actions.push(data);
|
|
3645
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3646
|
+
tag: graphTag,
|
|
3647
|
+
actions: graph.actions,
|
|
3648
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
3649
|
+
action: enums_1.RequestAction.UPDATE,
|
|
3650
|
+
}, this.getUserAccess());
|
|
3099
3651
|
}
|
|
3100
|
-
catch (
|
|
3101
|
-
throw
|
|
3652
|
+
catch (e) {
|
|
3653
|
+
throw e;
|
|
3102
3654
|
}
|
|
3103
3655
|
}
|
|
3104
|
-
async updateGraphAction(data) {
|
|
3105
|
-
var _a;
|
|
3656
|
+
async updateGraphAction(graphTag, actionTag, data) {
|
|
3106
3657
|
try {
|
|
3107
|
-
if (!data.tag) {
|
|
3108
|
-
throw new Error('tag field is required');
|
|
3109
|
-
}
|
|
3110
|
-
const [graphTag, tag] = data.tag.split(':');
|
|
3111
|
-
if (!graphTag || !tag) {
|
|
3112
|
-
throw new Error('tag should be formatted as graph_tag:action_tag');
|
|
3113
|
-
}
|
|
3114
3658
|
const graph = await this.fetchGraph(graphTag);
|
|
3115
3659
|
if (!graph) {
|
|
3116
|
-
throw new Error(`Graph ${graphTag} not found`);
|
|
3660
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
3117
3661
|
}
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
throw new Error(`Graph action ${data.tag} not found`);
|
|
3121
|
-
}
|
|
3122
|
-
// Validate the update data
|
|
3123
|
-
const validationData = Object.assign(Object.assign({}, data), { tag });
|
|
3124
|
-
await update_productGraphAction_validator_1.default.validateAsync(validationData);
|
|
3125
|
-
// Process template if provided
|
|
3126
|
-
const updateData = Object.assign(Object.assign({}, data), { tag });
|
|
3127
|
-
if (data.template) {
|
|
3128
|
-
updateData.data = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.template));
|
|
3129
|
-
updateData.template = JSON.stringify(data.template);
|
|
3662
|
+
if (!graph.actions) {
|
|
3663
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
3130
3664
|
}
|
|
3131
|
-
|
|
3132
|
-
if (
|
|
3133
|
-
|
|
3134
|
-
updateData.filterTemplate = JSON.stringify(data.filterTemplate);
|
|
3665
|
+
const actionIndex = graph.actions.findIndex((a) => a.tag === actionTag);
|
|
3666
|
+
if (actionIndex === -1) {
|
|
3667
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
3135
3668
|
}
|
|
3136
|
-
graph.actions[actionIndex] = Object.assign(Object.assign({}, graph.actions[actionIndex]),
|
|
3137
|
-
await this.
|
|
3669
|
+
graph.actions[actionIndex] = Object.assign(Object.assign({}, graph.actions[actionIndex]), data);
|
|
3670
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3671
|
+
tag: graphTag,
|
|
3672
|
+
actions: graph.actions,
|
|
3673
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
3674
|
+
action: enums_1.RequestAction.UPDATE,
|
|
3675
|
+
}, this.getUserAccess());
|
|
3138
3676
|
}
|
|
3139
|
-
catch (
|
|
3140
|
-
throw
|
|
3677
|
+
catch (e) {
|
|
3678
|
+
throw e;
|
|
3141
3679
|
}
|
|
3142
3680
|
}
|
|
3143
|
-
async fetchGraphAction(
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
throw new Error(`Graph action ${tag} not found`);
|
|
3155
|
-
return action || null;
|
|
3681
|
+
async fetchGraphAction(graphTag, actionTag) {
|
|
3682
|
+
try {
|
|
3683
|
+
const graph = await this.fetchGraph(graphTag);
|
|
3684
|
+
if (!graph || !graph.actions) {
|
|
3685
|
+
return null;
|
|
3686
|
+
}
|
|
3687
|
+
return graph.actions.find((a) => a.tag === actionTag) || null;
|
|
3688
|
+
}
|
|
3689
|
+
catch (e) {
|
|
3690
|
+
throw e;
|
|
3691
|
+
}
|
|
3156
3692
|
}
|
|
3157
3693
|
async fetchGraphActions(graphTag) {
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3694
|
+
try {
|
|
3695
|
+
const graph = await this.fetchGraph(graphTag);
|
|
3696
|
+
if (!graph) {
|
|
3697
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
3698
|
+
}
|
|
3699
|
+
return graph.actions || [];
|
|
3700
|
+
}
|
|
3701
|
+
catch (e) {
|
|
3702
|
+
throw e;
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
async deleteGraphAction(graphTag, actionTag) {
|
|
3706
|
+
try {
|
|
3707
|
+
const graph = await this.fetchGraph(graphTag);
|
|
3708
|
+
if (!graph) {
|
|
3709
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
3710
|
+
}
|
|
3711
|
+
if (!graph.actions) {
|
|
3712
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
3713
|
+
}
|
|
3714
|
+
const actionIndex = graph.actions.findIndex((a) => a.tag === actionTag);
|
|
3715
|
+
if (actionIndex === -1) {
|
|
3716
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
3717
|
+
}
|
|
3718
|
+
graph.actions.splice(actionIndex, 1);
|
|
3719
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3720
|
+
tag: graphTag,
|
|
3721
|
+
actions: graph.actions,
|
|
3722
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
3723
|
+
action: enums_1.RequestAction.UPDATE,
|
|
3724
|
+
}, this.getUserAccess());
|
|
3725
|
+
}
|
|
3726
|
+
catch (e) {
|
|
3727
|
+
throw e;
|
|
3161
3728
|
}
|
|
3162
|
-
return graph.actions || [];
|
|
3163
3729
|
}
|
|
3164
3730
|
async createDatabaseAction(data, throwErrorIfExists = false) {
|
|
3165
3731
|
try {
|
|
@@ -3173,18 +3739,27 @@ class ProductsBuilderService {
|
|
|
3173
3739
|
const exists = await this.fetchDatabaseAction(data.tag);
|
|
3174
3740
|
data.tag = tag;
|
|
3175
3741
|
if (!exists) {
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3742
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
3743
|
+
let values, template;
|
|
3744
|
+
if (database.type === productsBuilder_types_1.DatabaseTypes.MONGODB) {
|
|
3745
|
+
await create_productDatabaseAction_validator_1.NOSQLDatabaseActionsSchema.validateAsync(data);
|
|
3746
|
+
values = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.template));
|
|
3747
|
+
template = JSON.stringify(data.template);
|
|
3748
|
+
if (data.type === productsBuilder_types_1.DatabaseActionTypes.UPDATE && !data.filterTemplate) {
|
|
3749
|
+
throw new Error(`filterTemplate is required for ${productsBuilder_types_1.DatabaseActionTypes.UPDATE} actions in ${productsBuilder_types_1.DatabaseTypes.MONGODB}`);
|
|
3750
|
+
}
|
|
3751
|
+
if (data.filterTemplate) {
|
|
3752
|
+
data.filterData = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.filterTemplate));
|
|
3753
|
+
data.filterTemplate = JSON.stringify(data.filterTemplate);
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
else {
|
|
3757
|
+
create_productDatabaseAction_validator_1.SQLDatabaseActionSchema.validateAsync(data);
|
|
3758
|
+
values = (0, string_utils_1.extractPlaceholders)(String(data.template));
|
|
3759
|
+
template = data.template;
|
|
3760
|
+
if (data.filterTemplate) {
|
|
3761
|
+
data.filterData = (0, string_utils_1.extractPlaceholders)(String(data.filterTemplate));
|
|
3762
|
+
}
|
|
3188
3763
|
}
|
|
3189
3764
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { data: values, template,
|
|
3190
3765
|
databaseTag, component: enums_1.ProductComponents.DATABASE_ACTION, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
@@ -3224,27 +3799,32 @@ class ProductsBuilderService {
|
|
|
3224
3799
|
if (!databaseTag || !tag) {
|
|
3225
3800
|
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
3226
3801
|
}
|
|
3227
|
-
// Fetch required data
|
|
3228
|
-
await this.fetchDatabase(databaseTag);
|
|
3802
|
+
// Fetch required data
|
|
3803
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
3229
3804
|
const action = await this.fetchDatabaseAction(data.tag, true);
|
|
3230
3805
|
// Construct payload
|
|
3231
3806
|
const payload = Object.assign(Object.assign(Object.assign({}, action), data), { databaseTag, component: enums_1.ProductComponents.DATABASE_ACTION, action: enums_1.RequestAction.UPDATE });
|
|
3232
3807
|
// Validate and process the template
|
|
3233
3808
|
data.tag = tag;
|
|
3234
|
-
// Validate using the unified schema
|
|
3235
|
-
const validationData = Object.assign(Object.assign({}, data), { tag });
|
|
3236
|
-
await update_productDatabaseAction_validator_1.default.validateAsync(validationData);
|
|
3237
3809
|
if (data.template) {
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3810
|
+
let values, template;
|
|
3811
|
+
if (database.type === productsBuilder_types_1.DatabaseTypes.MONGODB) {
|
|
3812
|
+
await update_productDatabaseAction_validator_1.UpdateNOSQLDatabaseActionsSchema.validateAsync(data);
|
|
3813
|
+
values = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.template));
|
|
3814
|
+
template = JSON.stringify(data.template);
|
|
3815
|
+
}
|
|
3816
|
+
else {
|
|
3817
|
+
await update_productDatabaseAction_validator_1.UpdateSQLDatabaseActionSchema.validateAsync(data);
|
|
3818
|
+
values = (0, string_utils_1.extractPlaceholders)(String(data.template));
|
|
3819
|
+
template = data.template;
|
|
3820
|
+
}
|
|
3241
3821
|
Object.assign(payload, { data: values, template });
|
|
3242
3822
|
}
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3823
|
+
else if (database.type === productsBuilder_types_1.DatabaseTypes.MONGODB) {
|
|
3824
|
+
await update_productDatabaseAction_validator_1.UpdateNOSQLDatabaseActionsSchema.validateAsync(data);
|
|
3825
|
+
}
|
|
3826
|
+
else {
|
|
3827
|
+
await update_productDatabaseAction_validator_1.UpdateSQLDatabaseActionSchema.validateAsync(data);
|
|
3248
3828
|
}
|
|
3249
3829
|
// Update product and reinitialize
|
|
3250
3830
|
await this.productApi.updateProduct(this.product_id, payload, this.getUserAccess());
|
|
@@ -3254,7 +3834,7 @@ class ProductsBuilderService {
|
|
|
3254
3834
|
}
|
|
3255
3835
|
}
|
|
3256
3836
|
async fetchDatabaseActions(databaseTag) {
|
|
3257
|
-
const database =
|
|
3837
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
3258
3838
|
if (!database)
|
|
3259
3839
|
throw new Error(`Database ${databaseTag} not found`);
|
|
3260
3840
|
const actions = database.actions;
|
|
@@ -3265,6 +3845,27 @@ class ProductsBuilderService {
|
|
|
3265
3845
|
}
|
|
3266
3846
|
return actions;
|
|
3267
3847
|
}
|
|
3848
|
+
async deleteDatabaseAction(tag) {
|
|
3849
|
+
try {
|
|
3850
|
+
const [databaseTag, actionTag] = tag.split(':');
|
|
3851
|
+
if (!databaseTag || !actionTag) {
|
|
3852
|
+
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
3853
|
+
}
|
|
3854
|
+
const action = await this.fetchDatabaseAction(tag, true);
|
|
3855
|
+
if (!action) {
|
|
3856
|
+
throw new Error(`Database action with tag: ${tag} not found`);
|
|
3857
|
+
}
|
|
3858
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3859
|
+
tag: actionTag,
|
|
3860
|
+
databaseTag,
|
|
3861
|
+
component: enums_1.ProductComponents.DATABASE_ACTION,
|
|
3862
|
+
action: enums_1.RequestAction.DELETE,
|
|
3863
|
+
}, this.getUserAccess());
|
|
3864
|
+
}
|
|
3865
|
+
catch (e) {
|
|
3866
|
+
throw e;
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3268
3869
|
async createDatabaseMigration(data, throwErrorIfExists) {
|
|
3269
3870
|
if (!data.tag) {
|
|
3270
3871
|
throw new Error('tag field is required');
|
|
@@ -3273,20 +3874,47 @@ class ProductsBuilderService {
|
|
|
3273
3874
|
if (!databaseTag || !tag) {
|
|
3274
3875
|
throw new Error(`tag is expected to be defined as "database_tag:migration_tag"`);
|
|
3275
3876
|
}
|
|
3276
|
-
const exists = this.fetchDatabaseMigration(data.tag);
|
|
3877
|
+
const exists = await this.fetchDatabaseMigration(data.tag);
|
|
3277
3878
|
data.tag = tag;
|
|
3278
|
-
await create_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
3879
|
+
await create_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
3279
3880
|
if (!exists) {
|
|
3280
3881
|
const database = await this.fetchDatabase(databaseTag);
|
|
3281
3882
|
if (database.type === productsBuilder_types_1.DatabaseTypes.MONGODB) {
|
|
3282
3883
|
throw new Error(`${database.type} does not support migrations`);
|
|
3283
3884
|
}
|
|
3284
|
-
|
|
3885
|
+
// Process migration value - supports both simple strings and rich operations
|
|
3886
|
+
let processedValue = data.value;
|
|
3887
|
+
if (data.value) {
|
|
3888
|
+
processedValue = {
|
|
3889
|
+
up: this.processMigrationOperations(data.value.up),
|
|
3890
|
+
down: this.processMigrationOperations(data.value.down),
|
|
3891
|
+
};
|
|
3892
|
+
}
|
|
3893
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { value: processedValue, databaseTag, component: enums_1.ProductComponents.DATABASE_MIGRATION }), this.getUserAccess());
|
|
3285
3894
|
}
|
|
3286
3895
|
else {
|
|
3287
3896
|
if (throwErrorIfExists)
|
|
3288
|
-
throw new Error(`Database
|
|
3289
|
-
}
|
|
3897
|
+
throw new Error(`Database Migration ${data.tag} already exists`);
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
/**
|
|
3901
|
+
* Process migration operations - handles both string and object formats
|
|
3902
|
+
* Strings are passed through as-is (raw SQL/CQL)
|
|
3903
|
+
* Objects are serialized for storage and executed by the migration engine
|
|
3904
|
+
*/
|
|
3905
|
+
processMigrationOperations(operations) {
|
|
3906
|
+
if (!operations || !Array.isArray(operations))
|
|
3907
|
+
return [];
|
|
3908
|
+
return operations.map((op) => {
|
|
3909
|
+
if (typeof op === 'string') {
|
|
3910
|
+
return op; // Raw SQL/CQL string
|
|
3911
|
+
}
|
|
3912
|
+
// Rich operation object - validate it has required 'type' field
|
|
3913
|
+
if (typeof op === 'object' && op !== null && 'type' in op) {
|
|
3914
|
+
return op;
|
|
3915
|
+
}
|
|
3916
|
+
throw new Error(`Invalid migration operation format. Expected string or object with 'type' field.`);
|
|
3917
|
+
});
|
|
3290
3918
|
}
|
|
3291
3919
|
async updateDatabaseMigration(data) {
|
|
3292
3920
|
if (!data.tag) {
|
|
@@ -3296,20 +3924,28 @@ class ProductsBuilderService {
|
|
|
3296
3924
|
if (!databaseTag || !tag) {
|
|
3297
3925
|
throw new Error(`tag is expected to be defined as "database_tag:migration_tag"`);
|
|
3298
3926
|
}
|
|
3299
|
-
await update_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
3300
|
-
const
|
|
3301
|
-
if (!
|
|
3927
|
+
await update_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
3928
|
+
const existing = await this.fetchDatabaseMigration(data.tag);
|
|
3929
|
+
if (!existing) {
|
|
3302
3930
|
throw new Error(`Migration ${data.tag} not found`);
|
|
3303
3931
|
}
|
|
3304
3932
|
data.tag = tag;
|
|
3305
|
-
|
|
3933
|
+
// Process migration value if provided - supports both simple strings and rich operations
|
|
3934
|
+
let processedValue = data.value;
|
|
3935
|
+
if (data.value) {
|
|
3936
|
+
processedValue = {
|
|
3937
|
+
up: this.processMigrationOperations(data.value.up),
|
|
3938
|
+
down: this.processMigrationOperations(data.value.down),
|
|
3939
|
+
};
|
|
3940
|
+
}
|
|
3941
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({}, existing), data), { value: processedValue || existing.value, databaseTag, component: enums_1.ProductComponents.DATABASE_MIGRATION }), this.getUserAccess());
|
|
3306
3942
|
}
|
|
3307
3943
|
async fetchDatabaseMigration(tag, throwError = false) {
|
|
3308
3944
|
const [databaseTag, migrationTag] = tag.split(':');
|
|
3309
3945
|
if (!databaseTag || !migrationTag) {
|
|
3310
3946
|
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
3311
3947
|
}
|
|
3312
|
-
const database =
|
|
3948
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
3313
3949
|
if (!database)
|
|
3314
3950
|
throw new Error(`Database ${databaseTag} not found`);
|
|
3315
3951
|
const migration = database.migrations.find((data) => data.tag === migrationTag);
|
|
@@ -3318,12 +3954,125 @@ class ProductsBuilderService {
|
|
|
3318
3954
|
return migration;
|
|
3319
3955
|
}
|
|
3320
3956
|
async fetchDatabaseMigrations(databaseTag) {
|
|
3321
|
-
const database =
|
|
3957
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
3322
3958
|
if (!database)
|
|
3323
3959
|
throw new Error(`Database ${databaseTag} not found`);
|
|
3324
3960
|
const migrations = database.migrations;
|
|
3325
3961
|
return migrations;
|
|
3326
3962
|
}
|
|
3963
|
+
async deleteDatabaseMigration(tag) {
|
|
3964
|
+
try {
|
|
3965
|
+
const [databaseTag, migrationTag] = tag.split(':');
|
|
3966
|
+
if (!databaseTag || !migrationTag) {
|
|
3967
|
+
throw new Error(`tag is expected to be defined as "database_tag:migration_tag"`);
|
|
3968
|
+
}
|
|
3969
|
+
const migration = await this.fetchDatabaseMigration(tag, true);
|
|
3970
|
+
if (!migration) {
|
|
3971
|
+
throw new Error(`Database migration with tag: ${tag} not found`);
|
|
3972
|
+
}
|
|
3973
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3974
|
+
tag: migrationTag,
|
|
3975
|
+
databaseTag,
|
|
3976
|
+
component: enums_1.ProductComponents.DATABASE_MIGRATION,
|
|
3977
|
+
action: enums_1.RequestAction.DELETE,
|
|
3978
|
+
}, this.getUserAccess());
|
|
3979
|
+
}
|
|
3980
|
+
catch (e) {
|
|
3981
|
+
throw e;
|
|
3982
|
+
}
|
|
3983
|
+
}
|
|
3984
|
+
// ==================== DATABASE TRIGGER CRUD ====================
|
|
3985
|
+
async createDatabaseTrigger(data, throwErrorIfExists = false) {
|
|
3986
|
+
try {
|
|
3987
|
+
if (!data.tag) {
|
|
3988
|
+
throw new Error('tag field is required');
|
|
3989
|
+
}
|
|
3990
|
+
const [databaseTag, triggerTag] = data.tag.split(':');
|
|
3991
|
+
if (!databaseTag || !triggerTag) {
|
|
3992
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
3993
|
+
}
|
|
3994
|
+
const exists = await this.fetchDatabaseTrigger(data.tag);
|
|
3995
|
+
if (exists) {
|
|
3996
|
+
if (throwErrorIfExists) {
|
|
3997
|
+
throw new Error(`Database trigger with tag: ${data.tag} already exists`);
|
|
3998
|
+
}
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
4002
|
+
if (!database) {
|
|
4003
|
+
throw new Error(`Database ${databaseTag} not found`);
|
|
4004
|
+
}
|
|
4005
|
+
// Initialize triggers array if not present
|
|
4006
|
+
if (!database.triggers) {
|
|
4007
|
+
database.triggers = [];
|
|
4008
|
+
}
|
|
4009
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { tag: triggerTag, databaseTag, component: enums_1.ProductComponents.DATABASE_TRIGGER, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
4010
|
+
}
|
|
4011
|
+
catch (e) {
|
|
4012
|
+
throw e;
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
async updateDatabaseTrigger(data) {
|
|
4016
|
+
try {
|
|
4017
|
+
if (!data.tag) {
|
|
4018
|
+
throw new Error('tag field is required');
|
|
4019
|
+
}
|
|
4020
|
+
const [databaseTag, triggerTag] = data.tag.split(':');
|
|
4021
|
+
if (!databaseTag || !triggerTag) {
|
|
4022
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4023
|
+
}
|
|
4024
|
+
const exists = await this.fetchDatabaseTrigger(data.tag, true);
|
|
4025
|
+
if (!exists) {
|
|
4026
|
+
throw new Error(`Database trigger with tag: ${data.tag} not found`);
|
|
4027
|
+
}
|
|
4028
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { tag: triggerTag, databaseTag, component: enums_1.ProductComponents.DATABASE_TRIGGER, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
4029
|
+
}
|
|
4030
|
+
catch (e) {
|
|
4031
|
+
throw e;
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
async fetchDatabaseTrigger(tag, throwError = false) {
|
|
4035
|
+
const [databaseTag, triggerTag] = tag.split(':');
|
|
4036
|
+
if (!databaseTag || !triggerTag) {
|
|
4037
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4038
|
+
}
|
|
4039
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
4040
|
+
if (!database)
|
|
4041
|
+
throw new Error(`Database ${databaseTag} not found`);
|
|
4042
|
+
const triggers = database.triggers || [];
|
|
4043
|
+
const trigger = triggers.find((data) => data.tag === triggerTag);
|
|
4044
|
+
if (!trigger && throwError)
|
|
4045
|
+
throw new Error(`Database trigger ${tag} not found`);
|
|
4046
|
+
return trigger || null;
|
|
4047
|
+
}
|
|
4048
|
+
async fetchDatabaseTriggers(databaseTag) {
|
|
4049
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
4050
|
+
if (!database)
|
|
4051
|
+
throw new Error(`Database ${databaseTag} not found`);
|
|
4052
|
+
const triggers = database.triggers || [];
|
|
4053
|
+
return triggers;
|
|
4054
|
+
}
|
|
4055
|
+
async deleteDatabaseTrigger(tag) {
|
|
4056
|
+
try {
|
|
4057
|
+
const [databaseTag, triggerTag] = tag.split(':');
|
|
4058
|
+
if (!databaseTag || !triggerTag) {
|
|
4059
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4060
|
+
}
|
|
4061
|
+
const trigger = await this.fetchDatabaseTrigger(tag, true);
|
|
4062
|
+
if (!trigger) {
|
|
4063
|
+
throw new Error(`Database trigger with tag: ${tag} not found`);
|
|
4064
|
+
}
|
|
4065
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4066
|
+
tag: triggerTag,
|
|
4067
|
+
databaseTag,
|
|
4068
|
+
component: enums_1.ProductComponents.DATABASE_TRIGGER,
|
|
4069
|
+
action: enums_1.RequestAction.DELETE,
|
|
4070
|
+
}, this.getUserAccess());
|
|
4071
|
+
}
|
|
4072
|
+
catch (e) {
|
|
4073
|
+
throw e;
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
3327
4076
|
async validateJobEvent(data) {
|
|
3328
4077
|
const { type, app, event } = data;
|
|
3329
4078
|
if (type === productsBuilder_types_1.JobEventTypes.ACTION) {
|
|
@@ -3343,12 +4092,6 @@ class ProductsBuilderService {
|
|
|
3343
4092
|
throw new Error(`Database action ${event} not found`);
|
|
3344
4093
|
}
|
|
3345
4094
|
}
|
|
3346
|
-
if (type === productsBuilder_types_1.JobEventTypes.FUNCTION) {
|
|
3347
|
-
const found = await this.fetchFunction(event);
|
|
3348
|
-
if (!found) {
|
|
3349
|
-
throw new Error(`Cloud function ${event} not found`);
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
4095
|
if (type === productsBuilder_types_1.JobEventTypes.STORAGE) {
|
|
3353
4096
|
const found = await this.fetchStorage(event);
|
|
3354
4097
|
if (!found) {
|
|
@@ -3405,7 +4148,7 @@ class ProductsBuilderService {
|
|
|
3405
4148
|
}
|
|
3406
4149
|
async updateJob(tag, data) {
|
|
3407
4150
|
try {
|
|
3408
|
-
const job =
|
|
4151
|
+
const job = this.fetchJob(tag);
|
|
3409
4152
|
if (!job) {
|
|
3410
4153
|
throw new Error(`Job ${tag} not found`);
|
|
3411
4154
|
}
|
|
@@ -3428,6 +4171,99 @@ class ProductsBuilderService {
|
|
|
3428
4171
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'job', tag, this.getUserAccess());
|
|
3429
4172
|
return component;
|
|
3430
4173
|
}
|
|
4174
|
+
async deleteJob(tag) {
|
|
4175
|
+
try {
|
|
4176
|
+
const job = await this.fetchJob(tag);
|
|
4177
|
+
if (!job) {
|
|
4178
|
+
throw new Error(`Job with tag: ${tag} not found`);
|
|
4179
|
+
}
|
|
4180
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4181
|
+
tag,
|
|
4182
|
+
component: enums_1.ProductComponents.JOB,
|
|
4183
|
+
action: enums_1.RequestAction.DELETE,
|
|
4184
|
+
}, this.getUserAccess());
|
|
4185
|
+
}
|
|
4186
|
+
catch (e) {
|
|
4187
|
+
throw e;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
// ==================== WORKFLOW CRUD METHODS ====================
|
|
4191
|
+
async createWorkflow(data, throwErrorIfExists = false) {
|
|
4192
|
+
try {
|
|
4193
|
+
if (!(await this.fetchWorkflow(data.tag))) {
|
|
4194
|
+
// Validate required fields
|
|
4195
|
+
if (!data.name || !data.tag) {
|
|
4196
|
+
throw new Error('Workflow requires name and tag');
|
|
4197
|
+
}
|
|
4198
|
+
// Validate envs if provided
|
|
4199
|
+
if (data.envs && data.envs.length > 0) {
|
|
4200
|
+
for (const env of data.envs) {
|
|
4201
|
+
const exists = await this.fetchEnv(env.slug);
|
|
4202
|
+
if (!exists) {
|
|
4203
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.WORKFLOW, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
4208
|
+
}
|
|
4209
|
+
else {
|
|
4210
|
+
if (throwErrorIfExists)
|
|
4211
|
+
throw new Error(`Workflow ${data.tag} already exists`);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
catch (e) {
|
|
4215
|
+
throw e;
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
async updateWorkflow(tag, data) {
|
|
4219
|
+
try {
|
|
4220
|
+
const workflow = await this.fetchWorkflow(tag);
|
|
4221
|
+
if (!workflow) {
|
|
4222
|
+
throw new Error(`Workflow ${tag} not found`);
|
|
4223
|
+
}
|
|
4224
|
+
const { _id } = workflow;
|
|
4225
|
+
if (data.tag && data.tag !== tag && (await this.fetchWorkflow(data.tag))) {
|
|
4226
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
4227
|
+
}
|
|
4228
|
+
// Validate envs if provided
|
|
4229
|
+
if (data.envs && data.envs.length > 0) {
|
|
4230
|
+
for (const env of data.envs) {
|
|
4231
|
+
const exists = await this.fetchEnv(env.slug);
|
|
4232
|
+
if (!exists) {
|
|
4233
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id }, data), { tag, component: enums_1.ProductComponents.WORKFLOW, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
4238
|
+
}
|
|
4239
|
+
catch (e) {
|
|
4240
|
+
throw e;
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
async fetchWorkflows() {
|
|
4244
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'workflow', this.getUserAccess());
|
|
4245
|
+
return components;
|
|
4246
|
+
}
|
|
4247
|
+
async fetchWorkflow(tag) {
|
|
4248
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'workflow', tag, this.getUserAccess());
|
|
4249
|
+
return component;
|
|
4250
|
+
}
|
|
4251
|
+
async deleteWorkflow(tag) {
|
|
4252
|
+
try {
|
|
4253
|
+
const workflow = await this.fetchWorkflow(tag);
|
|
4254
|
+
if (!workflow) {
|
|
4255
|
+
throw new Error(`Workflow with tag: ${tag} not found`);
|
|
4256
|
+
}
|
|
4257
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4258
|
+
tag,
|
|
4259
|
+
component: enums_1.ProductComponents.WORKFLOW,
|
|
4260
|
+
action: enums_1.RequestAction.DELETE,
|
|
4261
|
+
}, this.getUserAccess());
|
|
4262
|
+
}
|
|
4263
|
+
catch (e) {
|
|
4264
|
+
throw e;
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
3431
4267
|
getUserAccess() {
|
|
3432
4268
|
return {
|
|
3433
4269
|
user_id: this.user_id,
|