@ductape/sdk 0.0.4-v51 → 0.0.4-v52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/agent-context.d.ts +98 -0
- package/dist/agents/agent-context.js +588 -0
- package/dist/agents/agent-context.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +180 -0
- package/dist/agents/agent-executor.js +715 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/agents.service.d.ts +304 -0
- package/dist/agents/agents.service.js +1244 -0
- package/dist/agents/agents.service.js.map +1 -0
- package/dist/agents/index.d.ts +55 -0
- package/dist/agents/index.js +110 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/memory-manager.d.ts +182 -0
- package/dist/agents/memory-manager.js +383 -0
- package/dist/agents/memory-manager.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +141 -0
- package/dist/agents/tool-registry.js +355 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/agents/types/agents.types.d.ts +1225 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.js +4 -5
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +322 -0
- package/dist/api/services/processorApi.service.js +252 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +69 -1
- package/dist/api/services/productsApi.service.js +67 -31
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +38 -0
- package/dist/api/services/secretsApi.service.js +96 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/userApi.service.js +0 -1
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +183 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.js +0 -1
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +57 -0
- package/dist/api/urls.js +68 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.js +4 -10
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +0 -10
- package/dist/apps/services/app.service.js +74 -30
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +405 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +257 -0
- package/dist/brokers/brokers.service.js +604 -0
- package/dist/brokers/brokers.service.js.map +1 -0
- package/dist/brokers/index.d.ts +46 -0
- package/dist/brokers/index.js +83 -0
- package/dist/brokers/index.js.map +1 -0
- package/dist/brokers/types/index.d.ts +288 -0
- package/dist/brokers/types/index.js +8 -0
- package/dist/brokers/types/index.js.map +1 -0
- package/dist/brokers/utils/broker.util.d.ts +33 -0
- package/dist/brokers/utils/broker.util.js +125 -0
- package/dist/brokers/utils/broker.util.js.map +1 -0
- package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
- package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
- package/dist/brokers/utils/providers/index.d.ts +6 -0
- package/dist/brokers/utils/providers/index.js +16 -0
- package/dist/brokers/utils/providers/index.js.map +1 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +16 -0
- package/dist/brokers/utils/providers/kafka.service.js +52 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +14 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
- package/dist/brokers/utils/providers/redis.service.js +93 -0
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +159 -0
- package/dist/cache/cache.manager.js +265 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +186 -0
- package/dist/cache/cache.service.js +437 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +79 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +106 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +307 -90
- package/dist/database/adapters/base.adapter.js +139 -20
- package/dist/database/adapters/base.adapter.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
- package/dist/database/adapters/cassandra.adapter.js +1019 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
- package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +105 -57
- package/dist/database/adapters/mongodb.adapter.js +941 -838
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +76 -138
- package/dist/database/adapters/mysql.adapter.js +990 -1246
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
- package/dist/database/adapters/postgresql.adapter.js +1076 -1346
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +1374 -0
- package/dist/database/databases.service.js +2680 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +41 -13
- package/dist/database/index.js +97 -86
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +132 -0
- package/dist/database/migrations/migration-engine.js +1356 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +64 -0
- package/dist/database/operators/aggregation-builder.js +746 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +55 -0
- package/dist/database/operators/query-builder.js +365 -0
- package/dist/database/operators/query-builder.js.map +1 -0
- package/dist/database/presave/decrypt.d.ts +25 -0
- package/dist/database/presave/decrypt.js +146 -0
- package/dist/database/presave/decrypt.js.map +1 -0
- package/dist/database/presave/index.d.ts +9 -0
- package/dist/database/presave/index.js +18 -0
- package/dist/database/presave/index.js.map +1 -0
- package/dist/database/presave/presave-processor.d.ts +148 -0
- package/dist/database/presave/presave-processor.js +702 -0
- package/dist/database/presave/presave-processor.js.map +1 -0
- package/dist/database/schema/index.d.ts +7 -0
- package/dist/database/schema/index.js +13 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/database/schema/schema-manager.d.ts +258 -0
- package/dist/database/schema/schema-manager.js +637 -0
- package/dist/database/schema/schema-manager.js.map +1 -0
- package/dist/database/transactions/index.d.ts +6 -0
- package/dist/database/transactions/index.js +13 -0
- package/dist/database/transactions/index.js.map +1 -0
- package/dist/database/transactions/transaction-manager.d.ts +113 -0
- package/dist/database/transactions/transaction-manager.js +344 -0
- package/dist/database/transactions/transaction-manager.js.map +1 -0
- package/dist/database/triggers/index.d.ts +7 -0
- package/dist/database/triggers/index.js +14 -0
- package/dist/database/triggers/index.js.map +1 -0
- package/dist/database/triggers/trigger-processor.d.ts +239 -0
- package/dist/database/triggers/trigger-processor.js +1034 -0
- package/dist/database/triggers/trigger-processor.js.map +1 -0
- package/dist/database/types/action.interface.d.ts +148 -0
- package/dist/database/types/action.interface.js +6 -0
- package/dist/database/types/action.interface.js.map +1 -0
- package/dist/database/types/aggregation.interface.d.ts +179 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/enums.d.ts +195 -0
- package/dist/database/types/enums.js +244 -0
- package/dist/database/types/enums.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -10
- package/dist/database/types/index.js +26 -32
- package/dist/database/types/index.js.map +1 -1
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +199 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +398 -0
- package/dist/database/types/schema.interface.js +6 -0
- package/dist/database/types/schema.interface.js.map +1 -0
- package/dist/database/types/transaction.interface.d.ts +84 -0
- package/dist/database/types/transaction.interface.js +6 -0
- package/dist/database/types/transaction.interface.js.map +1 -0
- package/dist/database/types/trigger.interface.d.ts +612 -0
- package/dist/database/types/trigger.interface.js +121 -0
- package/dist/database/types/trigger.interface.js.map +1 -0
- package/dist/database/types/write.interface.d.ts +208 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +78 -72
- package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/base.adapter.d.ts +135 -118
- package/dist/graph/adapters/base.adapter.js +46 -20
- package/dist/graph/adapters/base.adapter.js.map +1 -1
- package/dist/graph/adapters/index.d.ts +5 -4
- package/dist/graph/adapters/index.js +6 -8
- package/dist/graph/adapters/index.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
- package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
- package/dist/graph/adapters/neo4j.adapter.js +912 -1605
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
- package/dist/graph/adapters/neptune.adapter.js +1095 -1228
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +524 -0
- package/dist/graph/graphs.service.js +1683 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +54 -8
- package/dist/graph/index.js +67 -32
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +141 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -9
- package/dist/graph/types/index.js +15 -30
- package/dist/graph/types/index.js.map +1 -1
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +168 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/index.d.ts +1905 -875
- package/dist/index.js +3063 -1282
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/init.interface.js +3 -0
- package/dist/init.interface.js.map +1 -0
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.types.d.ts +12 -2
- package/dist/logs/logs.types.js +5 -1
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +252 -0
- package/dist/notifications/notifications.service.js +654 -0
- package/dist/notifications/notifications.service.js.map +1 -0
- package/dist/notifications/types/index.d.ts +4 -0
- package/dist/notifications/types/index.js +21 -0
- package/dist/notifications/types/index.js.map +1 -0
- package/dist/notifications/types/notifications.types.d.ts +400 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +86 -70
- package/dist/processor/services/processor.service.js +1353 -1259
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +5 -1
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/services/products.service.d.ts +167 -25
- package/dist/products/services/products.service.js +1248 -412
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +6 -3
- package/dist/products/validators/index.js +14 -5
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +218 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +4 -15
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +135 -50
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
- package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +0 -6
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +88 -0
- package/dist/resilience/fallback.service.js +511 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +106 -0
- package/dist/resilience/healthcheck.service.js +379 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +90 -0
- package/dist/resilience/quota.service.js +519 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +95 -0
- package/dist/resilience/resilience.service.js +525 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +479 -0
- package/dist/resilience/types/index.js +26 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +83 -0
- package/dist/secrets/secrets.service.js +159 -0
- package/dist/secrets/secrets.service.js.map +1 -0
- package/dist/secrets/secrets.types.d.ts +188 -0
- package/dist/secrets/secrets.types.js +87 -0
- package/dist/secrets/secrets.types.js.map +1 -0
- package/dist/sessions/index.d.ts +50 -0
- package/dist/sessions/index.js +93 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +68 -0
- package/dist/sessions/sessions.helper.js +116 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +150 -0
- package/dist/sessions/sessions.resolver.js +356 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +170 -0
- package/dist/sessions/sessions.service.js +736 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +290 -0
- package/dist/sessions/types/index.js +6 -0
- package/dist/sessions/types/index.js.map +1 -0
- package/dist/storage/index.d.ts +66 -0
- package/dist/storage/index.js +98 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +123 -0
- package/dist/storage/storage.service.js +478 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +207 -0
- package/dist/storage/types/index.js +6 -0
- package/dist/storage/types/index.js.map +1 -0
- package/dist/storage/utils/storage.util.d.ts +51 -0
- package/dist/storage/utils/storage.util.js +402 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +13 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -15
- package/dist/test/test.appBuilder.js.map +1 -1
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.health.d.ts +0 -1
- package/dist/test/test.health.js +0 -48
- package/dist/test/test.health.js.map +1 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1506
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -75
- package/dist/test/test.import.openapi.js.map +1 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -76
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -17
- package/dist/test/test.logs.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +0 -1
- package/dist/test/test.notifiers.js +0 -84
- package/dist/test/test.notifiers.js.map +1 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -37
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -660
- package/dist/test/test.productBuilder.js.map +1 -1
- package/dist/test/test.products.d.ts +0 -1
- package/dist/test/test.products.js +0 -48
- package/dist/test/test.products.js.map +1 -1
- package/dist/test/test.storage.js +332 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/dist/types/enums.d.ts +6 -1
- package/dist/types/enums.js +5 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/processor.types.d.ts +197 -35
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +837 -75
- package/dist/types/productsBuilder.types.js +168 -62
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +2 -49
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +152 -0
- package/dist/vector/adapters/base.adapter.js +137 -0
- package/dist/vector/adapters/base.adapter.js.map +1 -0
- package/dist/vector/adapters/index.d.ts +10 -0
- package/dist/vector/adapters/index.js +19 -0
- package/dist/vector/adapters/index.js.map +1 -0
- package/dist/vector/adapters/memory.adapter.d.ts +85 -0
- package/dist/vector/adapters/memory.adapter.js +505 -0
- package/dist/vector/adapters/memory.adapter.js.map +1 -0
- package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
- package/dist/vector/adapters/pinecone.adapter.js +400 -0
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
- package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
- package/dist/vector/adapters/qdrant.adapter.js +392 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
- package/dist/vector/adapters/weaviate.adapter.js +478 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +47 -0
- package/dist/vector/index.js +72 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/types/connection.interface.d.ts +151 -0
- package/dist/vector/types/connection.interface.js +8 -0
- package/dist/vector/types/connection.interface.js.map +1 -0
- package/dist/vector/types/embedding.interface.d.ts +144 -0
- package/dist/vector/types/embedding.interface.js +8 -0
- package/dist/vector/types/embedding.interface.js.map +1 -0
- package/dist/vector/types/enums.d.ts +104 -0
- package/dist/vector/types/enums.js +113 -0
- package/dist/vector/types/enums.js.map +1 -0
- package/dist/vector/types/index.d.ts +9 -0
- package/dist/vector/types/index.js +16 -0
- package/dist/vector/types/index.js.map +1 -0
- package/dist/vector/types/vector.interface.d.ts +315 -0
- package/dist/vector/types/vector.interface.js +8 -0
- package/dist/vector/types/vector.interface.js.map +1 -0
- package/dist/vector/utils/index.d.ts +6 -0
- package/dist/vector/utils/index.js +11 -0
- package/dist/vector/utils/index.js.map +1 -0
- package/dist/vector/utils/vector-error.d.ts +69 -0
- package/dist/vector/utils/vector-error.js +117 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +405 -0
- package/dist/vector/vector-database.service.js +544 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +245 -0
- package/dist/vector/vector.service.js +381 -0
- package/dist/vector/vector.service.js.map +1 -0
- package/dist/workflows/index.d.ts +30 -0
- package/dist/workflows/index.js +64 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types/index.d.ts +6 -0
- package/dist/workflows/types/index.js +23 -0
- package/dist/workflows/types/index.js.map +1 -0
- package/dist/workflows/types/workflows.types.d.ts +1035 -0
- package/dist/workflows/types/workflows.types.js +13 -0
- package/dist/workflows/types/workflows.types.js.map +1 -0
- package/dist/workflows/workflow-builder.d.ts +70 -0
- package/dist/workflows/workflow-builder.js +338 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +205 -0
- package/dist/workflows/workflow-executor.js +1186 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +398 -0
- package/dist/workflows/workflows.service.js +1595 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +16 -13
- package/dist/actions/actions.repo.d.ts +0 -0
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.d.ts +0 -0
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.d.ts +0 -0
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +0 -75
- package/dist/api/services/workspaceSecretsApi.service.js +0 -62
- package/dist/api/services/workspaceSecretsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/database/database.service.d.ts +0 -232
- package/dist/database/database.service.js +0 -802
- package/dist/database/database.service.js.map +0 -1
- package/dist/database/types/aggregation.types.d.ts +0 -261
- package/dist/database/types/aggregation.types.js +0 -21
- package/dist/database/types/aggregation.types.js.map +0 -1
- package/dist/database/types/connection.types.d.ts +0 -132
- package/dist/database/types/connection.types.js +0 -6
- package/dist/database/types/connection.types.js.map +0 -1
- package/dist/database/types/database.types.d.ts +0 -175
- package/dist/database/types/database.types.js +0 -75
- package/dist/database/types/database.types.js.map +0 -1
- package/dist/database/types/index.types.d.ts +0 -220
- package/dist/database/types/index.types.js +0 -27
- package/dist/database/types/index.types.js.map +0 -1
- package/dist/database/types/migration.types.d.ts +0 -205
- package/dist/database/types/migration.types.js +0 -44
- package/dist/database/types/migration.types.js.map +0 -1
- package/dist/database/types/query.types.d.ts +0 -305
- package/dist/database/types/query.types.js +0 -57
- package/dist/database/types/query.types.js.map +0 -1
- package/dist/database/types/result.types.d.ts +0 -220
- package/dist/database/types/result.types.js +0 -6
- package/dist/database/types/result.types.js.map +0 -1
- package/dist/database/types/schema.types.d.ts +0 -190
- package/dist/database/types/schema.types.js +0 -69
- package/dist/database/types/schema.types.js.map +0 -1
- package/dist/database/utils/helpers.d.ts +0 -66
- package/dist/database/utils/helpers.js +0 -501
- package/dist/database/utils/helpers.js.map +0 -1
- package/dist/database/utils/migration.utils.d.ts +0 -151
- package/dist/database/utils/migration.utils.js +0 -476
- package/dist/database/utils/migration.utils.js.map +0 -1
- package/dist/database/utils/transaction.d.ts +0 -64
- package/dist/database/utils/transaction.js +0 -130
- package/dist/database/utils/transaction.js.map +0 -1
- package/dist/database/validators/connection.validator.d.ts +0 -20
- package/dist/database/validators/connection.validator.js +0 -267
- package/dist/database/validators/connection.validator.js.map +0 -1
- package/dist/database/validators/query.validator.d.ts +0 -31
- package/dist/database/validators/query.validator.js +0 -305
- package/dist/database/validators/query.validator.js.map +0 -1
- package/dist/database/validators/schema.validator.d.ts +0 -31
- package/dist/database/validators/schema.validator.js +0 -334
- package/dist/database/validators/schema.validator.js.map +0 -1
- package/dist/graph/graph.service.d.ts +0 -278
- package/dist/graph/graph.service.js +0 -687
- package/dist/graph/graph.service.js.map +0 -1
- package/dist/graph/types/connection.types.d.ts +0 -158
- package/dist/graph/types/connection.types.js +0 -43
- package/dist/graph/types/connection.types.js.map +0 -1
- package/dist/graph/types/graph.types.d.ts +0 -144
- package/dist/graph/types/graph.types.js +0 -84
- package/dist/graph/types/graph.types.js.map +0 -1
- package/dist/graph/types/node.types.d.ts +0 -193
- package/dist/graph/types/node.types.js +0 -49
- package/dist/graph/types/node.types.js.map +0 -1
- package/dist/graph/types/path.types.d.ts +0 -224
- package/dist/graph/types/path.types.js +0 -38
- package/dist/graph/types/path.types.js.map +0 -1
- package/dist/graph/types/query.types.d.ts +0 -247
- package/dist/graph/types/query.types.js +0 -23
- package/dist/graph/types/query.types.js.map +0 -1
- package/dist/graph/types/relationship.types.d.ts +0 -224
- package/dist/graph/types/relationship.types.js +0 -35
- package/dist/graph/types/relationship.types.js.map +0 -1
- package/dist/graph/types/result.types.d.ts +0 -237
- package/dist/graph/types/result.types.js +0 -7
- package/dist/graph/types/result.types.js.map +0 -1
- package/dist/graph/validators/index.d.ts +0 -81
- package/dist/graph/validators/index.js +0 -243
- package/dist/graph/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/utils/mongo.util.d.ts +0 -0
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/services/utils/crypt.utils.d.ts +0 -1
- package/dist/products/services/utils/crypt.utils.js +0 -17
- package/dist/products/services/utils/crypt.utils.js.map +0 -1
- package/dist/products/services/utils/functions.utils.d.ts +0 -13
- package/dist/products/services/utils/functions.utils.js +0 -289
- package/dist/products/services/utils/functions.utils.js.map +0 -1
- package/dist/products/services/utils/objects.utils.d.ts +0 -13
- package/dist/products/services/utils/objects.utils.js +0 -89
- package/dist/products/services/utils/objects.utils.js.map +0 -1
- package/dist/products/services/utils/string.utils.d.ts +0 -12
- package/dist/products/services/utils/string.utils.js +0 -168
- package/dist/products/services/utils/string.utils.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- package/dist/test.import.d.ts +0 -0
- package/dist/test.import.js +0 -24
- package/dist/test.import.js.map +0 -1
- package/dist/test.imports.js +0 -28
- package/dist/test.imports.js.map +0 -1
- package/dist/test.integrationBuilder.js +0 -276
- package/dist/test.integrationBuilder.js.map +0 -1
- package/dist/test.processor.d.ts +0 -1
- package/dist/test.processor.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.d.ts +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* MongoDB
|
|
4
|
-
*
|
|
3
|
+
* MongoDB Adapter
|
|
4
|
+
*
|
|
5
|
+
* Database adapter for MongoDB databases using the 'mongodb' driver.
|
|
6
|
+
* Implements all methods from BaseAdapter with MongoDB-specific operations.
|
|
7
|
+
*
|
|
8
|
+
* Note: MongoDB uses collections instead of tables, and documents instead of rows.
|
|
9
|
+
* The adapter translates SQL-like operations to MongoDB operations.
|
|
5
10
|
*/
|
|
6
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
12
|
if (k2 === undefined) k2 = k;
|
|
@@ -36,1036 +41,1134 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
41
|
return result;
|
|
37
42
|
};
|
|
38
43
|
})();
|
|
39
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
40
|
-
var t = {};
|
|
41
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
42
|
-
t[p] = s[p];
|
|
43
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
44
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
45
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
46
|
-
t[p[i]] = s[p[i]];
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
};
|
|
50
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
45
|
exports.MongoDBAdapter = void 0;
|
|
52
46
|
const base_adapter_1 = require("./base.adapter");
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const query_types_1 = require("../types/query.types");
|
|
47
|
+
const enums_1 = require("../types/enums");
|
|
48
|
+
const database_error_1 = require("../utils/database-error");
|
|
56
49
|
/**
|
|
57
|
-
* MongoDB
|
|
50
|
+
* MongoDB database adapter
|
|
51
|
+
* Provides MongoDB-specific implementations for all database operations
|
|
58
52
|
*/
|
|
59
|
-
class
|
|
60
|
-
constructor(id, client, db) {
|
|
61
|
-
this.id = id;
|
|
62
|
-
this.type = database_types_1.DatabaseType.MONGODB;
|
|
63
|
-
this.status = database_types_1.ConnectionStatus.CONNECTED;
|
|
64
|
-
this.client = client;
|
|
65
|
-
this.db = db;
|
|
66
|
-
}
|
|
67
|
-
async connect() {
|
|
68
|
-
var _a;
|
|
69
|
-
if (this.client && !((_a = this.client.topology) === null || _a === void 0 ? void 0 : _a.isConnected())) {
|
|
70
|
-
await this.client.connect();
|
|
71
|
-
this.status = database_types_1.ConnectionStatus.CONNECTED;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async disconnect() {
|
|
75
|
-
if (this.client) {
|
|
76
|
-
await this.client.close();
|
|
77
|
-
this.status = database_types_1.ConnectionStatus.DISCONNECTED;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
isConnected() {
|
|
81
|
-
var _a, _b;
|
|
82
|
-
return this.status === database_types_1.ConnectionStatus.CONNECTED && ((_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.topology) === null || _b === void 0 ? void 0 : _b.isConnected());
|
|
83
|
-
}
|
|
84
|
-
getClient() {
|
|
85
|
-
return this.db;
|
|
86
|
-
}
|
|
87
|
-
getMongoClient() {
|
|
88
|
-
return this.client;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* MongoDB Transaction implementation
|
|
93
|
-
* Note: MongoDB uses sessions for transactions and does NOT support savepoints
|
|
94
|
-
*/
|
|
95
|
-
class MongoDBTransaction {
|
|
96
|
-
constructor(connection, session, options) {
|
|
97
|
-
this.id = (0, uuid_1.v4)();
|
|
98
|
-
this.connection = connection;
|
|
99
|
-
this.status = database_types_1.TransactionStatus.ACTIVE;
|
|
100
|
-
this.isolationLevel = options === null || options === void 0 ? void 0 : options.isolationLevel;
|
|
101
|
-
this.createdAt = new Date();
|
|
102
|
-
this.session = session;
|
|
103
|
-
this.native = session;
|
|
104
|
-
}
|
|
105
|
-
async commit() {
|
|
106
|
-
if (this.status !== database_types_1.TransactionStatus.ACTIVE) {
|
|
107
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.TRANSACTION_ERROR, `Cannot commit transaction: status is ${this.status}`);
|
|
108
|
-
}
|
|
109
|
-
await this.session.commitTransaction();
|
|
110
|
-
await this.session.endSession();
|
|
111
|
-
this.status = database_types_1.TransactionStatus.COMMITTED;
|
|
112
|
-
}
|
|
113
|
-
async rollback() {
|
|
114
|
-
if (this.status !== database_types_1.TransactionStatus.ACTIVE) {
|
|
115
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.TRANSACTION_ERROR, `Cannot rollback transaction: status is ${this.status}`);
|
|
116
|
-
}
|
|
117
|
-
await this.session.abortTransaction();
|
|
118
|
-
await this.session.endSession();
|
|
119
|
-
this.status = database_types_1.TransactionStatus.ROLLED_BACK;
|
|
120
|
-
}
|
|
121
|
-
async savepoint(_name) {
|
|
122
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.NOT_SUPPORTED, 'MongoDB does not support savepoints. Transactions are atomic - either all changes commit or all rollback.');
|
|
123
|
-
}
|
|
124
|
-
isActive() {
|
|
125
|
-
return this.status === database_types_1.TransactionStatus.ACTIVE;
|
|
126
|
-
}
|
|
127
|
-
getSession() {
|
|
128
|
-
return this.session;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* MongoDB Adapter
|
|
133
|
-
*/
|
|
134
|
-
class MongoDBAdapter extends base_adapter_1.BaseDatabaseAdapter {
|
|
53
|
+
class MongoDBAdapter extends base_adapter_1.BaseAdapter {
|
|
135
54
|
constructor() {
|
|
136
55
|
super(...arguments);
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
56
|
+
this.databaseType = enums_1.DatabaseType.MONGODB;
|
|
57
|
+
this.mongoClient = null;
|
|
58
|
+
this.db = null;
|
|
59
|
+
this.databaseName = '';
|
|
139
60
|
}
|
|
140
|
-
// ====================
|
|
141
|
-
async connect(
|
|
61
|
+
// ==================== CONNECTION METHODS ====================
|
|
62
|
+
async connect(options) {
|
|
142
63
|
try {
|
|
143
|
-
// Dynamic import of mongodb
|
|
144
|
-
// @ts-ignore - mongodb is an optional peer dependency
|
|
64
|
+
// Dynamic import of mongodb to avoid bundling issues
|
|
145
65
|
const { MongoClient } = await Promise.resolve().then(() => __importStar(require('mongodb')));
|
|
146
|
-
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const host = options.host || 'localhost';
|
|
154
|
-
const port = options.port || 27017;
|
|
155
|
-
const username = options.username || options.user;
|
|
156
|
-
const password = options.password;
|
|
157
|
-
const authSource = options.authSource || 'admin';
|
|
158
|
-
if (username && password) {
|
|
159
|
-
uri = `mongodb://${encodeURIComponent(username)}:${encodeURIComponent(password)}@${host}:${port}/${config.database}?authSource=${authSource}`;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
uri = `mongodb://${host}:${port}/${config.database}`;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
// Create MongoDB client with options
|
|
166
|
-
const clientOptions = {
|
|
66
|
+
this.connectionUrl = options.connectionUrl;
|
|
67
|
+
// Parse connection URL to extract database name
|
|
68
|
+
const url = new URL(options.connectionUrl);
|
|
69
|
+
this.databaseName = url.pathname.slice(1) || 'test';
|
|
70
|
+
this.mongoClient = new MongoClient(options.connectionUrl, {
|
|
167
71
|
maxPoolSize: options.poolSize || 10,
|
|
168
|
-
minPoolSize: options.minPoolSize || 2,
|
|
169
72
|
connectTimeoutMS: options.connectionTimeout || 10000,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
73
|
+
serverSelectionTimeoutMS: options.connectionTimeout || 10000,
|
|
74
|
+
});
|
|
75
|
+
await this.mongoClient.connect();
|
|
76
|
+
this.db = this.mongoClient.db(this.databaseName);
|
|
77
|
+
// Get server info
|
|
78
|
+
const adminDb = this.mongoClient.db('admin');
|
|
79
|
+
const serverInfo = await adminDb.command({ buildInfo: 1 });
|
|
80
|
+
this.client = this.mongoClient;
|
|
81
|
+
this.connected = true;
|
|
82
|
+
return {
|
|
83
|
+
connected: true,
|
|
84
|
+
version: serverInfo.version,
|
|
173
85
|
};
|
|
174
|
-
// Add SSL/TLS options if specified
|
|
175
|
-
if (options.ssl || options.tls) {
|
|
176
|
-
clientOptions.tls = true;
|
|
177
|
-
if (options.tlsCAFile)
|
|
178
|
-
clientOptions.tlsCAFile = options.tlsCAFile;
|
|
179
|
-
if (options.tlsCertificateKeyFile)
|
|
180
|
-
clientOptions.tlsCertificateKeyFile = options.tlsCertificateKeyFile;
|
|
181
|
-
clientOptions.tlsAllowInvalidCertificates = options.tlsAllowInvalidCertificates || false;
|
|
182
|
-
}
|
|
183
|
-
// Add replica set options if specified
|
|
184
|
-
if (options.replicaSet) {
|
|
185
|
-
clientOptions.replicaSet = options.replicaSet;
|
|
186
|
-
}
|
|
187
|
-
const client = new MongoClient(uri, clientOptions);
|
|
188
|
-
// Connect to MongoDB
|
|
189
|
-
await client.connect();
|
|
190
|
-
// Test connection
|
|
191
|
-
await client.db(config.database).command({ ping: 1 });
|
|
192
|
-
// Get database
|
|
193
|
-
const db = client.db(config.database);
|
|
194
|
-
// Create connection wrapper
|
|
195
|
-
const connectionId = `mongodb-${config.database}-${Date.now()}`;
|
|
196
|
-
const connection = new MongoDBConnection(connectionId, client, db);
|
|
197
|
-
// Store in pool map
|
|
198
|
-
this.connectionPool.set(connectionId, connection);
|
|
199
|
-
return connection;
|
|
200
86
|
}
|
|
201
87
|
catch (error) {
|
|
202
|
-
throw
|
|
88
|
+
throw database_error_1.DatabaseError.connectionError(`Failed to connect to MongoDB: ${error.message}`, error);
|
|
203
89
|
}
|
|
204
90
|
}
|
|
205
|
-
async
|
|
206
|
-
await connection.disconnect();
|
|
207
|
-
this.connectionPool.delete(connection.id);
|
|
208
|
-
}
|
|
209
|
-
async testConnection(connection) {
|
|
210
|
-
const startTime = Date.now();
|
|
91
|
+
async testConnection(options) {
|
|
211
92
|
try {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
93
|
+
const { MongoClient } = await Promise.resolve().then(() => __importStar(require('mongodb')));
|
|
94
|
+
const client = new MongoClient(options.connectionUrl, {
|
|
95
|
+
connectTimeoutMS: options.connectionTimeout || 5000,
|
|
96
|
+
serverSelectionTimeoutMS: options.connectionTimeout || 5000,
|
|
97
|
+
});
|
|
98
|
+
await client.connect();
|
|
99
|
+
const adminDb = client.db('admin');
|
|
100
|
+
const serverInfo = await adminDb.command({ buildInfo: 1 });
|
|
101
|
+
await client.close();
|
|
216
102
|
return {
|
|
217
103
|
connected: true,
|
|
218
|
-
|
|
219
|
-
databaseType: 'mongodb',
|
|
220
|
-
responseTime,
|
|
104
|
+
version: serverInfo.version,
|
|
221
105
|
};
|
|
222
106
|
}
|
|
223
107
|
catch (error) {
|
|
224
108
|
return {
|
|
225
109
|
connected: false,
|
|
226
|
-
message: 'Failed to connect to MongoDB',
|
|
227
|
-
databaseType: 'mongodb',
|
|
228
|
-
responseTime: Date.now() - startTime,
|
|
229
|
-
error: error.message,
|
|
230
110
|
};
|
|
231
111
|
}
|
|
232
112
|
}
|
|
233
|
-
|
|
234
|
-
|
|
113
|
+
async disconnect() {
|
|
114
|
+
if (this.mongoClient) {
|
|
115
|
+
await this.mongoClient.close();
|
|
116
|
+
this.mongoClient = null;
|
|
117
|
+
this.db = null;
|
|
118
|
+
this.client = null;
|
|
119
|
+
this.connected = false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ==================== QUERY METHODS ====================
|
|
123
|
+
async query(query) {
|
|
124
|
+
var _a;
|
|
125
|
+
this.ensureConnected();
|
|
235
126
|
try {
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
// Build
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
case database_types_1.TransactionIsolationLevel.READ_UNCOMMITTED:
|
|
248
|
-
case database_types_1.TransactionIsolationLevel.READ_COMMITTED:
|
|
249
|
-
txnOptions.readConcern = { level: 'local' };
|
|
250
|
-
break;
|
|
251
|
-
case database_types_1.TransactionIsolationLevel.REPEATABLE_READ:
|
|
252
|
-
txnOptions.readConcern = { level: 'snapshot' };
|
|
253
|
-
break;
|
|
254
|
-
case database_types_1.TransactionIsolationLevel.SERIALIZABLE:
|
|
255
|
-
txnOptions.readConcern = { level: 'linearizable' };
|
|
256
|
-
break;
|
|
257
|
-
default:
|
|
258
|
-
txnOptions.readConcern = { level: 'snapshot' };
|
|
127
|
+
const collection = this.db.collection(query.options.table);
|
|
128
|
+
const session = (_a = query.options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
129
|
+
// Build MongoDB filter from where clause
|
|
130
|
+
const filter = this.buildMongoFilter(query.options.where || {});
|
|
131
|
+
// Build options
|
|
132
|
+
const findOptions = { session };
|
|
133
|
+
// Select specific fields
|
|
134
|
+
if (query.options.select) {
|
|
135
|
+
findOptions.projection = {};
|
|
136
|
+
for (const field of query.options.select) {
|
|
137
|
+
findOptions.projection[field] = 1;
|
|
259
138
|
}
|
|
260
139
|
}
|
|
261
|
-
|
|
262
|
-
|
|
140
|
+
// Sorting
|
|
141
|
+
if (query.options.orderBy) {
|
|
142
|
+
findOptions.sort = {};
|
|
143
|
+
const orderByArray = Array.isArray(query.options.orderBy)
|
|
144
|
+
? query.options.orderBy
|
|
145
|
+
: [query.options.orderBy];
|
|
146
|
+
for (const order of orderByArray) {
|
|
147
|
+
findOptions.sort[order.column] = order.order === 'DESC' ? -1 : 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Pagination
|
|
151
|
+
if (query.options.limit) {
|
|
152
|
+
findOptions.limit = query.options.limit;
|
|
153
|
+
}
|
|
154
|
+
if (query.options.offset) {
|
|
155
|
+
findOptions.skip = query.options.offset;
|
|
263
156
|
}
|
|
264
|
-
|
|
265
|
-
|
|
157
|
+
const cursor = collection.find(filter, findOptions);
|
|
158
|
+
const data = await cursor.toArray();
|
|
159
|
+
// Get total count for pagination
|
|
160
|
+
const count = await collection.countDocuments(filter, { session });
|
|
161
|
+
return {
|
|
162
|
+
data: data,
|
|
163
|
+
count,
|
|
164
|
+
};
|
|
266
165
|
}
|
|
267
166
|
catch (error) {
|
|
268
|
-
throw
|
|
167
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
269
168
|
}
|
|
270
169
|
}
|
|
271
|
-
async
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
async rollbackTransaction(connection, transaction) {
|
|
275
|
-
await transaction.rollback();
|
|
276
|
-
}
|
|
277
|
-
async createSavepoint(_connection, _transaction, _savepointName) {
|
|
278
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.NOT_SUPPORTED, 'MongoDB does not support savepoints. Transactions are atomic - either all changes commit or all rollback.');
|
|
279
|
-
}
|
|
280
|
-
async rollbackToSavepoint(_connection, _transaction, _savepoint) {
|
|
281
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.NOT_SUPPORTED, 'MongoDB does not support savepoints.');
|
|
282
|
-
}
|
|
283
|
-
async releaseSavepoint(_connection, _transaction, _savepoint) {
|
|
284
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.NOT_SUPPORTED, 'MongoDB does not support savepoints.');
|
|
285
|
-
}
|
|
286
|
-
// ==================== Query Methods ====================
|
|
287
|
-
async query(connection, options) {
|
|
288
|
-
const startTime = Date.now();
|
|
170
|
+
async raw(options) {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
this.ensureConnected();
|
|
289
173
|
try {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (options.orderBy) {
|
|
306
|
-
const sort = {};
|
|
307
|
-
const orderByArray = Array.isArray(options.orderBy) ? options.orderBy : [options.orderBy];
|
|
308
|
-
orderByArray.forEach((order) => {
|
|
309
|
-
sort[order.column] = order.order === query_types_1.SortOrder.DESC ? -1 : 1;
|
|
310
|
-
});
|
|
311
|
-
query = query.sort(sort);
|
|
312
|
-
}
|
|
313
|
-
// Apply limit and offset
|
|
314
|
-
if (options.limit) {
|
|
315
|
-
query = query.limit(options.limit);
|
|
316
|
-
}
|
|
317
|
-
if (options.offset) {
|
|
318
|
-
query = query.skip(options.offset);
|
|
174
|
+
const query = options.query;
|
|
175
|
+
// If query is an object with MongoDB command keys, run it as a database command
|
|
176
|
+
if (query && typeof query === 'object' && !Array.isArray(query)) {
|
|
177
|
+
const commandKeys = ['create', 'drop', 'findAndModify', 'createIndexes', 'dropIndexes',
|
|
178
|
+
'collMod', 'shardCollection', 'update', 'insert', 'delete', 'aggregate', 'count',
|
|
179
|
+
'distinct', 'mapReduce', 'validate', 'listCollections', 'listIndexes'];
|
|
180
|
+
const isCommand = commandKeys.some(key => key in query);
|
|
181
|
+
if (isCommand) {
|
|
182
|
+
// Run as a database command
|
|
183
|
+
const result = await this.db.command(query);
|
|
184
|
+
return {
|
|
185
|
+
data: result.value ? [result.value] : (((_a = result.cursor) === null || _a === void 0 ? void 0 : _a.firstBatch) || [result]),
|
|
186
|
+
count: result.n || result.ok || 1,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
319
189
|
}
|
|
320
|
-
|
|
321
|
-
const
|
|
190
|
+
// Otherwise, treat as a find query on a collection
|
|
191
|
+
const collection = this.db.collection(options.collection || options.table || '');
|
|
192
|
+
const session = (_b = options.transaction) === null || _b === void 0 ? void 0 : _b.client;
|
|
193
|
+
// For MongoDB, 'query' is the filter object
|
|
194
|
+
const filter = query;
|
|
195
|
+
const cursor = collection.find(filter, { session });
|
|
196
|
+
const data = await cursor.toArray();
|
|
322
197
|
return {
|
|
323
|
-
data,
|
|
198
|
+
data: data,
|
|
324
199
|
count: data.length,
|
|
325
|
-
executionTime,
|
|
326
|
-
databaseType: 'mongodb',
|
|
327
200
|
};
|
|
328
201
|
}
|
|
329
202
|
catch (error) {
|
|
330
|
-
throw
|
|
203
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
331
204
|
}
|
|
332
205
|
}
|
|
333
|
-
|
|
334
|
-
|
|
206
|
+
// ==================== WRITE METHODS ====================
|
|
207
|
+
async insert(options) {
|
|
208
|
+
var _a;
|
|
209
|
+
this.ensureConnected();
|
|
335
210
|
try {
|
|
336
|
-
const
|
|
337
|
-
const
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
211
|
+
const collection = this.db.collection(options.table);
|
|
212
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
213
|
+
const data = Array.isArray(options.data) ? options.data : [options.data];
|
|
214
|
+
if (data.length === 0) {
|
|
215
|
+
return { data: [], count: 0, insertedIds: [] };
|
|
216
|
+
}
|
|
217
|
+
// Get auto-increment fields for this collection
|
|
218
|
+
const autoIncrementFields = await this.getAutoIncrementFields(options.table);
|
|
219
|
+
// Get schema metadata for default values
|
|
220
|
+
const schemaColumns = await this.getSchemaMetadata(options.table);
|
|
221
|
+
// Process each document and assign auto-increment values and defaults
|
|
222
|
+
const processedData = await Promise.all(data.map(async (doc) => {
|
|
223
|
+
const processedDoc = Object.assign({}, doc);
|
|
224
|
+
// Apply default values for missing fields
|
|
225
|
+
for (const column of schemaColumns) {
|
|
226
|
+
if (column.defaultValue !== undefined && column.defaultValue !== null) {
|
|
227
|
+
if (processedDoc[column.name] === undefined || processedDoc[column.name] === null) {
|
|
228
|
+
processedDoc[column.name] = this.resolveDefaultValue(column.defaultValue, column.type);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// For each auto-increment field, get the next value if not already set
|
|
233
|
+
for (const field of autoIncrementFields) {
|
|
234
|
+
if (processedDoc[field] === undefined || processedDoc[field] === null) {
|
|
235
|
+
processedDoc[field] = await this.getNextAutoIncrementValue(options.table, field);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return processedDoc;
|
|
239
|
+
}));
|
|
240
|
+
const result = await collection.insertMany(processedData, { session });
|
|
241
|
+
// Get inserted documents if returning is requested
|
|
242
|
+
let returnedData = [];
|
|
243
|
+
if (options.returning) {
|
|
244
|
+
const insertedIds = Object.values(result.insertedIds);
|
|
245
|
+
returnedData = await collection.find({ _id: { $in: insertedIds } }, { session }).toArray();
|
|
246
|
+
}
|
|
341
247
|
return {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
executionTime,
|
|
346
|
-
success: true,
|
|
248
|
+
data: returnedData,
|
|
249
|
+
count: result.insertedCount,
|
|
250
|
+
insertedIds: Object.values(result.insertedIds),
|
|
347
251
|
};
|
|
348
252
|
}
|
|
349
253
|
catch (error) {
|
|
350
|
-
throw
|
|
254
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
351
255
|
}
|
|
352
256
|
}
|
|
353
|
-
async update(
|
|
354
|
-
|
|
257
|
+
async update(options) {
|
|
258
|
+
var _a;
|
|
259
|
+
this.ensureConnected();
|
|
355
260
|
try {
|
|
356
|
-
const
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
const
|
|
261
|
+
const collection = this.db.collection(options.table);
|
|
262
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
263
|
+
// Build MongoDB filter
|
|
264
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
265
|
+
// Build update document
|
|
266
|
+
const updateDoc = { $set: {} };
|
|
267
|
+
for (const [key, value] of Object.entries(options.data)) {
|
|
268
|
+
if (value && typeof value === 'object' && this.isUpdateOperator(value)) {
|
|
269
|
+
// Handle update operators - MongoDB has native support
|
|
270
|
+
if ('$INC' in value) {
|
|
271
|
+
if (!updateDoc.$inc)
|
|
272
|
+
updateDoc.$inc = {};
|
|
273
|
+
updateDoc.$inc[key] = value.$INC;
|
|
274
|
+
}
|
|
275
|
+
else if ('$DEC' in value) {
|
|
276
|
+
// MongoDB uses $inc with negative value for decrement
|
|
277
|
+
if (!updateDoc.$inc)
|
|
278
|
+
updateDoc.$inc = {};
|
|
279
|
+
updateDoc.$inc[key] = -value.$DEC;
|
|
280
|
+
}
|
|
281
|
+
else if ('$MUL' in value) {
|
|
282
|
+
if (!updateDoc.$mul)
|
|
283
|
+
updateDoc.$mul = {};
|
|
284
|
+
updateDoc.$mul[key] = value.$MUL;
|
|
285
|
+
}
|
|
286
|
+
else if ('$MIN' in value) {
|
|
287
|
+
if (!updateDoc.$min)
|
|
288
|
+
updateDoc.$min = {};
|
|
289
|
+
updateDoc.$min[key] = value.$MIN;
|
|
290
|
+
}
|
|
291
|
+
else if ('$MAX' in value) {
|
|
292
|
+
if (!updateDoc.$max)
|
|
293
|
+
updateDoc.$max = {};
|
|
294
|
+
updateDoc.$max[key] = value.$MAX;
|
|
295
|
+
}
|
|
296
|
+
else if ('$SET' in value) {
|
|
297
|
+
updateDoc.$set[key] = value.$SET;
|
|
298
|
+
}
|
|
299
|
+
else if ('$UNSET' in value && value.$UNSET) {
|
|
300
|
+
if (!updateDoc.$unset)
|
|
301
|
+
updateDoc.$unset = {};
|
|
302
|
+
updateDoc.$unset[key] = '';
|
|
303
|
+
}
|
|
304
|
+
else if ('$PUSH' in value) {
|
|
305
|
+
if (!updateDoc.$push)
|
|
306
|
+
updateDoc.$push = {};
|
|
307
|
+
updateDoc.$push[key] = value.$PUSH;
|
|
308
|
+
}
|
|
309
|
+
else if ('$PULL' in value) {
|
|
310
|
+
if (!updateDoc.$pull)
|
|
311
|
+
updateDoc.$pull = {};
|
|
312
|
+
updateDoc.$pull[key] = value.$PULL;
|
|
313
|
+
}
|
|
314
|
+
else if ('$ADDTOSET' in value) {
|
|
315
|
+
if (!updateDoc.$addToSet)
|
|
316
|
+
updateDoc.$addToSet = {};
|
|
317
|
+
updateDoc.$addToSet[key] = value.$ADDTOSET;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
updateDoc.$set[key] = value;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// Remove empty $set
|
|
325
|
+
if (Object.keys(updateDoc.$set).length === 0) {
|
|
326
|
+
delete updateDoc.$set;
|
|
327
|
+
}
|
|
328
|
+
const result = await collection.updateMany(filter, updateDoc, { session });
|
|
329
|
+
// Get updated documents if returning is requested
|
|
330
|
+
let returnedData = [];
|
|
331
|
+
if (options.returning) {
|
|
332
|
+
returnedData = await collection.find(filter, { session }).toArray();
|
|
333
|
+
}
|
|
362
334
|
return {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
executionTime,
|
|
366
|
-
success: true,
|
|
335
|
+
data: returnedData,
|
|
336
|
+
count: result.modifiedCount,
|
|
367
337
|
};
|
|
368
338
|
}
|
|
369
339
|
catch (error) {
|
|
370
|
-
throw
|
|
340
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
371
341
|
}
|
|
372
342
|
}
|
|
373
|
-
async delete(
|
|
374
|
-
|
|
343
|
+
async delete(options) {
|
|
344
|
+
var _a;
|
|
345
|
+
this.ensureConnected();
|
|
375
346
|
try {
|
|
376
|
-
const
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
347
|
+
const collection = this.db.collection(options.table);
|
|
348
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
349
|
+
// Build MongoDB filter
|
|
350
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
351
|
+
// Get documents before delete if returning is requested
|
|
352
|
+
let deletedData;
|
|
353
|
+
if (options.returning) {
|
|
354
|
+
deletedData = await collection.find(filter, { session }).toArray();
|
|
355
|
+
}
|
|
356
|
+
const result = await collection.deleteMany(filter, { session });
|
|
381
357
|
return {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
success: true,
|
|
358
|
+
count: result.deletedCount,
|
|
359
|
+
data: deletedData,
|
|
385
360
|
};
|
|
386
361
|
}
|
|
387
362
|
catch (error) {
|
|
388
|
-
throw
|
|
363
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
389
364
|
}
|
|
390
365
|
}
|
|
391
|
-
async upsert(
|
|
392
|
-
|
|
366
|
+
async upsert(options) {
|
|
367
|
+
var _a, _b;
|
|
368
|
+
this.ensureConnected();
|
|
393
369
|
try {
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
//
|
|
397
|
-
const data = Array.isArray(options.data) ? options.data[0] : options.data;
|
|
398
|
-
// Build conflict filter
|
|
370
|
+
const collection = this.db.collection(options.table);
|
|
371
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
372
|
+
// Build filter from conflict keys
|
|
399
373
|
const filter = {};
|
|
400
|
-
options.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
374
|
+
for (const key of options.conflictKeys) {
|
|
375
|
+
filter[key] = options.data[key];
|
|
376
|
+
}
|
|
377
|
+
// Build update document
|
|
378
|
+
const updateDoc = { $set: options.data };
|
|
379
|
+
const result = await collection.findOneAndUpdate(filter, updateDoc, {
|
|
380
|
+
upsert: true,
|
|
381
|
+
returnDocument: 'after',
|
|
382
|
+
session,
|
|
404
383
|
});
|
|
405
|
-
const update = { $set: data };
|
|
406
|
-
const result = await collection.updateOne(filter, update, { upsert: true });
|
|
407
|
-
const executionTime = Date.now() - startTime;
|
|
408
384
|
return {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
executionTime,
|
|
413
|
-
success: true,
|
|
385
|
+
data: result.value ? [result.value] : [],
|
|
386
|
+
count: 1,
|
|
387
|
+
operation: ((_b = result.lastErrorObject) === null || _b === void 0 ? void 0 : _b.updatedExisting) ? 'updated' : 'inserted',
|
|
414
388
|
};
|
|
415
389
|
}
|
|
416
390
|
catch (error) {
|
|
417
|
-
throw
|
|
391
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
418
392
|
}
|
|
419
393
|
}
|
|
420
|
-
|
|
421
|
-
|
|
394
|
+
// ==================== AGGREGATION METHODS ====================
|
|
395
|
+
async count(options) {
|
|
396
|
+
var _a, _b;
|
|
397
|
+
this.ensureConnected();
|
|
422
398
|
try {
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
399
|
+
const collection = this.db.collection(options.table);
|
|
400
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
401
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
402
|
+
if (options.distinct && options.column) {
|
|
403
|
+
// For distinct count, use aggregation
|
|
404
|
+
const result = await collection.aggregate([
|
|
405
|
+
{ $match: filter },
|
|
406
|
+
{ $group: { _id: `$${options.column}` } },
|
|
407
|
+
{ $count: 'count' },
|
|
408
|
+
], { session }).toArray();
|
|
409
|
+
return ((_b = result[0]) === null || _b === void 0 ? void 0 : _b.count) || 0;
|
|
410
|
+
}
|
|
411
|
+
return await collection.countDocuments(filter, { session });
|
|
433
412
|
}
|
|
434
413
|
catch (error) {
|
|
435
|
-
throw
|
|
414
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
436
415
|
}
|
|
437
416
|
}
|
|
438
|
-
|
|
439
|
-
|
|
417
|
+
async sum(options) {
|
|
418
|
+
var _a, _b;
|
|
419
|
+
this.ensureConnected();
|
|
440
420
|
try {
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
const filter = this.buildMongoFilter(options.where);
|
|
444
|
-
|
|
421
|
+
const collection = this.db.collection(options.table);
|
|
422
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
423
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
424
|
+
const result = await collection.aggregate([
|
|
425
|
+
{ $match: filter },
|
|
426
|
+
{ $group: { _id: null, sum: { $sum: `$${options.column}` } } },
|
|
427
|
+
], { session }).toArray();
|
|
428
|
+
return ((_b = result[0]) === null || _b === void 0 ? void 0 : _b.sum) || 0;
|
|
445
429
|
}
|
|
446
430
|
catch (error) {
|
|
447
|
-
throw
|
|
431
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
448
432
|
}
|
|
449
433
|
}
|
|
450
|
-
async
|
|
451
|
-
var _a;
|
|
434
|
+
async avg(options) {
|
|
435
|
+
var _a, _b;
|
|
436
|
+
this.ensureConnected();
|
|
452
437
|
try {
|
|
453
|
-
const
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
const
|
|
457
|
-
{ $match:
|
|
458
|
-
{
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
total: { $sum: `$${options.column}` },
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
];
|
|
465
|
-
const result = await collection.aggregate(pipeline).toArray();
|
|
466
|
-
return ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.total) || 0;
|
|
438
|
+
const collection = this.db.collection(options.table);
|
|
439
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
440
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
441
|
+
const result = await collection.aggregate([
|
|
442
|
+
{ $match: filter },
|
|
443
|
+
{ $group: { _id: null, avg: { $avg: `$${options.column}` } } },
|
|
444
|
+
], { session }).toArray();
|
|
445
|
+
return ((_b = result[0]) === null || _b === void 0 ? void 0 : _b.avg) || 0;
|
|
467
446
|
}
|
|
468
447
|
catch (error) {
|
|
469
|
-
throw
|
|
448
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
470
449
|
}
|
|
471
450
|
}
|
|
472
|
-
async
|
|
473
|
-
var _a;
|
|
451
|
+
async min(options) {
|
|
452
|
+
var _a, _b;
|
|
453
|
+
this.ensureConnected();
|
|
474
454
|
try {
|
|
475
|
-
const
|
|
476
|
-
const
|
|
477
|
-
const
|
|
478
|
-
const
|
|
479
|
-
{ $match:
|
|
480
|
-
{
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
average: { $avg: `$${options.column}` },
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
];
|
|
487
|
-
const result = await collection.aggregate(pipeline).toArray();
|
|
488
|
-
return ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.average) || 0;
|
|
455
|
+
const collection = this.db.collection(options.table);
|
|
456
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
457
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
458
|
+
const result = await collection.aggregate([
|
|
459
|
+
{ $match: filter },
|
|
460
|
+
{ $group: { _id: null, min: { $min: `$${options.column}` } } },
|
|
461
|
+
], { session }).toArray();
|
|
462
|
+
return (_b = result[0]) === null || _b === void 0 ? void 0 : _b.min;
|
|
489
463
|
}
|
|
490
464
|
catch (error) {
|
|
491
|
-
throw
|
|
465
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
492
466
|
}
|
|
493
467
|
}
|
|
494
|
-
async
|
|
495
|
-
var _a;
|
|
468
|
+
async max(options) {
|
|
469
|
+
var _a, _b;
|
|
470
|
+
this.ensureConnected();
|
|
496
471
|
try {
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
const
|
|
500
|
-
const
|
|
501
|
-
{ $match:
|
|
502
|
-
{
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
minimum: { $min: `$${options.column}` },
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
|
-
];
|
|
509
|
-
const result = await collection.aggregate(pipeline).toArray();
|
|
510
|
-
return ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.minimum) || 0;
|
|
472
|
+
const collection = this.db.collection(options.table);
|
|
473
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
474
|
+
const filter = this.buildMongoFilter(options.where || {});
|
|
475
|
+
const result = await collection.aggregate([
|
|
476
|
+
{ $match: filter },
|
|
477
|
+
{ $group: { _id: null, max: { $max: `$${options.column}` } } },
|
|
478
|
+
], { session }).toArray();
|
|
479
|
+
return (_b = result[0]) === null || _b === void 0 ? void 0 : _b.max;
|
|
511
480
|
}
|
|
512
481
|
catch (error) {
|
|
513
|
-
throw
|
|
482
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
514
483
|
}
|
|
515
484
|
}
|
|
516
|
-
async
|
|
485
|
+
async aggregate(builtAggregation) {
|
|
517
486
|
var _a;
|
|
487
|
+
this.ensureConnected();
|
|
518
488
|
try {
|
|
519
|
-
const
|
|
520
|
-
const collection = db.collection(options.table);
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
},
|
|
530
|
-
];
|
|
531
|
-
const result = await collection.aggregate(pipeline).toArray();
|
|
532
|
-
return ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.maximum) || 0;
|
|
489
|
+
const options = builtAggregation.options;
|
|
490
|
+
const collection = this.db.collection(options.table);
|
|
491
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
492
|
+
// Use the pre-built pipeline
|
|
493
|
+
const result = await collection.aggregate(builtAggregation.pipeline || [], { session }).toArray();
|
|
494
|
+
// Remove _id from result
|
|
495
|
+
if (result[0]) {
|
|
496
|
+
delete result[0]._id;
|
|
497
|
+
}
|
|
498
|
+
return result[0] || {};
|
|
533
499
|
}
|
|
534
500
|
catch (error) {
|
|
535
|
-
throw
|
|
501
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
536
502
|
}
|
|
537
503
|
}
|
|
538
|
-
async groupBy(
|
|
504
|
+
async groupBy(builtGroupBy) {
|
|
505
|
+
var _a;
|
|
506
|
+
this.ensureConnected();
|
|
539
507
|
try {
|
|
540
|
-
const
|
|
541
|
-
const collection = db.collection(options.table);
|
|
542
|
-
const
|
|
543
|
-
//
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
aggregations[alias] = { $avg: `$${aggObj.$AVG}` };
|
|
561
|
-
}
|
|
562
|
-
else if (aggObj.$MIN !== undefined) {
|
|
563
|
-
aggregations[alias] = { $min: `$${aggObj.$MIN}` };
|
|
564
|
-
}
|
|
565
|
-
else if (aggObj.$MAX !== undefined) {
|
|
566
|
-
aggregations[alias] = { $max: `$${aggObj.$MAX}` };
|
|
567
|
-
}
|
|
568
|
-
else if (aggObj.$ARRAY_AGG !== undefined) {
|
|
569
|
-
aggregations[alias] = { $push: `$${aggObj.$ARRAY_AGG}` };
|
|
508
|
+
const options = builtGroupBy.options;
|
|
509
|
+
const collection = this.db.collection(options.table);
|
|
510
|
+
const session = (_a = options.transaction) === null || _a === void 0 ? void 0 : _a.client;
|
|
511
|
+
// Use the pre-built pipeline
|
|
512
|
+
const results = await collection.aggregate(builtGroupBy.pipeline || [], { session }).toArray();
|
|
513
|
+
return results.map((row) => {
|
|
514
|
+
var _a;
|
|
515
|
+
const group = {};
|
|
516
|
+
const aggregates = {};
|
|
517
|
+
// _id contains the group keys
|
|
518
|
+
if (row._id && typeof row._id === 'object') {
|
|
519
|
+
Object.assign(group, row._id);
|
|
520
|
+
}
|
|
521
|
+
else if (((_a = options.groupBy) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
522
|
+
group[options.groupBy[0]] = row._id;
|
|
523
|
+
}
|
|
524
|
+
// Everything else is aggregates
|
|
525
|
+
for (const key of Object.keys(row)) {
|
|
526
|
+
if (key !== '_id') {
|
|
527
|
+
aggregates[key] = row[key];
|
|
570
528
|
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
pipeline.push({ $sort: sortSpec });
|
|
529
|
+
}
|
|
530
|
+
return { group, aggregates: aggregates };
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
catch (error) {
|
|
534
|
+
throw database_error_1.DatabaseError.fromDatabaseError(error, 'mongodb');
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
// ==================== TRANSACTION METHODS ====================
|
|
538
|
+
async beginTransaction(isolationLevel, readOnly, timeout) {
|
|
539
|
+
this.ensureConnected();
|
|
540
|
+
try {
|
|
541
|
+
const session = this.mongoClient.startSession();
|
|
542
|
+
const id = `mongo_txn_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
543
|
+
const transactionOptions = {};
|
|
544
|
+
// MongoDB supports read concern and write concern instead of isolation levels
|
|
545
|
+
if (isolationLevel === enums_1.IsolationLevel.SERIALIZABLE) {
|
|
546
|
+
transactionOptions.readConcern = { level: 'snapshot' };
|
|
547
|
+
transactionOptions.writeConcern = { w: 'majority' };
|
|
591
548
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
549
|
+
else {
|
|
550
|
+
transactionOptions.readConcern = { level: 'majority' };
|
|
551
|
+
transactionOptions.writeConcern = { w: 'majority' };
|
|
595
552
|
}
|
|
596
|
-
if (
|
|
597
|
-
|
|
553
|
+
if (timeout) {
|
|
554
|
+
transactionOptions.maxCommitTimeMS = timeout;
|
|
598
555
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
556
|
+
session.startTransaction(transactionOptions);
|
|
557
|
+
return {
|
|
558
|
+
id,
|
|
559
|
+
databaseType: 'mongodb',
|
|
560
|
+
isolationLevel: isolationLevel || enums_1.IsolationLevel.READ_COMMITTED,
|
|
561
|
+
readOnly: readOnly || false,
|
|
562
|
+
timeout,
|
|
563
|
+
startedAt: new Date(),
|
|
564
|
+
client: session,
|
|
565
|
+
savepoints: new Map(),
|
|
566
|
+
status: 'active',
|
|
567
|
+
};
|
|
605
568
|
}
|
|
606
569
|
catch (error) {
|
|
607
|
-
throw
|
|
570
|
+
throw database_error_1.DatabaseError.transactionError(`Failed to begin transaction: ${error.message}`, error);
|
|
608
571
|
}
|
|
609
572
|
}
|
|
610
|
-
async
|
|
573
|
+
async commitTransaction(context) {
|
|
611
574
|
try {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
575
|
+
await context.client.commitTransaction();
|
|
576
|
+
await context.client.endSession();
|
|
577
|
+
context.status = 'committed';
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
context.status = 'error';
|
|
581
|
+
await context.client.endSession();
|
|
582
|
+
throw database_error_1.DatabaseError.transactionError(`Failed to commit transaction: ${error.message}`, error);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
async rollbackTransaction(context) {
|
|
586
|
+
try {
|
|
587
|
+
await context.client.abortTransaction();
|
|
588
|
+
await context.client.endSession();
|
|
589
|
+
context.status = 'rolled_back';
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
context.status = 'error';
|
|
593
|
+
await context.client.endSession();
|
|
594
|
+
throw database_error_1.DatabaseError.transactionError(`Failed to rollback transaction: ${error.message}`, error);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
async createSavepoint(context, name) {
|
|
598
|
+
// MongoDB does not support savepoints
|
|
599
|
+
throw new database_error_1.DatabaseError('MongoDB does not support savepoints. Savepoints are only available in PostgreSQL and MySQL.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
600
|
+
}
|
|
601
|
+
async releaseSavepoint(context, savepoint) {
|
|
602
|
+
// MongoDB does not support savepoints
|
|
603
|
+
throw new database_error_1.DatabaseError('MongoDB does not support savepoints. Savepoints are only available in PostgreSQL and MySQL.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
604
|
+
}
|
|
605
|
+
async rollbackToSavepoint(context, savepoint) {
|
|
606
|
+
// MongoDB does not support savepoints
|
|
607
|
+
throw new database_error_1.DatabaseError('MongoDB does not support savepoints. Savepoints are only available in PostgreSQL and MySQL.', enums_1.DatabaseErrorType.NOT_SUPPORTED);
|
|
608
|
+
}
|
|
609
|
+
supportsSavepoints() {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
// ==================== SCHEMA METHODS ====================
|
|
613
|
+
async createTable(definition, options) {
|
|
614
|
+
this.ensureConnected();
|
|
615
|
+
try {
|
|
616
|
+
// In MongoDB, creating a collection is optional as it's created on first insert
|
|
617
|
+
// But we can explicitly create it for validation
|
|
618
|
+
await this.db.createCollection(definition.name);
|
|
619
|
+
// Create indexes
|
|
620
|
+
if (definition.indexes) {
|
|
621
|
+
for (const index of definition.indexes) {
|
|
622
|
+
await this.createIndex(index);
|
|
630
623
|
}
|
|
631
|
-
|
|
632
|
-
|
|
624
|
+
}
|
|
625
|
+
// Create unique constraints as unique indexes and register auto-increment fields
|
|
626
|
+
for (const column of definition.columns) {
|
|
627
|
+
if (column.unique && column.name !== '_id') {
|
|
628
|
+
await this.db.collection(definition.name).createIndex({ [column.name]: 1 }, { unique: true });
|
|
633
629
|
}
|
|
634
|
-
|
|
635
|
-
|
|
630
|
+
// Register auto-increment fields in the counters collection
|
|
631
|
+
if (column.autoIncrement) {
|
|
632
|
+
await this.registerAutoIncrementField(definition.name, column.name);
|
|
636
633
|
}
|
|
637
|
-
});
|
|
638
|
-
// Build group stage
|
|
639
|
-
let groupId = null;
|
|
640
|
-
if (options.groupBy && options.groupBy.length > 0) {
|
|
641
|
-
groupId = {};
|
|
642
|
-
options.groupBy.forEach((col) => {
|
|
643
|
-
groupId[col] = `$${col}`;
|
|
644
|
-
});
|
|
645
634
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
if (options.having) {
|
|
654
|
-
pipeline.push({ $match: this.buildMongoFilter(options.having) });
|
|
635
|
+
// Store schema metadata for default values and other app-level features
|
|
636
|
+
await this.storeSchemaMetadata(definition.name, definition.columns);
|
|
637
|
+
}
|
|
638
|
+
catch (error) {
|
|
639
|
+
// Ignore "collection already exists" error if ifNotExists is true
|
|
640
|
+
if ((options === null || options === void 0 ? void 0 : options.ifNotExists) && error.code === 48) {
|
|
641
|
+
return;
|
|
655
642
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
643
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to create collection: ${error.message}`, error);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Register an auto-increment field in the counters collection.
|
|
648
|
+
* This creates/updates the counter document for the given collection and field.
|
|
649
|
+
*/
|
|
650
|
+
async registerAutoIncrementField(collectionName, fieldName) {
|
|
651
|
+
const countersCollection = this.db.collection('_ductape_counters');
|
|
652
|
+
// Initialize the counter for this collection/field combination
|
|
653
|
+
await countersCollection.updateOne({ _id: `${collectionName}.${fieldName}` }, {
|
|
654
|
+
$setOnInsert: {
|
|
655
|
+
collection: collectionName,
|
|
656
|
+
field: fieldName,
|
|
657
|
+
currentValue: 0
|
|
663
658
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
659
|
+
}, { upsert: true });
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Get the next auto-increment value atomically.
|
|
663
|
+
* Uses findOneAndUpdate with $inc to ensure atomic increment even under high concurrency.
|
|
664
|
+
*/
|
|
665
|
+
async getNextAutoIncrementValue(collectionName, fieldName) {
|
|
666
|
+
const countersCollection = this.db.collection('_ductape_counters');
|
|
667
|
+
const result = await countersCollection.findOneAndUpdate({ _id: `${collectionName}.${fieldName}` }, { $inc: { currentValue: 1 } }, { returnDocument: 'after', upsert: true });
|
|
668
|
+
return result.currentValue;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Get all auto-increment fields for a collection from the counters collection.
|
|
672
|
+
*/
|
|
673
|
+
async getAutoIncrementFields(collectionName) {
|
|
674
|
+
const countersCollection = this.db.collection('_ductape_counters');
|
|
675
|
+
const counters = await countersCollection.find({ collection: collectionName }).toArray();
|
|
676
|
+
return counters.map((c) => c.field);
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Store schema metadata for a collection (including default values).
|
|
680
|
+
* MongoDB doesn't have native schema enforcement, so we store this for application-level use.
|
|
681
|
+
*/
|
|
682
|
+
async storeSchemaMetadata(collectionName, columns) {
|
|
683
|
+
const metadataCollection = this.db.collection('_ductape_schema');
|
|
684
|
+
await metadataCollection.updateOne({ _id: collectionName }, {
|
|
685
|
+
$set: {
|
|
686
|
+
collection: collectionName,
|
|
687
|
+
columns: columns.map(col => ({
|
|
688
|
+
name: col.name,
|
|
689
|
+
type: col.type,
|
|
690
|
+
defaultValue: col.defaultValue,
|
|
691
|
+
nullable: col.nullable,
|
|
692
|
+
unique: col.unique,
|
|
693
|
+
primaryKey: col.primaryKey,
|
|
694
|
+
autoIncrement: col.autoIncrement,
|
|
695
|
+
})),
|
|
696
|
+
updatedAt: new Date()
|
|
668
697
|
}
|
|
698
|
+
}, { upsert: true });
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Get schema metadata for a collection to apply defaults during insert.
|
|
702
|
+
*/
|
|
703
|
+
async getSchemaMetadata(collectionName) {
|
|
704
|
+
const metadataCollection = this.db.collection('_ductape_schema');
|
|
705
|
+
const schema = await metadataCollection.findOne({ _id: collectionName });
|
|
706
|
+
return (schema === null || schema === void 0 ? void 0 : schema.columns) || [];
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Resolve a default value to its actual value.
|
|
710
|
+
* Handles special values like 'now', 'NOW()', true, false, etc.
|
|
711
|
+
*/
|
|
712
|
+
resolveDefaultValue(defaultValue, fieldType) {
|
|
713
|
+
if (defaultValue === undefined || defaultValue === null) {
|
|
714
|
+
return undefined;
|
|
669
715
|
}
|
|
670
|
-
|
|
671
|
-
|
|
716
|
+
// Handle string-based special defaults
|
|
717
|
+
if (typeof defaultValue === 'string') {
|
|
718
|
+
const lowerDefault = defaultValue.toLowerCase();
|
|
719
|
+
// Date/time defaults
|
|
720
|
+
if (lowerDefault === 'now' || lowerDefault === 'now()' || lowerDefault === 'current_timestamp') {
|
|
721
|
+
return new Date();
|
|
722
|
+
}
|
|
723
|
+
// Boolean defaults (for string representations)
|
|
724
|
+
if (lowerDefault === 'true')
|
|
725
|
+
return true;
|
|
726
|
+
if (lowerDefault === 'false')
|
|
727
|
+
return false;
|
|
728
|
+
// UUID defaults
|
|
729
|
+
if (lowerDefault === 'uuid' || lowerDefault === 'uuid()' || lowerDefault === 'gen_random_uuid()') {
|
|
730
|
+
return this.generateUUID();
|
|
731
|
+
}
|
|
672
732
|
}
|
|
733
|
+
// Return as-is for other values (numbers, booleans, objects, etc.)
|
|
734
|
+
return defaultValue;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Generate a UUID v4.
|
|
738
|
+
*/
|
|
739
|
+
generateUUID() {
|
|
740
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
741
|
+
const r = Math.random() * 16 | 0;
|
|
742
|
+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
743
|
+
return v.toString(16);
|
|
744
|
+
});
|
|
673
745
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
746
|
+
async alterTable(tableName, operations) {
|
|
747
|
+
this.ensureConnected();
|
|
748
|
+
// MongoDB is schemaless, so we don't need to alter the schema
|
|
749
|
+
// However, we can handle index and constraint operations
|
|
677
750
|
try {
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
// Create indexes if specified
|
|
682
|
-
if (schema.indexes && schema.indexes.length > 0) {
|
|
683
|
-
const collection = db.collection(schema.name);
|
|
684
|
-
for (const index of schema.indexes) {
|
|
751
|
+
for (const op of operations) {
|
|
752
|
+
if (op.type === 'ADD' && op.constraint && op.constraint.type === 'UNIQUE') {
|
|
753
|
+
// Add unique index
|
|
685
754
|
const indexSpec = {};
|
|
686
|
-
|
|
687
|
-
indexSpec[col
|
|
688
|
-
}
|
|
689
|
-
await collection.createIndex(indexSpec, { unique:
|
|
755
|
+
for (const col of op.constraint.columns) {
|
|
756
|
+
indexSpec[col] = 1;
|
|
757
|
+
}
|
|
758
|
+
await this.db.collection(tableName).createIndex(indexSpec, { unique: true });
|
|
759
|
+
}
|
|
760
|
+
else if (op.type === 'DROP' && op.constraintName) {
|
|
761
|
+
// Drop index
|
|
762
|
+
await this.db.collection(tableName).dropIndex(op.constraintName);
|
|
763
|
+
}
|
|
764
|
+
else if (op.type === 'RENAME' && op.oldName && op.newName) {
|
|
765
|
+
// Rename field in all documents
|
|
766
|
+
await this.db.collection(tableName).updateMany({}, { $rename: { [op.oldName]: op.newName } });
|
|
690
767
|
}
|
|
691
768
|
}
|
|
692
|
-
const executionTime = Date.now() - startTime;
|
|
693
|
-
return {
|
|
694
|
-
success: true,
|
|
695
|
-
operation: 'create',
|
|
696
|
-
table: schema.name,
|
|
697
|
-
executionTime,
|
|
698
|
-
};
|
|
699
769
|
}
|
|
700
770
|
catch (error) {
|
|
701
|
-
|
|
702
|
-
success: false,
|
|
703
|
-
operation: 'create',
|
|
704
|
-
table: schema.name,
|
|
705
|
-
error: error.message,
|
|
706
|
-
executionTime: Date.now() - startTime,
|
|
707
|
-
};
|
|
771
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to alter collection: ${error.message}`, error);
|
|
708
772
|
}
|
|
709
773
|
}
|
|
710
|
-
async dropTable(
|
|
711
|
-
|
|
774
|
+
async dropTable(tableName, ifExists, cascade) {
|
|
775
|
+
this.ensureConnected();
|
|
712
776
|
try {
|
|
713
|
-
|
|
714
|
-
await db.dropCollection(tableName);
|
|
715
|
-
return {
|
|
716
|
-
success: true,
|
|
717
|
-
operation: 'drop',
|
|
718
|
-
table: tableName,
|
|
719
|
-
executionTime: Date.now() - startTime,
|
|
720
|
-
};
|
|
777
|
+
await this.db.collection(tableName).drop();
|
|
721
778
|
}
|
|
722
779
|
catch (error) {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
executionTime: Date.now() - startTime,
|
|
729
|
-
};
|
|
780
|
+
// Ignore "collection doesn't exist" error if ifExists is true
|
|
781
|
+
if (ifExists && error.code === 26) {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to drop collection: ${error.message}`, error);
|
|
730
785
|
}
|
|
731
786
|
}
|
|
732
|
-
async
|
|
733
|
-
|
|
734
|
-
// Schema changes happen implicitly when documents are inserted
|
|
735
|
-
return {
|
|
736
|
-
success: true,
|
|
737
|
-
operation: 'alter',
|
|
738
|
-
table: tableName,
|
|
739
|
-
executionTime: 0,
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
async getTableSchema(connection, tableName) {
|
|
787
|
+
async listTables() {
|
|
788
|
+
this.ensureConnected();
|
|
743
789
|
try {
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
// Get a sample document to infer schema
|
|
747
|
-
const sampleDoc = await collection.findOne({});
|
|
748
|
-
// TODO: Infer column definitions from sample document
|
|
749
|
-
// This is a simplified implementation
|
|
750
|
-
const columns = sampleDoc
|
|
751
|
-
? Object.keys(sampleDoc).map((key) => ({
|
|
752
|
-
name: key,
|
|
753
|
-
type: typeof sampleDoc[key],
|
|
754
|
-
}))
|
|
755
|
-
: [];
|
|
756
|
-
return {
|
|
757
|
-
name: tableName,
|
|
758
|
-
columns,
|
|
759
|
-
};
|
|
790
|
+
const collections = await this.db.listCollections().toArray();
|
|
791
|
+
return collections.map((c) => c.name);
|
|
760
792
|
}
|
|
761
793
|
catch (error) {
|
|
762
|
-
throw
|
|
794
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to list collections: ${error.message}`, error);
|
|
763
795
|
}
|
|
764
796
|
}
|
|
765
|
-
async
|
|
797
|
+
async tableExists(tableName) {
|
|
798
|
+
this.ensureConnected();
|
|
766
799
|
try {
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
return collections.map((col) => col.name);
|
|
800
|
+
const collections = await this.db.listCollections({ name: tableName }).toArray();
|
|
801
|
+
return collections.length > 0;
|
|
770
802
|
}
|
|
771
803
|
catch (error) {
|
|
772
|
-
throw
|
|
804
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to check collection existence: ${error.message}`, error);
|
|
773
805
|
}
|
|
774
806
|
}
|
|
775
|
-
async
|
|
807
|
+
async getTableSchema(tableName) {
|
|
808
|
+
this.ensureConnected();
|
|
776
809
|
try {
|
|
777
|
-
const
|
|
778
|
-
|
|
810
|
+
const collection = this.db.collection(tableName);
|
|
811
|
+
// Sample documents to infer schema
|
|
812
|
+
const sampleDocs = await collection.find().limit(100).toArray();
|
|
813
|
+
// Infer columns from sample documents
|
|
814
|
+
const fieldTypes = new Map();
|
|
815
|
+
for (const doc of sampleDocs) {
|
|
816
|
+
this.extractFieldTypes(doc, '', fieldTypes);
|
|
817
|
+
}
|
|
818
|
+
const columns = Array.from(fieldTypes.entries()).map(([name, types]) => ({
|
|
819
|
+
name,
|
|
820
|
+
type: Array.from(types).join('|'),
|
|
821
|
+
nullable: true, // MongoDB is schemaless
|
|
822
|
+
isPrimaryKey: name === '_id',
|
|
823
|
+
isUnique: name === '_id',
|
|
824
|
+
isAutoIncrement: false,
|
|
825
|
+
}));
|
|
826
|
+
// Get indexes
|
|
827
|
+
const indexes = await this.listIndexes(tableName);
|
|
828
|
+
// Get estimated document count
|
|
829
|
+
const estimatedCount = await collection.estimatedDocumentCount();
|
|
830
|
+
return {
|
|
831
|
+
name: tableName,
|
|
832
|
+
columns,
|
|
833
|
+
indexes,
|
|
834
|
+
constraints: [],
|
|
835
|
+
primaryKey: ['_id'],
|
|
836
|
+
estimatedRowCount: estimatedCount,
|
|
837
|
+
};
|
|
779
838
|
}
|
|
780
839
|
catch (error) {
|
|
781
|
-
|
|
840
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to get collection schema: ${error.message}`, error);
|
|
782
841
|
}
|
|
783
842
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
const startTime = Date.now();
|
|
843
|
+
async createIndex(index, ifNotExists, concurrent) {
|
|
844
|
+
this.ensureConnected();
|
|
787
845
|
try {
|
|
788
|
-
const
|
|
789
|
-
|
|
846
|
+
const collection = this.db.collection(index.table);
|
|
847
|
+
// Build index specification
|
|
790
848
|
const indexSpec = {};
|
|
791
|
-
|
|
849
|
+
for (const col of index.columns) {
|
|
792
850
|
indexSpec[col.name] = col.order === 'DESC' ? -1 : 1;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
success: true,
|
|
800
|
-
operation: 'create',
|
|
801
|
-
indexName: options.index.name,
|
|
802
|
-
table: options.table,
|
|
803
|
-
executionTime: Date.now() - startTime,
|
|
851
|
+
}
|
|
852
|
+
// Build index options
|
|
853
|
+
const indexOptions = {
|
|
854
|
+
name: index.name,
|
|
855
|
+
unique: index.unique || false,
|
|
856
|
+
background: true, // Always create in background
|
|
804
857
|
};
|
|
858
|
+
// Partial index
|
|
859
|
+
if (index.where) {
|
|
860
|
+
// Parse the where clause to a MongoDB filter
|
|
861
|
+
// This is simplified - a real implementation would parse the expression
|
|
862
|
+
indexOptions.partialFilterExpression = {};
|
|
863
|
+
}
|
|
864
|
+
await collection.createIndex(indexSpec, indexOptions);
|
|
805
865
|
}
|
|
806
866
|
catch (error) {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
error: error.message,
|
|
813
|
-
executionTime: Date.now() - startTime,
|
|
814
|
-
};
|
|
867
|
+
// Ignore if index already exists and ifNotExists is true
|
|
868
|
+
if (ifNotExists && error.code === 85) {
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to create index: ${error.message}`, error);
|
|
815
872
|
}
|
|
816
873
|
}
|
|
817
|
-
async dropIndex(
|
|
818
|
-
|
|
874
|
+
async dropIndex(tableName, indexName, ifExists, concurrent, cascade) {
|
|
875
|
+
this.ensureConnected();
|
|
819
876
|
try {
|
|
820
|
-
|
|
821
|
-
const collection = db.collection(options.table);
|
|
822
|
-
await collection.dropIndex(options.indexName);
|
|
823
|
-
return {
|
|
824
|
-
success: true,
|
|
825
|
-
operation: 'drop',
|
|
826
|
-
indexName: options.indexName,
|
|
827
|
-
table: options.table,
|
|
828
|
-
executionTime: Date.now() - startTime,
|
|
829
|
-
};
|
|
877
|
+
await this.db.collection(tableName).dropIndex(indexName);
|
|
830
878
|
}
|
|
831
879
|
catch (error) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
error: error.message,
|
|
838
|
-
executionTime: Date.now() - startTime,
|
|
839
|
-
};
|
|
880
|
+
// Ignore if index doesn't exist and ifExists is true
|
|
881
|
+
if (ifExists && error.code === 27) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to drop index: ${error.message}`, error);
|
|
840
885
|
}
|
|
841
886
|
}
|
|
842
|
-
async listIndexes(
|
|
887
|
+
async listIndexes(tableName, includeSystem) {
|
|
888
|
+
this.ensureConnected();
|
|
843
889
|
try {
|
|
844
|
-
const
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
890
|
+
const collection = this.db.collection(tableName);
|
|
891
|
+
const indexes = await collection.indexes();
|
|
892
|
+
return indexes
|
|
893
|
+
.filter((idx) => includeSystem || idx.name !== '_id_')
|
|
894
|
+
.map((idx) => ({
|
|
895
|
+
name: idx.name,
|
|
896
|
+
table: tableName,
|
|
897
|
+
columns: Object.keys(idx.key),
|
|
898
|
+
unique: idx.unique || false,
|
|
899
|
+
primaryKey: idx.name === '_id_',
|
|
900
|
+
type: 'BTREE', // MongoDB uses B-tree by default
|
|
853
901
|
}));
|
|
854
902
|
}
|
|
855
903
|
catch (error) {
|
|
856
|
-
throw
|
|
904
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to list indexes: ${error.message}`, error);
|
|
857
905
|
}
|
|
858
906
|
}
|
|
859
|
-
async getIndexStatistics(
|
|
907
|
+
async getIndexStatistics(tableName, indexName) {
|
|
908
|
+
var _a, _b;
|
|
909
|
+
this.ensureConnected();
|
|
860
910
|
try {
|
|
861
|
-
const
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
911
|
+
const collection = this.db.collection(tableName);
|
|
912
|
+
const stats = await collection.aggregate([
|
|
913
|
+
{ $collStats: { storageStats: {} } },
|
|
914
|
+
]).toArray();
|
|
915
|
+
const indexStats = ((_b = (_a = stats[0]) === null || _a === void 0 ? void 0 : _a.storageStats) === null || _b === void 0 ? void 0 : _b.indexSizes) || {};
|
|
916
|
+
const results = [];
|
|
917
|
+
for (const [name, size] of Object.entries(indexStats)) {
|
|
918
|
+
if (indexName && name !== indexName)
|
|
919
|
+
continue;
|
|
920
|
+
results.push({
|
|
921
|
+
indexName: name,
|
|
922
|
+
tableName,
|
|
923
|
+
scans: 0, // MongoDB doesn't expose this easily
|
|
924
|
+
tuplesRead: 0,
|
|
925
|
+
sizeBytes: size,
|
|
926
|
+
sizeFormatted: this.formatBytes(size),
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
return results;
|
|
867
930
|
}
|
|
868
931
|
catch (error) {
|
|
869
|
-
throw
|
|
932
|
+
throw database_error_1.DatabaseError.schemaError(`Failed to get index statistics: ${error.message}`, error);
|
|
870
933
|
}
|
|
871
934
|
}
|
|
872
|
-
// ====================
|
|
873
|
-
|
|
874
|
-
//
|
|
875
|
-
|
|
876
|
-
}
|
|
877
|
-
async rollbackMigration(connection, migration, options) {
|
|
878
|
-
// TODO: Implement rollback logic
|
|
879
|
-
throw new database_types_1.DatabaseError(database_types_1.DatabaseErrorType.MIGRATION_ERROR, 'MongoDB migration rollback not implemented yet');
|
|
935
|
+
// ==================== UTILITY METHODS ====================
|
|
936
|
+
escapeIdentifier(identifier) {
|
|
937
|
+
// MongoDB doesn't need identifier escaping in the same way SQL databases do
|
|
938
|
+
return identifier;
|
|
880
939
|
}
|
|
881
|
-
|
|
882
|
-
//
|
|
883
|
-
return
|
|
940
|
+
escapeValue(value) {
|
|
941
|
+
// MongoDB uses BSON, no escaping needed
|
|
942
|
+
return JSON.stringify(value);
|
|
884
943
|
}
|
|
885
|
-
// ==================== Helper Methods ====================
|
|
886
944
|
/**
|
|
887
|
-
*
|
|
888
|
-
* Supports both simplified syntax (GT, LT, AND, OR, etc.) and legacy $ prefix operators
|
|
945
|
+
* Check if value is an update operator object
|
|
889
946
|
*/
|
|
890
|
-
|
|
891
|
-
if (!
|
|
892
|
-
return
|
|
947
|
+
isUpdateOperator(value) {
|
|
948
|
+
if (!value || typeof value !== 'object')
|
|
949
|
+
return false;
|
|
950
|
+
const operators = ['$INC', '$DEC', '$MUL', '$MIN', '$MAX', '$SET', '$UNSET', '$PUSH', '$PULL', '$ADDTOSET'];
|
|
951
|
+
return operators.some(op => op in value);
|
|
952
|
+
}
|
|
953
|
+
getParameterPlaceholder(index) {
|
|
954
|
+
// MongoDB doesn't use parameter placeholders like SQL
|
|
955
|
+
return '';
|
|
956
|
+
}
|
|
957
|
+
getColumnTypeString(columnType, options) {
|
|
958
|
+
// MongoDB is schemaless, but we can map to BSON types
|
|
959
|
+
const typeMap = {
|
|
960
|
+
[enums_1.ColumnType.INTEGER]: 'int',
|
|
961
|
+
[enums_1.ColumnType.BIGINT]: 'long',
|
|
962
|
+
[enums_1.ColumnType.FLOAT]: 'double',
|
|
963
|
+
[enums_1.ColumnType.DOUBLE]: 'double',
|
|
964
|
+
[enums_1.ColumnType.DECIMAL]: 'decimal',
|
|
965
|
+
[enums_1.ColumnType.STRING]: 'string',
|
|
966
|
+
[enums_1.ColumnType.TEXT]: 'string',
|
|
967
|
+
[enums_1.ColumnType.BOOLEAN]: 'bool',
|
|
968
|
+
[enums_1.ColumnType.DATE]: 'date',
|
|
969
|
+
[enums_1.ColumnType.DATETIME]: 'date',
|
|
970
|
+
[enums_1.ColumnType.TIMESTAMP]: 'date',
|
|
971
|
+
[enums_1.ColumnType.JSON]: 'object',
|
|
972
|
+
[enums_1.ColumnType.JSONB]: 'object',
|
|
973
|
+
[enums_1.ColumnType.UUID]: 'string',
|
|
974
|
+
[enums_1.ColumnType.BINARY]: 'binData',
|
|
975
|
+
[enums_1.ColumnType.ARRAY]: 'array',
|
|
976
|
+
};
|
|
977
|
+
return typeMap[columnType] || columnType;
|
|
978
|
+
}
|
|
979
|
+
getSupportedFeatures() {
|
|
980
|
+
return [
|
|
981
|
+
base_adapter_1.DatabaseFeature.TRANSACTIONS,
|
|
982
|
+
base_adapter_1.DatabaseFeature.JSON,
|
|
983
|
+
base_adapter_1.DatabaseFeature.ARRAYS,
|
|
984
|
+
base_adapter_1.DatabaseFeature.TTL,
|
|
985
|
+
base_adapter_1.DatabaseFeature.CHANGE_STREAMS,
|
|
986
|
+
base_adapter_1.DatabaseFeature.SECONDARY_INDEXES,
|
|
987
|
+
base_adapter_1.DatabaseFeature.AGGREGATION_PIPELINE,
|
|
988
|
+
base_adapter_1.DatabaseFeature.ATOMIC_COUNTERS,
|
|
989
|
+
base_adapter_1.DatabaseFeature.BATCH_OPERATIONS,
|
|
990
|
+
base_adapter_1.DatabaseFeature.REGEX,
|
|
991
|
+
];
|
|
992
|
+
}
|
|
993
|
+
parseError(error) {
|
|
994
|
+
const code = error.code;
|
|
995
|
+
let type = enums_1.DatabaseErrorType.UNKNOWN_ERROR;
|
|
996
|
+
// Map MongoDB error codes
|
|
997
|
+
switch (code) {
|
|
998
|
+
case 11000: // Duplicate key
|
|
999
|
+
type = enums_1.DatabaseErrorType.UNIQUE_VIOLATION;
|
|
1000
|
+
break;
|
|
1001
|
+
case 18: // Authentication failed
|
|
1002
|
+
type = enums_1.DatabaseErrorType.AUTHENTICATION_ERROR;
|
|
1003
|
+
break;
|
|
1004
|
+
case 26: // Namespace not found
|
|
1005
|
+
type = enums_1.DatabaseErrorType.NOT_FOUND;
|
|
1006
|
+
break;
|
|
1007
|
+
case 48: // Namespace already exists
|
|
1008
|
+
type = enums_1.DatabaseErrorType.SCHEMA_ERROR;
|
|
1009
|
+
break;
|
|
1010
|
+
default:
|
|
1011
|
+
if (error.name === 'MongoNetworkError') {
|
|
1012
|
+
type = enums_1.DatabaseErrorType.CONNECTION_ERROR;
|
|
1013
|
+
}
|
|
893
1014
|
}
|
|
894
|
-
|
|
895
|
-
|
|
1015
|
+
return {
|
|
1016
|
+
type,
|
|
1017
|
+
message: error.message || 'Unknown database error',
|
|
1018
|
+
code: String(code),
|
|
1019
|
+
details: {
|
|
1020
|
+
codeName: error.codeName,
|
|
1021
|
+
keyPattern: error.keyPattern,
|
|
1022
|
+
keyValue: error.keyValue,
|
|
1023
|
+
},
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
// ==================== PRIVATE HELPER METHODS ====================
|
|
1027
|
+
ensureConnected() {
|
|
1028
|
+
if (!this.connected || !this.db) {
|
|
1029
|
+
throw new database_error_1.DatabaseError('Not connected to MongoDB database', enums_1.DatabaseErrorType.CONNECTION_ERROR);
|
|
896
1030
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1031
|
+
}
|
|
1032
|
+
buildMongoFilter(where) {
|
|
1033
|
+
const filter = {};
|
|
1034
|
+
for (const [key, value] of Object.entries(where)) {
|
|
1035
|
+
if (key === '$AND') {
|
|
1036
|
+
filter.$and = Object.entries(value).map(([k, v]) => this.buildMongoFilter({ [k]: v }));
|
|
900
1037
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const andConditions = condition.$AND || condition.AND || condition.$and;
|
|
904
|
-
if (typeof andConditions === 'object' && !Array.isArray(andConditions)) {
|
|
905
|
-
// New syntax: { $AND: { col1: val1, col2: val2 } }
|
|
906
|
-
return buildCondition(andConditions);
|
|
907
|
-
}
|
|
908
|
-
else {
|
|
909
|
-
// Array syntax: { $AND: [cond1, cond2] }
|
|
910
|
-
return { $and: andConditions.map(buildCondition) };
|
|
911
|
-
}
|
|
1038
|
+
else if (key === '$OR') {
|
|
1039
|
+
filter.$or = Object.entries(value).map(([k, v]) => this.buildMongoFilter({ [k]: v }));
|
|
912
1040
|
}
|
|
913
|
-
if (
|
|
914
|
-
|
|
915
|
-
if (typeof orConditions === 'object' && !Array.isArray(orConditions)) {
|
|
916
|
-
// New syntax: { $OR: { col1: val1, col2: val2 } }
|
|
917
|
-
const subConditions = [];
|
|
918
|
-
for (const [key, value] of Object.entries(orConditions)) {
|
|
919
|
-
if (key === '$AND' || key === 'AND' || key === '$and' || key === '$OR' || key === 'OR' || key === '$or') {
|
|
920
|
-
subConditions.push(buildCondition({ [key]: value }));
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
subConditions.push(buildCondition({ [key]: value }));
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
return { $or: subConditions };
|
|
927
|
-
}
|
|
928
|
-
else {
|
|
929
|
-
// Array syntax: { $OR: [cond1, cond2] }
|
|
930
|
-
return { $or: orConditions.map(buildCondition) };
|
|
931
|
-
}
|
|
1041
|
+
else if (key === '$NOT') {
|
|
1042
|
+
filter.$nor = [this.buildMongoFilter(value)];
|
|
932
1043
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
case
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1044
|
+
else if (value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Date)) {
|
|
1045
|
+
// Handle operators
|
|
1046
|
+
const fieldFilter = {};
|
|
1047
|
+
for (const [op, opValue] of Object.entries(value)) {
|
|
1048
|
+
switch (op) {
|
|
1049
|
+
case '$EQ':
|
|
1050
|
+
fieldFilter.$eq = opValue;
|
|
1051
|
+
break;
|
|
1052
|
+
case '$NE':
|
|
1053
|
+
case '$NOT':
|
|
1054
|
+
fieldFilter.$ne = opValue;
|
|
1055
|
+
break;
|
|
1056
|
+
case '$GT':
|
|
1057
|
+
fieldFilter.$gt = opValue;
|
|
1058
|
+
break;
|
|
1059
|
+
case '$GTE':
|
|
1060
|
+
fieldFilter.$gte = opValue;
|
|
1061
|
+
break;
|
|
1062
|
+
case '$LT':
|
|
1063
|
+
fieldFilter.$lt = opValue;
|
|
1064
|
+
break;
|
|
1065
|
+
case '$LTE':
|
|
1066
|
+
fieldFilter.$lte = opValue;
|
|
1067
|
+
break;
|
|
1068
|
+
case '$IN':
|
|
1069
|
+
fieldFilter.$in = opValue;
|
|
1070
|
+
break;
|
|
1071
|
+
case '$NOT_IN':
|
|
1072
|
+
fieldFilter.$nin = opValue;
|
|
1073
|
+
break;
|
|
1074
|
+
case '$LIKE':
|
|
1075
|
+
// Convert SQL LIKE pattern to regex (case-sensitive)
|
|
1076
|
+
// 1. Escape regex special characters first (except % and _)
|
|
1077
|
+
// 2. Replace SQL wildcards with regex equivalents
|
|
1078
|
+
// 3. Anchor pattern to match full string
|
|
1079
|
+
const likePattern = '^' + opValue
|
|
1080
|
+
.replace(/[.*+?^${}()|[\]\\]/g, (char) => {
|
|
1081
|
+
// Don't escape % and _ - they are SQL wildcards
|
|
1082
|
+
if (char === '%' || char === '_')
|
|
1083
|
+
return char;
|
|
1084
|
+
return '\\' + char;
|
|
1085
|
+
})
|
|
1086
|
+
.replace(/%/g, '.*')
|
|
1087
|
+
.replace(/_/g, '.') + '$';
|
|
1088
|
+
fieldFilter.$regex = new RegExp(likePattern);
|
|
1089
|
+
break;
|
|
1090
|
+
case '$ILIKE':
|
|
1091
|
+
// Convert SQL ILIKE pattern to regex (case-insensitive)
|
|
1092
|
+
const ilikePattern = '^' + opValue
|
|
1093
|
+
.replace(/[.*+?^${}()|[\]\\]/g, (char) => {
|
|
1094
|
+
if (char === '%' || char === '_')
|
|
1095
|
+
return char;
|
|
1096
|
+
return '\\' + char;
|
|
1097
|
+
})
|
|
1098
|
+
.replace(/%/g, '.*')
|
|
1099
|
+
.replace(/_/g, '.') + '$';
|
|
1100
|
+
fieldFilter.$regex = new RegExp(ilikePattern, 'i');
|
|
1101
|
+
break;
|
|
1102
|
+
case '$IS_NULL':
|
|
1103
|
+
if (opValue) {
|
|
1104
|
+
fieldFilter.$eq = null;
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
fieldFilter.$ne = null;
|
|
1108
|
+
}
|
|
1109
|
+
break;
|
|
1110
|
+
case '$IS_NOT_NULL':
|
|
1111
|
+
if (opValue) {
|
|
1112
|
+
fieldFilter.$ne = null;
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
fieldFilter.$eq = null;
|
|
1116
|
+
}
|
|
1117
|
+
break;
|
|
1118
|
+
case '$BETWEEN':
|
|
1119
|
+
const [min, max] = opValue;
|
|
1120
|
+
fieldFilter.$gte = min;
|
|
1121
|
+
fieldFilter.$lte = max;
|
|
1122
|
+
break;
|
|
1123
|
+
case '$CONTAINS':
|
|
1124
|
+
fieldFilter.$elemMatch = { $eq: opValue };
|
|
1125
|
+
break;
|
|
1126
|
+
case '$OVERLAPS':
|
|
1127
|
+
fieldFilter.$elemMatch = { $in: opValue };
|
|
1128
|
+
break;
|
|
1016
1129
|
}
|
|
1017
|
-
filter[key] = operators;
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
// Simple equality
|
|
1021
|
-
filter[key] = value;
|
|
1022
1130
|
}
|
|
1131
|
+
filter[key] = fieldFilter;
|
|
1023
1132
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1133
|
+
else {
|
|
1134
|
+
// Simple equality
|
|
1135
|
+
filter[key] = value;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return filter;
|
|
1027
1139
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1140
|
+
extractFieldTypes(obj, prefix, fieldTypes) {
|
|
1141
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1142
|
+
const fieldName = prefix ? `${prefix}.${key}` : key;
|
|
1143
|
+
const type = this.getJsType(value);
|
|
1144
|
+
if (!fieldTypes.has(fieldName)) {
|
|
1145
|
+
fieldTypes.set(fieldName, new Set());
|
|
1146
|
+
}
|
|
1147
|
+
fieldTypes.get(fieldName).add(type);
|
|
1148
|
+
// Recurse into nested objects (but not arrays)
|
|
1149
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Date)) {
|
|
1150
|
+
this.extractFieldTypes(value, fieldName, fieldTypes);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1036
1153
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
*/
|
|
1040
|
-
escapeValue(value) {
|
|
1041
|
-
// MongoDB uses BSON, not SQL, so escaping is different
|
|
1042
|
-
// This is mainly for display/logging purposes
|
|
1043
|
-
if (value === null || value === undefined) {
|
|
1154
|
+
getJsType(value) {
|
|
1155
|
+
if (value === null)
|
|
1044
1156
|
return 'null';
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
if (value
|
|
1050
|
-
return
|
|
1051
|
-
|
|
1052
|
-
if (typeof value === 'object') {
|
|
1053
|
-
return JSON.stringify(value);
|
|
1054
|
-
}
|
|
1055
|
-
return String(value);
|
|
1157
|
+
if (Array.isArray(value))
|
|
1158
|
+
return 'array';
|
|
1159
|
+
if (value instanceof Date)
|
|
1160
|
+
return 'date';
|
|
1161
|
+
if (value && value._bsontype === 'ObjectId')
|
|
1162
|
+
return 'ObjectId';
|
|
1163
|
+
return typeof value;
|
|
1056
1164
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
return info.version || 'Unknown';
|
|
1065
|
-
}
|
|
1066
|
-
catch (error) {
|
|
1067
|
-
return 'Unknown';
|
|
1068
|
-
}
|
|
1165
|
+
formatBytes(bytes) {
|
|
1166
|
+
if (bytes === 0)
|
|
1167
|
+
return '0 B';
|
|
1168
|
+
const k = 1024;
|
|
1169
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
1170
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1171
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
1069
1172
|
}
|
|
1070
1173
|
}
|
|
1071
1174
|
exports.MongoDBAdapter = MongoDBAdapter;
|