@ductape/sdk 0.0.4-v51 → 0.0.4-v52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/agent-context.d.ts +98 -0
- package/dist/agents/agent-context.js +588 -0
- package/dist/agents/agent-context.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +180 -0
- package/dist/agents/agent-executor.js +715 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/agents.service.d.ts +304 -0
- package/dist/agents/agents.service.js +1244 -0
- package/dist/agents/agents.service.js.map +1 -0
- package/dist/agents/index.d.ts +55 -0
- package/dist/agents/index.js +110 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/memory-manager.d.ts +182 -0
- package/dist/agents/memory-manager.js +383 -0
- package/dist/agents/memory-manager.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +141 -0
- package/dist/agents/tool-registry.js +355 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/agents/types/agents.types.d.ts +1225 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.js +4 -5
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +322 -0
- package/dist/api/services/processorApi.service.js +252 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +69 -1
- package/dist/api/services/productsApi.service.js +67 -31
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +38 -0
- package/dist/api/services/secretsApi.service.js +96 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/userApi.service.js +0 -1
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +183 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.js +0 -1
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +57 -0
- package/dist/api/urls.js +68 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.js +4 -10
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +0 -10
- package/dist/apps/services/app.service.js +74 -30
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +405 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +257 -0
- package/dist/brokers/brokers.service.js +604 -0
- package/dist/brokers/brokers.service.js.map +1 -0
- package/dist/brokers/index.d.ts +46 -0
- package/dist/brokers/index.js +83 -0
- package/dist/brokers/index.js.map +1 -0
- package/dist/brokers/types/index.d.ts +288 -0
- package/dist/brokers/types/index.js +8 -0
- package/dist/brokers/types/index.js.map +1 -0
- package/dist/brokers/utils/broker.util.d.ts +33 -0
- package/dist/brokers/utils/broker.util.js +125 -0
- package/dist/brokers/utils/broker.util.js.map +1 -0
- package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
- package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
- package/dist/brokers/utils/providers/index.d.ts +6 -0
- package/dist/brokers/utils/providers/index.js +16 -0
- package/dist/brokers/utils/providers/index.js.map +1 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +16 -0
- package/dist/brokers/utils/providers/kafka.service.js +52 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +14 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
- package/dist/brokers/utils/providers/redis.service.js +93 -0
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +159 -0
- package/dist/cache/cache.manager.js +265 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +186 -0
- package/dist/cache/cache.service.js +437 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +79 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +106 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +307 -90
- package/dist/database/adapters/base.adapter.js +139 -20
- package/dist/database/adapters/base.adapter.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
- package/dist/database/adapters/cassandra.adapter.js +1019 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
- package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +105 -57
- package/dist/database/adapters/mongodb.adapter.js +941 -838
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +76 -138
- package/dist/database/adapters/mysql.adapter.js +990 -1246
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
- package/dist/database/adapters/postgresql.adapter.js +1076 -1346
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +1374 -0
- package/dist/database/databases.service.js +2680 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +41 -13
- package/dist/database/index.js +97 -86
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +132 -0
- package/dist/database/migrations/migration-engine.js +1356 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +64 -0
- package/dist/database/operators/aggregation-builder.js +746 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +55 -0
- package/dist/database/operators/query-builder.js +365 -0
- package/dist/database/operators/query-builder.js.map +1 -0
- package/dist/database/presave/decrypt.d.ts +25 -0
- package/dist/database/presave/decrypt.js +146 -0
- package/dist/database/presave/decrypt.js.map +1 -0
- package/dist/database/presave/index.d.ts +9 -0
- package/dist/database/presave/index.js +18 -0
- package/dist/database/presave/index.js.map +1 -0
- package/dist/database/presave/presave-processor.d.ts +148 -0
- package/dist/database/presave/presave-processor.js +702 -0
- package/dist/database/presave/presave-processor.js.map +1 -0
- package/dist/database/schema/index.d.ts +7 -0
- package/dist/database/schema/index.js +13 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/database/schema/schema-manager.d.ts +258 -0
- package/dist/database/schema/schema-manager.js +637 -0
- package/dist/database/schema/schema-manager.js.map +1 -0
- package/dist/database/transactions/index.d.ts +6 -0
- package/dist/database/transactions/index.js +13 -0
- package/dist/database/transactions/index.js.map +1 -0
- package/dist/database/transactions/transaction-manager.d.ts +113 -0
- package/dist/database/transactions/transaction-manager.js +344 -0
- package/dist/database/transactions/transaction-manager.js.map +1 -0
- package/dist/database/triggers/index.d.ts +7 -0
- package/dist/database/triggers/index.js +14 -0
- package/dist/database/triggers/index.js.map +1 -0
- package/dist/database/triggers/trigger-processor.d.ts +239 -0
- package/dist/database/triggers/trigger-processor.js +1034 -0
- package/dist/database/triggers/trigger-processor.js.map +1 -0
- package/dist/database/types/action.interface.d.ts +148 -0
- package/dist/database/types/action.interface.js +6 -0
- package/dist/database/types/action.interface.js.map +1 -0
- package/dist/database/types/aggregation.interface.d.ts +179 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/enums.d.ts +195 -0
- package/dist/database/types/enums.js +244 -0
- package/dist/database/types/enums.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -10
- package/dist/database/types/index.js +26 -32
- package/dist/database/types/index.js.map +1 -1
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +199 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +398 -0
- package/dist/database/types/schema.interface.js +6 -0
- package/dist/database/types/schema.interface.js.map +1 -0
- package/dist/database/types/transaction.interface.d.ts +84 -0
- package/dist/database/types/transaction.interface.js +6 -0
- package/dist/database/types/transaction.interface.js.map +1 -0
- package/dist/database/types/trigger.interface.d.ts +612 -0
- package/dist/database/types/trigger.interface.js +121 -0
- package/dist/database/types/trigger.interface.js.map +1 -0
- package/dist/database/types/write.interface.d.ts +208 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +78 -72
- package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/base.adapter.d.ts +135 -118
- package/dist/graph/adapters/base.adapter.js +46 -20
- package/dist/graph/adapters/base.adapter.js.map +1 -1
- package/dist/graph/adapters/index.d.ts +5 -4
- package/dist/graph/adapters/index.js +6 -8
- package/dist/graph/adapters/index.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
- package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
- package/dist/graph/adapters/neo4j.adapter.js +912 -1605
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
- package/dist/graph/adapters/neptune.adapter.js +1095 -1228
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +524 -0
- package/dist/graph/graphs.service.js +1683 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +54 -8
- package/dist/graph/index.js +67 -32
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +141 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -9
- package/dist/graph/types/index.js +15 -30
- package/dist/graph/types/index.js.map +1 -1
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +168 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/index.d.ts +1905 -875
- package/dist/index.js +3063 -1282
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/init.interface.js +3 -0
- package/dist/init.interface.js.map +1 -0
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.types.d.ts +12 -2
- package/dist/logs/logs.types.js +5 -1
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +252 -0
- package/dist/notifications/notifications.service.js +654 -0
- package/dist/notifications/notifications.service.js.map +1 -0
- package/dist/notifications/types/index.d.ts +4 -0
- package/dist/notifications/types/index.js +21 -0
- package/dist/notifications/types/index.js.map +1 -0
- package/dist/notifications/types/notifications.types.d.ts +400 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +86 -70
- package/dist/processor/services/processor.service.js +1353 -1259
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +5 -1
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/services/products.service.d.ts +167 -25
- package/dist/products/services/products.service.js +1248 -412
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +6 -3
- package/dist/products/validators/index.js +14 -5
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +218 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +4 -15
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +135 -50
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
- package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +0 -6
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +88 -0
- package/dist/resilience/fallback.service.js +511 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +106 -0
- package/dist/resilience/healthcheck.service.js +379 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +90 -0
- package/dist/resilience/quota.service.js +519 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +95 -0
- package/dist/resilience/resilience.service.js +525 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +479 -0
- package/dist/resilience/types/index.js +26 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +83 -0
- package/dist/secrets/secrets.service.js +159 -0
- package/dist/secrets/secrets.service.js.map +1 -0
- package/dist/secrets/secrets.types.d.ts +188 -0
- package/dist/secrets/secrets.types.js +87 -0
- package/dist/secrets/secrets.types.js.map +1 -0
- package/dist/sessions/index.d.ts +50 -0
- package/dist/sessions/index.js +93 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +68 -0
- package/dist/sessions/sessions.helper.js +116 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +150 -0
- package/dist/sessions/sessions.resolver.js +356 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +170 -0
- package/dist/sessions/sessions.service.js +736 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +290 -0
- package/dist/sessions/types/index.js +6 -0
- package/dist/sessions/types/index.js.map +1 -0
- package/dist/storage/index.d.ts +66 -0
- package/dist/storage/index.js +98 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +123 -0
- package/dist/storage/storage.service.js +478 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +207 -0
- package/dist/storage/types/index.js +6 -0
- package/dist/storage/types/index.js.map +1 -0
- package/dist/storage/utils/storage.util.d.ts +51 -0
- package/dist/storage/utils/storage.util.js +402 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +13 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -15
- package/dist/test/test.appBuilder.js.map +1 -1
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.health.d.ts +0 -1
- package/dist/test/test.health.js +0 -48
- package/dist/test/test.health.js.map +1 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1506
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -75
- package/dist/test/test.import.openapi.js.map +1 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -76
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -17
- package/dist/test/test.logs.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +0 -1
- package/dist/test/test.notifiers.js +0 -84
- package/dist/test/test.notifiers.js.map +1 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -37
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -660
- package/dist/test/test.productBuilder.js.map +1 -1
- package/dist/test/test.products.d.ts +0 -1
- package/dist/test/test.products.js +0 -48
- package/dist/test/test.products.js.map +1 -1
- package/dist/test/test.storage.js +332 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/dist/types/enums.d.ts +6 -1
- package/dist/types/enums.js +5 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/processor.types.d.ts +197 -35
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +837 -75
- package/dist/types/productsBuilder.types.js +168 -62
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +2 -49
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +152 -0
- package/dist/vector/adapters/base.adapter.js +137 -0
- package/dist/vector/adapters/base.adapter.js.map +1 -0
- package/dist/vector/adapters/index.d.ts +10 -0
- package/dist/vector/adapters/index.js +19 -0
- package/dist/vector/adapters/index.js.map +1 -0
- package/dist/vector/adapters/memory.adapter.d.ts +85 -0
- package/dist/vector/adapters/memory.adapter.js +505 -0
- package/dist/vector/adapters/memory.adapter.js.map +1 -0
- package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
- package/dist/vector/adapters/pinecone.adapter.js +400 -0
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
- package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
- package/dist/vector/adapters/qdrant.adapter.js +392 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
- package/dist/vector/adapters/weaviate.adapter.js +478 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +47 -0
- package/dist/vector/index.js +72 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/types/connection.interface.d.ts +151 -0
- package/dist/vector/types/connection.interface.js +8 -0
- package/dist/vector/types/connection.interface.js.map +1 -0
- package/dist/vector/types/embedding.interface.d.ts +144 -0
- package/dist/vector/types/embedding.interface.js +8 -0
- package/dist/vector/types/embedding.interface.js.map +1 -0
- package/dist/vector/types/enums.d.ts +104 -0
- package/dist/vector/types/enums.js +113 -0
- package/dist/vector/types/enums.js.map +1 -0
- package/dist/vector/types/index.d.ts +9 -0
- package/dist/vector/types/index.js +16 -0
- package/dist/vector/types/index.js.map +1 -0
- package/dist/vector/types/vector.interface.d.ts +315 -0
- package/dist/vector/types/vector.interface.js +8 -0
- package/dist/vector/types/vector.interface.js.map +1 -0
- package/dist/vector/utils/index.d.ts +6 -0
- package/dist/vector/utils/index.js +11 -0
- package/dist/vector/utils/index.js.map +1 -0
- package/dist/vector/utils/vector-error.d.ts +69 -0
- package/dist/vector/utils/vector-error.js +117 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +405 -0
- package/dist/vector/vector-database.service.js +544 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +245 -0
- package/dist/vector/vector.service.js +381 -0
- package/dist/vector/vector.service.js.map +1 -0
- package/dist/workflows/index.d.ts +30 -0
- package/dist/workflows/index.js +64 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types/index.d.ts +6 -0
- package/dist/workflows/types/index.js +23 -0
- package/dist/workflows/types/index.js.map +1 -0
- package/dist/workflows/types/workflows.types.d.ts +1035 -0
- package/dist/workflows/types/workflows.types.js +13 -0
- package/dist/workflows/types/workflows.types.js.map +1 -0
- package/dist/workflows/workflow-builder.d.ts +70 -0
- package/dist/workflows/workflow-builder.js +338 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +205 -0
- package/dist/workflows/workflow-executor.js +1186 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +398 -0
- package/dist/workflows/workflows.service.js +1595 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +16 -13
- package/dist/actions/actions.repo.d.ts +0 -0
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.d.ts +0 -0
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.d.ts +0 -0
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +0 -75
- package/dist/api/services/workspaceSecretsApi.service.js +0 -62
- package/dist/api/services/workspaceSecretsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/database/database.service.d.ts +0 -232
- package/dist/database/database.service.js +0 -802
- package/dist/database/database.service.js.map +0 -1
- package/dist/database/types/aggregation.types.d.ts +0 -261
- package/dist/database/types/aggregation.types.js +0 -21
- package/dist/database/types/aggregation.types.js.map +0 -1
- package/dist/database/types/connection.types.d.ts +0 -132
- package/dist/database/types/connection.types.js +0 -6
- package/dist/database/types/connection.types.js.map +0 -1
- package/dist/database/types/database.types.d.ts +0 -175
- package/dist/database/types/database.types.js +0 -75
- package/dist/database/types/database.types.js.map +0 -1
- package/dist/database/types/index.types.d.ts +0 -220
- package/dist/database/types/index.types.js +0 -27
- package/dist/database/types/index.types.js.map +0 -1
- package/dist/database/types/migration.types.d.ts +0 -205
- package/dist/database/types/migration.types.js +0 -44
- package/dist/database/types/migration.types.js.map +0 -1
- package/dist/database/types/query.types.d.ts +0 -305
- package/dist/database/types/query.types.js +0 -57
- package/dist/database/types/query.types.js.map +0 -1
- package/dist/database/types/result.types.d.ts +0 -220
- package/dist/database/types/result.types.js +0 -6
- package/dist/database/types/result.types.js.map +0 -1
- package/dist/database/types/schema.types.d.ts +0 -190
- package/dist/database/types/schema.types.js +0 -69
- package/dist/database/types/schema.types.js.map +0 -1
- package/dist/database/utils/helpers.d.ts +0 -66
- package/dist/database/utils/helpers.js +0 -501
- package/dist/database/utils/helpers.js.map +0 -1
- package/dist/database/utils/migration.utils.d.ts +0 -151
- package/dist/database/utils/migration.utils.js +0 -476
- package/dist/database/utils/migration.utils.js.map +0 -1
- package/dist/database/utils/transaction.d.ts +0 -64
- package/dist/database/utils/transaction.js +0 -130
- package/dist/database/utils/transaction.js.map +0 -1
- package/dist/database/validators/connection.validator.d.ts +0 -20
- package/dist/database/validators/connection.validator.js +0 -267
- package/dist/database/validators/connection.validator.js.map +0 -1
- package/dist/database/validators/query.validator.d.ts +0 -31
- package/dist/database/validators/query.validator.js +0 -305
- package/dist/database/validators/query.validator.js.map +0 -1
- package/dist/database/validators/schema.validator.d.ts +0 -31
- package/dist/database/validators/schema.validator.js +0 -334
- package/dist/database/validators/schema.validator.js.map +0 -1
- package/dist/graph/graph.service.d.ts +0 -278
- package/dist/graph/graph.service.js +0 -687
- package/dist/graph/graph.service.js.map +0 -1
- package/dist/graph/types/connection.types.d.ts +0 -158
- package/dist/graph/types/connection.types.js +0 -43
- package/dist/graph/types/connection.types.js.map +0 -1
- package/dist/graph/types/graph.types.d.ts +0 -144
- package/dist/graph/types/graph.types.js +0 -84
- package/dist/graph/types/graph.types.js.map +0 -1
- package/dist/graph/types/node.types.d.ts +0 -193
- package/dist/graph/types/node.types.js +0 -49
- package/dist/graph/types/node.types.js.map +0 -1
- package/dist/graph/types/path.types.d.ts +0 -224
- package/dist/graph/types/path.types.js +0 -38
- package/dist/graph/types/path.types.js.map +0 -1
- package/dist/graph/types/query.types.d.ts +0 -247
- package/dist/graph/types/query.types.js +0 -23
- package/dist/graph/types/query.types.js.map +0 -1
- package/dist/graph/types/relationship.types.d.ts +0 -224
- package/dist/graph/types/relationship.types.js +0 -35
- package/dist/graph/types/relationship.types.js.map +0 -1
- package/dist/graph/types/result.types.d.ts +0 -237
- package/dist/graph/types/result.types.js +0 -7
- package/dist/graph/types/result.types.js.map +0 -1
- package/dist/graph/validators/index.d.ts +0 -81
- package/dist/graph/validators/index.js +0 -243
- package/dist/graph/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/utils/mongo.util.d.ts +0 -0
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/services/utils/crypt.utils.d.ts +0 -1
- package/dist/products/services/utils/crypt.utils.js +0 -17
- package/dist/products/services/utils/crypt.utils.js.map +0 -1
- package/dist/products/services/utils/functions.utils.d.ts +0 -13
- package/dist/products/services/utils/functions.utils.js +0 -289
- package/dist/products/services/utils/functions.utils.js.map +0 -1
- package/dist/products/services/utils/objects.utils.d.ts +0 -13
- package/dist/products/services/utils/objects.utils.js +0 -89
- package/dist/products/services/utils/objects.utils.js.map +0 -1
- package/dist/products/services/utils/string.utils.d.ts +0 -12
- package/dist/products/services/utils/string.utils.js +0 -168
- package/dist/products/services/utils/string.utils.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- package/dist/test.import.d.ts +0 -0
- package/dist/test.import.js +0 -24
- package/dist/test.import.js.map +0 -1
- package/dist/test.imports.js +0 -28
- package/dist/test.imports.js.map +0 -1
- package/dist/test.integrationBuilder.js +0 -276
- package/dist/test.integrationBuilder.js.map +0 -1
- package/dist/test.processor.d.ts +0 -1
- package/dist/test.processor.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.d.ts +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
|
@@ -1,1430 +1,1297 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Amazon Neptune Graph Database Adapter
|
|
4
|
+
*
|
|
5
|
+
* Implements the BaseGraphAdapter for Amazon Neptune using Gremlin.
|
|
6
|
+
* Neptune is a fully managed graph database service that supports
|
|
7
|
+
* both property graph (Gremlin) and RDF (SPARQL) query languages.
|
|
8
|
+
*
|
|
9
|
+
* Key features:
|
|
10
|
+
* - Apache TinkerPop Gremlin support
|
|
11
|
+
* - WebSocket connection support
|
|
12
|
+
* - IAM authentication support
|
|
13
|
+
* - High availability and replication
|
|
5
14
|
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
6
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
49
|
exports.NeptuneAdapter = void 0;
|
|
8
50
|
const base_adapter_1 = require("./base.adapter");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
/**
|
|
12
|
-
* Neptune connection implementation
|
|
13
|
-
*/
|
|
14
|
-
class NeptuneConnection {
|
|
15
|
-
constructor(config, id) {
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.type = graph_types_1.GraphDatabaseType.NEPTUNE;
|
|
18
|
-
this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
|
|
19
|
-
this.httpClient = null;
|
|
20
|
-
this.awsCredentials = null;
|
|
21
|
-
this.id = id || `neptune-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
22
|
-
this.createdAt = new Date();
|
|
23
|
-
this.queryLanguage = config.queryLanguage;
|
|
24
|
-
}
|
|
25
|
-
async connect() {
|
|
26
|
-
var _a;
|
|
27
|
-
if (this.status === graph_types_1.GraphConnectionStatus.CONNECTED) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.status = graph_types_1.GraphConnectionStatus.CONNECTING;
|
|
31
|
-
try {
|
|
32
|
-
// Build endpoint URL
|
|
33
|
-
const port = this.config.port || 8182;
|
|
34
|
-
const protocol = this.config.ssl !== false ? 'https' : 'http';
|
|
35
|
-
const baseUrl = `${protocol}://${this.config.endpoint}:${port}`;
|
|
36
|
-
// If using IAM auth, set up AWS signing
|
|
37
|
-
if (this.config.useIAM) {
|
|
38
|
-
this.awsCredentials = {
|
|
39
|
-
accessKeyId: this.config.accessKeyId,
|
|
40
|
-
secretAccessKey: this.config.secretAccessKey,
|
|
41
|
-
sessionToken: this.config.sessionToken,
|
|
42
|
-
region: this.config.region,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
this.httpClient = {
|
|
46
|
-
baseUrl,
|
|
47
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers),
|
|
48
|
-
};
|
|
49
|
-
// Verify connectivity with a simple query
|
|
50
|
-
await this.executeQuery(this.queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN
|
|
51
|
-
? 'g.V().limit(1).count()'
|
|
52
|
-
: 'MATCH (n) RETURN count(n) LIMIT 1');
|
|
53
|
-
this.status = graph_types_1.GraphConnectionStatus.CONNECTED;
|
|
54
|
-
this.lastUsedAt = new Date();
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
this.status = graph_types_1.GraphConnectionStatus.ERROR;
|
|
58
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, `Failed to connect to Neptune: ${error.message}`, error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async disconnect() {
|
|
62
|
-
this.httpClient = null;
|
|
63
|
-
this.awsCredentials = null;
|
|
64
|
-
this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
|
|
65
|
-
}
|
|
66
|
-
isConnected() {
|
|
67
|
-
return this.status === graph_types_1.GraphConnectionStatus.CONNECTED && this.httpClient !== null;
|
|
68
|
-
}
|
|
69
|
-
getClient() {
|
|
70
|
-
if (!this.httpClient) {
|
|
71
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Neptune client not initialized. Call connect() first.');
|
|
72
|
-
}
|
|
73
|
-
return this.httpClient;
|
|
74
|
-
}
|
|
75
|
-
getSession() {
|
|
76
|
-
return this.getClient();
|
|
77
|
-
}
|
|
78
|
-
getConfig() {
|
|
79
|
-
return this.config;
|
|
80
|
-
}
|
|
81
|
-
async executeQuery(query, params) {
|
|
82
|
-
if (!this.httpClient) {
|
|
83
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Neptune client not initialized');
|
|
84
|
-
}
|
|
85
|
-
this.lastUsedAt = new Date();
|
|
86
|
-
const endpoint = this.queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN
|
|
87
|
-
? '/gremlin'
|
|
88
|
-
: '/openCypher';
|
|
89
|
-
const body = this.queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN
|
|
90
|
-
? { gremlin: query, bindings: params || {} }
|
|
91
|
-
: { query, parameters: params || {} };
|
|
92
|
-
try {
|
|
93
|
-
// Make HTTP request to Neptune
|
|
94
|
-
const response = await this.makeRequest(endpoint, body);
|
|
95
|
-
return response;
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.QUERY_ERROR, `Neptune query failed: ${error.message}`, error, query, params);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async makeRequest(endpoint, body) {
|
|
102
|
-
const url = `${this.httpClient.baseUrl}${endpoint}`;
|
|
103
|
-
const headers = Object.assign({}, this.httpClient.headers);
|
|
104
|
-
// Sign request if using IAM auth
|
|
105
|
-
if (this.awsCredentials) {
|
|
106
|
-
const signedHeaders = await this.signRequest('POST', url, JSON.stringify(body));
|
|
107
|
-
Object.assign(headers, signedHeaders);
|
|
108
|
-
}
|
|
109
|
-
// Using fetch for HTTP requests
|
|
110
|
-
const response = await fetch(url, {
|
|
111
|
-
method: 'POST',
|
|
112
|
-
headers,
|
|
113
|
-
body: JSON.stringify(body),
|
|
114
|
-
});
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
const errorBody = await response.text();
|
|
117
|
-
throw new Error(`HTTP ${response.status}: ${errorBody}`);
|
|
118
|
-
}
|
|
119
|
-
return response.json();
|
|
120
|
-
}
|
|
121
|
-
async signRequest(method, url, body) {
|
|
122
|
-
// AWS Signature V4 signing
|
|
123
|
-
// In production, use aws-sdk or @aws-sdk/signature-v4
|
|
124
|
-
// This is a placeholder for the signing logic
|
|
125
|
-
const timestamp = new Date().toISOString().replace(/[:-]|\.\d{3}/g, '');
|
|
126
|
-
const date = timestamp.slice(0, 8);
|
|
127
|
-
return {
|
|
128
|
-
'X-Amz-Date': timestamp,
|
|
129
|
-
'X-Amz-Security-Token': this.awsCredentials.sessionToken || '',
|
|
130
|
-
// In production, add proper Authorization header with signature
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
51
|
+
const enums_1 = require("../types/enums");
|
|
52
|
+
const graph_error_1 = require("../utils/graph-error");
|
|
134
53
|
/**
|
|
135
|
-
* Neptune
|
|
136
|
-
*
|
|
137
|
-
*/
|
|
138
|
-
class NeptuneTransaction {
|
|
139
|
-
constructor(connection, transactionId) {
|
|
140
|
-
this.connection = connection;
|
|
141
|
-
this.status = graph_types_1.GraphTransactionStatus.PENDING;
|
|
142
|
-
this.id = transactionId || `tx-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
143
|
-
this.createdAt = new Date();
|
|
144
|
-
this.status = graph_types_1.GraphTransactionStatus.ACTIVE;
|
|
145
|
-
this.native = { transactionId: this.id };
|
|
146
|
-
}
|
|
147
|
-
async commit() {
|
|
148
|
-
if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
|
|
149
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Cannot commit transaction in ${this.status} state`);
|
|
150
|
-
}
|
|
151
|
-
// Neptune auto-commits each query, so this is a no-op
|
|
152
|
-
this.status = graph_types_1.GraphTransactionStatus.COMMITTED;
|
|
153
|
-
}
|
|
154
|
-
async rollback() {
|
|
155
|
-
if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
// Neptune doesn't support rollback in the traditional sense
|
|
159
|
-
this.status = graph_types_1.GraphTransactionStatus.ROLLED_BACK;
|
|
160
|
-
}
|
|
161
|
-
isActive() {
|
|
162
|
-
return this.status === graph_types_1.GraphTransactionStatus.ACTIVE;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* AWS Neptune Graph Database Adapter
|
|
54
|
+
* Neptune adapter using Gremlin
|
|
55
|
+
* Uses the gremlin package for TinkerPop connectivity
|
|
167
56
|
*/
|
|
168
57
|
class NeptuneAdapter extends base_adapter_1.BaseGraphAdapter {
|
|
169
58
|
constructor() {
|
|
170
59
|
super(...arguments);
|
|
171
|
-
this.
|
|
172
|
-
this.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return connection;
|
|
183
|
-
}
|
|
184
|
-
async disconnect(connection) {
|
|
185
|
-
await connection.disconnect();
|
|
186
|
-
}
|
|
187
|
-
async testConnection(connection) {
|
|
188
|
-
const startTime = Date.now();
|
|
189
|
-
const neptuneConn = connection;
|
|
190
|
-
const queryLanguage = neptuneConn.getConfig().queryLanguage;
|
|
60
|
+
this.graphType = enums_1.GraphType.NEPTUNE;
|
|
61
|
+
this.supportedFeatures = new Set([
|
|
62
|
+
enums_1.GraphFeature.SCHEMA_INDEXES,
|
|
63
|
+
enums_1.GraphFeature.GRAPH_ALGORITHMS,
|
|
64
|
+
]);
|
|
65
|
+
this.connection = null;
|
|
66
|
+
this.g = null; // Gremlin graph traversal source
|
|
67
|
+
this.gremlin = null;
|
|
68
|
+
}
|
|
69
|
+
// ==================== CONNECTION MANAGEMENT ====================
|
|
70
|
+
async connect(options) {
|
|
191
71
|
try {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
72
|
+
// Dynamic import of gremlin package
|
|
73
|
+
this.gremlin = await Promise.resolve().then(() => __importStar(require('gremlin')));
|
|
74
|
+
const { DriverRemoteConnection } = this.gremlin.driver;
|
|
75
|
+
// Neptune WebSocket connection URL
|
|
76
|
+
const wsUrl = options.connectionUrl.replace(/^https?:\/\//, 'wss://').replace(/\/?$/, '/gremlin');
|
|
77
|
+
// Connection options for Neptune
|
|
78
|
+
const connectionOptions = {
|
|
79
|
+
mimeType: 'application/vnd.gremlin-v2.0+json',
|
|
80
|
+
pingEnabled: true,
|
|
81
|
+
pingInterval: 30000,
|
|
82
|
+
};
|
|
83
|
+
// Add authentication if provided
|
|
84
|
+
if (options.auth) {
|
|
85
|
+
// For IAM auth, you'd typically use AWS4 signing
|
|
86
|
+
// This is a simplified version - production would need proper IAM signing
|
|
87
|
+
connectionOptions.headers = {
|
|
88
|
+
Authorization: `Basic ${Buffer.from(`${options.auth.username}:${options.auth.password}`).toString('base64')}`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
this.connection = new DriverRemoteConnection(wsUrl, connectionOptions);
|
|
92
|
+
// Create graph traversal source
|
|
93
|
+
const { Graph } = this.gremlin.structure;
|
|
94
|
+
const graph = new Graph();
|
|
95
|
+
this.g = graph.traversal().withRemote(this.connection);
|
|
96
|
+
// Test the connection
|
|
97
|
+
await this.g.V().limit(1).toList();
|
|
98
|
+
this.connected = true;
|
|
99
|
+
this.connectionUrl = options.connectionUrl;
|
|
196
100
|
return {
|
|
197
101
|
connected: true,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
queryLanguage,
|
|
201
|
-
responseTime: Date.now() - startTime,
|
|
102
|
+
type: enums_1.GraphType.NEPTUNE,
|
|
103
|
+
latency: 0,
|
|
202
104
|
};
|
|
203
105
|
}
|
|
204
106
|
catch (error) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
message: 'Connection failed',
|
|
208
|
-
databaseType: graph_types_1.GraphDatabaseType.NEPTUNE,
|
|
209
|
-
queryLanguage,
|
|
210
|
-
responseTime: Date.now() - startTime,
|
|
211
|
-
error: error.message,
|
|
212
|
-
};
|
|
107
|
+
this.connected = false;
|
|
108
|
+
throw graph_error_1.GraphError.connectionError(`Failed to connect to Neptune: ${error.message}`, error);
|
|
213
109
|
}
|
|
214
110
|
}
|
|
215
|
-
async
|
|
216
|
-
const neptuneConn = connection;
|
|
111
|
+
async testConnection(options) {
|
|
217
112
|
try {
|
|
218
|
-
|
|
219
|
-
const
|
|
113
|
+
const gremlin = await Promise.resolve().then(() => __importStar(require('gremlin')));
|
|
114
|
+
const { DriverRemoteConnection } = gremlin.driver;
|
|
115
|
+
const startTime = Date.now();
|
|
116
|
+
const wsUrl = options.connectionUrl.replace(/^https?:\/\//, 'wss://').replace(/\/?$/, '/gremlin');
|
|
117
|
+
const testConnection = new DriverRemoteConnection(wsUrl, {
|
|
118
|
+
mimeType: 'application/vnd.gremlin-v2.0+json',
|
|
119
|
+
});
|
|
120
|
+
const { Graph } = gremlin.structure;
|
|
121
|
+
const graph = new Graph();
|
|
122
|
+
const testG = graph.traversal().withRemote(testConnection);
|
|
123
|
+
// Test query
|
|
124
|
+
await testG.V().limit(1).toList();
|
|
125
|
+
await testConnection.close();
|
|
220
126
|
return {
|
|
127
|
+
connected: true,
|
|
128
|
+
type: enums_1.GraphType.NEPTUNE,
|
|
221
129
|
version: 'Neptune',
|
|
222
|
-
|
|
223
|
-
features: ['gremlin', 'openCypher', 'sparql'],
|
|
130
|
+
latency: Date.now() - startTime,
|
|
224
131
|
};
|
|
225
132
|
}
|
|
226
|
-
catch (
|
|
227
|
-
return {
|
|
228
|
-
version: 'Unknown',
|
|
229
|
-
edition: 'AWS Neptune',
|
|
230
|
-
features: [],
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// ==================== TRANSACTION METHODS ====================
|
|
235
|
-
async beginTransaction(connection, options) {
|
|
236
|
-
// Neptune has limited transaction support
|
|
237
|
-
return new NeptuneTransaction(connection);
|
|
238
|
-
}
|
|
239
|
-
async commitTransaction(connection, transaction) {
|
|
240
|
-
await transaction.commit();
|
|
241
|
-
}
|
|
242
|
-
async rollbackTransaction(connection, transaction) {
|
|
243
|
-
await transaction.rollback();
|
|
244
|
-
}
|
|
245
|
-
// ==================== RAW QUERY METHODS ====================
|
|
246
|
-
async executeRaw(connection, options, transaction) {
|
|
247
|
-
const startTime = Date.now();
|
|
248
|
-
const neptuneConn = connection;
|
|
249
|
-
try {
|
|
250
|
-
const response = await neptuneConn.executeQuery(options.query, options.params);
|
|
251
|
-
const data = this.parseQueryResponse(response, neptuneConn.getConfig().queryLanguage);
|
|
133
|
+
catch (error) {
|
|
252
134
|
return {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
count: data.length,
|
|
135
|
+
connected: false,
|
|
136
|
+
type: enums_1.GraphType.NEPTUNE,
|
|
137
|
+
error: error.message,
|
|
257
138
|
};
|
|
258
139
|
}
|
|
259
|
-
catch (error) {
|
|
260
|
-
throw this.wrapError(error, graph_types_1.GraphErrorType.QUERY_ERROR, `Query execution failed: ${error.message}`, options.query, options.params);
|
|
261
|
-
}
|
|
262
140
|
}
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
|
|
141
|
+
async disconnect() {
|
|
142
|
+
if (this.connection) {
|
|
143
|
+
await this.connection.close();
|
|
144
|
+
this.connection = null;
|
|
145
|
+
this.g = null;
|
|
266
146
|
}
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
parseGremlinResponse(response) {
|
|
270
|
-
if (!response || !response.result)
|
|
271
|
-
return [];
|
|
272
|
-
const data = response.result.data;
|
|
273
|
-
if (!data || !data['@value'])
|
|
274
|
-
return [];
|
|
275
|
-
return data['@value'].map((item) => this.parseGremlinValue(item));
|
|
147
|
+
this.connected = false;
|
|
276
148
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const type = value['@type'];
|
|
282
|
-
const val = value['@value'];
|
|
283
|
-
switch (type) {
|
|
284
|
-
case 'g:Vertex':
|
|
285
|
-
return this.parseGremlinVertex(val);
|
|
286
|
-
case 'g:Edge':
|
|
287
|
-
return this.parseGremlinEdge(val);
|
|
288
|
-
case 'g:Path':
|
|
289
|
-
return this.parseGremlinPath(val);
|
|
290
|
-
case 'g:Int64':
|
|
291
|
-
case 'g:Int32':
|
|
292
|
-
case 'g:Double':
|
|
293
|
-
case 'g:Float':
|
|
294
|
-
return Number(val);
|
|
295
|
-
case 'g:List':
|
|
296
|
-
return val.map((v) => this.parseGremlinValue(v));
|
|
297
|
-
case 'g:Map':
|
|
298
|
-
return this.parseGremlinMap(val);
|
|
299
|
-
case 'g:Set':
|
|
300
|
-
return val.map((v) => this.parseGremlinValue(v));
|
|
301
|
-
case 'g:UUID':
|
|
302
|
-
return val;
|
|
303
|
-
case 'g:Date':
|
|
304
|
-
return new Date(val);
|
|
305
|
-
default:
|
|
306
|
-
return val;
|
|
307
|
-
}
|
|
149
|
+
ensureTraversal() {
|
|
150
|
+
this.ensureConnected();
|
|
151
|
+
if (!this.g) {
|
|
152
|
+
throw new Error('Graph traversal source not initialized');
|
|
308
153
|
}
|
|
309
|
-
|
|
310
|
-
return value.map(v => this.parseGremlinValue(v));
|
|
311
|
-
}
|
|
312
|
-
if (typeof value === 'object') {
|
|
313
|
-
const result = {};
|
|
314
|
-
Object.entries(value).forEach(([k, v]) => {
|
|
315
|
-
result[k] = this.parseGremlinValue(v);
|
|
316
|
-
});
|
|
317
|
-
return result;
|
|
318
|
-
}
|
|
319
|
-
return value;
|
|
154
|
+
return this.g;
|
|
320
155
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
156
|
+
// ==================== NODE OPERATIONS ====================
|
|
157
|
+
async createNode(options, _transaction) {
|
|
158
|
+
const g = this.ensureTraversal();
|
|
159
|
+
const { t } = this.gremlin.process;
|
|
160
|
+
// Start with addV for the first label
|
|
161
|
+
let traversal = g.addV(options.labels[0]);
|
|
162
|
+
// Add additional labels
|
|
163
|
+
for (let i = 1; i < options.labels.length; i++) {
|
|
164
|
+
traversal = traversal.property(t.label, options.labels[i]);
|
|
165
|
+
}
|
|
166
|
+
// Add properties
|
|
167
|
+
if (options.properties) {
|
|
168
|
+
for (const [key, value] of Object.entries(options.properties)) {
|
|
169
|
+
if (value !== undefined && value !== null) {
|
|
170
|
+
traversal = traversal.property(key, value);
|
|
328
171
|
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
return {
|
|
332
|
-
id: val.id,
|
|
333
|
-
labels: [val.label],
|
|
334
|
-
properties,
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
parseGremlinEdge(val) {
|
|
338
|
-
const properties = {};
|
|
339
|
-
if (val.properties) {
|
|
340
|
-
Object.entries(val.properties).forEach(([key, propVal]) => {
|
|
341
|
-
properties[key] = this.parseGremlinValue(propVal);
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
return {
|
|
345
|
-
id: val.id,
|
|
346
|
-
type: val.label,
|
|
347
|
-
startNodeId: val.outV,
|
|
348
|
-
endNodeId: val.inV,
|
|
349
|
-
properties,
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
parseGremlinPath(val) {
|
|
353
|
-
var _a;
|
|
354
|
-
const objects = ((_a = val.objects) === null || _a === void 0 ? void 0 : _a.map((obj) => this.parseGremlinValue(obj))) || [];
|
|
355
|
-
const nodes = [];
|
|
356
|
-
const relationships = [];
|
|
357
|
-
objects.forEach((obj) => {
|
|
358
|
-
if (obj.labels) {
|
|
359
|
-
nodes.push(obj);
|
|
360
|
-
}
|
|
361
|
-
else if (obj.type) {
|
|
362
|
-
relationships.push(obj);
|
|
363
172
|
}
|
|
364
|
-
});
|
|
365
|
-
return {
|
|
366
|
-
nodes,
|
|
367
|
-
relationships,
|
|
368
|
-
length: relationships.length,
|
|
369
|
-
start: nodes[0],
|
|
370
|
-
end: nodes[nodes.length - 1],
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
parseGremlinMap(val) {
|
|
374
|
-
const result = {};
|
|
375
|
-
for (let i = 0; i < val.length; i += 2) {
|
|
376
|
-
const key = this.parseGremlinValue(val[i]);
|
|
377
|
-
const value = this.parseGremlinValue(val[i + 1]);
|
|
378
|
-
result[key] = value;
|
|
379
173
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
return [];
|
|
385
|
-
return response.results;
|
|
386
|
-
}
|
|
387
|
-
// ==================== NODE OPERATIONS ====================
|
|
388
|
-
async createNode(connection, options, transaction) {
|
|
389
|
-
const startTime = Date.now();
|
|
390
|
-
const neptuneConn = connection;
|
|
391
|
-
const isGremlin = neptuneConn.getConfig().queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN;
|
|
392
|
-
const labels = this.normalizeLabels(options.labels);
|
|
393
|
-
let query;
|
|
394
|
-
let params = {};
|
|
395
|
-
if (isGremlin) {
|
|
396
|
-
// Gremlin addV query
|
|
397
|
-
const propsSteps = Object.entries(options.properties)
|
|
398
|
-
.map(([key, value]) => `.property('${key}', ${this.gremlinValue(value)})`)
|
|
399
|
-
.join('');
|
|
400
|
-
query = `g.addV('${labels[0]}')${propsSteps}`;
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
// openCypher CREATE query
|
|
404
|
-
const labelStr = labels.map(l => this.escapeIdentifier(l)).join(':');
|
|
405
|
-
const propEntries = Object.entries(options.properties);
|
|
406
|
-
const propStr = propEntries.map(([k], i) => `${k}: $prop${i}`).join(', ');
|
|
407
|
-
propEntries.forEach(([, v], i) => { params[`prop${i}`] = v; });
|
|
408
|
-
query = `CREATE (n:${labelStr} {${propStr}}) RETURN n`;
|
|
409
|
-
}
|
|
410
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
174
|
+
const result = await traversal.next();
|
|
175
|
+
const vertex = result.value;
|
|
176
|
+
// Fetch the complete vertex with properties
|
|
177
|
+
const fullVertex = await g.V(vertex.id).valueMap(true).next();
|
|
411
178
|
return {
|
|
412
|
-
|
|
413
|
-
executionTime: Date.now() - startTime,
|
|
414
|
-
node: result.data.length > 0 ? this.parseNode(result.data[0]) : undefined,
|
|
179
|
+
node: this.mapGremlinVertex(vertex.id, fullVertex.value),
|
|
415
180
|
created: true,
|
|
416
181
|
};
|
|
417
182
|
}
|
|
418
|
-
async findNodes(
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
183
|
+
async findNodes(options, _transaction) {
|
|
184
|
+
var _a, _b;
|
|
185
|
+
const g = this.ensureTraversal();
|
|
186
|
+
let traversal = g.V();
|
|
187
|
+
// Filter by labels
|
|
188
|
+
if ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
189
|
+
traversal = traversal.hasLabel(...options.labels);
|
|
190
|
+
}
|
|
191
|
+
// Apply where conditions
|
|
192
|
+
if (options.where) {
|
|
193
|
+
traversal = this.applyWhereConditions(traversal, options.where);
|
|
194
|
+
}
|
|
195
|
+
// Apply ordering
|
|
196
|
+
if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
|
|
197
|
+
const { order } = this.gremlin.process;
|
|
198
|
+
for (const orderSpec of options.orderBy) {
|
|
199
|
+
const orderDir = orderSpec.direction.toUpperCase() === 'DESC' ? order.desc : order.asc;
|
|
200
|
+
traversal = traversal.order().by(orderSpec.property, orderDir);
|
|
201
|
+
}
|
|
426
202
|
}
|
|
427
|
-
|
|
428
|
-
|
|
203
|
+
// Apply pagination
|
|
204
|
+
if (options.skip) {
|
|
205
|
+
traversal = traversal.skip(options.skip);
|
|
429
206
|
}
|
|
430
|
-
|
|
431
|
-
|
|
207
|
+
if (options.limit) {
|
|
208
|
+
traversal = traversal.limit(options.limit);
|
|
209
|
+
}
|
|
210
|
+
// Get vertices with properties
|
|
211
|
+
const results = await traversal.valueMap(true).toList();
|
|
212
|
+
const nodes = results.map((v) => this.mapGremlinVertexFromValueMap(v));
|
|
432
213
|
return {
|
|
433
|
-
success: true,
|
|
434
|
-
executionTime: Date.now() - startTime,
|
|
435
214
|
nodes,
|
|
436
215
|
count: nodes.length,
|
|
437
|
-
hasMore: options.limit !== undefined && nodes.length === options.limit,
|
|
438
216
|
};
|
|
439
217
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
query += `.hasLabel('${labels.join("', '")}')`;
|
|
445
|
-
}
|
|
446
|
-
if (options.properties) {
|
|
447
|
-
Object.entries(options.properties).forEach(([key, value]) => {
|
|
448
|
-
query += `.has('${key}', ${this.gremlinValue(value)})`;
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
452
|
-
const orderSteps = options.orderBy.map(o => `by('${o.property}', ${o.direction === 'DESC' ? 'desc' : 'asc'})`).join('.');
|
|
453
|
-
query += `.order().${orderSteps}`;
|
|
454
|
-
}
|
|
455
|
-
if (options.skip) {
|
|
456
|
-
query += `.skip(${options.skip})`;
|
|
457
|
-
}
|
|
458
|
-
if (options.limit) {
|
|
459
|
-
query += `.limit(${options.limit})`;
|
|
460
|
-
}
|
|
461
|
-
return query;
|
|
462
|
-
}
|
|
463
|
-
buildCypherFindNodesQuery(options, params) {
|
|
464
|
-
const labels = options.labels ? this.normalizeLabels(options.labels) : [];
|
|
465
|
-
const labelStr = labels.length > 0 ? ':' + labels.map(l => this.escapeIdentifier(l)).join(':') : '';
|
|
466
|
-
let query = `MATCH (n${labelStr})`;
|
|
467
|
-
if (options.properties && Object.keys(options.properties).length > 0) {
|
|
468
|
-
const whereParts = [];
|
|
469
|
-
Object.entries(options.properties).forEach(([key, value], index) => {
|
|
470
|
-
const paramName = `prop_${index}`;
|
|
471
|
-
whereParts.push(`n.${key} = $${paramName}`);
|
|
472
|
-
params[paramName] = value;
|
|
473
|
-
});
|
|
474
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
475
|
-
}
|
|
476
|
-
query += ' RETURN n';
|
|
477
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
478
|
-
const orderParts = options.orderBy.map(o => `n.${o.property} ${o.direction}`);
|
|
479
|
-
query += ` ORDER BY ${orderParts.join(', ')}`;
|
|
480
|
-
}
|
|
481
|
-
if (options.skip !== undefined) {
|
|
482
|
-
query += ` SKIP ${options.skip}`;
|
|
483
|
-
}
|
|
484
|
-
if (options.limit !== undefined) {
|
|
485
|
-
query += ` LIMIT ${options.limit}`;
|
|
486
|
-
}
|
|
487
|
-
return query;
|
|
488
|
-
}
|
|
489
|
-
async findNodeById(connection, id, transaction) {
|
|
490
|
-
const neptuneConn = connection;
|
|
491
|
-
const isGremlin = neptuneConn.getConfig().queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN;
|
|
492
|
-
const query = isGremlin
|
|
493
|
-
? `g.V('${id}')`
|
|
494
|
-
: `MATCH (n) WHERE id(n) = $id RETURN n`;
|
|
495
|
-
const result = await this.executeRaw(connection, { query, params: { id } }, transaction);
|
|
496
|
-
if (result.data.length === 0) {
|
|
218
|
+
async findNodeById(id, _transaction) {
|
|
219
|
+
const g = this.ensureTraversal();
|
|
220
|
+
const results = await g.V(id).valueMap(true).toList();
|
|
221
|
+
if (results.length === 0) {
|
|
497
222
|
return null;
|
|
498
223
|
}
|
|
499
|
-
return this.
|
|
224
|
+
return this.mapGremlinVertexFromValueMap(results[0]);
|
|
500
225
|
}
|
|
501
|
-
async updateNode(
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (isGremlin) {
|
|
508
|
-
query = `g.V('${options.id}')`;
|
|
509
|
-
if (options.set) {
|
|
510
|
-
Object.entries(options.set).forEach(([key, value]) => {
|
|
511
|
-
query += `.property('${key}', ${this.gremlinValue(value)})`;
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
if (options.remove && options.remove.length > 0) {
|
|
515
|
-
options.remove.forEach(prop => {
|
|
516
|
-
query += `.properties('${prop}').drop()`;
|
|
517
|
-
});
|
|
518
|
-
}
|
|
226
|
+
async updateNode(options, _transaction) {
|
|
227
|
+
var _a;
|
|
228
|
+
const g = this.ensureTraversal();
|
|
229
|
+
let traversal;
|
|
230
|
+
if (options.id) {
|
|
231
|
+
traversal = g.V(options.id);
|
|
519
232
|
}
|
|
520
233
|
else {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
if (options.set) {
|
|
525
|
-
Object.entries(options.set).forEach(([key, value], index) => {
|
|
526
|
-
const paramName = `set_${index}`;
|
|
527
|
-
setParts.push(`n.${key} = $${paramName}`);
|
|
528
|
-
params[paramName] = value;
|
|
529
|
-
});
|
|
234
|
+
traversal = g.V();
|
|
235
|
+
if ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
236
|
+
traversal = traversal.hasLabel(...options.labels);
|
|
530
237
|
}
|
|
531
|
-
if (
|
|
532
|
-
|
|
238
|
+
if (options.where) {
|
|
239
|
+
traversal = this.applyWhereConditions(traversal, options.where);
|
|
533
240
|
}
|
|
534
|
-
|
|
535
|
-
|
|
241
|
+
}
|
|
242
|
+
// Update properties
|
|
243
|
+
if (options.properties) {
|
|
244
|
+
for (const [key, value] of Object.entries(options.properties)) {
|
|
245
|
+
if (value !== undefined && value !== null) {
|
|
246
|
+
traversal = traversal.property(this.gremlin.process.cardinality.single, key, value);
|
|
247
|
+
}
|
|
536
248
|
}
|
|
537
|
-
query += ' RETURN n';
|
|
538
249
|
}
|
|
539
|
-
const
|
|
250
|
+
const results = await traversal.valueMap(true).toList();
|
|
251
|
+
const nodes = results.map((v) => this.mapGremlinVertexFromValueMap(v));
|
|
540
252
|
return {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
updated:
|
|
545
|
-
matchedCount: result.data.length,
|
|
546
|
-
modifiedCount: Object.keys(options.set || {}).length,
|
|
253
|
+
node: nodes.length === 1 ? nodes[0] : undefined,
|
|
254
|
+
nodes: nodes.length > 1 ? nodes : undefined,
|
|
255
|
+
updatedCount: nodes.length,
|
|
256
|
+
updated: nodes.length > 0,
|
|
547
257
|
};
|
|
548
258
|
}
|
|
549
|
-
async deleteNode(
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const labels = this.normalizeLabels(options.labels);
|
|
561
|
-
query = `g.V().hasLabel('${labels.join("', '")}').drop()`;
|
|
259
|
+
async deleteNode(options, _transaction) {
|
|
260
|
+
var _a, _b;
|
|
261
|
+
const g = this.ensureTraversal();
|
|
262
|
+
let traversal;
|
|
263
|
+
if (options.id) {
|
|
264
|
+
traversal = g.V(options.id);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
traversal = g.V();
|
|
268
|
+
if ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
269
|
+
traversal = traversal.hasLabel(...options.labels);
|
|
562
270
|
}
|
|
563
|
-
|
|
564
|
-
|
|
271
|
+
if (options.where) {
|
|
272
|
+
traversal = this.applyWhereConditions(traversal, options.where);
|
|
565
273
|
}
|
|
566
274
|
}
|
|
275
|
+
// Count before delete
|
|
276
|
+
const countResult = await traversal.count().next();
|
|
277
|
+
const count = countResult.value;
|
|
278
|
+
// In Gremlin, drop() removes the vertex and all connected edges
|
|
279
|
+
if (options.id) {
|
|
280
|
+
await g.V(options.id).drop().iterate();
|
|
281
|
+
}
|
|
567
282
|
else {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
283
|
+
let dropTraversal = g.V();
|
|
284
|
+
if ((_b = options.labels) === null || _b === void 0 ? void 0 : _b.length) {
|
|
285
|
+
dropTraversal = dropTraversal.hasLabel(...options.labels);
|
|
571
286
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
query = `MATCH (n:${labels.join(':')}) ${options.detach ? 'DETACH DELETE' : 'DELETE'} n`;
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Must specify id or labels for delete');
|
|
287
|
+
if (options.where) {
|
|
288
|
+
dropTraversal = this.applyWhereConditions(dropTraversal, options.where);
|
|
578
289
|
}
|
|
290
|
+
await dropTraversal.drop().iterate();
|
|
579
291
|
}
|
|
580
|
-
await this.executeRaw(connection, { query, params }, transaction);
|
|
581
292
|
return {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
deletedCount: 1, // Neptune doesn't return count
|
|
293
|
+
deleted: count > 0,
|
|
294
|
+
deletedCount: count,
|
|
585
295
|
};
|
|
586
296
|
}
|
|
587
|
-
async mergeNode(
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
297
|
+
async mergeNode(options, _transaction) {
|
|
298
|
+
const g = this.ensureTraversal();
|
|
299
|
+
// Check if node exists
|
|
300
|
+
let matchTraversal = g.V().hasLabel(options.labels[0]);
|
|
301
|
+
for (const [key, value] of Object.entries(options.matchProperties)) {
|
|
302
|
+
matchTraversal = matchTraversal.has(key, value);
|
|
303
|
+
}
|
|
304
|
+
const existing = await matchTraversal.toList();
|
|
305
|
+
if (existing.length > 0) {
|
|
306
|
+
// Update existing node
|
|
307
|
+
let updateTraversal = g.V(existing[0].id);
|
|
308
|
+
if (options.onMatch) {
|
|
309
|
+
for (const [key, value] of Object.entries(options.onMatch)) {
|
|
310
|
+
if (value !== undefined && value !== null) {
|
|
311
|
+
updateTraversal = updateTraversal.property(this.gremlin.process.cardinality.single, key, value);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const updated = await updateTraversal.valueMap(true).next();
|
|
316
|
+
return {
|
|
317
|
+
node: this.mapGremlinVertexFromValueMap(updated.value),
|
|
318
|
+
created: false,
|
|
319
|
+
merged: true,
|
|
320
|
+
};
|
|
606
321
|
}
|
|
607
322
|
else {
|
|
608
|
-
//
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const createProps = Object.entries(options.onCreate)
|
|
616
|
-
.map(([k], i) => `n.${k} = $create${i}`)
|
|
617
|
-
.join(', ');
|
|
618
|
-
Object.entries(options.onCreate).forEach(([, v], i) => { params[`create${i}`] = v; });
|
|
619
|
-
query += ` ON CREATE SET ${createProps}`;
|
|
323
|
+
// Create new node
|
|
324
|
+
let createTraversal = g.addV(options.labels[0]);
|
|
325
|
+
// Add match properties
|
|
326
|
+
for (const [key, value] of Object.entries(options.matchProperties)) {
|
|
327
|
+
if (value !== undefined && value !== null) {
|
|
328
|
+
createTraversal = createTraversal.property(key, value);
|
|
329
|
+
}
|
|
620
330
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
331
|
+
// Add onCreate properties
|
|
332
|
+
if (options.onCreate) {
|
|
333
|
+
for (const [key, value] of Object.entries(options.onCreate)) {
|
|
334
|
+
if (value !== undefined && value !== null) {
|
|
335
|
+
createTraversal = createTraversal.property(key, value);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
627
338
|
}
|
|
628
|
-
|
|
339
|
+
const created = await createTraversal.next();
|
|
340
|
+
const fullVertex = await g.V(created.value.id).valueMap(true).next();
|
|
341
|
+
return {
|
|
342
|
+
node: this.mapGremlinVertexFromValueMap(fullVertex.value),
|
|
343
|
+
created: true,
|
|
344
|
+
merged: true,
|
|
345
|
+
};
|
|
629
346
|
}
|
|
630
|
-
|
|
347
|
+
}
|
|
348
|
+
// ==================== LABEL MANAGEMENT ====================
|
|
349
|
+
async addLabels(options, _transaction) {
|
|
350
|
+
const g = this.ensureTraversal();
|
|
351
|
+
// In Gremlin/Neptune, vertices have a single label
|
|
352
|
+
// We can add additional labels by adding them as properties or using multi-labels if supported
|
|
353
|
+
// Neptune supports multi-labels via the ::label property pattern
|
|
354
|
+
// For now, we'll treat it as a limitation - Neptune vertices typically have a single label
|
|
355
|
+
// Get the vertex first
|
|
356
|
+
const vertex = await g.V(options.id).next();
|
|
357
|
+
if (!vertex.value) {
|
|
358
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
359
|
+
}
|
|
360
|
+
// Neptune doesn't natively support adding labels to existing vertices
|
|
361
|
+
// This is a limitation of the Gremlin model
|
|
362
|
+
// We store additional labels as a property
|
|
363
|
+
const existingLabelsResult = await g.V(options.id).values('_additionalLabels').toList();
|
|
364
|
+
const existingLabels = existingLabelsResult.length > 0
|
|
365
|
+
? JSON.parse(existingLabelsResult[0])
|
|
366
|
+
: [];
|
|
367
|
+
const newLabels = [...new Set([...existingLabels, ...options.labels])];
|
|
368
|
+
await g.V(options.id)
|
|
369
|
+
.property('_additionalLabels', JSON.stringify(newLabels))
|
|
370
|
+
.next();
|
|
371
|
+
const fullVertex = await g.V(options.id).valueMap(true).next();
|
|
372
|
+
const node = this.mapGremlinVertexFromValueMap(fullVertex.value);
|
|
373
|
+
// Add the additional labels to the node's labels array
|
|
374
|
+
node.labels = [...new Set([...node.labels, ...options.labels])];
|
|
631
375
|
return {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
376
|
+
node,
|
|
377
|
+
addedLabels: options.labels,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
async removeLabels(options, _transaction) {
|
|
381
|
+
const g = this.ensureTraversal();
|
|
382
|
+
// Get the vertex first
|
|
383
|
+
const vertex = await g.V(options.id).next();
|
|
384
|
+
if (!vertex.value) {
|
|
385
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
386
|
+
}
|
|
387
|
+
// Get existing additional labels
|
|
388
|
+
const existingLabelsResult = await g.V(options.id).values('_additionalLabels').toList();
|
|
389
|
+
const existingLabels = existingLabelsResult.length > 0
|
|
390
|
+
? JSON.parse(existingLabelsResult[0])
|
|
391
|
+
: [];
|
|
392
|
+
// Remove the specified labels
|
|
393
|
+
const newLabels = existingLabels.filter(l => !options.labels.includes(l));
|
|
394
|
+
await g.V(options.id)
|
|
395
|
+
.property('_additionalLabels', JSON.stringify(newLabels))
|
|
396
|
+
.next();
|
|
397
|
+
const fullVertex = await g.V(options.id).valueMap(true).next();
|
|
398
|
+
const node = this.mapGremlinVertexFromValueMap(fullVertex.value);
|
|
399
|
+
return {
|
|
400
|
+
node,
|
|
401
|
+
removedLabels: options.labels,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
async setLabels(options, _transaction) {
|
|
405
|
+
const g = this.ensureTraversal();
|
|
406
|
+
// Get the vertex first
|
|
407
|
+
const vertex = await g.V(options.id).next();
|
|
408
|
+
if (!vertex.value) {
|
|
409
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
410
|
+
}
|
|
411
|
+
// Get current labels (primary label + additional)
|
|
412
|
+
const primaryLabel = await g.V(options.id).label().next();
|
|
413
|
+
const existingLabelsResult = await g.V(options.id).values('_additionalLabels').toList();
|
|
414
|
+
const additionalLabels = existingLabelsResult.length > 0
|
|
415
|
+
? JSON.parse(existingLabelsResult[0])
|
|
416
|
+
: [];
|
|
417
|
+
const previousLabels = [primaryLabel.value, ...additionalLabels];
|
|
418
|
+
// In Neptune, we can't change the primary label, so we store all labels as additional
|
|
419
|
+
// Filter out the primary label from the new labels
|
|
420
|
+
const newAdditionalLabels = options.labels.filter(l => l !== primaryLabel.value);
|
|
421
|
+
await g.V(options.id)
|
|
422
|
+
.property('_additionalLabels', JSON.stringify(newAdditionalLabels))
|
|
423
|
+
.next();
|
|
424
|
+
const fullVertex = await g.V(options.id).valueMap(true).next();
|
|
425
|
+
const node = this.mapGremlinVertexFromValueMap(fullVertex.value);
|
|
426
|
+
node.labels = [primaryLabel.value, ...newAdditionalLabels];
|
|
427
|
+
return {
|
|
428
|
+
node,
|
|
429
|
+
previousLabels,
|
|
430
|
+
newLabels: options.labels,
|
|
637
431
|
};
|
|
638
432
|
}
|
|
639
433
|
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
640
|
-
async createRelationship(
|
|
641
|
-
const
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
.join('')
|
|
653
|
-
: '';
|
|
654
|
-
query = `g.V('${fromId}').addE('${options.type}').to(g.V('${toId}'))${propsSteps}`;
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
const fromMatch = this.buildCypherNodeMatch(options.fromNode, 'from', params, 'from_');
|
|
658
|
-
const toMatch = this.buildCypherNodeMatch(options.toNode, 'to', params, 'to_');
|
|
659
|
-
let propsStr = '';
|
|
660
|
-
if (options.properties && Object.keys(options.properties).length > 0) {
|
|
661
|
-
propsStr = ' {' + Object.entries(options.properties)
|
|
662
|
-
.map(([k], i) => { params[`rel${i}`] = options.properties[k]; return `${k}: $rel${i}`; })
|
|
663
|
-
.join(', ') + '}';
|
|
434
|
+
async createRelationship(options, _transaction) {
|
|
435
|
+
const g = this.ensureTraversal();
|
|
436
|
+
const { __ } = this.gremlin.process;
|
|
437
|
+
let traversal = g.V(options.startNodeId)
|
|
438
|
+
.addE(options.type)
|
|
439
|
+
.to(__.V(options.endNodeId));
|
|
440
|
+
// Add properties
|
|
441
|
+
if (options.properties) {
|
|
442
|
+
for (const [key, value] of Object.entries(options.properties)) {
|
|
443
|
+
if (value !== undefined && value !== null) {
|
|
444
|
+
traversal = traversal.property(key, value);
|
|
445
|
+
}
|
|
664
446
|
}
|
|
665
|
-
query = `
|
|
666
|
-
MATCH ${fromMatch}, ${toMatch}
|
|
667
|
-
CREATE (from)-[r:${options.type}${propsStr}]->(to)
|
|
668
|
-
RETURN r
|
|
669
|
-
`;
|
|
670
447
|
}
|
|
671
|
-
const result = await
|
|
448
|
+
const result = await traversal.next();
|
|
449
|
+
const edge = result.value;
|
|
450
|
+
// Fetch full edge with properties
|
|
451
|
+
const fullEdge = await g.E(edge.id).valueMap(true).next();
|
|
672
452
|
return {
|
|
673
|
-
|
|
674
|
-
executionTime: Date.now() - startTime,
|
|
675
|
-
relationship: result.data.length > 0 ? this.parseRelationship(isGremlin ? result.data[0] : result.data[0].r) : undefined,
|
|
453
|
+
relationship: this.mapGremlinEdge(edge, fullEdge.value, options.startNodeId, options.endNodeId),
|
|
676
454
|
created: true,
|
|
677
455
|
};
|
|
678
456
|
}
|
|
679
|
-
async findRelationships(
|
|
680
|
-
const
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
const types = Array.isArray(options.type) ? options.type : [options.type];
|
|
689
|
-
query += `.hasLabel('${types.join("', '")}')`;
|
|
690
|
-
}
|
|
691
|
-
if (options.properties) {
|
|
692
|
-
Object.entries(options.properties).forEach(([k, v]) => {
|
|
693
|
-
query += `.has('${k}', ${this.gremlinValue(v)})`;
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
if (options.limit) {
|
|
697
|
-
query += `.limit(${options.limit})`;
|
|
698
|
-
}
|
|
457
|
+
async findRelationships(options, _transaction) {
|
|
458
|
+
const g = this.ensureTraversal();
|
|
459
|
+
const { __ } = this.gremlin.process;
|
|
460
|
+
let traversal;
|
|
461
|
+
if (options.startNodeId) {
|
|
462
|
+
traversal = g.V(options.startNodeId).outE();
|
|
463
|
+
}
|
|
464
|
+
else if (options.endNodeId) {
|
|
465
|
+
traversal = g.V(options.endNodeId).inE();
|
|
699
466
|
}
|
|
700
467
|
else {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
468
|
+
traversal = g.E();
|
|
469
|
+
}
|
|
470
|
+
// Filter by type
|
|
471
|
+
const types = options.type
|
|
472
|
+
? (Array.isArray(options.type) ? options.type : [options.type])
|
|
473
|
+
: (options.types || []);
|
|
474
|
+
if (types.length > 0) {
|
|
475
|
+
traversal = traversal.hasLabel(...types);
|
|
476
|
+
}
|
|
477
|
+
// Apply where conditions
|
|
478
|
+
if (options.where) {
|
|
479
|
+
traversal = this.applyWhereConditions(traversal, options.where);
|
|
480
|
+
}
|
|
481
|
+
// Apply endpoint filtering if both are specified
|
|
482
|
+
if (options.startNodeId && options.endNodeId) {
|
|
483
|
+
traversal = traversal.where(__.inV().hasId(options.endNodeId));
|
|
484
|
+
}
|
|
485
|
+
// Apply pagination
|
|
486
|
+
if (options.skip) {
|
|
487
|
+
traversal = traversal.skip(options.skip);
|
|
713
488
|
}
|
|
714
|
-
|
|
715
|
-
|
|
489
|
+
if (options.limit) {
|
|
490
|
+
traversal = traversal.limit(options.limit);
|
|
491
|
+
}
|
|
492
|
+
// Get edges with in/out vertices
|
|
493
|
+
const results = await traversal.project('edge', 'outV', 'inV')
|
|
494
|
+
.by(__.valueMap(true))
|
|
495
|
+
.by(__.outV().id())
|
|
496
|
+
.by(__.inV().id())
|
|
497
|
+
.toList();
|
|
498
|
+
const relationships = results.map((r) => this.mapGremlinEdgeFromProject(r));
|
|
716
499
|
return {
|
|
717
|
-
success: true,
|
|
718
|
-
executionTime: Date.now() - startTime,
|
|
719
500
|
relationships,
|
|
720
501
|
count: relationships.length,
|
|
721
|
-
hasMore: options.limit !== undefined && relationships.length === options.limit,
|
|
722
502
|
};
|
|
723
503
|
}
|
|
724
|
-
async findRelationshipById(
|
|
725
|
-
const
|
|
726
|
-
const
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
504
|
+
async findRelationshipById(id, _transaction) {
|
|
505
|
+
const g = this.ensureTraversal();
|
|
506
|
+
const { __ } = this.gremlin.process;
|
|
507
|
+
const results = await g.E(id)
|
|
508
|
+
.project('edge', 'outV', 'inV')
|
|
509
|
+
.by(__.valueMap(true))
|
|
510
|
+
.by(__.outV().id())
|
|
511
|
+
.by(__.inV().id())
|
|
512
|
+
.toList();
|
|
513
|
+
if (results.length === 0) {
|
|
732
514
|
return null;
|
|
733
515
|
}
|
|
734
|
-
return this.
|
|
516
|
+
return this.mapGremlinEdgeFromProject(results[0]);
|
|
735
517
|
}
|
|
736
|
-
async updateRelationship(
|
|
737
|
-
const
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (isGremlin) {
|
|
743
|
-
query = `g.E('${options.id}')`;
|
|
744
|
-
if (options.set) {
|
|
745
|
-
Object.entries(options.set).forEach(([k, v]) => {
|
|
746
|
-
query += `.property('${k}', ${this.gremlinValue(v)})`;
|
|
747
|
-
});
|
|
748
|
-
}
|
|
518
|
+
async updateRelationship(options, _transaction) {
|
|
519
|
+
const g = this.ensureTraversal();
|
|
520
|
+
const { __ } = this.gremlin.process;
|
|
521
|
+
let traversal;
|
|
522
|
+
if (options.id) {
|
|
523
|
+
traversal = g.E(options.id);
|
|
749
524
|
}
|
|
750
525
|
else {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
});
|
|
758
|
-
query += ` SET ${setParts.join(', ')}`;
|
|
526
|
+
traversal = g.E();
|
|
527
|
+
if (options.type) {
|
|
528
|
+
traversal = traversal.hasLabel(options.type);
|
|
529
|
+
}
|
|
530
|
+
if (options.where) {
|
|
531
|
+
traversal = this.applyWhereConditions(traversal, options.where);
|
|
759
532
|
}
|
|
760
|
-
query += ' RETURN r';
|
|
761
533
|
}
|
|
762
|
-
|
|
534
|
+
// Update properties
|
|
535
|
+
if (options.properties) {
|
|
536
|
+
for (const [key, value] of Object.entries(options.properties)) {
|
|
537
|
+
if (value !== undefined && value !== null) {
|
|
538
|
+
traversal = traversal.property(key, value);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
// Get updated edges
|
|
543
|
+
const results = await traversal.project('edge', 'outV', 'inV')
|
|
544
|
+
.by(__.valueMap(true))
|
|
545
|
+
.by(__.outV().id())
|
|
546
|
+
.by(__.inV().id())
|
|
547
|
+
.toList();
|
|
548
|
+
const relationships = results.map((r) => this.mapGremlinEdgeFromProject(r));
|
|
763
549
|
return {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
updated:
|
|
768
|
-
matchedCount: result.data.length,
|
|
769
|
-
modifiedCount: Object.keys(options.set || {}).length,
|
|
550
|
+
relationship: relationships.length === 1 ? relationships[0] : undefined,
|
|
551
|
+
relationships: relationships.length > 1 ? relationships : undefined,
|
|
552
|
+
updatedCount: relationships.length,
|
|
553
|
+
updated: relationships.length > 0,
|
|
770
554
|
};
|
|
771
555
|
}
|
|
772
|
-
async deleteRelationship(
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
if (options.
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
else if (options.type) {
|
|
783
|
-
const types = Array.isArray(options.type) ? options.type : [options.type];
|
|
784
|
-
query = `g.E().hasLabel('${types.join("', '")}').drop()`;
|
|
556
|
+
async deleteRelationship(options, _transaction) {
|
|
557
|
+
const g = this.ensureTraversal();
|
|
558
|
+
let traversal;
|
|
559
|
+
if (options.id) {
|
|
560
|
+
traversal = g.E(options.id);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
if (options.startNodeId && options.endNodeId && options.type) {
|
|
564
|
+
traversal = g.V(options.startNodeId).outE(options.type).where(this.gremlin.process.__.inV().hasId(options.endNodeId));
|
|
785
565
|
}
|
|
786
566
|
else {
|
|
787
|
-
|
|
567
|
+
traversal = g.E();
|
|
568
|
+
if (options.type) {
|
|
569
|
+
traversal = traversal.hasLabel(options.type);
|
|
570
|
+
}
|
|
571
|
+
if (options.where) {
|
|
572
|
+
traversal = this.applyWhereConditions(traversal, options.where);
|
|
573
|
+
}
|
|
788
574
|
}
|
|
789
575
|
}
|
|
576
|
+
// Count before delete
|
|
577
|
+
let countTraversal;
|
|
578
|
+
if (options.id) {
|
|
579
|
+
countTraversal = g.E(options.id);
|
|
580
|
+
}
|
|
581
|
+
else if (options.startNodeId && options.endNodeId && options.type) {
|
|
582
|
+
countTraversal = g.V(options.startNodeId).outE(options.type).where(this.gremlin.process.__.inV().hasId(options.endNodeId));
|
|
583
|
+
}
|
|
790
584
|
else {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
else if (options.type) {
|
|
796
|
-
const types = Array.isArray(options.type) ? options.type : [options.type];
|
|
797
|
-
query = `MATCH ()-[r:${types.join('|')}]->() DELETE r`;
|
|
798
|
-
}
|
|
799
|
-
else {
|
|
800
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Must specify id or type for delete');
|
|
585
|
+
countTraversal = g.E();
|
|
586
|
+
if (options.type) {
|
|
587
|
+
countTraversal = countTraversal.hasLabel(options.type);
|
|
801
588
|
}
|
|
802
589
|
}
|
|
803
|
-
await
|
|
590
|
+
const countResult = await countTraversal.count().next();
|
|
591
|
+
const count = countResult.value;
|
|
592
|
+
// Delete
|
|
593
|
+
await traversal.drop().iterate();
|
|
804
594
|
return {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
deletedCount: 1,
|
|
595
|
+
deleted: count > 0,
|
|
596
|
+
deletedCount: count,
|
|
808
597
|
};
|
|
809
598
|
}
|
|
810
|
-
async mergeRelationship(
|
|
811
|
-
const
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
let
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
599
|
+
async mergeRelationship(options, _transaction) {
|
|
600
|
+
const g = this.ensureTraversal();
|
|
601
|
+
const { __ } = this.gremlin.process;
|
|
602
|
+
// Check if relationship exists
|
|
603
|
+
let matchTraversal = g.V(options.startNodeId).outE(options.type).where(__.inV().hasId(options.endNodeId));
|
|
604
|
+
if (options.matchProperties) {
|
|
605
|
+
for (const [key, value] of Object.entries(options.matchProperties)) {
|
|
606
|
+
matchTraversal = matchTraversal.has(key, value);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const existing = await matchTraversal.toList();
|
|
610
|
+
if (existing.length > 0) {
|
|
611
|
+
// Update existing relationship
|
|
612
|
+
let updateTraversal = g.E(existing[0].id);
|
|
613
|
+
if (options.onMatch) {
|
|
614
|
+
for (const [key, value] of Object.entries(options.onMatch)) {
|
|
615
|
+
if (value !== undefined && value !== null) {
|
|
616
|
+
updateTraversal = updateTraversal.property(key, value);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const updated = await updateTraversal.project('edge', 'outV', 'inV')
|
|
621
|
+
.by(__.valueMap(true))
|
|
622
|
+
.by(__.outV().id())
|
|
623
|
+
.by(__.inV().id())
|
|
624
|
+
.next();
|
|
625
|
+
return {
|
|
626
|
+
relationship: this.mapGremlinEdgeFromProject(updated.value),
|
|
627
|
+
created: false,
|
|
628
|
+
merged: true,
|
|
629
|
+
};
|
|
829
630
|
}
|
|
830
631
|
else {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
632
|
+
// Create new relationship
|
|
633
|
+
let createTraversal = g.V(options.startNodeId)
|
|
634
|
+
.addE(options.type)
|
|
635
|
+
.to(__.V(options.endNodeId));
|
|
636
|
+
// Add match properties
|
|
637
|
+
if (options.matchProperties) {
|
|
638
|
+
for (const [key, value] of Object.entries(options.matchProperties)) {
|
|
639
|
+
if (value !== undefined && value !== null) {
|
|
640
|
+
createTraversal = createTraversal.property(key, value);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
842
643
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
644
|
+
// Add onCreate properties
|
|
645
|
+
if (options.onCreate) {
|
|
646
|
+
for (const [key, value] of Object.entries(options.onCreate)) {
|
|
647
|
+
if (value !== undefined && value !== null) {
|
|
648
|
+
createTraversal = createTraversal.property(key, value);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
848
651
|
}
|
|
849
|
-
|
|
652
|
+
const created = await createTraversal.next();
|
|
653
|
+
const fullEdge = await g.E(created.value.id).project('edge', 'outV', 'inV')
|
|
654
|
+
.by(__.valueMap(true))
|
|
655
|
+
.by(__.outV().id())
|
|
656
|
+
.by(__.inV().id())
|
|
657
|
+
.next();
|
|
658
|
+
return {
|
|
659
|
+
relationship: this.mapGremlinEdgeFromProject(fullEdge.value),
|
|
660
|
+
created: true,
|
|
661
|
+
merged: true,
|
|
662
|
+
};
|
|
850
663
|
}
|
|
851
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
852
|
-
return {
|
|
853
|
-
success: true,
|
|
854
|
-
executionTime: Date.now() - startTime,
|
|
855
|
-
relationship: result.data.length > 0 ? this.parseRelationship(isGremlin ? result.data[0] : result.data[0].r) : undefined,
|
|
856
|
-
created: true,
|
|
857
|
-
matched: false,
|
|
858
|
-
};
|
|
859
664
|
}
|
|
860
|
-
// ====================
|
|
861
|
-
async traverse(
|
|
862
|
-
|
|
863
|
-
const
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
665
|
+
// ==================== TRAVERSAL OPERATIONS ====================
|
|
666
|
+
async traverse(options, _transaction) {
|
|
667
|
+
var _a;
|
|
668
|
+
const g = this.ensureTraversal();
|
|
669
|
+
const { __ } = this.gremlin.process;
|
|
670
|
+
const maxDepth = options.maxDepth || 3;
|
|
671
|
+
// Build direction
|
|
672
|
+
let edgeDirection;
|
|
673
|
+
switch (options.direction) {
|
|
674
|
+
case enums_1.TraversalDirection.INCOMING:
|
|
675
|
+
case 'INCOMING':
|
|
676
|
+
edgeDirection = 'in';
|
|
677
|
+
break;
|
|
678
|
+
case enums_1.TraversalDirection.OUTGOING:
|
|
679
|
+
case 'OUTGOING':
|
|
680
|
+
edgeDirection = 'out';
|
|
681
|
+
break;
|
|
682
|
+
default:
|
|
683
|
+
edgeDirection = 'both';
|
|
684
|
+
}
|
|
685
|
+
// Build traversal
|
|
686
|
+
let traversal = g.V(options.startNodeId);
|
|
687
|
+
// Use repeat for variable-length traversal
|
|
688
|
+
const repeatStep = edgeDirection === 'out' ? __.out() :
|
|
689
|
+
edgeDirection === 'in' ? __.in_() :
|
|
690
|
+
__.both();
|
|
691
|
+
if ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
692
|
+
traversal = traversal.repeat(edgeDirection === 'out' ? __.out(...options.relationshipTypes) :
|
|
693
|
+
edgeDirection === 'in' ? __.in_(...options.relationshipTypes) :
|
|
694
|
+
__.both(...options.relationshipTypes)).times(maxDepth).emit();
|
|
877
695
|
}
|
|
878
696
|
else {
|
|
879
|
-
|
|
880
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
881
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
882
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
883
|
-
query = `
|
|
884
|
-
MATCH ${startMatch}
|
|
885
|
-
MATCH path = (start)${dirStart}[*${minDepth}..${maxDepth}]${dirEnd}(end)
|
|
886
|
-
RETURN path
|
|
887
|
-
`;
|
|
888
|
-
if (options.limit) {
|
|
889
|
-
query += ` LIMIT ${options.limit}`;
|
|
890
|
-
}
|
|
697
|
+
traversal = traversal.repeat(repeatStep).times(maxDepth).emit();
|
|
891
698
|
}
|
|
892
|
-
|
|
893
|
-
|
|
699
|
+
if (options.limit) {
|
|
700
|
+
traversal = traversal.limit(options.limit);
|
|
701
|
+
}
|
|
702
|
+
// Get paths
|
|
703
|
+
const results = await traversal.path().by(__.valueMap(true)).toList();
|
|
704
|
+
const paths = [];
|
|
894
705
|
const nodesMap = new Map();
|
|
895
706
|
const relsMap = new Map();
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
707
|
+
for (const pathResult of results) {
|
|
708
|
+
const pathNodes = [];
|
|
709
|
+
const pathRels = [];
|
|
710
|
+
if (pathResult.objects) {
|
|
711
|
+
for (const obj of pathResult.objects) {
|
|
712
|
+
if (obj.id) {
|
|
713
|
+
const node = this.mapGremlinVertexFromValueMap(obj);
|
|
714
|
+
pathNodes.push(node);
|
|
715
|
+
nodesMap.set(String(node.id), node);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
if (pathNodes.length > 0) {
|
|
720
|
+
paths.push({
|
|
721
|
+
nodes: pathNodes,
|
|
722
|
+
relationships: pathRels,
|
|
723
|
+
length: pathNodes.length - 1,
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
}
|
|
900
727
|
return {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
paths: options.returnPaths ? paths : undefined,
|
|
904
|
-
nodes: options.returnNodes ? Array.from(nodesMap.values()) : undefined,
|
|
728
|
+
paths,
|
|
729
|
+
nodes: Array.from(nodesMap.values()),
|
|
905
730
|
relationships: Array.from(relsMap.values()),
|
|
906
731
|
count: paths.length,
|
|
907
732
|
};
|
|
908
733
|
}
|
|
909
|
-
async shortestPath(
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
if (
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
734
|
+
async shortestPath(options, _transaction) {
|
|
735
|
+
var _a;
|
|
736
|
+
const g = this.ensureTraversal();
|
|
737
|
+
const { __ } = this.gremlin.process;
|
|
738
|
+
// Build shortest path query
|
|
739
|
+
let traversal = g.V(options.startNodeId);
|
|
740
|
+
if ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
741
|
+
traversal = traversal.repeat(__.both(...options.relationshipTypes).simplePath())
|
|
742
|
+
.until(__.hasId(options.endNodeId))
|
|
743
|
+
.limit(1)
|
|
744
|
+
.path();
|
|
920
745
|
}
|
|
921
746
|
else {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
747
|
+
traversal = traversal.repeat(__.both().simplePath())
|
|
748
|
+
.until(__.hasId(options.endNodeId))
|
|
749
|
+
.limit(1)
|
|
750
|
+
.path();
|
|
751
|
+
}
|
|
752
|
+
const results = await traversal.by(__.valueMap(true)).toList();
|
|
753
|
+
if (results.length === 0) {
|
|
754
|
+
return { path: null, found: false };
|
|
755
|
+
}
|
|
756
|
+
const pathResult = results[0];
|
|
757
|
+
const pathNodes = [];
|
|
758
|
+
if (pathResult.objects) {
|
|
759
|
+
for (const obj of pathResult.objects) {
|
|
760
|
+
if (obj.id) {
|
|
761
|
+
pathNodes.push(this.mapGremlinVertexFromValueMap(obj));
|
|
762
|
+
}
|
|
763
|
+
}
|
|
938
764
|
}
|
|
939
|
-
const path =
|
|
765
|
+
const path = {
|
|
766
|
+
nodes: pathNodes,
|
|
767
|
+
relationships: [],
|
|
768
|
+
length: pathNodes.length - 1,
|
|
769
|
+
};
|
|
940
770
|
return {
|
|
941
|
-
success: true,
|
|
942
|
-
executionTime: Date.now() - startTime,
|
|
943
771
|
path,
|
|
944
|
-
found: true,
|
|
945
772
|
length: path.length,
|
|
773
|
+
found: true,
|
|
946
774
|
};
|
|
947
775
|
}
|
|
948
|
-
async allPaths(
|
|
949
|
-
|
|
950
|
-
const
|
|
951
|
-
const
|
|
776
|
+
async allPaths(options, _transaction) {
|
|
777
|
+
var _a;
|
|
778
|
+
const g = this.ensureTraversal();
|
|
779
|
+
const { __ } = this.gremlin.process;
|
|
952
780
|
const minDepth = options.minDepth || 1;
|
|
953
|
-
const maxDepth = options.maxDepth ||
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
781
|
+
const maxDepth = options.maxDepth || 5;
|
|
782
|
+
const limit = options.limit || options.maxPaths || 100;
|
|
783
|
+
// Build all paths query
|
|
784
|
+
let traversal = g.V(options.startNodeId);
|
|
785
|
+
if ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
786
|
+
traversal = traversal.repeat(__.both(...options.relationshipTypes).simplePath())
|
|
787
|
+
.until(__.hasId(options.endNodeId).or().loops().is(maxDepth))
|
|
788
|
+
.hasId(options.endNodeId)
|
|
789
|
+
.limit(limit)
|
|
790
|
+
.path();
|
|
963
791
|
}
|
|
964
792
|
else {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
793
|
+
traversal = traversal.repeat(__.both().simplePath())
|
|
794
|
+
.until(__.hasId(options.endNodeId).or().loops().is(maxDepth))
|
|
795
|
+
.hasId(options.endNodeId)
|
|
796
|
+
.limit(limit)
|
|
797
|
+
.path();
|
|
798
|
+
}
|
|
799
|
+
const results = await traversal.by(__.valueMap(true)).toList();
|
|
800
|
+
const paths = [];
|
|
801
|
+
for (const pathResult of results) {
|
|
802
|
+
const pathNodes = [];
|
|
803
|
+
if (pathResult.objects) {
|
|
804
|
+
for (const obj of pathResult.objects) {
|
|
805
|
+
if (obj.id) {
|
|
806
|
+
pathNodes.push(this.mapGremlinVertexFromValueMap(obj));
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (pathNodes.length >= minDepth + 1) {
|
|
811
|
+
paths.push({
|
|
812
|
+
nodes: pathNodes,
|
|
813
|
+
relationships: [],
|
|
814
|
+
length: pathNodes.length - 1,
|
|
815
|
+
});
|
|
974
816
|
}
|
|
975
817
|
}
|
|
976
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
977
|
-
const paths = result.data.map(row => this.parsePath(isGremlin ? row : row.path || row));
|
|
978
818
|
return {
|
|
979
|
-
success: true,
|
|
980
|
-
executionTime: Date.now() - startTime,
|
|
981
819
|
paths,
|
|
982
820
|
count: paths.length,
|
|
821
|
+
total: paths.length,
|
|
983
822
|
};
|
|
984
823
|
}
|
|
985
|
-
async
|
|
986
|
-
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
|
|
824
|
+
async getNeighborhood(options, _transaction) {
|
|
825
|
+
var _a, _b, _c;
|
|
826
|
+
const g = this.ensureTraversal();
|
|
827
|
+
const { __ } = this.gremlin.process;
|
|
828
|
+
const depth = options.depth || 1;
|
|
829
|
+
// Build direction
|
|
830
|
+
let traversalStep;
|
|
831
|
+
switch (options.direction) {
|
|
832
|
+
case enums_1.TraversalDirection.INCOMING:
|
|
833
|
+
case 'INCOMING':
|
|
834
|
+
traversalStep = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
|
|
835
|
+
? __.in_(...options.relationshipTypes)
|
|
836
|
+
: __.in_();
|
|
837
|
+
break;
|
|
838
|
+
case enums_1.TraversalDirection.OUTGOING:
|
|
839
|
+
case 'OUTGOING':
|
|
840
|
+
traversalStep = ((_b = options.relationshipTypes) === null || _b === void 0 ? void 0 : _b.length)
|
|
841
|
+
? __.out(...options.relationshipTypes)
|
|
842
|
+
: __.out();
|
|
843
|
+
break;
|
|
844
|
+
default:
|
|
845
|
+
traversalStep = ((_c = options.relationshipTypes) === null || _c === void 0 ? void 0 : _c.length)
|
|
846
|
+
? __.both(...options.relationshipTypes)
|
|
847
|
+
: __.both();
|
|
848
|
+
}
|
|
849
|
+
// Get neighbors
|
|
850
|
+
let traversal = g.V(options.nodeId)
|
|
851
|
+
.repeat(traversalStep)
|
|
852
|
+
.times(depth)
|
|
853
|
+
.emit()
|
|
854
|
+
.dedup();
|
|
1012
855
|
if (options.limit) {
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
const
|
|
856
|
+
traversal = traversal.limit(options.limit);
|
|
857
|
+
}
|
|
858
|
+
const nodeResults = await traversal.valueMap(true).toList();
|
|
859
|
+
const nodes = nodeResults.map((v) => this.mapGremlinVertexFromValueMap(v));
|
|
860
|
+
// Get relationships (simplified - just outgoing edges from source)
|
|
861
|
+
const edgeResults = await g.V(options.nodeId)
|
|
862
|
+
.bothE(...(options.relationshipTypes || []))
|
|
863
|
+
.project('edge', 'outV', 'inV')
|
|
864
|
+
.by(__.valueMap(true))
|
|
865
|
+
.by(__.outV().id())
|
|
866
|
+
.by(__.inV().id())
|
|
867
|
+
.toList();
|
|
868
|
+
const relationships = edgeResults.map((r) => this.mapGremlinEdgeFromProject(r));
|
|
1016
869
|
return {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
count: result.data.length,
|
|
1021
|
-
hasMore: options.limit !== undefined && result.data.length === options.limit,
|
|
870
|
+
nodes,
|
|
871
|
+
relationships,
|
|
872
|
+
depth,
|
|
1022
873
|
};
|
|
1023
874
|
}
|
|
1024
|
-
async
|
|
1025
|
-
|
|
1026
|
-
const
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
let
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
875
|
+
async findConnectedComponents(options, _transaction) {
|
|
876
|
+
var _a;
|
|
877
|
+
const g = this.ensureTraversal();
|
|
878
|
+
const { __ } = this.gremlin.process;
|
|
879
|
+
// Neptune doesn't have built-in connected components algorithm
|
|
880
|
+
// We'll implement a basic version using Gremlin
|
|
881
|
+
let startTraversal = g.V();
|
|
882
|
+
if ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.length) {
|
|
883
|
+
startTraversal = startTraversal.hasLabel(...options.labels);
|
|
884
|
+
}
|
|
885
|
+
// Get all vertices
|
|
886
|
+
const allVertices = await startTraversal.id().toList();
|
|
887
|
+
const visited = new Set();
|
|
888
|
+
const components = [];
|
|
889
|
+
for (const vertexId of allVertices) {
|
|
890
|
+
if (visited.has(String(vertexId)))
|
|
891
|
+
continue;
|
|
892
|
+
// BFS to find all connected vertices
|
|
893
|
+
const componentVertices = await g.V(vertexId)
|
|
894
|
+
.repeat(__.both(...(options.relationshipTypes || [])))
|
|
895
|
+
.until(__.not(__.both(...(options.relationshipTypes || []))))
|
|
896
|
+
.emit()
|
|
897
|
+
.dedup()
|
|
898
|
+
.valueMap(true)
|
|
899
|
+
.toList();
|
|
900
|
+
// Include the starting vertex
|
|
901
|
+
const startVertex = await g.V(vertexId).valueMap(true).next();
|
|
902
|
+
const allInComponent = [startVertex.value, ...componentVertices];
|
|
903
|
+
const nodes = allInComponent.map((v) => {
|
|
904
|
+
const node = this.mapGremlinVertexFromValueMap(v);
|
|
905
|
+
visited.add(String(node.id));
|
|
906
|
+
return node;
|
|
907
|
+
});
|
|
908
|
+
components.push({
|
|
909
|
+
nodes,
|
|
910
|
+
size: nodes.length,
|
|
911
|
+
});
|
|
1060
912
|
}
|
|
1061
913
|
return {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
subgraph: {
|
|
1065
|
-
nodes,
|
|
1066
|
-
relationships,
|
|
1067
|
-
nodeCount: nodes.length,
|
|
1068
|
-
relationshipCount: relationships.length,
|
|
1069
|
-
},
|
|
914
|
+
components,
|
|
915
|
+
count: components.length,
|
|
1070
916
|
};
|
|
1071
917
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
const params = {};
|
|
1079
|
-
if (isGremlin) {
|
|
1080
|
-
const nodeId = options.node.id;
|
|
1081
|
-
const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'in' :
|
|
1082
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'out' : 'both';
|
|
1083
|
-
query = `g.V('${nodeId}').repeat(${direction}().simplePath()).times(${depth}).emit()${options.includeCenter ? '' : '.where(neq(V(\'' + nodeId + '\')))'}`;
|
|
918
|
+
// ==================== AGGREGATION OPERATIONS ====================
|
|
919
|
+
async countNodes(labels, where, _transaction) {
|
|
920
|
+
const g = this.ensureTraversal();
|
|
921
|
+
let traversal = g.V();
|
|
922
|
+
if (labels === null || labels === void 0 ? void 0 : labels.length) {
|
|
923
|
+
traversal = traversal.hasLabel(...labels);
|
|
1084
924
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
1088
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
1089
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
1090
|
-
query = `
|
|
1091
|
-
MATCH ${centerMatch}
|
|
1092
|
-
MATCH path = (center)${dirStart}[*0..${depth}]${dirEnd}(n)
|
|
1093
|
-
WITH COLLECT(DISTINCT n) AS nodes, COLLECT(DISTINCT relationships(path)) AS rels
|
|
1094
|
-
UNWIND rels AS relList
|
|
1095
|
-
UNWIND relList AS r
|
|
1096
|
-
RETURN nodes, COLLECT(DISTINCT r) AS relationships
|
|
1097
|
-
`;
|
|
1098
|
-
}
|
|
1099
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
1100
|
-
const nodes = [];
|
|
1101
|
-
const relationships = [];
|
|
1102
|
-
if (isGremlin) {
|
|
1103
|
-
result.data.forEach((n) => nodes.push(this.parseNode(n)));
|
|
1104
|
-
}
|
|
1105
|
-
else if (result.data.length > 0) {
|
|
1106
|
-
const row = result.data[0];
|
|
1107
|
-
if (row.nodes) {
|
|
1108
|
-
row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
|
|
1109
|
-
}
|
|
1110
|
-
if (row.relationships) {
|
|
1111
|
-
row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
|
|
1112
|
-
}
|
|
925
|
+
if (where) {
|
|
926
|
+
traversal = this.applyWhereConditions(traversal, where);
|
|
1113
927
|
}
|
|
928
|
+
const result = await traversal.count().next();
|
|
1114
929
|
return {
|
|
1115
|
-
|
|
1116
|
-
executionTime: Date.now() - startTime,
|
|
1117
|
-
nodes,
|
|
1118
|
-
relationships,
|
|
1119
|
-
levels: new Map(), // Would need additional queries to populate
|
|
930
|
+
count: result.value,
|
|
1120
931
|
};
|
|
1121
932
|
}
|
|
1122
|
-
async
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Connected components analysis requires Neptune Analytics or manual implementation');
|
|
1128
|
-
}
|
|
1129
|
-
// ==================== AGGREGATION OPERATIONS ====================
|
|
1130
|
-
async countNodes(connection, labels, where, transaction) {
|
|
1131
|
-
var _a;
|
|
1132
|
-
const startTime = Date.now();
|
|
1133
|
-
const neptuneConn = connection;
|
|
1134
|
-
const isGremlin = neptuneConn.getConfig().queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN;
|
|
1135
|
-
let query;
|
|
1136
|
-
const params = {};
|
|
1137
|
-
if (isGremlin) {
|
|
1138
|
-
query = 'g.V()';
|
|
1139
|
-
if (labels) {
|
|
1140
|
-
const labelArr = Array.isArray(labels) ? labels : [labels];
|
|
1141
|
-
query += `.hasLabel('${labelArr.join("', '")}')`;
|
|
1142
|
-
}
|
|
1143
|
-
if (where) {
|
|
1144
|
-
Object.entries(where).forEach(([k, v]) => {
|
|
1145
|
-
query += `.has('${k}', ${this.gremlinValue(v)})`;
|
|
1146
|
-
});
|
|
1147
|
-
}
|
|
1148
|
-
query += '.count()';
|
|
933
|
+
async countRelationships(types, where, _transaction) {
|
|
934
|
+
const g = this.ensureTraversal();
|
|
935
|
+
let traversal = g.E();
|
|
936
|
+
if (types === null || types === void 0 ? void 0 : types.length) {
|
|
937
|
+
traversal = traversal.hasLabel(...types);
|
|
1149
938
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
? ':' + (Array.isArray(labels) ? labels : [labels]).join(':')
|
|
1153
|
-
: '';
|
|
1154
|
-
query = `MATCH (n${labelStr})`;
|
|
1155
|
-
if (where && Object.keys(where).length > 0) {
|
|
1156
|
-
const whereParts = Object.entries(where).map(([k], i) => {
|
|
1157
|
-
params[`w${i}`] = where[k];
|
|
1158
|
-
return `n.${k} = $w${i}`;
|
|
1159
|
-
});
|
|
1160
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
1161
|
-
}
|
|
1162
|
-
query += ' RETURN count(n) AS count';
|
|
939
|
+
if (where) {
|
|
940
|
+
traversal = this.applyWhereConditions(traversal, where);
|
|
1163
941
|
}
|
|
1164
|
-
const result = await
|
|
1165
|
-
const count = isGremlin
|
|
1166
|
-
? result.data[0] || 0
|
|
1167
|
-
: ((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0;
|
|
942
|
+
const result = await traversal.count().next();
|
|
1168
943
|
return {
|
|
1169
|
-
|
|
1170
|
-
executionTime: Date.now() - startTime,
|
|
1171
|
-
count: Number(count),
|
|
944
|
+
count: result.value,
|
|
1172
945
|
};
|
|
1173
946
|
}
|
|
1174
|
-
async
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
const
|
|
1178
|
-
const isGremlin = neptuneConn.getConfig().queryLanguage === graph_types_1.GraphQueryLanguage.GREMLIN;
|
|
1179
|
-
let query;
|
|
1180
|
-
const params = {};
|
|
1181
|
-
if (isGremlin) {
|
|
1182
|
-
query = 'g.E()';
|
|
1183
|
-
if (type) {
|
|
1184
|
-
const typeArr = Array.isArray(type) ? type : [type];
|
|
1185
|
-
query += `.hasLabel('${typeArr.join("', '")}')`;
|
|
1186
|
-
}
|
|
1187
|
-
if (where) {
|
|
1188
|
-
Object.entries(where).forEach(([k, v]) => {
|
|
1189
|
-
query += `.has('${k}', ${this.gremlinValue(v)})`;
|
|
1190
|
-
});
|
|
1191
|
-
}
|
|
1192
|
-
query += '.count()';
|
|
1193
|
-
}
|
|
1194
|
-
else {
|
|
1195
|
-
const typeStr = type
|
|
1196
|
-
? ':' + (Array.isArray(type) ? type : [type]).join('|')
|
|
1197
|
-
: '';
|
|
1198
|
-
query = `MATCH ()-[r${typeStr}]->() RETURN count(r) AS count`;
|
|
1199
|
-
}
|
|
1200
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
1201
|
-
const count = isGremlin
|
|
1202
|
-
? result.data[0] || 0
|
|
1203
|
-
: ((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0;
|
|
947
|
+
async getStatistics(_transaction) {
|
|
948
|
+
const g = this.ensureTraversal();
|
|
949
|
+
const nodeCount = await g.V().count().next();
|
|
950
|
+
const relCount = await g.E().count().next();
|
|
1204
951
|
return {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
count: Number(count),
|
|
952
|
+
nodeCount: nodeCount.value,
|
|
953
|
+
relationshipCount: relCount.value,
|
|
1208
954
|
};
|
|
1209
955
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
const relResult = await this.executeRaw(connection, { query: 'g.E().count()' }, transaction);
|
|
1220
|
-
relationshipCount = relResult.data[0] || 0;
|
|
1221
|
-
}
|
|
1222
|
-
else {
|
|
1223
|
-
const result = await this.executeRaw(connection, {
|
|
1224
|
-
query: `
|
|
1225
|
-
MATCH (n)
|
|
1226
|
-
WITH count(n) AS nodeCount
|
|
1227
|
-
MATCH ()-[r]->()
|
|
1228
|
-
RETURN nodeCount, count(r) AS relCount
|
|
1229
|
-
`,
|
|
1230
|
-
}, transaction);
|
|
1231
|
-
if (result.data.length > 0) {
|
|
1232
|
-
nodeCount = result.data[0].nodeCount || 0;
|
|
1233
|
-
relationshipCount = result.data[0].relCount || 0;
|
|
1234
|
-
}
|
|
956
|
+
// ==================== SEARCH OPERATIONS ====================
|
|
957
|
+
async fullTextSearch(options, _transaction) {
|
|
958
|
+
const g = this.ensureTraversal();
|
|
959
|
+
// Neptune supports text predicates via Neptune-specific features
|
|
960
|
+
// Basic implementation using contains predicate
|
|
961
|
+
const textPredicate = this.gremlin.process.P.containing(options.query);
|
|
962
|
+
let traversal = g.V().or(this.gremlin.process.__.has('name', textPredicate), this.gremlin.process.__.has('title', textPredicate), this.gremlin.process.__.has('description', textPredicate));
|
|
963
|
+
if (options.limit) {
|
|
964
|
+
traversal = traversal.limit(options.limit);
|
|
1235
965
|
}
|
|
966
|
+
const results = await traversal.valueMap(true).toList();
|
|
967
|
+
const nodes = results.map((v) => this.mapGremlinVertexFromValueMap(v));
|
|
1236
968
|
return {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
nodeCount: Number(nodeCount),
|
|
1240
|
-
relationshipCount: Number(relationshipCount),
|
|
1241
|
-
labelCounts: {},
|
|
1242
|
-
relationshipTypeCounts: {},
|
|
969
|
+
nodes,
|
|
970
|
+
scores: nodes.map(() => 1.0),
|
|
1243
971
|
};
|
|
1244
972
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
// Neptune doesn't have built-in full-text search
|
|
1248
|
-
// Would need to use OpenSearch integration
|
|
1249
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Full-text search requires Neptune integration with OpenSearch');
|
|
1250
|
-
}
|
|
1251
|
-
async vectorSearch(connection, options, transaction) {
|
|
1252
|
-
// Neptune Analytics supports vector search
|
|
1253
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Vector search requires Neptune Analytics');
|
|
1254
|
-
}
|
|
1255
|
-
// ==================== SCHEMA OPERATIONS ====================
|
|
1256
|
-
// Note: Neptune has limited schema support compared to Neo4j
|
|
1257
|
-
async createNodeConstraint(connection, constraint, transaction) {
|
|
1258
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Neptune does not support explicit constraints');
|
|
1259
|
-
}
|
|
1260
|
-
async createRelationshipConstraint(connection, constraint, transaction) {
|
|
1261
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Neptune does not support explicit constraints');
|
|
1262
|
-
}
|
|
1263
|
-
async dropConstraint(connection, name, transaction) {
|
|
1264
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Neptune does not support explicit constraints');
|
|
973
|
+
async vectorSearch(_options, _transaction) {
|
|
974
|
+
throw graph_error_1.GraphError.unsupportedOperationError('Vector search is not natively supported in Neptune. Consider using Amazon OpenSearch with Neptune.', this.graphType);
|
|
1265
975
|
}
|
|
1266
|
-
|
|
976
|
+
// ==================== RAW QUERY ====================
|
|
977
|
+
async query(options, _transaction) {
|
|
978
|
+
// For Gremlin, the query is a Gremlin script string
|
|
979
|
+
// Neptune supports script execution via the submit method
|
|
980
|
+
if (!this.connection) {
|
|
981
|
+
throw new Error('Not connected to Neptune');
|
|
982
|
+
}
|
|
983
|
+
const result = await this.connection.submit(options.query, options.params || {});
|
|
984
|
+
const records = await result.toArray();
|
|
1267
985
|
return {
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
constraints: [],
|
|
986
|
+
records: records,
|
|
987
|
+
summary: {},
|
|
1271
988
|
};
|
|
1272
989
|
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
990
|
+
// ==================== SCHEMA OPERATIONS ====================
|
|
991
|
+
async createNodeIndex(options) {
|
|
992
|
+
// Neptune doesn't support user-created indexes in the same way as Neo4j
|
|
993
|
+
// Indexes are managed automatically by Neptune
|
|
994
|
+
// Return success as Neptune will handle optimization automatically
|
|
995
|
+
return { created: true, name: options.name };
|
|
996
|
+
}
|
|
997
|
+
async createNodeConstraint(_options) {
|
|
998
|
+
// Neptune doesn't support constraints like Neo4j
|
|
999
|
+
throw graph_error_1.GraphError.unsupportedOperationError('Neptune does not support user-defined constraints. Data validation should be handled at the application level.', this.graphType);
|
|
1000
|
+
}
|
|
1001
|
+
async createRelationshipIndex(options) {
|
|
1002
|
+
// Neptune handles indexes automatically
|
|
1003
|
+
return { created: true, name: options.name };
|
|
1004
|
+
}
|
|
1005
|
+
async listIndexes() {
|
|
1006
|
+
// Neptune indexes are managed internally
|
|
1007
|
+
return { indexes: [] };
|
|
1008
|
+
}
|
|
1009
|
+
async listConstraints() {
|
|
1010
|
+
// Neptune doesn't have user-defined constraints
|
|
1011
|
+
return { constraints: [] };
|
|
1012
|
+
}
|
|
1013
|
+
async dropIndex(_name) {
|
|
1014
|
+
// Neptune indexes are managed internally
|
|
1015
|
+
return { dropped: false };
|
|
1016
|
+
}
|
|
1017
|
+
async dropConstraint(_name) {
|
|
1018
|
+
// Neptune doesn't have user-defined constraints
|
|
1019
|
+
return { dropped: false };
|
|
1020
|
+
}
|
|
1021
|
+
// ==================== SCHEMA INTROSPECTION ====================
|
|
1022
|
+
async listLabels() {
|
|
1023
|
+
this.ensureConnected();
|
|
1024
|
+
try {
|
|
1025
|
+
// Get all distinct vertex labels
|
|
1026
|
+
const labelsTraversal = this.g.V().label().dedup();
|
|
1027
|
+
const labelNames = await labelsTraversal.toList();
|
|
1028
|
+
const labels = [];
|
|
1029
|
+
for (const labelName of labelNames) {
|
|
1030
|
+
// Get count for each label
|
|
1031
|
+
const countTraversal = this.g.V().hasLabel(labelName).count();
|
|
1032
|
+
const countResult = await countTraversal.next();
|
|
1033
|
+
const count = countResult.value || 0;
|
|
1034
|
+
// Get properties from a sample of vertices with this label
|
|
1035
|
+
const propsTraversal = this.g.V().hasLabel(labelName).limit(100).properties().key().dedup();
|
|
1036
|
+
const propertyNames = await propsTraversal.toList();
|
|
1037
|
+
const properties = propertyNames.map((name) => ({
|
|
1038
|
+
name,
|
|
1039
|
+
type: 'unknown',
|
|
1040
|
+
}));
|
|
1041
|
+
labels.push({
|
|
1042
|
+
name: String(labelName),
|
|
1043
|
+
count: Number(count),
|
|
1044
|
+
properties,
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
return { labels };
|
|
1048
|
+
}
|
|
1049
|
+
catch (error) {
|
|
1050
|
+
throw graph_error_1.GraphError.queryError(`Failed to list labels: ${error.message}`);
|
|
1051
|
+
}
|
|
1278
1052
|
}
|
|
1279
|
-
async
|
|
1280
|
-
|
|
1053
|
+
async listRelationshipTypes() {
|
|
1054
|
+
this.ensureConnected();
|
|
1055
|
+
try {
|
|
1056
|
+
// Get all distinct edge labels
|
|
1057
|
+
const typesTraversal = this.g.E().label().dedup();
|
|
1058
|
+
const typeNames = await typesTraversal.toList();
|
|
1059
|
+
const types = [];
|
|
1060
|
+
for (const typeName of typeNames) {
|
|
1061
|
+
// Get count for each edge label
|
|
1062
|
+
const countTraversal = this.g.E().hasLabel(typeName).count();
|
|
1063
|
+
const countResult = await countTraversal.next();
|
|
1064
|
+
const count = countResult.value || 0;
|
|
1065
|
+
// Get source and target vertex labels
|
|
1066
|
+
const endpointsTraversal = this.g.E().hasLabel(typeName).limit(100)
|
|
1067
|
+
.project('fromLabel', 'toLabel')
|
|
1068
|
+
.by(this.gremlin.process.statics.outV().label())
|
|
1069
|
+
.by(this.gremlin.process.statics.inV().label());
|
|
1070
|
+
const endpoints = await endpointsTraversal.toList();
|
|
1071
|
+
const fromLabelsSet = new Set();
|
|
1072
|
+
const toLabelsSet = new Set();
|
|
1073
|
+
for (const ep of endpoints) {
|
|
1074
|
+
if (ep.fromLabel)
|
|
1075
|
+
fromLabelsSet.add(String(ep.fromLabel));
|
|
1076
|
+
if (ep.toLabel)
|
|
1077
|
+
toLabelsSet.add(String(ep.toLabel));
|
|
1078
|
+
}
|
|
1079
|
+
// Get properties from a sample of edges
|
|
1080
|
+
const propsTraversal = this.g.E().hasLabel(typeName).limit(100).properties().key().dedup();
|
|
1081
|
+
const propertyNames = await propsTraversal.toList();
|
|
1082
|
+
const properties = propertyNames.map((name) => ({
|
|
1083
|
+
name,
|
|
1084
|
+
type: 'unknown',
|
|
1085
|
+
}));
|
|
1086
|
+
types.push({
|
|
1087
|
+
type: String(typeName),
|
|
1088
|
+
count: Number(count),
|
|
1089
|
+
fromLabels: Array.from(fromLabelsSet),
|
|
1090
|
+
toLabels: Array.from(toLabelsSet),
|
|
1091
|
+
properties: properties.length > 0 ? properties : undefined,
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
return { types };
|
|
1095
|
+
}
|
|
1096
|
+
catch (error) {
|
|
1097
|
+
throw graph_error_1.GraphError.queryError(`Failed to list relationship types: ${error.message}`);
|
|
1098
|
+
}
|
|
1281
1099
|
}
|
|
1282
|
-
|
|
1100
|
+
// ==================== TRANSACTION OPERATIONS ====================
|
|
1101
|
+
async beginTransaction(_options) {
|
|
1102
|
+
// Neptune has limited transaction support via sessions
|
|
1103
|
+
// For now, we create a session-based pseudo-transaction
|
|
1104
|
+
this.ensureConnected();
|
|
1283
1105
|
return {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1106
|
+
id: `tx_${Date.now()}`,
|
|
1107
|
+
status: enums_1.GraphTransactionStatus.ACTIVE,
|
|
1108
|
+
client: this.g,
|
|
1109
|
+
nativeTransaction: null,
|
|
1110
|
+
startTime: new Date(),
|
|
1111
|
+
commit: async () => {
|
|
1112
|
+
// Neptune auto-commits each query
|
|
1113
|
+
},
|
|
1114
|
+
rollback: async () => {
|
|
1115
|
+
// Neptune doesn't support rollback for individual queries
|
|
1116
|
+
},
|
|
1287
1117
|
};
|
|
1288
1118
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
return identifier.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
1119
|
+
async commitTransaction(_transaction) {
|
|
1120
|
+
// Neptune auto-commits each query
|
|
1292
1121
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
return 'null';
|
|
1296
|
-
if (typeof value === 'string')
|
|
1297
|
-
return `'${value.replace(/'/g, "\\'")}'`;
|
|
1298
|
-
if (typeof value === 'number')
|
|
1299
|
-
return String(value);
|
|
1300
|
-
if (typeof value === 'boolean')
|
|
1301
|
-
return value ? 'true' : 'false';
|
|
1302
|
-
if (value instanceof Date)
|
|
1303
|
-
return `datetime('${value.toISOString()}')`;
|
|
1304
|
-
if (Array.isArray(value))
|
|
1305
|
-
return `[${value.map(v => this.escapeValue(v)).join(', ')}]`;
|
|
1306
|
-
return String(value);
|
|
1122
|
+
async rollbackTransaction(_transaction) {
|
|
1123
|
+
// Neptune doesn't support rollback for individual queries
|
|
1307
1124
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1125
|
+
// ==================== UTILITY METHODS ====================
|
|
1126
|
+
buildWhereClause(where) {
|
|
1127
|
+
// For Gremlin, we return the where clause object as-is
|
|
1128
|
+
// The actual predicate building is done in applyWhereConditions
|
|
1129
|
+
return where;
|
|
1130
|
+
}
|
|
1131
|
+
applyWhereConditions(traversal, where) {
|
|
1132
|
+
const { P } = this.gremlin.process;
|
|
1133
|
+
for (const [key, value] of Object.entries(where)) {
|
|
1134
|
+
if (key === '$AND') {
|
|
1135
|
+
// Apply AND conditions
|
|
1136
|
+
traversal = traversal.and(...Object.entries(value).map(([k, v]) => this.gremlin.process.__.has(k, v)));
|
|
1137
|
+
}
|
|
1138
|
+
else if (key === '$OR') {
|
|
1139
|
+
// Apply OR conditions
|
|
1140
|
+
traversal = traversal.or(...Object.entries(value).map(([k, v]) => this.gremlin.process.__.has(k, v)));
|
|
1141
|
+
}
|
|
1142
|
+
else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
1143
|
+
// Apply operator conditions
|
|
1144
|
+
for (const [op, opValue] of Object.entries(value)) {
|
|
1145
|
+
switch (op) {
|
|
1146
|
+
case '$GT':
|
|
1147
|
+
traversal = traversal.has(key, P.gt(opValue));
|
|
1148
|
+
break;
|
|
1149
|
+
case '$GTE':
|
|
1150
|
+
traversal = traversal.has(key, P.gte(opValue));
|
|
1151
|
+
break;
|
|
1152
|
+
case '$LT':
|
|
1153
|
+
traversal = traversal.has(key, P.lt(opValue));
|
|
1154
|
+
break;
|
|
1155
|
+
case '$LTE':
|
|
1156
|
+
traversal = traversal.has(key, P.lte(opValue));
|
|
1157
|
+
break;
|
|
1158
|
+
case '$NE':
|
|
1159
|
+
traversal = traversal.has(key, P.neq(opValue));
|
|
1160
|
+
break;
|
|
1161
|
+
case '$IN':
|
|
1162
|
+
traversal = traversal.has(key, P.within(...opValue));
|
|
1163
|
+
break;
|
|
1164
|
+
case '$NOT_IN':
|
|
1165
|
+
traversal = traversal.has(key, P.without(...opValue));
|
|
1166
|
+
break;
|
|
1167
|
+
case '$CONTAINS':
|
|
1168
|
+
traversal = traversal.has(key, P.containing(opValue));
|
|
1169
|
+
break;
|
|
1170
|
+
case '$STARTS_WITH':
|
|
1171
|
+
traversal = traversal.has(key, P.startingWith(opValue));
|
|
1172
|
+
break;
|
|
1173
|
+
case '$ENDS_WITH':
|
|
1174
|
+
traversal = traversal.has(key, P.endingWith(opValue));
|
|
1175
|
+
break;
|
|
1176
|
+
case '$EXISTS':
|
|
1177
|
+
if (opValue) {
|
|
1178
|
+
traversal = traversal.has(key);
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
traversal = traversal.hasNot(key);
|
|
1182
|
+
}
|
|
1183
|
+
break;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
// Simple equality
|
|
1189
|
+
traversal = traversal.has(key, value);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
return traversal;
|
|
1320
1193
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.NODE_ERROR, 'Cannot parse null node');
|
|
1194
|
+
parseError(error) {
|
|
1195
|
+
if (error instanceof graph_error_1.GraphError) {
|
|
1196
|
+
return error;
|
|
1325
1197
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1198
|
+
return graph_error_1.GraphError.queryError(String(error));
|
|
1199
|
+
}
|
|
1200
|
+
// ==================== PRIVATE HELPER METHODS ====================
|
|
1201
|
+
mapGremlinVertex(id, properties) {
|
|
1202
|
+
const props = {};
|
|
1203
|
+
const labels = [];
|
|
1204
|
+
if (properties) {
|
|
1205
|
+
for (const [key, value] of properties) {
|
|
1206
|
+
if (key === 'label' || key === this.gremlin.process.t.label) {
|
|
1207
|
+
labels.push(Array.isArray(value) ? value[0] : value);
|
|
1208
|
+
}
|
|
1209
|
+
else if (key === 'id' || key === this.gremlin.process.t.id) {
|
|
1210
|
+
// Skip id as we have it separately
|
|
1211
|
+
}
|
|
1212
|
+
else {
|
|
1213
|
+
props[key] = Array.isArray(value) ? value[0] : value;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1329
1216
|
}
|
|
1330
1217
|
return {
|
|
1331
|
-
id:
|
|
1332
|
-
labels
|
|
1333
|
-
properties:
|
|
1218
|
+
id: String(id),
|
|
1219
|
+
labels,
|
|
1220
|
+
properties: props,
|
|
1334
1221
|
};
|
|
1335
1222
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1223
|
+
mapGremlinVertexFromValueMap(valueMap) {
|
|
1224
|
+
const props = {};
|
|
1225
|
+
const labels = [];
|
|
1226
|
+
let id = '';
|
|
1227
|
+
if (valueMap) {
|
|
1228
|
+
for (const [key, value] of Object.entries(valueMap)) {
|
|
1229
|
+
if (key === 'label' || String(key).includes('label')) {
|
|
1230
|
+
const labelValue = Array.isArray(value) ? value[0] : value;
|
|
1231
|
+
labels.push(String(labelValue));
|
|
1232
|
+
}
|
|
1233
|
+
else if (key === 'id' || String(key).includes('id')) {
|
|
1234
|
+
id = String(Array.isArray(value) ? value[0] : value);
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
props[key] = Array.isArray(value) ? value[0] : value;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1343
1240
|
}
|
|
1344
1241
|
return {
|
|
1345
|
-
id
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
endNodeId: nativeRelationship.endNodeId || nativeRelationship.inV || '',
|
|
1349
|
-
properties: (nativeRelationship.properties || nativeRelationship),
|
|
1242
|
+
id,
|
|
1243
|
+
labels,
|
|
1244
|
+
properties: props,
|
|
1350
1245
|
};
|
|
1351
1246
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
}
|
|
1360
|
-
const nodes = [];
|
|
1361
|
-
const relationships = [];
|
|
1362
|
-
if (nativePath.objects) {
|
|
1363
|
-
// Gremlin path
|
|
1364
|
-
nativePath.objects.forEach((obj) => {
|
|
1365
|
-
if (obj.labels || obj.label) {
|
|
1366
|
-
nodes.push(this.parseNode(obj));
|
|
1247
|
+
mapGremlinEdge(edge, properties, startId, endId) {
|
|
1248
|
+
const props = {};
|
|
1249
|
+
let type = '';
|
|
1250
|
+
if (properties) {
|
|
1251
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
1252
|
+
if (key === 'label' || String(key).includes('label')) {
|
|
1253
|
+
type = String(Array.isArray(value) ? value[0] : value);
|
|
1367
1254
|
}
|
|
1368
|
-
else if (
|
|
1369
|
-
|
|
1255
|
+
else if (key === 'id' || String(key).includes('id')) {
|
|
1256
|
+
// Skip id
|
|
1370
1257
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
nativePath.nodes.forEach((n) => nodes.push(this.parseNode(n)));
|
|
1376
|
-
nativePath.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
|
|
1258
|
+
else {
|
|
1259
|
+
props[key] = Array.isArray(value) ? value[0] : value;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1377
1262
|
}
|
|
1378
1263
|
return {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1264
|
+
id: String(edge.id),
|
|
1265
|
+
type: type || edge.label,
|
|
1266
|
+
startNodeId: String(startId),
|
|
1267
|
+
endNodeId: String(endId),
|
|
1268
|
+
properties: props,
|
|
1384
1269
|
};
|
|
1385
1270
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
if (Array.isArray(value))
|
|
1402
|
-
return `[${value.map(v => this.gremlinValue(v)).join(', ')}]`;
|
|
1403
|
-
return String(value);
|
|
1404
|
-
}
|
|
1405
|
-
buildCypherNodeMatch(ref, alias, params, prefix = '') {
|
|
1406
|
-
let pattern = `(${alias}`;
|
|
1407
|
-
if (ref.labels) {
|
|
1408
|
-
const labels = this.normalizeLabels(ref.labels);
|
|
1409
|
-
pattern += ':' + labels.join(':');
|
|
1410
|
-
}
|
|
1411
|
-
if (ref.id !== undefined) {
|
|
1412
|
-
const paramName = `${prefix}id`;
|
|
1413
|
-
params[paramName] = ref.id;
|
|
1414
|
-
pattern += ` {id: $${paramName}}`;
|
|
1415
|
-
}
|
|
1416
|
-
else if (ref.properties && Object.keys(ref.properties).length > 0) {
|
|
1417
|
-
const propParts = Object.entries(ref.properties).map(([k], i) => {
|
|
1418
|
-
const paramName = `${prefix}prop${i}`;
|
|
1419
|
-
params[paramName] = ref.properties[k];
|
|
1420
|
-
return `${k}: $${paramName}`;
|
|
1421
|
-
});
|
|
1422
|
-
pattern += ` {${propParts.join(', ')}}`;
|
|
1271
|
+
mapGremlinEdgeFromProject(result) {
|
|
1272
|
+
const edge = result.edge || {};
|
|
1273
|
+
const props = {};
|
|
1274
|
+
let type = '';
|
|
1275
|
+
let id = '';
|
|
1276
|
+
for (const [key, value] of Object.entries(edge)) {
|
|
1277
|
+
if (key === 'label' || String(key).includes('label')) {
|
|
1278
|
+
type = String(Array.isArray(value) ? value[0] : value);
|
|
1279
|
+
}
|
|
1280
|
+
else if (key === 'id' || String(key).includes('id')) {
|
|
1281
|
+
id = String(Array.isArray(value) ? value[0] : value);
|
|
1282
|
+
}
|
|
1283
|
+
else {
|
|
1284
|
+
props[key] = Array.isArray(value) ? value[0] : value;
|
|
1285
|
+
}
|
|
1423
1286
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1287
|
+
return {
|
|
1288
|
+
id,
|
|
1289
|
+
type,
|
|
1290
|
+
startNodeId: String(result.outV),
|
|
1291
|
+
endNodeId: String(result.inV),
|
|
1292
|
+
properties: props,
|
|
1293
|
+
};
|
|
1426
1294
|
}
|
|
1427
1295
|
}
|
|
1428
1296
|
exports.NeptuneAdapter = NeptuneAdapter;
|
|
1429
|
-
exports.default = NeptuneAdapter;
|
|
1430
1297
|
//# sourceMappingURL=neptune.adapter.js.map
|