@ductape/sdk 0.0.4-v51 → 0.0.4-v53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/agent-context.d.ts +98 -0
- package/dist/agents/agent-context.js +588 -0
- package/dist/agents/agent-context.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +180 -0
- package/dist/agents/agent-executor.js +715 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/agents.service.d.ts +304 -0
- package/dist/agents/agents.service.js +1244 -0
- package/dist/agents/agents.service.js.map +1 -0
- package/dist/agents/index.d.ts +55 -0
- package/dist/agents/index.js +110 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/memory-manager.d.ts +182 -0
- package/dist/agents/memory-manager.js +383 -0
- package/dist/agents/memory-manager.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +141 -0
- package/dist/agents/tool-registry.js +355 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/agents/types/agents.types.d.ts +1225 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.js +4 -5
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +322 -0
- package/dist/api/services/processorApi.service.js +252 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +69 -1
- package/dist/api/services/productsApi.service.js +67 -31
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +38 -0
- package/dist/api/services/secretsApi.service.js +96 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/userApi.service.js +0 -1
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +183 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.js +0 -1
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +57 -0
- package/dist/api/urls.js +68 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.js +4 -10
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +0 -10
- package/dist/apps/services/app.service.js +74 -30
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +405 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +257 -0
- package/dist/brokers/brokers.service.js +604 -0
- package/dist/brokers/brokers.service.js.map +1 -0
- package/dist/brokers/index.d.ts +46 -0
- package/dist/brokers/index.js +83 -0
- package/dist/brokers/index.js.map +1 -0
- package/dist/brokers/types/index.d.ts +288 -0
- package/dist/brokers/types/index.js +8 -0
- package/dist/brokers/types/index.js.map +1 -0
- package/dist/brokers/utils/broker.util.d.ts +33 -0
- package/dist/brokers/utils/broker.util.js +125 -0
- package/dist/brokers/utils/broker.util.js.map +1 -0
- package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
- package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
- package/dist/brokers/utils/providers/index.d.ts +6 -0
- package/dist/brokers/utils/providers/index.js +16 -0
- package/dist/brokers/utils/providers/index.js.map +1 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +16 -0
- package/dist/brokers/utils/providers/kafka.service.js +52 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +14 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
- package/dist/brokers/utils/providers/redis.service.js +93 -0
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +159 -0
- package/dist/cache/cache.manager.js +265 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +186 -0
- package/dist/cache/cache.service.js +437 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +79 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +106 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +307 -90
- package/dist/database/adapters/base.adapter.js +139 -20
- package/dist/database/adapters/base.adapter.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
- package/dist/database/adapters/cassandra.adapter.js +1019 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
- package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +105 -57
- package/dist/database/adapters/mongodb.adapter.js +941 -838
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +76 -138
- package/dist/database/adapters/mysql.adapter.js +990 -1246
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
- package/dist/database/adapters/postgresql.adapter.js +1076 -1346
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +1374 -0
- package/dist/database/databases.service.js +2680 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +41 -13
- package/dist/database/index.js +97 -86
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +132 -0
- package/dist/database/migrations/migration-engine.js +1356 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +64 -0
- package/dist/database/operators/aggregation-builder.js +746 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +55 -0
- package/dist/database/operators/query-builder.js +365 -0
- package/dist/database/operators/query-builder.js.map +1 -0
- package/dist/database/presave/decrypt.d.ts +25 -0
- package/dist/database/presave/decrypt.js +146 -0
- package/dist/database/presave/decrypt.js.map +1 -0
- package/dist/database/presave/index.d.ts +9 -0
- package/dist/database/presave/index.js +18 -0
- package/dist/database/presave/index.js.map +1 -0
- package/dist/database/presave/presave-processor.d.ts +148 -0
- package/dist/database/presave/presave-processor.js +702 -0
- package/dist/database/presave/presave-processor.js.map +1 -0
- package/dist/database/schema/index.d.ts +7 -0
- package/dist/database/schema/index.js +13 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/database/schema/schema-manager.d.ts +258 -0
- package/dist/database/schema/schema-manager.js +637 -0
- package/dist/database/schema/schema-manager.js.map +1 -0
- package/dist/database/transactions/index.d.ts +6 -0
- package/dist/database/transactions/index.js +13 -0
- package/dist/database/transactions/index.js.map +1 -0
- package/dist/database/transactions/transaction-manager.d.ts +113 -0
- package/dist/database/transactions/transaction-manager.js +344 -0
- package/dist/database/transactions/transaction-manager.js.map +1 -0
- package/dist/database/triggers/index.d.ts +7 -0
- package/dist/database/triggers/index.js +14 -0
- package/dist/database/triggers/index.js.map +1 -0
- package/dist/database/triggers/trigger-processor.d.ts +239 -0
- package/dist/database/triggers/trigger-processor.js +1034 -0
- package/dist/database/triggers/trigger-processor.js.map +1 -0
- package/dist/database/types/action.interface.d.ts +148 -0
- package/dist/database/types/action.interface.js +6 -0
- package/dist/database/types/action.interface.js.map +1 -0
- package/dist/database/types/aggregation.interface.d.ts +179 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/enums.d.ts +195 -0
- package/dist/database/types/enums.js +244 -0
- package/dist/database/types/enums.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -10
- package/dist/database/types/index.js +26 -32
- package/dist/database/types/index.js.map +1 -1
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +199 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +398 -0
- package/dist/database/types/schema.interface.js +6 -0
- package/dist/database/types/schema.interface.js.map +1 -0
- package/dist/database/types/transaction.interface.d.ts +84 -0
- package/dist/database/types/transaction.interface.js +6 -0
- package/dist/database/types/transaction.interface.js.map +1 -0
- package/dist/database/types/trigger.interface.d.ts +612 -0
- package/dist/database/types/trigger.interface.js +121 -0
- package/dist/database/types/trigger.interface.js.map +1 -0
- package/dist/database/types/write.interface.d.ts +208 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +78 -72
- package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/base.adapter.d.ts +135 -118
- package/dist/graph/adapters/base.adapter.js +46 -20
- package/dist/graph/adapters/base.adapter.js.map +1 -1
- package/dist/graph/adapters/index.d.ts +5 -4
- package/dist/graph/adapters/index.js +6 -8
- package/dist/graph/adapters/index.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
- package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
- package/dist/graph/adapters/neo4j.adapter.js +912 -1605
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
- package/dist/graph/adapters/neptune.adapter.js +1095 -1228
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +524 -0
- package/dist/graph/graphs.service.js +1683 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +54 -8
- package/dist/graph/index.js +67 -32
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +141 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -9
- package/dist/graph/types/index.js +15 -30
- package/dist/graph/types/index.js.map +1 -1
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +168 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/index.d.ts +1905 -875
- package/dist/index.js +3063 -1282
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/init.interface.js +3 -0
- package/dist/init.interface.js.map +1 -0
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.types.d.ts +12 -2
- package/dist/logs/logs.types.js +5 -1
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +252 -0
- package/dist/notifications/notifications.service.js +654 -0
- package/dist/notifications/notifications.service.js.map +1 -0
- package/dist/notifications/types/index.d.ts +4 -0
- package/dist/notifications/types/index.js +21 -0
- package/dist/notifications/types/index.js.map +1 -0
- package/dist/notifications/types/notifications.types.d.ts +400 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +86 -70
- package/dist/processor/services/processor.service.js +1353 -1259
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +5 -1
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/services/products.service.d.ts +167 -25
- package/dist/products/services/products.service.js +1248 -412
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +6 -3
- package/dist/products/validators/index.js +14 -5
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +218 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +4 -15
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +135 -50
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
- package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +0 -6
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +88 -0
- package/dist/resilience/fallback.service.js +511 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +106 -0
- package/dist/resilience/healthcheck.service.js +379 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +90 -0
- package/dist/resilience/quota.service.js +519 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +95 -0
- package/dist/resilience/resilience.service.js +525 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +479 -0
- package/dist/resilience/types/index.js +26 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +83 -0
- package/dist/secrets/secrets.service.js +159 -0
- package/dist/secrets/secrets.service.js.map +1 -0
- package/dist/secrets/secrets.types.d.ts +188 -0
- package/dist/secrets/secrets.types.js +87 -0
- package/dist/secrets/secrets.types.js.map +1 -0
- package/dist/sessions/index.d.ts +50 -0
- package/dist/sessions/index.js +93 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +68 -0
- package/dist/sessions/sessions.helper.js +116 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +150 -0
- package/dist/sessions/sessions.resolver.js +356 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +170 -0
- package/dist/sessions/sessions.service.js +736 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +290 -0
- package/dist/sessions/types/index.js +6 -0
- package/dist/sessions/types/index.js.map +1 -0
- package/dist/storage/index.d.ts +66 -0
- package/dist/storage/index.js +98 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +123 -0
- package/dist/storage/storage.service.js +478 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +207 -0
- package/dist/storage/types/index.js +6 -0
- package/dist/storage/types/index.js.map +1 -0
- package/dist/storage/utils/storage.util.d.ts +51 -0
- package/dist/storage/utils/storage.util.js +402 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +13 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -15
- package/dist/test/test.appBuilder.js.map +1 -1
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.health.d.ts +0 -1
- package/dist/test/test.health.js +0 -48
- package/dist/test/test.health.js.map +1 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1506
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -75
- package/dist/test/test.import.openapi.js.map +1 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -76
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -17
- package/dist/test/test.logs.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +0 -1
- package/dist/test/test.notifiers.js +0 -84
- package/dist/test/test.notifiers.js.map +1 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -37
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -660
- package/dist/test/test.productBuilder.js.map +1 -1
- package/dist/test/test.products.d.ts +0 -1
- package/dist/test/test.products.js +0 -48
- package/dist/test/test.products.js.map +1 -1
- package/dist/test/test.storage.js +332 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/dist/types/enums.d.ts +6 -1
- package/dist/types/enums.js +5 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/processor.types.d.ts +197 -35
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +837 -75
- package/dist/types/productsBuilder.types.js +168 -62
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +2 -49
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +152 -0
- package/dist/vector/adapters/base.adapter.js +137 -0
- package/dist/vector/adapters/base.adapter.js.map +1 -0
- package/dist/vector/adapters/index.d.ts +10 -0
- package/dist/vector/adapters/index.js +19 -0
- package/dist/vector/adapters/index.js.map +1 -0
- package/dist/vector/adapters/memory.adapter.d.ts +85 -0
- package/dist/vector/adapters/memory.adapter.js +505 -0
- package/dist/vector/adapters/memory.adapter.js.map +1 -0
- package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
- package/dist/vector/adapters/pinecone.adapter.js +400 -0
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
- package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
- package/dist/vector/adapters/qdrant.adapter.js +392 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
- package/dist/vector/adapters/weaviate.adapter.js +478 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +47 -0
- package/dist/vector/index.js +72 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/types/connection.interface.d.ts +151 -0
- package/dist/vector/types/connection.interface.js +8 -0
- package/dist/vector/types/connection.interface.js.map +1 -0
- package/dist/vector/types/embedding.interface.d.ts +144 -0
- package/dist/vector/types/embedding.interface.js +8 -0
- package/dist/vector/types/embedding.interface.js.map +1 -0
- package/dist/vector/types/enums.d.ts +104 -0
- package/dist/vector/types/enums.js +113 -0
- package/dist/vector/types/enums.js.map +1 -0
- package/dist/vector/types/index.d.ts +9 -0
- package/dist/vector/types/index.js +16 -0
- package/dist/vector/types/index.js.map +1 -0
- package/dist/vector/types/vector.interface.d.ts +315 -0
- package/dist/vector/types/vector.interface.js +8 -0
- package/dist/vector/types/vector.interface.js.map +1 -0
- package/dist/vector/utils/index.d.ts +6 -0
- package/dist/vector/utils/index.js +11 -0
- package/dist/vector/utils/index.js.map +1 -0
- package/dist/vector/utils/vector-error.d.ts +69 -0
- package/dist/vector/utils/vector-error.js +117 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +405 -0
- package/dist/vector/vector-database.service.js +544 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +245 -0
- package/dist/vector/vector.service.js +381 -0
- package/dist/vector/vector.service.js.map +1 -0
- package/dist/workflows/index.d.ts +30 -0
- package/dist/workflows/index.js +64 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types/index.d.ts +6 -0
- package/dist/workflows/types/index.js +23 -0
- package/dist/workflows/types/index.js.map +1 -0
- package/dist/workflows/types/workflows.types.d.ts +1035 -0
- package/dist/workflows/types/workflows.types.js +13 -0
- package/dist/workflows/types/workflows.types.js.map +1 -0
- package/dist/workflows/workflow-builder.d.ts +70 -0
- package/dist/workflows/workflow-builder.js +338 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +205 -0
- package/dist/workflows/workflow-executor.js +1186 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +398 -0
- package/dist/workflows/workflows.service.js +1595 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +16 -13
- package/dist/actions/actions.repo.d.ts +0 -0
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.d.ts +0 -0
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.d.ts +0 -0
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +0 -75
- package/dist/api/services/workspaceSecretsApi.service.js +0 -62
- package/dist/api/services/workspaceSecretsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/database/database.service.d.ts +0 -232
- package/dist/database/database.service.js +0 -802
- package/dist/database/database.service.js.map +0 -1
- package/dist/database/types/aggregation.types.d.ts +0 -261
- package/dist/database/types/aggregation.types.js +0 -21
- package/dist/database/types/aggregation.types.js.map +0 -1
- package/dist/database/types/connection.types.d.ts +0 -132
- package/dist/database/types/connection.types.js +0 -6
- package/dist/database/types/connection.types.js.map +0 -1
- package/dist/database/types/database.types.d.ts +0 -175
- package/dist/database/types/database.types.js +0 -75
- package/dist/database/types/database.types.js.map +0 -1
- package/dist/database/types/index.types.d.ts +0 -220
- package/dist/database/types/index.types.js +0 -27
- package/dist/database/types/index.types.js.map +0 -1
- package/dist/database/types/migration.types.d.ts +0 -205
- package/dist/database/types/migration.types.js +0 -44
- package/dist/database/types/migration.types.js.map +0 -1
- package/dist/database/types/query.types.d.ts +0 -305
- package/dist/database/types/query.types.js +0 -57
- package/dist/database/types/query.types.js.map +0 -1
- package/dist/database/types/result.types.d.ts +0 -220
- package/dist/database/types/result.types.js +0 -6
- package/dist/database/types/result.types.js.map +0 -1
- package/dist/database/types/schema.types.d.ts +0 -190
- package/dist/database/types/schema.types.js +0 -69
- package/dist/database/types/schema.types.js.map +0 -1
- package/dist/database/utils/helpers.d.ts +0 -66
- package/dist/database/utils/helpers.js +0 -501
- package/dist/database/utils/helpers.js.map +0 -1
- package/dist/database/utils/migration.utils.d.ts +0 -151
- package/dist/database/utils/migration.utils.js +0 -476
- package/dist/database/utils/migration.utils.js.map +0 -1
- package/dist/database/utils/transaction.d.ts +0 -64
- package/dist/database/utils/transaction.js +0 -130
- package/dist/database/utils/transaction.js.map +0 -1
- package/dist/database/validators/connection.validator.d.ts +0 -20
- package/dist/database/validators/connection.validator.js +0 -267
- package/dist/database/validators/connection.validator.js.map +0 -1
- package/dist/database/validators/query.validator.d.ts +0 -31
- package/dist/database/validators/query.validator.js +0 -305
- package/dist/database/validators/query.validator.js.map +0 -1
- package/dist/database/validators/schema.validator.d.ts +0 -31
- package/dist/database/validators/schema.validator.js +0 -334
- package/dist/database/validators/schema.validator.js.map +0 -1
- package/dist/graph/graph.service.d.ts +0 -278
- package/dist/graph/graph.service.js +0 -687
- package/dist/graph/graph.service.js.map +0 -1
- package/dist/graph/types/connection.types.d.ts +0 -158
- package/dist/graph/types/connection.types.js +0 -43
- package/dist/graph/types/connection.types.js.map +0 -1
- package/dist/graph/types/graph.types.d.ts +0 -144
- package/dist/graph/types/graph.types.js +0 -84
- package/dist/graph/types/graph.types.js.map +0 -1
- package/dist/graph/types/node.types.d.ts +0 -193
- package/dist/graph/types/node.types.js +0 -49
- package/dist/graph/types/node.types.js.map +0 -1
- package/dist/graph/types/path.types.d.ts +0 -224
- package/dist/graph/types/path.types.js +0 -38
- package/dist/graph/types/path.types.js.map +0 -1
- package/dist/graph/types/query.types.d.ts +0 -247
- package/dist/graph/types/query.types.js +0 -23
- package/dist/graph/types/query.types.js.map +0 -1
- package/dist/graph/types/relationship.types.d.ts +0 -224
- package/dist/graph/types/relationship.types.js +0 -35
- package/dist/graph/types/relationship.types.js.map +0 -1
- package/dist/graph/types/result.types.d.ts +0 -237
- package/dist/graph/types/result.types.js +0 -7
- package/dist/graph/types/result.types.js.map +0 -1
- package/dist/graph/validators/index.d.ts +0 -81
- package/dist/graph/validators/index.js +0 -243
- package/dist/graph/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/utils/mongo.util.d.ts +0 -0
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/services/utils/crypt.utils.d.ts +0 -1
- package/dist/products/services/utils/crypt.utils.js +0 -17
- package/dist/products/services/utils/crypt.utils.js.map +0 -1
- package/dist/products/services/utils/functions.utils.d.ts +0 -13
- package/dist/products/services/utils/functions.utils.js +0 -289
- package/dist/products/services/utils/functions.utils.js.map +0 -1
- package/dist/products/services/utils/objects.utils.d.ts +0 -13
- package/dist/products/services/utils/objects.utils.js +0 -89
- package/dist/products/services/utils/objects.utils.js.map +0 -1
- package/dist/products/services/utils/string.utils.d.ts +0 -12
- package/dist/products/services/utils/string.utils.js +0 -168
- package/dist/products/services/utils/string.utils.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- package/dist/test.import.d.ts +0 -0
- package/dist/test.import.js +0 -24
- package/dist/test.import.js.map +0 -1
- package/dist/test.imports.js +0 -28
- package/dist/test.imports.js.map +0 -1
- package/dist/test.integrationBuilder.js +0 -276
- package/dist/test.integrationBuilder.js.map +0 -1
- package/dist/test.processor.d.ts +0 -1
- package/dist/test.processor.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.d.ts +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* ArangoDB Graph Database Adapter
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* Implements the BaseGraphAdapter for ArangoDB.
|
|
6
|
+
* ArangoDB is a multi-model database that supports documents, graphs, and key-value.
|
|
7
|
+
* Uses AQL (ArangoDB Query Language) for graph operations.
|
|
5
8
|
*/
|
|
6
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
10
|
if (k2 === undefined) k2 = k;
|
|
@@ -36,1358 +39,1445 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
39
|
return result;
|
|
37
40
|
};
|
|
38
41
|
})();
|
|
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
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
43
|
exports.ArangoDBAdapter = void 0;
|
|
52
44
|
const base_adapter_1 = require("./base.adapter");
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const relationship_types_1 = require("../types/relationship.types");
|
|
45
|
+
const enums_1 = require("../types/enums");
|
|
46
|
+
const graph_error_1 = require("../utils/graph-error");
|
|
56
47
|
/**
|
|
57
|
-
* ArangoDB
|
|
48
|
+
* ArangoDB adapter using arangojs
|
|
58
49
|
*/
|
|
59
|
-
class
|
|
60
|
-
constructor(
|
|
61
|
-
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
|
|
50
|
+
class ArangoDBAdapter extends base_adapter_1.BaseGraphAdapter {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
this.graphType = enums_1.GraphType.ARANGODB;
|
|
54
|
+
this.supportedFeatures = new Set([
|
|
55
|
+
enums_1.GraphFeature.TRANSACTIONS,
|
|
56
|
+
enums_1.GraphFeature.SCHEMA_INDEXES,
|
|
57
|
+
enums_1.GraphFeature.FULL_TEXT_SEARCH,
|
|
58
|
+
enums_1.GraphFeature.MULTI_TENANCY,
|
|
59
|
+
]);
|
|
65
60
|
this.db = null;
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
this.graph = null;
|
|
62
|
+
this.graphName = '';
|
|
63
|
+
this.vertexCollections = [];
|
|
64
|
+
this.edgeCollections = [];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Connect to ArangoDB
|
|
68
|
+
*/
|
|
69
|
+
async connect(options) {
|
|
70
|
+
var _a;
|
|
75
71
|
try {
|
|
76
|
-
//
|
|
72
|
+
// Dynamically import arangojs
|
|
77
73
|
const arangojs = await Promise.resolve().then(() => __importStar(require('arangojs')));
|
|
78
74
|
const { Database } = arangojs;
|
|
79
|
-
|
|
80
|
-
url:
|
|
81
|
-
databaseName:
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
dbConfig.headers = this.config.headers;
|
|
97
|
-
}
|
|
98
|
-
const db = new Database(dbConfig);
|
|
99
|
-
// Verify connectivity
|
|
100
|
-
const exists = await db.exists();
|
|
101
|
-
if (!exists) {
|
|
102
|
-
throw new Error(`Database '${this.config.database}' does not exist`);
|
|
75
|
+
this.db = new Database({
|
|
76
|
+
url: options.connectionUrl,
|
|
77
|
+
databaseName: options.database || '_system',
|
|
78
|
+
});
|
|
79
|
+
// If graph name is provided, get the graph
|
|
80
|
+
if (options.graphName) {
|
|
81
|
+
this.graphName = options.graphName;
|
|
82
|
+
this.graph = this.db.graph(options.graphName);
|
|
83
|
+
// Get graph info
|
|
84
|
+
const graphInfo = await this.graph.get();
|
|
85
|
+
this.vertexCollections = graphInfo.orphanCollections || [];
|
|
86
|
+
this.edgeCollections = ((_a = graphInfo.edgeDefinitions) === null || _a === void 0 ? void 0 : _a.map((ed) => ed.collection)) || [];
|
|
87
|
+
// Add vertex collections from edge definitions
|
|
88
|
+
for (const ed of graphInfo.edgeDefinitions || []) {
|
|
89
|
+
this.vertexCollections.push(...ed.from, ...ed.to);
|
|
90
|
+
}
|
|
91
|
+
this.vertexCollections = [...new Set(this.vertexCollections)];
|
|
103
92
|
}
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
106
|
-
|
|
93
|
+
this.client = this.db;
|
|
94
|
+
this.connected = true;
|
|
95
|
+
return {
|
|
96
|
+
connected: true,
|
|
97
|
+
type: this.graphType,
|
|
98
|
+
version: await this.getVersion(),
|
|
99
|
+
};
|
|
107
100
|
}
|
|
108
101
|
catch (error) {
|
|
109
|
-
this.
|
|
110
|
-
throw
|
|
102
|
+
this.connected = false;
|
|
103
|
+
throw graph_error_1.GraphError.connectionError(`Failed to connect to ArangoDB: ${error.message}`);
|
|
111
104
|
}
|
|
112
105
|
}
|
|
113
|
-
async
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
getClient() {
|
|
121
|
-
if (!this.db) {
|
|
122
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'ArangoDB client not initialized. Call connect() first.');
|
|
106
|
+
async getVersion() {
|
|
107
|
+
try {
|
|
108
|
+
const info = await this.db.version();
|
|
109
|
+
return info.version;
|
|
110
|
+
}
|
|
111
|
+
catch (_a) {
|
|
112
|
+
return 'unknown';
|
|
123
113
|
}
|
|
124
|
-
return this.db;
|
|
125
|
-
}
|
|
126
|
-
getSession() {
|
|
127
|
-
return this.getClient();
|
|
128
|
-
}
|
|
129
|
-
getConfig() {
|
|
130
|
-
return this.config;
|
|
131
|
-
}
|
|
132
|
-
setGraphName(name) {
|
|
133
|
-
this.graphName = name;
|
|
134
114
|
}
|
|
135
|
-
|
|
136
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Disconnect from ArangoDB
|
|
117
|
+
*/
|
|
118
|
+
async disconnect() {
|
|
119
|
+
if (this.db) {
|
|
120
|
+
this.db = null;
|
|
121
|
+
this.graph = null;
|
|
122
|
+
this.client = null;
|
|
123
|
+
this.connected = false;
|
|
124
|
+
}
|
|
137
125
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Test ArangoDB connection
|
|
128
|
+
*/
|
|
129
|
+
async testConnection(options) {
|
|
130
|
+
try {
|
|
131
|
+
await this.connect(options);
|
|
132
|
+
const startTime = Date.now();
|
|
133
|
+
const version = await this.getVersion();
|
|
134
|
+
const latency = Date.now() - startTime;
|
|
135
|
+
await this.disconnect();
|
|
136
|
+
return {
|
|
137
|
+
connected: true,
|
|
138
|
+
type: this.graphType,
|
|
139
|
+
version,
|
|
140
|
+
latency,
|
|
141
|
+
features: ['aql', 'multi-model', 'transactions'],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return {
|
|
146
|
+
connected: false,
|
|
147
|
+
type: this.graphType,
|
|
148
|
+
error: error.message,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
150
151
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
// ==================== NODE OPERATIONS ====================
|
|
153
|
+
async createNode(options, transaction) {
|
|
154
|
+
this.ensureConnected();
|
|
155
|
+
try {
|
|
156
|
+
const collectionName = options.labels[0];
|
|
157
|
+
const collection = this.db.collection(collectionName);
|
|
158
|
+
const doc = Object.assign(Object.assign({}, options.properties), { _labels: options.labels });
|
|
159
|
+
const result = await collection.save(doc, { returnNew: true });
|
|
160
|
+
const node = {
|
|
161
|
+
id: result._key,
|
|
162
|
+
labels: options.labels,
|
|
163
|
+
properties: result.new,
|
|
164
|
+
elementId: result._id,
|
|
165
|
+
};
|
|
166
|
+
return { node, created: true };
|
|
154
167
|
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
throw graph_error_1.GraphError.queryError(`Failed to create node: ${error.message}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async findNodes(options, transaction) {
|
|
173
|
+
var _a, _b, _c, _d, _e;
|
|
174
|
+
this.ensureConnected();
|
|
155
175
|
try {
|
|
156
|
-
|
|
157
|
-
|
|
176
|
+
let aql = 'FOR doc IN @@collection';
|
|
177
|
+
const bindVars = {};
|
|
178
|
+
const collectionName = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a[0]) || this.vertexCollections[0];
|
|
179
|
+
bindVars['@collection'] = collectionName;
|
|
180
|
+
if (options.where) {
|
|
181
|
+
const { filterStr, filterVars } = this.buildArangoWhereClause(options.where, 'doc');
|
|
182
|
+
if (filterStr) {
|
|
183
|
+
aql += ` FILTER ${filterStr}`;
|
|
184
|
+
Object.assign(bindVars, filterVars);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
|
|
188
|
+
const sortParts = options.orderBy.map((o) => `doc.${o.property} ${o.direction || 'ASC'}`);
|
|
189
|
+
aql += ` SORT ${sortParts.join(', ')}`;
|
|
158
190
|
}
|
|
159
|
-
|
|
191
|
+
const skipValue = (_d = (_c = options.skip) !== null && _c !== void 0 ? _c : options.offset) !== null && _d !== void 0 ? _d : 0;
|
|
192
|
+
const limitValue = (_e = options.limit) !== null && _e !== void 0 ? _e : 100;
|
|
193
|
+
aql += ` LIMIT ${skipValue}, ${limitValue}`;
|
|
194
|
+
aql += ' RETURN doc';
|
|
195
|
+
const cursor = await this.db.query(aql, bindVars);
|
|
196
|
+
const docs = await cursor.all();
|
|
197
|
+
const nodes = docs.map((doc) => ({
|
|
198
|
+
id: doc._key,
|
|
199
|
+
labels: doc._labels || [collectionName],
|
|
200
|
+
properties: this.cleanArangoProps(doc),
|
|
201
|
+
elementId: doc._id,
|
|
202
|
+
}));
|
|
203
|
+
const countAql = `RETURN LENGTH(FOR doc IN @@collection ${options.where ? `FILTER ${this.buildArangoWhereClause(options.where, 'doc').filterStr}` : ''} RETURN 1)`;
|
|
204
|
+
const countCursor = await this.db.query(countAql, { '@collection': collectionName });
|
|
205
|
+
const [total] = await countCursor.all();
|
|
206
|
+
return { nodes, total };
|
|
160
207
|
}
|
|
161
208
|
catch (error) {
|
|
162
|
-
|
|
163
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to commit transaction: ${error.message}`, error);
|
|
209
|
+
throw graph_error_1.GraphError.queryError(`Failed to find nodes: ${error.message}`);
|
|
164
210
|
}
|
|
165
211
|
}
|
|
166
|
-
async
|
|
167
|
-
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
212
|
+
async findNodeById(id, transaction) {
|
|
213
|
+
this.ensureConnected();
|
|
170
214
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
215
|
+
const docId = String(id).includes('/') ? id : null;
|
|
216
|
+
if (!docId) {
|
|
217
|
+
for (const collName of this.vertexCollections) {
|
|
218
|
+
try {
|
|
219
|
+
const collection = this.db.collection(collName);
|
|
220
|
+
const doc = await collection.document(id);
|
|
221
|
+
return {
|
|
222
|
+
id: doc._key,
|
|
223
|
+
labels: doc._labels || [collName],
|
|
224
|
+
properties: this.cleanArangoProps(doc),
|
|
225
|
+
elementId: doc._id,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
catch (_a) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
173
233
|
}
|
|
174
|
-
|
|
234
|
+
const [collName] = String(docId).split('/');
|
|
235
|
+
const collection = this.db.collection(collName);
|
|
236
|
+
const doc = await collection.document(docId);
|
|
237
|
+
return {
|
|
238
|
+
id: doc._key,
|
|
239
|
+
labels: doc._labels || [collName],
|
|
240
|
+
properties: this.cleanArangoProps(doc),
|
|
241
|
+
elementId: doc._id,
|
|
242
|
+
};
|
|
175
243
|
}
|
|
176
244
|
catch (error) {
|
|
177
|
-
|
|
178
|
-
|
|
245
|
+
if (error.code === 404) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
throw graph_error_1.GraphError.queryError(`Failed to find node by ID: ${error.message}`);
|
|
179
249
|
}
|
|
180
250
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
251
|
+
async updateNode(options, transaction) {
|
|
252
|
+
this.ensureConnected();
|
|
253
|
+
try {
|
|
254
|
+
const docId = String(options.id);
|
|
255
|
+
const [collName] = docId.includes('/') ? docId.split('/') : [this.vertexCollections[0]];
|
|
256
|
+
const collection = this.db.collection(collName);
|
|
257
|
+
const key = docId.includes('/') ? docId.split('/')[1] : docId;
|
|
258
|
+
let updateData = {};
|
|
259
|
+
if (options.properties) {
|
|
260
|
+
if ('$SET' in options.properties) {
|
|
261
|
+
updateData = Object.assign(Object.assign({}, updateData), options.properties.$SET);
|
|
262
|
+
}
|
|
263
|
+
if ('$UNSET' in options.properties) {
|
|
264
|
+
for (const prop of options.properties.$UNSET || []) {
|
|
265
|
+
updateData[prop] = null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if ('$INCREMENT' in options.properties) {
|
|
269
|
+
for (const [prop, value] of Object.entries(options.properties.$INCREMENT || {})) {
|
|
270
|
+
const current = await collection.document(key);
|
|
271
|
+
updateData[prop] = (current[prop] || 0) + value;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if ('$APPEND' in options.properties) {
|
|
275
|
+
for (const [prop, value] of Object.entries(options.properties.$APPEND || {})) {
|
|
276
|
+
const current = await collection.document(key);
|
|
277
|
+
updateData[prop] = [...(current[prop] || []), value];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const result = await collection.update(key, updateData, { returnNew: true });
|
|
282
|
+
const node = {
|
|
283
|
+
id: result._key,
|
|
284
|
+
labels: result.new._labels || [collName],
|
|
285
|
+
properties: this.cleanArangoProps(result.new),
|
|
286
|
+
elementId: result._id,
|
|
287
|
+
};
|
|
288
|
+
return { node, updated: true };
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
throw graph_error_1.GraphError.queryError(`Failed to update node: ${error.message}`);
|
|
292
|
+
}
|
|
197
293
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
294
|
+
async deleteNode(options, transaction) {
|
|
295
|
+
this.ensureConnected();
|
|
296
|
+
try {
|
|
297
|
+
const docId = String(options.id);
|
|
298
|
+
const [collName] = docId.includes('/') ? docId.split('/') : [this.vertexCollections[0]];
|
|
299
|
+
const collection = this.db.collection(collName);
|
|
300
|
+
const key = docId.includes('/') ? docId.split('/')[1] : docId;
|
|
301
|
+
if (options.detach) {
|
|
302
|
+
const fullId = docId.includes('/') ? docId : `${collName}/${key}`;
|
|
303
|
+
for (const edgeCollName of this.edgeCollections) {
|
|
304
|
+
await this.db.query(`FOR e IN @@collection FILTER e._from == @id OR e._to == @id REMOVE e IN @@collection`, { '@collection': edgeCollName, id: fullId });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
await collection.remove(key);
|
|
308
|
+
return { deleted: true, id: options.id };
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
throw graph_error_1.GraphError.queryError(`Failed to delete node: ${error.message}`);
|
|
312
|
+
}
|
|
206
313
|
}
|
|
207
|
-
async
|
|
208
|
-
|
|
314
|
+
async mergeNode(options, transaction) {
|
|
315
|
+
this.ensureConnected();
|
|
316
|
+
try {
|
|
317
|
+
const collectionName = options.labels[0];
|
|
318
|
+
const collection = this.db.collection(collectionName);
|
|
319
|
+
const { filterStr, filterVars } = this.buildArangoWhereClause(options.matchProperties, 'doc');
|
|
320
|
+
const findAql = `FOR doc IN @@collection FILTER ${filterStr} LIMIT 1 RETURN doc`;
|
|
321
|
+
const cursor = await this.db.query(findAql, Object.assign({ '@collection': collectionName }, filterVars));
|
|
322
|
+
const existing = await cursor.all();
|
|
323
|
+
if (existing.length > 0) {
|
|
324
|
+
const doc = existing[0];
|
|
325
|
+
const updateData = options.onMatch || {};
|
|
326
|
+
const result = await collection.update(doc._key, updateData, { returnNew: true });
|
|
327
|
+
return {
|
|
328
|
+
node: {
|
|
329
|
+
id: result._key,
|
|
330
|
+
labels: options.labels,
|
|
331
|
+
properties: this.cleanArangoProps(result.new),
|
|
332
|
+
elementId: result._id,
|
|
333
|
+
},
|
|
334
|
+
created: false,
|
|
335
|
+
merged: true,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
const createData = Object.assign(Object.assign(Object.assign({}, options.matchProperties), (options.onCreate || {})), { _labels: options.labels });
|
|
340
|
+
const result = await collection.save(createData, { returnNew: true });
|
|
341
|
+
return {
|
|
342
|
+
node: {
|
|
343
|
+
id: result._key,
|
|
344
|
+
labels: options.labels,
|
|
345
|
+
properties: this.cleanArangoProps(result.new),
|
|
346
|
+
elementId: result._id,
|
|
347
|
+
},
|
|
348
|
+
created: true,
|
|
349
|
+
merged: true,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
throw graph_error_1.GraphError.queryError(`Failed to merge node: ${error.message}`);
|
|
355
|
+
}
|
|
209
356
|
}
|
|
210
|
-
|
|
211
|
-
|
|
357
|
+
// ==================== LABEL MANAGEMENT ====================
|
|
358
|
+
async addLabels(options, _transaction) {
|
|
359
|
+
this.ensureConnected();
|
|
212
360
|
try {
|
|
213
|
-
|
|
214
|
-
|
|
361
|
+
// In ArangoDB, we store labels in a _labels array property
|
|
362
|
+
// First, find the document
|
|
363
|
+
const docId = String(options.id);
|
|
364
|
+
const isFullId = docId.includes('/');
|
|
365
|
+
let doc;
|
|
366
|
+
if (isFullId) {
|
|
367
|
+
const [collectionName, key] = docId.split('/');
|
|
368
|
+
const collection = this.db.collection(collectionName);
|
|
369
|
+
doc = await collection.document(key);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
// Search across vertex collections
|
|
373
|
+
for (const collectionName of this.vertexCollections) {
|
|
374
|
+
try {
|
|
375
|
+
const collection = this.db.collection(collectionName);
|
|
376
|
+
doc = await collection.document(docId);
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
catch (_a) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!doc) {
|
|
385
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
386
|
+
}
|
|
387
|
+
const existingLabels = doc._labels || [];
|
|
388
|
+
const newLabels = [...new Set([...existingLabels, ...options.labels])];
|
|
389
|
+
const [collectionName] = doc._id.split('/');
|
|
390
|
+
const collection = this.db.collection(collectionName);
|
|
391
|
+
const result = await collection.update(doc._key, { _labels: newLabels }, { returnNew: true });
|
|
215
392
|
return {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
393
|
+
node: {
|
|
394
|
+
id: result._key,
|
|
395
|
+
labels: newLabels,
|
|
396
|
+
properties: this.cleanArangoProps(result.new),
|
|
397
|
+
elementId: result._id,
|
|
398
|
+
},
|
|
399
|
+
addedLabels: options.labels,
|
|
222
400
|
};
|
|
223
401
|
}
|
|
224
402
|
catch (error) {
|
|
403
|
+
if (error instanceof graph_error_1.GraphError)
|
|
404
|
+
throw error;
|
|
405
|
+
throw graph_error_1.GraphError.queryError(`Failed to add labels: ${error.message}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
async removeLabels(options, _transaction) {
|
|
409
|
+
this.ensureConnected();
|
|
410
|
+
try {
|
|
411
|
+
const docId = String(options.id);
|
|
412
|
+
const isFullId = docId.includes('/');
|
|
413
|
+
let doc;
|
|
414
|
+
if (isFullId) {
|
|
415
|
+
const [collectionName, key] = docId.split('/');
|
|
416
|
+
const collection = this.db.collection(collectionName);
|
|
417
|
+
doc = await collection.document(key);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
for (const collectionName of this.vertexCollections) {
|
|
421
|
+
try {
|
|
422
|
+
const collection = this.db.collection(collectionName);
|
|
423
|
+
doc = await collection.document(docId);
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
catch (_a) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (!doc) {
|
|
432
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
433
|
+
}
|
|
434
|
+
const existingLabels = doc._labels || [];
|
|
435
|
+
const newLabels = existingLabels.filter(l => !options.labels.includes(l));
|
|
436
|
+
const [collectionName] = doc._id.split('/');
|
|
437
|
+
const collection = this.db.collection(collectionName);
|
|
438
|
+
const result = await collection.update(doc._key, { _labels: newLabels }, { returnNew: true });
|
|
225
439
|
return {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
440
|
+
node: {
|
|
441
|
+
id: result._key,
|
|
442
|
+
labels: newLabels,
|
|
443
|
+
properties: this.cleanArangoProps(result.new),
|
|
444
|
+
elementId: result._id,
|
|
445
|
+
},
|
|
446
|
+
removedLabels: options.labels,
|
|
232
447
|
};
|
|
233
448
|
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
if (error instanceof graph_error_1.GraphError)
|
|
451
|
+
throw error;
|
|
452
|
+
throw graph_error_1.GraphError.queryError(`Failed to remove labels: ${error.message}`);
|
|
453
|
+
}
|
|
234
454
|
}
|
|
235
|
-
async
|
|
236
|
-
|
|
237
|
-
const versionInfo = await db.version();
|
|
238
|
-
return {
|
|
239
|
-
version: versionInfo.version,
|
|
240
|
-
edition: versionInfo.server,
|
|
241
|
-
features: ['graphs', 'full-text-search', 'geo-spatial'],
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
// ==================== TRANSACTION METHODS ====================
|
|
245
|
-
async beginTransaction(connection, options) {
|
|
246
|
-
const db = connection.getClient();
|
|
247
|
-
const collections = {
|
|
248
|
-
read: [this.defaultVertexCollection, this.defaultEdgeCollection],
|
|
249
|
-
write: [this.defaultVertexCollection, this.defaultEdgeCollection],
|
|
250
|
-
};
|
|
251
|
-
const trx = await db.beginTransaction(collections);
|
|
252
|
-
return new ArangoDBTransaction(connection, trx);
|
|
253
|
-
}
|
|
254
|
-
async commitTransaction(connection, transaction) {
|
|
255
|
-
await transaction.commit();
|
|
256
|
-
}
|
|
257
|
-
async rollbackTransaction(connection, transaction) {
|
|
258
|
-
await transaction.rollback();
|
|
259
|
-
}
|
|
260
|
-
// ==================== RAW QUERY METHODS ====================
|
|
261
|
-
async executeRaw(connection, options, transaction) {
|
|
262
|
-
const startTime = Date.now();
|
|
263
|
-
const db = connection.getClient();
|
|
455
|
+
async setLabels(options, _transaction) {
|
|
456
|
+
this.ensureConnected();
|
|
264
457
|
try {
|
|
265
|
-
const
|
|
266
|
-
const
|
|
458
|
+
const docId = String(options.id);
|
|
459
|
+
const isFullId = docId.includes('/');
|
|
460
|
+
let doc;
|
|
461
|
+
if (isFullId) {
|
|
462
|
+
const [collectionName, key] = docId.split('/');
|
|
463
|
+
const collection = this.db.collection(collectionName);
|
|
464
|
+
doc = await collection.document(key);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
for (const collectionName of this.vertexCollections) {
|
|
468
|
+
try {
|
|
469
|
+
const collection = this.db.collection(collectionName);
|
|
470
|
+
doc = await collection.document(docId);
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
catch (_a) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (!doc) {
|
|
479
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
480
|
+
}
|
|
481
|
+
const previousLabels = doc._labels || [];
|
|
482
|
+
const [collectionName] = doc._id.split('/');
|
|
483
|
+
const collection = this.db.collection(collectionName);
|
|
484
|
+
const result = await collection.update(doc._key, { _labels: options.labels }, { returnNew: true });
|
|
267
485
|
return {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
486
|
+
node: {
|
|
487
|
+
id: result._key,
|
|
488
|
+
labels: options.labels,
|
|
489
|
+
properties: this.cleanArangoProps(result.new),
|
|
490
|
+
elementId: result._id,
|
|
491
|
+
},
|
|
492
|
+
previousLabels,
|
|
493
|
+
newLabels: options.labels,
|
|
272
494
|
};
|
|
273
495
|
}
|
|
274
496
|
catch (error) {
|
|
275
|
-
|
|
497
|
+
if (error instanceof graph_error_1.GraphError)
|
|
498
|
+
throw error;
|
|
499
|
+
throw graph_error_1.GraphError.queryError(`Failed to set labels: ${error.message}`);
|
|
276
500
|
}
|
|
277
501
|
}
|
|
278
|
-
// ====================
|
|
279
|
-
async
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
created: true
|
|
301
|
-
}
|
|
502
|
+
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
503
|
+
async createRelationship(options, transaction) {
|
|
504
|
+
this.ensureConnected();
|
|
505
|
+
try {
|
|
506
|
+
const edgeCollectionName = options.type;
|
|
507
|
+
const edgeCollection = this.db.collection(edgeCollectionName);
|
|
508
|
+
const fromId = String(options.startNodeId).includes('/')
|
|
509
|
+
? options.startNodeId
|
|
510
|
+
: await this.resolveNodeId(options.startNodeId);
|
|
511
|
+
const toId = String(options.endNodeId).includes('/')
|
|
512
|
+
? options.endNodeId
|
|
513
|
+
: await this.resolveNodeId(options.endNodeId);
|
|
514
|
+
const edgeDoc = Object.assign({ _from: fromId, _to: toId }, options.properties);
|
|
515
|
+
const result = await edgeCollection.save(edgeDoc, { returnNew: true });
|
|
516
|
+
const relationship = {
|
|
517
|
+
id: result._key,
|
|
518
|
+
type: options.type,
|
|
519
|
+
startNodeId: fromId,
|
|
520
|
+
endNodeId: toId,
|
|
521
|
+
properties: this.cleanArangoProps(result.new),
|
|
522
|
+
elementId: result._id,
|
|
523
|
+
};
|
|
524
|
+
return { relationship, created: true };
|
|
525
|
+
}
|
|
526
|
+
catch (error) {
|
|
527
|
+
throw graph_error_1.GraphError.queryError(`Failed to create relationship: ${error.message}`);
|
|
528
|
+
}
|
|
302
529
|
}
|
|
303
|
-
async
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
530
|
+
async findRelationships(options, transaction) {
|
|
531
|
+
var _a, _b, _c, _d;
|
|
532
|
+
this.ensureConnected();
|
|
533
|
+
try {
|
|
534
|
+
const edgeCollectionName = ((_a = options.types) === null || _a === void 0 ? void 0 : _a[0]) || (Array.isArray(options.type) ? options.type[0] : options.type) || this.edgeCollections[0];
|
|
535
|
+
let aql = 'FOR edge IN @@collection';
|
|
536
|
+
const bindVars = { '@collection': edgeCollectionName };
|
|
537
|
+
if (options.where) {
|
|
538
|
+
const { filterStr, filterVars } = this.buildArangoWhereClause(options.where, 'edge');
|
|
539
|
+
if (filterStr) {
|
|
540
|
+
aql += ` FILTER ${filterStr}`;
|
|
541
|
+
Object.assign(bindVars, filterVars);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const skipValue = (_c = (_b = options.skip) !== null && _b !== void 0 ? _b : options.offset) !== null && _c !== void 0 ? _c : 0;
|
|
545
|
+
const limitValue = (_d = options.limit) !== null && _d !== void 0 ? _d : 100;
|
|
546
|
+
aql += ` LIMIT ${skipValue}, ${limitValue}`;
|
|
547
|
+
aql += ' RETURN edge';
|
|
548
|
+
const cursor = await this.db.query(aql, bindVars);
|
|
549
|
+
const edges = await cursor.all();
|
|
550
|
+
const relationships = edges.map((edge) => ({
|
|
551
|
+
id: edge._key,
|
|
552
|
+
type: edgeCollectionName,
|
|
553
|
+
startNodeId: edge._from,
|
|
554
|
+
endNodeId: edge._to,
|
|
555
|
+
properties: this.cleanArangoProps(edge),
|
|
556
|
+
elementId: edge._id,
|
|
557
|
+
}));
|
|
558
|
+
return { relationships, total: relationships.length };
|
|
321
559
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
filters.push(filterClause);
|
|
560
|
+
catch (error) {
|
|
561
|
+
throw graph_error_1.GraphError.queryError(`Failed to find relationships: ${error.message}`);
|
|
325
562
|
}
|
|
326
|
-
|
|
327
|
-
|
|
563
|
+
}
|
|
564
|
+
async findRelationshipById(id, transaction) {
|
|
565
|
+
this.ensureConnected();
|
|
566
|
+
try {
|
|
567
|
+
const docId = String(id);
|
|
568
|
+
if (!docId.includes('/')) {
|
|
569
|
+
for (const collName of this.edgeCollections) {
|
|
570
|
+
try {
|
|
571
|
+
const collection = this.db.collection(collName);
|
|
572
|
+
const edge = await collection.document(id);
|
|
573
|
+
return {
|
|
574
|
+
id: edge._key,
|
|
575
|
+
type: collName,
|
|
576
|
+
startNodeId: edge._from,
|
|
577
|
+
endNodeId: edge._to,
|
|
578
|
+
properties: this.cleanArangoProps(edge),
|
|
579
|
+
elementId: edge._id,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
catch (_a) {
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
const [collName] = docId.split('/');
|
|
589
|
+
const collection = this.db.collection(collName);
|
|
590
|
+
const edge = await collection.document(docId);
|
|
591
|
+
return {
|
|
592
|
+
id: edge._key,
|
|
593
|
+
type: collName,
|
|
594
|
+
startNodeId: edge._from,
|
|
595
|
+
endNodeId: edge._to,
|
|
596
|
+
properties: this.cleanArangoProps(edge),
|
|
597
|
+
elementId: edge._id,
|
|
598
|
+
};
|
|
328
599
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
600
|
+
catch (error) {
|
|
601
|
+
if (error.code === 404) {
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
throw graph_error_1.GraphError.queryError(`Failed to find relationship by ID: ${error.message}`);
|
|
333
605
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
606
|
+
}
|
|
607
|
+
async updateRelationship(options, transaction) {
|
|
608
|
+
this.ensureConnected();
|
|
609
|
+
try {
|
|
610
|
+
const docId = String(options.id);
|
|
611
|
+
const [collName] = docId.includes('/') ? docId.split('/') : [this.edgeCollections[0]];
|
|
612
|
+
const collection = this.db.collection(collName);
|
|
613
|
+
const key = docId.includes('/') ? docId.split('/')[1] : docId;
|
|
614
|
+
let updateData = {};
|
|
615
|
+
if (options.properties) {
|
|
616
|
+
if ('$SET' in options.properties) {
|
|
617
|
+
updateData = Object.assign(Object.assign({}, updateData), options.properties.$SET);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const result = await collection.update(key, updateData, { returnNew: true });
|
|
621
|
+
const relationship = {
|
|
622
|
+
id: result._key,
|
|
623
|
+
type: collName,
|
|
624
|
+
startNodeId: result.new._from,
|
|
625
|
+
endNodeId: result.new._to,
|
|
626
|
+
properties: this.cleanArangoProps(result.new),
|
|
627
|
+
elementId: result._id,
|
|
628
|
+
};
|
|
629
|
+
return { relationship, updated: true };
|
|
630
|
+
}
|
|
631
|
+
catch (error) {
|
|
632
|
+
throw graph_error_1.GraphError.queryError(`Failed to update relationship: ${error.message}`);
|
|
339
633
|
}
|
|
340
|
-
query += ` RETURN doc`;
|
|
341
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
342
|
-
const nodes = result.data.map(doc => this.parseNode(doc));
|
|
343
|
-
return {
|
|
344
|
-
success: true,
|
|
345
|
-
executionTime: Date.now() - startTime,
|
|
346
|
-
nodes,
|
|
347
|
-
count: nodes.length,
|
|
348
|
-
hasMore: options.limit !== undefined && nodes.length === options.limit,
|
|
349
|
-
};
|
|
350
634
|
}
|
|
351
|
-
async
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
return this.parseNode(result.data[0]);
|
|
635
|
+
async deleteRelationship(options, transaction) {
|
|
636
|
+
this.ensureConnected();
|
|
637
|
+
try {
|
|
638
|
+
const docId = String(options.id);
|
|
639
|
+
const [collName] = docId.includes('/') ? docId.split('/') : [this.edgeCollections[0]];
|
|
640
|
+
const collection = this.db.collection(collName);
|
|
641
|
+
const key = docId.includes('/') ? docId.split('/')[1] : docId;
|
|
642
|
+
await collection.remove(key);
|
|
643
|
+
return { deleted: true, id: options.id };
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
throw graph_error_1.GraphError.queryError(`Failed to delete relationship: ${error.message}`);
|
|
647
|
+
}
|
|
365
648
|
}
|
|
366
|
-
async
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
649
|
+
async mergeRelationship(options, transaction) {
|
|
650
|
+
this.ensureConnected();
|
|
651
|
+
try {
|
|
652
|
+
const edgeCollectionName = options.type;
|
|
653
|
+
const fromId = String(options.startNodeId).includes('/')
|
|
654
|
+
? options.startNodeId
|
|
655
|
+
: await this.resolveNodeId(options.startNodeId);
|
|
656
|
+
const toId = String(options.endNodeId).includes('/')
|
|
657
|
+
? options.endNodeId
|
|
658
|
+
: await this.resolveNodeId(options.endNodeId);
|
|
659
|
+
let filterStr = 'edge._from == @from AND edge._to == @to';
|
|
660
|
+
const bindVars = {
|
|
661
|
+
'@collection': edgeCollectionName,
|
|
662
|
+
from: fromId,
|
|
663
|
+
to: toId,
|
|
664
|
+
};
|
|
665
|
+
if (options.matchProperties) {
|
|
666
|
+
const { filterStr: matchFilter, filterVars } = this.buildArangoWhereClause(options.matchProperties, 'edge');
|
|
667
|
+
if (matchFilter) {
|
|
668
|
+
filterStr += ` AND ${matchFilter}`;
|
|
669
|
+
Object.assign(bindVars, filterVars);
|
|
670
|
+
}
|
|
378
671
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
672
|
+
const findAql = `FOR edge IN @@collection FILTER ${filterStr} LIMIT 1 RETURN edge`;
|
|
673
|
+
const cursor = await this.db.query(findAql, bindVars);
|
|
674
|
+
const existing = await cursor.all();
|
|
675
|
+
if (existing.length > 0) {
|
|
676
|
+
const edge = existing[0];
|
|
677
|
+
const collection = this.db.collection(edgeCollectionName);
|
|
678
|
+
const updateData = options.onMatch || {};
|
|
679
|
+
const result = await collection.update(edge._key, updateData, { returnNew: true });
|
|
680
|
+
return {
|
|
681
|
+
relationship: {
|
|
682
|
+
id: result._key,
|
|
683
|
+
type: options.type,
|
|
684
|
+
startNodeId: result.new._from,
|
|
685
|
+
endNodeId: result.new._to,
|
|
686
|
+
properties: this.cleanArangoProps(result.new),
|
|
687
|
+
elementId: result._id,
|
|
688
|
+
},
|
|
689
|
+
created: false,
|
|
690
|
+
merged: true,
|
|
691
|
+
};
|
|
394
692
|
}
|
|
395
|
-
|
|
396
|
-
const
|
|
397
|
-
|
|
693
|
+
else {
|
|
694
|
+
const createProps = Object.assign(Object.assign({}, options.matchProperties), (options.onCreate || {}));
|
|
695
|
+
const result = await this.createRelationship({
|
|
696
|
+
type: options.type,
|
|
697
|
+
startNodeId: options.startNodeId,
|
|
698
|
+
endNodeId: options.endNodeId,
|
|
699
|
+
properties: createProps,
|
|
700
|
+
});
|
|
701
|
+
return { relationship: result.relationship, created: true, merged: true };
|
|
398
702
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
703
|
+
}
|
|
704
|
+
catch (error) {
|
|
705
|
+
throw graph_error_1.GraphError.queryError(`Failed to merge relationship: ${error.message}`);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
// ==================== TRAVERSAL OPERATIONS ====================
|
|
709
|
+
async traverse(options, transaction) {
|
|
710
|
+
var _a;
|
|
711
|
+
this.ensureConnected();
|
|
712
|
+
try {
|
|
713
|
+
const startId = String(options.startNodeId).includes('/')
|
|
714
|
+
? options.startNodeId
|
|
715
|
+
: await this.resolveNodeId(options.startNodeId);
|
|
716
|
+
const direction = this.mapDirection(options.direction);
|
|
717
|
+
const maxDepth = options.maxDepth || 3;
|
|
718
|
+
const minDepth = 1;
|
|
719
|
+
const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
720
|
+
? options.relationshipTypes.join(', ')
|
|
721
|
+
: this.edgeCollections.join(', ');
|
|
722
|
+
const aql = `
|
|
723
|
+
FOR v, e, p IN ${minDepth}..${maxDepth} ${direction} @startVertex
|
|
724
|
+
${edgeCollections}
|
|
725
|
+
OPTIONS { bfs: true, uniqueVertices: 'global' }
|
|
726
|
+
RETURN { vertex: v, edge: e, path: p }
|
|
404
727
|
`;
|
|
405
|
-
|
|
406
|
-
|
|
728
|
+
const cursor = await this.db.query(aql, { startVertex: startId });
|
|
729
|
+
const results = await cursor.all();
|
|
730
|
+
const nodesMap = new Map();
|
|
731
|
+
const relationshipsMap = new Map();
|
|
732
|
+
for (const result of results) {
|
|
733
|
+
if (result.vertex) {
|
|
734
|
+
const v = result.vertex;
|
|
735
|
+
nodesMap.set(v._id, {
|
|
736
|
+
id: v._key,
|
|
737
|
+
labels: v._labels || [v._id.split('/')[0]],
|
|
738
|
+
properties: this.cleanArangoProps(v),
|
|
739
|
+
elementId: v._id,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
if (result.edge) {
|
|
743
|
+
const e = result.edge;
|
|
744
|
+
relationshipsMap.set(e._id, {
|
|
745
|
+
id: e._key,
|
|
746
|
+
type: e._id.split('/')[0],
|
|
747
|
+
startNodeId: e._from,
|
|
748
|
+
endNodeId: e._to,
|
|
749
|
+
properties: this.cleanArangoProps(e),
|
|
750
|
+
elementId: e._id,
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return {
|
|
755
|
+
nodes: Array.from(nodesMap.values()),
|
|
756
|
+
relationships: Array.from(relationshipsMap.values()),
|
|
757
|
+
paths: [],
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
catch (error) {
|
|
761
|
+
throw graph_error_1.GraphError.queryError(`Failed to traverse: ${error.message}`);
|
|
407
762
|
}
|
|
408
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
409
|
-
return {
|
|
410
|
-
success: true,
|
|
411
|
-
executionTime: Date.now() - startTime,
|
|
412
|
-
node: result.data.length > 0 ? this.parseNode(result.data[0]) : undefined,
|
|
413
|
-
updated: result.data.length > 0,
|
|
414
|
-
matchedCount: result.data.length,
|
|
415
|
-
modifiedCount: result.data.length,
|
|
416
|
-
};
|
|
417
763
|
}
|
|
418
|
-
async
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
764
|
+
async shortestPath(options, transaction) {
|
|
765
|
+
var _a;
|
|
766
|
+
this.ensureConnected();
|
|
767
|
+
try {
|
|
768
|
+
const startId = String(options.startNodeId).includes('/')
|
|
769
|
+
? options.startNodeId
|
|
770
|
+
: await this.resolveNodeId(options.startNodeId);
|
|
771
|
+
const endId = String(options.endNodeId).includes('/')
|
|
772
|
+
? options.endNodeId
|
|
773
|
+
: await this.resolveNodeId(options.endNodeId);
|
|
774
|
+
const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
775
|
+
? options.relationshipTypes.join(', ')
|
|
776
|
+
: this.edgeCollections.join(', ');
|
|
777
|
+
let aql;
|
|
778
|
+
if (options.weightProperty) {
|
|
779
|
+
aql = `
|
|
780
|
+
FOR v, e IN OUTBOUND SHORTEST_PATH @start TO @end
|
|
781
|
+
${edgeCollections}
|
|
782
|
+
OPTIONS { weightAttribute: @weight }
|
|
783
|
+
RETURN { vertex: v, edge: e }
|
|
435
784
|
`;
|
|
436
785
|
}
|
|
437
786
|
else {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
787
|
+
aql = `
|
|
788
|
+
FOR v, e IN OUTBOUND SHORTEST_PATH @start TO @end
|
|
789
|
+
${edgeCollections}
|
|
790
|
+
RETURN { vertex: v, edge: e }
|
|
441
791
|
`;
|
|
442
792
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
450
|
-
|
|
451
|
-
filters.push(`@labels ALL IN doc._labels`);
|
|
452
|
-
params.labels = labels;
|
|
793
|
+
const cursor = await this.db.query(aql, {
|
|
794
|
+
start: startId,
|
|
795
|
+
end: endId,
|
|
796
|
+
weight: options.weightProperty,
|
|
797
|
+
});
|
|
798
|
+
const results = await cursor.all();
|
|
799
|
+
if (results.length === 0) {
|
|
800
|
+
return { path: null, length: -1, found: false };
|
|
453
801
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
802
|
+
const nodes = [];
|
|
803
|
+
const relationships = [];
|
|
804
|
+
for (const result of results) {
|
|
805
|
+
if (result.vertex) {
|
|
806
|
+
nodes.push({
|
|
807
|
+
id: result.vertex._key,
|
|
808
|
+
labels: result.vertex._labels || [result.vertex._id.split('/')[0]],
|
|
809
|
+
properties: this.cleanArangoProps(result.vertex),
|
|
810
|
+
elementId: result.vertex._id,
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
if (result.edge) {
|
|
814
|
+
relationships.push({
|
|
815
|
+
id: result.edge._key,
|
|
816
|
+
type: result.edge._id.split('/')[0],
|
|
817
|
+
startNodeId: result.edge._from,
|
|
818
|
+
endNodeId: result.edge._to,
|
|
819
|
+
properties: this.cleanArangoProps(result.edge),
|
|
820
|
+
elementId: result.edge._id,
|
|
821
|
+
});
|
|
822
|
+
}
|
|
457
823
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
RETURN 1
|
|
471
|
-
`;
|
|
472
|
-
params['@collection'] = this.defaultVertexCollection;
|
|
473
|
-
params['@edges'] = this.defaultEdgeCollection;
|
|
824
|
+
return {
|
|
825
|
+
path: {
|
|
826
|
+
nodes,
|
|
827
|
+
relationships,
|
|
828
|
+
length: relationships.length,
|
|
829
|
+
},
|
|
830
|
+
length: relationships.length,
|
|
831
|
+
found: true,
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
catch (error) {
|
|
835
|
+
throw graph_error_1.GraphError.queryError(`Failed to find shortest path: ${error.message}`);
|
|
474
836
|
}
|
|
475
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
476
|
-
return {
|
|
477
|
-
success: true,
|
|
478
|
-
executionTime: Date.now() - startTime,
|
|
479
|
-
deletedCount: result.data.length,
|
|
480
|
-
deletedRelationshipsCount: 0, // Could be calculated from detach query
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
async mergeNode(connection, options, transaction) {
|
|
484
|
-
var _a, _b;
|
|
485
|
-
const startTime = Date.now();
|
|
486
|
-
const labels = this.normalizeLabels(options.labels);
|
|
487
|
-
const collection = this.getVertexCollection(labels[0]);
|
|
488
|
-
// Build match filter
|
|
489
|
-
const matchFilters = [];
|
|
490
|
-
const params = { '@collection': collection };
|
|
491
|
-
matchFilters.push(`@labels ALL IN doc._labels`);
|
|
492
|
-
params.labels = labels;
|
|
493
|
-
Object.entries(options.matchProperties).forEach(([key, value], index) => {
|
|
494
|
-
const paramName = `match_${index}`;
|
|
495
|
-
matchFilters.push(`doc.${key} == @${paramName}`);
|
|
496
|
-
params[paramName] = value;
|
|
497
|
-
});
|
|
498
|
-
const onCreate = Object.assign(Object.assign(Object.assign({}, options.matchProperties), options.onCreate), { _labels: labels });
|
|
499
|
-
const onMatch = options.onMatch || {};
|
|
500
|
-
const query = `
|
|
501
|
-
UPSERT { ${Object.keys(options.matchProperties).map(k => `${k}: @match_${Object.keys(options.matchProperties).indexOf(k)}`).join(', ')}, _labels: @labels }
|
|
502
|
-
INSERT @onCreate
|
|
503
|
-
UPDATE @onMatch
|
|
504
|
-
IN @@collection
|
|
505
|
-
RETURN { doc: NEW, created: OLD ? false : true }
|
|
506
|
-
`;
|
|
507
|
-
params.onCreate = onCreate;
|
|
508
|
-
params.onMatch = onMatch;
|
|
509
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
510
|
-
return {
|
|
511
|
-
success: true,
|
|
512
|
-
executionTime: Date.now() - startTime,
|
|
513
|
-
node: result.data.length > 0 ? this.parseNode(result.data[0].doc) : undefined,
|
|
514
|
-
created: ((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.created) || false,
|
|
515
|
-
matched: !((_b = result.data[0]) === null || _b === void 0 ? void 0 : _b.created),
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
519
|
-
async createRelationship(connection, options, transaction) {
|
|
520
|
-
const startTime = Date.now();
|
|
521
|
-
const fromId = this.resolveNodeId(options.fromNode);
|
|
522
|
-
const toId = this.resolveNodeId(options.toNode);
|
|
523
|
-
const edge = Object.assign({ _from: fromId, _to: toId, _type: options.type }, options.properties);
|
|
524
|
-
const query = `
|
|
525
|
-
INSERT @edge INTO @@collection
|
|
526
|
-
RETURN NEW
|
|
527
|
-
`;
|
|
528
|
-
const result = await this.executeRaw(connection, {
|
|
529
|
-
query,
|
|
530
|
-
params: {
|
|
531
|
-
edge,
|
|
532
|
-
'@collection': this.defaultEdgeCollection,
|
|
533
|
-
},
|
|
534
|
-
}, transaction);
|
|
535
|
-
return {
|
|
536
|
-
success: true,
|
|
537
|
-
executionTime: Date.now() - startTime,
|
|
538
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0]) : undefined,
|
|
539
|
-
created: true,
|
|
540
|
-
};
|
|
541
837
|
}
|
|
542
|
-
async
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
838
|
+
async allPaths(options, transaction) {
|
|
839
|
+
var _a;
|
|
840
|
+
this.ensureConnected();
|
|
841
|
+
try {
|
|
842
|
+
const startId = String(options.startNodeId).includes('/')
|
|
843
|
+
? options.startNodeId
|
|
844
|
+
: await this.resolveNodeId(options.startNodeId);
|
|
845
|
+
const endId = String(options.endNodeId).includes('/')
|
|
846
|
+
? options.endNodeId
|
|
847
|
+
: await this.resolveNodeId(options.endNodeId);
|
|
848
|
+
const maxDepth = options.maxDepth || 5;
|
|
849
|
+
const maxPaths = options.maxPaths || options.limit || 10;
|
|
850
|
+
const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
851
|
+
? options.relationshipTypes.join(', ')
|
|
852
|
+
: this.edgeCollections.join(', ');
|
|
853
|
+
const aql = `
|
|
854
|
+
FOR p IN 1..@maxDepth OUTBOUND @start
|
|
855
|
+
${edgeCollections}
|
|
856
|
+
PRUNE p.vertices[-1]._id == @end
|
|
857
|
+
OPTIONS { bfs: false }
|
|
858
|
+
FILTER p.vertices[-1]._id == @end
|
|
859
|
+
LIMIT @maxPaths
|
|
860
|
+
RETURN p
|
|
861
|
+
`;
|
|
862
|
+
const cursor = await this.db.query(aql, {
|
|
863
|
+
start: startId,
|
|
864
|
+
end: endId,
|
|
865
|
+
maxDepth,
|
|
866
|
+
maxPaths,
|
|
565
867
|
});
|
|
868
|
+
const pathResults = await cursor.all();
|
|
869
|
+
const paths = pathResults.map((p) => {
|
|
870
|
+
const nodes = p.vertices.map((v) => ({
|
|
871
|
+
id: v._key,
|
|
872
|
+
labels: v._labels || [v._id.split('/')[0]],
|
|
873
|
+
properties: this.cleanArangoProps(v),
|
|
874
|
+
elementId: v._id,
|
|
875
|
+
}));
|
|
876
|
+
const relationships = p.edges.map((e) => ({
|
|
877
|
+
id: e._key,
|
|
878
|
+
type: e._id.split('/')[0],
|
|
879
|
+
startNodeId: e._from,
|
|
880
|
+
endNodeId: e._to,
|
|
881
|
+
properties: this.cleanArangoProps(e),
|
|
882
|
+
elementId: e._id,
|
|
883
|
+
}));
|
|
884
|
+
return { nodes, relationships, length: relationships.length };
|
|
885
|
+
});
|
|
886
|
+
return { paths, total: paths.length };
|
|
566
887
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
// ORDER BY
|
|
571
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
572
|
-
const sortParts = options.orderBy.map(o => `edge.${o.property} ${o.direction}`);
|
|
573
|
-
query += ` SORT ${sortParts.join(', ')}`;
|
|
574
|
-
}
|
|
575
|
-
// LIMIT
|
|
576
|
-
if (options.skip !== undefined || options.limit !== undefined) {
|
|
577
|
-
const skip = options.skip || 0;
|
|
578
|
-
const limit = options.limit || 100;
|
|
579
|
-
query += ` LIMIT ${skip}, ${limit}`;
|
|
888
|
+
catch (error) {
|
|
889
|
+
throw graph_error_1.GraphError.queryError(`Failed to find all paths: ${error.message}`);
|
|
580
890
|
}
|
|
581
|
-
query += ` RETURN edge`;
|
|
582
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
583
|
-
const relationships = result.data.map(doc => this.parseRelationship(doc));
|
|
584
|
-
return {
|
|
585
|
-
success: true,
|
|
586
|
-
executionTime: Date.now() - startTime,
|
|
587
|
-
relationships,
|
|
588
|
-
count: relationships.length,
|
|
589
|
-
hasMore: options.limit !== undefined && relationships.length === options.limit,
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
async findRelationshipById(connection, id, transaction) {
|
|
593
|
-
const query = `
|
|
594
|
-
FOR edge IN @@collection
|
|
595
|
-
FILTER edge._key == @id OR edge._id == @id
|
|
596
|
-
RETURN edge
|
|
597
|
-
`;
|
|
598
|
-
const result = await this.executeRaw(connection, {
|
|
599
|
-
query,
|
|
600
|
-
params: { id: String(id), '@collection': this.defaultEdgeCollection },
|
|
601
|
-
}, transaction);
|
|
602
|
-
if (result.data.length === 0) {
|
|
603
|
-
return null;
|
|
604
|
-
}
|
|
605
|
-
return this.parseRelationship(result.data[0]);
|
|
606
|
-
}
|
|
607
|
-
async updateRelationship(connection, options, transaction) {
|
|
608
|
-
const startTime = Date.now();
|
|
609
|
-
const query = `
|
|
610
|
-
UPDATE { _key: @id } WITH @updates IN @@collection
|
|
611
|
-
RETURN NEW
|
|
612
|
-
`;
|
|
613
|
-
const result = await this.executeRaw(connection, {
|
|
614
|
-
query,
|
|
615
|
-
params: {
|
|
616
|
-
id: String(options.id),
|
|
617
|
-
updates: options.set || {},
|
|
618
|
-
'@collection': this.defaultEdgeCollection,
|
|
619
|
-
},
|
|
620
|
-
}, transaction);
|
|
621
|
-
return {
|
|
622
|
-
success: true,
|
|
623
|
-
executionTime: Date.now() - startTime,
|
|
624
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0]) : undefined,
|
|
625
|
-
updated: result.data.length > 0,
|
|
626
|
-
matchedCount: result.data.length,
|
|
627
|
-
modifiedCount: result.data.length,
|
|
628
|
-
};
|
|
629
891
|
}
|
|
630
|
-
async
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
892
|
+
async getNeighborhood(options, transaction) {
|
|
893
|
+
var _a;
|
|
894
|
+
this.ensureConnected();
|
|
895
|
+
try {
|
|
896
|
+
const nodeId = String(options.nodeId).includes('/')
|
|
897
|
+
? options.nodeId
|
|
898
|
+
: await this.resolveNodeId(options.nodeId);
|
|
899
|
+
const direction = this.mapDirection(options.direction);
|
|
900
|
+
const depth = options.depth || 1;
|
|
901
|
+
const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
902
|
+
? options.relationshipTypes.join(', ')
|
|
903
|
+
: this.edgeCollections.join(', ');
|
|
904
|
+
let aql = `
|
|
905
|
+
FOR v, e IN 1..@depth ${direction} @start
|
|
906
|
+
${edgeCollections}
|
|
907
|
+
OPTIONS { uniqueVertices: 'global' }
|
|
638
908
|
`;
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
else {
|
|
642
|
-
const filters = [];
|
|
643
|
-
if (options.type) {
|
|
644
|
-
const types = Array.isArray(options.type) ? options.type : [options.type];
|
|
645
|
-
filters.push(`edge._type IN @types`);
|
|
646
|
-
params.types = types;
|
|
909
|
+
if (options.limit) {
|
|
910
|
+
aql += ` LIMIT @limit`;
|
|
647
911
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
912
|
+
aql += ` RETURN { vertex: v, edge: e }`;
|
|
913
|
+
const cursor = await this.db.query(aql, {
|
|
914
|
+
start: nodeId,
|
|
915
|
+
depth,
|
|
916
|
+
limit: options.limit,
|
|
917
|
+
});
|
|
918
|
+
const results = await cursor.all();
|
|
919
|
+
const nodesMap = new Map();
|
|
920
|
+
const relationshipsMap = new Map();
|
|
921
|
+
for (const result of results) {
|
|
922
|
+
if (result.vertex) {
|
|
923
|
+
nodesMap.set(result.vertex._id, {
|
|
924
|
+
id: result.vertex._key,
|
|
925
|
+
labels: result.vertex._labels || [result.vertex._id.split('/')[0]],
|
|
926
|
+
properties: this.cleanArangoProps(result.vertex),
|
|
927
|
+
elementId: result.vertex._id,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
if (result.edge) {
|
|
931
|
+
relationshipsMap.set(result.edge._id, {
|
|
932
|
+
id: result.edge._key,
|
|
933
|
+
type: result.edge._id.split('/')[0],
|
|
934
|
+
startNodeId: result.edge._from,
|
|
935
|
+
endNodeId: result.edge._to,
|
|
936
|
+
properties: this.cleanArangoProps(result.edge),
|
|
937
|
+
elementId: result.edge._id,
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return {
|
|
942
|
+
nodes: Array.from(nodesMap.values()),
|
|
943
|
+
relationships: Array.from(relationshipsMap.values()),
|
|
944
|
+
depth,
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
catch (error) {
|
|
948
|
+
throw graph_error_1.GraphError.queryError(`Failed to get neighborhood: ${error.message}`);
|
|
654
949
|
}
|
|
655
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
656
|
-
return {
|
|
657
|
-
success: true,
|
|
658
|
-
executionTime: Date.now() - startTime,
|
|
659
|
-
deletedCount: result.data.length,
|
|
660
|
-
};
|
|
661
950
|
}
|
|
662
|
-
async
|
|
663
|
-
|
|
664
|
-
const startTime = Date.now();
|
|
665
|
-
const fromId = this.resolveNodeId(options.fromNode);
|
|
666
|
-
const toId = this.resolveNodeId(options.toNode);
|
|
667
|
-
const matchDoc = Object.assign({ _from: fromId, _to: toId, _type: options.type }, options.matchProperties);
|
|
668
|
-
const insertDoc = Object.assign(Object.assign({}, matchDoc), options.onCreate);
|
|
669
|
-
const updateDoc = options.onMatch || {};
|
|
670
|
-
const query = `
|
|
671
|
-
UPSERT @matchDoc
|
|
672
|
-
INSERT @insertDoc
|
|
673
|
-
UPDATE @updateDoc
|
|
674
|
-
IN @@collection
|
|
675
|
-
RETURN { doc: NEW, created: OLD ? false : true }
|
|
676
|
-
`;
|
|
677
|
-
const result = await this.executeRaw(connection, {
|
|
678
|
-
query,
|
|
679
|
-
params: {
|
|
680
|
-
matchDoc,
|
|
681
|
-
insertDoc,
|
|
682
|
-
updateDoc,
|
|
683
|
-
'@collection': this.defaultEdgeCollection,
|
|
684
|
-
},
|
|
685
|
-
}, transaction);
|
|
686
|
-
return {
|
|
687
|
-
success: true,
|
|
688
|
-
executionTime: Date.now() - startTime,
|
|
689
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].doc) : undefined,
|
|
690
|
-
created: ((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.created) || false,
|
|
691
|
-
matched: !((_b = result.data[0]) === null || _b === void 0 ? void 0 : _b.created),
|
|
692
|
-
};
|
|
951
|
+
async findConnectedComponents(options, transaction) {
|
|
952
|
+
throw graph_error_1.GraphError.unsupportedOperationError('Connected components', 'ArangoDB (requires Pregel or SmartGraphs)');
|
|
693
953
|
}
|
|
694
|
-
// ====================
|
|
695
|
-
async
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
// In ArangoDB, you'd filter by edge type within the traversal
|
|
954
|
+
// ==================== AGGREGATION ====================
|
|
955
|
+
async countNodes(labels, where, transaction) {
|
|
956
|
+
this.ensureConnected();
|
|
957
|
+
try {
|
|
958
|
+
const collectionName = (labels === null || labels === void 0 ? void 0 : labels[0]) || this.vertexCollections[0];
|
|
959
|
+
let aql = 'RETURN LENGTH(FOR doc IN @@collection';
|
|
960
|
+
const bindVars = { '@collection': collectionName };
|
|
961
|
+
if (where) {
|
|
962
|
+
const { filterStr, filterVars } = this.buildArangoWhereClause(where, 'doc');
|
|
963
|
+
if (filterStr) {
|
|
964
|
+
aql += ` FILTER ${filterStr}`;
|
|
965
|
+
Object.assign(bindVars, filterVars);
|
|
966
|
+
}
|
|
708
967
|
}
|
|
968
|
+
aql += ' RETURN 1)';
|
|
969
|
+
const cursor = await this.db.query(aql, bindVars);
|
|
970
|
+
const [count] = await cursor.all();
|
|
971
|
+
return { count };
|
|
972
|
+
}
|
|
973
|
+
catch (error) {
|
|
974
|
+
throw graph_error_1.GraphError.queryError(`Failed to count nodes: ${error.message}`);
|
|
709
975
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
const relsMap = new Map();
|
|
724
|
-
const paths = [];
|
|
725
|
-
result.data.forEach(row => {
|
|
726
|
-
if (row.vertex) {
|
|
727
|
-
const node = this.parseNode(row.vertex);
|
|
728
|
-
nodesMap.set(String(node.id), node);
|
|
976
|
+
}
|
|
977
|
+
async countRelationships(types, where, transaction) {
|
|
978
|
+
this.ensureConnected();
|
|
979
|
+
try {
|
|
980
|
+
const collectionName = (types === null || types === void 0 ? void 0 : types[0]) || this.edgeCollections[0];
|
|
981
|
+
let aql = 'RETURN LENGTH(FOR edge IN @@collection';
|
|
982
|
+
const bindVars = { '@collection': collectionName };
|
|
983
|
+
if (where) {
|
|
984
|
+
const { filterStr, filterVars } = this.buildArangoWhereClause(where, 'edge');
|
|
985
|
+
if (filterStr) {
|
|
986
|
+
aql += ` FILTER ${filterStr}`;
|
|
987
|
+
Object.assign(bindVars, filterVars);
|
|
988
|
+
}
|
|
729
989
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
990
|
+
aql += ' RETURN 1)';
|
|
991
|
+
const cursor = await this.db.query(aql, bindVars);
|
|
992
|
+
const [count] = await cursor.all();
|
|
993
|
+
return { count };
|
|
994
|
+
}
|
|
995
|
+
catch (error) {
|
|
996
|
+
throw graph_error_1.GraphError.queryError(`Failed to count relationships: ${error.message}`);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
async getStatistics(transaction) {
|
|
1000
|
+
this.ensureConnected();
|
|
1001
|
+
try {
|
|
1002
|
+
let nodeCount = 0;
|
|
1003
|
+
let relationshipCount = 0;
|
|
1004
|
+
const nodesByLabel = {};
|
|
1005
|
+
const relationshipsByType = {};
|
|
1006
|
+
for (const collName of this.vertexCollections) {
|
|
1007
|
+
const cursor = await this.db.query('RETURN LENGTH(FOR doc IN @@collection RETURN 1)', { '@collection': collName });
|
|
1008
|
+
const [count] = await cursor.all();
|
|
1009
|
+
nodesByLabel[collName] = count;
|
|
1010
|
+
nodeCount += count;
|
|
733
1011
|
}
|
|
734
|
-
|
|
735
|
-
|
|
1012
|
+
for (const collName of this.edgeCollections) {
|
|
1013
|
+
const cursor = await this.db.query('RETURN LENGTH(FOR edge IN @@collection RETURN 1)', { '@collection': collName });
|
|
1014
|
+
const [count] = await cursor.all();
|
|
1015
|
+
relationshipsByType[collName] = count;
|
|
1016
|
+
relationshipCount += count;
|
|
736
1017
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1018
|
+
return {
|
|
1019
|
+
nodeCount,
|
|
1020
|
+
relationshipCount,
|
|
1021
|
+
nodesByLabel,
|
|
1022
|
+
relationshipsByType,
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
catch (error) {
|
|
1026
|
+
throw graph_error_1.GraphError.queryError(`Failed to get statistics: ${error.message}`);
|
|
1027
|
+
}
|
|
746
1028
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
FOR path IN ${direction} SHORTEST_PATH @startId TO @endId
|
|
758
|
-
GRAPH @graphName
|
|
759
|
-
OPTIONS { weightAttribute: @weightProp }
|
|
760
|
-
RETURN path
|
|
1029
|
+
// ==================== SEARCH ====================
|
|
1030
|
+
async fullTextSearch(options, transaction) {
|
|
1031
|
+
this.ensureConnected();
|
|
1032
|
+
try {
|
|
1033
|
+
const aql = `
|
|
1034
|
+
FOR doc IN ${options.indexName}
|
|
1035
|
+
SEARCH ANALYZER(doc.content IN TOKENS(@query, 'text_en'), 'text_en')
|
|
1036
|
+
SORT BM25(doc) DESC
|
|
1037
|
+
LIMIT @limit
|
|
1038
|
+
RETURN doc
|
|
761
1039
|
`;
|
|
1040
|
+
const cursor = await this.db.query(aql, {
|
|
1041
|
+
query: options.query,
|
|
1042
|
+
limit: options.limit || 10,
|
|
1043
|
+
});
|
|
1044
|
+
const results = await cursor.all();
|
|
1045
|
+
return {
|
|
1046
|
+
nodes: results.map((doc) => ({
|
|
1047
|
+
id: doc._key,
|
|
1048
|
+
labels: doc._labels || [doc._id.split('/')[0]],
|
|
1049
|
+
properties: this.cleanArangoProps(doc),
|
|
1050
|
+
elementId: doc._id,
|
|
1051
|
+
})),
|
|
1052
|
+
};
|
|
762
1053
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
FOR path IN ${direction} SHORTEST_PATH @startId TO @endId
|
|
766
|
-
GRAPH @graphName
|
|
767
|
-
RETURN path
|
|
768
|
-
`;
|
|
1054
|
+
catch (error) {
|
|
1055
|
+
throw graph_error_1.GraphError.queryError(`Failed to perform full-text search: ${error.message}`);
|
|
769
1056
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}, transaction);
|
|
781
|
-
if (result.data.length === 0 || !result.data[0]) {
|
|
1057
|
+
}
|
|
1058
|
+
async vectorSearch(options, transaction) {
|
|
1059
|
+
throw graph_error_1.GraphError.unsupportedOperationError('Vector search', 'ArangoDB');
|
|
1060
|
+
}
|
|
1061
|
+
// ==================== RAW QUERY ====================
|
|
1062
|
+
async query(options, transaction) {
|
|
1063
|
+
this.ensureConnected();
|
|
1064
|
+
try {
|
|
1065
|
+
const cursor = await this.db.query(options.query, options.params || {});
|
|
1066
|
+
const records = await cursor.all();
|
|
782
1067
|
return {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
1068
|
+
records: records,
|
|
1069
|
+
summary: {
|
|
1070
|
+
database: this.db.name,
|
|
1071
|
+
},
|
|
786
1072
|
};
|
|
787
1073
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
executionTime: Date.now() - startTime,
|
|
792
|
-
path,
|
|
793
|
-
found: true,
|
|
794
|
-
length: path.length,
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
async allPaths(connection, options, transaction) {
|
|
798
|
-
const startTime = Date.now();
|
|
799
|
-
const startId = this.resolveNodeId(options.startNode);
|
|
800
|
-
const endId = this.resolveNodeId(options.endNode);
|
|
801
|
-
const minDepth = options.minDepth || 1;
|
|
802
|
-
const maxDepth = options.maxDepth || 10;
|
|
803
|
-
const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'INBOUND' :
|
|
804
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'OUTBOUND' : 'ANY';
|
|
805
|
-
const query = `
|
|
806
|
-
FOR vertex, edge, path IN ${minDepth}..${maxDepth} ${direction} @startId
|
|
807
|
-
GRAPH @graphName
|
|
808
|
-
FILTER vertex._id == @endId
|
|
809
|
-
${options.limit ? `LIMIT ${options.limit}` : ''}
|
|
810
|
-
RETURN path
|
|
811
|
-
`;
|
|
812
|
-
const arangoConn = connection;
|
|
813
|
-
const graphName = arangoConn.getGraphName() || 'defaultGraph';
|
|
814
|
-
const result = await this.executeRaw(connection, {
|
|
815
|
-
query,
|
|
816
|
-
params: { startId, endId, graphName },
|
|
817
|
-
}, transaction);
|
|
818
|
-
const paths = result.data.map(p => this.parsePath(p));
|
|
819
|
-
return {
|
|
820
|
-
success: true,
|
|
821
|
-
executionTime: Date.now() - startTime,
|
|
822
|
-
paths,
|
|
823
|
-
count: paths.length,
|
|
824
|
-
};
|
|
1074
|
+
catch (error) {
|
|
1075
|
+
throw graph_error_1.GraphError.queryError(`Failed to execute query: ${error.message}`);
|
|
1076
|
+
}
|
|
825
1077
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
params[`labels_${index}`] = labels;
|
|
1078
|
+
// ==================== SCHEMA ====================
|
|
1079
|
+
async createNodeIndex(options) {
|
|
1080
|
+
var _a, _b;
|
|
1081
|
+
this.ensureConnected();
|
|
1082
|
+
try {
|
|
1083
|
+
const collection = this.db.collection(options.label);
|
|
1084
|
+
const indexOptions = {
|
|
1085
|
+
type: this.mapIndexType(options.type),
|
|
1086
|
+
fields: options.properties,
|
|
1087
|
+
name: options.name,
|
|
1088
|
+
};
|
|
1089
|
+
if (((_a = options.options) === null || _a === void 0 ? void 0 : _a.sparse) !== undefined) {
|
|
1090
|
+
indexOptions.sparse = options.options.sparse;
|
|
840
1091
|
}
|
|
841
|
-
if (
|
|
842
|
-
|
|
843
|
-
const paramName = `node_${index}_prop_${propIndex}`;
|
|
844
|
-
filters.push(`${node.variable}.${key} == @${paramName}`);
|
|
845
|
-
params[paramName] = value;
|
|
846
|
-
});
|
|
1092
|
+
if (((_b = options.options) === null || _b === void 0 ? void 0 : _b.unique) !== undefined) {
|
|
1093
|
+
indexOptions.unique = options.options.unique;
|
|
847
1094
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
const edgeVar = rel.variable || `_edge_${index}`;
|
|
854
|
-
filters.push(`${edgeVar}._from == ${rel.startNode}._id`);
|
|
855
|
-
filters.push(`${edgeVar}._to == ${rel.endNode}._id`);
|
|
856
|
-
if (rel.type) {
|
|
857
|
-
const types = Array.isArray(rel.type) ? rel.type : [rel.type];
|
|
858
|
-
filters.push(`${edgeVar}._type IN @relTypes_${index}`);
|
|
859
|
-
params[`relTypes_${index}`] = types;
|
|
860
|
-
}
|
|
861
|
-
});
|
|
862
|
-
const returnVars = options.return || pattern.nodes.map(n => n.variable);
|
|
863
|
-
let query = forClauses.join('\n');
|
|
864
|
-
if (filters.length > 0) {
|
|
865
|
-
query += `\nFILTER ${filters.join(' AND ')}`;
|
|
1095
|
+
const result = await collection.ensureIndex(indexOptions);
|
|
1096
|
+
return {
|
|
1097
|
+
created: result.isNewlyCreated,
|
|
1098
|
+
name: result.name,
|
|
1099
|
+
};
|
|
866
1100
|
}
|
|
867
|
-
|
|
868
|
-
|
|
1101
|
+
catch (error) {
|
|
1102
|
+
throw graph_error_1.GraphError.queryError(`Failed to create index: ${error.message}`);
|
|
869
1103
|
}
|
|
870
|
-
query += `\nRETURN { ${returnVars.map(v => `${v}: ${v}`).join(', ')} }`;
|
|
871
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
872
|
-
return {
|
|
873
|
-
success: true,
|
|
874
|
-
executionTime: Date.now() - startTime,
|
|
875
|
-
matches: result.data,
|
|
876
|
-
count: result.data.length,
|
|
877
|
-
hasMore: options.limit !== undefined && result.data.length === options.limit,
|
|
878
|
-
};
|
|
879
1104
|
}
|
|
880
|
-
async
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
GRAPH @graphName
|
|
899
|
-
RETURN DISTINCT edge
|
|
900
|
-
)
|
|
901
|
-
RETURN { nodes: subgraphNodes, edges: subgraphEdges }
|
|
902
|
-
`;
|
|
903
|
-
const arangoConn = connection;
|
|
904
|
-
const graphName = arangoConn.getGraphName() || 'defaultGraph';
|
|
905
|
-
const result = await this.executeRaw(connection, {
|
|
906
|
-
query,
|
|
907
|
-
params: { startIds, maxDepth, graphName },
|
|
908
|
-
}, transaction);
|
|
909
|
-
const nodes = [];
|
|
910
|
-
const relationships = [];
|
|
911
|
-
if (result.data.length > 0) {
|
|
912
|
-
const row = result.data[0];
|
|
913
|
-
if (row.nodes) {
|
|
914
|
-
row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
|
|
915
|
-
}
|
|
916
|
-
if (row.edges) {
|
|
917
|
-
row.edges.filter((e) => e).forEach((e) => relationships.push(this.parseRelationship(e)));
|
|
918
|
-
}
|
|
1105
|
+
async createNodeConstraint(options) {
|
|
1106
|
+
this.ensureConnected();
|
|
1107
|
+
try {
|
|
1108
|
+
const collection = this.db.collection(options.label);
|
|
1109
|
+
const fields = options.properties || (options.property ? [options.property] : []);
|
|
1110
|
+
const result = await collection.ensureIndex({
|
|
1111
|
+
type: 'persistent',
|
|
1112
|
+
fields,
|
|
1113
|
+
name: options.name,
|
|
1114
|
+
unique: true,
|
|
1115
|
+
});
|
|
1116
|
+
return {
|
|
1117
|
+
created: result.isNewlyCreated,
|
|
1118
|
+
name: result.name,
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
catch (error) {
|
|
1122
|
+
throw graph_error_1.GraphError.queryError(`Failed to create constraint: ${error.message}`);
|
|
919
1123
|
}
|
|
920
|
-
return {
|
|
921
|
-
success: true,
|
|
922
|
-
executionTime: Date.now() - startTime,
|
|
923
|
-
subgraph: {
|
|
924
|
-
nodes,
|
|
925
|
-
relationships,
|
|
926
|
-
nodeCount: nodes.length,
|
|
927
|
-
relationshipCount: relationships.length,
|
|
928
|
-
},
|
|
929
|
-
};
|
|
930
1124
|
}
|
|
931
|
-
async
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
options.
|
|
937
|
-
const query = `
|
|
938
|
-
FOR vertex, edge IN 0..@depth ${direction} @nodeId
|
|
939
|
-
GRAPH @graphName
|
|
940
|
-
RETURN { vertex, edge }
|
|
941
|
-
`;
|
|
942
|
-
const arangoConn = connection;
|
|
943
|
-
const graphName = arangoConn.getGraphName() || 'defaultGraph';
|
|
944
|
-
const result = await this.executeRaw(connection, {
|
|
945
|
-
query,
|
|
946
|
-
params: { nodeId, depth, graphName },
|
|
947
|
-
}, transaction);
|
|
948
|
-
const nodesMap = new Map();
|
|
949
|
-
const relsMap = new Map();
|
|
950
|
-
result.data.forEach(row => {
|
|
951
|
-
if (row.vertex) {
|
|
952
|
-
const node = this.parseNode(row.vertex);
|
|
953
|
-
nodesMap.set(String(node.id), node);
|
|
954
|
-
}
|
|
955
|
-
if (row.edge) {
|
|
956
|
-
const rel = this.parseRelationship(row.edge);
|
|
957
|
-
relsMap.set(String(rel.id), rel);
|
|
958
|
-
}
|
|
1125
|
+
async createRelationshipIndex(options) {
|
|
1126
|
+
return this.createNodeIndex({
|
|
1127
|
+
label: options.type,
|
|
1128
|
+
properties: options.properties,
|
|
1129
|
+
name: options.name,
|
|
1130
|
+
type: options.type,
|
|
959
1131
|
});
|
|
960
|
-
return {
|
|
961
|
-
success: true,
|
|
962
|
-
executionTime: Date.now() - startTime,
|
|
963
|
-
nodes: Array.from(nodesMap.values()),
|
|
964
|
-
relationships: Array.from(relsMap.values()),
|
|
965
|
-
levels: new Map(),
|
|
966
|
-
};
|
|
967
1132
|
}
|
|
968
|
-
async
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
Object.entries(where).forEach(([key, value], index) => {
|
|
987
|
-
const paramName = `where_${index}`;
|
|
988
|
-
filters.push(`doc.${key} == @${paramName}`);
|
|
989
|
-
params[paramName] = value;
|
|
990
|
-
});
|
|
1133
|
+
async listIndexes() {
|
|
1134
|
+
this.ensureConnected();
|
|
1135
|
+
try {
|
|
1136
|
+
const indexes = [];
|
|
1137
|
+
for (const collName of [...this.vertexCollections, ...this.edgeCollections]) {
|
|
1138
|
+
const collection = this.db.collection(collName);
|
|
1139
|
+
const collIndexes = await collection.indexes();
|
|
1140
|
+
for (const idx of collIndexes) {
|
|
1141
|
+
indexes.push({
|
|
1142
|
+
name: idx.name,
|
|
1143
|
+
labelOrType: collName,
|
|
1144
|
+
properties: idx.fields || [],
|
|
1145
|
+
type: idx.type,
|
|
1146
|
+
unique: idx.unique || false,
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return { indexes };
|
|
991
1151
|
}
|
|
992
|
-
|
|
993
|
-
|
|
1152
|
+
catch (error) {
|
|
1153
|
+
throw graph_error_1.GraphError.queryError(`Failed to list indexes: ${error.message}`);
|
|
994
1154
|
}
|
|
995
|
-
query += ` RETURN 1)`;
|
|
996
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
997
|
-
return {
|
|
998
|
-
success: true,
|
|
999
|
-
executionTime: Date.now() - startTime,
|
|
1000
|
-
count: result.data[0] || 0,
|
|
1001
|
-
};
|
|
1002
1155
|
}
|
|
1003
|
-
async
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1156
|
+
async listConstraints() {
|
|
1157
|
+
this.ensureConnected();
|
|
1158
|
+
try {
|
|
1159
|
+
const constraints = [];
|
|
1160
|
+
for (const collName of this.vertexCollections) {
|
|
1161
|
+
const collection = this.db.collection(collName);
|
|
1162
|
+
const indexes = await collection.indexes();
|
|
1163
|
+
for (const idx of indexes) {
|
|
1164
|
+
if (idx.unique) {
|
|
1165
|
+
constraints.push({
|
|
1166
|
+
name: idx.name,
|
|
1167
|
+
label: collName,
|
|
1168
|
+
property: (idx.fields || [])[0] || '',
|
|
1169
|
+
type: 'UNIQUE',
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
return { constraints };
|
|
1019
1175
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1176
|
+
catch (error) {
|
|
1177
|
+
throw graph_error_1.GraphError.queryError(`Failed to list constraints: ${error.message}`);
|
|
1022
1178
|
}
|
|
1023
|
-
query += ` RETURN 1)`;
|
|
1024
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
1025
|
-
return {
|
|
1026
|
-
success: true,
|
|
1027
|
-
executionTime: Date.now() - startTime,
|
|
1028
|
-
count: result.data[0] || 0,
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
async getStatistics(connection, transaction) {
|
|
1032
|
-
const startTime = Date.now();
|
|
1033
|
-
const nodeCountResult = await this.countNodes(connection, undefined, undefined, transaction);
|
|
1034
|
-
const relCountResult = await this.countRelationships(connection, undefined, undefined, transaction);
|
|
1035
|
-
return {
|
|
1036
|
-
success: true,
|
|
1037
|
-
executionTime: Date.now() - startTime,
|
|
1038
|
-
nodeCount: nodeCountResult.count,
|
|
1039
|
-
relationshipCount: relCountResult.count,
|
|
1040
|
-
labelCounts: {},
|
|
1041
|
-
relationshipTypeCounts: {},
|
|
1042
|
-
};
|
|
1043
1179
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
query,
|
|
1057
|
-
params: {
|
|
1058
|
-
'@view': `${this.defaultVertexCollection}_search`,
|
|
1059
|
-
searchQuery: options.query,
|
|
1060
|
-
labels: options.labels || [],
|
|
1061
|
-
},
|
|
1062
|
-
}, transaction);
|
|
1063
|
-
const nodes = result.data.map(doc => {
|
|
1064
|
-
const node = this.parseNode(doc);
|
|
1065
|
-
if (options.score && doc.score !== undefined) {
|
|
1066
|
-
return Object.assign(Object.assign({}, node), { score: doc.score });
|
|
1180
|
+
async dropIndex(name) {
|
|
1181
|
+
this.ensureConnected();
|
|
1182
|
+
try {
|
|
1183
|
+
for (const collName of [...this.vertexCollections, ...this.edgeCollections]) {
|
|
1184
|
+
const collection = this.db.collection(collName);
|
|
1185
|
+
try {
|
|
1186
|
+
await collection.dropIndex(name);
|
|
1187
|
+
return { dropped: true };
|
|
1188
|
+
}
|
|
1189
|
+
catch (_a) {
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1067
1192
|
}
|
|
1068
|
-
return
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
nodes,
|
|
1074
|
-
count: nodes.length,
|
|
1075
|
-
};
|
|
1193
|
+
return { dropped: false };
|
|
1194
|
+
}
|
|
1195
|
+
catch (error) {
|
|
1196
|
+
throw graph_error_1.GraphError.queryError(`Failed to drop index: ${error.message}`);
|
|
1197
|
+
}
|
|
1076
1198
|
}
|
|
1077
|
-
async
|
|
1078
|
-
|
|
1079
|
-
|
|
1199
|
+
async dropConstraint(name) {
|
|
1200
|
+
const result = await this.dropIndex(name);
|
|
1201
|
+
return { dropped: result.dropped };
|
|
1202
|
+
}
|
|
1203
|
+
// ==================== SCHEMA INTROSPECTION ====================
|
|
1204
|
+
async listLabels() {
|
|
1205
|
+
this.ensureConnected();
|
|
1206
|
+
const labels = [];
|
|
1207
|
+
// In ArangoDB, vertex collections act as "labels"
|
|
1208
|
+
for (const collectionName of this.vertexCollections) {
|
|
1209
|
+
try {
|
|
1210
|
+
const collection = this.db.collection(collectionName);
|
|
1211
|
+
// Get count
|
|
1212
|
+
const countResult = await collection.count();
|
|
1213
|
+
const count = countResult.count || 0;
|
|
1214
|
+
// Get properties from a sample of documents
|
|
1215
|
+
const cursor = await this.db.query(`
|
|
1216
|
+
FOR doc IN \`${collectionName}\`
|
|
1217
|
+
LIMIT 100
|
|
1218
|
+
RETURN ATTRIBUTES(doc, true)
|
|
1219
|
+
`);
|
|
1220
|
+
const attributeArrays = await cursor.all();
|
|
1221
|
+
// Flatten and dedupe property names
|
|
1222
|
+
const propertyNames = new Set();
|
|
1223
|
+
for (const attrs of attributeArrays) {
|
|
1224
|
+
for (const attr of attrs) {
|
|
1225
|
+
if (attr !== '_key' && attr !== '_id' && attr !== '_rev') {
|
|
1226
|
+
propertyNames.add(attr);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
const properties = Array.from(propertyNames).map(name => ({
|
|
1231
|
+
name,
|
|
1232
|
+
type: 'unknown',
|
|
1233
|
+
}));
|
|
1234
|
+
labels.push({
|
|
1235
|
+
name: collectionName,
|
|
1236
|
+
count,
|
|
1237
|
+
properties,
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
catch (error) {
|
|
1241
|
+
// Skip collections that don't exist or have errors
|
|
1242
|
+
continue;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return { labels };
|
|
1246
|
+
}
|
|
1247
|
+
async listRelationshipTypes() {
|
|
1248
|
+
this.ensureConnected();
|
|
1249
|
+
const types = [];
|
|
1250
|
+
// In ArangoDB, edge collections act as "relationship types"
|
|
1251
|
+
for (const collectionName of this.edgeCollections) {
|
|
1252
|
+
try {
|
|
1253
|
+
const collection = this.db.collection(collectionName);
|
|
1254
|
+
// Get count
|
|
1255
|
+
const countResult = await collection.count();
|
|
1256
|
+
const count = countResult.count || 0;
|
|
1257
|
+
// Get source and target collection information
|
|
1258
|
+
const endpointsCursor = await this.db.query(`
|
|
1259
|
+
FOR edge IN \`${collectionName}\`
|
|
1260
|
+
LIMIT 100
|
|
1261
|
+
RETURN {
|
|
1262
|
+
fromCollection: PARSE_IDENTIFIER(edge._from).collection,
|
|
1263
|
+
toCollection: PARSE_IDENTIFIER(edge._to).collection
|
|
1264
|
+
}
|
|
1265
|
+
`);
|
|
1266
|
+
const endpoints = await endpointsCursor.all();
|
|
1267
|
+
const fromLabelsSet = new Set();
|
|
1268
|
+
const toLabelsSet = new Set();
|
|
1269
|
+
for (const ep of endpoints) {
|
|
1270
|
+
if (ep.fromCollection)
|
|
1271
|
+
fromLabelsSet.add(ep.fromCollection);
|
|
1272
|
+
if (ep.toCollection)
|
|
1273
|
+
toLabelsSet.add(ep.toCollection);
|
|
1274
|
+
}
|
|
1275
|
+
// Get properties from a sample of edges
|
|
1276
|
+
const propsCursor = await this.db.query(`
|
|
1277
|
+
FOR edge IN \`${collectionName}\`
|
|
1278
|
+
LIMIT 100
|
|
1279
|
+
RETURN ATTRIBUTES(edge, true)
|
|
1280
|
+
`);
|
|
1281
|
+
const attributeArrays = await propsCursor.all();
|
|
1282
|
+
const propertyNames = new Set();
|
|
1283
|
+
for (const attrs of attributeArrays) {
|
|
1284
|
+
for (const attr of attrs) {
|
|
1285
|
+
if (!['_key', '_id', '_rev', '_from', '_to'].includes(attr)) {
|
|
1286
|
+
propertyNames.add(attr);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
const properties = Array.from(propertyNames).map(name => ({
|
|
1291
|
+
name,
|
|
1292
|
+
type: 'unknown',
|
|
1293
|
+
}));
|
|
1294
|
+
types.push({
|
|
1295
|
+
type: collectionName,
|
|
1296
|
+
count,
|
|
1297
|
+
fromLabels: Array.from(fromLabelsSet),
|
|
1298
|
+
toLabels: Array.from(toLabelsSet),
|
|
1299
|
+
properties: properties.length > 0 ? properties : undefined,
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
catch (error) {
|
|
1303
|
+
// Skip collections that don't exist or have errors
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return { types };
|
|
1080
1308
|
}
|
|
1081
|
-
// ====================
|
|
1082
|
-
async
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
if (constraint.type === node_types_1.NodeConstraintType.UNIQUE) {
|
|
1089
|
-
await coll.ensureIndex({
|
|
1090
|
-
type: 'persistent',
|
|
1091
|
-
fields: constraint.properties,
|
|
1092
|
-
unique: true,
|
|
1093
|
-
name: constraint.name,
|
|
1309
|
+
// ==================== TRANSACTIONS ====================
|
|
1310
|
+
async beginTransaction() {
|
|
1311
|
+
this.ensureConnected();
|
|
1312
|
+
try {
|
|
1313
|
+
const trx = await this.db.beginTransaction({
|
|
1314
|
+
write: [...this.vertexCollections, ...this.edgeCollections],
|
|
1315
|
+
read: [...this.vertexCollections, ...this.edgeCollections],
|
|
1094
1316
|
});
|
|
1317
|
+
return {
|
|
1318
|
+
id: trx.id,
|
|
1319
|
+
status: enums_1.GraphTransactionStatus.ACTIVE,
|
|
1320
|
+
startTime: new Date(),
|
|
1321
|
+
nativeTransaction: trx,
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
catch (error) {
|
|
1325
|
+
throw graph_error_1.GraphError.transactionError(`Failed to begin transaction: ${error.message}`);
|
|
1095
1326
|
}
|
|
1096
|
-
return {
|
|
1097
|
-
success: true,
|
|
1098
|
-
executionTime: Date.now() - startTime,
|
|
1099
|
-
name: constraint.name,
|
|
1100
|
-
created: true,
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
async createRelationshipConstraint(connection, constraint, transaction) {
|
|
1104
|
-
const startTime = Date.now();
|
|
1105
|
-
const db = connection.getClient();
|
|
1106
|
-
const coll = db.collection(this.defaultEdgeCollection);
|
|
1107
|
-
await coll.ensureIndex({
|
|
1108
|
-
type: 'persistent',
|
|
1109
|
-
fields: constraint.properties,
|
|
1110
|
-
unique: true,
|
|
1111
|
-
name: constraint.name,
|
|
1112
|
-
});
|
|
1113
|
-
return {
|
|
1114
|
-
success: true,
|
|
1115
|
-
executionTime: Date.now() - startTime,
|
|
1116
|
-
name: constraint.name,
|
|
1117
|
-
created: true,
|
|
1118
|
-
};
|
|
1119
1327
|
}
|
|
1120
|
-
async
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
executionTime: Date.now() - startTime,
|
|
1129
|
-
name,
|
|
1130
|
-
dropped: true,
|
|
1131
|
-
};
|
|
1328
|
+
async commitTransaction(transaction) {
|
|
1329
|
+
try {
|
|
1330
|
+
await transaction.nativeTransaction.commit();
|
|
1331
|
+
transaction.status = enums_1.GraphTransactionStatus.COMMITTED;
|
|
1332
|
+
}
|
|
1333
|
+
catch (error) {
|
|
1334
|
+
throw graph_error_1.GraphError.transactionError(`Failed to commit transaction: ${error.message}`);
|
|
1335
|
+
}
|
|
1132
1336
|
}
|
|
1133
|
-
async
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
.
|
|
1140
|
-
|
|
1141
|
-
name: idx.name,
|
|
1142
|
-
type: 'UNIQUE',
|
|
1143
|
-
entityType: 'NODE',
|
|
1144
|
-
labelsOrTypes: [],
|
|
1145
|
-
properties: idx.fields,
|
|
1146
|
-
}));
|
|
1147
|
-
return {
|
|
1148
|
-
success: true,
|
|
1149
|
-
executionTime: Date.now() - startTime,
|
|
1150
|
-
constraints,
|
|
1151
|
-
};
|
|
1337
|
+
async rollbackTransaction(transaction) {
|
|
1338
|
+
try {
|
|
1339
|
+
await transaction.nativeTransaction.abort();
|
|
1340
|
+
transaction.status = enums_1.GraphTransactionStatus.ROLLED_BACK;
|
|
1341
|
+
}
|
|
1342
|
+
catch (error) {
|
|
1343
|
+
throw graph_error_1.GraphError.transactionError(`Failed to rollback transaction: ${error.message}`);
|
|
1344
|
+
}
|
|
1152
1345
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
case node_types_1.NodeIndexType.FULLTEXT:
|
|
1165
|
-
indexType = 'fulltext';
|
|
1166
|
-
break;
|
|
1167
|
-
case node_types_1.NodeIndexType.POINT:
|
|
1168
|
-
indexType = 'geo';
|
|
1169
|
-
break;
|
|
1346
|
+
// ==================== HELPERS ====================
|
|
1347
|
+
mapDirection(direction) {
|
|
1348
|
+
switch (direction) {
|
|
1349
|
+
case enums_1.TraversalDirection.OUTGOING:
|
|
1350
|
+
case 'OUTGOING':
|
|
1351
|
+
return 'OUTBOUND';
|
|
1352
|
+
case enums_1.TraversalDirection.INCOMING:
|
|
1353
|
+
case 'INCOMING':
|
|
1354
|
+
return 'INBOUND';
|
|
1355
|
+
case enums_1.TraversalDirection.BOTH:
|
|
1356
|
+
case 'BOTH':
|
|
1170
1357
|
default:
|
|
1171
|
-
|
|
1358
|
+
return 'ANY';
|
|
1172
1359
|
}
|
|
1173
|
-
options.type = indexType;
|
|
1174
|
-
await coll.ensureIndex(options);
|
|
1175
|
-
return {
|
|
1176
|
-
success: true,
|
|
1177
|
-
executionTime: Date.now() - startTime,
|
|
1178
|
-
name: index.name,
|
|
1179
|
-
created: true,
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
async createRelationshipIndex(connection, index, transaction) {
|
|
1183
|
-
const startTime = Date.now();
|
|
1184
|
-
const db = connection.getClient();
|
|
1185
|
-
const coll = db.collection(this.defaultEdgeCollection);
|
|
1186
|
-
await coll.ensureIndex({
|
|
1187
|
-
type: 'persistent',
|
|
1188
|
-
fields: index.properties,
|
|
1189
|
-
name: index.name,
|
|
1190
|
-
});
|
|
1191
|
-
return {
|
|
1192
|
-
success: true,
|
|
1193
|
-
executionTime: Date.now() - startTime,
|
|
1194
|
-
name: index.name,
|
|
1195
|
-
created: true,
|
|
1196
|
-
};
|
|
1197
1360
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
}
|
|
1210
|
-
async listIndexes(connection, transaction) {
|
|
1211
|
-
const startTime = Date.now();
|
|
1212
|
-
const db = connection.getClient();
|
|
1213
|
-
const coll = db.collection(this.defaultVertexCollection);
|
|
1214
|
-
const indexes = await coll.indexes();
|
|
1215
|
-
const indexList = indexes.map((idx) => ({
|
|
1216
|
-
name: idx.name,
|
|
1217
|
-
type: idx.type,
|
|
1218
|
-
entityType: 'NODE',
|
|
1219
|
-
labelsOrTypes: [],
|
|
1220
|
-
properties: idx.fields,
|
|
1221
|
-
state: 'ONLINE',
|
|
1222
|
-
uniqueness: idx.unique ? 'UNIQUE' : 'NONUNIQUE',
|
|
1223
|
-
}));
|
|
1224
|
-
return {
|
|
1225
|
-
success: true,
|
|
1226
|
-
executionTime: Date.now() - startTime,
|
|
1227
|
-
indexes: indexList,
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
// ==================== UTILITY METHODS ====================
|
|
1231
|
-
escapeIdentifier(identifier) {
|
|
1232
|
-
return identifier.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
1233
|
-
}
|
|
1234
|
-
escapeValue(value) {
|
|
1235
|
-
if (value === null)
|
|
1236
|
-
return 'null';
|
|
1237
|
-
if (typeof value === 'string')
|
|
1238
|
-
return `"${value.replace(/"/g, '\\"')}"`;
|
|
1239
|
-
if (typeof value === 'number')
|
|
1240
|
-
return String(value);
|
|
1241
|
-
if (typeof value === 'boolean')
|
|
1242
|
-
return value ? 'true' : 'false';
|
|
1243
|
-
if (value instanceof Date)
|
|
1244
|
-
return `"${value.toISOString()}"`;
|
|
1245
|
-
if (Array.isArray(value))
|
|
1246
|
-
return `[${value.map(v => this.escapeValue(v)).join(', ')}]`;
|
|
1247
|
-
return JSON.stringify(value);
|
|
1248
|
-
}
|
|
1249
|
-
buildWhereClause(where, variableName = 'doc') {
|
|
1250
|
-
const params = {};
|
|
1251
|
-
const parts = [];
|
|
1252
|
-
Object.entries(where).forEach(([key, value], index) => {
|
|
1253
|
-
const paramName = `where_${index}`;
|
|
1254
|
-
parts.push(`${variableName}.${key} == @${paramName}`);
|
|
1255
|
-
params[paramName] = value;
|
|
1256
|
-
});
|
|
1257
|
-
return {
|
|
1258
|
-
clause: parts.join(' AND '),
|
|
1259
|
-
params,
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
// ==================== PROTECTED PARSER METHODS ====================
|
|
1263
|
-
parseNode(nativeNode) {
|
|
1264
|
-
if (!nativeNode) {
|
|
1265
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.NODE_ERROR, 'Cannot parse null node');
|
|
1361
|
+
mapIndexType(type) {
|
|
1362
|
+
switch (type) {
|
|
1363
|
+
case 'fulltext':
|
|
1364
|
+
return 'fulltext';
|
|
1365
|
+
case 'geo':
|
|
1366
|
+
case 'point':
|
|
1367
|
+
return 'geo';
|
|
1368
|
+
case 'ttl':
|
|
1369
|
+
return 'ttl';
|
|
1370
|
+
default:
|
|
1371
|
+
return 'persistent';
|
|
1266
1372
|
}
|
|
1267
|
-
const { _key, _id, _rev, _labels } = nativeNode, properties = __rest(nativeNode, ["_key", "_id", "_rev", "_labels"]);
|
|
1268
|
-
return {
|
|
1269
|
-
id: _key || _id,
|
|
1270
|
-
labels: _labels || [],
|
|
1271
|
-
properties: properties,
|
|
1272
|
-
elementId: _id,
|
|
1273
|
-
};
|
|
1274
1373
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.RELATIONSHIP_ERROR, 'Cannot parse null relationship');
|
|
1278
|
-
}
|
|
1279
|
-
const { _key, _id, _rev, _from, _to, _type } = nativeRelationship, properties = __rest(nativeRelationship, ["_key", "_id", "_rev", "_from", "_to", "_type"]);
|
|
1280
|
-
return {
|
|
1281
|
-
id: _key || _id,
|
|
1282
|
-
type: _type || '',
|
|
1283
|
-
startNodeId: _from,
|
|
1284
|
-
endNodeId: _to,
|
|
1285
|
-
properties: properties,
|
|
1286
|
-
elementId: _id,
|
|
1287
|
-
};
|
|
1374
|
+
buildWhereClause(where) {
|
|
1375
|
+
return this.buildArangoWhereClause(where, 'doc');
|
|
1288
1376
|
}
|
|
1289
|
-
|
|
1290
|
-
if (
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1377
|
+
parseError(error) {
|
|
1378
|
+
if (error instanceof graph_error_1.GraphError) {
|
|
1379
|
+
return error;
|
|
1380
|
+
}
|
|
1381
|
+
return graph_error_1.GraphError.queryError(String(error));
|
|
1382
|
+
}
|
|
1383
|
+
buildArangoWhereClause(where, varName) {
|
|
1384
|
+
const conditions = [];
|
|
1385
|
+
const filterVars = {};
|
|
1386
|
+
let varCounter = 0;
|
|
1387
|
+
for (const [key, value] of Object.entries(where)) {
|
|
1388
|
+
if (key === '$AND') {
|
|
1389
|
+
const { filterStr, filterVars: andVars } = this.buildArangoWhereClause(value, varName);
|
|
1390
|
+
if (filterStr) {
|
|
1391
|
+
conditions.push(`(${filterStr})`);
|
|
1392
|
+
Object.assign(filterVars, andVars);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
else if (key === '$OR') {
|
|
1396
|
+
const { filterStr, filterVars: orVars } = this.buildArangoWhereClause(value, varName);
|
|
1397
|
+
if (filterStr) {
|
|
1398
|
+
conditions.push(`(${filterStr.replace(/ AND /g, ' OR ')})`);
|
|
1399
|
+
Object.assign(filterVars, orVars);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
1403
|
+
for (const [op, opValue] of Object.entries(value)) {
|
|
1404
|
+
const varKey = `v${varCounter++}`;
|
|
1405
|
+
filterVars[varKey] = opValue;
|
|
1406
|
+
switch (op) {
|
|
1407
|
+
case '$GT':
|
|
1408
|
+
conditions.push(`${varName}.${key} > @${varKey}`);
|
|
1409
|
+
break;
|
|
1410
|
+
case '$GTE':
|
|
1411
|
+
conditions.push(`${varName}.${key} >= @${varKey}`);
|
|
1412
|
+
break;
|
|
1413
|
+
case '$LT':
|
|
1414
|
+
conditions.push(`${varName}.${key} < @${varKey}`);
|
|
1415
|
+
break;
|
|
1416
|
+
case '$LTE':
|
|
1417
|
+
conditions.push(`${varName}.${key} <= @${varKey}`);
|
|
1418
|
+
break;
|
|
1419
|
+
case '$NE':
|
|
1420
|
+
conditions.push(`${varName}.${key} != @${varKey}`);
|
|
1421
|
+
break;
|
|
1422
|
+
case '$IN':
|
|
1423
|
+
conditions.push(`${varName}.${key} IN @${varKey}`);
|
|
1424
|
+
break;
|
|
1425
|
+
case '$NOT_IN':
|
|
1426
|
+
conditions.push(`${varName}.${key} NOT IN @${varKey}`);
|
|
1427
|
+
break;
|
|
1428
|
+
case '$CONTAINS':
|
|
1429
|
+
conditions.push(`CONTAINS(${varName}.${key}, @${varKey})`);
|
|
1430
|
+
break;
|
|
1431
|
+
case '$STARTS_WITH':
|
|
1432
|
+
conditions.push(`STARTS_WITH(${varName}.${key}, @${varKey})`);
|
|
1433
|
+
break;
|
|
1434
|
+
case '$ENDS_WITH':
|
|
1435
|
+
conditions.push(`LIKE(${varName}.${key}, CONCAT('%', @${varKey}))`);
|
|
1436
|
+
break;
|
|
1437
|
+
case '$EXISTS':
|
|
1438
|
+
if (opValue) {
|
|
1439
|
+
conditions.push(`${varName}.${key} != null`);
|
|
1440
|
+
}
|
|
1441
|
+
else {
|
|
1442
|
+
conditions.push(`${varName}.${key} == null`);
|
|
1443
|
+
}
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
else {
|
|
1449
|
+
const varKey = `v${varCounter++}`;
|
|
1450
|
+
filterVars[varKey] = value;
|
|
1451
|
+
conditions.push(`${varName}.${key} == @${varKey}`);
|
|
1452
|
+
}
|
|
1303
1453
|
}
|
|
1304
1454
|
return {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
length: relationships.length,
|
|
1308
|
-
start: nodes[0],
|
|
1309
|
-
end: nodes[nodes.length - 1],
|
|
1455
|
+
filterStr: conditions.join(' AND '),
|
|
1456
|
+
filterVars,
|
|
1310
1457
|
};
|
|
1311
1458
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
// In ArangoDB, you might use different collections per label
|
|
1318
|
-
// For simplicity, using default collection
|
|
1319
|
-
return this.defaultVertexCollection;
|
|
1320
|
-
}
|
|
1321
|
-
resolveNodeId(ref) {
|
|
1322
|
-
if (typeof ref === 'string')
|
|
1323
|
-
return ref;
|
|
1324
|
-
if (ref.id) {
|
|
1325
|
-
const id = String(ref.id);
|
|
1326
|
-
// If it's not already a full document ID, prefix it
|
|
1327
|
-
if (!id.includes('/')) {
|
|
1328
|
-
return `${this.defaultVertexCollection}/${id}`;
|
|
1459
|
+
cleanArangoProps(doc) {
|
|
1460
|
+
const result = {};
|
|
1461
|
+
for (const [key, value] of Object.entries(doc)) {
|
|
1462
|
+
if (!key.startsWith('_')) {
|
|
1463
|
+
result[key] = value;
|
|
1329
1464
|
}
|
|
1330
|
-
return id;
|
|
1331
1465
|
}
|
|
1332
|
-
|
|
1466
|
+
return result;
|
|
1333
1467
|
}
|
|
1334
|
-
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
case node_types_1.NodeComparisonOperator.GREATER_THAN:
|
|
1345
|
-
operator = '>';
|
|
1346
|
-
break;
|
|
1347
|
-
case node_types_1.NodeComparisonOperator.GREATER_THAN_OR_EQUAL:
|
|
1348
|
-
operator = '>=';
|
|
1349
|
-
break;
|
|
1350
|
-
case node_types_1.NodeComparisonOperator.LESS_THAN:
|
|
1351
|
-
operator = '<';
|
|
1352
|
-
break;
|
|
1353
|
-
case node_types_1.NodeComparisonOperator.LESS_THAN_OR_EQUAL:
|
|
1354
|
-
operator = '<=';
|
|
1355
|
-
break;
|
|
1356
|
-
case node_types_1.NodeComparisonOperator.IN:
|
|
1357
|
-
operator = 'IN';
|
|
1358
|
-
break;
|
|
1359
|
-
case node_types_1.NodeComparisonOperator.NOT_IN:
|
|
1360
|
-
operator = 'NOT IN';
|
|
1361
|
-
break;
|
|
1362
|
-
case node_types_1.NodeComparisonOperator.CONTAINS:
|
|
1363
|
-
params[paramName] = where.value;
|
|
1364
|
-
return `CONTAINS(${alias}.${where.property}, @${paramName})`;
|
|
1365
|
-
case node_types_1.NodeComparisonOperator.STARTS_WITH:
|
|
1366
|
-
params[paramName] = where.value;
|
|
1367
|
-
return `STARTS_WITH(${alias}.${where.property}, @${paramName})`;
|
|
1368
|
-
case node_types_1.NodeComparisonOperator.IS_NULL:
|
|
1369
|
-
return `${alias}.${where.property} == null`;
|
|
1370
|
-
case node_types_1.NodeComparisonOperator.IS_NOT_NULL:
|
|
1371
|
-
return `${alias}.${where.property} != null`;
|
|
1372
|
-
case node_types_1.NodeComparisonOperator.REGEX:
|
|
1373
|
-
params[paramName] = where.value;
|
|
1374
|
-
return `REGEX_TEST(${alias}.${where.property}, @${paramName})`;
|
|
1375
|
-
default:
|
|
1376
|
-
operator = '==';
|
|
1377
|
-
}
|
|
1378
|
-
params[paramName] = where.value;
|
|
1379
|
-
let condition = `${alias}.${where.property} ${operator} @${paramName}`;
|
|
1380
|
-
if (where.and && where.and.length > 0) {
|
|
1381
|
-
const andClauses = where.and.map((w, i) => this.buildAQLFilter(w, alias, params, `${prefix}and${i}_`));
|
|
1382
|
-
condition = `(${condition} AND ${andClauses.join(' AND ')})`;
|
|
1383
|
-
}
|
|
1384
|
-
if (where.or && where.or.length > 0) {
|
|
1385
|
-
const orClauses = where.or.map((w, i) => this.buildAQLFilter(w, alias, params, `${prefix}or${i}_`));
|
|
1386
|
-
condition = `(${condition} OR ${orClauses.join(' OR ')})`;
|
|
1468
|
+
async resolveNodeId(id) {
|
|
1469
|
+
for (const collName of this.vertexCollections) {
|
|
1470
|
+
try {
|
|
1471
|
+
const collection = this.db.collection(collName);
|
|
1472
|
+
await collection.document(id);
|
|
1473
|
+
return `${collName}/${id}`;
|
|
1474
|
+
}
|
|
1475
|
+
catch (_a) {
|
|
1476
|
+
continue;
|
|
1477
|
+
}
|
|
1387
1478
|
}
|
|
1388
|
-
|
|
1479
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${id} not found`);
|
|
1389
1480
|
}
|
|
1390
1481
|
}
|
|
1391
1482
|
exports.ArangoDBAdapter = ArangoDBAdapter;
|
|
1392
|
-
exports.default = ArangoDBAdapter;
|
|
1393
1483
|
//# sourceMappingURL=arangodb.adapter.js.map
|