@ductape/sdk 0.0.4-v6 → 0.0.4-v60
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/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 +310 -0
- package/dist/agents/agents.service.js +1249 -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 +1227 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.d.ts +51 -5
- package/dist/api/services/appApi.service.js +101 -3
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/pricingApi.service.d.ts +10 -0
- package/dist/api/services/pricingApi.service.js +34 -0
- package/dist/api/services/pricingApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +334 -2
- package/dist/api/services/processorApi.service.js +264 -2
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +108 -1
- package/dist/api/services/productsApi.service.js +150 -3
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +50 -0
- package/dist/api/services/secretsApi.service.js +124 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- 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.d.ts +8 -0
- package/dist/api/services/workspaceApi.service.js +20 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +65 -1
- package/dist/api/urls.js +90 -18
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/auth.utils.d.ts +1 -3
- package/dist/api/utils/auth.utils.js.map +1 -1
- package/dist/api/utils/cache.utils.d.ts +1 -1
- package/dist/api/utils/cache.utils.js +2 -2
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/api/utils/strings.utils.d.ts +2 -0
- package/dist/api/utils/strings.utils.js +14 -0
- package/dist/api/utils/strings.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +41 -33
- package/dist/apps/services/app.service.js +472 -184
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +429 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js +21 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +289 -0
- package/dist/brokers/brokers.service.js +722 -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 +314 -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 +23 -0
- package/dist/brokers/utils/providers/kafka.service.js +131 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +15 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +151 -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/clients/pricing.client.d.ts +3 -0
- package/dist/clients/pricing.client.js +33 -0
- package/dist/clients/pricing.client.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +393 -0
- package/dist/database/adapters/base.adapter.js +150 -0
- package/dist/database/adapters/base.adapter.js.map +1 -0
- package/dist/database/adapters/cassandra.adapter.d.ts +91 -0
- package/dist/database/adapters/cassandra.adapter.js +1075 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +109 -0
- package/dist/database/adapters/dynamodb.adapter.js +1534 -0
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +120 -0
- package/dist/database/adapters/mongodb.adapter.js +1253 -0
- package/dist/database/adapters/mongodb.adapter.js.map +1 -0
- package/dist/database/adapters/mysql.adapter.d.ts +85 -0
- package/dist/database/adapters/mysql.adapter.js +1313 -0
- package/dist/database/adapters/mysql.adapter.js.map +1 -0
- package/dist/database/adapters/postgresql.adapter.d.ts +88 -0
- package/dist/database/adapters/postgresql.adapter.js +1434 -0
- package/dist/database/adapters/postgresql.adapter.js.map +1 -0
- package/dist/database/databases.service.d.ts +1388 -0
- package/dist/database/databases.service.js +2821 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +46 -0
- package/dist/database/index.js +109 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +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 +67 -0
- package/dist/database/operators/aggregation-builder.js +841 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +59 -0
- package/dist/database/operators/query-builder.js +397 -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 +185 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/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 +14 -0
- package/dist/database/types/index.js +31 -0
- package/dist/database/types/index.js.map +1 -0
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +205 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +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 +216 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +86 -0
- package/dist/graph/adapters/arangodb.adapter.js +1522 -0
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
- package/dist/graph/adapters/base.adapter.d.ts +245 -0
- package/dist/graph/adapters/base.adapter.js +64 -0
- package/dist/graph/adapters/base.adapter.js.map +1 -0
- package/dist/graph/adapters/index.d.ts +11 -0
- package/dist/graph/adapters/index.js +21 -0
- package/dist/graph/adapters/index.js.map +1 -0
- package/dist/graph/adapters/memgraph.adapter.d.ts +110 -0
- package/dist/graph/adapters/memgraph.adapter.js +1345 -0
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
- package/dist/graph/adapters/neo4j.adapter.d.ts +81 -0
- package/dist/graph/adapters/neo4j.adapter.js +1198 -0
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
- package/dist/graph/adapters/neptune.adapter.d.ts +82 -0
- package/dist/graph/adapters/neptune.adapter.js +1313 -0
- package/dist/graph/adapters/neptune.adapter.js.map +1 -0
- package/dist/graph/graphs.service.d.ts +546 -0
- package/dist/graph/graphs.service.js +1893 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +57 -0
- package/dist/graph/index.js +77 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +149 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +13 -0
- package/dist/graph/types/index.js +20 -0
- package/dist/graph/types/index.js.map +1 -0
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +175 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/imports/imports.service.d.ts +3 -3
- package/dist/imports/imports.service.js +8 -7
- package/dist/imports/imports.service.js.map +1 -1
- package/dist/imports/imports.types.d.ts +8 -0
- package/dist/imports/repos/openApi.repo.d.ts +1 -1
- package/dist/imports/repos/openApi.repo.js +414 -47
- package/dist/imports/repos/openApi.repo.js.map +1 -1
- package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
- package/dist/imports/repos/postmanV21.repo.js +126 -83
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +3239 -285
- package/dist/index.js +4705 -687
- 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/inputs/inputs.service.d.ts +1 -1
- package/dist/inputs/inputs.service.js +2 -2
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/inputs/utils/inputs.utils.create.js +1 -1
- package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.types.d.ts +16 -1
- package/dist/logs/logs.types.js +5 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +257 -0
- package/dist/notifications/notifications.service.js +656 -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/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +27 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
- package/dist/parsers/pipelines/postman.pipelines.js +103 -0
- package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
- package/dist/parsers/types/postman.types.d.ts +200 -0
- package/dist/parsers/types/postman.types.js +3 -0
- package/dist/parsers/types/postman.types.js.map +1 -0
- package/dist/parsers/utils/postman.utils.d.ts +12 -0
- package/dist/parsers/utils/postman.utils.js +116 -0
- package/dist/parsers/utils/postman.utils.js.map +1 -0
- package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
- package/dist/parsers/validators/postman-auth.validators.js +127 -0
- package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
- package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-request.validators.js +139 -0
- package/dist/parsers/validators/postman-request.validators.js.map +1 -0
- package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-response.validators.js +150 -0
- package/dist/parsers/validators/postman-response.validators.js.map +1 -0
- package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
- package/dist/parsers/validators/postman-variable.validators.js +163 -0
- package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
- package/dist/pricing/pricing.repo.js +1 -0
- package/dist/pricing/pricing.repo.js.map +1 -0
- package/dist/pricing/pricing.service.d.ts +24 -0
- package/dist/pricing/pricing.service.js +51 -0
- package/dist/pricing/pricing.service.js.map +1 -0
- package/dist/pricing/pricing.types.d.ts +76 -0
- package/dist/pricing/pricing.types.js +21 -0
- package/dist/pricing/pricing.types.js.map +1 -0
- package/dist/pricing/utils/string.utils.d.ts +1 -0
- package/dist/pricing/utils/string.utils.js +9 -0
- package/dist/pricing/utils/string.utils.js.map +1 -0
- package/dist/processor/services/processor.service.d.ts +120 -73
- package/dist/processor/services/processor.service.js +1705 -1294
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/request.service.d.ts +36 -0
- package/dist/processor/services/request.service.js +304 -0
- package/dist/processor/services/request.service.js.map +1 -0
- package/dist/processor/types/request.types.d.ts +14 -0
- package/dist/processor/types/request.types.js +3 -0
- package/dist/processor/types/request.types.js.map +1 -0
- package/dist/processor/utils/processor.utils.d.ts +3 -0
- package/dist/processor/utils/processor.utils.js +87 -21
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/processor/utils/request.utils.d.ts +20 -0
- package/dist/processor/utils/request.utils.js +113 -0
- package/dist/processor/utils/request.utils.js.map +1 -0
- package/dist/products/services/products.service.d.ts +330 -77
- package/dist/products/services/products.service.js +2586 -397
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/utils/string.utils.d.ts +1 -1
- package/dist/products/utils/string.utils.js +14 -2
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +7 -1
- package/dist/products/validators/index.js +16 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +266 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +89 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +81 -25
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +133 -45
- 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.dataValue.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
- package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +88 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
- package/dist/resilience/fallback.service.d.ts +140 -0
- package/dist/resilience/fallback.service.js +764 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +159 -0
- package/dist/resilience/healthcheck.service.js +943 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +82 -0
- package/dist/resilience/quota.service.js +516 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +98 -0
- package/dist/resilience/resilience.service.js +560 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +513 -0
- package/dist/resilience/types/index.js +29 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +93 -0
- package/dist/secrets/secrets.service.js +258 -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 +151 -0
- package/dist/storage/storage.service.js +522 -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 +11 -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.broker.kafka.js +172 -0
- package/dist/test/test.broker.kafka.js.map +1 -0
- package/dist/test/test.broker.nats.js +193 -0
- package/dist/test/test.broker.nats.js.map +1 -0
- package/dist/test/test.broker.pubsub.js +171 -0
- package/dist/test/test.broker.pubsub.js.map +1 -0
- package/dist/test/test.broker.rabbitmq.js +164 -0
- package/dist/test/test.broker.rabbitmq.js.map +1 -0
- package/dist/test/test.broker.redis.js +168 -0
- package/dist/test/test.broker.redis.js.map +1 -0
- package/dist/test/test.broker.sqs.d.ts +1 -0
- package/dist/test/test.broker.sqs.js +158 -0
- package/dist/test/test.broker.sqs.js.map +1 -0
- package/dist/test/test.caches.d.ts +1 -0
- package/dist/test/test.caches.js +231 -0
- package/dist/test/test.caches.js.map +1 -0
- package/dist/test/test.database.d.ts +1 -0
- package/dist/test/test.database.dynamo.d.ts +1 -0
- package/dist/test/test.database.dynamo.js +265 -0
- package/dist/test/test.database.dynamo.js.map +1 -0
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.database.mongo.d.ts +1 -0
- package/dist/test/test.database.mongo.js +371 -0
- package/dist/test/test.database.mongo.js.map +1 -0
- package/dist/test/test.database.mysql.d.ts +1 -0
- package/dist/test/test.database.mysql.js +415 -0
- package/dist/test/test.database.mysql.js.map +1 -0
- package/dist/test/test.database.postgres.d.ts +1 -0
- package/dist/test/test.database.postgres.js +412 -0
- package/dist/test/test.database.postgres.js.map +1 -0
- package/dist/test/test.email.brevo.d.ts +1 -0
- package/dist/test/test.email.brevo.js +326 -0
- package/dist/test/test.email.brevo.js.map +1 -0
- package/dist/test/test.email.mailgun.d.ts +1 -0
- package/dist/test/test.email.mailgun.js +352 -0
- package/dist/test/test.email.mailgun.js.map +1 -0
- package/dist/test/test.email.postmark.d.ts +1 -0
- package/dist/test/test.email.postmark.js +316 -0
- package/dist/test/test.email.postmark.js.map +1 -0
- package/dist/test/test.email.sendgrid.d.ts +1 -0
- package/dist/test/test.email.sendgrid.js +365 -0
- package/dist/test/test.email.sendgrid.js.map +1 -0
- package/dist/test/test.email.smtp.d.ts +1 -0
- package/dist/test/test.email.smtp.js +323 -0
- package/dist/test/test.email.smtp.js.map +1 -0
- package/dist/test/test.graph.arangodb.d.ts +1 -0
- package/dist/test/test.graph.arangodb.js +358 -0
- package/dist/test/test.graph.arangodb.js.map +1 -0
- package/dist/test/test.graph.memgraph.d.ts +1 -0
- package/dist/test/test.graph.memgraph.js +320 -0
- package/dist/test/test.graph.memgraph.js.map +1 -0
- package/dist/test/test.graph.neo4j.d.ts +1 -0
- package/dist/test/test.graph.neo4j.js +218 -0
- package/dist/test/test.graph.neo4j.js.map +1 -0
- package/dist/test/test.graph.neptune.d.ts +1 -0
- package/dist/test/test.graph.neptune.js +331 -0
- package/dist/test/test.graph.neptune.js.map +1 -0
- package/dist/test/test.health.js +1 -0
- package/dist/test/test.health.js.map +1 -0
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1459
- 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.js +14 -55
- 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.notifications.d.ts +1 -0
- package/dist/test/test.notifications.js +198 -0
- package/dist/test/test.notifications.js.map +1 -0
- package/dist/test/test.notifiers.js +1 -0
- package/dist/test/test.notifiers.js.map +1 -0
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -122
- 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.js +1 -0
- package/dist/test/test.products.js.map +1 -0
- package/dist/test/test.push.expo.d.ts +1 -0
- package/dist/test/test.push.expo.js +442 -0
- package/dist/test/test.push.expo.js.map +1 -0
- package/dist/test/test.push.firebase.d.ts +1 -0
- package/dist/test/test.push.firebase.js +409 -0
- package/dist/test/test.push.firebase.js.map +1 -0
- package/dist/test/test.session.d.ts +1 -0
- package/dist/test/test.session.js +299 -0
- package/dist/test/test.session.js.map +1 -0
- package/dist/test/test.sms.nexmo.d.ts +1 -0
- package/dist/test/test.sms.nexmo.js +278 -0
- package/dist/test/test.sms.nexmo.js.map +1 -0
- package/dist/test/test.sms.twilio.d.ts +1 -0
- package/dist/test/test.sms.twilio.js +275 -0
- package/dist/test/test.sms.twilio.js.map +1 -0
- package/dist/test/test.storage.d.ts +1 -0
- package/dist/test/test.storage.js +202 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.d.ts +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/test/test.vector.pinecone.d.ts +1 -0
- package/dist/test/test.vector.pinecone.js +238 -0
- package/dist/test/test.vector.pinecone.js.map +1 -0
- package/dist/test/test.vector.qdrant.d.ts +1 -0
- package/dist/test/test.vector.qdrant.js +307 -0
- package/dist/test/test.vector.qdrant.js.map +1 -0
- package/dist/test/test.vector.weaviate.d.ts +1 -0
- package/dist/test/test.vector.weaviate.js +325 -0
- package/dist/test/test.vector.weaviate.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +10 -13
- package/dist/types/enums.d.ts +11 -1
- package/dist/types/enums.js +10 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +6 -4
- package/dist/types/index.types.js +0 -1
- package/dist/types/index.types.js.map +1 -1
- package/dist/types/pricing.types.d.ts +4 -0
- package/dist/types/pricing.types.js +3 -0
- package/dist/types/pricing.types.js.map +1 -0
- package/dist/types/processor.types.d.ts +245 -20
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +906 -24
- package/dist/types/productsBuilder.types.js +173 -2
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/request-tracker.interface.js +1 -0
- package/dist/types/request-tracker.interface.js.map +1 -0
- package/dist/types/requests.types.d.ts +2 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +24 -52
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/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 +116 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +408 -0
- package/dist/vector/vector-database.service.js +545 -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 +384 -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 +208 -0
- package/dist/workflows/workflow-executor.js +1194 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +404 -0
- package/dist/workflows/workflows.service.js +1620 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +54 -11
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- 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.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{actions/actions.repo.d.ts → pricing/pricing.repo.d.ts} +0 -0
- /package/dist/{appBuilder/validators/joi-validators/create.app.validator.d.ts → products/validators/joi-validators/create.productGraph.validator.d.ts} +0 -0
- /package/dist/{appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts → products/validators/joi-validators/update.productGraph.validator.d.ts} +0 -0
- /package/dist/{test.appBuilder.d.ts → test/test.broker.kafka.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.broker.nats.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.broker.pubsub.d.ts} +0 -0
- /package/dist/{test.processor.d.ts → test/test.broker.rabbitmq.d.ts} +0 -0
- /package/dist/{test.utils.d.ts → test/test.broker.redis.d.ts} +0 -0
- /package/dist/{actions/actions.service.d.ts → test/test.health.d.ts} +0 -0
- /package/dist/{actions/utils/actions.util.read.d.ts → test/test.notifiers.d.ts} +0 -0
- /package/dist/{processor/utils/mongo.util.d.ts → test/test.products.d.ts} +0 -0
- /package/dist/{test.import.d.ts → types/request-tracker.interface.d.ts} +0 -0
|
@@ -36,17 +36,20 @@ 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 secrets_1 = require("../../secrets");
|
|
39
40
|
const update_productNotificationMessage_validator_1 = __importDefault(require("../validators/joi-validators/update.productNotificationMessage.validator"));
|
|
40
41
|
const create_productNotification_validator_1 = require("../validators/joi-validators/create.productNotification.validator");
|
|
41
42
|
const functions_utils_1 = require("../utils/functions.utils");
|
|
42
43
|
const objects_utils_2 = require("../../apps/utils/objects.utils");
|
|
43
44
|
const webhooksApi_service_1 = require("../../api/services/webhooksApi.service");
|
|
44
45
|
class ProductsBuilderService {
|
|
45
|
-
constructor({ workspace_id, public_key, user_id, token, env_type, redis_client }) {
|
|
46
|
+
constructor({ workspace_id, public_key, user_id, token, env_type, redis_client, queues, access_key }) {
|
|
47
|
+
this.workspace_private_key = null;
|
|
46
48
|
this.workspace_id = workspace_id;
|
|
47
49
|
this.public_key = public_key;
|
|
48
50
|
this.user_id = user_id;
|
|
49
51
|
this.token = token;
|
|
52
|
+
this.access_key = access_key || null;
|
|
50
53
|
this.userApi = new userApi_service_1.UserApiService(env_type, redis_client);
|
|
51
54
|
this.productApi = new productsApi_service_1.ProductsApiService(env_type, redis_client);
|
|
52
55
|
this.workspaceApi = new workspaceApi_service_1.WorkspaceApiService(env_type, redis_client);
|
|
@@ -54,6 +57,150 @@ class ProductsBuilderService {
|
|
|
54
57
|
this.appApi = new appApi_service_1.AppApiService(env_type, redis_client);
|
|
55
58
|
this.inputsService = new inputs_service_1.default();
|
|
56
59
|
this.thirdPartyApps = [];
|
|
60
|
+
if (redis_client) {
|
|
61
|
+
this.redisClient = redis_client;
|
|
62
|
+
// Start healthcheck workers automatically
|
|
63
|
+
//this.startHealthcheckWorkers();
|
|
64
|
+
}
|
|
65
|
+
if (queues) {
|
|
66
|
+
this.queues = queues;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
fetchPrivateKey() {
|
|
70
|
+
return this.product.private_key;
|
|
71
|
+
}
|
|
72
|
+
fetchWorkspaceId() {
|
|
73
|
+
return this.product.workspace_id;
|
|
74
|
+
}
|
|
75
|
+
fetchProductId() {
|
|
76
|
+
return this.product._id;
|
|
77
|
+
}
|
|
78
|
+
async createHealthcheck(data) {
|
|
79
|
+
try {
|
|
80
|
+
await validators_1.CreateProductHealthcheckSchema.validateAsync(data);
|
|
81
|
+
if (!data.tag) {
|
|
82
|
+
throw new Error('tag field is required');
|
|
83
|
+
}
|
|
84
|
+
const exists = await this.fetchHealthcheck(data.app, data.tag);
|
|
85
|
+
if (!exists) {
|
|
86
|
+
const { app: access_tag, event: action } = data;
|
|
87
|
+
const app = await this.fetchThirdPartyAppByAccessTag(access_tag);
|
|
88
|
+
const version = app.versions.find((data) => data.tag === app.version);
|
|
89
|
+
if (!version) {
|
|
90
|
+
throw new Error(`Version ${app.version} not found`);
|
|
91
|
+
}
|
|
92
|
+
const event = version.actions.find((act) => act.tag === action);
|
|
93
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
94
|
+
const exists = await this.fetchEnv(env.slug);
|
|
95
|
+
if (!exists) {
|
|
96
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
97
|
+
}
|
|
98
|
+
await this.validateActionDataInput({ input: env.input }, event, env.input, 0, 0);
|
|
99
|
+
env.input = (0, processor_utils_1.encrypt)(JSON.stringify(env.input), this.product.private_key);
|
|
100
|
+
console.log('INPUT', env);
|
|
101
|
+
return env;
|
|
102
|
+
}));
|
|
103
|
+
const envs = await this.fetchEnvs();
|
|
104
|
+
console.log('ENVS ===>>>>', envs);
|
|
105
|
+
console.log('DBENVS ====>>>>', data.envs);
|
|
106
|
+
envs.map((env) => {
|
|
107
|
+
const exists = data.envs.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
108
|
+
if (exists === -1) {
|
|
109
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide details`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
console.log('UPDATING VALUE', data);
|
|
113
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { action: enums_1.RequestAction.CREATE, component: enums_1.ProductComponents.HEALTHCHECK }), this.getUserAccess());
|
|
114
|
+
data.envs.map(async (env) => {
|
|
115
|
+
const payload = {
|
|
116
|
+
app: data.app,
|
|
117
|
+
action: data.event,
|
|
118
|
+
input: env.input,
|
|
119
|
+
env: env.slug,
|
|
120
|
+
product: this.product.tag,
|
|
121
|
+
retries: data.retries,
|
|
122
|
+
};
|
|
123
|
+
const jobId = `healthcheck-${data.tag}`;
|
|
124
|
+
const job = await this.queues.health.getJob(jobId);
|
|
125
|
+
if (job) {
|
|
126
|
+
await job.remove();
|
|
127
|
+
}
|
|
128
|
+
await this.queues.health.add(jobId, payload, { jobId, repeat: { every: data.interval } });
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
console.log(e);
|
|
134
|
+
throw e;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async updateHealthcheck(tag, data) {
|
|
138
|
+
try {
|
|
139
|
+
// 1. Fetch the existing healthcheck
|
|
140
|
+
const healthcheck = await this.fetchHealthcheck(data.app, tag);
|
|
141
|
+
if (!healthcheck) {
|
|
142
|
+
throw new Error(`Healthcheck with tag: ${tag} not found`);
|
|
143
|
+
}
|
|
144
|
+
// 2. Validate the incoming data
|
|
145
|
+
await validators_1.CreateProductHealthcheckSchema.validateAsync(data); // No Update schema, use Create
|
|
146
|
+
// 3. Check for tag conflicts
|
|
147
|
+
if (data.tag && data.tag !== tag && (await this.fetchHealthcheck(data.app, data.tag))) {
|
|
148
|
+
throw new Error(`Healthcheck with tag ${data.tag} already exists`);
|
|
149
|
+
}
|
|
150
|
+
// 4. Validate and process envs
|
|
151
|
+
if (data.envs) {
|
|
152
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
153
|
+
const exists = await this.fetchEnv(env.slug);
|
|
154
|
+
if (!exists) {
|
|
155
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
156
|
+
}
|
|
157
|
+
// Validate input if present
|
|
158
|
+
if (env.input) {
|
|
159
|
+
const app = await this.fetchThirdPartyAppByAccessTag(data.app);
|
|
160
|
+
const version = app.versions.find((v) => v.tag === app.version);
|
|
161
|
+
if (!version) {
|
|
162
|
+
throw new Error(`Version ${app.version} not found`);
|
|
163
|
+
}
|
|
164
|
+
const event = version.actions.find((act) => act.tag === data.event);
|
|
165
|
+
await this.validateActionDataInput({ input: env.input }, event, env.input, 0, 0);
|
|
166
|
+
env.input = (0, processor_utils_1.encrypt)(JSON.stringify(env.input), this.product.private_key);
|
|
167
|
+
}
|
|
168
|
+
return env;
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
// 5. Ensure all product envs are covered
|
|
172
|
+
const envs = await this.fetchEnvs();
|
|
173
|
+
envs.map((env) => {
|
|
174
|
+
var _a;
|
|
175
|
+
const exists = (_a = data.envs) === null || _a === void 0 ? void 0 : _a.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
176
|
+
if (exists === -1) {
|
|
177
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide details`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
// 6. Update the healthcheck
|
|
181
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({}, healthcheck), data), { tag, component: enums_1.ProductComponents.HEALTHCHECK, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async fetchHealthcheck(access_tag, tag, throwError = false) {
|
|
188
|
+
const healthchecks = await this.productApi.fetchProductComponents(this.product_id, 'healthcheck', this.getUserAccess());
|
|
189
|
+
const health = healthchecks.find((data) => data.tag === tag && data.app === access_tag);
|
|
190
|
+
if (!health && throwError)
|
|
191
|
+
throw new Error(`Healthcheck ${tag} not found`);
|
|
192
|
+
return health || null;
|
|
193
|
+
}
|
|
194
|
+
async fetchHealthchecks(access_tag, throwError = false) {
|
|
195
|
+
const healthchecks = await this.productApi.fetchProductComponents(this.product_id, 'healthcheck', this.getUserAccess());
|
|
196
|
+
const health = healthchecks.filter((data) => data.app === access_tag);
|
|
197
|
+
if (!health && throwError)
|
|
198
|
+
throw new Error(`Access tag ${access_tag} not found`);
|
|
199
|
+
return health;
|
|
200
|
+
}
|
|
201
|
+
async fetchProductHealthchecks() {
|
|
202
|
+
const healthchecks = await this.productApi.fetchProductComponents(this.product_id, 'healthcheck', this.getUserAccess());
|
|
203
|
+
return healthchecks;
|
|
57
204
|
}
|
|
58
205
|
async updateDataValidation(selector, update) {
|
|
59
206
|
if (!selector.startsWith('$Data{') && !selector.startsWith('$Filter')) {
|
|
@@ -68,26 +215,27 @@ class ProductsBuilderService {
|
|
|
68
215
|
if (stages.length < 3) {
|
|
69
216
|
throw new Error(`Invalid selector ${selector}`);
|
|
70
217
|
}
|
|
71
|
-
const tag = stages[0];
|
|
72
|
-
const type = stages[1];
|
|
218
|
+
const tag = String(stages[0]);
|
|
219
|
+
const type = String(stages[1]);
|
|
73
220
|
let size = 2;
|
|
74
221
|
let data;
|
|
75
222
|
switch (type) {
|
|
76
223
|
case productsBuilder_types_1.FeatureEventTypes.DB_ACTION:
|
|
77
|
-
const action = this.fetchDatabaseAction(tag);
|
|
224
|
+
const action = await this.fetchDatabaseAction(tag);
|
|
78
225
|
if (!action)
|
|
79
226
|
throw new Error(`DB Action ${tag} not found`);
|
|
80
227
|
data = useData ? action.data : action.filterData;
|
|
81
228
|
break;
|
|
82
229
|
case productsBuilder_types_1.FeatureEventTypes.NOTIFICATION:
|
|
83
230
|
size = 3;
|
|
84
|
-
|
|
85
|
-
|
|
231
|
+
const stage3Str = String(stages[3]);
|
|
232
|
+
if (!stages[3] || (stage3Str !== 'push' && stage3Str !== 'callback' && stage3Str !== 'email')) {
|
|
233
|
+
throw new Error(`Invalid value ${stage3Str} in ${selector}, expected to be "push", "callback" or "email" in notification`);
|
|
86
234
|
}
|
|
87
|
-
const notification = this.fetchNotificationMessage(tag);
|
|
235
|
+
const notification = await this.fetchNotificationMessage(tag);
|
|
88
236
|
if (!notification)
|
|
89
237
|
throw new Error(`Notification ${tag} not found`);
|
|
90
|
-
if (
|
|
238
|
+
if (stage3Str === 'push') {
|
|
91
239
|
data = notification.push_notification_data;
|
|
92
240
|
}
|
|
93
241
|
if (stages[3] === 'callback') {
|
|
@@ -129,11 +277,11 @@ class ProductsBuilderService {
|
|
|
129
277
|
await validators_1.CreateProductBuilderSchema.validateAsync(data);
|
|
130
278
|
const exists = await this.checkIfProductExists(data.name);
|
|
131
279
|
if (exists && (exists === null || exists === void 0 ? void 0 : exists._id)) {
|
|
132
|
-
await this.initializeProduct(exists
|
|
280
|
+
// await this.initializeProduct(exists?._id);
|
|
133
281
|
}
|
|
134
282
|
else {
|
|
135
283
|
const product = await this.createNewProduct(data);
|
|
136
|
-
await this.initializeProduct(product._id);
|
|
284
|
+
// await this.initializeProduct(product._id);
|
|
137
285
|
}
|
|
138
286
|
}
|
|
139
287
|
catch (e) {
|
|
@@ -144,10 +292,26 @@ class ProductsBuilderService {
|
|
|
144
292
|
if (!this.workspace) {
|
|
145
293
|
this.workspace = await this.workspaceApi.fetchWorkspaceById(this.getUserAccess(), subCheck);
|
|
146
294
|
}
|
|
295
|
+
// Fetch workspace private key using the dedicated endpoint for secrets encryption
|
|
296
|
+
if (!this.workspace_private_key && this.access_key) {
|
|
297
|
+
try {
|
|
298
|
+
this.workspace_private_key = await this.workspaceApi.fetchPrivateKey(this.getUserAccess(), this.access_key);
|
|
299
|
+
}
|
|
300
|
+
catch (e) {
|
|
301
|
+
console.warn('[ProductsBuilderService] Failed to fetch workspace private key:', e);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get the workspace private key for secrets encryption
|
|
307
|
+
* @returns The workspace private key or null if not available
|
|
308
|
+
*/
|
|
309
|
+
getWorkspacePrivateKey() {
|
|
310
|
+
return this.workspace_private_key;
|
|
147
311
|
}
|
|
148
312
|
async initializeProduct(product_id) {
|
|
149
313
|
try {
|
|
150
|
-
this.product = await this.productApi.
|
|
314
|
+
this.product = (await this.productApi.initProduct(product_id, this.getUserAccess()));
|
|
151
315
|
this.product_id = product_id;
|
|
152
316
|
}
|
|
153
317
|
catch (e) {
|
|
@@ -156,20 +320,64 @@ class ProductsBuilderService {
|
|
|
156
320
|
}
|
|
157
321
|
async initializeProductByTag(tag) {
|
|
158
322
|
try {
|
|
159
|
-
this.product = await this.productApi.
|
|
323
|
+
this.product = (await this.productApi.initProduct(tag, this.getUserAccess()));
|
|
324
|
+
if (!this.product) {
|
|
325
|
+
throw new Error(`Product with tag "${tag}" not found or failed to fetch`);
|
|
326
|
+
}
|
|
160
327
|
this.product_id = this.product._id;
|
|
161
328
|
}
|
|
162
329
|
catch (e) {
|
|
163
330
|
throw e;
|
|
164
331
|
}
|
|
165
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Bootstrap action - ultra-lightweight API call to fetch action data needed for processAction
|
|
335
|
+
* Replaces 5+ separate API calls: initializeProduct, fetchApp, fetchThirdPartyApp, fetchEnv, initializePricing
|
|
336
|
+
* Returns only the minimal action data needed to execute
|
|
337
|
+
*/
|
|
338
|
+
async bootstrapAction(params) {
|
|
339
|
+
try {
|
|
340
|
+
const result = await this.productApi.bootstrapAction(params, this.getUserAccess());
|
|
341
|
+
// Initialize minimal product data
|
|
342
|
+
if (result.product_id) {
|
|
343
|
+
this.product_id = result.product_id;
|
|
344
|
+
}
|
|
345
|
+
return result;
|
|
346
|
+
}
|
|
347
|
+
catch (e) {
|
|
348
|
+
throw e;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
async bootstrapNotification(params) {
|
|
352
|
+
try {
|
|
353
|
+
const result = await this.productApi.bootstrapNotification(params, this.getUserAccess());
|
|
354
|
+
if (result.product_id) {
|
|
355
|
+
this.product_id = result.product_id;
|
|
356
|
+
}
|
|
357
|
+
return result;
|
|
358
|
+
}
|
|
359
|
+
catch (e) {
|
|
360
|
+
throw e;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async bootstrapStorage(params) {
|
|
364
|
+
try {
|
|
365
|
+
const result = await this.productApi.bootstrapStorage(params, this.getUserAccess());
|
|
366
|
+
if (result.product_id) {
|
|
367
|
+
this.product_id = result.product_id;
|
|
368
|
+
}
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
catch (e) {
|
|
372
|
+
throw e;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
166
375
|
async updateProduct(data) {
|
|
167
376
|
try {
|
|
168
377
|
if (!this.app_id)
|
|
169
378
|
throw new Error('Product not initialized');
|
|
170
379
|
await validators_1.CreateProductBuilderSchema.validateAsync(data);
|
|
171
380
|
await this.productApi.updateProduct(this.product_id, Object.assign({}, data), this.getUserAccess());
|
|
172
|
-
await this.initializeProduct(this.product_id);
|
|
173
381
|
}
|
|
174
382
|
catch (e) {
|
|
175
383
|
throw e;
|
|
@@ -186,11 +394,11 @@ class ProductsBuilderService {
|
|
|
186
394
|
return false;
|
|
187
395
|
}
|
|
188
396
|
}
|
|
189
|
-
fetchProduct() {
|
|
397
|
+
async fetchProduct() {
|
|
190
398
|
if (!this.product) {
|
|
191
399
|
throw new Error('Product not yet initiated');
|
|
192
400
|
}
|
|
193
|
-
return this.product;
|
|
401
|
+
return await this.productApi.fetchProductByTag(this.product.tag, this.getUserAccess());
|
|
194
402
|
}
|
|
195
403
|
async createSession(data, throwErrorIfExists = false) {
|
|
196
404
|
try {
|
|
@@ -198,10 +406,10 @@ class ProductsBuilderService {
|
|
|
198
406
|
if (!data.tag) {
|
|
199
407
|
throw new Error('tag field is required');
|
|
200
408
|
}
|
|
201
|
-
const exists = this.fetchSession(data.tag);
|
|
409
|
+
const exists = await this.fetchSession(data.tag);
|
|
202
410
|
if (!exists) {
|
|
203
|
-
if (!data.selector.startsWith('$
|
|
204
|
-
throw new Error('Selector should be in the format $
|
|
411
|
+
if (!data.selector.startsWith('$Session{')) {
|
|
412
|
+
throw new Error('Selector should be in the format $Session{...}{key}');
|
|
205
413
|
}
|
|
206
414
|
const stages = (0, string_utils_1.extractStages)(data.selector);
|
|
207
415
|
let current = data.schema;
|
|
@@ -213,20 +421,16 @@ class ProductsBuilderService {
|
|
|
213
421
|
throw new Error(`${data.selector} not found in event sample`);
|
|
214
422
|
}
|
|
215
423
|
}
|
|
216
|
-
if (current === null ||
|
|
217
|
-
|
|
218
|
-
typeof current === "object") {
|
|
219
|
-
throw new Error("Selector value is not allowed to be an object|array|null|undefined");
|
|
424
|
+
if (current === null || typeof current === 'undefined' || typeof current === 'object') {
|
|
425
|
+
throw new Error('Selector value is not allowed to be an object|array|null|undefined');
|
|
220
426
|
}
|
|
221
|
-
data.schema_data = await this.inputsService.parseJson({
|
|
427
|
+
data.schema_data = (await this.inputsService.parseJson({
|
|
222
428
|
data: data.schema,
|
|
223
|
-
expected: inputs_types_1.ExpectedValues.PARSESAMPLE
|
|
224
|
-
});
|
|
429
|
+
expected: inputs_types_1.ExpectedValues.PARSESAMPLE,
|
|
430
|
+
}));
|
|
225
431
|
data.selectorValue = current;
|
|
226
|
-
delete data.tag;
|
|
227
432
|
const payload = Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.SESSION, action: enums_1.RequestAction.CREATE });
|
|
228
|
-
await this.
|
|
229
|
-
await this.initializeProduct(this.product_id);
|
|
433
|
+
await this.productApi.updateProduct(this.product_id, payload, this.getUserAccess());
|
|
230
434
|
}
|
|
231
435
|
else {
|
|
232
436
|
if (throwErrorIfExists)
|
|
@@ -239,7 +443,7 @@ class ProductsBuilderService {
|
|
|
239
443
|
}
|
|
240
444
|
async updateSession(tag, data) {
|
|
241
445
|
try {
|
|
242
|
-
const session = this.fetchSession(tag);
|
|
446
|
+
const session = await this.fetchSession(tag);
|
|
243
447
|
if (!session) {
|
|
244
448
|
throw new Error(`Session with tag: ${tag} not found`);
|
|
245
449
|
}
|
|
@@ -272,25 +476,39 @@ class ProductsBuilderService {
|
|
|
272
476
|
throw new Error(`${data.selector} not found in event sample`);
|
|
273
477
|
}
|
|
274
478
|
}
|
|
275
|
-
if (current === null ||
|
|
276
|
-
|
|
277
|
-
typeof current === "object") {
|
|
278
|
-
throw new Error("Selector value is not allowed to be an object|array|null|undefined");
|
|
479
|
+
if (current === null || typeof current === 'undefined' || typeof current === 'object') {
|
|
480
|
+
throw new Error('Selector value is not allowed to be an object|array|null|undefined');
|
|
279
481
|
}
|
|
280
482
|
}
|
|
281
483
|
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());
|
|
282
|
-
await this.initializeProduct(this.product_id);
|
|
283
484
|
}
|
|
284
485
|
catch (e) {
|
|
285
486
|
throw e;
|
|
286
487
|
}
|
|
287
488
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return
|
|
489
|
+
async fetchSessions(version) {
|
|
490
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'session', this.getUserAccess());
|
|
491
|
+
return components;
|
|
492
|
+
}
|
|
493
|
+
async fetchSession(tag) {
|
|
494
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'session', tag, this.getUserAccess());
|
|
495
|
+
return component;
|
|
291
496
|
}
|
|
292
|
-
|
|
293
|
-
|
|
497
|
+
async deleteSession(tag) {
|
|
498
|
+
try {
|
|
499
|
+
const session = await this.fetchSession(tag);
|
|
500
|
+
if (!session) {
|
|
501
|
+
throw new Error(`Session with tag: ${tag} not found`);
|
|
502
|
+
}
|
|
503
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
504
|
+
tag,
|
|
505
|
+
component: enums_1.ProductComponents.SESSION,
|
|
506
|
+
action: enums_1.RequestAction.DELETE,
|
|
507
|
+
}, this.getUserAccess());
|
|
508
|
+
}
|
|
509
|
+
catch (e) {
|
|
510
|
+
throw e;
|
|
511
|
+
}
|
|
294
512
|
}
|
|
295
513
|
async createMessageBrokerTopic(data, throwErrorIfExists = false) {
|
|
296
514
|
try {
|
|
@@ -304,16 +522,17 @@ class ProductsBuilderService {
|
|
|
304
522
|
if (data.sample)
|
|
305
523
|
data.sample = JSON.stringify(data.sample);
|
|
306
524
|
await create_productMessageBrokerTopic_validator_1.default.validateAsync(data);
|
|
307
|
-
const exists = this.fetchMessageBrokerTopic(data.tag);
|
|
308
|
-
const broker = this.fetchMessageBroker(messageBrokerTag);
|
|
309
|
-
|
|
525
|
+
const exists = await this.fetchMessageBrokerTopic(data.tag);
|
|
526
|
+
const broker = await this.fetchMessageBroker(messageBrokerTag);
|
|
527
|
+
if (broker) {
|
|
528
|
+
(0, functions_utils_1.validateAWSSQSQueueUrl)(broker.envs, data.queueUrls);
|
|
529
|
+
}
|
|
310
530
|
data.tag = tag;
|
|
311
531
|
if (!exists) {
|
|
312
532
|
if (data.sample) {
|
|
313
533
|
data.data = (await (0, string_utils_1.extractPlaceholders)(data.sample));
|
|
314
534
|
}
|
|
315
535
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_TOPIC, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
316
|
-
await this.initializeProduct(this.product_id);
|
|
317
536
|
}
|
|
318
537
|
else {
|
|
319
538
|
if (throwErrorIfExists)
|
|
@@ -336,12 +555,12 @@ class ProductsBuilderService {
|
|
|
336
555
|
if (!messageBrokerTag || !tag) {
|
|
337
556
|
throw new Error(`tag is expected to be defined as "messageBrokr_tag:topic_tag"`);
|
|
338
557
|
}
|
|
339
|
-
const exists = this.fetchMessageBrokerTopic(data.tag);
|
|
558
|
+
const exists = await this.fetchMessageBrokerTopic(data.tag);
|
|
340
559
|
if (!exists) {
|
|
341
560
|
throw new Error(`Topic ${data.tag} not found`);
|
|
342
561
|
}
|
|
343
|
-
const broker = this.fetchMessageBroker(messageBrokerTag);
|
|
344
|
-
if (data.queueUrls) {
|
|
562
|
+
const broker = await this.fetchMessageBroker(messageBrokerTag);
|
|
563
|
+
if (data.queueUrls && broker) {
|
|
345
564
|
(0, functions_utils_1.validateAWSSQSQueueUrl)(broker.envs, data.queueUrls);
|
|
346
565
|
}
|
|
347
566
|
data.tag = tag;
|
|
@@ -350,7 +569,6 @@ class ProductsBuilderService {
|
|
|
350
569
|
data.data = (await (0, string_utils_1.extractPlaceholders)(data.sample));
|
|
351
570
|
}
|
|
352
571
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_TOPIC, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
353
|
-
await this.initializeProduct(this.product_id);
|
|
354
572
|
}
|
|
355
573
|
else {
|
|
356
574
|
throw new Error(`Message Broker Topic ${data.tag} not found`);
|
|
@@ -360,7 +578,7 @@ class ProductsBuilderService {
|
|
|
360
578
|
throw e;
|
|
361
579
|
}
|
|
362
580
|
}
|
|
363
|
-
fetchMessageBrokerTopic(tag, throwErrorIfExists = false) {
|
|
581
|
+
async fetchMessageBrokerTopic(tag, throwErrorIfExists = false) {
|
|
364
582
|
const [messageBrokerTag, topicTag] = tag.split(':');
|
|
365
583
|
if (!messageBrokerTag || !topicTag) {
|
|
366
584
|
throw new Error(`tag is expected to be defined as "messageBroker_tag:topic_tag"`);
|
|
@@ -373,12 +591,140 @@ class ProductsBuilderService {
|
|
|
373
591
|
throw new Error(`MessageBroker topic ${tag} not found`);
|
|
374
592
|
return topic;
|
|
375
593
|
}
|
|
376
|
-
fetchMessageBrokerTopics(messageBrokerTag) {
|
|
594
|
+
async fetchMessageBrokerTopics(messageBrokerTag) {
|
|
377
595
|
const messageBroker = this.product.messageBrokers.find((data) => data.tag === messageBrokerTag);
|
|
378
596
|
if (!messageBroker)
|
|
379
597
|
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
380
598
|
return messageBroker.topics;
|
|
381
599
|
}
|
|
600
|
+
// ==================== MESSAGE BROKER PRODUCERS ====================
|
|
601
|
+
async createMessageBrokerProducer(data) {
|
|
602
|
+
var _a, _b;
|
|
603
|
+
try {
|
|
604
|
+
const [messageBrokerTag, topicTag] = data.topic.split(':');
|
|
605
|
+
if (!messageBrokerTag || !topicTag) {
|
|
606
|
+
throw new Error(`topic is expected to be defined as "messageBroker_tag:topic_tag"`);
|
|
607
|
+
}
|
|
608
|
+
const broker = await this.fetchMessageBroker(messageBrokerTag);
|
|
609
|
+
if (!broker) {
|
|
610
|
+
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
611
|
+
}
|
|
612
|
+
// Check if topic exists
|
|
613
|
+
const topic = (_a = broker.topics) === null || _a === void 0 ? void 0 : _a.find((t) => t.tag === topicTag);
|
|
614
|
+
if (!topic) {
|
|
615
|
+
throw new Error(`Topic ${topicTag} not found in broker ${messageBrokerTag}`);
|
|
616
|
+
}
|
|
617
|
+
// Check if producer already exists
|
|
618
|
+
const existingProducer = (_b = broker.producers) === null || _b === void 0 ? void 0 : _b.find((p) => p.tag === data.tag);
|
|
619
|
+
if (existingProducer) {
|
|
620
|
+
throw new Error(`Producer ${data.tag} already exists in broker ${messageBrokerTag}`);
|
|
621
|
+
}
|
|
622
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_PRODUCER, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
623
|
+
}
|
|
624
|
+
catch (e) {
|
|
625
|
+
throw e;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
async updateMessageBrokerProducer(data) {
|
|
629
|
+
var _a;
|
|
630
|
+
try {
|
|
631
|
+
const [messageBrokerTag, topicTag] = data.topic.split(':');
|
|
632
|
+
if (!messageBrokerTag || !topicTag) {
|
|
633
|
+
throw new Error(`topic is expected to be defined as "messageBroker_tag:topic_tag"`);
|
|
634
|
+
}
|
|
635
|
+
const broker = await this.fetchMessageBroker(messageBrokerTag);
|
|
636
|
+
if (!broker) {
|
|
637
|
+
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
638
|
+
}
|
|
639
|
+
// Check if producer exists
|
|
640
|
+
const existingProducer = (_a = broker.producers) === null || _a === void 0 ? void 0 : _a.find((p) => p.tag === data.tag);
|
|
641
|
+
if (!existingProducer) {
|
|
642
|
+
throw new Error(`Producer ${data.tag} not found in broker ${messageBrokerTag}`);
|
|
643
|
+
}
|
|
644
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_PRODUCER, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
645
|
+
}
|
|
646
|
+
catch (e) {
|
|
647
|
+
throw e;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
async fetchMessageBrokerProducer(brokerTag, tag) {
|
|
651
|
+
var _a;
|
|
652
|
+
const messageBroker = this.product.messageBrokers.find((data) => data.tag === brokerTag);
|
|
653
|
+
if (!messageBroker)
|
|
654
|
+
throw new Error(`MessageBroker ${brokerTag} not found`);
|
|
655
|
+
const producer = (_a = messageBroker.producers) === null || _a === void 0 ? void 0 : _a.find((p) => p.tag === tag);
|
|
656
|
+
return producer || null;
|
|
657
|
+
}
|
|
658
|
+
async fetchMessageBrokerProducers(messageBrokerTag) {
|
|
659
|
+
const messageBroker = this.product.messageBrokers.find((data) => data.tag === messageBrokerTag);
|
|
660
|
+
if (!messageBroker)
|
|
661
|
+
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
662
|
+
return messageBroker.producers || [];
|
|
663
|
+
}
|
|
664
|
+
// ==================== MESSAGE BROKER CONSUMERS ====================
|
|
665
|
+
async createMessageBrokerConsumer(data) {
|
|
666
|
+
var _a, _b;
|
|
667
|
+
try {
|
|
668
|
+
const [messageBrokerTag, topicTag] = data.topic.split(':');
|
|
669
|
+
if (!messageBrokerTag || !topicTag) {
|
|
670
|
+
throw new Error(`topic is expected to be defined as "messageBroker_tag:topic_tag"`);
|
|
671
|
+
}
|
|
672
|
+
const broker = await this.fetchMessageBroker(messageBrokerTag);
|
|
673
|
+
if (!broker) {
|
|
674
|
+
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
675
|
+
}
|
|
676
|
+
// Check if topic exists
|
|
677
|
+
const topic = (_a = broker.topics) === null || _a === void 0 ? void 0 : _a.find((t) => t.tag === topicTag);
|
|
678
|
+
if (!topic) {
|
|
679
|
+
throw new Error(`Topic ${topicTag} not found in broker ${messageBrokerTag}`);
|
|
680
|
+
}
|
|
681
|
+
// Check if consumer already exists
|
|
682
|
+
const existingConsumer = (_b = broker.consumers) === null || _b === void 0 ? void 0 : _b.find((c) => c.tag === data.tag);
|
|
683
|
+
if (existingConsumer) {
|
|
684
|
+
throw new Error(`Consumer ${data.tag} already exists in broker ${messageBrokerTag}`);
|
|
685
|
+
}
|
|
686
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_CONSUMER, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
687
|
+
}
|
|
688
|
+
catch (e) {
|
|
689
|
+
throw e;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
async updateMessageBrokerConsumer(data) {
|
|
693
|
+
var _a;
|
|
694
|
+
try {
|
|
695
|
+
const [messageBrokerTag, topicTag] = data.topic.split(':');
|
|
696
|
+
if (!messageBrokerTag || !topicTag) {
|
|
697
|
+
throw new Error(`topic is expected to be defined as "messageBroker_tag:topic_tag"`);
|
|
698
|
+
}
|
|
699
|
+
const broker = await this.fetchMessageBroker(messageBrokerTag);
|
|
700
|
+
if (!broker) {
|
|
701
|
+
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
702
|
+
}
|
|
703
|
+
// Check if consumer exists
|
|
704
|
+
const existingConsumer = (_a = broker.consumers) === null || _a === void 0 ? void 0 : _a.find((c) => c.tag === data.tag);
|
|
705
|
+
if (!existingConsumer) {
|
|
706
|
+
throw new Error(`Consumer ${data.tag} not found in broker ${messageBrokerTag}`);
|
|
707
|
+
}
|
|
708
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_CONSUMER, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
709
|
+
}
|
|
710
|
+
catch (e) {
|
|
711
|
+
throw e;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async fetchMessageBrokerConsumer(brokerTag, tag) {
|
|
715
|
+
var _a;
|
|
716
|
+
const messageBroker = this.product.messageBrokers.find((data) => data.tag === brokerTag);
|
|
717
|
+
if (!messageBroker)
|
|
718
|
+
throw new Error(`MessageBroker ${brokerTag} not found`);
|
|
719
|
+
const consumer = (_a = messageBroker.consumers) === null || _a === void 0 ? void 0 : _a.find((c) => c.tag === tag);
|
|
720
|
+
return consumer || null;
|
|
721
|
+
}
|
|
722
|
+
async fetchMessageBrokerConsumers(messageBrokerTag) {
|
|
723
|
+
const messageBroker = this.product.messageBrokers.find((data) => data.tag === messageBrokerTag);
|
|
724
|
+
if (!messageBroker)
|
|
725
|
+
throw new Error(`Message Broker ${messageBrokerTag} not found`);
|
|
726
|
+
return messageBroker.consumers || [];
|
|
727
|
+
}
|
|
382
728
|
async validateQuotaFallbackInputAndOutput(data, type) {
|
|
383
729
|
const input = data.input;
|
|
384
730
|
await Promise.all(data.options.map(async (d, index) => {
|
|
@@ -411,7 +757,7 @@ class ProductsBuilderService {
|
|
|
411
757
|
this.checkActionQuotaFallbackInput(action.body, option.input.body, input, 'body');
|
|
412
758
|
}
|
|
413
759
|
else {
|
|
414
|
-
const feature = this.fetchFeature(option.event);
|
|
760
|
+
const feature = await this.fetchFeature(option.event);
|
|
415
761
|
if (!feature) {
|
|
416
762
|
throw new Error(`Feature ${option.event} not found`);
|
|
417
763
|
}
|
|
@@ -501,7 +847,7 @@ class ProductsBuilderService {
|
|
|
501
847
|
}
|
|
502
848
|
else {
|
|
503
849
|
// fetch feature
|
|
504
|
-
const feature = this.fetchFeature(option.event);
|
|
850
|
+
const feature = await this.fetchFeature(option.event);
|
|
505
851
|
if (!feature) {
|
|
506
852
|
throw new Error(`Feature ${option.event} not found`);
|
|
507
853
|
}
|
|
@@ -569,7 +915,7 @@ class ProductsBuilderService {
|
|
|
569
915
|
if (!data.tag) {
|
|
570
916
|
throw new Error('tag field is required');
|
|
571
917
|
}
|
|
572
|
-
if (!this.fetchQuota(data.tag)) {
|
|
918
|
+
if (!(await this.fetchQuota(data.tag))) {
|
|
573
919
|
await validators_1.CreateProductQuotaSchema.validateAsync(data);
|
|
574
920
|
await this.validateQuotaFallbackInputAndOutput(data, 'quota');
|
|
575
921
|
data.total_quota = 0;
|
|
@@ -594,7 +940,10 @@ class ProductsBuilderService {
|
|
|
594
940
|
if (!action) {
|
|
595
941
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
596
942
|
}
|
|
597
|
-
if (action.headers.data.length > 0 ||
|
|
943
|
+
if (action.headers.data.length > 0 ||
|
|
944
|
+
action.body.data.length > 0 ||
|
|
945
|
+
action.params.data.length > 0 ||
|
|
946
|
+
action.query.data.length > 0) {
|
|
598
947
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
599
948
|
}
|
|
600
949
|
}
|
|
@@ -612,7 +961,7 @@ class ProductsBuilderService {
|
|
|
612
961
|
}
|
|
613
962
|
async updateQuota(tag, data) {
|
|
614
963
|
try {
|
|
615
|
-
const quota = this.fetchQuota(tag);
|
|
964
|
+
const quota = await this.fetchQuota(tag);
|
|
616
965
|
if (quota) {
|
|
617
966
|
await validators_1.UpdateProductQuotaSchema.validateAsync(data);
|
|
618
967
|
if (data.options) {
|
|
@@ -640,7 +989,10 @@ class ProductsBuilderService {
|
|
|
640
989
|
if (!action) {
|
|
641
990
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
642
991
|
}
|
|
643
|
-
if (action.headers.data.length > 0 ||
|
|
992
|
+
if (action.headers.data.length > 0 ||
|
|
993
|
+
action.body.data.length > 0 ||
|
|
994
|
+
action.params.data.length > 0 ||
|
|
995
|
+
action.query.data.length > 0) {
|
|
644
996
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
645
997
|
}
|
|
646
998
|
}
|
|
@@ -660,18 +1012,36 @@ class ProductsBuilderService {
|
|
|
660
1012
|
throw e;
|
|
661
1013
|
}
|
|
662
1014
|
}
|
|
663
|
-
|
|
664
|
-
|
|
1015
|
+
async fetchQuotas(version) {
|
|
1016
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'quota', this.getUserAccess());
|
|
1017
|
+
return components;
|
|
665
1018
|
}
|
|
666
|
-
|
|
667
|
-
|
|
1019
|
+
async fetchQuota(tag, version) {
|
|
1020
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'quota', tag, this.getUserAccess());
|
|
1021
|
+
return component;
|
|
1022
|
+
}
|
|
1023
|
+
async deleteQuota(tag) {
|
|
1024
|
+
try {
|
|
1025
|
+
const quota = await this.fetchQuota(tag);
|
|
1026
|
+
if (!quota) {
|
|
1027
|
+
throw new Error(`Quota with tag: ${tag} not found`);
|
|
1028
|
+
}
|
|
1029
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1030
|
+
tag,
|
|
1031
|
+
component: enums_1.ProductComponents.QUOTA,
|
|
1032
|
+
action: enums_1.RequestAction.DELETE,
|
|
1033
|
+
}, this.getUserAccess());
|
|
1034
|
+
}
|
|
1035
|
+
catch (e) {
|
|
1036
|
+
throw e;
|
|
1037
|
+
}
|
|
668
1038
|
}
|
|
669
1039
|
async createFallback(data) {
|
|
670
1040
|
try {
|
|
671
1041
|
if (!data.tag) {
|
|
672
1042
|
throw new Error('tag field is required');
|
|
673
1043
|
}
|
|
674
|
-
if (!this.fetchFallback(data.tag)) {
|
|
1044
|
+
if (!(await this.fetchFallback(data.tag))) {
|
|
675
1045
|
await validators_1.CreateProductFallbackSchema.validateAsync(data);
|
|
676
1046
|
await this.validateQuotaFallbackInputAndOutput(data, 'fallback');
|
|
677
1047
|
await Promise.all(data.options.map(async (d) => {
|
|
@@ -693,7 +1063,10 @@ class ProductsBuilderService {
|
|
|
693
1063
|
if (!action) {
|
|
694
1064
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
695
1065
|
}
|
|
696
|
-
if (action.headers.data.length > 0 ||
|
|
1066
|
+
if (action.headers.data.length > 0 ||
|
|
1067
|
+
action.body.data.length > 0 ||
|
|
1068
|
+
action.params.data.length > 0 ||
|
|
1069
|
+
action.query.data.length > 0) {
|
|
697
1070
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
698
1071
|
}
|
|
699
1072
|
}
|
|
@@ -711,7 +1084,7 @@ class ProductsBuilderService {
|
|
|
711
1084
|
}
|
|
712
1085
|
async updateFallback(tag, data) {
|
|
713
1086
|
try {
|
|
714
|
-
const fallback = this.fetchFallback(tag);
|
|
1087
|
+
const fallback = await this.fetchFallback(tag);
|
|
715
1088
|
if (fallback) {
|
|
716
1089
|
await validators_1.UpdateProductFallbackSchema.validateAsync(data);
|
|
717
1090
|
if (data.options) {
|
|
@@ -736,7 +1109,10 @@ class ProductsBuilderService {
|
|
|
736
1109
|
if (!action) {
|
|
737
1110
|
throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
|
|
738
1111
|
}
|
|
739
|
-
if (action.headers.data.length > 0 ||
|
|
1112
|
+
if (action.headers.data.length > 0 ||
|
|
1113
|
+
action.body.data.length > 0 ||
|
|
1114
|
+
action.params.data.length > 0 ||
|
|
1115
|
+
action.query.data.length > 0) {
|
|
740
1116
|
throw new Error('Healthcheck action is expected to have no headers, body, params or query');
|
|
741
1117
|
}
|
|
742
1118
|
}
|
|
@@ -756,19 +1132,36 @@ class ProductsBuilderService {
|
|
|
756
1132
|
throw e;
|
|
757
1133
|
}
|
|
758
1134
|
}
|
|
759
|
-
|
|
760
|
-
|
|
1135
|
+
async fetchFallbacks(version) {
|
|
1136
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'fallback', this.getUserAccess());
|
|
1137
|
+
return components;
|
|
1138
|
+
}
|
|
1139
|
+
async fetchFallback(tag, version) {
|
|
1140
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'fallback', tag, this.getUserAccess());
|
|
1141
|
+
return component;
|
|
761
1142
|
}
|
|
762
|
-
|
|
763
|
-
|
|
1143
|
+
async deleteFallback(tag) {
|
|
1144
|
+
try {
|
|
1145
|
+
const fallback = await this.fetchFallback(tag);
|
|
1146
|
+
if (!fallback) {
|
|
1147
|
+
throw new Error(`Fallback with tag: ${tag} not found`);
|
|
1148
|
+
}
|
|
1149
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1150
|
+
tag,
|
|
1151
|
+
component: enums_1.ProductComponents.FALLBACK,
|
|
1152
|
+
action: enums_1.RequestAction.DELETE,
|
|
1153
|
+
}, this.getUserAccess());
|
|
1154
|
+
}
|
|
1155
|
+
catch (e) {
|
|
1156
|
+
throw e;
|
|
1157
|
+
}
|
|
764
1158
|
}
|
|
765
1159
|
async createEnv(data, throwErrorIfExists = false) {
|
|
766
1160
|
try {
|
|
767
1161
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
768
|
-
if (!this.fetchEnv(data.slug)) {
|
|
1162
|
+
if (!(await this.fetchEnv(data.slug))) {
|
|
769
1163
|
await validators_1.CreateProductEnvSchema.validateAsync(data);
|
|
770
1164
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.ENV, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
771
|
-
await this.initializeProduct(this.product_id);
|
|
772
1165
|
}
|
|
773
1166
|
else {
|
|
774
1167
|
if (throwErrorIfExists)
|
|
@@ -781,137 +1174,221 @@ class ProductsBuilderService {
|
|
|
781
1174
|
}
|
|
782
1175
|
async updateEnv(slug, data) {
|
|
783
1176
|
try {
|
|
784
|
-
const env = this.fetchEnv(slug
|
|
1177
|
+
const env = await this.fetchEnv(slug);
|
|
785
1178
|
if (!env) {
|
|
786
1179
|
throw new Error(`Env ${slug} not found`);
|
|
787
1180
|
}
|
|
788
1181
|
const { _id } = env;
|
|
789
1182
|
await validators_1.UpdateProductEnvSchema.validateAsync(data); // Change to update;
|
|
790
|
-
if (data.slug && this.fetchEnv(data.slug)) {
|
|
1183
|
+
if (data.slug && (await this.fetchEnv(data.slug))) {
|
|
791
1184
|
throw new Error(`slug ${slug} is in use`); // TODO: also check on the backend
|
|
792
1185
|
}
|
|
793
1186
|
if (!data.slug) {
|
|
794
1187
|
data.slug = slug;
|
|
795
1188
|
}
|
|
796
1189
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, Object.assign(Object.assign({}, env), data)), { component: enums_1.ProductComponents.ENV, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
797
|
-
await this.initializeProduct(this.product_id);
|
|
798
1190
|
}
|
|
799
1191
|
catch (e) {
|
|
800
1192
|
throw e;
|
|
801
1193
|
}
|
|
802
1194
|
}
|
|
803
|
-
fetchEnvs() {
|
|
804
|
-
|
|
1195
|
+
async fetchEnvs(version) {
|
|
1196
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'env', this.getUserAccess());
|
|
1197
|
+
return components;
|
|
805
1198
|
}
|
|
806
|
-
fetchEnv(slug
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
1199
|
+
async fetchEnv(slug) {
|
|
1200
|
+
console.log;
|
|
1201
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'env', slug, this.getUserAccess());
|
|
1202
|
+
return component;
|
|
1203
|
+
}
|
|
1204
|
+
async deleteEnv(slug) {
|
|
1205
|
+
try {
|
|
1206
|
+
const env = await this.fetchEnv(slug);
|
|
1207
|
+
if (!env) {
|
|
1208
|
+
throw new Error(`Environment with slug: ${slug} not found`);
|
|
1209
|
+
}
|
|
1210
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1211
|
+
slug,
|
|
1212
|
+
component: enums_1.ProductComponents.ENV,
|
|
1213
|
+
action: enums_1.RequestAction.DELETE,
|
|
1214
|
+
}, this.getUserAccess());
|
|
1215
|
+
}
|
|
1216
|
+
catch (e) {
|
|
1217
|
+
throw e;
|
|
1218
|
+
}
|
|
811
1219
|
}
|
|
812
1220
|
async createMessageBroker(data, throwErrorIfExists = false) {
|
|
813
|
-
|
|
1221
|
+
var _a;
|
|
1222
|
+
const logPrefix = '[MessageBroker:Create]';
|
|
1223
|
+
console.log(`${logPrefix} Starting creation for broker: ${data.tag}`);
|
|
1224
|
+
console.log(`${logPrefix} Broker name: ${data.name}`);
|
|
1225
|
+
console.log(`${logPrefix} Broker description: ${data.description || 'N/A'}`);
|
|
1226
|
+
console.log(`${logPrefix} Number of environments: ${((_a = data.envs) === null || _a === void 0 ? void 0 : _a.length) || 0}`);
|
|
1227
|
+
const existingBroker = await this.fetchMessageBroker(data.tag);
|
|
1228
|
+
if (!existingBroker) {
|
|
1229
|
+
console.log(`${logPrefix} Broker ${data.tag} does not exist, proceeding with creation`);
|
|
1230
|
+
console.log(`${logPrefix} Validating schema...`);
|
|
814
1231
|
await validators_1.CreateMessageBrokerSchema.validateAsync(data);
|
|
815
|
-
|
|
816
|
-
|
|
1232
|
+
console.log(`${logPrefix} Schema validation passed`);
|
|
1233
|
+
const processedEnvs = [];
|
|
1234
|
+
for (const env of data.envs) {
|
|
1235
|
+
console.log(`${logPrefix} Processing env: ${env.slug} (type: ${env.type})`);
|
|
1236
|
+
const exists = await this.fetchEnv(env.slug);
|
|
817
1237
|
if (!exists) {
|
|
1238
|
+
console.error(`${logPrefix} Env ${env.slug} does not exist`);
|
|
818
1239
|
throw new Error(`Env ${env.slug} does not exist`);
|
|
819
1240
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
1241
|
+
console.log(`${logPrefix} Env ${env.slug} exists, verified`);
|
|
1242
|
+
// Store sensitive credentials as secrets
|
|
1243
|
+
console.log(`${logPrefix} Processing secrets for env: ${env.slug}...`);
|
|
1244
|
+
env.config = await this.processMessageBrokerConfigSecrets(env.config, env.type, data.tag, env.slug);
|
|
1245
|
+
console.log(`${logPrefix} Secrets processed for env: ${env.slug}`);
|
|
1246
|
+
console.log(`${logPrefix} Encrypting config for env: ${env.slug}...`);
|
|
1247
|
+
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.product.private_key);
|
|
1248
|
+
console.log(`${logPrefix} Config encrypted for env: ${env.slug}`);
|
|
1249
|
+
processedEnvs.push(env);
|
|
1250
|
+
}
|
|
1251
|
+
data.envs = processedEnvs;
|
|
1252
|
+
console.log(`${logPrefix} All environments processed: ${processedEnvs.length}`);
|
|
1253
|
+
const envs = await this.fetchEnvs();
|
|
1254
|
+
console.log(`${logPrefix} Product has ${envs.length} environments defined`);
|
|
1255
|
+
for (const env of envs) {
|
|
825
1256
|
const exists = data.envs.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
826
1257
|
if (exists === -1) {
|
|
1258
|
+
console.error(`${logPrefix} Product env ${env.slug} is not defined in broker config`);
|
|
827
1259
|
throw new Error(`Product env ${env.slug} is not defined, please provide connection details`);
|
|
828
1260
|
}
|
|
829
|
-
}
|
|
1261
|
+
}
|
|
1262
|
+
console.log(`${logPrefix} All product environments have broker configs`);
|
|
1263
|
+
console.log(`${logPrefix} Sending create request to API...`);
|
|
830
1264
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.MESSAGEBROKER, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
831
|
-
|
|
1265
|
+
console.log(`${logPrefix} Message broker ${data.tag} created successfully`);
|
|
832
1266
|
}
|
|
833
1267
|
else {
|
|
1268
|
+
console.log(`${logPrefix} Broker ${data.tag} already exists`);
|
|
834
1269
|
if (throwErrorIfExists)
|
|
835
1270
|
throw new Error(`Message Broker ${data.tag} already exists`);
|
|
836
1271
|
}
|
|
837
1272
|
}
|
|
838
1273
|
async updateMessageBroker(tag, data) {
|
|
1274
|
+
var _a, _b;
|
|
1275
|
+
const logPrefix = '[MessageBroker:Update]';
|
|
1276
|
+
console.log(`${logPrefix} Starting update for broker: ${tag}`);
|
|
1277
|
+
console.log(`${logPrefix} New tag (if changed): ${data.tag || 'unchanged'}`);
|
|
1278
|
+
console.log(`${logPrefix} New name: ${data.name || 'unchanged'}`);
|
|
1279
|
+
console.log(`${logPrefix} Number of environments in update: ${((_a = data.envs) === null || _a === void 0 ? void 0 : _a.length) || 0}`);
|
|
839
1280
|
try {
|
|
840
|
-
|
|
1281
|
+
console.log(`${logPrefix} Fetching existing broker: ${tag}`);
|
|
1282
|
+
const messageBroker = await this.fetchMessageBroker(tag);
|
|
841
1283
|
if (!messageBroker) {
|
|
1284
|
+
console.error(`${logPrefix} Broker ${tag} not found`);
|
|
842
1285
|
throw new Error(`Broker ${tag} not found`);
|
|
843
1286
|
}
|
|
1287
|
+
console.log(`${logPrefix} Existing broker found with ${((_b = messageBroker.envs) === null || _b === void 0 ? void 0 : _b.length) || 0} environments`);
|
|
844
1288
|
const { _id, envs } = messageBroker;
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1289
|
+
console.log(`${logPrefix} Broker ID: ${_id}`);
|
|
1290
|
+
console.log(`${logPrefix} Validating update schema...`);
|
|
1291
|
+
await validators_1.UpdateMessageBrokerSchema.validateAsync(data);
|
|
1292
|
+
console.log(`${logPrefix} Schema validation passed`);
|
|
1293
|
+
if (data.tag && (await this.fetchMessageBroker(data.tag))) {
|
|
1294
|
+
console.error(`${logPrefix} Tag ${data.tag} is already in use`);
|
|
1295
|
+
throw new Error(`tag ${tag} is in use`);
|
|
1296
|
+
}
|
|
1297
|
+
const processedEnvs = [];
|
|
1298
|
+
for (const env of data.envs) {
|
|
1299
|
+
console.log(`${logPrefix} Processing env: ${env.slug} (type: ${env.type})`);
|
|
1300
|
+
const exists = await this.fetchEnv(env.slug);
|
|
852
1301
|
if (!exists) {
|
|
1302
|
+
console.error(`${logPrefix} Env ${env.slug} does not exist`);
|
|
853
1303
|
throw new Error(`Env ${env.slug} does not exist`);
|
|
854
1304
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
1305
|
+
console.log(`${logPrefix} Env ${env.slug} exists, verified`);
|
|
1306
|
+
if (env.config) {
|
|
1307
|
+
// Store sensitive credentials as secrets
|
|
1308
|
+
console.log(`${logPrefix} Processing secrets for env: ${env.slug}...`);
|
|
1309
|
+
env.config = await this.processMessageBrokerConfigSecrets(env.config, env.type, data.tag || tag, env.slug);
|
|
1310
|
+
console.log(`${logPrefix} Secrets processed for env: ${env.slug}`);
|
|
1311
|
+
console.log(`${logPrefix} Encrypting config for env: ${env.slug}...`);
|
|
1312
|
+
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.product.private_key);
|
|
1313
|
+
console.log(`${logPrefix} Config encrypted for env: ${env.slug}`);
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
console.log(`${logPrefix} No config provided for env: ${env.slug}, skipping secrets processing`);
|
|
1317
|
+
}
|
|
1318
|
+
processedEnvs.push(env);
|
|
1319
|
+
}
|
|
1320
|
+
data.envs = processedEnvs;
|
|
1321
|
+
console.log(`${logPrefix} All environments processed: ${processedEnvs.length}`);
|
|
859
1322
|
const overwrite = [];
|
|
860
1323
|
const newEnvs = [];
|
|
861
|
-
data.envs
|
|
1324
|
+
for (const dataEnv of data.envs) {
|
|
862
1325
|
const exists = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
863
|
-
if (!this.fetchEnv(dataEnv.slug)) {
|
|
1326
|
+
if (!(await this.fetchEnv(dataEnv.slug))) {
|
|
1327
|
+
console.error(`${logPrefix} Product Environment ${dataEnv.slug} doesn't exist`);
|
|
864
1328
|
throw new Error(`Product Environment ${dataEnv.slug} doesn't exist`);
|
|
865
1329
|
}
|
|
866
1330
|
if (exists === -1) {
|
|
1331
|
+
console.log(`${logPrefix} Env ${dataEnv.slug} is a NEW environment`);
|
|
867
1332
|
if (!dataEnv.config) {
|
|
1333
|
+
console.error(`${logPrefix} Config is required for new env ${dataEnv.slug}`);
|
|
868
1334
|
throw new Error(`config is required for new env ${data.envs[exists].slug}`);
|
|
869
1335
|
}
|
|
870
1336
|
newEnvs.push(dataEnv);
|
|
871
1337
|
}
|
|
872
1338
|
else {
|
|
1339
|
+
console.log(`${logPrefix} Env ${dataEnv.slug} will OVERWRITE existing config`);
|
|
873
1340
|
if (envs[exists].config) {
|
|
874
|
-
envs[exists].config = (0, processor_utils_1.encrypt)(JSON.stringify(envs[exists].config), this.
|
|
1341
|
+
envs[exists].config = (0, processor_utils_1.encrypt)(JSON.stringify(envs[exists].config), this.product.private_key);
|
|
875
1342
|
}
|
|
876
1343
|
overwrite.push(Object.assign(Object.assign({}, envs[exists]), dataEnv));
|
|
877
1344
|
}
|
|
878
|
-
}
|
|
1345
|
+
}
|
|
879
1346
|
const unchanged = [];
|
|
880
|
-
|
|
1347
|
+
for (const env of envs) {
|
|
881
1348
|
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
882
1349
|
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
883
1350
|
if (!newEnv && !overwriteEnv) {
|
|
1351
|
+
console.log(`${logPrefix} Env ${env.slug} is UNCHANGED`);
|
|
884
1352
|
if (env.config) {
|
|
885
|
-
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.
|
|
1353
|
+
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.product.private_key);
|
|
886
1354
|
}
|
|
887
1355
|
unchanged.push(env);
|
|
888
1356
|
}
|
|
889
|
-
}
|
|
1357
|
+
}
|
|
890
1358
|
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1359
|
+
console.log(`${logPrefix} Final env breakdown - Unchanged: ${unchanged.length}, Overwrite: ${overwrite.length}, New: ${newEnvs.length}`);
|
|
1360
|
+
console.log(`${logPrefix} Sending update request to API...`);
|
|
891
1361
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({ _id }, messageBroker), data), { component: enums_1.ProductComponents.MESSAGEBROKER, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
892
|
-
|
|
1362
|
+
console.log(`${logPrefix} Message broker ${tag} updated successfully`);
|
|
893
1363
|
}
|
|
894
1364
|
catch (e) {
|
|
1365
|
+
console.error(`${logPrefix} Update failed:`, e);
|
|
895
1366
|
throw e;
|
|
896
1367
|
}
|
|
897
1368
|
}
|
|
898
|
-
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
throw new Error(`Message Broker ${tag} not found`);
|
|
902
|
-
if (messageBroker) {
|
|
903
|
-
messageBroker.envs.map((broker) => {
|
|
904
|
-
if (typeof broker.config === 'string') {
|
|
905
|
-
broker.config = JSON.parse((0, processor_utils_1.decrypt)(String(broker.config), this.fetchProduct().private_key));
|
|
906
|
-
}
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
return messageBroker;
|
|
1369
|
+
async fetchMessageBrokers(version) {
|
|
1370
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'message_broker', this.getUserAccess());
|
|
1371
|
+
return components;
|
|
910
1372
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1373
|
+
async fetchMessageBroker(tag, version) {
|
|
1374
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'message_broker', tag, this.getUserAccess());
|
|
1375
|
+
return component;
|
|
1376
|
+
}
|
|
1377
|
+
async deleteMessageBroker(tag) {
|
|
1378
|
+
try {
|
|
1379
|
+
const messageBroker = await this.fetchMessageBroker(tag);
|
|
1380
|
+
if (!messageBroker) {
|
|
1381
|
+
throw new Error(`Message broker with tag: ${tag} not found`);
|
|
1382
|
+
}
|
|
1383
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1384
|
+
tag,
|
|
1385
|
+
component: enums_1.ProductComponents.MESSAGEBROKER,
|
|
1386
|
+
action: enums_1.RequestAction.DELETE,
|
|
1387
|
+
}, this.getUserAccess());
|
|
1388
|
+
}
|
|
1389
|
+
catch (e) {
|
|
1390
|
+
throw e;
|
|
1391
|
+
}
|
|
915
1392
|
}
|
|
916
1393
|
async fetchStorageFiles(filter) {
|
|
917
1394
|
try {
|
|
@@ -927,14 +1404,31 @@ class ProductsBuilderService {
|
|
|
927
1404
|
});
|
|
928
1405
|
}
|
|
929
1406
|
catch (e) {
|
|
930
|
-
throw
|
|
1407
|
+
throw e;
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
async fetchSessionUsers(filter) {
|
|
1411
|
+
try {
|
|
1412
|
+
const result = await this.productApi.fetchProductSessionUsers(Object.assign(Object.assign({}, filter), { product: this.product.tag }), this.getUserAccess());
|
|
1413
|
+
if (!result)
|
|
1414
|
+
return [];
|
|
1415
|
+
return result.map((res) => {
|
|
1416
|
+
delete res._id;
|
|
1417
|
+
delete res.workspace_id;
|
|
1418
|
+
delete res.__v;
|
|
1419
|
+
return res;
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
catch (e) {
|
|
1423
|
+
throw e;
|
|
931
1424
|
}
|
|
932
1425
|
}
|
|
933
1426
|
async createStorage(data, throwErrorIfExists = false) {
|
|
934
|
-
if (!this.fetchStorage(data.tag
|
|
1427
|
+
if (!(await this.fetchStorage(data.tag))) {
|
|
935
1428
|
await create_productStorage_validator_1.CreateProductStorageSchema.validateAsync(data);
|
|
936
|
-
|
|
937
|
-
|
|
1429
|
+
const processedEnvs = [];
|
|
1430
|
+
for (const env of data.envs) {
|
|
1431
|
+
const exists = await this.fetchEnv(env.slug);
|
|
938
1432
|
if (!exists) {
|
|
939
1433
|
throw new Error(`Env ${env.slug} does not exist`);
|
|
940
1434
|
}
|
|
@@ -942,18 +1436,20 @@ class ProductsBuilderService {
|
|
|
942
1436
|
// @ts-ignore
|
|
943
1437
|
//env.config.config.private_key = gcpPKCSConvert(env.config.config.private_key)
|
|
944
1438
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1439
|
+
// Store sensitive credentials as secrets
|
|
1440
|
+
env.config = await this.processStorageConfigSecrets(env.config, env.type, data.tag, env.slug);
|
|
1441
|
+
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.product.private_key);
|
|
1442
|
+
processedEnvs.push(env);
|
|
1443
|
+
}
|
|
1444
|
+
data.envs = processedEnvs;
|
|
1445
|
+
const envs = await this.fetchEnvs();
|
|
1446
|
+
for (const env of envs) {
|
|
950
1447
|
const exists = data.envs.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
951
1448
|
if (exists === -1) {
|
|
952
1449
|
throw new Error(`Product env ${env.slug} is not defined, please provide connection details`);
|
|
953
1450
|
}
|
|
954
|
-
}
|
|
1451
|
+
}
|
|
955
1452
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.STORAGE, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
956
|
-
await this.initializeProduct(this.product_id);
|
|
957
1453
|
}
|
|
958
1454
|
else {
|
|
959
1455
|
if (throwErrorIfExists)
|
|
@@ -962,7 +1458,7 @@ class ProductsBuilderService {
|
|
|
962
1458
|
}
|
|
963
1459
|
async updateStorage(tag, data) {
|
|
964
1460
|
try {
|
|
965
|
-
const storage = this.fetchStorage(tag);
|
|
1461
|
+
const storage = await this.fetchStorage(tag);
|
|
966
1462
|
if (!storage) {
|
|
967
1463
|
throw new Error(`Storage ${tag} not found`);
|
|
968
1464
|
}
|
|
@@ -971,8 +1467,8 @@ class ProductsBuilderService {
|
|
|
971
1467
|
if (data.tag && this.fetchStorage(data.tag)) {
|
|
972
1468
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
973
1469
|
}
|
|
974
|
-
data.envs = data.envs.map((env) => {
|
|
975
|
-
const exists = this.fetchEnv(env.slug);
|
|
1470
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
1471
|
+
const exists = await this.fetchEnv(env.slug);
|
|
976
1472
|
if (!exists) {
|
|
977
1473
|
throw new Error(`Env ${env.slug} does not exist`);
|
|
978
1474
|
}
|
|
@@ -980,10 +1476,13 @@ class ProductsBuilderService {
|
|
|
980
1476
|
// @ts-ignore
|
|
981
1477
|
//env.config.config.private_key = gcpPKCSConvert(env.config.config.private_key)
|
|
982
1478
|
}
|
|
983
|
-
if (env.config)
|
|
984
|
-
|
|
1479
|
+
if (env.config) {
|
|
1480
|
+
// Store sensitive credentials as secrets
|
|
1481
|
+
env.config = await this.processStorageConfigSecrets(env.config, env.type, data.tag || tag, env.slug);
|
|
1482
|
+
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.product.private_key);
|
|
1483
|
+
}
|
|
985
1484
|
return env;
|
|
986
|
-
});
|
|
1485
|
+
}));
|
|
987
1486
|
const overwrite = [];
|
|
988
1487
|
const newEnvs = [];
|
|
989
1488
|
data.envs.map((dataEnv) => {
|
|
@@ -999,7 +1498,7 @@ class ProductsBuilderService {
|
|
|
999
1498
|
}
|
|
1000
1499
|
else {
|
|
1001
1500
|
if (envs[exists].config) {
|
|
1002
|
-
envs[exists].config = (0, processor_utils_1.encrypt)(JSON.stringify(envs[exists].config), this.
|
|
1501
|
+
envs[exists].config = (0, processor_utils_1.encrypt)(JSON.stringify(envs[exists].config), this.product.private_key);
|
|
1003
1502
|
}
|
|
1004
1503
|
overwrite.push(Object.assign(Object.assign({}, envs[exists]), dataEnv));
|
|
1005
1504
|
}
|
|
@@ -1010,60 +1509,531 @@ class ProductsBuilderService {
|
|
|
1010
1509
|
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1011
1510
|
if (!newEnv && !overwriteEnv) {
|
|
1012
1511
|
if (env.config) {
|
|
1013
|
-
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.
|
|
1512
|
+
env.config = (0, processor_utils_1.encrypt)(JSON.stringify(env.config), this.product.private_key);
|
|
1014
1513
|
}
|
|
1015
1514
|
unchanged.push(env);
|
|
1016
1515
|
}
|
|
1017
1516
|
});
|
|
1018
1517
|
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1019
1518
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({ _id }, storage), data), { component: enums_1.ProductComponents.STORAGE, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
1020
|
-
await this.initializeProduct(this.product_id);
|
|
1021
1519
|
}
|
|
1022
1520
|
catch (e) {
|
|
1023
1521
|
throw e;
|
|
1024
1522
|
}
|
|
1025
1523
|
}
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1029
|
-
throw new Error(`Storage ${tag} not found`);
|
|
1030
|
-
if (storage) {
|
|
1031
|
-
storage.envs.map((store) => {
|
|
1032
|
-
if (typeof store.config === 'string') {
|
|
1033
|
-
store.config = JSON.parse((0, processor_utils_1.decrypt)(String(store.config), this.fetchProduct().private_key));
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
return storage;
|
|
1038
|
-
}
|
|
1039
|
-
fetchStorages() {
|
|
1040
|
-
return this.product.storage.map((storage) => {
|
|
1041
|
-
return this.fetchStorage(storage.tag);
|
|
1042
|
-
});
|
|
1524
|
+
async fetchStorages(version) {
|
|
1525
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'storage', this.getUserAccess());
|
|
1526
|
+
return components;
|
|
1043
1527
|
}
|
|
1044
|
-
async
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
// const { envs: appEnvs, auths: appAuths } = appData
|
|
1048
|
-
const version = appData.versions.find((data) => (data.latest = true));
|
|
1049
|
-
app.envs = this.validateAppEnvs(envs, version);
|
|
1050
|
-
// await this.validateAppAuth(auth, appData);
|
|
1051
|
-
return app;
|
|
1528
|
+
async fetchStorage(tag, version) {
|
|
1529
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'storage', tag, this.getUserAccess());
|
|
1530
|
+
return component;
|
|
1052
1531
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1532
|
+
async deleteStorage(tag) {
|
|
1533
|
+
try {
|
|
1534
|
+
const storage = await this.fetchStorage(tag);
|
|
1535
|
+
if (!storage) {
|
|
1536
|
+
throw new Error(`Storage with tag: ${tag} not found`);
|
|
1537
|
+
}
|
|
1538
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1539
|
+
tag,
|
|
1540
|
+
component: enums_1.ProductComponents.STORAGE,
|
|
1541
|
+
action: enums_1.RequestAction.DELETE,
|
|
1542
|
+
}, this.getUserAccess());
|
|
1543
|
+
}
|
|
1544
|
+
catch (e) {
|
|
1545
|
+
throw e;
|
|
1062
1546
|
}
|
|
1063
1547
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1548
|
+
// ==================== VECTOR DATABASE METHODS ====================
|
|
1549
|
+
/**
|
|
1550
|
+
* Create a new vector database configuration
|
|
1551
|
+
* @param data Vector database configuration
|
|
1552
|
+
* @param throwErrorIfExists Whether to throw error if vector config already exists
|
|
1553
|
+
*/
|
|
1554
|
+
async createVector(data, throwErrorIfExists = false) {
|
|
1555
|
+
var _a, _b, _c, _d;
|
|
1556
|
+
console.log('[ProductsService.createVector] Starting vector creation:', {
|
|
1557
|
+
tag: data.tag,
|
|
1558
|
+
name: data.name,
|
|
1559
|
+
type: data.type,
|
|
1560
|
+
envsCount: (_a = data.envs) === null || _a === void 0 ? void 0 : _a.length,
|
|
1561
|
+
productTag: (_b = this.product) === null || _b === void 0 ? void 0 : _b.tag,
|
|
1562
|
+
});
|
|
1563
|
+
if (!(await this.fetchVector(data.tag))) {
|
|
1564
|
+
await validators_1.CreateProductVectorSchema.validateAsync(data);
|
|
1565
|
+
const processedEnvs = [];
|
|
1566
|
+
for (const env of data.envs) {
|
|
1567
|
+
console.log('[ProductsService.createVector] Processing env:', {
|
|
1568
|
+
slug: env.slug,
|
|
1569
|
+
hasApiKey: !!env.apiKey,
|
|
1570
|
+
hasEndpoint: !!env.endpoint,
|
|
1571
|
+
});
|
|
1572
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1573
|
+
if (!exists) {
|
|
1574
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1575
|
+
}
|
|
1576
|
+
// Store API key as secret and encrypt
|
|
1577
|
+
if (env.apiKey) {
|
|
1578
|
+
console.log('[ProductsService.createVector] Converting API key to secret for env:', env.slug);
|
|
1579
|
+
const originalApiKey = env.apiKey;
|
|
1580
|
+
env.apiKey = await this.storeVectorApiKeyAsSecret(env.apiKey, data.tag, env.slug);
|
|
1581
|
+
console.log('[ProductsService.createVector] API key after secret conversion:', {
|
|
1582
|
+
wasConverted: originalApiKey !== env.apiKey,
|
|
1583
|
+
isSecretRef: (_c = env.apiKey) === null || _c === void 0 ? void 0 : _c.startsWith('$Secret{'),
|
|
1584
|
+
});
|
|
1585
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1586
|
+
console.log('[ProductsService.createVector] API key encrypted');
|
|
1587
|
+
}
|
|
1588
|
+
// Store endpoint as secret and encrypt
|
|
1589
|
+
if (env.endpoint) {
|
|
1590
|
+
console.log('[ProductsService.createVector] Converting endpoint to secret for env:', env.slug);
|
|
1591
|
+
const originalEndpoint = env.endpoint;
|
|
1592
|
+
env.endpoint = await this.storeVectorEndpointAsSecret(env.endpoint, data.tag, env.slug);
|
|
1593
|
+
console.log('[ProductsService.createVector] Endpoint after secret conversion:', {
|
|
1594
|
+
wasConverted: originalEndpoint !== env.endpoint,
|
|
1595
|
+
isSecretRef: (_d = env.endpoint) === null || _d === void 0 ? void 0 : _d.startsWith('$Secret{'),
|
|
1596
|
+
});
|
|
1597
|
+
env.endpoint = (0, processor_utils_1.encrypt)(env.endpoint, this.product.private_key);
|
|
1598
|
+
console.log('[ProductsService.createVector] Endpoint encrypted');
|
|
1599
|
+
}
|
|
1600
|
+
processedEnvs.push(env);
|
|
1601
|
+
console.log('[ProductsService.createVector] Env processed successfully:', env.slug);
|
|
1602
|
+
}
|
|
1603
|
+
data.envs = processedEnvs;
|
|
1604
|
+
console.log('[ProductsService.createVector] All envs processed, total:', processedEnvs.length);
|
|
1605
|
+
const envs = await this.fetchEnvs();
|
|
1606
|
+
for (const env of envs) {
|
|
1607
|
+
const exists = data.envs.findIndex((vecEnv) => vecEnv.slug === env.slug);
|
|
1608
|
+
if (exists === -1) {
|
|
1609
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide connection details`);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.VECTOR, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1613
|
+
}
|
|
1614
|
+
else {
|
|
1615
|
+
if (throwErrorIfExists)
|
|
1616
|
+
throw new Error(`Vector ${data.tag} already exists`);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Update an existing vector database configuration
|
|
1621
|
+
* @param tag Vector config tag
|
|
1622
|
+
* @param data Updated vector configuration
|
|
1623
|
+
*/
|
|
1624
|
+
async updateVector(tag, data) {
|
|
1625
|
+
var _a, _b;
|
|
1626
|
+
console.log('[ProductsService.updateVector] Starting vector update:', {
|
|
1627
|
+
tag,
|
|
1628
|
+
newTag: data.tag,
|
|
1629
|
+
name: data.name,
|
|
1630
|
+
envsCount: (_a = data.envs) === null || _a === void 0 ? void 0 : _a.length,
|
|
1631
|
+
productTag: (_b = this.product) === null || _b === void 0 ? void 0 : _b.tag,
|
|
1632
|
+
});
|
|
1633
|
+
try {
|
|
1634
|
+
const vector = await this.fetchVector(tag);
|
|
1635
|
+
if (!vector) {
|
|
1636
|
+
throw new Error(`Vector ${tag} not found`);
|
|
1637
|
+
}
|
|
1638
|
+
const { _id, envs } = vector;
|
|
1639
|
+
console.log('[ProductsService.updateVector] Found existing vector:', {
|
|
1640
|
+
_id,
|
|
1641
|
+
existingEnvsCount: envs === null || envs === void 0 ? void 0 : envs.length,
|
|
1642
|
+
});
|
|
1643
|
+
await validators_1.UpdateProductVectorSchema.validateAsync(data);
|
|
1644
|
+
if (data.tag && (await this.fetchVector(data.tag))) {
|
|
1645
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
1646
|
+
}
|
|
1647
|
+
if (data.envs) {
|
|
1648
|
+
console.log('[ProductsService.updateVector] Processing envs update');
|
|
1649
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
1650
|
+
var _a, _b;
|
|
1651
|
+
console.log('[ProductsService.updateVector] Processing env:', {
|
|
1652
|
+
slug: env.slug,
|
|
1653
|
+
hasApiKey: !!env.apiKey,
|
|
1654
|
+
hasEndpoint: !!env.endpoint,
|
|
1655
|
+
});
|
|
1656
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1657
|
+
if (!exists) {
|
|
1658
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1659
|
+
}
|
|
1660
|
+
// Store API key as secret and encrypt
|
|
1661
|
+
if (env.apiKey) {
|
|
1662
|
+
console.log('[ProductsService.updateVector] Converting API key to secret for env:', env.slug);
|
|
1663
|
+
const originalApiKey = env.apiKey;
|
|
1664
|
+
env.apiKey = await this.storeVectorApiKeyAsSecret(env.apiKey, data.tag || tag, env.slug);
|
|
1665
|
+
console.log('[ProductsService.updateVector] API key after secret conversion:', {
|
|
1666
|
+
wasConverted: originalApiKey !== env.apiKey,
|
|
1667
|
+
isSecretRef: (_a = env.apiKey) === null || _a === void 0 ? void 0 : _a.startsWith('$Secret{'),
|
|
1668
|
+
});
|
|
1669
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1670
|
+
console.log('[ProductsService.updateVector] API key encrypted');
|
|
1671
|
+
}
|
|
1672
|
+
// Store endpoint as secret and encrypt
|
|
1673
|
+
if (env.endpoint) {
|
|
1674
|
+
console.log('[ProductsService.updateVector] Converting endpoint to secret for env:', env.slug);
|
|
1675
|
+
const originalEndpoint = env.endpoint;
|
|
1676
|
+
env.endpoint = await this.storeVectorEndpointAsSecret(env.endpoint, data.tag || tag, env.slug);
|
|
1677
|
+
console.log('[ProductsService.updateVector] Endpoint after secret conversion:', {
|
|
1678
|
+
wasConverted: originalEndpoint !== env.endpoint,
|
|
1679
|
+
isSecretRef: (_b = env.endpoint) === null || _b === void 0 ? void 0 : _b.startsWith('$Secret{'),
|
|
1680
|
+
});
|
|
1681
|
+
env.endpoint = (0, processor_utils_1.encrypt)(env.endpoint, this.product.private_key);
|
|
1682
|
+
console.log('[ProductsService.updateVector] Endpoint encrypted');
|
|
1683
|
+
}
|
|
1684
|
+
console.log('[ProductsService.updateVector] Env processed successfully:', env.slug);
|
|
1685
|
+
return env;
|
|
1686
|
+
}));
|
|
1687
|
+
const overwrite = [];
|
|
1688
|
+
const newEnvs = [];
|
|
1689
|
+
data.envs.forEach((dataEnv) => {
|
|
1690
|
+
const existsIdx = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
1691
|
+
if (existsIdx === -1) {
|
|
1692
|
+
newEnvs.push(dataEnv);
|
|
1693
|
+
}
|
|
1694
|
+
else {
|
|
1695
|
+
overwrite.push(Object.assign(Object.assign({}, envs[existsIdx]), dataEnv));
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
const unchanged = [];
|
|
1699
|
+
envs.forEach((env) => {
|
|
1700
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1701
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1702
|
+
if (!newEnv && !overwriteEnv) {
|
|
1703
|
+
unchanged.push(env);
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1707
|
+
}
|
|
1708
|
+
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());
|
|
1709
|
+
}
|
|
1710
|
+
catch (e) {
|
|
1711
|
+
throw e;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Fetch all vector database configurations
|
|
1716
|
+
* @param version Optional version
|
|
1717
|
+
*/
|
|
1718
|
+
async fetchVectors(version) {
|
|
1719
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'vector', this.getUserAccess());
|
|
1720
|
+
return components;
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Fetch a specific vector database configuration by tag
|
|
1724
|
+
* @param tag Vector config tag
|
|
1725
|
+
* @param version Optional version
|
|
1726
|
+
*/
|
|
1727
|
+
async fetchVector(tag, version) {
|
|
1728
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'vector', tag, this.getUserAccess());
|
|
1729
|
+
return component;
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Delete a vector database configuration
|
|
1733
|
+
* @param tag Vector config tag
|
|
1734
|
+
*/
|
|
1735
|
+
async deleteVector(tag) {
|
|
1736
|
+
try {
|
|
1737
|
+
const vector = await this.fetchVector(tag);
|
|
1738
|
+
if (!vector) {
|
|
1739
|
+
throw new Error(`Vector with tag: ${tag} not found`);
|
|
1740
|
+
}
|
|
1741
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1742
|
+
tag,
|
|
1743
|
+
component: enums_1.ProductComponents.VECTOR,
|
|
1744
|
+
action: enums_1.RequestAction.DELETE,
|
|
1745
|
+
}, this.getUserAccess());
|
|
1746
|
+
}
|
|
1747
|
+
catch (e) {
|
|
1748
|
+
throw e;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
// ==================== AGENT METHODS ====================
|
|
1752
|
+
/**
|
|
1753
|
+
* Create a new agent configuration
|
|
1754
|
+
* @param data Agent configuration data
|
|
1755
|
+
* @param throwErrorIfExists Whether to throw an error if agent already exists
|
|
1756
|
+
*/
|
|
1757
|
+
async createAgent(data, throwErrorIfExists = false) {
|
|
1758
|
+
if (!(await this.fetchAgent(data.tag))) {
|
|
1759
|
+
await validators_1.CreateProductAgentSchema.validateAsync(data);
|
|
1760
|
+
// Validate envs if provided
|
|
1761
|
+
if (data.envs) {
|
|
1762
|
+
for (const env of data.envs) {
|
|
1763
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1764
|
+
if (!exists) {
|
|
1765
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
// Validate that all product envs are configured
|
|
1770
|
+
const envs = await this.fetchEnvs();
|
|
1771
|
+
if (data.envs) {
|
|
1772
|
+
for (const env of envs) {
|
|
1773
|
+
const exists = data.envs.findIndex((agentEnv) => agentEnv.slug === env.slug);
|
|
1774
|
+
if (exists === -1) {
|
|
1775
|
+
// Auto-add missing envs with default config
|
|
1776
|
+
data.envs.push({ slug: env.slug, active: true });
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
else {
|
|
1781
|
+
// Initialize envs with all product envs
|
|
1782
|
+
data.envs = envs.map((env) => ({ slug: env.slug, active: true }));
|
|
1783
|
+
}
|
|
1784
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.AGENT, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
if (throwErrorIfExists)
|
|
1788
|
+
throw new Error(`Agent ${data.tag} already exists`);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Update an existing agent configuration
|
|
1793
|
+
* @param tag Agent tag
|
|
1794
|
+
* @param data Updated agent configuration
|
|
1795
|
+
*/
|
|
1796
|
+
async updateAgent(tag, data) {
|
|
1797
|
+
try {
|
|
1798
|
+
const agent = await this.fetchAgent(tag);
|
|
1799
|
+
if (!agent) {
|
|
1800
|
+
throw new Error(`Agent ${tag} not found`);
|
|
1801
|
+
}
|
|
1802
|
+
const { _id, envs } = agent;
|
|
1803
|
+
await validators_1.UpdateProductAgentSchema.validateAsync(data);
|
|
1804
|
+
if (data.tag && data.tag !== tag && (await this.fetchAgent(data.tag))) {
|
|
1805
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
1806
|
+
}
|
|
1807
|
+
if (data.envs) {
|
|
1808
|
+
// Validate that all provided envs exist
|
|
1809
|
+
for (const env of data.envs) {
|
|
1810
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1811
|
+
if (!exists) {
|
|
1812
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
const overwrite = [];
|
|
1816
|
+
const newEnvs = [];
|
|
1817
|
+
data.envs.forEach((dataEnv) => {
|
|
1818
|
+
var _a;
|
|
1819
|
+
const existsIdx = (_a = envs === null || envs === void 0 ? void 0 : envs.findIndex((env) => env.slug === dataEnv.slug)) !== null && _a !== void 0 ? _a : -1;
|
|
1820
|
+
if (existsIdx === -1) {
|
|
1821
|
+
newEnvs.push(dataEnv);
|
|
1822
|
+
}
|
|
1823
|
+
else {
|
|
1824
|
+
overwrite.push(Object.assign(Object.assign({}, envs[existsIdx]), dataEnv));
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
const unchanged = [];
|
|
1828
|
+
envs === null || envs === void 0 ? void 0 : envs.forEach((env) => {
|
|
1829
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1830
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1831
|
+
if (!newEnv && !overwriteEnv) {
|
|
1832
|
+
unchanged.push(env);
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1836
|
+
}
|
|
1837
|
+
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());
|
|
1838
|
+
}
|
|
1839
|
+
catch (e) {
|
|
1840
|
+
throw e;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Fetch all agent configurations
|
|
1845
|
+
* @param version Optional version
|
|
1846
|
+
*/
|
|
1847
|
+
async fetchAgents(version) {
|
|
1848
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'agent', this.getUserAccess());
|
|
1849
|
+
return components;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Fetch a specific agent configuration by tag
|
|
1853
|
+
* @param tag Agent tag
|
|
1854
|
+
* @param version Optional version
|
|
1855
|
+
*/
|
|
1856
|
+
async fetchAgent(tag, version) {
|
|
1857
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'agent', tag, this.getUserAccess());
|
|
1858
|
+
return component;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Delete an agent configuration
|
|
1862
|
+
* @param tag Agent tag
|
|
1863
|
+
*/
|
|
1864
|
+
async deleteAgent(tag) {
|
|
1865
|
+
try {
|
|
1866
|
+
const agent = await this.fetchAgent(tag);
|
|
1867
|
+
if (!agent) {
|
|
1868
|
+
throw new Error(`Agent with tag: ${tag} not found`);
|
|
1869
|
+
}
|
|
1870
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
1871
|
+
tag,
|
|
1872
|
+
component: enums_1.ProductComponents.AGENT,
|
|
1873
|
+
action: enums_1.RequestAction.DELETE,
|
|
1874
|
+
}, this.getUserAccess());
|
|
1875
|
+
}
|
|
1876
|
+
catch (e) {
|
|
1877
|
+
throw e;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
// ==================== LLM MODEL METHODS ====================
|
|
1881
|
+
/**
|
|
1882
|
+
* Create a new LLM model configuration
|
|
1883
|
+
* API keys are automatically encrypted using the product's private key
|
|
1884
|
+
* @param data LLM model configuration
|
|
1885
|
+
* @param throwErrorIfExists Whether to throw error if model already exists
|
|
1886
|
+
*/
|
|
1887
|
+
async createModel(data, throwErrorIfExists = false) {
|
|
1888
|
+
if (!(await this.fetchModel(data.tag))) {
|
|
1889
|
+
await validators_1.CreateProductModelSchema.validateAsync(data);
|
|
1890
|
+
const processedEnvs = [];
|
|
1891
|
+
for (const env of data.envs) {
|
|
1892
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1893
|
+
if (!exists) {
|
|
1894
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1895
|
+
}
|
|
1896
|
+
// Store API key as secret and encrypt
|
|
1897
|
+
if (env.apiKey) {
|
|
1898
|
+
env.apiKey = await this.storeModelApiKeyAsSecret(env.apiKey, data.tag, env.slug);
|
|
1899
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1900
|
+
}
|
|
1901
|
+
processedEnvs.push(env);
|
|
1902
|
+
}
|
|
1903
|
+
data.envs = processedEnvs;
|
|
1904
|
+
const envs = await this.fetchEnvs();
|
|
1905
|
+
for (const env of envs) {
|
|
1906
|
+
const exists = data.envs.findIndex((modelEnv) => modelEnv.slug === env.slug);
|
|
1907
|
+
if (exists === -1) {
|
|
1908
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide API key configuration`);
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.MODEL, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1912
|
+
}
|
|
1913
|
+
else {
|
|
1914
|
+
if (throwErrorIfExists)
|
|
1915
|
+
throw new Error(`Model ${data.tag} already exists`);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
/**
|
|
1919
|
+
* Update an existing LLM model configuration
|
|
1920
|
+
* @param tag Model tag
|
|
1921
|
+
* @param data Updated model configuration
|
|
1922
|
+
*/
|
|
1923
|
+
async updateModel(tag, data) {
|
|
1924
|
+
try {
|
|
1925
|
+
const model = await this.fetchModel(tag);
|
|
1926
|
+
if (!model) {
|
|
1927
|
+
throw new Error(`Model ${tag} not found`);
|
|
1928
|
+
}
|
|
1929
|
+
const { _id, envs } = model;
|
|
1930
|
+
await validators_1.UpdateProductModelSchema.validateAsync(data);
|
|
1931
|
+
if (data.tag && (await this.fetchModel(data.tag))) {
|
|
1932
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
1933
|
+
}
|
|
1934
|
+
if (data.envs) {
|
|
1935
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
1936
|
+
const exists = await this.fetchEnv(env.slug);
|
|
1937
|
+
if (!exists) {
|
|
1938
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
1939
|
+
}
|
|
1940
|
+
// Store API key as secret and encrypt
|
|
1941
|
+
if (env.apiKey) {
|
|
1942
|
+
env.apiKey = await this.storeModelApiKeyAsSecret(env.apiKey, data.tag || tag, env.slug);
|
|
1943
|
+
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1944
|
+
}
|
|
1945
|
+
return env;
|
|
1946
|
+
}));
|
|
1947
|
+
const overwrite = [];
|
|
1948
|
+
const newEnvs = [];
|
|
1949
|
+
data.envs.forEach((dataEnv) => {
|
|
1950
|
+
const existsIdx = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
1951
|
+
if (existsIdx === -1) {
|
|
1952
|
+
newEnvs.push(dataEnv);
|
|
1953
|
+
}
|
|
1954
|
+
else {
|
|
1955
|
+
overwrite.push(Object.assign(Object.assign({}, envs[existsIdx]), dataEnv));
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1958
|
+
const unchanged = [];
|
|
1959
|
+
envs.forEach((env) => {
|
|
1960
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1961
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1962
|
+
if (!newEnv && !overwriteEnv) {
|
|
1963
|
+
unchanged.push(env);
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1966
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1967
|
+
}
|
|
1968
|
+
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());
|
|
1969
|
+
}
|
|
1970
|
+
catch (e) {
|
|
1971
|
+
throw e;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Fetch all LLM model configurations
|
|
1976
|
+
* @param version Optional version
|
|
1977
|
+
*/
|
|
1978
|
+
async fetchModels(version) {
|
|
1979
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'model', this.getUserAccess());
|
|
1980
|
+
return components;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Fetch a specific LLM model configuration by tag
|
|
1984
|
+
* @param tag Model tag
|
|
1985
|
+
* @param version Optional version
|
|
1986
|
+
*/
|
|
1987
|
+
async fetchModel(tag, version) {
|
|
1988
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'model', tag, this.getUserAccess());
|
|
1989
|
+
return component;
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Delete an LLM model configuration
|
|
1993
|
+
* @param tag Model tag
|
|
1994
|
+
*/
|
|
1995
|
+
async deleteModel(tag) {
|
|
1996
|
+
try {
|
|
1997
|
+
const model = await this.fetchModel(tag);
|
|
1998
|
+
if (!model) {
|
|
1999
|
+
throw new Error(`Model with tag: ${tag} not found`);
|
|
2000
|
+
}
|
|
2001
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2002
|
+
tag,
|
|
2003
|
+
component: enums_1.ProductComponents.MODEL,
|
|
2004
|
+
action: enums_1.RequestAction.DELETE,
|
|
2005
|
+
}, this.getUserAccess());
|
|
2006
|
+
}
|
|
2007
|
+
catch (e) {
|
|
2008
|
+
throw e;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
async validateAppData(appData, app) {
|
|
2012
|
+
// TODO:
|
|
2013
|
+
const { envs } = app;
|
|
2014
|
+
// const { envs: appEnvs, auths: appAuths } = appData
|
|
2015
|
+
const version = appData.versions.find((data) => (data.latest = true));
|
|
2016
|
+
app.envs = this.validateAppEnvs(envs, version);
|
|
2017
|
+
// await this.validateAppAuth(auth, appData);
|
|
2018
|
+
return app;
|
|
2019
|
+
}
|
|
2020
|
+
validateVariablesSchema(variables, appVariables) {
|
|
2021
|
+
if (variables && variables.length) {
|
|
2022
|
+
variables.map((data) => {
|
|
2023
|
+
const appVar = appVariables.find((value) => value.key === data.key);
|
|
2024
|
+
if (!appVar) {
|
|
2025
|
+
throw new Error(`variable key: ${data.key} not found`);
|
|
2026
|
+
}
|
|
2027
|
+
// if()
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
validateVariablesValues(variables, appVariables) {
|
|
2032
|
+
if (!variables) {
|
|
2033
|
+
variables = [];
|
|
2034
|
+
}
|
|
2035
|
+
if (appVariables && appVariables.length) {
|
|
2036
|
+
appVariables.map((data) => {
|
|
1067
2037
|
const find = variables.find((value) => value.key === data.key);
|
|
1068
2038
|
if (data.required) {
|
|
1069
2039
|
if (!find) {
|
|
@@ -1078,7 +2048,7 @@ class ProductsBuilderService {
|
|
|
1078
2048
|
const { envs: appEnvs } = version;
|
|
1079
2049
|
return envs.map((env) => {
|
|
1080
2050
|
const { auth } = env;
|
|
1081
|
-
this.fetchEnv(env.product_env_slug
|
|
2051
|
+
this.fetchEnv(env.product_env_slug);
|
|
1082
2052
|
const appEnv = appEnvs.find((appEnv) => appEnv.slug === env.app_env_slug);
|
|
1083
2053
|
if (!appEnv) {
|
|
1084
2054
|
throw new Error(`app_slug ${env.app_env_slug} not found`);
|
|
@@ -1168,10 +2138,10 @@ class ProductsBuilderService {
|
|
|
1168
2138
|
});
|
|
1169
2139
|
(0, inputs_utils_create_1.validateInputSchema)(queryValues, querySchema);
|
|
1170
2140
|
}
|
|
1171
|
-
const updateData = (0, processor_utils_1.encrypt)(JSON.stringify(data), this.
|
|
2141
|
+
const updateData = (0, processor_utils_1.encrypt)(JSON.stringify(data), this.product.private_key);
|
|
1172
2142
|
let updateValues = null;
|
|
1173
2143
|
if (exists.setup_type === enums_1.AuthTypes.TOKEN) {
|
|
1174
|
-
updateValues = (0, processor_utils_1.encrypt)(JSON.stringify(data), this.
|
|
2144
|
+
updateValues = (0, processor_utils_1.encrypt)(JSON.stringify(data), this.product.private_key);
|
|
1175
2145
|
}
|
|
1176
2146
|
return { data: updateData, values: updateValues };
|
|
1177
2147
|
}
|
|
@@ -1204,8 +2174,10 @@ class ProductsBuilderService {
|
|
|
1204
2174
|
throw new Error(`App ${app.access_tag} not found`);
|
|
1205
2175
|
}
|
|
1206
2176
|
const cleanedAppData = await this.validateAppData(appData, app);
|
|
1207
|
-
|
|
1208
|
-
|
|
2177
|
+
if (!cleanedAppData.pricing_tag) {
|
|
2178
|
+
cleanedAppData.pricing_tag = `${appData.tag}:${productsBuilder_types_1.PricingTag.FREE}`;
|
|
2179
|
+
}
|
|
2180
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, cleanedAppData), { app_tag: appData.tag, component: enums_1.ProductComponents.APP, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1209
2181
|
}
|
|
1210
2182
|
else {
|
|
1211
2183
|
if (throwErrorIfExists)
|
|
@@ -1236,7 +2208,7 @@ class ProductsBuilderService {
|
|
|
1236
2208
|
}
|
|
1237
2209
|
async updateApp(access_tag, data) {
|
|
1238
2210
|
try {
|
|
1239
|
-
const app = this.fetchApp(access_tag);
|
|
2211
|
+
const app = await this.fetchApp(access_tag);
|
|
1240
2212
|
if (!app) {
|
|
1241
2213
|
throw new Error(`App ${access_tag} not found`);
|
|
1242
2214
|
}
|
|
@@ -1252,28 +2224,43 @@ class ProductsBuilderService {
|
|
|
1252
2224
|
throw new Error(`access_tag ${access_tag} is in use`); // TODO: also check on the backend
|
|
1253
2225
|
}*/
|
|
1254
2226
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id }, data), { access_tag, component: enums_1.ProductComponents.APP, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
1255
|
-
await this.initializeProduct(this.product_id);
|
|
1256
2227
|
}
|
|
1257
2228
|
catch (e) {
|
|
1258
2229
|
throw e;
|
|
1259
2230
|
}
|
|
1260
2231
|
}
|
|
1261
|
-
fetchApps() {
|
|
2232
|
+
async fetchApps() {
|
|
1262
2233
|
return this.product.apps;
|
|
1263
2234
|
}
|
|
1264
|
-
fetchApp(tag, throwErrorIfExists = false) {
|
|
1265
|
-
const app = this.product.apps.find((data) => data.access_tag === tag);
|
|
2235
|
+
async fetchApp(tag, throwErrorIfExists = false) {
|
|
2236
|
+
const app = this.product.apps.find((data) => data.app_tag === tag || data.access_tag === tag);
|
|
1266
2237
|
if (!app && throwErrorIfExists)
|
|
1267
2238
|
throw new Error(`App ${tag} not found`);
|
|
1268
2239
|
return app;
|
|
1269
2240
|
}
|
|
2241
|
+
async deleteApp(tag) {
|
|
2242
|
+
try {
|
|
2243
|
+
const app = await this.fetchApp(tag, true);
|
|
2244
|
+
if (!app) {
|
|
2245
|
+
throw new Error(`App with tag: ${tag} not found`);
|
|
2246
|
+
}
|
|
2247
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2248
|
+
tag: app.access_tag,
|
|
2249
|
+
component: enums_1.ProductComponents.APP,
|
|
2250
|
+
action: enums_1.RequestAction.DELETE,
|
|
2251
|
+
}, this.getUserAccess());
|
|
2252
|
+
}
|
|
2253
|
+
catch (e) {
|
|
2254
|
+
throw e;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
1270
2257
|
async createFunction(data, throwErrorIfExists = false) {
|
|
1271
2258
|
try {
|
|
1272
2259
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
1273
|
-
if (!this.fetchFunction(data.tag)) {
|
|
2260
|
+
if (!(await this.fetchFunction(data.tag))) {
|
|
1274
2261
|
await validators_1.CreateProductFunctionSchema.validateAsync(data);
|
|
1275
2262
|
data.envs.map((env) => {
|
|
1276
|
-
env.auth = (0, processor_utils_1.encrypt)(JSON.stringify(env.auth), this.
|
|
2263
|
+
env.auth = (0, processor_utils_1.encrypt)(JSON.stringify(env.auth), this.product.private_key);
|
|
1277
2264
|
});
|
|
1278
2265
|
data.sample_data = (await this.inputsService.parseJson({
|
|
1279
2266
|
data: data.sample,
|
|
@@ -1286,7 +2273,6 @@ class ProductsBuilderService {
|
|
|
1286
2273
|
category: enums_1.Categories.DATA,
|
|
1287
2274
|
}));
|
|
1288
2275
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.FUNCTION, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1289
|
-
await this.initializeProduct(this.product_id);
|
|
1290
2276
|
}
|
|
1291
2277
|
else {
|
|
1292
2278
|
if (throwErrorIfExists)
|
|
@@ -1299,37 +2285,51 @@ class ProductsBuilderService {
|
|
|
1299
2285
|
}
|
|
1300
2286
|
async updateFunction(tag, data) {
|
|
1301
2287
|
try {
|
|
1302
|
-
const func = this.fetchFunction(tag);
|
|
2288
|
+
const func = await this.fetchFunction(tag);
|
|
1303
2289
|
if (!func) {
|
|
1304
2290
|
throw new Error(`Function ${tag} not found`);
|
|
1305
2291
|
}
|
|
1306
2292
|
const { _id } = func;
|
|
1307
2293
|
await validators_1.UpdateProductFunctionSchema.validateAsync(data); // Change to update;
|
|
1308
|
-
if (data.tag && this.fetchFunction(data.tag)) {
|
|
2294
|
+
if (data.tag && (await this.fetchFunction(data.tag))) {
|
|
1309
2295
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
1310
2296
|
}
|
|
1311
2297
|
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());
|
|
1312
|
-
await this.initializeProduct(this.product_id);
|
|
1313
2298
|
}
|
|
1314
2299
|
catch (e) {
|
|
1315
2300
|
throw e;
|
|
1316
2301
|
}
|
|
1317
2302
|
}
|
|
1318
|
-
fetchFunctions() {
|
|
1319
|
-
|
|
2303
|
+
async fetchFunctions(version) {
|
|
2304
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'function', this.getUserAccess());
|
|
2305
|
+
return components;
|
|
2306
|
+
}
|
|
2307
|
+
async fetchFunction(tag, version) {
|
|
2308
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'function', tag, this.getUserAccess());
|
|
2309
|
+
return component;
|
|
1320
2310
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
2311
|
+
async deleteFunction(tag) {
|
|
2312
|
+
try {
|
|
2313
|
+
const func = await this.fetchFunction(tag);
|
|
2314
|
+
if (!func) {
|
|
2315
|
+
throw new Error(`Function with tag: ${tag} not found`);
|
|
2316
|
+
}
|
|
2317
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2318
|
+
tag,
|
|
2319
|
+
component: enums_1.ProductComponents.FUNCTION,
|
|
2320
|
+
action: enums_1.RequestAction.DELETE,
|
|
2321
|
+
}, this.getUserAccess());
|
|
2322
|
+
}
|
|
2323
|
+
catch (e) {
|
|
2324
|
+
throw e;
|
|
2325
|
+
}
|
|
1325
2326
|
}
|
|
1326
2327
|
async createCache(data, throwErrorIfExists = false) {
|
|
1327
2328
|
try {
|
|
1328
2329
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
1329
|
-
if (!this.fetchCache(data.tag)) {
|
|
2330
|
+
if (!(await this.fetchCache(data.tag))) {
|
|
1330
2331
|
await validators_1.CreateProductCacheSchema.validateAsync(data);
|
|
1331
2332
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.CACHE, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1332
|
-
await this.initializeProduct(this.product_id);
|
|
1333
2333
|
}
|
|
1334
2334
|
else {
|
|
1335
2335
|
if (throwErrorIfExists)
|
|
@@ -1342,62 +2342,75 @@ class ProductsBuilderService {
|
|
|
1342
2342
|
}
|
|
1343
2343
|
async updateCache(tag, data) {
|
|
1344
2344
|
try {
|
|
1345
|
-
const cache = this.fetchCache(tag);
|
|
2345
|
+
const cache = await this.fetchCache(tag);
|
|
1346
2346
|
if (!cache) {
|
|
1347
2347
|
throw new Error(`Cache ${tag} not found`);
|
|
1348
2348
|
}
|
|
1349
2349
|
const { _id } = cache;
|
|
1350
2350
|
await validators_1.UpdateProductCacheSchema.validateAsync(data); // Change to update;
|
|
1351
|
-
if (data.tag && this.fetchCache(data.tag)) {
|
|
2351
|
+
if (data.tag && (await this.fetchCache(data.tag))) {
|
|
1352
2352
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
1353
2353
|
}
|
|
1354
2354
|
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());
|
|
1355
|
-
await this.initializeProduct(this.product_id);
|
|
1356
2355
|
}
|
|
1357
2356
|
catch (e) {
|
|
1358
2357
|
throw e;
|
|
1359
2358
|
}
|
|
1360
2359
|
}
|
|
1361
|
-
|
|
1362
|
-
const
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
2360
|
+
async fetchCaches(version) {
|
|
2361
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'cache', this.getUserAccess());
|
|
2362
|
+
return components;
|
|
2363
|
+
}
|
|
2364
|
+
async fetchCache(tag, version) {
|
|
2365
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'cache', tag, this.getUserAccess());
|
|
2366
|
+
return component;
|
|
1366
2367
|
}
|
|
1367
|
-
|
|
1368
|
-
|
|
2368
|
+
async deleteCache(tag) {
|
|
2369
|
+
try {
|
|
2370
|
+
const cache = await this.fetchCache(tag);
|
|
2371
|
+
if (!cache) {
|
|
2372
|
+
throw new Error(`Cache with tag: ${tag} not found`);
|
|
2373
|
+
}
|
|
2374
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2375
|
+
tag,
|
|
2376
|
+
component: enums_1.ProductComponents.CACHE,
|
|
2377
|
+
action: enums_1.RequestAction.DELETE,
|
|
2378
|
+
}, this.getUserAccess());
|
|
2379
|
+
}
|
|
2380
|
+
catch (e) {
|
|
2381
|
+
throw e;
|
|
2382
|
+
}
|
|
1369
2383
|
}
|
|
1370
2384
|
async createNotification(data, throwErrorIfExists = false) {
|
|
1371
2385
|
try {
|
|
1372
2386
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
1373
|
-
if (!this.fetchNotification(data.tag)) {
|
|
2387
|
+
if (!(await this.fetchNotification(data.tag))) {
|
|
1374
2388
|
await validators_1.CreateProductNotificationSchema.validateAsync(data);
|
|
1375
|
-
const envs = this.fetchEnvs();
|
|
1376
|
-
|
|
2389
|
+
const envs = await this.fetchEnvs();
|
|
2390
|
+
for (const env of envs) {
|
|
1377
2391
|
const exists = data.envs.findIndex((nEnv) => nEnv.slug === env.slug);
|
|
1378
2392
|
if (exists === -1) {
|
|
1379
2393
|
throw new Error(`Notification for environment ${env.slug} is not defined, please provide the environment details`);
|
|
1380
2394
|
}
|
|
1381
|
-
}
|
|
2395
|
+
}
|
|
1382
2396
|
for (let i = 0; i < data.envs.length; i++) {
|
|
2397
|
+
// Process secrets for each notification handler
|
|
2398
|
+
const processedEnv = await this.processNotificationEnvSecrets(data.envs[i], data.tag, data.envs[i].slug);
|
|
1383
2399
|
const updates = {
|
|
1384
|
-
push_notifications:
|
|
1385
|
-
? (0, processor_utils_1.encrypt)(JSON.stringify(
|
|
2400
|
+
push_notifications: processedEnv.push_notifications
|
|
2401
|
+
? (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.push_notifications), this.product.private_key)
|
|
1386
2402
|
: undefined,
|
|
1387
|
-
emails:
|
|
1388
|
-
? (0, processor_utils_1.encrypt)(JSON.stringify(
|
|
2403
|
+
emails: processedEnv.emails
|
|
2404
|
+
? (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.emails), this.product.private_key)
|
|
1389
2405
|
: undefined,
|
|
1390
|
-
callbacks:
|
|
1391
|
-
? (0, processor_utils_1.encrypt)(JSON.stringify(
|
|
1392
|
-
: undefined,
|
|
1393
|
-
sms: data.envs[i].sms
|
|
1394
|
-
? (0, processor_utils_1.encrypt)(JSON.stringify(data.envs[i].sms), this.fetchProduct().private_key)
|
|
2406
|
+
callbacks: processedEnv.callbacks
|
|
2407
|
+
? (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.callbacks), this.product.private_key)
|
|
1395
2408
|
: undefined,
|
|
2409
|
+
sms: processedEnv.sms ? (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.sms), this.product.private_key) : undefined,
|
|
1396
2410
|
};
|
|
1397
2411
|
data.envs[i] = Object.assign(Object.assign({}, data.envs[i]), updates);
|
|
1398
2412
|
}
|
|
1399
2413
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.NOTIFICATION, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1400
|
-
await this.initializeProduct(this.product_id);
|
|
1401
2414
|
}
|
|
1402
2415
|
else {
|
|
1403
2416
|
if (throwErrorIfExists)
|
|
@@ -1418,7 +2431,7 @@ class ProductsBuilderService {
|
|
|
1418
2431
|
if (!notificationTag || !tag) {
|
|
1419
2432
|
throw new Error(`tag is expected to be defined as "notification_tag:message_tag"`);
|
|
1420
2433
|
}
|
|
1421
|
-
const exists = this.fetchNotificationMessage(data.tag);
|
|
2434
|
+
const exists = await this.fetchNotificationMessage(data.tag);
|
|
1422
2435
|
data.tag = tag;
|
|
1423
2436
|
if (!exists) {
|
|
1424
2437
|
if (!data.email && !data.push_notification && !data.callback) {
|
|
@@ -1455,7 +2468,6 @@ class ProductsBuilderService {
|
|
|
1455
2468
|
data.sms_data = (0, string_utils_1.extractPlaceholders)(data.sms, '');
|
|
1456
2469
|
}
|
|
1457
2470
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { notificationTag, component: enums_1.ProductComponents.NOTIFICATION_MESSAGE, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
1458
|
-
await this.initializeProduct(this.product_id);
|
|
1459
2471
|
}
|
|
1460
2472
|
else {
|
|
1461
2473
|
if (throwErrorIfExists)
|
|
@@ -1466,12 +2478,12 @@ class ProductsBuilderService {
|
|
|
1466
2478
|
throw e;
|
|
1467
2479
|
}
|
|
1468
2480
|
}
|
|
1469
|
-
fetchNotificationMessage(tag, throwErrorIfExists = false) {
|
|
2481
|
+
async fetchNotificationMessage(tag, throwErrorIfExists = false) {
|
|
1470
2482
|
const [notificationTag, messageTag] = tag.split(':');
|
|
1471
2483
|
if (!notificationTag || !messageTag) {
|
|
1472
2484
|
throw new Error(`tag is expected to be defined as "notification_tag:message_tag"`);
|
|
1473
2485
|
}
|
|
1474
|
-
const notification = this.fetchNotification(notificationTag);
|
|
2486
|
+
const notification = await this.fetchNotification(notificationTag);
|
|
1475
2487
|
if (!notification)
|
|
1476
2488
|
throw new Error(`Notification ${notificationTag} not found`);
|
|
1477
2489
|
const message = notification.messages.find((data) => data.tag === messageTag);
|
|
@@ -1479,7 +2491,7 @@ class ProductsBuilderService {
|
|
|
1479
2491
|
throw new Error(`Notification message ${tag} not found`);
|
|
1480
2492
|
return message;
|
|
1481
2493
|
}
|
|
1482
|
-
fetchNotificationMessages(notificationTag, throwErrorIfExists = false) {
|
|
2494
|
+
async fetchNotificationMessages(notificationTag, throwErrorIfExists = false) {
|
|
1483
2495
|
const notification = this.product.notifications.find((data) => data.tag === notificationTag);
|
|
1484
2496
|
if (!notification)
|
|
1485
2497
|
throw new Error(`Notification ${notificationTag} not found`);
|
|
@@ -1487,7 +2499,7 @@ class ProductsBuilderService {
|
|
|
1487
2499
|
}
|
|
1488
2500
|
async updateNotificationMessage(data) {
|
|
1489
2501
|
try {
|
|
1490
|
-
console.log(
|
|
2502
|
+
console.log('NOTIFICATION DATA!!', data);
|
|
1491
2503
|
await update_productNotificationMessage_validator_1.default.validateAsync(data);
|
|
1492
2504
|
if (!data.tag) {
|
|
1493
2505
|
throw new Error('tag field is required');
|
|
@@ -1533,7 +2545,6 @@ class ProductsBuilderService {
|
|
|
1533
2545
|
const payload = Object.assign(Object.assign(Object.assign({}, message), data), { notificationTag, component: enums_1.ProductComponents.NOTIFICATION_MESSAGE, action: enums_1.RequestAction.UPDATE });
|
|
1534
2546
|
// Update product and reinitialize
|
|
1535
2547
|
await this.productApi.updateProduct(this.product_id, payload, this.getUserAccess());
|
|
1536
|
-
await this.initializeProduct(this.product_id);
|
|
1537
2548
|
}
|
|
1538
2549
|
catch (error) {
|
|
1539
2550
|
throw error;
|
|
@@ -1541,21 +2552,25 @@ class ProductsBuilderService {
|
|
|
1541
2552
|
}
|
|
1542
2553
|
async updateNotification(tag, data) {
|
|
1543
2554
|
try {
|
|
1544
|
-
const
|
|
1545
|
-
if (
|
|
2555
|
+
const notificationResult = await this.fetchNotification(tag);
|
|
2556
|
+
if (!notificationResult) {
|
|
2557
|
+
throw new Error(`Notification with tag ${tag} not found`);
|
|
2558
|
+
}
|
|
2559
|
+
const { _id, envs } = notificationResult;
|
|
2560
|
+
if (data.tag && tag !== data.tag && (await this.fetchNotification(data.tag))) {
|
|
1546
2561
|
throw new Error(`Notification of tag ${data.tag} already exists`);
|
|
1547
2562
|
}
|
|
1548
2563
|
await validators_1.UpdateProductNotificationSchema.validateAsync(data); // Change to update;
|
|
1549
|
-
let notification = this.fetchNotification(tag);
|
|
2564
|
+
let notification = await this.fetchNotification(tag);
|
|
1550
2565
|
if (!notification) {
|
|
1551
2566
|
throw new Error(`Notification with tag ${tag} not found`);
|
|
1552
2567
|
}
|
|
1553
2568
|
if (data.envs) {
|
|
1554
2569
|
const overwrite = [];
|
|
1555
2570
|
const newEnvs = [];
|
|
1556
|
-
data.envs
|
|
2571
|
+
for (const dataEnv of data.envs) {
|
|
1557
2572
|
const exists = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
1558
|
-
if (!this.fetchEnv(dataEnv.slug)) {
|
|
2573
|
+
if (!(await this.fetchEnv(dataEnv.slug))) {
|
|
1559
2574
|
throw new Error(`Product Environment ${dataEnv.slug} doesn't exist`);
|
|
1560
2575
|
}
|
|
1561
2576
|
if (exists === -1) {
|
|
@@ -1565,70 +2580,61 @@ class ProductsBuilderService {
|
|
|
1565
2580
|
else {
|
|
1566
2581
|
overwrite.push(Object.assign(Object.assign({}, envs[exists]), dataEnv));
|
|
1567
2582
|
}
|
|
1568
|
-
}
|
|
2583
|
+
}
|
|
1569
2584
|
const unchanged = [];
|
|
1570
|
-
|
|
2585
|
+
for (const env of envs) {
|
|
1571
2586
|
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1572
2587
|
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
1573
2588
|
if (!newEnv && !overwriteEnv) {
|
|
1574
2589
|
unchanged.push(env);
|
|
1575
2590
|
}
|
|
1576
|
-
}
|
|
2591
|
+
}
|
|
1577
2592
|
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
1578
2593
|
}
|
|
1579
2594
|
const update = Object.assign(Object.assign({}, notification), data);
|
|
1580
|
-
update.envs.
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
2595
|
+
for (let i = 0; i < update.envs.length; i++) {
|
|
2596
|
+
const env = update.envs[i];
|
|
2597
|
+
// Process secrets for each notification handler
|
|
2598
|
+
const processedEnv = await this.processNotificationEnvSecrets(env, data.tag || tag, env.slug);
|
|
2599
|
+
if (processedEnv.emails)
|
|
2600
|
+
update.envs[i].emails = (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.emails), this.product.private_key);
|
|
2601
|
+
if (processedEnv.push_notifications)
|
|
2602
|
+
update.envs[i].push_notifications = (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.push_notifications), this.product.private_key);
|
|
2603
|
+
if (processedEnv.callbacks)
|
|
2604
|
+
update.envs[i].callbacks = (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.callbacks), this.product.private_key);
|
|
2605
|
+
if (processedEnv.sms)
|
|
2606
|
+
update.envs[i].sms = (0, processor_utils_1.encrypt)(JSON.stringify(processedEnv.sms), this.product.private_key);
|
|
2607
|
+
}
|
|
1591
2608
|
const payload = Object.assign(Object.assign({ _id }, update), { component: enums_1.ProductComponents.NOTIFICATION, action: enums_1.RequestAction.UPDATE });
|
|
1592
2609
|
await this.productApi.updateProduct(this.product_id, payload, this.getUserAccess());
|
|
1593
|
-
await this.initializeProduct(this.product_id);
|
|
1594
2610
|
}
|
|
1595
2611
|
catch (e) {
|
|
1596
2612
|
throw e;
|
|
1597
2613
|
}
|
|
1598
2614
|
}
|
|
1599
|
-
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
throw new Error(`Notification ${tag} is in use`);
|
|
1603
|
-
/*if (notification_slug) {
|
|
1604
|
-
const { notifications, emails, callbacks } = notification.envs.find(
|
|
1605
|
-
(data: INotificationEnv) => (data.slug = notification_slug),
|
|
1606
|
-
);
|
|
1607
|
-
return { notifications, emails, callbacks };
|
|
1608
|
-
}*/
|
|
1609
|
-
if (notification) {
|
|
1610
|
-
notification.envs.map((data) => {
|
|
1611
|
-
if (data.callbacks && typeof data.callbacks == 'string') {
|
|
1612
|
-
data.callbacks = JSON.parse((0, processor_utils_1.decrypt)(String(data.callbacks), this.fetchProduct().private_key));
|
|
1613
|
-
}
|
|
1614
|
-
if (data.push_notifications && typeof data.push_notifications == 'string') {
|
|
1615
|
-
data.push_notifications = JSON.parse((0, processor_utils_1.decrypt)(String(data.push_notifications), this.fetchProduct().private_key));
|
|
1616
|
-
}
|
|
1617
|
-
if (data.emails && typeof data.emails == 'string') {
|
|
1618
|
-
data.emails = JSON.parse((0, processor_utils_1.decrypt)(String(data.emails), this.fetchProduct().private_key));
|
|
1619
|
-
}
|
|
1620
|
-
if (data.sms && typeof data.sms == 'string') {
|
|
1621
|
-
data.sms = JSON.parse((0, processor_utils_1.decrypt)(String(data.sms), this.fetchProduct().private_key));
|
|
1622
|
-
}
|
|
1623
|
-
return data;
|
|
1624
|
-
});
|
|
1625
|
-
}
|
|
1626
|
-
return notification;
|
|
2615
|
+
async fetchNotifications(version) {
|
|
2616
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'notification', this.getUserAccess());
|
|
2617
|
+
return components;
|
|
1627
2618
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
2619
|
+
async fetchNotification(tag, version) {
|
|
2620
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'notification', tag, this.getUserAccess());
|
|
2621
|
+
return component;
|
|
2622
|
+
}
|
|
2623
|
+
async deleteNotification(tag) {
|
|
2624
|
+
try {
|
|
2625
|
+
const notification = await this.fetchNotification(tag);
|
|
2626
|
+
if (!notification) {
|
|
2627
|
+
throw new Error(`Notification with tag: ${tag} not found`);
|
|
2628
|
+
}
|
|
2629
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
2630
|
+
tag,
|
|
2631
|
+
component: enums_1.ProductComponents.NOTIFICATION,
|
|
2632
|
+
action: enums_1.RequestAction.DELETE,
|
|
2633
|
+
}, this.getUserAccess());
|
|
2634
|
+
}
|
|
2635
|
+
catch (e) {
|
|
2636
|
+
throw e;
|
|
2637
|
+
}
|
|
1632
2638
|
}
|
|
1633
2639
|
validateFeatureSequence(array) {
|
|
1634
2640
|
// Validate uniqueness of sequence_tag
|
|
@@ -1728,24 +2734,27 @@ class ProductsBuilderService {
|
|
|
1728
2734
|
await this.validateActionDataInput(data, action, event.input, event_index, sequence_index);
|
|
1729
2735
|
}
|
|
1730
2736
|
async checkAndValidateFunctionDataInput(data, sequence_index, event, event_index) {
|
|
1731
|
-
const func = this.fetchFunction(event.event);
|
|
2737
|
+
const func = (await this.fetchFunction(event.event));
|
|
1732
2738
|
await this.validateActionDataInput(data, func, event.input, event_index, sequence_index);
|
|
1733
2739
|
}
|
|
1734
2740
|
async checkAndValidateDBActionDataInput(data, sequence_index, event, event_index) {
|
|
1735
2741
|
console.log('EVENTY', event.event);
|
|
1736
|
-
const { filterData, data: dbData, filterTemplate, template } = this.fetchDatabaseAction(event.event);
|
|
2742
|
+
const { filterData, data: dbData, filterTemplate, template } = await this.fetchDatabaseAction(event.event);
|
|
1737
2743
|
await this.validateDBActionDataInput(data, { filterData, data: dbData, template, filter: filterTemplate }, event.input, event_index, sequence_index);
|
|
1738
2744
|
}
|
|
1739
2745
|
async checkAndValidateFeatureDataInput(data, sequence_index, event, event_index) {
|
|
1740
|
-
const
|
|
2746
|
+
const feature = await this.fetchFeature(event.event);
|
|
2747
|
+
if (!feature)
|
|
2748
|
+
throw new Error(`Feature ${event.event} not found`);
|
|
2749
|
+
const { input } = feature;
|
|
1741
2750
|
await this.validateFeatureDataInput(data, input, event.input, event_index, sequence_index);
|
|
1742
2751
|
}
|
|
1743
2752
|
async checkAndValidateNotificationDataInput(data, sequence_index, event, event_index) {
|
|
1744
|
-
const { callback_data: callback, push_notification_data: notification, email_data: email, sms_data: sms, } = this.fetchNotificationMessage(event.event);
|
|
2753
|
+
const { callback_data: callback, push_notification_data: notification, email_data: email, sms_data: sms, } = await this.fetchNotificationMessage(event.event);
|
|
1745
2754
|
await this.validateNotificationDataInput(data, { callback, notification, email, sms }, event.input, event_index, sequence_index);
|
|
1746
2755
|
}
|
|
1747
2756
|
async checkAndValidatePublishDataInput(data, sequence_index, event, event_index) {
|
|
1748
|
-
const topic = this.fetchMessageBrokerTopic(event.event);
|
|
2757
|
+
const topic = await this.fetchMessageBrokerTopic(event.event);
|
|
1749
2758
|
if (!topic) {
|
|
1750
2759
|
throw new Error(`Topic ${event.event} not registered`);
|
|
1751
2760
|
}
|
|
@@ -1753,14 +2762,14 @@ class ProductsBuilderService {
|
|
|
1753
2762
|
//await this.validatePublishTopicDataInput(data, { data: topicData }, event.input, event_index, sequence_index)
|
|
1754
2763
|
}
|
|
1755
2764
|
async checkAndValidateStorageDataInput(data, sequence_index, event, event_index) {
|
|
1756
|
-
const storage = this.fetchStorage(event.event);
|
|
2765
|
+
const storage = await this.fetchStorage(event.event);
|
|
1757
2766
|
if (!storage) {
|
|
1758
2767
|
throw new Error(`Storage ${event.event} does not exist`);
|
|
1759
2768
|
}
|
|
1760
2769
|
//await this.validateStorageDataInput(data, {}, event.input, event_index, sequence_index);
|
|
1761
2770
|
}
|
|
1762
2771
|
async checkAndValidateJobDataInput(data, sequence_index, event, event_index) {
|
|
1763
|
-
const job = this.fetchJob(event.event);
|
|
2772
|
+
const job = await this.fetchJob(event.event);
|
|
1764
2773
|
if (job.type === productsBuilder_types_1.JobEventTypes.ACTION) {
|
|
1765
2774
|
await this.checkAndValidateActionDataInput(data, sequence_index, event, event_index);
|
|
1766
2775
|
}
|
|
@@ -1776,9 +2785,6 @@ class ProductsBuilderService {
|
|
|
1776
2785
|
if (job.type === productsBuilder_types_1.JobEventTypes.PUBLISH) {
|
|
1777
2786
|
await this.checkAndValidatePublishDataInput(data, sequence_index, event, event_index);
|
|
1778
2787
|
}
|
|
1779
|
-
if (job.type === productsBuilder_types_1.JobEventTypes.FUNCTION) {
|
|
1780
|
-
await this.checkAndValidateFunctionDataInput(data, sequence_index, event, event_index);
|
|
1781
|
-
}
|
|
1782
2788
|
}
|
|
1783
2789
|
async checkAndValidateFallbackDataInput(data, sequence_index, event, event_index) { }
|
|
1784
2790
|
async validateEvent(data, sequence_index, event, event_index) {
|
|
@@ -1800,7 +2806,7 @@ class ProductsBuilderService {
|
|
|
1800
2806
|
await this.checkAndValidatePublishDataInput(data, sequence_index, event, event_index);
|
|
1801
2807
|
}
|
|
1802
2808
|
/*if (event.type === FeatureEventTypes.SUBSCRIBE) {
|
|
1803
|
-
const topic = this.fetchMessageBrokerTopic(event.event);
|
|
2809
|
+
const topic = await this.fetchMessageBrokerTopic(event.event);
|
|
1804
2810
|
|
|
1805
2811
|
if(!topic) {
|
|
1806
2812
|
throw new Error(`Topic ${event.event} not registered`);
|
|
@@ -2003,7 +3009,7 @@ class ProductsBuilderService {
|
|
|
2003
3009
|
});
|
|
2004
3010
|
}
|
|
2005
3011
|
async validateActionInputData(data, skipSample = false, option = false, optionIndex = 0) {
|
|
2006
|
-
var _a;
|
|
3012
|
+
var _a, _b;
|
|
2007
3013
|
const { obj } = data, base_data = __rest(data, ["obj"]);
|
|
2008
3014
|
if (!data.sample && Object.keys(obj).length === 0) {
|
|
2009
3015
|
return;
|
|
@@ -2011,8 +3017,8 @@ class ProductsBuilderService {
|
|
|
2011
3017
|
if (!data.sample) {
|
|
2012
3018
|
throw new Error('Something unexpected happened in validating action input');
|
|
2013
3019
|
}
|
|
2014
|
-
const sequence = data.feature.sequence[data.sequence_index];
|
|
2015
|
-
if (obj === undefined || obj === null) {
|
|
3020
|
+
const sequence = data.feature.sequence ? (_a = data.feature) === null || _a === void 0 ? void 0 : _a.sequence[data.sequence_index] : null;
|
|
3021
|
+
if ((obj === undefined || obj === null) && sequence) {
|
|
2016
3022
|
if (!option) {
|
|
2017
3023
|
throw new Error(`sequence ${sequence.tag} event ${sequence.events[data.event_index].event} ${data.type} should not be ${obj}`);
|
|
2018
3024
|
}
|
|
@@ -2020,7 +3026,7 @@ class ProductsBuilderService {
|
|
|
2020
3026
|
throw new Error(`option event index ${optionIndex}, ${data.type} should not be ${obj}`);
|
|
2021
3027
|
}
|
|
2022
3028
|
}
|
|
2023
|
-
if (Object.values(obj).length > 0 && ((
|
|
3029
|
+
if (sequence && Object.values(obj).length > 0 && ((_b = data.sample.data) === null || _b === void 0 ? void 0 : _b.length) === 0) {
|
|
2024
3030
|
if (!option) {
|
|
2025
3031
|
throw new Error(`sequence ${sequence.tag} event ${sequence.events[data.event_index].event} ${data.type} should be an empty object`);
|
|
2026
3032
|
}
|
|
@@ -2031,7 +3037,7 @@ class ProductsBuilderService {
|
|
|
2031
3037
|
if (Object.values(obj).length === 0 && data.sample.data.length === 0 /*data.sample?.data?.length === 0*/) {
|
|
2032
3038
|
return;
|
|
2033
3039
|
}
|
|
2034
|
-
if (Object.values(obj).length === 0 && data.sample.data.length > 0 && !skipSample) {
|
|
3040
|
+
if (sequence && Object.values(obj).length === 0 && data.sample.data.length > 0 && !skipSample) {
|
|
2035
3041
|
//console.log("validity err: ",obj, data.sample)
|
|
2036
3042
|
if (!option) {
|
|
2037
3043
|
throw new Error(`sequence ${sequence.tag} event ${sequence.events[data.event_index].event} ${data.type} should not be an empty object`);
|
|
@@ -2207,7 +3213,9 @@ class ProductsBuilderService {
|
|
|
2207
3213
|
let current_input = input;
|
|
2208
3214
|
for (let i = 0; i < stages.length; i++) {
|
|
2209
3215
|
let stage = stages[i];
|
|
2210
|
-
|
|
3216
|
+
// Convert to string for .match() call
|
|
3217
|
+
const stageStr = String(stage);
|
|
3218
|
+
const matches = stageStr.match(/^\[(\d+)\]$/);
|
|
2211
3219
|
if (matches && matches.length === 2) {
|
|
2212
3220
|
const number = parseInt(matches[1], 10);
|
|
2213
3221
|
if (!isNaN(number)) {
|
|
@@ -2263,14 +3271,16 @@ class ProductsBuilderService {
|
|
|
2263
3271
|
}
|
|
2264
3272
|
else {
|
|
2265
3273
|
//const envs =
|
|
2266
|
-
const app = this.fetchApp(access_tag);
|
|
3274
|
+
const app = await this.fetchApp(access_tag);
|
|
2267
3275
|
const { envs } = app;
|
|
2268
3276
|
await Promise.all(envs.map((env) => {
|
|
2269
3277
|
if (stages[0] !== env.auth.auth_tag) {
|
|
2270
3278
|
throw new Error(`Auth ${stages[0]} does not exist on env ${env.product_env_slug} on app ${access_tag}`);
|
|
2271
3279
|
}
|
|
2272
|
-
const decrypted = JSON.parse((0, processor_utils_1.decrypt)(env.auth.values, this.
|
|
2273
|
-
|
|
3280
|
+
const decrypted = JSON.parse((0, processor_utils_1.decrypt)(env.auth.values, this.product.private_key));
|
|
3281
|
+
// Convert stages to string[] for findFaultyKeys
|
|
3282
|
+
const stringStages = stages.slice(1).map((stage) => String(stage));
|
|
3283
|
+
const check = (0, objects_utils_1.findFaultyKeys)(stringStages, decrypted);
|
|
2274
3284
|
if (check.faultyKeys) {
|
|
2275
3285
|
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}`);
|
|
2276
3286
|
}
|
|
@@ -2286,7 +3296,9 @@ class ProductsBuilderService {
|
|
|
2286
3296
|
let i = 1;
|
|
2287
3297
|
while (i < stages.length) {
|
|
2288
3298
|
let stage = stages[i];
|
|
2289
|
-
|
|
3299
|
+
// Convert to string for .match() call
|
|
3300
|
+
const stageStr = String(stage);
|
|
3301
|
+
const matches = stageStr.match(/^\[(\d+)\]$/);
|
|
2290
3302
|
if (matches && matches.length === 2) {
|
|
2291
3303
|
const number = parseInt(matches[1], 10);
|
|
2292
3304
|
if (!isNaN(number)) {
|
|
@@ -2360,11 +3372,15 @@ class ProductsBuilderService {
|
|
|
2360
3372
|
// let current_data;
|
|
2361
3373
|
if (i === 0) {
|
|
2362
3374
|
// find sequence by tag, see if it exists and its before current sequence
|
|
2363
|
-
|
|
2364
|
-
|
|
3375
|
+
// Convert stage to string for function calls
|
|
3376
|
+
const stageStr = String(stage);
|
|
3377
|
+
this.validateSequenceInputParents(stageStr, meta.sequence_index, meta.feature.sequence);
|
|
3378
|
+
sequence = this.fetchPriorSequence(meta, stageStr);
|
|
2365
3379
|
}
|
|
2366
3380
|
if (i === 1 && sequence) {
|
|
2367
|
-
|
|
3381
|
+
// Convert stage to string for function calls
|
|
3382
|
+
const stageStr = String(stage);
|
|
3383
|
+
event = this.fetchSequenceEvent(sequence, stageStr);
|
|
2368
3384
|
if (!event) {
|
|
2369
3385
|
throw new Error(`event ${stage} not found in sequence ${sequence.tag}`);
|
|
2370
3386
|
}
|
|
@@ -2393,7 +3409,9 @@ class ProductsBuilderService {
|
|
|
2393
3409
|
if (i > 1 && response) {
|
|
2394
3410
|
let parent_index = 0;
|
|
2395
3411
|
let increment = false;
|
|
2396
|
-
|
|
3412
|
+
// Convert to string for .match() call
|
|
3413
|
+
const stageStr = String(stage);
|
|
3414
|
+
const matches = stageStr.match(/^\[(\d+)\]$/);
|
|
2397
3415
|
if (matches && matches.length === 2) {
|
|
2398
3416
|
const number = parseInt(matches[1], 10);
|
|
2399
3417
|
if (!isNaN(number)) {
|
|
@@ -2451,7 +3469,7 @@ class ProductsBuilderService {
|
|
|
2451
3469
|
if (stages.length > 2) {
|
|
2452
3470
|
throw new Error(`sequence ${sequence.tag} event ${sequence.events[meta.event_index].event} ${meta.type}, has invalid varibale definition ${value}, only two keys is required`);
|
|
2453
3471
|
}
|
|
2454
|
-
const app = this.fetchApp(stages[0]);
|
|
3472
|
+
const app = await this.fetchApp(String(stages[0]));
|
|
2455
3473
|
if (!app) {
|
|
2456
3474
|
throw new Error(`App ${stages[0]} not found in sequence ${sequence.tag} event ${sequence.events[meta.event_index].event} ${meta.type}, has invalid varibale definition ${value}. `);
|
|
2457
3475
|
}
|
|
@@ -2468,8 +3486,8 @@ class ProductsBuilderService {
|
|
|
2468
3486
|
if (stages.length !== 2) {
|
|
2469
3487
|
throw new Error(`When using constants you need to specify the constant in the format $Constant{app_tag}{key} instead of ${value}`);
|
|
2470
3488
|
}
|
|
2471
|
-
const app_tag = stages[0];
|
|
2472
|
-
const key = stages[1];
|
|
3489
|
+
const app_tag = String(stages[0]);
|
|
3490
|
+
const key = String(stages[1]);
|
|
2473
3491
|
const _c = await this.fetchThirdPartyAppByAccessTag(app_tag), { version } = _c, app = __rest(_c, ["version"]);
|
|
2474
3492
|
if (!app) {
|
|
2475
3493
|
throw new Error(`App ${app_tag} not found in constant ${value}`);
|
|
@@ -2559,9 +3577,10 @@ class ProductsBuilderService {
|
|
|
2559
3577
|
return found;
|
|
2560
3578
|
}
|
|
2561
3579
|
validateActionKeyPlacement(data) {
|
|
3580
|
+
var _a;
|
|
2562
3581
|
const actionData = data.sample.data;
|
|
2563
3582
|
const { indexes } = data;
|
|
2564
|
-
const sequence = data.feature.sequence[data.sequence_index];
|
|
3583
|
+
const sequence = data.feature.sequence ? (_a = data.feature) === null || _a === void 0 ? void 0 : _a.sequence[data.sequence_index] : null;
|
|
2565
3584
|
const datapoint = actionData.find((item) => {
|
|
2566
3585
|
return (item.parent_key === indexes.parent_key && item.key === data.key && item.level === indexes.level //&&
|
|
2567
3586
|
//indexes.index === item.index
|
|
@@ -2569,7 +3588,12 @@ class ProductsBuilderService {
|
|
|
2569
3588
|
});
|
|
2570
3589
|
if (!datapoint) {
|
|
2571
3590
|
console.log('VALIDATE', data.key, data.value, actionData, indexes);
|
|
2572
|
-
|
|
3591
|
+
if (sequence) {
|
|
3592
|
+
throw new Error(`Key ${data.key} not found for ${data.type} for sequence ${sequence.tag} event ${sequence.events[data.event_index].event}`);
|
|
3593
|
+
}
|
|
3594
|
+
else {
|
|
3595
|
+
throw new Error(`Key ${data.key} not found`);
|
|
3596
|
+
}
|
|
2573
3597
|
}
|
|
2574
3598
|
return datapoint;
|
|
2575
3599
|
}
|
|
@@ -2600,12 +3624,11 @@ class ProductsBuilderService {
|
|
|
2600
3624
|
}
|
|
2601
3625
|
async createFeature(data, throwErrorIfExists = false) {
|
|
2602
3626
|
try {
|
|
2603
|
-
if (!this.fetchFeature(data.tag
|
|
3627
|
+
if (!(await this.fetchFeature(data.tag))) {
|
|
2604
3628
|
await validators_1.CreateProductFeatureSchema.validateAsync(data);
|
|
2605
3629
|
try {
|
|
2606
3630
|
await this.validateFeatureData(data);
|
|
2607
3631
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.FEATURE, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
2608
|
-
await this.initializeProduct(this.product_id);
|
|
2609
3632
|
}
|
|
2610
3633
|
catch (e) {
|
|
2611
3634
|
throw e;
|
|
@@ -2622,7 +3645,7 @@ class ProductsBuilderService {
|
|
|
2622
3645
|
}
|
|
2623
3646
|
async updateFeature(tag, data) {
|
|
2624
3647
|
try {
|
|
2625
|
-
const feature = this.fetchFeature(tag);
|
|
3648
|
+
const feature = await this.fetchFeature(tag);
|
|
2626
3649
|
if (!feature) {
|
|
2627
3650
|
throw new Error(`Feature ${tag} not found`);
|
|
2628
3651
|
}
|
|
@@ -2634,43 +3657,58 @@ class ProductsBuilderService {
|
|
|
2634
3657
|
}
|
|
2635
3658
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id,
|
|
2636
3659
|
tag }, data), { component: enums_1.ProductComponents.FEATURE, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
2637
|
-
await this.initializeProduct(this.product_id);
|
|
2638
3660
|
}
|
|
2639
3661
|
catch (e) {
|
|
2640
3662
|
throw e;
|
|
2641
3663
|
}
|
|
2642
3664
|
}
|
|
2643
|
-
|
|
2644
|
-
const
|
|
2645
|
-
|
|
2646
|
-
throw new Error(`Feature ${tag} not found`);
|
|
2647
|
-
return feature;
|
|
3665
|
+
async fetchFeatures() {
|
|
3666
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'feature', this.getUserAccess());
|
|
3667
|
+
return components;
|
|
2648
3668
|
}
|
|
2649
|
-
|
|
2650
|
-
|
|
3669
|
+
async fetchFeature(tag) {
|
|
3670
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'feature', tag, this.getUserAccess());
|
|
3671
|
+
return component;
|
|
2651
3672
|
}
|
|
2652
|
-
async
|
|
3673
|
+
async deleteFeature(tag) {
|
|
3674
|
+
try {
|
|
3675
|
+
const feature = await this.fetchFeature(tag);
|
|
3676
|
+
if (!feature) {
|
|
3677
|
+
throw new Error(`Feature with tag: ${tag} not found`);
|
|
3678
|
+
}
|
|
3679
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3680
|
+
tag,
|
|
3681
|
+
component: enums_1.ProductComponents.FEATURE,
|
|
3682
|
+
action: enums_1.RequestAction.DELETE,
|
|
3683
|
+
}, this.getUserAccess());
|
|
3684
|
+
}
|
|
3685
|
+
catch (e) {
|
|
3686
|
+
throw e;
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
async createDatabase(data, throwErrorIfExists = false) {
|
|
2653
3690
|
try {
|
|
2654
3691
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
2655
|
-
if (!this.fetchDatabase(data.tag
|
|
3692
|
+
if (!(await this.fetchDatabase(data.tag))) {
|
|
2656
3693
|
await validators_1.CreateProductDatabaseSchema.validateAsync(data);
|
|
2657
|
-
|
|
2658
|
-
|
|
3694
|
+
const processedEnvs = [];
|
|
3695
|
+
for (const env of data.envs) {
|
|
3696
|
+
const exists = await this.fetchEnv(env.slug);
|
|
2659
3697
|
if (!exists) {
|
|
2660
3698
|
throw new Error(`Env ${env.slug} does not exist`);
|
|
2661
3699
|
}
|
|
2662
|
-
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.
|
|
2663
|
-
|
|
2664
|
-
}
|
|
2665
|
-
|
|
2666
|
-
envs.
|
|
3700
|
+
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
3701
|
+
processedEnvs.push(env);
|
|
3702
|
+
}
|
|
3703
|
+
data.envs = processedEnvs;
|
|
3704
|
+
const envs = await this.fetchEnvs();
|
|
3705
|
+
for (const env of envs) {
|
|
2667
3706
|
const exists = data.envs.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
2668
3707
|
if (exists === -1) {
|
|
2669
3708
|
throw new Error(`Product env ${env.slug} is not defined, please provide connection details`);
|
|
2670
3709
|
}
|
|
2671
|
-
}
|
|
3710
|
+
}
|
|
2672
3711
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.DATABASE, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
2673
|
-
await this.initializeProduct(this.product_id);
|
|
2674
3712
|
}
|
|
2675
3713
|
else {
|
|
2676
3714
|
if (throwErrorIfExists)
|
|
@@ -2683,7 +3721,7 @@ class ProductsBuilderService {
|
|
|
2683
3721
|
}
|
|
2684
3722
|
async updateDatabase(tag, data) {
|
|
2685
3723
|
try {
|
|
2686
|
-
const db = this.fetchDatabase(tag);
|
|
3724
|
+
const db = await this.fetchDatabase(tag);
|
|
2687
3725
|
if (!db) {
|
|
2688
3726
|
throw new Error(`Database ${tag} not found`);
|
|
2689
3727
|
}
|
|
@@ -2692,15 +3730,16 @@ class ProductsBuilderService {
|
|
|
2692
3730
|
if (data.tag && this.fetchDatabase(data.tag)) {
|
|
2693
3731
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
2694
3732
|
}
|
|
2695
|
-
data.envs = data.envs.map((env) => {
|
|
2696
|
-
const exists = this.fetchEnv(env.slug);
|
|
3733
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
3734
|
+
const exists = await this.fetchEnv(env.slug);
|
|
2697
3735
|
if (!exists) {
|
|
2698
3736
|
throw new Error(`Env ${env.slug} does not exist`);
|
|
2699
3737
|
}
|
|
2700
|
-
if (env.connection_url)
|
|
2701
|
-
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.
|
|
3738
|
+
if (env.connection_url) {
|
|
3739
|
+
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
3740
|
+
}
|
|
2702
3741
|
return env;
|
|
2703
|
-
});
|
|
3742
|
+
}));
|
|
2704
3743
|
const overwrite = [];
|
|
2705
3744
|
const newEnvs = [];
|
|
2706
3745
|
data.envs.map((dataEnv) => {
|
|
@@ -2729,23 +3768,333 @@ class ProductsBuilderService {
|
|
|
2729
3768
|
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
2730
3769
|
//console.log("UPDATED!!!", JSON.stringify(data.envs))
|
|
2731
3770
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id }, data), { tag, component: enums_1.ProductComponents.DATABASE, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
2732
|
-
await this.initializeProduct(this.product_id);
|
|
2733
3771
|
}
|
|
2734
3772
|
catch (e) {
|
|
2735
3773
|
throw e;
|
|
2736
3774
|
}
|
|
2737
3775
|
}
|
|
2738
|
-
|
|
2739
|
-
const
|
|
2740
|
-
|
|
2741
|
-
|
|
3776
|
+
async fetchDatabases() {
|
|
3777
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'database', this.getUserAccess());
|
|
3778
|
+
const decryptedComponents = components.map((component) => {
|
|
3779
|
+
const dbComponent = component;
|
|
3780
|
+
const decryptedEnvs = dbComponent.envs.map((env) => {
|
|
3781
|
+
return Object.assign(Object.assign({}, env), { connection_url: (0, processor_utils_1.decrypt)(env.connection_url, this.product.private_key) });
|
|
3782
|
+
});
|
|
3783
|
+
return Object.assign(Object.assign({}, dbComponent), { envs: decryptedEnvs });
|
|
3784
|
+
});
|
|
3785
|
+
return decryptedComponents;
|
|
3786
|
+
}
|
|
3787
|
+
async fetchDatabase(tag) {
|
|
3788
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'database', tag, this.getUserAccess());
|
|
3789
|
+
if (component) {
|
|
3790
|
+
const decryptedEnvs = component.envs.map((env) => {
|
|
3791
|
+
return Object.assign(Object.assign({}, env), { connection_url: (0, processor_utils_1.decrypt)(env.connection_url, this.product.private_key) });
|
|
3792
|
+
});
|
|
3793
|
+
return Object.assign(Object.assign({}, component), { envs: decryptedEnvs });
|
|
3794
|
+
}
|
|
3795
|
+
return component;
|
|
3796
|
+
}
|
|
3797
|
+
async deleteDatabase(tag) {
|
|
3798
|
+
try {
|
|
3799
|
+
const database = await this.fetchDatabase(tag);
|
|
3800
|
+
if (!database) {
|
|
3801
|
+
throw new Error(`Database with tag: ${tag} not found`);
|
|
3802
|
+
}
|
|
3803
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3804
|
+
tag,
|
|
3805
|
+
component: enums_1.ProductComponents.DATABASE,
|
|
3806
|
+
action: enums_1.RequestAction.DELETE,
|
|
3807
|
+
}, this.getUserAccess());
|
|
3808
|
+
}
|
|
3809
|
+
catch (e) {
|
|
3810
|
+
throw e;
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
// GRAPH CRUD METHODS
|
|
3814
|
+
async createGraph(data, throwErrorIfExists = false) {
|
|
3815
|
+
var _a, _b, _c;
|
|
3816
|
+
console.log('[ProductsService.createGraph] Starting graph creation:', {
|
|
3817
|
+
tag: data.tag,
|
|
3818
|
+
name: data.name,
|
|
3819
|
+
type: data.type,
|
|
3820
|
+
envsCount: (_a = data.envs) === null || _a === void 0 ? void 0 : _a.length,
|
|
3821
|
+
productTag: (_b = this.product) === null || _b === void 0 ? void 0 : _b.tag,
|
|
2742
3822
|
});
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
3823
|
+
try {
|
|
3824
|
+
if (!(await this.fetchGraph(data.tag))) {
|
|
3825
|
+
await validators_1.CreateProductGraphSchema.validateAsync(data);
|
|
3826
|
+
const processedEnvs = [];
|
|
3827
|
+
for (const env of data.envs) {
|
|
3828
|
+
console.log('[ProductsService.createGraph] Processing env:', {
|
|
3829
|
+
slug: env.slug,
|
|
3830
|
+
hasConnectionUrl: !!env.connection_url,
|
|
3831
|
+
hasUsername: !!env.username,
|
|
3832
|
+
hasPassword: !!env.password,
|
|
3833
|
+
});
|
|
3834
|
+
const exists = await this.fetchEnv(env.slug);
|
|
3835
|
+
if (!exists) {
|
|
3836
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
3837
|
+
}
|
|
3838
|
+
// Store connection URL as secret
|
|
3839
|
+
console.log('[ProductsService.createGraph] Converting connection URL to secret for env:', env.slug);
|
|
3840
|
+
const originalUrl = env.connection_url;
|
|
3841
|
+
env.connection_url = await this.storeGraphConnectionUrlAsSecret(env.connection_url, data.tag, env.slug);
|
|
3842
|
+
console.log('[ProductsService.createGraph] Connection URL after secret conversion:', {
|
|
3843
|
+
wasConverted: originalUrl !== env.connection_url,
|
|
3844
|
+
isSecretRef: (_c = env.connection_url) === null || _c === void 0 ? void 0 : _c.startsWith('$Secret{'),
|
|
3845
|
+
});
|
|
3846
|
+
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
3847
|
+
console.log('[ProductsService.createGraph] Connection URL encrypted');
|
|
3848
|
+
// Encrypt username and password if provided
|
|
3849
|
+
if (env.username) {
|
|
3850
|
+
console.log('[ProductsService.createGraph] Encrypting username for env:', env.slug);
|
|
3851
|
+
env.username = (0, processor_utils_1.encrypt)(env.username, this.product.private_key);
|
|
3852
|
+
}
|
|
3853
|
+
if (env.password) {
|
|
3854
|
+
console.log('[ProductsService.createGraph] Encrypting password for env:', env.slug);
|
|
3855
|
+
env.password = (0, processor_utils_1.encrypt)(env.password, this.product.private_key);
|
|
3856
|
+
}
|
|
3857
|
+
processedEnvs.push(env);
|
|
3858
|
+
console.log('[ProductsService.createGraph] Env processed successfully:', env.slug);
|
|
3859
|
+
}
|
|
3860
|
+
data.envs = processedEnvs;
|
|
3861
|
+
console.log('[ProductsService.createGraph] All envs processed, total:', processedEnvs.length);
|
|
3862
|
+
const envs = await this.fetchEnvs();
|
|
3863
|
+
for (const env of envs) {
|
|
3864
|
+
const exists = data.envs.findIndex((graphEnv) => graphEnv.slug === env.slug);
|
|
3865
|
+
if (exists === -1) {
|
|
3866
|
+
throw new Error(`Product env ${env.slug} is not defined, please provide connection details`);
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.GRAPH, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
3870
|
+
}
|
|
3871
|
+
else {
|
|
3872
|
+
if (throwErrorIfExists)
|
|
3873
|
+
throw new Error(`Graph ${data.tag} already exists`);
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
catch (e) {
|
|
3877
|
+
throw e;
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
async updateGraph(tag, data) {
|
|
3881
|
+
var _a, _b;
|
|
3882
|
+
console.log('[ProductsService.updateGraph] Starting graph update:', {
|
|
3883
|
+
tag,
|
|
3884
|
+
newTag: data.tag,
|
|
3885
|
+
name: data.name,
|
|
3886
|
+
type: data.type,
|
|
3887
|
+
envsCount: (_a = data.envs) === null || _a === void 0 ? void 0 : _a.length,
|
|
3888
|
+
productTag: (_b = this.product) === null || _b === void 0 ? void 0 : _b.tag,
|
|
3889
|
+
});
|
|
3890
|
+
try {
|
|
3891
|
+
const graph = await this.fetchGraph(tag);
|
|
3892
|
+
if (!graph) {
|
|
3893
|
+
throw new Error(`Graph ${tag} not found`);
|
|
3894
|
+
}
|
|
3895
|
+
const { _id, envs } = graph;
|
|
3896
|
+
console.log('[ProductsService.updateGraph] Found existing graph:', {
|
|
3897
|
+
_id,
|
|
3898
|
+
existingEnvsCount: envs === null || envs === void 0 ? void 0 : envs.length,
|
|
3899
|
+
});
|
|
3900
|
+
await validators_1.UpdateProductGraphSchema.validateAsync(data);
|
|
3901
|
+
if (data.tag && this.fetchGraph(data.tag)) {
|
|
3902
|
+
throw new Error(`tag ${tag} is in use`);
|
|
3903
|
+
}
|
|
3904
|
+
console.log('[ProductsService.updateGraph] Processing envs update');
|
|
3905
|
+
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
3906
|
+
var _a;
|
|
3907
|
+
console.log('[ProductsService.updateGraph] Processing env:', {
|
|
3908
|
+
slug: env.slug,
|
|
3909
|
+
hasConnectionUrl: !!env.connection_url,
|
|
3910
|
+
hasUsername: !!env.username,
|
|
3911
|
+
hasPassword: !!env.password,
|
|
3912
|
+
});
|
|
3913
|
+
const exists = await this.fetchEnv(env.slug);
|
|
3914
|
+
if (!exists) {
|
|
3915
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
3916
|
+
}
|
|
3917
|
+
if (env.connection_url) {
|
|
3918
|
+
// Store connection URL as secret
|
|
3919
|
+
console.log('[ProductsService.updateGraph] Converting connection URL to secret for env:', env.slug);
|
|
3920
|
+
const originalUrl = env.connection_url;
|
|
3921
|
+
env.connection_url = await this.storeGraphConnectionUrlAsSecret(env.connection_url, data.tag || tag, env.slug);
|
|
3922
|
+
console.log('[ProductsService.updateGraph] Connection URL after secret conversion:', {
|
|
3923
|
+
wasConverted: originalUrl !== env.connection_url,
|
|
3924
|
+
isSecretRef: (_a = env.connection_url) === null || _a === void 0 ? void 0 : _a.startsWith('$Secret{'),
|
|
3925
|
+
});
|
|
3926
|
+
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
3927
|
+
console.log('[ProductsService.updateGraph] Connection URL encrypted');
|
|
3928
|
+
}
|
|
3929
|
+
// Encrypt username and password if provided
|
|
3930
|
+
if (env.username) {
|
|
3931
|
+
console.log('[ProductsService.updateGraph] Encrypting username for env:', env.slug);
|
|
3932
|
+
env.username = (0, processor_utils_1.encrypt)(env.username, this.product.private_key);
|
|
3933
|
+
}
|
|
3934
|
+
if (env.password) {
|
|
3935
|
+
console.log('[ProductsService.updateGraph] Encrypting password for env:', env.slug);
|
|
3936
|
+
env.password = (0, processor_utils_1.encrypt)(env.password, this.product.private_key);
|
|
3937
|
+
}
|
|
3938
|
+
console.log('[ProductsService.updateGraph] Env processed successfully:', env.slug);
|
|
3939
|
+
return env;
|
|
3940
|
+
}));
|
|
3941
|
+
const overwrite = [];
|
|
3942
|
+
const newEnvs = [];
|
|
3943
|
+
data.envs.map((dataEnv) => {
|
|
3944
|
+
const exists = envs.findIndex((env) => env.slug === dataEnv.slug);
|
|
3945
|
+
if (!this.fetchEnv(dataEnv.slug)) {
|
|
3946
|
+
throw new Error(`Product Environment ${dataEnv.slug} doesn't exist`);
|
|
3947
|
+
}
|
|
3948
|
+
if (exists === -1) {
|
|
3949
|
+
if (!dataEnv.connection_url) {
|
|
3950
|
+
throw new Error(`connection_url is required for new env ${data.envs[exists].slug}`);
|
|
3951
|
+
}
|
|
3952
|
+
newEnvs.push(dataEnv);
|
|
3953
|
+
}
|
|
3954
|
+
else {
|
|
3955
|
+
overwrite.push(Object.assign(Object.assign({}, envs[exists]), dataEnv));
|
|
3956
|
+
}
|
|
3957
|
+
});
|
|
3958
|
+
const unchanged = [];
|
|
3959
|
+
envs.map((env) => {
|
|
3960
|
+
const newEnv = newEnvs.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
3961
|
+
const overwriteEnv = overwrite.findIndex((dataEnv) => env.slug === dataEnv.slug) > -1;
|
|
3962
|
+
if (!newEnv && !overwriteEnv) {
|
|
3963
|
+
unchanged.push(env);
|
|
3964
|
+
}
|
|
3965
|
+
});
|
|
3966
|
+
data.envs = [...unchanged, ...overwrite, ...newEnvs];
|
|
3967
|
+
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());
|
|
3968
|
+
}
|
|
3969
|
+
catch (e) {
|
|
3970
|
+
throw e;
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
async fetchGraphs() {
|
|
3974
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'graph', this.getUserAccess());
|
|
3975
|
+
return components;
|
|
2746
3976
|
}
|
|
2747
|
-
|
|
2748
|
-
|
|
3977
|
+
async fetchGraph(tag) {
|
|
3978
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'graph', tag, this.getUserAccess());
|
|
3979
|
+
return component;
|
|
3980
|
+
}
|
|
3981
|
+
async deleteGraph(tag) {
|
|
3982
|
+
try {
|
|
3983
|
+
const graph = await this.fetchGraph(tag);
|
|
3984
|
+
if (!graph) {
|
|
3985
|
+
throw new Error(`Graph with tag: ${tag} not found`);
|
|
3986
|
+
}
|
|
3987
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
3988
|
+
tag,
|
|
3989
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
3990
|
+
action: enums_1.RequestAction.DELETE,
|
|
3991
|
+
}, this.getUserAccess());
|
|
3992
|
+
}
|
|
3993
|
+
catch (e) {
|
|
3994
|
+
throw e;
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
// ==================== GRAPH ACTIONS ====================
|
|
3998
|
+
async createGraphAction(graphTag, data) {
|
|
3999
|
+
try {
|
|
4000
|
+
const graph = await this.fetchGraph(graphTag);
|
|
4001
|
+
if (!graph) {
|
|
4002
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
4003
|
+
}
|
|
4004
|
+
// Initialize actions array if it doesn't exist
|
|
4005
|
+
if (!graph.actions) {
|
|
4006
|
+
graph.actions = [];
|
|
4007
|
+
}
|
|
4008
|
+
// Check if action already exists
|
|
4009
|
+
const existingAction = graph.actions.find((a) => a.tag === data.tag);
|
|
4010
|
+
if (existingAction) {
|
|
4011
|
+
throw new Error(`Action with tag: ${data.tag} already exists`);
|
|
4012
|
+
}
|
|
4013
|
+
graph.actions.push(data);
|
|
4014
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4015
|
+
tag: graphTag,
|
|
4016
|
+
actions: graph.actions,
|
|
4017
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
4018
|
+
action: enums_1.RequestAction.UPDATE,
|
|
4019
|
+
}, this.getUserAccess());
|
|
4020
|
+
}
|
|
4021
|
+
catch (e) {
|
|
4022
|
+
throw e;
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
async updateGraphAction(graphTag, actionTag, data) {
|
|
4026
|
+
try {
|
|
4027
|
+
const graph = await this.fetchGraph(graphTag);
|
|
4028
|
+
if (!graph) {
|
|
4029
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
4030
|
+
}
|
|
4031
|
+
if (!graph.actions) {
|
|
4032
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
4033
|
+
}
|
|
4034
|
+
const actionIndex = graph.actions.findIndex((a) => a.tag === actionTag);
|
|
4035
|
+
if (actionIndex === -1) {
|
|
4036
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
4037
|
+
}
|
|
4038
|
+
graph.actions[actionIndex] = Object.assign(Object.assign({}, graph.actions[actionIndex]), data);
|
|
4039
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4040
|
+
tag: graphTag,
|
|
4041
|
+
actions: graph.actions,
|
|
4042
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
4043
|
+
action: enums_1.RequestAction.UPDATE,
|
|
4044
|
+
}, this.getUserAccess());
|
|
4045
|
+
}
|
|
4046
|
+
catch (e) {
|
|
4047
|
+
throw e;
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
async fetchGraphAction(graphTag, actionTag) {
|
|
4051
|
+
try {
|
|
4052
|
+
const graph = await this.fetchGraph(graphTag);
|
|
4053
|
+
if (!graph || !graph.actions) {
|
|
4054
|
+
return null;
|
|
4055
|
+
}
|
|
4056
|
+
return graph.actions.find((a) => a.tag === actionTag) || null;
|
|
4057
|
+
}
|
|
4058
|
+
catch (e) {
|
|
4059
|
+
throw e;
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
async fetchGraphActions(graphTag) {
|
|
4063
|
+
try {
|
|
4064
|
+
const graph = await this.fetchGraph(graphTag);
|
|
4065
|
+
if (!graph) {
|
|
4066
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
4067
|
+
}
|
|
4068
|
+
return graph.actions || [];
|
|
4069
|
+
}
|
|
4070
|
+
catch (e) {
|
|
4071
|
+
throw e;
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
async deleteGraphAction(graphTag, actionTag) {
|
|
4075
|
+
try {
|
|
4076
|
+
const graph = await this.fetchGraph(graphTag);
|
|
4077
|
+
if (!graph) {
|
|
4078
|
+
throw new Error(`Graph with tag: ${graphTag} not found`);
|
|
4079
|
+
}
|
|
4080
|
+
if (!graph.actions) {
|
|
4081
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
4082
|
+
}
|
|
4083
|
+
const actionIndex = graph.actions.findIndex((a) => a.tag === actionTag);
|
|
4084
|
+
if (actionIndex === -1) {
|
|
4085
|
+
throw new Error(`Action with tag: ${actionTag} not found`);
|
|
4086
|
+
}
|
|
4087
|
+
graph.actions.splice(actionIndex, 1);
|
|
4088
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4089
|
+
tag: graphTag,
|
|
4090
|
+
actions: graph.actions,
|
|
4091
|
+
component: enums_1.ProductComponents.GRAPH,
|
|
4092
|
+
action: enums_1.RequestAction.UPDATE,
|
|
4093
|
+
}, this.getUserAccess());
|
|
4094
|
+
}
|
|
4095
|
+
catch (e) {
|
|
4096
|
+
throw e;
|
|
4097
|
+
}
|
|
2749
4098
|
}
|
|
2750
4099
|
async createDatabaseAction(data, throwErrorIfExists = false) {
|
|
2751
4100
|
try {
|
|
@@ -2756,10 +4105,10 @@ class ProductsBuilderService {
|
|
|
2756
4105
|
if (!databaseTag || !tag) {
|
|
2757
4106
|
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
2758
4107
|
}
|
|
2759
|
-
const exists = this.fetchDatabaseAction(data.tag);
|
|
4108
|
+
const exists = await this.fetchDatabaseAction(data.tag);
|
|
2760
4109
|
data.tag = tag;
|
|
2761
4110
|
if (!exists) {
|
|
2762
|
-
const database = this.fetchDatabase(databaseTag);
|
|
4111
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
2763
4112
|
let values, template;
|
|
2764
4113
|
if (database.type === productsBuilder_types_1.DatabaseTypes.MONGODB) {
|
|
2765
4114
|
await create_productDatabaseAction_validator_1.NOSQLDatabaseActionsSchema.validateAsync(data);
|
|
@@ -2783,7 +4132,6 @@ class ProductsBuilderService {
|
|
|
2783
4132
|
}
|
|
2784
4133
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { data: values, template,
|
|
2785
4134
|
databaseTag, component: enums_1.ProductComponents.DATABASE_ACTION, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
2786
|
-
await this.initializeProduct(this.product_id);
|
|
2787
4135
|
}
|
|
2788
4136
|
else {
|
|
2789
4137
|
if (throwErrorIfExists)
|
|
@@ -2794,7 +4142,7 @@ class ProductsBuilderService {
|
|
|
2794
4142
|
throw e;
|
|
2795
4143
|
}
|
|
2796
4144
|
}
|
|
2797
|
-
fetchDatabaseAction(tag, throwErrorIfExists = false) {
|
|
4145
|
+
async fetchDatabaseAction(tag, throwErrorIfExists = false) {
|
|
2798
4146
|
const [databaseTag, actionTag] = tag.split(':');
|
|
2799
4147
|
if (!databaseTag || !actionTag) {
|
|
2800
4148
|
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
@@ -2821,7 +4169,7 @@ class ProductsBuilderService {
|
|
|
2821
4169
|
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
2822
4170
|
}
|
|
2823
4171
|
// Fetch required data
|
|
2824
|
-
const database = await this.fetchDatabase(databaseTag
|
|
4172
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
2825
4173
|
const action = await this.fetchDatabaseAction(data.tag, true);
|
|
2826
4174
|
// Construct payload
|
|
2827
4175
|
const payload = Object.assign(Object.assign(Object.assign({}, action), data), { databaseTag, component: enums_1.ProductComponents.DATABASE_ACTION, action: enums_1.RequestAction.UPDATE });
|
|
@@ -2849,13 +4197,12 @@ class ProductsBuilderService {
|
|
|
2849
4197
|
}
|
|
2850
4198
|
// Update product and reinitialize
|
|
2851
4199
|
await this.productApi.updateProduct(this.product_id, payload, this.getUserAccess());
|
|
2852
|
-
await this.initializeProduct(this.product_id);
|
|
2853
4200
|
}
|
|
2854
4201
|
catch (error) {
|
|
2855
4202
|
throw error;
|
|
2856
4203
|
}
|
|
2857
4204
|
}
|
|
2858
|
-
fetchDatabaseActions(databaseTag) {
|
|
4205
|
+
async fetchDatabaseActions(databaseTag) {
|
|
2859
4206
|
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
2860
4207
|
if (!database)
|
|
2861
4208
|
throw new Error(`Database ${databaseTag} not found`);
|
|
@@ -2867,6 +4214,27 @@ class ProductsBuilderService {
|
|
|
2867
4214
|
}
|
|
2868
4215
|
return actions;
|
|
2869
4216
|
}
|
|
4217
|
+
async deleteDatabaseAction(tag) {
|
|
4218
|
+
try {
|
|
4219
|
+
const [databaseTag, actionTag] = tag.split(':');
|
|
4220
|
+
if (!databaseTag || !actionTag) {
|
|
4221
|
+
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
4222
|
+
}
|
|
4223
|
+
const action = await this.fetchDatabaseAction(tag, true);
|
|
4224
|
+
if (!action) {
|
|
4225
|
+
throw new Error(`Database action with tag: ${tag} not found`);
|
|
4226
|
+
}
|
|
4227
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4228
|
+
tag: actionTag,
|
|
4229
|
+
databaseTag,
|
|
4230
|
+
component: enums_1.ProductComponents.DATABASE_ACTION,
|
|
4231
|
+
action: enums_1.RequestAction.DELETE,
|
|
4232
|
+
}, this.getUserAccess());
|
|
4233
|
+
}
|
|
4234
|
+
catch (e) {
|
|
4235
|
+
throw e;
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
2870
4238
|
async createDatabaseMigration(data, throwErrorIfExists) {
|
|
2871
4239
|
if (!data.tag) {
|
|
2872
4240
|
throw new Error('tag field is required');
|
|
@@ -2875,22 +4243,48 @@ class ProductsBuilderService {
|
|
|
2875
4243
|
if (!databaseTag || !tag) {
|
|
2876
4244
|
throw new Error(`tag is expected to be defined as "database_tag:migration_tag"`);
|
|
2877
4245
|
}
|
|
2878
|
-
const exists = this.fetchDatabaseMigration(data.tag);
|
|
4246
|
+
const exists = await this.fetchDatabaseMigration(data.tag);
|
|
2879
4247
|
data.tag = tag;
|
|
2880
|
-
await create_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
4248
|
+
await create_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
2881
4249
|
if (!exists) {
|
|
2882
|
-
const database = this.fetchDatabase(databaseTag
|
|
4250
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
2883
4251
|
if (database.type === productsBuilder_types_1.DatabaseTypes.MONGODB) {
|
|
2884
4252
|
throw new Error(`${database.type} does not support migrations`);
|
|
2885
4253
|
}
|
|
2886
|
-
|
|
2887
|
-
|
|
4254
|
+
// Process migration value - supports both simple strings and rich operations
|
|
4255
|
+
let processedValue = data.value;
|
|
4256
|
+
if (data.value) {
|
|
4257
|
+
processedValue = {
|
|
4258
|
+
up: this.processMigrationOperations(data.value.up),
|
|
4259
|
+
down: this.processMigrationOperations(data.value.down),
|
|
4260
|
+
};
|
|
4261
|
+
}
|
|
4262
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { value: processedValue, databaseTag, component: enums_1.ProductComponents.DATABASE_MIGRATION }), this.getUserAccess());
|
|
2888
4263
|
}
|
|
2889
4264
|
else {
|
|
2890
4265
|
if (throwErrorIfExists)
|
|
2891
|
-
throw new Error(`Database
|
|
4266
|
+
throw new Error(`Database Migration ${data.tag} already exists`);
|
|
2892
4267
|
}
|
|
2893
4268
|
}
|
|
4269
|
+
/**
|
|
4270
|
+
* Process migration operations - handles both string and object formats
|
|
4271
|
+
* Strings are passed through as-is (raw SQL/CQL)
|
|
4272
|
+
* Objects are serialized for storage and executed by the migration engine
|
|
4273
|
+
*/
|
|
4274
|
+
processMigrationOperations(operations) {
|
|
4275
|
+
if (!operations || !Array.isArray(operations))
|
|
4276
|
+
return [];
|
|
4277
|
+
return operations.map((op) => {
|
|
4278
|
+
if (typeof op === 'string') {
|
|
4279
|
+
return op; // Raw SQL/CQL string
|
|
4280
|
+
}
|
|
4281
|
+
// Rich operation object - validate it has required 'type' field
|
|
4282
|
+
if (typeof op === 'object' && op !== null && 'type' in op) {
|
|
4283
|
+
return op;
|
|
4284
|
+
}
|
|
4285
|
+
throw new Error(`Invalid migration operation format. Expected string or object with 'type' field.`);
|
|
4286
|
+
});
|
|
4287
|
+
}
|
|
2894
4288
|
async updateDatabaseMigration(data) {
|
|
2895
4289
|
if (!data.tag) {
|
|
2896
4290
|
throw new Error('tag field is required');
|
|
@@ -2899,16 +4293,23 @@ class ProductsBuilderService {
|
|
|
2899
4293
|
if (!databaseTag || !tag) {
|
|
2900
4294
|
throw new Error(`tag is expected to be defined as "database_tag:migration_tag"`);
|
|
2901
4295
|
}
|
|
2902
|
-
await update_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
2903
|
-
const
|
|
2904
|
-
if (!
|
|
4296
|
+
await update_productDatabaseMigration_validator_1.default.validateAsync(Object.assign(Object.assign({}, data), { databaseTag }));
|
|
4297
|
+
const existing = await this.fetchDatabaseMigration(data.tag);
|
|
4298
|
+
if (!existing) {
|
|
2905
4299
|
throw new Error(`Migration ${data.tag} not found`);
|
|
2906
4300
|
}
|
|
2907
4301
|
data.tag = tag;
|
|
2908
|
-
|
|
2909
|
-
|
|
4302
|
+
// Process migration value if provided - supports both simple strings and rich operations
|
|
4303
|
+
let processedValue = data.value;
|
|
4304
|
+
if (data.value) {
|
|
4305
|
+
processedValue = {
|
|
4306
|
+
up: this.processMigrationOperations(data.value.up),
|
|
4307
|
+
down: this.processMigrationOperations(data.value.down),
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
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());
|
|
2910
4311
|
}
|
|
2911
|
-
fetchDatabaseMigration(tag, throwError = false) {
|
|
4312
|
+
async fetchDatabaseMigration(tag, throwError = false) {
|
|
2912
4313
|
const [databaseTag, migrationTag] = tag.split(':');
|
|
2913
4314
|
if (!databaseTag || !migrationTag) {
|
|
2914
4315
|
throw new Error(`tag is expected to be defined as "database_tag:action_tag"`);
|
|
@@ -2921,13 +4322,126 @@ class ProductsBuilderService {
|
|
|
2921
4322
|
throw new Error(`Database migration ${tag} not found`);
|
|
2922
4323
|
return migration;
|
|
2923
4324
|
}
|
|
2924
|
-
fetchDatabaseMigrations(databaseTag) {
|
|
4325
|
+
async fetchDatabaseMigrations(databaseTag) {
|
|
2925
4326
|
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
2926
4327
|
if (!database)
|
|
2927
4328
|
throw new Error(`Database ${databaseTag} not found`);
|
|
2928
4329
|
const migrations = database.migrations;
|
|
2929
4330
|
return migrations;
|
|
2930
4331
|
}
|
|
4332
|
+
async deleteDatabaseMigration(tag) {
|
|
4333
|
+
try {
|
|
4334
|
+
const [databaseTag, migrationTag] = tag.split(':');
|
|
4335
|
+
if (!databaseTag || !migrationTag) {
|
|
4336
|
+
throw new Error(`tag is expected to be defined as "database_tag:migration_tag"`);
|
|
4337
|
+
}
|
|
4338
|
+
const migration = await this.fetchDatabaseMigration(tag, true);
|
|
4339
|
+
if (!migration) {
|
|
4340
|
+
throw new Error(`Database migration with tag: ${tag} not found`);
|
|
4341
|
+
}
|
|
4342
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4343
|
+
tag: migrationTag,
|
|
4344
|
+
databaseTag,
|
|
4345
|
+
component: enums_1.ProductComponents.DATABASE_MIGRATION,
|
|
4346
|
+
action: enums_1.RequestAction.DELETE,
|
|
4347
|
+
}, this.getUserAccess());
|
|
4348
|
+
}
|
|
4349
|
+
catch (e) {
|
|
4350
|
+
throw e;
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
// ==================== DATABASE TRIGGER CRUD ====================
|
|
4354
|
+
async createDatabaseTrigger(data, throwErrorIfExists = false) {
|
|
4355
|
+
try {
|
|
4356
|
+
if (!data.tag) {
|
|
4357
|
+
throw new Error('tag field is required');
|
|
4358
|
+
}
|
|
4359
|
+
const [databaseTag, triggerTag] = data.tag.split(':');
|
|
4360
|
+
if (!databaseTag || !triggerTag) {
|
|
4361
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4362
|
+
}
|
|
4363
|
+
const exists = await this.fetchDatabaseTrigger(data.tag);
|
|
4364
|
+
if (exists) {
|
|
4365
|
+
if (throwErrorIfExists) {
|
|
4366
|
+
throw new Error(`Database trigger with tag: ${data.tag} already exists`);
|
|
4367
|
+
}
|
|
4368
|
+
return;
|
|
4369
|
+
}
|
|
4370
|
+
const database = await this.fetchDatabase(databaseTag);
|
|
4371
|
+
if (!database) {
|
|
4372
|
+
throw new Error(`Database ${databaseTag} not found`);
|
|
4373
|
+
}
|
|
4374
|
+
// Initialize triggers array if not present
|
|
4375
|
+
if (!database.triggers) {
|
|
4376
|
+
database.triggers = [];
|
|
4377
|
+
}
|
|
4378
|
+
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());
|
|
4379
|
+
}
|
|
4380
|
+
catch (e) {
|
|
4381
|
+
throw e;
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
async updateDatabaseTrigger(data) {
|
|
4385
|
+
try {
|
|
4386
|
+
if (!data.tag) {
|
|
4387
|
+
throw new Error('tag field is required');
|
|
4388
|
+
}
|
|
4389
|
+
const [databaseTag, triggerTag] = data.tag.split(':');
|
|
4390
|
+
if (!databaseTag || !triggerTag) {
|
|
4391
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4392
|
+
}
|
|
4393
|
+
const exists = await this.fetchDatabaseTrigger(data.tag, true);
|
|
4394
|
+
if (!exists) {
|
|
4395
|
+
throw new Error(`Database trigger with tag: ${data.tag} not found`);
|
|
4396
|
+
}
|
|
4397
|
+
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());
|
|
4398
|
+
}
|
|
4399
|
+
catch (e) {
|
|
4400
|
+
throw e;
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
async fetchDatabaseTrigger(tag, throwError = false) {
|
|
4404
|
+
const [databaseTag, triggerTag] = tag.split(':');
|
|
4405
|
+
if (!databaseTag || !triggerTag) {
|
|
4406
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4407
|
+
}
|
|
4408
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
4409
|
+
if (!database)
|
|
4410
|
+
throw new Error(`Database ${databaseTag} not found`);
|
|
4411
|
+
const triggers = database.triggers || [];
|
|
4412
|
+
const trigger = triggers.find((data) => data.tag === triggerTag);
|
|
4413
|
+
if (!trigger && throwError)
|
|
4414
|
+
throw new Error(`Database trigger ${tag} not found`);
|
|
4415
|
+
return trigger || null;
|
|
4416
|
+
}
|
|
4417
|
+
async fetchDatabaseTriggers(databaseTag) {
|
|
4418
|
+
const database = this.product.databases.find((data) => data.tag === databaseTag);
|
|
4419
|
+
if (!database)
|
|
4420
|
+
throw new Error(`Database ${databaseTag} not found`);
|
|
4421
|
+
const triggers = database.triggers || [];
|
|
4422
|
+
return triggers;
|
|
4423
|
+
}
|
|
4424
|
+
async deleteDatabaseTrigger(tag) {
|
|
4425
|
+
try {
|
|
4426
|
+
const [databaseTag, triggerTag] = tag.split(':');
|
|
4427
|
+
if (!databaseTag || !triggerTag) {
|
|
4428
|
+
throw new Error(`tag is expected to be defined as "database_tag:trigger_tag"`);
|
|
4429
|
+
}
|
|
4430
|
+
const trigger = await this.fetchDatabaseTrigger(tag, true);
|
|
4431
|
+
if (!trigger) {
|
|
4432
|
+
throw new Error(`Database trigger with tag: ${tag} not found`);
|
|
4433
|
+
}
|
|
4434
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4435
|
+
tag: triggerTag,
|
|
4436
|
+
databaseTag,
|
|
4437
|
+
component: enums_1.ProductComponents.DATABASE_TRIGGER,
|
|
4438
|
+
action: enums_1.RequestAction.DELETE,
|
|
4439
|
+
}, this.getUserAccess());
|
|
4440
|
+
}
|
|
4441
|
+
catch (e) {
|
|
4442
|
+
throw e;
|
|
4443
|
+
}
|
|
4444
|
+
}
|
|
2931
4445
|
async validateJobEvent(data) {
|
|
2932
4446
|
const { type, app, event } = data;
|
|
2933
4447
|
if (type === productsBuilder_types_1.JobEventTypes.ACTION) {
|
|
@@ -2942,31 +4456,25 @@ class ProductsBuilderService {
|
|
|
2942
4456
|
}
|
|
2943
4457
|
}
|
|
2944
4458
|
if (type === productsBuilder_types_1.JobEventTypes.DATABASE_ACTION) {
|
|
2945
|
-
const found = this.fetchDatabaseAction(event);
|
|
4459
|
+
const found = await this.fetchDatabaseAction(event);
|
|
2946
4460
|
if (!found) {
|
|
2947
4461
|
throw new Error(`Database action ${event} not found`);
|
|
2948
4462
|
}
|
|
2949
4463
|
}
|
|
2950
|
-
if (type === productsBuilder_types_1.JobEventTypes.FUNCTION) {
|
|
2951
|
-
const found = this.fetchFunction(event);
|
|
2952
|
-
if (!found) {
|
|
2953
|
-
throw new Error(`Cloud function ${event} not found`);
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
4464
|
if (type === productsBuilder_types_1.JobEventTypes.STORAGE) {
|
|
2957
|
-
const found = this.fetchStorage(event);
|
|
4465
|
+
const found = await this.fetchStorage(event);
|
|
2958
4466
|
if (!found) {
|
|
2959
4467
|
throw new Error(`Storage ${event} not found`);
|
|
2960
4468
|
}
|
|
2961
4469
|
}
|
|
2962
4470
|
if (type === productsBuilder_types_1.JobEventTypes.NOTIFICATION) {
|
|
2963
|
-
const found = this.fetchNotification(event);
|
|
4471
|
+
const found = await this.fetchNotification(event);
|
|
2964
4472
|
if (!found) {
|
|
2965
4473
|
throw new Error(`Notification ${event} not found`);
|
|
2966
4474
|
}
|
|
2967
4475
|
}
|
|
2968
4476
|
if (type === productsBuilder_types_1.JobEventTypes.PUBLISH) {
|
|
2969
|
-
const found = this.fetchMessageBroker(event);
|
|
4477
|
+
const found = await this.fetchMessageBroker(event);
|
|
2970
4478
|
if (!found) {
|
|
2971
4479
|
throw new Error(`Message Broker ${event} not found`);
|
|
2972
4480
|
}
|
|
@@ -2975,7 +4483,7 @@ class ProductsBuilderService {
|
|
|
2975
4483
|
async createJob(data, throwErrorIfExists = false) {
|
|
2976
4484
|
try {
|
|
2977
4485
|
// TODO: figure out a way to check if this has run before, halt if it has
|
|
2978
|
-
if (!this.fetchJob(data.tag)) {
|
|
4486
|
+
if (!(await this.fetchJob(data.tag))) {
|
|
2979
4487
|
await validators_1.CreateProductJobSchema.validateAsync(data);
|
|
2980
4488
|
await this.validateJobEvent(data);
|
|
2981
4489
|
if (data.type === productsBuilder_types_1.JobEventTypes.ACTION) {
|
|
@@ -2997,7 +4505,6 @@ class ProductsBuilderService {
|
|
|
2997
4505
|
const dbAction = await this.fetchDatabaseAction(data.event);
|
|
2998
4506
|
}
|
|
2999
4507
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.JOB, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
3000
|
-
await this.initializeProduct(this.product_id);
|
|
3001
4508
|
}
|
|
3002
4509
|
else {
|
|
3003
4510
|
if (throwErrorIfExists)
|
|
@@ -3020,20 +4527,111 @@ class ProductsBuilderService {
|
|
|
3020
4527
|
throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
|
|
3021
4528
|
}
|
|
3022
4529
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign(Object.assign({}, job), data), { component: enums_1.ProductComponents.JOB, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
3023
|
-
await this.initializeProduct(this.product_id);
|
|
3024
4530
|
}
|
|
3025
4531
|
catch (e) {
|
|
3026
4532
|
throw e;
|
|
3027
4533
|
}
|
|
3028
4534
|
}
|
|
3029
|
-
|
|
3030
|
-
const
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
4535
|
+
async fetchJobs() {
|
|
4536
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'job', this.getUserAccess());
|
|
4537
|
+
return components;
|
|
4538
|
+
}
|
|
4539
|
+
async fetchJob(tag) {
|
|
4540
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'job', tag, this.getUserAccess());
|
|
4541
|
+
return component;
|
|
3034
4542
|
}
|
|
3035
|
-
|
|
3036
|
-
|
|
4543
|
+
async deleteJob(tag) {
|
|
4544
|
+
try {
|
|
4545
|
+
const job = await this.fetchJob(tag);
|
|
4546
|
+
if (!job) {
|
|
4547
|
+
throw new Error(`Job with tag: ${tag} not found`);
|
|
4548
|
+
}
|
|
4549
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4550
|
+
tag,
|
|
4551
|
+
component: enums_1.ProductComponents.JOB,
|
|
4552
|
+
action: enums_1.RequestAction.DELETE,
|
|
4553
|
+
}, this.getUserAccess());
|
|
4554
|
+
}
|
|
4555
|
+
catch (e) {
|
|
4556
|
+
throw e;
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
// ==================== WORKFLOW CRUD METHODS ====================
|
|
4560
|
+
async createWorkflow(data, throwErrorIfExists = false) {
|
|
4561
|
+
try {
|
|
4562
|
+
if (!(await this.fetchWorkflow(data.tag))) {
|
|
4563
|
+
// Validate required fields
|
|
4564
|
+
if (!data.name || !data.tag) {
|
|
4565
|
+
throw new Error('Workflow requires name and tag');
|
|
4566
|
+
}
|
|
4567
|
+
// Validate envs if provided
|
|
4568
|
+
if (data.envs && data.envs.length > 0) {
|
|
4569
|
+
for (const env of data.envs) {
|
|
4570
|
+
const exists = await this.fetchEnv(env.slug);
|
|
4571
|
+
if (!exists) {
|
|
4572
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.WORKFLOW, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
4577
|
+
}
|
|
4578
|
+
else {
|
|
4579
|
+
if (throwErrorIfExists)
|
|
4580
|
+
throw new Error(`Workflow ${data.tag} already exists`);
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
catch (e) {
|
|
4584
|
+
throw e;
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4587
|
+
async updateWorkflow(tag, data) {
|
|
4588
|
+
try {
|
|
4589
|
+
const workflow = await this.fetchWorkflow(tag);
|
|
4590
|
+
if (!workflow) {
|
|
4591
|
+
throw new Error(`Workflow ${tag} not found`);
|
|
4592
|
+
}
|
|
4593
|
+
const { _id } = workflow;
|
|
4594
|
+
if (data.tag && data.tag !== tag && (await this.fetchWorkflow(data.tag))) {
|
|
4595
|
+
throw new Error(`tag ${data.tag} is in use`);
|
|
4596
|
+
}
|
|
4597
|
+
// Validate envs if provided
|
|
4598
|
+
if (data.envs && data.envs.length > 0) {
|
|
4599
|
+
for (const env of data.envs) {
|
|
4600
|
+
const exists = await this.fetchEnv(env.slug);
|
|
4601
|
+
if (!exists) {
|
|
4602
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
4606
|
+
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());
|
|
4607
|
+
}
|
|
4608
|
+
catch (e) {
|
|
4609
|
+
throw e;
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
async fetchWorkflows() {
|
|
4613
|
+
const components = await this.productApi.fetchProductComponents(this.product_id, 'workflow', this.getUserAccess());
|
|
4614
|
+
return components;
|
|
4615
|
+
}
|
|
4616
|
+
async fetchWorkflow(tag) {
|
|
4617
|
+
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'workflow', tag, this.getUserAccess());
|
|
4618
|
+
return component;
|
|
4619
|
+
}
|
|
4620
|
+
async deleteWorkflow(tag) {
|
|
4621
|
+
try {
|
|
4622
|
+
const workflow = await this.fetchWorkflow(tag);
|
|
4623
|
+
if (!workflow) {
|
|
4624
|
+
throw new Error(`Workflow with tag: ${tag} not found`);
|
|
4625
|
+
}
|
|
4626
|
+
await this.productApi.updateProduct(this.product_id, {
|
|
4627
|
+
tag,
|
|
4628
|
+
component: enums_1.ProductComponents.WORKFLOW,
|
|
4629
|
+
action: enums_1.RequestAction.DELETE,
|
|
4630
|
+
}, this.getUserAccess());
|
|
4631
|
+
}
|
|
4632
|
+
catch (e) {
|
|
4633
|
+
throw e;
|
|
4634
|
+
}
|
|
3037
4635
|
}
|
|
3038
4636
|
getUserAccess() {
|
|
3039
4637
|
return {
|
|
@@ -3041,7 +4639,598 @@ class ProductsBuilderService {
|
|
|
3041
4639
|
workspace_id: this.workspace_id,
|
|
3042
4640
|
token: this.token,
|
|
3043
4641
|
public_key: this.public_key,
|
|
4642
|
+
access_key: this.access_key,
|
|
4643
|
+
};
|
|
4644
|
+
}
|
|
4645
|
+
async fetchSessionUser(ductape_user_id) {
|
|
4646
|
+
return await this.productApi.fetchProductSessionUser(ductape_user_id, this.getUserAccess());
|
|
4647
|
+
}
|
|
4648
|
+
/**
|
|
4649
|
+
* Process storage config to store sensitive credentials as secrets
|
|
4650
|
+
* Format: STORAGE_{PRODUCT}_{STORAGE_TAG}_{ENV}_{KEY}
|
|
4651
|
+
*
|
|
4652
|
+
* Product parsing: split by ":", select first element
|
|
4653
|
+
* Storage tag: replace "-" with "_"
|
|
4654
|
+
*/
|
|
4655
|
+
async processStorageConfigSecrets(config, providerType, storageTag, envSlug) {
|
|
4656
|
+
console.log(`[Storage Secrets] Processing secrets for storage: ${storageTag}, env: ${envSlug}, provider: ${providerType}`);
|
|
4657
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
4658
|
+
if (!secretsService) {
|
|
4659
|
+
console.log(`[Storage Secrets] No secrets service available, skipping secret storage`);
|
|
4660
|
+
return config;
|
|
4661
|
+
}
|
|
4662
|
+
const generateSecretKey = (keyName) => {
|
|
4663
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
4664
|
+
const productParts = this.product.tag.split(':');
|
|
4665
|
+
const productKey = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
|
|
4666
|
+
const storageKey = storageTag.replace(/-/g, '_');
|
|
4667
|
+
const key = `STORAGE_${sanitize(productKey)}_${sanitize(storageKey)}_${sanitize(envSlug)}_${sanitize(keyName)}`;
|
|
4668
|
+
console.log(`[Storage Secrets] Generated secret key: ${key}`);
|
|
4669
|
+
return key;
|
|
3044
4670
|
};
|
|
4671
|
+
const storeAsSecret = async (value, keyName) => {
|
|
4672
|
+
const secretCheck = (0, secrets_1.isSecretReference)(value);
|
|
4673
|
+
if (secretCheck.isSecret) {
|
|
4674
|
+
console.log(`[Storage Secrets] ${keyName} is already a secret reference, skipping`);
|
|
4675
|
+
return value; // Already a secret reference
|
|
4676
|
+
}
|
|
4677
|
+
const secretKey = generateSecretKey(keyName);
|
|
4678
|
+
try {
|
|
4679
|
+
const exists = await secretsService.exists(secretKey);
|
|
4680
|
+
if (exists) {
|
|
4681
|
+
console.log(`[Storage Secrets] Updating existing secret: ${secretKey}`);
|
|
4682
|
+
await secretsService.update(secretKey, { value });
|
|
4683
|
+
}
|
|
4684
|
+
else {
|
|
4685
|
+
console.log(`[Storage Secrets] Creating new secret: ${secretKey}`);
|
|
4686
|
+
await secretsService.create({
|
|
4687
|
+
key: secretKey,
|
|
4688
|
+
value,
|
|
4689
|
+
description: `Storage ${keyName} for ${storageTag} in ${envSlug}`,
|
|
4690
|
+
scope: [this.product.tag, storageTag],
|
|
4691
|
+
envs: [envSlug],
|
|
4692
|
+
});
|
|
4693
|
+
}
|
|
4694
|
+
console.log(`[Storage Secrets] Successfully stored ${keyName} as secret: $Secret{${secretKey}}`);
|
|
4695
|
+
return `$Secret{${secretKey}}`;
|
|
4696
|
+
}
|
|
4697
|
+
catch (error) {
|
|
4698
|
+
console.warn(`[Storage Secrets] Failed to store storage credential as secret: ${error}`);
|
|
4699
|
+
return value;
|
|
4700
|
+
}
|
|
4701
|
+
};
|
|
4702
|
+
if (providerType === productsBuilder_types_1.StorageProviders.AWS) {
|
|
4703
|
+
console.log(`[Storage Secrets] Processing AWS S3 credentials`);
|
|
4704
|
+
const awsConfig = config;
|
|
4705
|
+
const result = Object.assign(Object.assign({}, awsConfig), { accessKeyId: await storeAsSecret(awsConfig.accessKeyId, 'ACCESS_KEY_ID'), secretAccessKey: await storeAsSecret(awsConfig.secretAccessKey, 'SECRET_ACCESS_KEY') });
|
|
4706
|
+
console.log(`[Storage Secrets] AWS S3 config processed successfully`);
|
|
4707
|
+
return result;
|
|
4708
|
+
}
|
|
4709
|
+
else if (providerType === productsBuilder_types_1.StorageProviders.GCP) {
|
|
4710
|
+
console.log(`[Storage Secrets] Processing GCP credentials`);
|
|
4711
|
+
const gcpConfig = config;
|
|
4712
|
+
if (gcpConfig.config) {
|
|
4713
|
+
const processedConfig = Object.assign({}, gcpConfig.config);
|
|
4714
|
+
// Store private_key_id as secret
|
|
4715
|
+
if (processedConfig.private_key_id) {
|
|
4716
|
+
processedConfig.private_key_id = await storeAsSecret(processedConfig.private_key_id, 'PRIVATE_KEY_ID');
|
|
4717
|
+
}
|
|
4718
|
+
// Store private_key as secret
|
|
4719
|
+
if (processedConfig.private_key) {
|
|
4720
|
+
processedConfig.private_key = await storeAsSecret(processedConfig.private_key, 'PRIVATE_KEY');
|
|
4721
|
+
}
|
|
4722
|
+
// Store client_email as secret
|
|
4723
|
+
if (processedConfig.client_email) {
|
|
4724
|
+
processedConfig.client_email = await storeAsSecret(processedConfig.client_email, 'CLIENT_EMAIL');
|
|
4725
|
+
}
|
|
4726
|
+
// Store client_id as secret
|
|
4727
|
+
if (processedConfig.client_id) {
|
|
4728
|
+
processedConfig.client_id = await storeAsSecret(processedConfig.client_id, 'CLIENT_ID');
|
|
4729
|
+
}
|
|
4730
|
+
const result = Object.assign(Object.assign({}, gcpConfig), { config: processedConfig });
|
|
4731
|
+
console.log(`[Storage Secrets] GCP config processed successfully`);
|
|
4732
|
+
console.log(`[Storage Secrets] Converted GCP config:`, JSON.stringify(result, null, 2));
|
|
4733
|
+
return result;
|
|
4734
|
+
}
|
|
4735
|
+
console.log(`[Storage Secrets] GCP config has no nested config, skipping`);
|
|
4736
|
+
return gcpConfig;
|
|
4737
|
+
}
|
|
4738
|
+
else if (providerType === productsBuilder_types_1.StorageProviders.AZURE) {
|
|
4739
|
+
console.log(`[Storage Secrets] Processing Azure Blob credentials`);
|
|
4740
|
+
const azureConfig = config;
|
|
4741
|
+
const result = Object.assign(Object.assign({}, azureConfig), { connectionString: await storeAsSecret(azureConfig.connectionString, 'CONNECTION_STRING') });
|
|
4742
|
+
console.log(`[Storage Secrets] Azure Blob config processed successfully`);
|
|
4743
|
+
return result;
|
|
4744
|
+
}
|
|
4745
|
+
console.log(`[Storage Secrets] Unknown provider type: ${providerType}, returning config as-is`);
|
|
4746
|
+
return config;
|
|
4747
|
+
}
|
|
4748
|
+
/**
|
|
4749
|
+
* Process message broker config to store sensitive credentials as secrets
|
|
4750
|
+
* Format: BROKER_{PRODUCT}_{BROKER_TAG}_{ENV}_{KEY}
|
|
4751
|
+
*
|
|
4752
|
+
* Product parsing: split by ":", select first element
|
|
4753
|
+
* Broker tag: replace "-" with "_"
|
|
4754
|
+
*/
|
|
4755
|
+
async processMessageBrokerConfigSecrets(config, brokerType, brokerTag, envSlug) {
|
|
4756
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4757
|
+
const logPrefix = '[MessageBroker:Secrets]';
|
|
4758
|
+
console.log(`${logPrefix} Processing secrets for broker: ${brokerTag}, env: ${envSlug}, type: ${brokerType}`);
|
|
4759
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
4760
|
+
if (!secretsService) {
|
|
4761
|
+
console.log(`${logPrefix} No secrets service available, skipping secret storage`);
|
|
4762
|
+
return config;
|
|
4763
|
+
}
|
|
4764
|
+
console.log(`${logPrefix} Secrets service available`);
|
|
4765
|
+
const generateSecretKey = (keyName) => {
|
|
4766
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
4767
|
+
const productParts = this.product.tag.split(':');
|
|
4768
|
+
const productKey = productParts[1] || productParts[0];
|
|
4769
|
+
const brokerKey = brokerTag.replace(/-/g, '_');
|
|
4770
|
+
const key = `BROKER_${sanitize(productKey)}_${sanitize(brokerKey)}_${sanitize(envSlug)}_${sanitize(keyName)}`;
|
|
4771
|
+
console.log(`${logPrefix} Generated secret key: ${key}`);
|
|
4772
|
+
return key;
|
|
4773
|
+
};
|
|
4774
|
+
const storeAsSecret = async (value, keyName) => {
|
|
4775
|
+
console.log(`${logPrefix} Processing field: ${keyName}`);
|
|
4776
|
+
if (!value) {
|
|
4777
|
+
console.log(`${logPrefix} Field ${keyName} is empty, skipping`);
|
|
4778
|
+
return value;
|
|
4779
|
+
}
|
|
4780
|
+
const secretCheck = (0, secrets_1.isSecretReference)(value);
|
|
4781
|
+
if (secretCheck.isSecret) {
|
|
4782
|
+
console.log(`${logPrefix} Field ${keyName} is already a secret reference: ${value}`);
|
|
4783
|
+
return value;
|
|
4784
|
+
}
|
|
4785
|
+
const secretKey = generateSecretKey(keyName);
|
|
4786
|
+
console.log(`${logPrefix} Storing ${keyName} as secret with key: ${secretKey}`);
|
|
4787
|
+
try {
|
|
4788
|
+
const exists = await secretsService.exists(secretKey);
|
|
4789
|
+
console.log(`${logPrefix} Secret ${secretKey} exists: ${exists}`);
|
|
4790
|
+
if (exists) {
|
|
4791
|
+
console.log(`${logPrefix} Updating existing secret: ${secretKey}`);
|
|
4792
|
+
await secretsService.update(secretKey, { value });
|
|
4793
|
+
console.log(`${logPrefix} Secret ${secretKey} updated successfully`);
|
|
4794
|
+
}
|
|
4795
|
+
else {
|
|
4796
|
+
console.log(`${logPrefix} Creating new secret: ${secretKey}`);
|
|
4797
|
+
await secretsService.create({
|
|
4798
|
+
key: secretKey,
|
|
4799
|
+
value,
|
|
4800
|
+
description: `Message broker ${keyName} for ${brokerTag} in ${envSlug}`,
|
|
4801
|
+
scope: [this.product.tag, brokerTag],
|
|
4802
|
+
envs: [envSlug],
|
|
4803
|
+
});
|
|
4804
|
+
console.log(`${logPrefix} Secret ${secretKey} created successfully`);
|
|
4805
|
+
}
|
|
4806
|
+
const secretRef = `$Secret{${secretKey}}`;
|
|
4807
|
+
console.log(`${logPrefix} Field ${keyName} converted to secret reference: ${secretRef}`);
|
|
4808
|
+
return secretRef;
|
|
4809
|
+
}
|
|
4810
|
+
catch (error) {
|
|
4811
|
+
console.error(`${logPrefix} Failed to store ${keyName} as secret:`, error);
|
|
4812
|
+
console.warn(`${logPrefix} Returning original value for ${keyName}`);
|
|
4813
|
+
return value;
|
|
4814
|
+
}
|
|
4815
|
+
};
|
|
4816
|
+
// Handle different broker types - config is passed directly without wrapper
|
|
4817
|
+
console.log(`${logPrefix} Processing broker type: ${brokerType}`);
|
|
4818
|
+
if (brokerType === productsBuilder_types_1.MessageBrokerTypes.REDIS) {
|
|
4819
|
+
console.log(`${logPrefix} Redis config detected`);
|
|
4820
|
+
console.log(`${logPrefix} Redis fields - host: ${config.host}, port: ${config.port}, password: ${config.password ? '[SET]' : '[NOT SET]'}`);
|
|
4821
|
+
if (config.password) {
|
|
4822
|
+
config.password = await storeAsSecret(config.password, 'PASSWORD');
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
else if (brokerType === productsBuilder_types_1.MessageBrokerTypes.RABBITMQ) {
|
|
4826
|
+
console.log(`${logPrefix} RabbitMQ config detected`);
|
|
4827
|
+
console.log(`${logPrefix} RabbitMQ fields - url: ${config.url ? '[SET]' : '[NOT SET]'}`);
|
|
4828
|
+
if (config.url) {
|
|
4829
|
+
config.url = await storeAsSecret(config.url, 'URL');
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
else if (brokerType === productsBuilder_types_1.MessageBrokerTypes.KAFKA) {
|
|
4833
|
+
console.log(`${logPrefix} Kafka config detected`);
|
|
4834
|
+
console.log(`${logPrefix} Kafka fields - brokers: ${(_a = config.brokers) === null || _a === void 0 ? void 0 : _a.join(', ')}, clientId: ${config.clientId}, ssl: ${config.ssl}`);
|
|
4835
|
+
console.log(`${logPrefix} Kafka SASL - mechanism: ${((_b = config.sasl) === null || _b === void 0 ? void 0 : _b.mechanism) || 'N/A'}, username: ${((_c = config.sasl) === null || _c === void 0 ? void 0 : _c.username) ? '[SET]' : '[NOT SET]'}, password: ${((_d = config.sasl) === null || _d === void 0 ? void 0 : _d.password) ? '[SET]' : '[NOT SET]'}`);
|
|
4836
|
+
if ((_e = config.sasl) === null || _e === void 0 ? void 0 : _e.username) {
|
|
4837
|
+
config.sasl.username = await storeAsSecret(config.sasl.username, 'SASL_USERNAME');
|
|
4838
|
+
}
|
|
4839
|
+
if ((_f = config.sasl) === null || _f === void 0 ? void 0 : _f.password) {
|
|
4840
|
+
config.sasl.password = await storeAsSecret(config.sasl.password, 'SASL_PASSWORD');
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
else if (brokerType === productsBuilder_types_1.MessageBrokerTypes.AWS_SQS) {
|
|
4844
|
+
console.log(`${logPrefix} AWS SQS config detected`);
|
|
4845
|
+
console.log(`${logPrefix} AWS SQS fields - region: ${config.region}, accessKeyId: ${config.accessKeyId ? '[SET]' : '[NOT SET]'}, secretAccessKey: ${config.secretAccessKey ? '[SET]' : '[NOT SET]'}`);
|
|
4846
|
+
if (config.accessKeyId) {
|
|
4847
|
+
config.accessKeyId = await storeAsSecret(config.accessKeyId, 'ACCESS_KEY_ID');
|
|
4848
|
+
}
|
|
4849
|
+
if (config.secretAccessKey) {
|
|
4850
|
+
config.secretAccessKey = await storeAsSecret(config.secretAccessKey, 'SECRET_ACCESS_KEY');
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
else if (brokerType === productsBuilder_types_1.MessageBrokerTypes.NATS) {
|
|
4854
|
+
console.log(`${logPrefix} NATS config detected`);
|
|
4855
|
+
console.log(`${logPrefix} NATS fields - servers: ${(_g = config.servers) === null || _g === void 0 ? void 0 : _g.join(', ')}, token: ${config.token ? '[SET]' : '[NOT SET]'}, user: ${config.user ? '[SET]' : '[NOT SET]'}, pass: ${config.pass ? '[SET]' : '[NOT SET]'}, tls: ${config.tls}`);
|
|
4856
|
+
if (config.token) {
|
|
4857
|
+
config.token = await storeAsSecret(config.token, 'TOKEN');
|
|
4858
|
+
}
|
|
4859
|
+
if (config.user) {
|
|
4860
|
+
config.user = await storeAsSecret(config.user, 'USER');
|
|
4861
|
+
}
|
|
4862
|
+
if (config.pass) {
|
|
4863
|
+
config.pass = await storeAsSecret(config.pass, 'PASSWORD');
|
|
4864
|
+
}
|
|
4865
|
+
}
|
|
4866
|
+
else if (brokerType === productsBuilder_types_1.MessageBrokerTypes.GOOGLE_PUBSUB) {
|
|
4867
|
+
console.log(`${logPrefix} Google Pub/Sub config detected`);
|
|
4868
|
+
console.log(`${logPrefix} Google Pub/Sub fields - projectId: ${config.projectId}, credentials: ${config.credentials ? '[SET]' : '[NOT SET]'}`);
|
|
4869
|
+
if (config.credentials) {
|
|
4870
|
+
console.log(`${logPrefix} Google Pub/Sub credentials - type: ${config.credentials.type}, project_id: ${config.credentials.project_id}`);
|
|
4871
|
+
console.log(`${logPrefix} Google Pub/Sub credentials - private_key_id: ${config.credentials.private_key_id ? '[SET]' : '[NOT SET]'}, private_key: ${config.credentials.private_key ? '[SET]' : '[NOT SET]'}`);
|
|
4872
|
+
console.log(`${logPrefix} Google Pub/Sub credentials - client_email: ${config.credentials.client_email ? '[SET]' : '[NOT SET]'}, client_id: ${config.credentials.client_id ? '[SET]' : '[NOT SET]'}`);
|
|
4873
|
+
if (config.credentials.private_key_id) {
|
|
4874
|
+
config.credentials.private_key_id = await storeAsSecret(config.credentials.private_key_id, 'PRIVATE_KEY_ID');
|
|
4875
|
+
}
|
|
4876
|
+
if (config.credentials.private_key) {
|
|
4877
|
+
config.credentials.private_key = await storeAsSecret(config.credentials.private_key, 'PRIVATE_KEY');
|
|
4878
|
+
}
|
|
4879
|
+
if (config.credentials.client_email) {
|
|
4880
|
+
config.credentials.client_email = await storeAsSecret(config.credentials.client_email, 'CLIENT_EMAIL');
|
|
4881
|
+
}
|
|
4882
|
+
if (config.credentials.client_id) {
|
|
4883
|
+
config.credentials.client_id = await storeAsSecret(config.credentials.client_id, 'CLIENT_ID');
|
|
4884
|
+
}
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
else {
|
|
4888
|
+
console.log(`${logPrefix} Unknown broker type: ${brokerType}, no secrets processing`);
|
|
4889
|
+
}
|
|
4890
|
+
console.log(`${logPrefix} Secrets processing completed for ${brokerTag}:${envSlug}`);
|
|
4891
|
+
return config;
|
|
4892
|
+
}
|
|
4893
|
+
/**
|
|
4894
|
+
* Process notification environment config to store sensitive credentials as secrets
|
|
4895
|
+
* Format: NOTIFIER_{PRODUCT}_{NOTIFIER_TAG}_{ENV}_{KEY}
|
|
4896
|
+
*
|
|
4897
|
+
* Product parsing: split by ":", select first element
|
|
4898
|
+
* Notifier tag: replace "-" with "_"
|
|
4899
|
+
*/
|
|
4900
|
+
async processNotificationEnvSecrets(env, notifierTag, envSlug) {
|
|
4901
|
+
var _a, _b;
|
|
4902
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
4903
|
+
if (!secretsService) {
|
|
4904
|
+
return env;
|
|
4905
|
+
}
|
|
4906
|
+
const generateSecretKey = (keyName) => {
|
|
4907
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
4908
|
+
const productParts = this.product.tag.split(':');
|
|
4909
|
+
const productKey = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
|
|
4910
|
+
const notifierKey = notifierTag.replace(/-/g, '_');
|
|
4911
|
+
return `NOTIFIER_${sanitize(productKey)}_${sanitize(notifierKey)}_${sanitize(envSlug)}_${sanitize(keyName)}`;
|
|
4912
|
+
};
|
|
4913
|
+
const storeAsSecret = async (value, keyName) => {
|
|
4914
|
+
if (!value)
|
|
4915
|
+
return value;
|
|
4916
|
+
const secretCheck = (0, secrets_1.isSecretReference)(value);
|
|
4917
|
+
if (secretCheck.isSecret) {
|
|
4918
|
+
return value; // Already a secret reference
|
|
4919
|
+
}
|
|
4920
|
+
const secretKey = generateSecretKey(keyName);
|
|
4921
|
+
try {
|
|
4922
|
+
const exists = await secretsService.exists(secretKey);
|
|
4923
|
+
if (exists) {
|
|
4924
|
+
await secretsService.update(secretKey, { value });
|
|
4925
|
+
}
|
|
4926
|
+
else {
|
|
4927
|
+
await secretsService.create({
|
|
4928
|
+
key: secretKey,
|
|
4929
|
+
value,
|
|
4930
|
+
description: `Notification ${keyName} for ${notifierTag} in ${envSlug}`,
|
|
4931
|
+
scope: [this.product.tag, notifierTag],
|
|
4932
|
+
envs: [envSlug],
|
|
4933
|
+
});
|
|
4934
|
+
}
|
|
4935
|
+
return `$Secret{${secretKey}}`;
|
|
4936
|
+
}
|
|
4937
|
+
catch (error) {
|
|
4938
|
+
console.warn(`Failed to store notification credential as secret: ${error}`);
|
|
4939
|
+
return value;
|
|
4940
|
+
}
|
|
4941
|
+
};
|
|
4942
|
+
const result = Object.assign({}, env);
|
|
4943
|
+
// Process email handler
|
|
4944
|
+
if ((_a = result.emails) === null || _a === void 0 ? void 0 : _a.auth) {
|
|
4945
|
+
result.emails = Object.assign(Object.assign({}, result.emails), { auth: Object.assign(Object.assign({}, result.emails.auth), { pass: await storeAsSecret(result.emails.auth.pass, 'EMAIL_PASSWORD') }) });
|
|
4946
|
+
}
|
|
4947
|
+
// Process SMS handler
|
|
4948
|
+
if (result.sms) {
|
|
4949
|
+
const smsUpdates = {};
|
|
4950
|
+
if (result.sms.authToken) {
|
|
4951
|
+
smsUpdates.authToken = await storeAsSecret(result.sms.authToken, 'SMS_AUTH_TOKEN');
|
|
4952
|
+
}
|
|
4953
|
+
if (result.sms.apiSecret) {
|
|
4954
|
+
smsUpdates.apiSecret = await storeAsSecret(result.sms.apiSecret, 'SMS_API_SECRET');
|
|
4955
|
+
}
|
|
4956
|
+
if (result.sms.apiKey) {
|
|
4957
|
+
smsUpdates.apiKey = await storeAsSecret(result.sms.apiKey, 'SMS_API_KEY');
|
|
4958
|
+
}
|
|
4959
|
+
if (result.sms.accountSid) {
|
|
4960
|
+
smsUpdates.accountSid = await storeAsSecret(result.sms.accountSid, 'SMS_ACCOUNT_SID');
|
|
4961
|
+
}
|
|
4962
|
+
result.sms = Object.assign(Object.assign({}, result.sms), smsUpdates);
|
|
4963
|
+
}
|
|
4964
|
+
// Process push notifications handler (Firebase credentials)
|
|
4965
|
+
if ((_b = result.push_notifications) === null || _b === void 0 ? void 0 : _b.credentials) {
|
|
4966
|
+
const creds = result.push_notifications.credentials;
|
|
4967
|
+
if (creds.private_key) {
|
|
4968
|
+
result.push_notifications = Object.assign(Object.assign({}, result.push_notifications), { credentials: Object.assign(Object.assign({}, creds), { private_key: await storeAsSecret(creds.private_key, 'PUSH_PRIVATE_KEY') }) });
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
return result;
|
|
4972
|
+
}
|
|
4973
|
+
/**
|
|
4974
|
+
* Store graph connection URL as a secret
|
|
4975
|
+
* Format: GRAPH_{PRODUCT}_{GRAPH_TAG}_{ENV}_URL
|
|
4976
|
+
*/
|
|
4977
|
+
async storeGraphConnectionUrlAsSecret(connectionUrl, graphTag, envSlug) {
|
|
4978
|
+
var _a;
|
|
4979
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Starting secret conversion:', {
|
|
4980
|
+
graphTag,
|
|
4981
|
+
envSlug,
|
|
4982
|
+
hasConnectionUrl: !!connectionUrl,
|
|
4983
|
+
connectionUrlLength: connectionUrl === null || connectionUrl === void 0 ? void 0 : connectionUrl.length,
|
|
4984
|
+
productTag: (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag,
|
|
4985
|
+
});
|
|
4986
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
4987
|
+
if (!secretsService) {
|
|
4988
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] No secrets service available, returning original value');
|
|
4989
|
+
return connectionUrl;
|
|
4990
|
+
}
|
|
4991
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Secrets service is available');
|
|
4992
|
+
const secretCheck = (0, secrets_1.isSecretReference)(connectionUrl);
|
|
4993
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Secret reference check:', {
|
|
4994
|
+
isSecret: secretCheck.isSecret,
|
|
4995
|
+
secretKey: secretCheck.isSecret ? secretCheck.key : null,
|
|
4996
|
+
});
|
|
4997
|
+
if (secretCheck.isSecret) {
|
|
4998
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Value is already a secret reference, returning as-is');
|
|
4999
|
+
return connectionUrl;
|
|
5000
|
+
}
|
|
5001
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
5002
|
+
const productParts = this.product.tag.split(':');
|
|
5003
|
+
const productKey = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
|
|
5004
|
+
const graphKey = graphTag.replace(/-/g, '_');
|
|
5005
|
+
const secretKey = `GRAPH_${sanitize(productKey)}_${sanitize(graphKey)}_${sanitize(envSlug)}_URL`;
|
|
5006
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Generated secret key:', {
|
|
5007
|
+
secretKey,
|
|
5008
|
+
productParts,
|
|
5009
|
+
productKey,
|
|
5010
|
+
graphKey,
|
|
5011
|
+
});
|
|
5012
|
+
try {
|
|
5013
|
+
const exists = await secretsService.exists(secretKey);
|
|
5014
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Secret exists check:', { secretKey, exists });
|
|
5015
|
+
if (exists) {
|
|
5016
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Updating existing secret:', secretKey);
|
|
5017
|
+
await secretsService.update(secretKey, { value: connectionUrl });
|
|
5018
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Secret updated successfully');
|
|
5019
|
+
}
|
|
5020
|
+
else {
|
|
5021
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Creating new secret:', {
|
|
5022
|
+
secretKey,
|
|
5023
|
+
description: `Graph connection URL for ${graphTag} in ${envSlug}`,
|
|
5024
|
+
scope: [this.product.tag, graphTag],
|
|
5025
|
+
envs: [envSlug],
|
|
5026
|
+
});
|
|
5027
|
+
await secretsService.create({
|
|
5028
|
+
key: secretKey,
|
|
5029
|
+
value: connectionUrl,
|
|
5030
|
+
description: `Graph connection URL for ${graphTag} in ${envSlug}`,
|
|
5031
|
+
scope: [this.product.tag, graphTag],
|
|
5032
|
+
envs: [envSlug],
|
|
5033
|
+
});
|
|
5034
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Secret created successfully');
|
|
5035
|
+
}
|
|
5036
|
+
const secretRef = `$Secret{${secretKey}}`;
|
|
5037
|
+
console.log('[ProductsService.storeGraphConnectionUrlAsSecret] Returning secret reference:', secretRef);
|
|
5038
|
+
return secretRef;
|
|
5039
|
+
}
|
|
5040
|
+
catch (error) {
|
|
5041
|
+
console.error('[ProductsService.storeGraphConnectionUrlAsSecret] Failed to store secret:', {
|
|
5042
|
+
secretKey,
|
|
5043
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5044
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
5045
|
+
});
|
|
5046
|
+
return connectionUrl;
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5049
|
+
/**
|
|
5050
|
+
* Generate a secret key for vector configuration field
|
|
5051
|
+
* Format: VECTOR_{PRODUCT}_{ASSET_TAG}_{ENV}_{KEY}
|
|
5052
|
+
*
|
|
5053
|
+
* Where:
|
|
5054
|
+
* - PRODUCT = productTag.split('.')[1] (second part after workspace)
|
|
5055
|
+
* - ASSET_TAG = if vectorTag starts with same workspace prefix, use second part; otherwise sanitize full tag
|
|
5056
|
+
* - All parts are automatically capitalized
|
|
5057
|
+
*/
|
|
5058
|
+
generateVectorSecretKey(vectorTag, envSlug, field) {
|
|
5059
|
+
var _a;
|
|
5060
|
+
console.log('[ProductsService.generateVectorSecretKey] Generating secret key:', {
|
|
5061
|
+
vectorTag,
|
|
5062
|
+
envSlug,
|
|
5063
|
+
field,
|
|
5064
|
+
productTag: (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag,
|
|
5065
|
+
});
|
|
5066
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
5067
|
+
// Support both ':' and '.' delimiters for product tags (e.g., 'ductape:rematch' or 'ductape.rematch')
|
|
5068
|
+
const productParts = this.product.tag.includes(':')
|
|
5069
|
+
? this.product.tag.split(':')
|
|
5070
|
+
: this.product.tag.split('.');
|
|
5071
|
+
const product = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
|
|
5072
|
+
const workspace = productParts[0];
|
|
5073
|
+
console.log('[ProductsService.generateVectorSecretKey] Product parsing:', {
|
|
5074
|
+
productParts,
|
|
5075
|
+
product,
|
|
5076
|
+
workspace,
|
|
5077
|
+
});
|
|
5078
|
+
// Support both ':' and '.' delimiters for vector tags
|
|
5079
|
+
const vectorParts = vectorTag.includes(':') ? vectorTag.split(':') : vectorTag.split('.');
|
|
5080
|
+
let assetTag;
|
|
5081
|
+
if (vectorParts.length > 1 && vectorParts[0] === workspace) {
|
|
5082
|
+
// Same workspace prefix, use second part
|
|
5083
|
+
assetTag = vectorParts[1];
|
|
5084
|
+
console.log('[ProductsService.generateVectorSecretKey] Using second part of vectorTag:', assetTag);
|
|
5085
|
+
}
|
|
5086
|
+
else {
|
|
5087
|
+
// Different or no prefix, use full tag
|
|
5088
|
+
assetTag = vectorTag;
|
|
5089
|
+
console.log('[ProductsService.generateVectorSecretKey] Using full vectorTag:', assetTag);
|
|
5090
|
+
}
|
|
5091
|
+
const secretKey = `VECTOR_${sanitize(product)}_${sanitize(assetTag)}_${sanitize(envSlug)}_${sanitize(field)}`;
|
|
5092
|
+
console.log('[ProductsService.generateVectorSecretKey] Generated secret key:', secretKey);
|
|
5093
|
+
return secretKey;
|
|
5094
|
+
}
|
|
5095
|
+
/**
|
|
5096
|
+
* Store a vector field value as a secret if it exists and is not already a secret reference
|
|
5097
|
+
* @returns The secret reference if stored, or the original value
|
|
5098
|
+
*/
|
|
5099
|
+
async storeVectorFieldAsSecret(value, vectorTag, envSlug, fieldName, description) {
|
|
5100
|
+
var _a;
|
|
5101
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Starting secret conversion:', {
|
|
5102
|
+
vectorTag,
|
|
5103
|
+
envSlug,
|
|
5104
|
+
fieldName,
|
|
5105
|
+
hasValue: !!value,
|
|
5106
|
+
valueLength: value === null || value === void 0 ? void 0 : value.length,
|
|
5107
|
+
productTag: (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag,
|
|
5108
|
+
});
|
|
5109
|
+
if (!value) {
|
|
5110
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] No value provided, returning undefined');
|
|
5111
|
+
return undefined;
|
|
5112
|
+
}
|
|
5113
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
5114
|
+
if (!secretsService) {
|
|
5115
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] No secrets service available, returning original value');
|
|
5116
|
+
return value;
|
|
5117
|
+
}
|
|
5118
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Secrets service is available');
|
|
5119
|
+
const secretCheck = (0, secrets_1.isSecretReference)(value);
|
|
5120
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Secret reference check:', {
|
|
5121
|
+
isSecret: secretCheck.isSecret,
|
|
5122
|
+
secretKey: secretCheck.isSecret ? secretCheck.key : null,
|
|
5123
|
+
});
|
|
5124
|
+
if (secretCheck.isSecret) {
|
|
5125
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Value is already a secret reference, returning as-is');
|
|
5126
|
+
return value;
|
|
5127
|
+
}
|
|
5128
|
+
const secretKey = this.generateVectorSecretKey(vectorTag, envSlug, fieldName);
|
|
5129
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Generated secret key:', secretKey);
|
|
5130
|
+
try {
|
|
5131
|
+
const exists = await secretsService.exists(secretKey);
|
|
5132
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Secret exists check:', { secretKey, exists });
|
|
5133
|
+
if (exists) {
|
|
5134
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Updating existing secret:', secretKey);
|
|
5135
|
+
await secretsService.update(secretKey, { value });
|
|
5136
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Secret updated successfully');
|
|
5137
|
+
}
|
|
5138
|
+
else {
|
|
5139
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Creating new secret:', {
|
|
5140
|
+
secretKey,
|
|
5141
|
+
description,
|
|
5142
|
+
scope: [this.product.tag, vectorTag],
|
|
5143
|
+
envs: [envSlug],
|
|
5144
|
+
});
|
|
5145
|
+
await secretsService.create({
|
|
5146
|
+
key: secretKey,
|
|
5147
|
+
value,
|
|
5148
|
+
description,
|
|
5149
|
+
scope: [this.product.tag, vectorTag],
|
|
5150
|
+
envs: [envSlug],
|
|
5151
|
+
});
|
|
5152
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Secret created successfully');
|
|
5153
|
+
}
|
|
5154
|
+
const secretRef = `$Secret{${secretKey}}`;
|
|
5155
|
+
console.log('[ProductsService.storeVectorFieldAsSecret] Returning secret reference:', secretRef);
|
|
5156
|
+
return secretRef;
|
|
5157
|
+
}
|
|
5158
|
+
catch (error) {
|
|
5159
|
+
console.error('[ProductsService.storeVectorFieldAsSecret] Failed to store secret:', {
|
|
5160
|
+
secretKey,
|
|
5161
|
+
fieldName,
|
|
5162
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5163
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
5164
|
+
});
|
|
5165
|
+
return value;
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
async storeVectorApiKeyAsSecret(apiKey, vectorTag, envSlug) {
|
|
5169
|
+
console.log('[ProductsService.storeVectorApiKeyAsSecret] Storing API key as secret:', {
|
|
5170
|
+
vectorTag,
|
|
5171
|
+
envSlug,
|
|
5172
|
+
hasApiKey: !!apiKey,
|
|
5173
|
+
apiKeyLength: apiKey === null || apiKey === void 0 ? void 0 : apiKey.length,
|
|
5174
|
+
});
|
|
5175
|
+
const result = await this.storeVectorFieldAsSecret(apiKey, vectorTag, envSlug, 'API_KEY', `Vector API key for ${vectorTag} in ${envSlug}`);
|
|
5176
|
+
console.log('[ProductsService.storeVectorApiKeyAsSecret] Result:', {
|
|
5177
|
+
hasResult: !!result,
|
|
5178
|
+
isSecretRef: result === null || result === void 0 ? void 0 : result.startsWith('$Secret{'),
|
|
5179
|
+
});
|
|
5180
|
+
return result || apiKey;
|
|
5181
|
+
}
|
|
5182
|
+
async storeVectorEndpointAsSecret(endpoint, vectorTag, envSlug) {
|
|
5183
|
+
console.log('[ProductsService.storeVectorEndpointAsSecret] Storing endpoint as secret:', {
|
|
5184
|
+
vectorTag,
|
|
5185
|
+
envSlug,
|
|
5186
|
+
hasEndpoint: !!endpoint,
|
|
5187
|
+
endpointLength: endpoint === null || endpoint === void 0 ? void 0 : endpoint.length,
|
|
5188
|
+
});
|
|
5189
|
+
const result = await this.storeVectorFieldAsSecret(endpoint, vectorTag, envSlug, 'ENDPOINT', `Vector endpoint for ${vectorTag} in ${envSlug}`);
|
|
5190
|
+
console.log('[ProductsService.storeVectorEndpointAsSecret] Result:', {
|
|
5191
|
+
hasResult: !!result,
|
|
5192
|
+
isSecretRef: result === null || result === void 0 ? void 0 : result.startsWith('$Secret{'),
|
|
5193
|
+
});
|
|
5194
|
+
return result || endpoint;
|
|
5195
|
+
}
|
|
5196
|
+
/**
|
|
5197
|
+
* Store LLM model API key as a secret
|
|
5198
|
+
* Format: MODEL_{PRODUCT}_{MODEL_TAG}_{ENV}_API_KEY
|
|
5199
|
+
*/
|
|
5200
|
+
async storeModelApiKeyAsSecret(apiKey, modelTag, envSlug) {
|
|
5201
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
5202
|
+
if (!secretsService) {
|
|
5203
|
+
return apiKey;
|
|
5204
|
+
}
|
|
5205
|
+
const secretCheck = (0, secrets_1.isSecretReference)(apiKey);
|
|
5206
|
+
if (secretCheck.isSecret) {
|
|
5207
|
+
return apiKey;
|
|
5208
|
+
}
|
|
5209
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
5210
|
+
const productParts = this.product.tag.split(':');
|
|
5211
|
+
const productKey = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
|
|
5212
|
+
const modelKey = modelTag.replace(/-/g, '_');
|
|
5213
|
+
const secretKey = `MODEL_${sanitize(productKey)}_${sanitize(modelKey)}_${sanitize(envSlug)}_API_KEY`;
|
|
5214
|
+
try {
|
|
5215
|
+
const exists = await secretsService.exists(secretKey);
|
|
5216
|
+
if (exists) {
|
|
5217
|
+
await secretsService.update(secretKey, { value: apiKey });
|
|
5218
|
+
}
|
|
5219
|
+
else {
|
|
5220
|
+
await secretsService.create({
|
|
5221
|
+
key: secretKey,
|
|
5222
|
+
value: apiKey,
|
|
5223
|
+
description: `LLM model API key for ${modelTag} in ${envSlug}`,
|
|
5224
|
+
scope: [this.product.tag, modelTag],
|
|
5225
|
+
envs: [envSlug],
|
|
5226
|
+
});
|
|
5227
|
+
}
|
|
5228
|
+
return `$Secret{${secretKey}}`;
|
|
5229
|
+
}
|
|
5230
|
+
catch (error) {
|
|
5231
|
+
console.warn(`Failed to store model API key as secret: ${error}`);
|
|
5232
|
+
return apiKey;
|
|
5233
|
+
}
|
|
3045
5234
|
}
|
|
3046
5235
|
}
|
|
3047
5236
|
exports.default = ProductsBuilderService;
|