@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
|
@@ -0,0 +1,1534 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DynamoDB Adapter
|
|
4
|
+
*
|
|
5
|
+
* Database adapter for AWS DynamoDB using the '@aws-sdk/client-dynamodb' and
|
|
6
|
+
* '@aws-sdk/lib-dynamodb' libraries.
|
|
7
|
+
* Implements all methods from BaseAdapter with DynamoDB-specific operations.
|
|
8
|
+
*
|
|
9
|
+
* Note: DynamoDB is a NoSQL key-value store with different concepts:
|
|
10
|
+
* - Tables have a partition key (and optional sort key)
|
|
11
|
+
* - No traditional transactions (uses TransactWriteItems/TransactGetItems)
|
|
12
|
+
* - No savepoints
|
|
13
|
+
* - Different query patterns than SQL databases
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.DynamoDBAdapter = void 0;
|
|
50
|
+
const base_adapter_1 = require("./base.adapter");
|
|
51
|
+
const enums_1 = require("../types/enums");
|
|
52
|
+
const database_error_1 = require("../utils/database-error");
|
|
53
|
+
/**
|
|
54
|
+
* DynamoDB database adapter
|
|
55
|
+
* Provides DynamoDB-specific implementations for all database operations
|
|
56
|
+
*/
|
|
57
|
+
class DynamoDBAdapter extends base_adapter_1.BaseAdapter {
|
|
58
|
+
constructor() {
|
|
59
|
+
super(...arguments);
|
|
60
|
+
this.databaseType = enums_1.DatabaseType.DYNAMODB;
|
|
61
|
+
this.dynamoClient = null;
|
|
62
|
+
this.docClient = null;
|
|
63
|
+
this.region = '';
|
|
64
|
+
}
|
|
65
|
+
// ==================== CONNECTION METHODS ====================
|
|
66
|
+
async connect(options) {
|
|
67
|
+
console.log(`[DynamoDBAdapter] connect() called`);
|
|
68
|
+
console.log(`[DynamoDBAdapter] Options:`, JSON.stringify(Object.assign(Object.assign({}, options), { connectionUrl: '***REDACTED***' }), null, 2));
|
|
69
|
+
try {
|
|
70
|
+
console.log(`[DynamoDBAdapter] Importing AWS SDK libraries...`);
|
|
71
|
+
// Dynamic import of AWS SDK
|
|
72
|
+
const { DynamoDBClient } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
73
|
+
const { DynamoDBDocumentClient } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
74
|
+
console.log(`[DynamoDBAdapter] AWS SDK libraries imported successfully`);
|
|
75
|
+
this.connectionUrl = options.connectionUrl;
|
|
76
|
+
console.log(`[DynamoDBAdapter] Connection URL stored`);
|
|
77
|
+
// Parse connection URL: dynamodb://region/access-key/secret-key
|
|
78
|
+
// Or: dynamodb://region (uses default credentials)
|
|
79
|
+
console.log(`[DynamoDBAdapter] Parsing connection URL...`);
|
|
80
|
+
const url = new URL(options.connectionUrl);
|
|
81
|
+
this.region = url.hostname || 'us-east-1';
|
|
82
|
+
console.log(`[DynamoDBAdapter] Region: ${this.region}`);
|
|
83
|
+
const clientConfig = {
|
|
84
|
+
region: this.region,
|
|
85
|
+
};
|
|
86
|
+
// If credentials are provided in the URL
|
|
87
|
+
if (url.pathname && url.pathname !== '/') {
|
|
88
|
+
const parts = url.pathname.slice(1).split('/');
|
|
89
|
+
if (parts.length >= 2) {
|
|
90
|
+
clientConfig.credentials = {
|
|
91
|
+
accessKeyId: parts[0],
|
|
92
|
+
secretAccessKey: parts[1],
|
|
93
|
+
};
|
|
94
|
+
console.log(`[DynamoDBAdapter] Credentials found in URL`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(`[DynamoDBAdapter] Using default credentials from environment`);
|
|
99
|
+
}
|
|
100
|
+
// Custom endpoint for local DynamoDB
|
|
101
|
+
if (url.port) {
|
|
102
|
+
clientConfig.endpoint = `http://${url.hostname}:${url.port}`;
|
|
103
|
+
console.log(`[DynamoDBAdapter] Custom endpoint: ${clientConfig.endpoint}`);
|
|
104
|
+
}
|
|
105
|
+
console.log(`[DynamoDBAdapter] Creating DynamoDBClient...`);
|
|
106
|
+
this.dynamoClient = new DynamoDBClient(clientConfig);
|
|
107
|
+
console.log(`[DynamoDBAdapter] DynamoDBClient created`);
|
|
108
|
+
console.log(`[DynamoDBAdapter] Creating DynamoDBDocumentClient...`);
|
|
109
|
+
this.docClient = DynamoDBDocumentClient.from(this.dynamoClient, {
|
|
110
|
+
marshallOptions: {
|
|
111
|
+
removeUndefinedValues: true,
|
|
112
|
+
convertEmptyValues: true,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
console.log(`[DynamoDBAdapter] DynamoDBDocumentClient created`);
|
|
116
|
+
console.log(`[DynamoDBAdapter] Testing connection by listing tables...`);
|
|
117
|
+
// Test connection by listing tables
|
|
118
|
+
const { ListTablesCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
119
|
+
await this.dynamoClient.send(new ListTablesCommand({ Limit: 1 }));
|
|
120
|
+
console.log(`[DynamoDBAdapter] Connection test successful`);
|
|
121
|
+
this.client = this.docClient;
|
|
122
|
+
this.connected = true;
|
|
123
|
+
console.log(`[DynamoDBAdapter] Connection marked as connected`);
|
|
124
|
+
return {
|
|
125
|
+
connected: true,
|
|
126
|
+
version: `DynamoDB (${this.region})`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
console.error(`[DynamoDBAdapter] Connection failed with error:`, error);
|
|
131
|
+
console.error(`[DynamoDBAdapter] Error type:`, error.constructor.name);
|
|
132
|
+
console.error(`[DynamoDBAdapter] Error message:`, error.message);
|
|
133
|
+
console.error(`[DynamoDBAdapter] Error code:`, error.code);
|
|
134
|
+
console.error(`[DynamoDBAdapter] Full error:`, JSON.stringify(error, null, 2));
|
|
135
|
+
throw database_error_1.DatabaseError.connectionError(`Failed to connect to DynamoDB: ${error.message}`, error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async testConnection(options) {
|
|
139
|
+
try {
|
|
140
|
+
const { DynamoDBClient, ListTablesCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
141
|
+
const url = new URL(options.connectionUrl);
|
|
142
|
+
const region = url.hostname || 'us-east-1';
|
|
143
|
+
const clientConfig = { region };
|
|
144
|
+
if (url.pathname && url.pathname !== '/') {
|
|
145
|
+
const parts = url.pathname.slice(1).split('/');
|
|
146
|
+
if (parts.length >= 2) {
|
|
147
|
+
clientConfig.credentials = {
|
|
148
|
+
accessKeyId: parts[0],
|
|
149
|
+
secretAccessKey: parts[1],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (url.port) {
|
|
154
|
+
clientConfig.endpoint = `http://${url.hostname}:${url.port}`;
|
|
155
|
+
}
|
|
156
|
+
const client = new DynamoDBClient(clientConfig);
|
|
157
|
+
await client.send(new ListTablesCommand({ Limit: 1 }));
|
|
158
|
+
client.destroy();
|
|
159
|
+
return {
|
|
160
|
+
connected: true,
|
|
161
|
+
version: `DynamoDB (${region})`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return {
|
|
166
|
+
connected: false,
|
|
167
|
+
error: error.message,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async disconnect() {
|
|
172
|
+
if (this.dynamoClient) {
|
|
173
|
+
this.dynamoClient.destroy();
|
|
174
|
+
this.dynamoClient = null;
|
|
175
|
+
this.docClient = null;
|
|
176
|
+
this.client = null;
|
|
177
|
+
this.connected = false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// ==================== QUERY METHODS ====================
|
|
181
|
+
async query(query) {
|
|
182
|
+
var _a;
|
|
183
|
+
this.ensureConnected();
|
|
184
|
+
try {
|
|
185
|
+
const { ScanCommand, QueryCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
186
|
+
const tableName = query.options.table;
|
|
187
|
+
const filter = query.options.where || {};
|
|
188
|
+
// Determine if we can use Query (needs key conditions) or must use Scan
|
|
189
|
+
const { keyCondition, filterCondition } = await this.extractKeyCondition(filter, tableName);
|
|
190
|
+
let items = [];
|
|
191
|
+
let count = 0;
|
|
192
|
+
if (keyCondition) {
|
|
193
|
+
// Use Query command for key-based lookups (much faster than Scan)
|
|
194
|
+
const params = {
|
|
195
|
+
TableName: tableName,
|
|
196
|
+
KeyConditionExpression: keyCondition.expression,
|
|
197
|
+
ExpressionAttributeNames: Object.assign({}, keyCondition.names),
|
|
198
|
+
ExpressionAttributeValues: Object.assign({}, keyCondition.values),
|
|
199
|
+
};
|
|
200
|
+
// Add filter for non-key conditions
|
|
201
|
+
if (filterCondition && filterCondition.expression) {
|
|
202
|
+
params.FilterExpression = filterCondition.expression;
|
|
203
|
+
Object.assign(params.ExpressionAttributeNames, filterCondition.names);
|
|
204
|
+
Object.assign(params.ExpressionAttributeValues, filterCondition.values);
|
|
205
|
+
}
|
|
206
|
+
// Projection
|
|
207
|
+
if (query.options.select) {
|
|
208
|
+
params.ProjectionExpression = query.options.select
|
|
209
|
+
.map((col, i) => {
|
|
210
|
+
params.ExpressionAttributeNames[`#proj${i}`] = col;
|
|
211
|
+
return `#proj${i}`;
|
|
212
|
+
})
|
|
213
|
+
.join(', ');
|
|
214
|
+
}
|
|
215
|
+
// Limit
|
|
216
|
+
if (query.options.limit) {
|
|
217
|
+
params.Limit = query.options.limit;
|
|
218
|
+
}
|
|
219
|
+
// Sort order (only works if there's a sort key)
|
|
220
|
+
if (query.options.orderBy) {
|
|
221
|
+
const orderByArray = Array.isArray(query.options.orderBy)
|
|
222
|
+
? query.options.orderBy
|
|
223
|
+
: [query.options.orderBy];
|
|
224
|
+
// DynamoDB only supports ASC/DESC on sort key
|
|
225
|
+
if (((_a = orderByArray[0]) === null || _a === void 0 ? void 0 : _a.order) === 'DESC') {
|
|
226
|
+
params.ScanIndexForward = false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const response = await this.docClient.send(new QueryCommand(params));
|
|
230
|
+
items = response.Items || [];
|
|
231
|
+
count = response.Count || 0;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
// Use Scan command (less efficient but necessary for non-key queries)
|
|
235
|
+
const params = {
|
|
236
|
+
TableName: tableName,
|
|
237
|
+
};
|
|
238
|
+
// Build filter expression
|
|
239
|
+
const filterExpression = this.buildFilterExpression(filter, {}, {});
|
|
240
|
+
if (filterExpression.expression) {
|
|
241
|
+
params.FilterExpression = filterExpression.expression;
|
|
242
|
+
params.ExpressionAttributeNames = filterExpression.names;
|
|
243
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
244
|
+
}
|
|
245
|
+
// Projection
|
|
246
|
+
if (query.options.select) {
|
|
247
|
+
params.ExpressionAttributeNames = params.ExpressionAttributeNames || {};
|
|
248
|
+
params.ProjectionExpression = query.options.select
|
|
249
|
+
.map((col, i) => {
|
|
250
|
+
params.ExpressionAttributeNames[`#proj${i}`] = col;
|
|
251
|
+
return `#proj${i}`;
|
|
252
|
+
})
|
|
253
|
+
.join(', ');
|
|
254
|
+
}
|
|
255
|
+
// Limit
|
|
256
|
+
if (query.options.limit) {
|
|
257
|
+
params.Limit = query.options.limit;
|
|
258
|
+
}
|
|
259
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
260
|
+
items = response.Items || [];
|
|
261
|
+
// Use Count (items after filtering) not ScannedCount (items before filtering)
|
|
262
|
+
count = response.Count || items.length;
|
|
263
|
+
}
|
|
264
|
+
// Apply offset (DynamoDB doesn't have native offset)
|
|
265
|
+
if (query.options.offset && query.options.offset > 0) {
|
|
266
|
+
items = items.slice(query.options.offset);
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
data: items,
|
|
270
|
+
count,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async raw(options) {
|
|
278
|
+
this.ensureConnected();
|
|
279
|
+
try {
|
|
280
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
281
|
+
// For DynamoDB, raw query is a PartiQL statement or direct command
|
|
282
|
+
// Here we support simple scan with filter
|
|
283
|
+
const params = Object.assign({ TableName: options.table || options.collection }, options.query);
|
|
284
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
285
|
+
return {
|
|
286
|
+
data: (response.Items || []),
|
|
287
|
+
count: response.Count || 0,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// ==================== WRITE METHODS ====================
|
|
295
|
+
async insert(options) {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
this.ensureConnected();
|
|
298
|
+
try {
|
|
299
|
+
const { PutCommand, BatchWriteCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
300
|
+
const data = Array.isArray(options.data) ? options.data : [options.data];
|
|
301
|
+
if (data.length === 0) {
|
|
302
|
+
return { data: [], count: 0, insertedIds: [] };
|
|
303
|
+
}
|
|
304
|
+
const insertedIds = [];
|
|
305
|
+
if (data.length === 1) {
|
|
306
|
+
// Single item put
|
|
307
|
+
await this.docClient.send(new PutCommand({
|
|
308
|
+
TableName: options.table,
|
|
309
|
+
Item: data[0],
|
|
310
|
+
ConditionExpression: ((_a = options.onConflict) === null || _a === void 0 ? void 0 : _a.action) === 'ignore'
|
|
311
|
+
? 'attribute_not_exists(#pk)'
|
|
312
|
+
: undefined,
|
|
313
|
+
ExpressionAttributeNames: ((_b = options.onConflict) === null || _b === void 0 ? void 0 : _b.action) === 'ignore'
|
|
314
|
+
? { '#pk': options.onConflict.columns[0] }
|
|
315
|
+
: undefined,
|
|
316
|
+
}));
|
|
317
|
+
insertedIds.push(data[0].id || data[0]._id);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
// Batch write (max 25 items per batch)
|
|
321
|
+
const batches = this.chunkArray(data, 25);
|
|
322
|
+
for (const batch of batches) {
|
|
323
|
+
await this.docClient.send(new BatchWriteCommand({
|
|
324
|
+
RequestItems: {
|
|
325
|
+
[options.table]: batch.map(item => ({
|
|
326
|
+
PutRequest: { Item: item },
|
|
327
|
+
})),
|
|
328
|
+
},
|
|
329
|
+
}));
|
|
330
|
+
batch.forEach(item => insertedIds.push(item.id || item._id));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
data: options.returning ? data : [],
|
|
335
|
+
count: data.length,
|
|
336
|
+
insertedIds,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async update(options) {
|
|
344
|
+
this.ensureConnected();
|
|
345
|
+
try {
|
|
346
|
+
const { UpdateCommand, ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
347
|
+
// First, find items to update
|
|
348
|
+
const filter = options.where || {};
|
|
349
|
+
const filterExpression = this.buildFilterExpression(filter, {}, {});
|
|
350
|
+
const scanParams = {
|
|
351
|
+
TableName: options.table,
|
|
352
|
+
};
|
|
353
|
+
if (filterExpression.expression) {
|
|
354
|
+
scanParams.FilterExpression = filterExpression.expression;
|
|
355
|
+
scanParams.ExpressionAttributeNames = filterExpression.names;
|
|
356
|
+
scanParams.ExpressionAttributeValues = filterExpression.values;
|
|
357
|
+
}
|
|
358
|
+
const scanResponse = await this.docClient.send(new ScanCommand(scanParams));
|
|
359
|
+
const itemsToUpdate = scanResponse.Items || [];
|
|
360
|
+
// Build update expression
|
|
361
|
+
const { expression, names, values } = this.buildUpdateExpression(options.data);
|
|
362
|
+
let updatedCount = 0;
|
|
363
|
+
const updatedItems = [];
|
|
364
|
+
for (const item of itemsToUpdate) {
|
|
365
|
+
// Get primary key from item
|
|
366
|
+
const key = await this.getTableKey(options.table, item);
|
|
367
|
+
const updateParams = {
|
|
368
|
+
TableName: options.table,
|
|
369
|
+
Key: key,
|
|
370
|
+
UpdateExpression: expression,
|
|
371
|
+
ExpressionAttributeNames: names,
|
|
372
|
+
ExpressionAttributeValues: values,
|
|
373
|
+
ReturnValues: options.returning ? 'ALL_NEW' : 'NONE',
|
|
374
|
+
};
|
|
375
|
+
const response = await this.docClient.send(new UpdateCommand(updateParams));
|
|
376
|
+
updatedCount++;
|
|
377
|
+
if (options.returning && response.Attributes) {
|
|
378
|
+
updatedItems.push(response.Attributes);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
data: updatedItems,
|
|
383
|
+
count: updatedCount,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
async delete(options) {
|
|
391
|
+
this.ensureConnected();
|
|
392
|
+
try {
|
|
393
|
+
const { DeleteCommand, ScanCommand, BatchWriteCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
394
|
+
// First, find items to delete
|
|
395
|
+
const filter = options.where || {};
|
|
396
|
+
const filterExpression = this.buildFilterExpression(filter, {}, {});
|
|
397
|
+
const scanParams = {
|
|
398
|
+
TableName: options.table,
|
|
399
|
+
};
|
|
400
|
+
if (filterExpression.expression) {
|
|
401
|
+
scanParams.FilterExpression = filterExpression.expression;
|
|
402
|
+
scanParams.ExpressionAttributeNames = filterExpression.names;
|
|
403
|
+
scanParams.ExpressionAttributeValues = filterExpression.values;
|
|
404
|
+
}
|
|
405
|
+
const scanResponse = await this.docClient.send(new ScanCommand(scanParams));
|
|
406
|
+
const itemsToDelete = scanResponse.Items || [];
|
|
407
|
+
if (itemsToDelete.length === 0) {
|
|
408
|
+
return { count: 0 };
|
|
409
|
+
}
|
|
410
|
+
// Delete items in batches of 25
|
|
411
|
+
const batches = this.chunkArray(itemsToDelete, 25);
|
|
412
|
+
for (const batch of batches) {
|
|
413
|
+
const deleteRequests = await Promise.all(batch.map(async (item) => {
|
|
414
|
+
const key = await this.getTableKey(options.table, item);
|
|
415
|
+
return { DeleteRequest: { Key: key } };
|
|
416
|
+
}));
|
|
417
|
+
await this.docClient.send(new BatchWriteCommand({
|
|
418
|
+
RequestItems: {
|
|
419
|
+
[options.table]: deleteRequests,
|
|
420
|
+
},
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
count: itemsToDelete.length,
|
|
425
|
+
data: options.returning ? itemsToDelete : undefined,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
async upsert(options) {
|
|
433
|
+
this.ensureConnected();
|
|
434
|
+
try {
|
|
435
|
+
const { PutCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
436
|
+
// DynamoDB PutCommand is an upsert by default
|
|
437
|
+
await this.docClient.send(new PutCommand({
|
|
438
|
+
TableName: options.table,
|
|
439
|
+
Item: options.data,
|
|
440
|
+
ReturnValues: 'NONE',
|
|
441
|
+
}));
|
|
442
|
+
return {
|
|
443
|
+
data: [options.data],
|
|
444
|
+
count: 1,
|
|
445
|
+
operation: 'inserted', // DynamoDB doesn't distinguish
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// ==================== AGGREGATION METHODS ====================
|
|
453
|
+
async count(options) {
|
|
454
|
+
this.ensureConnected();
|
|
455
|
+
try {
|
|
456
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
457
|
+
const params = {
|
|
458
|
+
TableName: options.table,
|
|
459
|
+
Select: 'COUNT',
|
|
460
|
+
};
|
|
461
|
+
if (options.where) {
|
|
462
|
+
const filterExpression = this.buildFilterExpression(options.where, {}, {});
|
|
463
|
+
if (filterExpression.expression) {
|
|
464
|
+
params.FilterExpression = filterExpression.expression;
|
|
465
|
+
params.ExpressionAttributeNames = filterExpression.names;
|
|
466
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
470
|
+
return response.Count || 0;
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async sum(options) {
|
|
477
|
+
this.ensureConnected();
|
|
478
|
+
try {
|
|
479
|
+
// DynamoDB doesn't have native aggregations, need to scan and sum
|
|
480
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
481
|
+
const params = {
|
|
482
|
+
TableName: options.table,
|
|
483
|
+
ProjectionExpression: `#col`,
|
|
484
|
+
ExpressionAttributeNames: { '#col': options.column },
|
|
485
|
+
};
|
|
486
|
+
if (options.where) {
|
|
487
|
+
const filterExpression = this.buildFilterExpression(options.where, params.ExpressionAttributeNames, {});
|
|
488
|
+
if (filterExpression.expression) {
|
|
489
|
+
params.FilterExpression = filterExpression.expression;
|
|
490
|
+
Object.assign(params.ExpressionAttributeNames, filterExpression.names);
|
|
491
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
495
|
+
const items = response.Items || [];
|
|
496
|
+
return items.reduce((sum, item) => sum + (Number(item[options.column]) || 0), 0);
|
|
497
|
+
}
|
|
498
|
+
catch (error) {
|
|
499
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
async avg(options) {
|
|
503
|
+
this.ensureConnected();
|
|
504
|
+
try {
|
|
505
|
+
// DynamoDB doesn't have native aggregations, need to scan and calculate
|
|
506
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
507
|
+
const params = {
|
|
508
|
+
TableName: options.table,
|
|
509
|
+
ProjectionExpression: `#col`,
|
|
510
|
+
ExpressionAttributeNames: { '#col': options.column },
|
|
511
|
+
};
|
|
512
|
+
if (options.where) {
|
|
513
|
+
const filterExpression = this.buildFilterExpression(options.where, params.ExpressionAttributeNames, {});
|
|
514
|
+
if (filterExpression.expression) {
|
|
515
|
+
params.FilterExpression = filterExpression.expression;
|
|
516
|
+
Object.assign(params.ExpressionAttributeNames, filterExpression.names);
|
|
517
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
521
|
+
const items = response.Items || [];
|
|
522
|
+
if (items.length === 0)
|
|
523
|
+
return 0;
|
|
524
|
+
const sum = items.reduce((acc, item) => acc + (Number(item[options.column]) || 0), 0);
|
|
525
|
+
return sum / items.length;
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
async min(options) {
|
|
532
|
+
this.ensureConnected();
|
|
533
|
+
try {
|
|
534
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
535
|
+
const params = {
|
|
536
|
+
TableName: options.table,
|
|
537
|
+
ProjectionExpression: `#col`,
|
|
538
|
+
ExpressionAttributeNames: { '#col': options.column },
|
|
539
|
+
};
|
|
540
|
+
if (options.where) {
|
|
541
|
+
const filterExpression = this.buildFilterExpression(options.where, params.ExpressionAttributeNames, {});
|
|
542
|
+
if (filterExpression.expression) {
|
|
543
|
+
params.FilterExpression = filterExpression.expression;
|
|
544
|
+
Object.assign(params.ExpressionAttributeNames, filterExpression.names);
|
|
545
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
549
|
+
const items = response.Items || [];
|
|
550
|
+
if (items.length === 0)
|
|
551
|
+
return null;
|
|
552
|
+
return items.reduce((min, item) => {
|
|
553
|
+
const val = item[options.column];
|
|
554
|
+
return min === null || val < min ? val : min;
|
|
555
|
+
}, null);
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
async max(options) {
|
|
562
|
+
this.ensureConnected();
|
|
563
|
+
try {
|
|
564
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
565
|
+
const params = {
|
|
566
|
+
TableName: options.table,
|
|
567
|
+
ProjectionExpression: `#col`,
|
|
568
|
+
ExpressionAttributeNames: { '#col': options.column },
|
|
569
|
+
};
|
|
570
|
+
if (options.where) {
|
|
571
|
+
const filterExpression = this.buildFilterExpression(options.where, params.ExpressionAttributeNames, {});
|
|
572
|
+
if (filterExpression.expression) {
|
|
573
|
+
params.FilterExpression = filterExpression.expression;
|
|
574
|
+
Object.assign(params.ExpressionAttributeNames, filterExpression.names);
|
|
575
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
579
|
+
const items = response.Items || [];
|
|
580
|
+
if (items.length === 0)
|
|
581
|
+
return null;
|
|
582
|
+
return items.reduce((max, item) => {
|
|
583
|
+
const val = item[options.column];
|
|
584
|
+
return max === null || val > max ? val : max;
|
|
585
|
+
}, null);
|
|
586
|
+
}
|
|
587
|
+
catch (error) {
|
|
588
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
async aggregate(builtAggregation) {
|
|
592
|
+
this.ensureConnected();
|
|
593
|
+
try {
|
|
594
|
+
// DynamoDB doesn't support native aggregations - scan and compute in memory
|
|
595
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
596
|
+
const options = builtAggregation.options;
|
|
597
|
+
const params = {
|
|
598
|
+
TableName: options.table,
|
|
599
|
+
};
|
|
600
|
+
if (options.where) {
|
|
601
|
+
const filterExpression = this.buildFilterExpression(options.where, {}, {});
|
|
602
|
+
if (filterExpression.expression) {
|
|
603
|
+
params.FilterExpression = filterExpression.expression;
|
|
604
|
+
params.ExpressionAttributeNames = filterExpression.names;
|
|
605
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
609
|
+
const items = response.Items || [];
|
|
610
|
+
// Compute aggregations in memory
|
|
611
|
+
const result = {};
|
|
612
|
+
const operations = options.operations || {};
|
|
613
|
+
for (const [alias, op] of Object.entries(operations)) {
|
|
614
|
+
const operation = op;
|
|
615
|
+
if (operation.$COUNT) {
|
|
616
|
+
result[alias] = items.length;
|
|
617
|
+
}
|
|
618
|
+
else if (operation.$SUM) {
|
|
619
|
+
result[alias] = items.reduce((sum, item) => sum + (Number(item[operation.$SUM]) || 0), 0);
|
|
620
|
+
}
|
|
621
|
+
else if (operation.$AVG) {
|
|
622
|
+
const values = items.map((item) => Number(item[operation.$AVG]) || 0);
|
|
623
|
+
result[alias] = values.length > 0 ? values.reduce((a, b) => a + b, 0) / values.length : 0;
|
|
624
|
+
}
|
|
625
|
+
else if (operation.$MIN) {
|
|
626
|
+
const values = items.map((item) => item[operation.$MIN]).filter((v) => v != null);
|
|
627
|
+
result[alias] = values.length > 0 ? Math.min(...values) : null;
|
|
628
|
+
}
|
|
629
|
+
else if (operation.$MAX) {
|
|
630
|
+
const values = items.map((item) => item[operation.$MAX]).filter((v) => v != null);
|
|
631
|
+
result[alias] = values.length > 0 ? Math.max(...values) : null;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return result;
|
|
635
|
+
}
|
|
636
|
+
catch (error) {
|
|
637
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async groupBy(builtGroupBy) {
|
|
641
|
+
this.ensureConnected();
|
|
642
|
+
try {
|
|
643
|
+
// DynamoDB doesn't support native GROUP BY - scan and group in memory
|
|
644
|
+
const { ScanCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
645
|
+
const options = builtGroupBy.options;
|
|
646
|
+
const params = {
|
|
647
|
+
TableName: options.table,
|
|
648
|
+
};
|
|
649
|
+
if (options.where) {
|
|
650
|
+
const filterExpression = this.buildFilterExpression(options.where, {}, {});
|
|
651
|
+
if (filterExpression.expression) {
|
|
652
|
+
params.FilterExpression = filterExpression.expression;
|
|
653
|
+
params.ExpressionAttributeNames = filterExpression.names;
|
|
654
|
+
params.ExpressionAttributeValues = filterExpression.values;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const response = await this.docClient.send(new ScanCommand(params));
|
|
658
|
+
const items = response.Items || [];
|
|
659
|
+
// Group items in memory
|
|
660
|
+
const groups = new Map();
|
|
661
|
+
const groupByColumns = options.groupBy || [];
|
|
662
|
+
for (const item of items) {
|
|
663
|
+
const groupKey = groupByColumns.map((col) => String(item[col])).join('|');
|
|
664
|
+
if (!groups.has(groupKey)) {
|
|
665
|
+
groups.set(groupKey, []);
|
|
666
|
+
}
|
|
667
|
+
groups.get(groupKey).push(item);
|
|
668
|
+
}
|
|
669
|
+
// Compute aggregations for each group
|
|
670
|
+
const results = [];
|
|
671
|
+
const operations = options.operations || {};
|
|
672
|
+
for (const [groupKey, groupItems] of groups) {
|
|
673
|
+
const group = {};
|
|
674
|
+
const keyParts = groupKey.split('|');
|
|
675
|
+
groupByColumns.forEach((col, i) => {
|
|
676
|
+
group[col] = keyParts[i];
|
|
677
|
+
});
|
|
678
|
+
const aggregates = {};
|
|
679
|
+
for (const [alias, op] of Object.entries(operations)) {
|
|
680
|
+
const operation = op;
|
|
681
|
+
if (operation.$COUNT) {
|
|
682
|
+
aggregates[alias] = groupItems.length;
|
|
683
|
+
}
|
|
684
|
+
else if (operation.$SUM) {
|
|
685
|
+
aggregates[alias] = groupItems.reduce((sum, item) => sum + (Number(item[operation.$SUM]) || 0), 0);
|
|
686
|
+
}
|
|
687
|
+
else if (operation.$AVG) {
|
|
688
|
+
const values = groupItems.map(item => Number(item[operation.$AVG]) || 0);
|
|
689
|
+
aggregates[alias] = values.length > 0 ? values.reduce((a, b) => a + b, 0) / values.length : 0;
|
|
690
|
+
}
|
|
691
|
+
else if (operation.$MIN) {
|
|
692
|
+
const values = groupItems.map(item => item[operation.$MIN]).filter(v => v != null);
|
|
693
|
+
aggregates[alias] = values.length > 0 ? Math.min(...values) : null;
|
|
694
|
+
}
|
|
695
|
+
else if (operation.$MAX) {
|
|
696
|
+
const values = groupItems.map(item => item[operation.$MAX]).filter(v => v != null);
|
|
697
|
+
aggregates[alias] = values.length > 0 ? Math.max(...values) : null;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
results.push({ group, aggregates: aggregates });
|
|
701
|
+
}
|
|
702
|
+
return results;
|
|
703
|
+
}
|
|
704
|
+
catch (error) {
|
|
705
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'dynamodb');
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
// ==================== TRANSACTION METHODS ====================
|
|
709
|
+
async beginTransaction(isolationLevel, readOnly, timeout) {
|
|
710
|
+
this.ensureConnected();
|
|
711
|
+
// DynamoDB uses TransactWriteItems for transactions, not traditional BEGIN/COMMIT
|
|
712
|
+
// We create a transaction context that collects operations
|
|
713
|
+
const id = `dynamo_txn_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
714
|
+
return {
|
|
715
|
+
id,
|
|
716
|
+
databaseType: 'dynamodb',
|
|
717
|
+
isolationLevel: enums_1.IsolationLevel.SERIALIZABLE, // DynamoDB transactions are serializable
|
|
718
|
+
readOnly: readOnly || false,
|
|
719
|
+
timeout,
|
|
720
|
+
startedAt: new Date(),
|
|
721
|
+
client: {
|
|
722
|
+
operations: [],
|
|
723
|
+
conditionChecks: [],
|
|
724
|
+
},
|
|
725
|
+
savepoints: new Map(),
|
|
726
|
+
status: 'active',
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
async commitTransaction(context) {
|
|
730
|
+
this.ensureConnected();
|
|
731
|
+
try {
|
|
732
|
+
const { TransactWriteCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/lib-dynamodb')));
|
|
733
|
+
const operations = context.client.operations || [];
|
|
734
|
+
if (operations.length === 0) {
|
|
735
|
+
context.status = 'committed';
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
await this.docClient.send(new TransactWriteCommand({
|
|
739
|
+
TransactItems: operations,
|
|
740
|
+
}));
|
|
741
|
+
context.status = 'committed';
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
context.status = 'error';
|
|
745
|
+
throw database_error_1.DatabaseError.transactionError(`Failed to commit transaction: ${error.message}`, error);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
async rollbackTransaction(context) {
|
|
749
|
+
// DynamoDB doesn't have explicit rollback - transaction is simply not committed
|
|
750
|
+
context.client.operations = [];
|
|
751
|
+
context.status = 'rolled_back';
|
|
752
|
+
}
|
|
753
|
+
async createSavepoint(context, name) {
|
|
754
|
+
// DynamoDB does not support savepoints
|
|
755
|
+
throw new database_error_1.DatabaseError('DynamoDB does not support savepoints.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
756
|
+
}
|
|
757
|
+
async releaseSavepoint(context, savepoint) {
|
|
758
|
+
throw new database_error_1.DatabaseError('DynamoDB does not support savepoints.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
759
|
+
}
|
|
760
|
+
async rollbackToSavepoint(context, savepoint) {
|
|
761
|
+
throw new database_error_1.DatabaseError('DynamoDB does not support savepoints.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
762
|
+
}
|
|
763
|
+
supportsSavepoints() {
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
// ==================== SCHEMA METHODS ====================
|
|
767
|
+
async createTable(definition, options) {
|
|
768
|
+
this.ensureConnected();
|
|
769
|
+
try {
|
|
770
|
+
const { CreateTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
771
|
+
// Find primary key column
|
|
772
|
+
const pkColumn = definition.columns.find(c => c.primaryKey);
|
|
773
|
+
if (!pkColumn) {
|
|
774
|
+
throw new Error('DynamoDB tables require a primary key column');
|
|
775
|
+
}
|
|
776
|
+
const keySchema = [
|
|
777
|
+
{ AttributeName: pkColumn.name, KeyType: 'HASH' },
|
|
778
|
+
];
|
|
779
|
+
const attributeDefinitions = [
|
|
780
|
+
{ AttributeName: pkColumn.name, AttributeType: this.mapToDynamoType(pkColumn.type) },
|
|
781
|
+
];
|
|
782
|
+
// Check for sort key (second column marked as primary key or sort key)
|
|
783
|
+
const sortKeyColumn = definition.columns.find(c => c.name !== pkColumn.name && c.sortKey);
|
|
784
|
+
if (sortKeyColumn) {
|
|
785
|
+
keySchema.push({ AttributeName: sortKeyColumn.name, KeyType: 'RANGE' });
|
|
786
|
+
attributeDefinitions.push({
|
|
787
|
+
AttributeName: sortKeyColumn.name,
|
|
788
|
+
AttributeType: this.mapToDynamoType(sortKeyColumn.type),
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
const params = {
|
|
792
|
+
TableName: definition.name,
|
|
793
|
+
KeySchema: keySchema,
|
|
794
|
+
AttributeDefinitions: attributeDefinitions,
|
|
795
|
+
BillingMode: 'PAY_PER_REQUEST', // On-demand capacity
|
|
796
|
+
};
|
|
797
|
+
await this.dynamoClient.send(new CreateTableCommand(params));
|
|
798
|
+
// Wait for table to be active
|
|
799
|
+
await this.waitForTableActive(definition.name);
|
|
800
|
+
// Create GSIs if defined
|
|
801
|
+
if (definition.indexes) {
|
|
802
|
+
for (const index of definition.indexes) {
|
|
803
|
+
await this.createIndex(index);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
catch (error) {
|
|
808
|
+
if ((options === null || options === void 0 ? void 0 : options.ifNotExists) && error.name === 'ResourceInUseException') {
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to create table: ${error.message}`, error);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
async alterTable(tableName, operations) {
|
|
815
|
+
this.ensureConnected();
|
|
816
|
+
// DynamoDB has very limited ALTER capabilities
|
|
817
|
+
// Can only modify GSIs and some table settings
|
|
818
|
+
try {
|
|
819
|
+
for (const op of operations) {
|
|
820
|
+
if (op.type === 'ADD' && op.constraint) {
|
|
821
|
+
// Add GSI
|
|
822
|
+
// This would require UpdateTableCommand with GlobalSecondaryIndexUpdates
|
|
823
|
+
throw new database_error_1.DatabaseError('Adding indexes to DynamoDB requires table recreation or GSI updates. Use createIndex instead.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
catch (error) {
|
|
828
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to alter table: ${error.message}`, error);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async dropTable(tableName, ifExists, cascade) {
|
|
832
|
+
this.ensureConnected();
|
|
833
|
+
try {
|
|
834
|
+
const { DeleteTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
835
|
+
await this.dynamoClient.send(new DeleteTableCommand({
|
|
836
|
+
TableName: tableName,
|
|
837
|
+
}));
|
|
838
|
+
}
|
|
839
|
+
catch (error) {
|
|
840
|
+
if (ifExists && error.name === 'ResourceNotFoundException') {
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to drop table: ${error.message}`, error);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
async listTables() {
|
|
847
|
+
this.ensureConnected();
|
|
848
|
+
try {
|
|
849
|
+
const { ListTablesCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
850
|
+
const response = await this.dynamoClient.send(new ListTablesCommand({}));
|
|
851
|
+
return response.TableNames || [];
|
|
852
|
+
}
|
|
853
|
+
catch (error) {
|
|
854
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to list tables: ${error.message}`, error);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async tableExists(tableName) {
|
|
858
|
+
this.ensureConnected();
|
|
859
|
+
try {
|
|
860
|
+
const { DescribeTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
861
|
+
await this.dynamoClient.send(new DescribeTableCommand({
|
|
862
|
+
TableName: tableName,
|
|
863
|
+
}));
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
catch (error) {
|
|
867
|
+
if (error.name === 'ResourceNotFoundException') {
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to check table existence: ${error.message}`, error);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async getTableSchema(tableName) {
|
|
874
|
+
var _a;
|
|
875
|
+
this.ensureConnected();
|
|
876
|
+
try {
|
|
877
|
+
const { DescribeTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
878
|
+
const response = await this.dynamoClient.send(new DescribeTableCommand({
|
|
879
|
+
TableName: tableName,
|
|
880
|
+
}));
|
|
881
|
+
const table = response.Table;
|
|
882
|
+
// Map attribute definitions to columns
|
|
883
|
+
const columns = (table.AttributeDefinitions || []).map((attr) => {
|
|
884
|
+
var _a;
|
|
885
|
+
return ({
|
|
886
|
+
name: attr.AttributeName,
|
|
887
|
+
type: this.mapFromDynamoType(attr.AttributeType),
|
|
888
|
+
nullable: true,
|
|
889
|
+
isPrimaryKey: ((_a = table.KeySchema) === null || _a === void 0 ? void 0 : _a.some((k) => k.AttributeName === attr.AttributeName && k.KeyType === 'HASH')) || false,
|
|
890
|
+
isUnique: false,
|
|
891
|
+
isAutoIncrement: false,
|
|
892
|
+
});
|
|
893
|
+
});
|
|
894
|
+
// Get primary key
|
|
895
|
+
const primaryKey = ((_a = table.KeySchema) === null || _a === void 0 ? void 0 : _a.filter((k) => k.KeyType === 'HASH').map((k) => k.AttributeName)) || [];
|
|
896
|
+
// Get GSIs as indexes
|
|
897
|
+
const indexes = (table.GlobalSecondaryIndexes || []).map((gsi) => {
|
|
898
|
+
var _a;
|
|
899
|
+
return ({
|
|
900
|
+
name: gsi.IndexName,
|
|
901
|
+
table: tableName,
|
|
902
|
+
columns: ((_a = gsi.KeySchema) === null || _a === void 0 ? void 0 : _a.map((k) => k.AttributeName)) || [],
|
|
903
|
+
unique: false,
|
|
904
|
+
primaryKey: false,
|
|
905
|
+
type: 'GSI',
|
|
906
|
+
});
|
|
907
|
+
});
|
|
908
|
+
// Add LSIs
|
|
909
|
+
(table.LocalSecondaryIndexes || []).forEach((lsi) => {
|
|
910
|
+
var _a;
|
|
911
|
+
indexes.push({
|
|
912
|
+
name: lsi.IndexName,
|
|
913
|
+
table: tableName,
|
|
914
|
+
columns: ((_a = lsi.KeySchema) === null || _a === void 0 ? void 0 : _a.map((k) => k.AttributeName)) || [],
|
|
915
|
+
unique: false,
|
|
916
|
+
primaryKey: false,
|
|
917
|
+
type: 'LSI',
|
|
918
|
+
});
|
|
919
|
+
});
|
|
920
|
+
return {
|
|
921
|
+
name: tableName,
|
|
922
|
+
columns,
|
|
923
|
+
indexes,
|
|
924
|
+
constraints: [],
|
|
925
|
+
primaryKey,
|
|
926
|
+
estimatedRowCount: Number(table.ItemCount) || 0,
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
catch (error) {
|
|
930
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to get table schema: ${error.message}`, error);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
async createIndex(index, ifNotExists, concurrent) {
|
|
934
|
+
this.ensureConnected();
|
|
935
|
+
// DynamoDB indexes (GSI) can only be created during table creation
|
|
936
|
+
// or via UpdateTable (which is limited)
|
|
937
|
+
throw new database_error_1.DatabaseError('DynamoDB Global Secondary Indexes must be created during table creation or via UpdateTable with specific parameters.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
938
|
+
}
|
|
939
|
+
async dropIndex(tableName, indexName, ifExists, concurrent, cascade) {
|
|
940
|
+
this.ensureConnected();
|
|
941
|
+
try {
|
|
942
|
+
const { UpdateTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
943
|
+
await this.dynamoClient.send(new UpdateTableCommand({
|
|
944
|
+
TableName: tableName,
|
|
945
|
+
GlobalSecondaryIndexUpdates: [
|
|
946
|
+
{
|
|
947
|
+
Delete: {
|
|
948
|
+
IndexName: indexName,
|
|
949
|
+
},
|
|
950
|
+
},
|
|
951
|
+
],
|
|
952
|
+
}));
|
|
953
|
+
}
|
|
954
|
+
catch (error) {
|
|
955
|
+
if (ifExists && error.name === 'ResourceNotFoundException') {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to drop index: ${error.message}`, error);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
async listIndexes(tableName, includeSystem) {
|
|
962
|
+
this.ensureConnected();
|
|
963
|
+
try {
|
|
964
|
+
const schema = await this.getTableSchema(tableName);
|
|
965
|
+
return schema.indexes;
|
|
966
|
+
}
|
|
967
|
+
catch (error) {
|
|
968
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to list indexes: ${error.message}`, error);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
async getIndexStatistics(tableName, indexName) {
|
|
972
|
+
this.ensureConnected();
|
|
973
|
+
try {
|
|
974
|
+
const { DescribeTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
975
|
+
const response = await this.dynamoClient.send(new DescribeTableCommand({
|
|
976
|
+
TableName: tableName,
|
|
977
|
+
}));
|
|
978
|
+
const results = [];
|
|
979
|
+
const table = response.Table;
|
|
980
|
+
// Add table itself as primary index
|
|
981
|
+
if (!indexName || indexName === 'PRIMARY') {
|
|
982
|
+
results.push({
|
|
983
|
+
indexName: 'PRIMARY',
|
|
984
|
+
tableName,
|
|
985
|
+
scans: 0,
|
|
986
|
+
tuplesRead: Number(table.ItemCount) || 0,
|
|
987
|
+
sizeBytes: Number(table.TableSizeBytes) || 0,
|
|
988
|
+
sizeFormatted: this.formatBytes(Number(table.TableSizeBytes) || 0),
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
// Add GSIs
|
|
992
|
+
for (const gsi of table.GlobalSecondaryIndexes || []) {
|
|
993
|
+
if (!indexName || indexName === gsi.IndexName) {
|
|
994
|
+
results.push({
|
|
995
|
+
indexName: gsi.IndexName,
|
|
996
|
+
tableName,
|
|
997
|
+
scans: 0,
|
|
998
|
+
tuplesRead: Number(gsi.ItemCount) || 0,
|
|
999
|
+
sizeBytes: Number(gsi.IndexSizeBytes) || 0,
|
|
1000
|
+
sizeFormatted: this.formatBytes(Number(gsi.IndexSizeBytes) || 0),
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
return results;
|
|
1005
|
+
}
|
|
1006
|
+
catch (error) {
|
|
1007
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to get index statistics: ${error.message}`, error);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
// ==================== UTILITY METHODS ====================
|
|
1011
|
+
escapeIdentifier(identifier) {
|
|
1012
|
+
return identifier;
|
|
1013
|
+
}
|
|
1014
|
+
escapeValue(value) {
|
|
1015
|
+
return JSON.stringify(value);
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Check if value is an update operator object
|
|
1019
|
+
* Supports both lowercase (new) and uppercase (legacy) operators
|
|
1020
|
+
*/
|
|
1021
|
+
isUpdateOperator(value) {
|
|
1022
|
+
if (!value || typeof value !== 'object')
|
|
1023
|
+
return false;
|
|
1024
|
+
// Support both lowercase (Mongoose style) and uppercase (legacy) operators
|
|
1025
|
+
const operators = [
|
|
1026
|
+
'$inc', '$INC', '$dec', '$DEC', '$mul', '$MUL', '$min', '$MIN', '$max', '$MAX',
|
|
1027
|
+
'$set', '$SET', '$unset', '$UNSET', '$push', '$PUSH', '$pull', '$PULL',
|
|
1028
|
+
'$addToSet', '$ADDTOSET', '$currentDate', '$CURRENTDATE'
|
|
1029
|
+
];
|
|
1030
|
+
return operators.some(op => op in value);
|
|
1031
|
+
}
|
|
1032
|
+
getParameterPlaceholder(index) {
|
|
1033
|
+
return `:val${index}`;
|
|
1034
|
+
}
|
|
1035
|
+
getColumnTypeString(columnType, options) {
|
|
1036
|
+
return this.mapToDynamoType(columnType);
|
|
1037
|
+
}
|
|
1038
|
+
getSupportedFeatures() {
|
|
1039
|
+
return [
|
|
1040
|
+
base_adapter_1.DatabaseFeature.TRANSACTIONS,
|
|
1041
|
+
base_adapter_1.DatabaseFeature.TTL,
|
|
1042
|
+
base_adapter_1.DatabaseFeature.GLOBAL_SECONDARY_INDEXES,
|
|
1043
|
+
base_adapter_1.DatabaseFeature.LOCAL_SECONDARY_INDEXES,
|
|
1044
|
+
base_adapter_1.DatabaseFeature.BATCH_OPERATIONS,
|
|
1045
|
+
base_adapter_1.DatabaseFeature.ATOMIC_COUNTERS,
|
|
1046
|
+
base_adapter_1.DatabaseFeature.CHANGE_STREAMS,
|
|
1047
|
+
];
|
|
1048
|
+
}
|
|
1049
|
+
parseError(error) {
|
|
1050
|
+
const name = error.name || error.code;
|
|
1051
|
+
let type = enums_1.DatabaseErrorType.UNKNOWN_ERROR;
|
|
1052
|
+
switch (name) {
|
|
1053
|
+
case 'ConditionalCheckFailedException':
|
|
1054
|
+
type = enums_1.DatabaseErrorType.UNIQUE_VIOLATION;
|
|
1055
|
+
break;
|
|
1056
|
+
case 'ResourceNotFoundException':
|
|
1057
|
+
type = enums_1.DatabaseErrorType.NOT_FOUND;
|
|
1058
|
+
break;
|
|
1059
|
+
case 'ResourceInUseException':
|
|
1060
|
+
type = enums_1.DatabaseErrorType.SCHEMA_ERROR;
|
|
1061
|
+
break;
|
|
1062
|
+
case 'ValidationException':
|
|
1063
|
+
type = enums_1.DatabaseErrorType.VALIDATION_ERROR;
|
|
1064
|
+
break;
|
|
1065
|
+
case 'ProvisionedThroughputExceededException':
|
|
1066
|
+
case 'ThrottlingException':
|
|
1067
|
+
type = enums_1.DatabaseErrorType.QUERY_ERROR;
|
|
1068
|
+
break;
|
|
1069
|
+
case 'AccessDeniedException':
|
|
1070
|
+
type = enums_1.DatabaseErrorType.AUTHENTICATION_ERROR;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
return {
|
|
1074
|
+
type,
|
|
1075
|
+
message: error.message || 'Unknown database error',
|
|
1076
|
+
code: name,
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
// ==================== PRIVATE HELPER METHODS ====================
|
|
1080
|
+
ensureConnected() {
|
|
1081
|
+
if (!this.connected || !this.docClient) {
|
|
1082
|
+
throw new database_error_1.DatabaseError('Not connected to DynamoDB', enums_1.DatabaseErrorType.CONNECTION_ERROR);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
buildFilterExpression(where, existingNames, existingValues) {
|
|
1086
|
+
const conditions = [];
|
|
1087
|
+
const names = Object.assign({}, existingNames);
|
|
1088
|
+
const values = Object.assign({}, existingValues);
|
|
1089
|
+
let valueIndex = Object.keys(existingValues).length;
|
|
1090
|
+
for (const [key, value] of Object.entries(where)) {
|
|
1091
|
+
// Normalize key to lowercase for logical operators (support both cases for backwards compatibility)
|
|
1092
|
+
const normalizedKey = key.toLowerCase();
|
|
1093
|
+
if (normalizedKey === '$and') {
|
|
1094
|
+
const conditions_list = Array.isArray(value) ? value : Object.entries(value).map(([k, v]) => ({ [k]: v }));
|
|
1095
|
+
const andConditions = [];
|
|
1096
|
+
for (const cond of conditions_list) {
|
|
1097
|
+
const result = this.buildFilterExpression(cond, names, values);
|
|
1098
|
+
andConditions.push(result.expression);
|
|
1099
|
+
Object.assign(names, result.names);
|
|
1100
|
+
Object.assign(values, result.values);
|
|
1101
|
+
}
|
|
1102
|
+
conditions.push(`(${andConditions.join(' AND ')})`);
|
|
1103
|
+
}
|
|
1104
|
+
else if (normalizedKey === '$or') {
|
|
1105
|
+
const conditions_list = Array.isArray(value) ? value : Object.entries(value).map(([k, v]) => ({ [k]: v }));
|
|
1106
|
+
const orConditions = [];
|
|
1107
|
+
for (const cond of conditions_list) {
|
|
1108
|
+
const result = this.buildFilterExpression(cond, names, values);
|
|
1109
|
+
orConditions.push(result.expression);
|
|
1110
|
+
Object.assign(names, result.names);
|
|
1111
|
+
Object.assign(values, result.values);
|
|
1112
|
+
}
|
|
1113
|
+
conditions.push(`(${orConditions.join(' OR ')})`);
|
|
1114
|
+
}
|
|
1115
|
+
else if (normalizedKey === '$not') {
|
|
1116
|
+
const result = this.buildFilterExpression(value, names, values);
|
|
1117
|
+
conditions.push(`NOT (${result.expression})`);
|
|
1118
|
+
Object.assign(names, result.names);
|
|
1119
|
+
Object.assign(values, result.values);
|
|
1120
|
+
}
|
|
1121
|
+
else if (normalizedKey === '$nor') {
|
|
1122
|
+
const conditions_list = Array.isArray(value) ? value : [value];
|
|
1123
|
+
const norConditions = [];
|
|
1124
|
+
for (const cond of conditions_list) {
|
|
1125
|
+
const result = this.buildFilterExpression(cond, names, values);
|
|
1126
|
+
norConditions.push(result.expression);
|
|
1127
|
+
Object.assign(names, result.names);
|
|
1128
|
+
Object.assign(values, result.values);
|
|
1129
|
+
}
|
|
1130
|
+
conditions.push(`NOT (${norConditions.join(' OR ')})`);
|
|
1131
|
+
}
|
|
1132
|
+
else if (value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Date)) {
|
|
1133
|
+
const nameKey = `#${key.replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
1134
|
+
names[nameKey] = key;
|
|
1135
|
+
for (const [op, opValue] of Object.entries(value)) {
|
|
1136
|
+
const valueKey = `:val${valueIndex++}`;
|
|
1137
|
+
values[valueKey] = opValue;
|
|
1138
|
+
// Normalize operator to lowercase (support both cases for backwards compatibility)
|
|
1139
|
+
const normalizedOp = op.toLowerCase();
|
|
1140
|
+
switch (normalizedOp) {
|
|
1141
|
+
case '$eq':
|
|
1142
|
+
conditions.push(`${nameKey} = ${valueKey}`);
|
|
1143
|
+
break;
|
|
1144
|
+
case '$ne':
|
|
1145
|
+
conditions.push(`${nameKey} <> ${valueKey}`);
|
|
1146
|
+
break;
|
|
1147
|
+
case '$gt':
|
|
1148
|
+
conditions.push(`${nameKey} > ${valueKey}`);
|
|
1149
|
+
break;
|
|
1150
|
+
case '$gte':
|
|
1151
|
+
conditions.push(`${nameKey} >= ${valueKey}`);
|
|
1152
|
+
break;
|
|
1153
|
+
case '$lt':
|
|
1154
|
+
conditions.push(`${nameKey} < ${valueKey}`);
|
|
1155
|
+
break;
|
|
1156
|
+
case '$lte':
|
|
1157
|
+
conditions.push(`${nameKey} <= ${valueKey}`);
|
|
1158
|
+
break;
|
|
1159
|
+
case '$in':
|
|
1160
|
+
// DynamoDB requires separate placeholders for each value in IN clause
|
|
1161
|
+
if (Array.isArray(opValue)) {
|
|
1162
|
+
const inPlaceholders = [];
|
|
1163
|
+
for (const item of opValue) {
|
|
1164
|
+
const itemKey = `:val${valueIndex++}`;
|
|
1165
|
+
values[itemKey] = item;
|
|
1166
|
+
inPlaceholders.push(itemKey);
|
|
1167
|
+
}
|
|
1168
|
+
// Remove the original valueKey since we're using individual placeholders
|
|
1169
|
+
delete values[valueKey];
|
|
1170
|
+
conditions.push(`${nameKey} IN (${inPlaceholders.join(', ')})`);
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
// Single value - treat as equality
|
|
1174
|
+
conditions.push(`${nameKey} = ${valueKey}`);
|
|
1175
|
+
}
|
|
1176
|
+
break;
|
|
1177
|
+
case '$between':
|
|
1178
|
+
const [min, max] = opValue;
|
|
1179
|
+
const minKey = `:val${valueIndex++}`;
|
|
1180
|
+
const maxKey = `:val${valueIndex++}`;
|
|
1181
|
+
values[minKey] = min;
|
|
1182
|
+
values[maxKey] = max;
|
|
1183
|
+
conditions.push(`${nameKey} BETWEEN ${minKey} AND ${maxKey}`);
|
|
1184
|
+
break;
|
|
1185
|
+
case '$like':
|
|
1186
|
+
conditions.push(`contains(${nameKey}, ${valueKey})`);
|
|
1187
|
+
break;
|
|
1188
|
+
case '$isnull':
|
|
1189
|
+
case '$is_null':
|
|
1190
|
+
if (opValue) {
|
|
1191
|
+
conditions.push(`attribute_not_exists(${nameKey})`);
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
conditions.push(`attribute_exists(${nameKey})`);
|
|
1195
|
+
}
|
|
1196
|
+
delete values[valueKey];
|
|
1197
|
+
break;
|
|
1198
|
+
case '$isnotnull':
|
|
1199
|
+
case '$is_not_null':
|
|
1200
|
+
if (opValue) {
|
|
1201
|
+
conditions.push(`attribute_exists(${nameKey})`);
|
|
1202
|
+
}
|
|
1203
|
+
else {
|
|
1204
|
+
conditions.push(`attribute_not_exists(${nameKey})`);
|
|
1205
|
+
}
|
|
1206
|
+
delete values[valueKey];
|
|
1207
|
+
break;
|
|
1208
|
+
case '$exists':
|
|
1209
|
+
if (opValue) {
|
|
1210
|
+
conditions.push(`attribute_exists(${nameKey})`);
|
|
1211
|
+
}
|
|
1212
|
+
else {
|
|
1213
|
+
conditions.push(`attribute_not_exists(${nameKey})`);
|
|
1214
|
+
}
|
|
1215
|
+
delete values[valueKey];
|
|
1216
|
+
break;
|
|
1217
|
+
case '$contains':
|
|
1218
|
+
conditions.push(`contains(${nameKey}, ${valueKey})`);
|
|
1219
|
+
break;
|
|
1220
|
+
case '$begins_with':
|
|
1221
|
+
conditions.push(`begins_with(${nameKey}, ${valueKey})`);
|
|
1222
|
+
break;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
const nameKey = `#${key.replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
1228
|
+
const valueKey = `:val${valueIndex++}`;
|
|
1229
|
+
names[nameKey] = key;
|
|
1230
|
+
values[valueKey] = value;
|
|
1231
|
+
conditions.push(`${nameKey} = ${valueKey}`);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
return {
|
|
1235
|
+
expression: conditions.join(' AND '),
|
|
1236
|
+
names,
|
|
1237
|
+
values,
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
buildUpdateExpression(data) {
|
|
1241
|
+
const setClauses = [];
|
|
1242
|
+
const addClauses = [];
|
|
1243
|
+
const names = {};
|
|
1244
|
+
const values = {};
|
|
1245
|
+
let valueIndex = 0;
|
|
1246
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1247
|
+
const nameKey = `#${key.replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
1248
|
+
names[nameKey] = key;
|
|
1249
|
+
if (value && typeof value === 'object' && this.isUpdateOperator(value)) {
|
|
1250
|
+
const valueKey = `:val${valueIndex++}`;
|
|
1251
|
+
if ('$INC' in value) {
|
|
1252
|
+
values[valueKey] = value.$INC;
|
|
1253
|
+
addClauses.push(`${nameKey} ${valueKey}`);
|
|
1254
|
+
}
|
|
1255
|
+
else if ('$DEC' in value) {
|
|
1256
|
+
values[valueKey] = -value.$DEC;
|
|
1257
|
+
addClauses.push(`${nameKey} ${valueKey}`);
|
|
1258
|
+
}
|
|
1259
|
+
else if ('$MUL' in value) {
|
|
1260
|
+
// DynamoDB doesn't have native multiply - use SET with expression
|
|
1261
|
+
const mulValueKey = `:mul${valueIndex++}`;
|
|
1262
|
+
values[mulValueKey] = value.$MUL;
|
|
1263
|
+
setClauses.push(`${nameKey} = ${nameKey} * ${mulValueKey}`);
|
|
1264
|
+
}
|
|
1265
|
+
else if ('$MIN' in value) {
|
|
1266
|
+
// DynamoDB doesn't have native min - use if_not_exists or conditional
|
|
1267
|
+
// For simplicity, just set the value (user should use conditional writes for atomic min)
|
|
1268
|
+
values[valueKey] = value.$MIN;
|
|
1269
|
+
setClauses.push(`${nameKey} = if_not_exists(${nameKey}, ${valueKey})`);
|
|
1270
|
+
}
|
|
1271
|
+
else if ('$MAX' in value) {
|
|
1272
|
+
// DynamoDB doesn't have native max - similar to min
|
|
1273
|
+
values[valueKey] = value.$MAX;
|
|
1274
|
+
setClauses.push(`${nameKey} = if_not_exists(${nameKey}, ${valueKey})`);
|
|
1275
|
+
}
|
|
1276
|
+
else if ('$SET' in value) {
|
|
1277
|
+
values[valueKey] = value.$SET;
|
|
1278
|
+
setClauses.push(`${nameKey} = ${valueKey}`);
|
|
1279
|
+
}
|
|
1280
|
+
else if ('$UNSET' in value && value.$UNSET) {
|
|
1281
|
+
// Use REMOVE clause for unsetting
|
|
1282
|
+
// Note: REMOVE is handled separately
|
|
1283
|
+
setClauses.push(`REMOVE ${nameKey}`);
|
|
1284
|
+
}
|
|
1285
|
+
else if ('$PUSH' in value) {
|
|
1286
|
+
// DynamoDB list_append for arrays
|
|
1287
|
+
values[valueKey] = [value.$PUSH];
|
|
1288
|
+
setClauses.push(`${nameKey} = list_append(if_not_exists(${nameKey}, :emptyList), ${valueKey})`);
|
|
1289
|
+
values[':emptyList'] = [];
|
|
1290
|
+
}
|
|
1291
|
+
else if ('$ADDTOSET' in value) {
|
|
1292
|
+
// DynamoDB ADD for sets
|
|
1293
|
+
values[valueKey] = new Set([value.$ADDTOSET]);
|
|
1294
|
+
addClauses.push(`${nameKey} ${valueKey}`);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
else {
|
|
1298
|
+
const valueKey = `:val${valueIndex++}`;
|
|
1299
|
+
values[valueKey] = value;
|
|
1300
|
+
setClauses.push(`${nameKey} = ${valueKey}`);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
let expression = '';
|
|
1304
|
+
if (setClauses.length > 0) {
|
|
1305
|
+
expression += `SET ${setClauses.join(', ')}`;
|
|
1306
|
+
}
|
|
1307
|
+
if (addClauses.length > 0) {
|
|
1308
|
+
if (expression)
|
|
1309
|
+
expression += ' ';
|
|
1310
|
+
expression += `ADD ${addClauses.join(', ')}`;
|
|
1311
|
+
}
|
|
1312
|
+
return { expression, names, values };
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Extract key condition from where clause if partition key is present.
|
|
1316
|
+
* This enables using Query instead of Scan for better performance.
|
|
1317
|
+
*/
|
|
1318
|
+
async extractKeyCondition(where, tableName) {
|
|
1319
|
+
var _a, _b, _c;
|
|
1320
|
+
if (!where || Object.keys(where).length === 0) {
|
|
1321
|
+
return { keyCondition: null, filterCondition: null };
|
|
1322
|
+
}
|
|
1323
|
+
try {
|
|
1324
|
+
const { DescribeTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
1325
|
+
const response = await this.dynamoClient.send(new DescribeTableCommand({
|
|
1326
|
+
TableName: tableName,
|
|
1327
|
+
}));
|
|
1328
|
+
const keySchema = ((_a = response.Table) === null || _a === void 0 ? void 0 : _a.KeySchema) || [];
|
|
1329
|
+
if (keySchema.length === 0) {
|
|
1330
|
+
return { keyCondition: null, filterCondition: null };
|
|
1331
|
+
}
|
|
1332
|
+
// Get partition key and sort key names
|
|
1333
|
+
const partitionKeyName = (_b = keySchema.find((k) => k.KeyType === 'HASH')) === null || _b === void 0 ? void 0 : _b.AttributeName;
|
|
1334
|
+
const sortKeyName = (_c = keySchema.find((k) => k.KeyType === 'RANGE')) === null || _c === void 0 ? void 0 : _c.AttributeName;
|
|
1335
|
+
if (!partitionKeyName) {
|
|
1336
|
+
return { keyCondition: null, filterCondition: null };
|
|
1337
|
+
}
|
|
1338
|
+
// Check if partition key is in the where clause
|
|
1339
|
+
const partitionKeyValue = this.getWhereValue(where, partitionKeyName);
|
|
1340
|
+
if (partitionKeyValue === undefined) {
|
|
1341
|
+
// No partition key - must use Scan
|
|
1342
|
+
return { keyCondition: null, filterCondition: null };
|
|
1343
|
+
}
|
|
1344
|
+
// Build key condition expression
|
|
1345
|
+
const keyNames = {};
|
|
1346
|
+
const keyValues = {};
|
|
1347
|
+
const keyConditions = [];
|
|
1348
|
+
// Add partition key condition (must be equality)
|
|
1349
|
+
const pkNameKey = `#pk`;
|
|
1350
|
+
const pkValueKey = `:pkval`;
|
|
1351
|
+
keyNames[pkNameKey] = partitionKeyName;
|
|
1352
|
+
keyValues[pkValueKey] = partitionKeyValue;
|
|
1353
|
+
keyConditions.push(`${pkNameKey} = ${pkValueKey}`);
|
|
1354
|
+
// Check for sort key condition (can be equality or range)
|
|
1355
|
+
if (sortKeyName) {
|
|
1356
|
+
const sortKeyOp = this.getWhereOperator(where, sortKeyName);
|
|
1357
|
+
if (sortKeyOp) {
|
|
1358
|
+
const skNameKey = `#sk`;
|
|
1359
|
+
keyNames[skNameKey] = sortKeyName;
|
|
1360
|
+
if (sortKeyOp.op === '$EQ' || sortKeyOp.op === 'equality') {
|
|
1361
|
+
const skValueKey = `:skval`;
|
|
1362
|
+
keyValues[skValueKey] = sortKeyOp.value;
|
|
1363
|
+
keyConditions.push(`${skNameKey} = ${skValueKey}`);
|
|
1364
|
+
}
|
|
1365
|
+
else if (sortKeyOp.op === '$GT') {
|
|
1366
|
+
const skValueKey = `:skval`;
|
|
1367
|
+
keyValues[skValueKey] = sortKeyOp.value;
|
|
1368
|
+
keyConditions.push(`${skNameKey} > ${skValueKey}`);
|
|
1369
|
+
}
|
|
1370
|
+
else if (sortKeyOp.op === '$GTE') {
|
|
1371
|
+
const skValueKey = `:skval`;
|
|
1372
|
+
keyValues[skValueKey] = sortKeyOp.value;
|
|
1373
|
+
keyConditions.push(`${skNameKey} >= ${skValueKey}`);
|
|
1374
|
+
}
|
|
1375
|
+
else if (sortKeyOp.op === '$LT') {
|
|
1376
|
+
const skValueKey = `:skval`;
|
|
1377
|
+
keyValues[skValueKey] = sortKeyOp.value;
|
|
1378
|
+
keyConditions.push(`${skNameKey} < ${skValueKey}`);
|
|
1379
|
+
}
|
|
1380
|
+
else if (sortKeyOp.op === '$LTE') {
|
|
1381
|
+
const skValueKey = `:skval`;
|
|
1382
|
+
keyValues[skValueKey] = sortKeyOp.value;
|
|
1383
|
+
keyConditions.push(`${skNameKey} <= ${skValueKey}`);
|
|
1384
|
+
}
|
|
1385
|
+
else if (sortKeyOp.op === '$BETWEEN') {
|
|
1386
|
+
const [min, max] = sortKeyOp.value;
|
|
1387
|
+
keyValues[`:skmin`] = min;
|
|
1388
|
+
keyValues[`:skmax`] = max;
|
|
1389
|
+
keyConditions.push(`${skNameKey} BETWEEN :skmin AND :skmax`);
|
|
1390
|
+
}
|
|
1391
|
+
else if (sortKeyOp.op === '$BEGINS_WITH') {
|
|
1392
|
+
const skValueKey = `:skval`;
|
|
1393
|
+
keyValues[skValueKey] = sortKeyOp.value;
|
|
1394
|
+
keyConditions.push(`begins_with(${skNameKey}, ${skValueKey})`);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
// Build filter condition for remaining where clauses
|
|
1399
|
+
const filterWhere = Object.assign({}, where);
|
|
1400
|
+
delete filterWhere[partitionKeyName];
|
|
1401
|
+
if (sortKeyName) {
|
|
1402
|
+
delete filterWhere[sortKeyName];
|
|
1403
|
+
}
|
|
1404
|
+
let filterCondition = null;
|
|
1405
|
+
if (Object.keys(filterWhere).length > 0) {
|
|
1406
|
+
filterCondition = this.buildFilterExpression(filterWhere, {}, {});
|
|
1407
|
+
}
|
|
1408
|
+
return {
|
|
1409
|
+
keyCondition: {
|
|
1410
|
+
expression: keyConditions.join(' AND '),
|
|
1411
|
+
names: keyNames,
|
|
1412
|
+
values: keyValues,
|
|
1413
|
+
},
|
|
1414
|
+
filterCondition,
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
catch (error) {
|
|
1418
|
+
// If we can't get table metadata, fall back to Scan
|
|
1419
|
+
return { keyCondition: null, filterCondition: null };
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Get simple value from where clause for a specific field
|
|
1424
|
+
*/
|
|
1425
|
+
getWhereValue(where, fieldName) {
|
|
1426
|
+
const value = where[fieldName];
|
|
1427
|
+
if (value === undefined) {
|
|
1428
|
+
return undefined;
|
|
1429
|
+
}
|
|
1430
|
+
// Simple equality check
|
|
1431
|
+
if (typeof value !== 'object' || value === null) {
|
|
1432
|
+
return value;
|
|
1433
|
+
}
|
|
1434
|
+
// Check for $EQ operator
|
|
1435
|
+
if (value.$EQ !== undefined) {
|
|
1436
|
+
return value.$EQ;
|
|
1437
|
+
}
|
|
1438
|
+
return undefined;
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Get operator and value from where clause for a specific field
|
|
1442
|
+
*/
|
|
1443
|
+
getWhereOperator(where, fieldName) {
|
|
1444
|
+
const value = where[fieldName];
|
|
1445
|
+
if (value === undefined) {
|
|
1446
|
+
return null;
|
|
1447
|
+
}
|
|
1448
|
+
// Simple equality
|
|
1449
|
+
if (typeof value !== 'object' || value === null) {
|
|
1450
|
+
return { op: 'equality', value };
|
|
1451
|
+
}
|
|
1452
|
+
// Check for operators
|
|
1453
|
+
for (const op of ['$EQ', '$GT', '$GTE', '$LT', '$LTE', '$BETWEEN', '$BEGINS_WITH']) {
|
|
1454
|
+
if (value[op] !== undefined) {
|
|
1455
|
+
return { op, value: value[op] };
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
async getTableKey(tableName, item) {
|
|
1461
|
+
var _a;
|
|
1462
|
+
const { DescribeTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
1463
|
+
const response = await this.dynamoClient.send(new DescribeTableCommand({
|
|
1464
|
+
TableName: tableName,
|
|
1465
|
+
}));
|
|
1466
|
+
const key = {};
|
|
1467
|
+
const keySchema = ((_a = response.Table) === null || _a === void 0 ? void 0 : _a.KeySchema) || [];
|
|
1468
|
+
for (const keyDef of keySchema) {
|
|
1469
|
+
key[keyDef.AttributeName] = item[keyDef.AttributeName];
|
|
1470
|
+
}
|
|
1471
|
+
return key;
|
|
1472
|
+
}
|
|
1473
|
+
async waitForTableActive(tableName, maxWait = 60000) {
|
|
1474
|
+
var _a;
|
|
1475
|
+
const { DescribeTableCommand } = await Promise.resolve().then(() => __importStar(require('@aws-sdk/client-dynamodb')));
|
|
1476
|
+
const startTime = Date.now();
|
|
1477
|
+
while (Date.now() - startTime < maxWait) {
|
|
1478
|
+
const response = await this.dynamoClient.send(new DescribeTableCommand({
|
|
1479
|
+
TableName: tableName,
|
|
1480
|
+
}));
|
|
1481
|
+
if (((_a = response.Table) === null || _a === void 0 ? void 0 : _a.TableStatus) === 'ACTIVE') {
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1485
|
+
}
|
|
1486
|
+
throw new Error(`Table ${tableName} did not become active within ${maxWait}ms`);
|
|
1487
|
+
}
|
|
1488
|
+
mapToDynamoType(columnType) {
|
|
1489
|
+
const typeMap = {
|
|
1490
|
+
[enums_1.ColumnType.INTEGER]: 'N',
|
|
1491
|
+
[enums_1.ColumnType.BIGINT]: 'N',
|
|
1492
|
+
[enums_1.ColumnType.FLOAT]: 'N',
|
|
1493
|
+
[enums_1.ColumnType.DOUBLE]: 'N',
|
|
1494
|
+
[enums_1.ColumnType.DECIMAL]: 'N',
|
|
1495
|
+
[enums_1.ColumnType.STRING]: 'S',
|
|
1496
|
+
[enums_1.ColumnType.TEXT]: 'S',
|
|
1497
|
+
[enums_1.ColumnType.BOOLEAN]: 'BOOL',
|
|
1498
|
+
[enums_1.ColumnType.BINARY]: 'B',
|
|
1499
|
+
[enums_1.ColumnType.UUID]: 'S',
|
|
1500
|
+
};
|
|
1501
|
+
return typeMap[columnType] || 'S';
|
|
1502
|
+
}
|
|
1503
|
+
mapFromDynamoType(dynamoType) {
|
|
1504
|
+
const typeMap = {
|
|
1505
|
+
'N': 'number',
|
|
1506
|
+
'S': 'string',
|
|
1507
|
+
'B': 'binary',
|
|
1508
|
+
'BOOL': 'boolean',
|
|
1509
|
+
'L': 'list',
|
|
1510
|
+
'M': 'map',
|
|
1511
|
+
'SS': 'stringSet',
|
|
1512
|
+
'NS': 'numberSet',
|
|
1513
|
+
'BS': 'binarySet',
|
|
1514
|
+
};
|
|
1515
|
+
return typeMap[dynamoType] || 'unknown';
|
|
1516
|
+
}
|
|
1517
|
+
chunkArray(array, size) {
|
|
1518
|
+
const chunks = [];
|
|
1519
|
+
for (let i = 0; i < array.length; i += size) {
|
|
1520
|
+
chunks.push(array.slice(i, i + size));
|
|
1521
|
+
}
|
|
1522
|
+
return chunks;
|
|
1523
|
+
}
|
|
1524
|
+
formatBytes(bytes) {
|
|
1525
|
+
if (bytes === 0)
|
|
1526
|
+
return '0 B';
|
|
1527
|
+
const k = 1024;
|
|
1528
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
1529
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1530
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
exports.DynamoDBAdapter = DynamoDBAdapter;
|
|
1534
|
+
//# sourceMappingURL=dynamodb.adapter.js.map
|