@ductape/sdk 0.0.4-v51 → 0.0.4-v53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/agent-context.d.ts +98 -0
- package/dist/agents/agent-context.js +588 -0
- package/dist/agents/agent-context.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +180 -0
- package/dist/agents/agent-executor.js +715 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/agents.service.d.ts +304 -0
- package/dist/agents/agents.service.js +1244 -0
- package/dist/agents/agents.service.js.map +1 -0
- package/dist/agents/index.d.ts +55 -0
- package/dist/agents/index.js +110 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/memory-manager.d.ts +182 -0
- package/dist/agents/memory-manager.js +383 -0
- package/dist/agents/memory-manager.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +141 -0
- package/dist/agents/tool-registry.js +355 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/agents/types/agents.types.d.ts +1225 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.js +4 -5
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +322 -0
- package/dist/api/services/processorApi.service.js +252 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +69 -1
- package/dist/api/services/productsApi.service.js +67 -31
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +38 -0
- package/dist/api/services/secretsApi.service.js +96 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/userApi.service.js +0 -1
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +183 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.js +0 -1
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +57 -0
- package/dist/api/urls.js +68 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.js +4 -10
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +0 -10
- package/dist/apps/services/app.service.js +74 -30
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +405 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +257 -0
- package/dist/brokers/brokers.service.js +604 -0
- package/dist/brokers/brokers.service.js.map +1 -0
- package/dist/brokers/index.d.ts +46 -0
- package/dist/brokers/index.js +83 -0
- package/dist/brokers/index.js.map +1 -0
- package/dist/brokers/types/index.d.ts +288 -0
- package/dist/brokers/types/index.js +8 -0
- package/dist/brokers/types/index.js.map +1 -0
- package/dist/brokers/utils/broker.util.d.ts +33 -0
- package/dist/brokers/utils/broker.util.js +125 -0
- package/dist/brokers/utils/broker.util.js.map +1 -0
- package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
- package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
- package/dist/brokers/utils/providers/index.d.ts +6 -0
- package/dist/brokers/utils/providers/index.js +16 -0
- package/dist/brokers/utils/providers/index.js.map +1 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +16 -0
- package/dist/brokers/utils/providers/kafka.service.js +52 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +14 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
- package/dist/brokers/utils/providers/redis.service.js +93 -0
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +159 -0
- package/dist/cache/cache.manager.js +265 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +186 -0
- package/dist/cache/cache.service.js +437 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +79 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +106 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +307 -90
- package/dist/database/adapters/base.adapter.js +139 -20
- package/dist/database/adapters/base.adapter.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
- package/dist/database/adapters/cassandra.adapter.js +1019 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
- package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +105 -57
- package/dist/database/adapters/mongodb.adapter.js +941 -838
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +76 -138
- package/dist/database/adapters/mysql.adapter.js +990 -1246
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
- package/dist/database/adapters/postgresql.adapter.js +1076 -1346
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +1374 -0
- package/dist/database/databases.service.js +2680 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +41 -13
- package/dist/database/index.js +97 -86
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +132 -0
- package/dist/database/migrations/migration-engine.js +1356 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +64 -0
- package/dist/database/operators/aggregation-builder.js +746 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +55 -0
- package/dist/database/operators/query-builder.js +365 -0
- package/dist/database/operators/query-builder.js.map +1 -0
- package/dist/database/presave/decrypt.d.ts +25 -0
- package/dist/database/presave/decrypt.js +146 -0
- package/dist/database/presave/decrypt.js.map +1 -0
- package/dist/database/presave/index.d.ts +9 -0
- package/dist/database/presave/index.js +18 -0
- package/dist/database/presave/index.js.map +1 -0
- package/dist/database/presave/presave-processor.d.ts +148 -0
- package/dist/database/presave/presave-processor.js +702 -0
- package/dist/database/presave/presave-processor.js.map +1 -0
- package/dist/database/schema/index.d.ts +7 -0
- package/dist/database/schema/index.js +13 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/database/schema/schema-manager.d.ts +258 -0
- package/dist/database/schema/schema-manager.js +637 -0
- package/dist/database/schema/schema-manager.js.map +1 -0
- package/dist/database/transactions/index.d.ts +6 -0
- package/dist/database/transactions/index.js +13 -0
- package/dist/database/transactions/index.js.map +1 -0
- package/dist/database/transactions/transaction-manager.d.ts +113 -0
- package/dist/database/transactions/transaction-manager.js +344 -0
- package/dist/database/transactions/transaction-manager.js.map +1 -0
- package/dist/database/triggers/index.d.ts +7 -0
- package/dist/database/triggers/index.js +14 -0
- package/dist/database/triggers/index.js.map +1 -0
- package/dist/database/triggers/trigger-processor.d.ts +239 -0
- package/dist/database/triggers/trigger-processor.js +1034 -0
- package/dist/database/triggers/trigger-processor.js.map +1 -0
- package/dist/database/types/action.interface.d.ts +148 -0
- package/dist/database/types/action.interface.js +6 -0
- package/dist/database/types/action.interface.js.map +1 -0
- package/dist/database/types/aggregation.interface.d.ts +179 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/enums.d.ts +195 -0
- package/dist/database/types/enums.js +244 -0
- package/dist/database/types/enums.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -10
- package/dist/database/types/index.js +26 -32
- package/dist/database/types/index.js.map +1 -1
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +199 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +398 -0
- package/dist/database/types/schema.interface.js +6 -0
- package/dist/database/types/schema.interface.js.map +1 -0
- package/dist/database/types/transaction.interface.d.ts +84 -0
- package/dist/database/types/transaction.interface.js +6 -0
- package/dist/database/types/transaction.interface.js.map +1 -0
- package/dist/database/types/trigger.interface.d.ts +612 -0
- package/dist/database/types/trigger.interface.js +121 -0
- package/dist/database/types/trigger.interface.js.map +1 -0
- package/dist/database/types/write.interface.d.ts +208 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +78 -72
- package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/base.adapter.d.ts +135 -118
- package/dist/graph/adapters/base.adapter.js +46 -20
- package/dist/graph/adapters/base.adapter.js.map +1 -1
- package/dist/graph/adapters/index.d.ts +5 -4
- package/dist/graph/adapters/index.js +6 -8
- package/dist/graph/adapters/index.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
- package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
- package/dist/graph/adapters/neo4j.adapter.js +912 -1605
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
- package/dist/graph/adapters/neptune.adapter.js +1095 -1228
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +524 -0
- package/dist/graph/graphs.service.js +1683 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +54 -8
- package/dist/graph/index.js +67 -32
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +141 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -9
- package/dist/graph/types/index.js +15 -30
- package/dist/graph/types/index.js.map +1 -1
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +168 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/index.d.ts +1905 -875
- package/dist/index.js +3063 -1282
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/init.interface.js +3 -0
- package/dist/init.interface.js.map +1 -0
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.types.d.ts +12 -2
- package/dist/logs/logs.types.js +5 -1
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +252 -0
- package/dist/notifications/notifications.service.js +654 -0
- package/dist/notifications/notifications.service.js.map +1 -0
- package/dist/notifications/types/index.d.ts +4 -0
- package/dist/notifications/types/index.js +21 -0
- package/dist/notifications/types/index.js.map +1 -0
- package/dist/notifications/types/notifications.types.d.ts +400 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +86 -70
- package/dist/processor/services/processor.service.js +1353 -1259
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +5 -1
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/services/products.service.d.ts +167 -25
- package/dist/products/services/products.service.js +1248 -412
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +6 -3
- package/dist/products/validators/index.js +14 -5
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +218 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +4 -15
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +135 -50
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
- package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +0 -6
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +88 -0
- package/dist/resilience/fallback.service.js +511 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +106 -0
- package/dist/resilience/healthcheck.service.js +379 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +90 -0
- package/dist/resilience/quota.service.js +519 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +95 -0
- package/dist/resilience/resilience.service.js +525 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +479 -0
- package/dist/resilience/types/index.js +26 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +83 -0
- package/dist/secrets/secrets.service.js +159 -0
- package/dist/secrets/secrets.service.js.map +1 -0
- package/dist/secrets/secrets.types.d.ts +188 -0
- package/dist/secrets/secrets.types.js +87 -0
- package/dist/secrets/secrets.types.js.map +1 -0
- package/dist/sessions/index.d.ts +50 -0
- package/dist/sessions/index.js +93 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +68 -0
- package/dist/sessions/sessions.helper.js +116 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +150 -0
- package/dist/sessions/sessions.resolver.js +356 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +170 -0
- package/dist/sessions/sessions.service.js +736 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +290 -0
- package/dist/sessions/types/index.js +6 -0
- package/dist/sessions/types/index.js.map +1 -0
- package/dist/storage/index.d.ts +66 -0
- package/dist/storage/index.js +98 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +123 -0
- package/dist/storage/storage.service.js +478 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +207 -0
- package/dist/storage/types/index.js +6 -0
- package/dist/storage/types/index.js.map +1 -0
- package/dist/storage/utils/storage.util.d.ts +51 -0
- package/dist/storage/utils/storage.util.js +402 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +13 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -15
- package/dist/test/test.appBuilder.js.map +1 -1
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.health.d.ts +0 -1
- package/dist/test/test.health.js +0 -48
- package/dist/test/test.health.js.map +1 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1506
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -75
- package/dist/test/test.import.openapi.js.map +1 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -76
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -17
- package/dist/test/test.logs.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +0 -1
- package/dist/test/test.notifiers.js +0 -84
- package/dist/test/test.notifiers.js.map +1 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -37
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -660
- package/dist/test/test.productBuilder.js.map +1 -1
- package/dist/test/test.products.d.ts +0 -1
- package/dist/test/test.products.js +0 -48
- package/dist/test/test.products.js.map +1 -1
- package/dist/test/test.storage.js +332 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/dist/types/enums.d.ts +6 -1
- package/dist/types/enums.js +5 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/processor.types.d.ts +197 -35
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +837 -75
- package/dist/types/productsBuilder.types.js +168 -62
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +2 -49
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +152 -0
- package/dist/vector/adapters/base.adapter.js +137 -0
- package/dist/vector/adapters/base.adapter.js.map +1 -0
- package/dist/vector/adapters/index.d.ts +10 -0
- package/dist/vector/adapters/index.js +19 -0
- package/dist/vector/adapters/index.js.map +1 -0
- package/dist/vector/adapters/memory.adapter.d.ts +85 -0
- package/dist/vector/adapters/memory.adapter.js +505 -0
- package/dist/vector/adapters/memory.adapter.js.map +1 -0
- package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
- package/dist/vector/adapters/pinecone.adapter.js +400 -0
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
- package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
- package/dist/vector/adapters/qdrant.adapter.js +392 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
- package/dist/vector/adapters/weaviate.adapter.js +478 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +47 -0
- package/dist/vector/index.js +72 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/types/connection.interface.d.ts +151 -0
- package/dist/vector/types/connection.interface.js +8 -0
- package/dist/vector/types/connection.interface.js.map +1 -0
- package/dist/vector/types/embedding.interface.d.ts +144 -0
- package/dist/vector/types/embedding.interface.js +8 -0
- package/dist/vector/types/embedding.interface.js.map +1 -0
- package/dist/vector/types/enums.d.ts +104 -0
- package/dist/vector/types/enums.js +113 -0
- package/dist/vector/types/enums.js.map +1 -0
- package/dist/vector/types/index.d.ts +9 -0
- package/dist/vector/types/index.js +16 -0
- package/dist/vector/types/index.js.map +1 -0
- package/dist/vector/types/vector.interface.d.ts +315 -0
- package/dist/vector/types/vector.interface.js +8 -0
- package/dist/vector/types/vector.interface.js.map +1 -0
- package/dist/vector/utils/index.d.ts +6 -0
- package/dist/vector/utils/index.js +11 -0
- package/dist/vector/utils/index.js.map +1 -0
- package/dist/vector/utils/vector-error.d.ts +69 -0
- package/dist/vector/utils/vector-error.js +117 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +405 -0
- package/dist/vector/vector-database.service.js +544 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +245 -0
- package/dist/vector/vector.service.js +381 -0
- package/dist/vector/vector.service.js.map +1 -0
- package/dist/workflows/index.d.ts +30 -0
- package/dist/workflows/index.js +64 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types/index.d.ts +6 -0
- package/dist/workflows/types/index.js +23 -0
- package/dist/workflows/types/index.js.map +1 -0
- package/dist/workflows/types/workflows.types.d.ts +1035 -0
- package/dist/workflows/types/workflows.types.js +13 -0
- package/dist/workflows/types/workflows.types.js.map +1 -0
- package/dist/workflows/workflow-builder.d.ts +70 -0
- package/dist/workflows/workflow-builder.js +338 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +205 -0
- package/dist/workflows/workflow-executor.js +1186 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +398 -0
- package/dist/workflows/workflows.service.js +1595 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +16 -13
- package/dist/actions/actions.repo.d.ts +0 -0
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.d.ts +0 -0
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.d.ts +0 -0
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +0 -75
- package/dist/api/services/workspaceSecretsApi.service.js +0 -62
- package/dist/api/services/workspaceSecretsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/database/database.service.d.ts +0 -232
- package/dist/database/database.service.js +0 -802
- package/dist/database/database.service.js.map +0 -1
- package/dist/database/types/aggregation.types.d.ts +0 -261
- package/dist/database/types/aggregation.types.js +0 -21
- package/dist/database/types/aggregation.types.js.map +0 -1
- package/dist/database/types/connection.types.d.ts +0 -132
- package/dist/database/types/connection.types.js +0 -6
- package/dist/database/types/connection.types.js.map +0 -1
- package/dist/database/types/database.types.d.ts +0 -175
- package/dist/database/types/database.types.js +0 -75
- package/dist/database/types/database.types.js.map +0 -1
- package/dist/database/types/index.types.d.ts +0 -220
- package/dist/database/types/index.types.js +0 -27
- package/dist/database/types/index.types.js.map +0 -1
- package/dist/database/types/migration.types.d.ts +0 -205
- package/dist/database/types/migration.types.js +0 -44
- package/dist/database/types/migration.types.js.map +0 -1
- package/dist/database/types/query.types.d.ts +0 -305
- package/dist/database/types/query.types.js +0 -57
- package/dist/database/types/query.types.js.map +0 -1
- package/dist/database/types/result.types.d.ts +0 -220
- package/dist/database/types/result.types.js +0 -6
- package/dist/database/types/result.types.js.map +0 -1
- package/dist/database/types/schema.types.d.ts +0 -190
- package/dist/database/types/schema.types.js +0 -69
- package/dist/database/types/schema.types.js.map +0 -1
- package/dist/database/utils/helpers.d.ts +0 -66
- package/dist/database/utils/helpers.js +0 -501
- package/dist/database/utils/helpers.js.map +0 -1
- package/dist/database/utils/migration.utils.d.ts +0 -151
- package/dist/database/utils/migration.utils.js +0 -476
- package/dist/database/utils/migration.utils.js.map +0 -1
- package/dist/database/utils/transaction.d.ts +0 -64
- package/dist/database/utils/transaction.js +0 -130
- package/dist/database/utils/transaction.js.map +0 -1
- package/dist/database/validators/connection.validator.d.ts +0 -20
- package/dist/database/validators/connection.validator.js +0 -267
- package/dist/database/validators/connection.validator.js.map +0 -1
- package/dist/database/validators/query.validator.d.ts +0 -31
- package/dist/database/validators/query.validator.js +0 -305
- package/dist/database/validators/query.validator.js.map +0 -1
- package/dist/database/validators/schema.validator.d.ts +0 -31
- package/dist/database/validators/schema.validator.js +0 -334
- package/dist/database/validators/schema.validator.js.map +0 -1
- package/dist/graph/graph.service.d.ts +0 -278
- package/dist/graph/graph.service.js +0 -687
- package/dist/graph/graph.service.js.map +0 -1
- package/dist/graph/types/connection.types.d.ts +0 -158
- package/dist/graph/types/connection.types.js +0 -43
- package/dist/graph/types/connection.types.js.map +0 -1
- package/dist/graph/types/graph.types.d.ts +0 -144
- package/dist/graph/types/graph.types.js +0 -84
- package/dist/graph/types/graph.types.js.map +0 -1
- package/dist/graph/types/node.types.d.ts +0 -193
- package/dist/graph/types/node.types.js +0 -49
- package/dist/graph/types/node.types.js.map +0 -1
- package/dist/graph/types/path.types.d.ts +0 -224
- package/dist/graph/types/path.types.js +0 -38
- package/dist/graph/types/path.types.js.map +0 -1
- package/dist/graph/types/query.types.d.ts +0 -247
- package/dist/graph/types/query.types.js +0 -23
- package/dist/graph/types/query.types.js.map +0 -1
- package/dist/graph/types/relationship.types.d.ts +0 -224
- package/dist/graph/types/relationship.types.js +0 -35
- package/dist/graph/types/relationship.types.js.map +0 -1
- package/dist/graph/types/result.types.d.ts +0 -237
- package/dist/graph/types/result.types.js +0 -7
- package/dist/graph/types/result.types.js.map +0 -1
- package/dist/graph/validators/index.d.ts +0 -81
- package/dist/graph/validators/index.js +0 -243
- package/dist/graph/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/utils/mongo.util.d.ts +0 -0
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/services/utils/crypt.utils.d.ts +0 -1
- package/dist/products/services/utils/crypt.utils.js +0 -17
- package/dist/products/services/utils/crypt.utils.js.map +0 -1
- package/dist/products/services/utils/functions.utils.d.ts +0 -13
- package/dist/products/services/utils/functions.utils.js +0 -289
- package/dist/products/services/utils/functions.utils.js.map +0 -1
- package/dist/products/services/utils/objects.utils.d.ts +0 -13
- package/dist/products/services/utils/objects.utils.js +0 -89
- package/dist/products/services/utils/objects.utils.js.map +0 -1
- package/dist/products/services/utils/string.utils.d.ts +0 -12
- package/dist/products/services/utils/string.utils.js +0 -168
- package/dist/products/services/utils/string.utils.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- package/dist/test.import.d.ts +0 -0
- package/dist/test.import.js +0 -24
- package/dist/test.import.js.map +0 -1
- package/dist/test.imports.js +0 -28
- package/dist/test.imports.js.map +0 -1
- package/dist/test.integrationBuilder.js +0 -276
- package/dist/test.integrationBuilder.js.map +0 -1
- package/dist/test.processor.d.ts +0 -1
- package/dist/test.processor.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.d.ts +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Memgraph Graph Database Adapter
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* Implements the BaseGraphAdapter for Memgraph.
|
|
6
|
+
* Memgraph is a high-performance, in-memory graph database
|
|
7
|
+
* that is fully compatible with Neo4j's Bolt protocol and Cypher query language.
|
|
8
|
+
*
|
|
9
|
+
* Key features:
|
|
10
|
+
* - Cypher query language compatibility
|
|
11
|
+
* - Bolt protocol support
|
|
12
|
+
* - In-memory performance
|
|
13
|
+
* - Triggers and streams support
|
|
14
|
+
* - MAGE graph algorithms library
|
|
6
15
|
*/
|
|
7
16
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
17
|
if (k2 === undefined) k2 = k;
|
|
@@ -40,1452 +49,1291 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
50
|
exports.MemgraphAdapter = void 0;
|
|
42
51
|
const base_adapter_1 = require("./base.adapter");
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const relationship_types_1 = require("../types/relationship.types");
|
|
52
|
+
const enums_1 = require("../types/enums");
|
|
53
|
+
const graph_error_1 = require("../utils/graph-error");
|
|
46
54
|
/**
|
|
47
|
-
* Memgraph
|
|
48
|
-
* Uses
|
|
55
|
+
* Memgraph adapter - Cypher-compatible graph database
|
|
56
|
+
* Uses the neo4j-driver package as Memgraph supports the Bolt protocol
|
|
49
57
|
*/
|
|
50
|
-
class
|
|
51
|
-
constructor(
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
|
|
58
|
+
class MemgraphAdapter extends base_adapter_1.BaseGraphAdapter {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.graphType = enums_1.GraphType.MEMGRAPH;
|
|
62
|
+
this.supportedFeatures = new Set([
|
|
63
|
+
enums_1.GraphFeature.TRANSACTIONS,
|
|
64
|
+
enums_1.GraphFeature.SCHEMA_INDEXES,
|
|
65
|
+
enums_1.GraphFeature.TRIGGERS,
|
|
66
|
+
enums_1.GraphFeature.CHANGE_STREAMS,
|
|
67
|
+
enums_1.GraphFeature.GRAPH_ALGORITHMS,
|
|
68
|
+
]);
|
|
56
69
|
this.driver = null;
|
|
57
|
-
this.
|
|
58
|
-
this.id = id || `memgraph-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
59
|
-
this.createdAt = new Date();
|
|
70
|
+
this.session = null;
|
|
60
71
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
this.status = graph_types_1.GraphConnectionStatus.CONNECTING;
|
|
72
|
+
// ==================== CONNECTION MANAGEMENT ====================
|
|
73
|
+
async connect(options) {
|
|
74
|
+
var _a, _b;
|
|
67
75
|
try {
|
|
68
|
-
//
|
|
76
|
+
// Memgraph uses the Bolt protocol, compatible with neo4j-driver
|
|
69
77
|
const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
connectionTimeout: this.config.connectionTimeout || 30000,
|
|
78
|
-
};
|
|
79
|
-
if (this.config.encrypted !== undefined) {
|
|
80
|
-
driverConfig.encrypted = this.config.encrypted;
|
|
81
|
-
}
|
|
82
|
-
if ((_a = this.config.options) === null || _a === void 0 ? void 0 : _a.trustAll) {
|
|
83
|
-
driverConfig.trust = 'TRUST_ALL_CERTIFICATES';
|
|
84
|
-
}
|
|
85
|
-
this.driver = neo4j.default.driver(uri, authToken, driverConfig);
|
|
86
|
-
// Verify connectivity
|
|
78
|
+
const auth = options.auth
|
|
79
|
+
? neo4j.auth.basic(options.auth.username, options.auth.password)
|
|
80
|
+
: neo4j.auth.basic('', ''); // Memgraph can run without auth
|
|
81
|
+
this.driver = neo4j.driver(options.connectionUrl, auth, Object.assign(Object.assign({}, options.options), {
|
|
82
|
+
// Memgraph-specific settings
|
|
83
|
+
encrypted: (_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.encrypted) !== null && _b !== void 0 ? _b : false }));
|
|
84
|
+
// Verify connection
|
|
87
85
|
await this.driver.verifyConnectivity();
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
async disconnect() {
|
|
97
|
-
if (this.currentSession) {
|
|
98
|
-
await this.currentSession.close();
|
|
99
|
-
this.currentSession = null;
|
|
100
|
-
}
|
|
101
|
-
if (this.driver) {
|
|
102
|
-
await this.driver.close();
|
|
103
|
-
this.driver = null;
|
|
104
|
-
}
|
|
105
|
-
this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
|
|
106
|
-
}
|
|
107
|
-
isConnected() {
|
|
108
|
-
return this.status === graph_types_1.GraphConnectionStatus.CONNECTED && this.driver !== null;
|
|
109
|
-
}
|
|
110
|
-
getClient() {
|
|
111
|
-
if (!this.driver) {
|
|
112
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Memgraph driver not initialized. Call connect() first.');
|
|
113
|
-
}
|
|
114
|
-
return this.driver;
|
|
115
|
-
}
|
|
116
|
-
getSession() {
|
|
117
|
-
if (!this.driver) {
|
|
118
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Memgraph driver not initialized. Call connect() first.');
|
|
119
|
-
}
|
|
120
|
-
const sessionConfig = {};
|
|
121
|
-
if (this.config.database) {
|
|
122
|
-
sessionConfig.database = this.config.database;
|
|
123
|
-
}
|
|
124
|
-
this.currentSession = this.driver.session(sessionConfig);
|
|
125
|
-
this.lastUsedAt = new Date();
|
|
126
|
-
return this.currentSession;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Memgraph transaction implementation
|
|
131
|
-
*/
|
|
132
|
-
class MemgraphTransaction {
|
|
133
|
-
constructor(connection, session, transaction) {
|
|
134
|
-
this.connection = connection;
|
|
135
|
-
this.session = session;
|
|
136
|
-
this.status = graph_types_1.GraphTransactionStatus.PENDING;
|
|
137
|
-
this.id = `tx-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
138
|
-
this.createdAt = new Date();
|
|
139
|
-
this.native = transaction;
|
|
140
|
-
this.status = graph_types_1.GraphTransactionStatus.ACTIVE;
|
|
141
|
-
}
|
|
142
|
-
async commit() {
|
|
143
|
-
if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
|
|
144
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Cannot commit transaction in ${this.status} state`);
|
|
145
|
-
}
|
|
146
|
-
try {
|
|
147
|
-
await this.native.commit();
|
|
148
|
-
this.status = graph_types_1.GraphTransactionStatus.COMMITTED;
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
this.status = graph_types_1.GraphTransactionStatus.FAILED;
|
|
152
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to commit transaction: ${error.message}`, error);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async rollback() {
|
|
156
|
-
if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
try {
|
|
160
|
-
await this.native.rollback();
|
|
161
|
-
this.status = graph_types_1.GraphTransactionStatus.ROLLED_BACK;
|
|
86
|
+
this.connected = true;
|
|
87
|
+
this.connectionUrl = options.connectionUrl;
|
|
88
|
+
return {
|
|
89
|
+
connected: true,
|
|
90
|
+
type: enums_1.GraphType.MEMGRAPH,
|
|
91
|
+
latency: 0,
|
|
92
|
+
};
|
|
162
93
|
}
|
|
163
94
|
catch (error) {
|
|
164
|
-
this.
|
|
165
|
-
throw
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
isActive() {
|
|
169
|
-
return this.status === graph_types_1.GraphTransactionStatus.ACTIVE;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Memgraph Graph Database Adapter
|
|
174
|
-
*/
|
|
175
|
-
class MemgraphAdapter extends base_adapter_1.BaseGraphAdapter {
|
|
176
|
-
constructor() {
|
|
177
|
-
super(...arguments);
|
|
178
|
-
this.type = graph_types_1.GraphDatabaseType.MEMGRAPH;
|
|
179
|
-
this.supportedLanguages = [graph_types_1.GraphQueryLanguage.CYPHER];
|
|
180
|
-
this.defaultLanguage = graph_types_1.GraphQueryLanguage.CYPHER;
|
|
181
|
-
}
|
|
182
|
-
// ==================== CONNECTION METHODS ====================
|
|
183
|
-
async connect(config) {
|
|
184
|
-
if (config.type !== graph_types_1.GraphDatabaseType.MEMGRAPH) {
|
|
185
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Invalid config type ${config.type}. Expected ${graph_types_1.GraphDatabaseType.MEMGRAPH}`);
|
|
95
|
+
this.connected = false;
|
|
96
|
+
throw graph_error_1.GraphError.connectionError(`Failed to connect to Memgraph: ${error.message}`, error);
|
|
186
97
|
}
|
|
187
|
-
const connection = new MemgraphConnection(config);
|
|
188
|
-
await connection.connect();
|
|
189
|
-
return connection;
|
|
190
|
-
}
|
|
191
|
-
async disconnect(connection) {
|
|
192
|
-
await connection.disconnect();
|
|
193
98
|
}
|
|
194
|
-
async testConnection(
|
|
195
|
-
const startTime = Date.now();
|
|
99
|
+
async testConnection(options) {
|
|
196
100
|
try {
|
|
197
|
-
const
|
|
198
|
-
const
|
|
101
|
+
const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
|
|
102
|
+
const startTime = Date.now();
|
|
103
|
+
const auth = options.auth
|
|
104
|
+
? neo4j.auth.basic(options.auth.username, options.auth.password)
|
|
105
|
+
: neo4j.auth.basic('', '');
|
|
106
|
+
const testDriver = neo4j.driver(options.connectionUrl, auth, Object.assign(Object.assign({}, options.options), { connectionTimeout: 5000 }));
|
|
107
|
+
await testDriver.verifyConnectivity();
|
|
108
|
+
// Get Memgraph version
|
|
109
|
+
const session = testDriver.session();
|
|
110
|
+
const result = await session.run('CALL mg.info() YIELD key, value WHERE key = "version" RETURN value');
|
|
111
|
+
const version = result.records.length > 0 ? result.records[0].get('value') : 'unknown';
|
|
199
112
|
await session.close();
|
|
113
|
+
await testDriver.close();
|
|
200
114
|
return {
|
|
201
115
|
connected: true,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
responseTime: Date.now() - startTime,
|
|
116
|
+
type: enums_1.GraphType.MEMGRAPH,
|
|
117
|
+
version,
|
|
118
|
+
latency: Date.now() - startTime,
|
|
206
119
|
};
|
|
207
120
|
}
|
|
208
121
|
catch (error) {
|
|
209
122
|
return {
|
|
210
123
|
connected: false,
|
|
211
|
-
|
|
212
|
-
databaseType: graph_types_1.GraphDatabaseType.MEMGRAPH,
|
|
213
|
-
queryLanguage: graph_types_1.GraphQueryLanguage.CYPHER,
|
|
214
|
-
responseTime: Date.now() - startTime,
|
|
124
|
+
type: enums_1.GraphType.MEMGRAPH,
|
|
215
125
|
error: error.message,
|
|
216
126
|
};
|
|
217
127
|
}
|
|
218
128
|
}
|
|
219
|
-
async
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const result = await session.run('CALL mg.info() YIELD * RETURN *');
|
|
224
|
-
const record = result.records[0];
|
|
225
|
-
return {
|
|
226
|
-
version: (record === null || record === void 0 ? void 0 : record.get('version')) || 'Unknown',
|
|
227
|
-
edition: 'Memgraph',
|
|
228
|
-
features: ['cypher', 'streaming', 'in-memory'],
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
catch (_a) {
|
|
232
|
-
// Fallback for older Memgraph versions
|
|
233
|
-
return {
|
|
234
|
-
version: 'Unknown',
|
|
235
|
-
edition: 'Memgraph',
|
|
236
|
-
features: ['cypher', 'streaming', 'in-memory'],
|
|
237
|
-
};
|
|
129
|
+
async disconnect() {
|
|
130
|
+
if (this.session) {
|
|
131
|
+
await this.session.close();
|
|
132
|
+
this.session = null;
|
|
238
133
|
}
|
|
239
|
-
|
|
240
|
-
await
|
|
134
|
+
if (this.driver) {
|
|
135
|
+
await this.driver.close();
|
|
136
|
+
this.driver = null;
|
|
241
137
|
}
|
|
138
|
+
this.connected = false;
|
|
242
139
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const txConfig = {};
|
|
247
|
-
if (options === null || options === void 0 ? void 0 : options.timeout) {
|
|
248
|
-
txConfig.timeout = options.timeout;
|
|
140
|
+
getSession(transaction) {
|
|
141
|
+
if (transaction === null || transaction === void 0 ? void 0 : transaction.client) {
|
|
142
|
+
return transaction.client;
|
|
249
143
|
}
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const transaction = session.beginTransaction(txConfig);
|
|
254
|
-
return new MemgraphTransaction(connection, session, transaction);
|
|
255
|
-
}
|
|
256
|
-
async commitTransaction(connection, transaction) {
|
|
257
|
-
await transaction.commit();
|
|
258
|
-
}
|
|
259
|
-
async rollbackTransaction(connection, transaction) {
|
|
260
|
-
await transaction.rollback();
|
|
261
|
-
}
|
|
262
|
-
// ==================== RAW QUERY METHODS ====================
|
|
263
|
-
async executeRaw(connection, options, transaction) {
|
|
264
|
-
var _a;
|
|
265
|
-
const startTime = Date.now();
|
|
266
|
-
try {
|
|
267
|
-
let result;
|
|
268
|
-
if (transaction && transaction.isActive()) {
|
|
269
|
-
result = await transaction.native.run(options.query, options.params || {});
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
const session = connection.getSession();
|
|
273
|
-
try {
|
|
274
|
-
result = await session.run(options.query, options.params || {});
|
|
275
|
-
}
|
|
276
|
-
finally {
|
|
277
|
-
await session.close();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const records = result.records.map((record) => {
|
|
281
|
-
const obj = {};
|
|
282
|
-
record.keys.forEach((key) => {
|
|
283
|
-
obj[key] = this.convertValue(record.get(key));
|
|
284
|
-
});
|
|
285
|
-
return obj;
|
|
286
|
-
});
|
|
287
|
-
return {
|
|
288
|
-
success: true,
|
|
289
|
-
executionTime: Date.now() - startTime,
|
|
290
|
-
data: records,
|
|
291
|
-
columns: result.records.length > 0 ? [...result.records[0].keys] : [],
|
|
292
|
-
count: records.length,
|
|
293
|
-
statistics: this.parseStatistics((_a = result.summary) === null || _a === void 0 ? void 0 : _a.counters),
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
throw this.wrapError(error, graph_types_1.GraphErrorType.QUERY_ERROR, `Query execution failed: ${error.message}`, options.query, options.params);
|
|
144
|
+
if (!this.session) {
|
|
145
|
+
this.ensureConnected();
|
|
146
|
+
this.session = this.driver.session();
|
|
298
147
|
}
|
|
148
|
+
return this.session;
|
|
299
149
|
}
|
|
300
150
|
// ==================== NODE OPERATIONS ====================
|
|
301
|
-
async createNode(
|
|
302
|
-
|
|
303
|
-
const labels =
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
const
|
|
151
|
+
async createNode(options, transaction) {
|
|
152
|
+
this.ensureConnected();
|
|
153
|
+
const labels = options.labels.join(':');
|
|
154
|
+
const query = `CREATE (n:${labels} $props) RETURN n, id(n) as nodeId`;
|
|
155
|
+
const session = this.getSession(transaction);
|
|
156
|
+
const result = await session.run(query, { props: options.properties });
|
|
157
|
+
const record = result.records[0];
|
|
158
|
+
const node = record.get('n');
|
|
159
|
+
const nodeId = record.get('nodeId');
|
|
308
160
|
return {
|
|
309
|
-
|
|
310
|
-
executionTime: Date.now() - startTime,
|
|
311
|
-
node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
|
|
161
|
+
node: this.mapMemgraphNode(node, nodeId),
|
|
312
162
|
created: true,
|
|
313
|
-
statistics: result.statistics,
|
|
314
163
|
};
|
|
315
164
|
}
|
|
316
|
-
async findNodes(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
165
|
+
async findNodes(options, transaction) {
|
|
166
|
+
var _a, _b;
|
|
167
|
+
this.ensureConnected();
|
|
168
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
169
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
170
|
+
let query = `MATCH (n${labelClause})`;
|
|
321
171
|
const params = {};
|
|
322
|
-
// Build WHERE clause
|
|
323
|
-
const whereParts = [];
|
|
324
172
|
if (options.where) {
|
|
325
|
-
const { clause, params: whereParams } = this.
|
|
326
|
-
|
|
173
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
|
|
174
|
+
query += ` WHERE ${clause}`;
|
|
327
175
|
Object.assign(params, whereParams);
|
|
328
176
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
params[paramName] = value;
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
if (whereParts.length > 0) {
|
|
337
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
177
|
+
query += ' RETURN n, id(n) as nodeId';
|
|
178
|
+
if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
|
|
179
|
+
const orderClauses = options.orderBy.map(o => `n.${o.property} ${o.direction.toUpperCase()}`);
|
|
180
|
+
query += ` ORDER BY ${orderClauses.join(', ')}`;
|
|
338
181
|
}
|
|
339
|
-
|
|
340
|
-
// ORDER BY
|
|
341
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
342
|
-
const orderParts = options.orderBy.map(o => `n.${this.escapeIdentifier(o.property)} ${o.direction}`);
|
|
343
|
-
query += ` ORDER BY ${orderParts.join(', ')}`;
|
|
344
|
-
}
|
|
345
|
-
// SKIP and LIMIT
|
|
346
|
-
if (options.skip !== undefined) {
|
|
182
|
+
if (options.skip) {
|
|
347
183
|
query += ` SKIP ${options.skip}`;
|
|
348
184
|
}
|
|
349
|
-
if (options.limit
|
|
185
|
+
if (options.limit) {
|
|
350
186
|
query += ` LIMIT ${options.limit}`;
|
|
351
187
|
}
|
|
352
|
-
const
|
|
353
|
-
const
|
|
188
|
+
const session = this.getSession(transaction);
|
|
189
|
+
const result = await session.run(query, params);
|
|
190
|
+
const nodes = result.records.map((record) => this.mapMemgraphNode(record.get('n'), record.get('nodeId')));
|
|
354
191
|
return {
|
|
355
|
-
success: true,
|
|
356
|
-
executionTime: Date.now() - startTime,
|
|
357
192
|
nodes,
|
|
358
193
|
count: nodes.length,
|
|
359
|
-
hasMore: options.limit !== undefined && nodes.length === options.limit,
|
|
360
194
|
};
|
|
361
195
|
}
|
|
362
|
-
async findNodeById(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
|
|
196
|
+
async findNodeById(id, transaction) {
|
|
197
|
+
this.ensureConnected();
|
|
198
|
+
// Memgraph uses internal id() function
|
|
199
|
+
const query = `MATCH (n) WHERE id(n) = $id RETURN n, id(n) as nodeId`;
|
|
200
|
+
const session = this.getSession(transaction);
|
|
201
|
+
const result = await session.run(query, {
|
|
202
|
+
id: typeof id === 'number' ? id : parseInt(id, 10),
|
|
203
|
+
});
|
|
204
|
+
if (result.records.length === 0) {
|
|
367
205
|
return null;
|
|
368
206
|
}
|
|
369
|
-
return this.
|
|
207
|
+
return this.mapMemgraphNode(result.records[0].get('n'), result.records[0].get('nodeId'));
|
|
370
208
|
}
|
|
371
|
-
async updateNode(
|
|
209
|
+
async updateNode(options, transaction) {
|
|
372
210
|
var _a;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (options.id
|
|
377
|
-
|
|
378
|
-
params.
|
|
379
|
-
}
|
|
380
|
-
else if (options.labels) {
|
|
381
|
-
const labels = this.normalizeLabels(options.labels);
|
|
382
|
-
matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
|
|
383
|
-
}
|
|
384
|
-
if (options.where) {
|
|
385
|
-
const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
|
|
386
|
-
matchClause += options.id === undefined && !options.labels ? ` WHERE ${clause}` : ` AND ${clause}`;
|
|
387
|
-
Object.assign(params, whereParams);
|
|
388
|
-
}
|
|
389
|
-
const setParts = [];
|
|
390
|
-
const removeParts = [];
|
|
391
|
-
if (options.set) {
|
|
392
|
-
Object.entries(options.set).forEach(([key, value], index) => {
|
|
393
|
-
const paramName = `set_${index}`;
|
|
394
|
-
setParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
395
|
-
params[paramName] = value;
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
if (options.addLabels && options.addLabels.length > 0) {
|
|
399
|
-
setParts.push(`n:${options.addLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
|
|
400
|
-
}
|
|
401
|
-
if (options.remove && options.remove.length > 0) {
|
|
402
|
-
options.remove.forEach(prop => {
|
|
403
|
-
removeParts.push(`n.${this.escapeIdentifier(prop)}`);
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
if (options.removeLabels && options.removeLabels.length > 0) {
|
|
407
|
-
removeParts.push(`n:${options.removeLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
|
|
408
|
-
}
|
|
409
|
-
let query = matchClause;
|
|
410
|
-
if (setParts.length > 0) {
|
|
411
|
-
query += ` SET ${setParts.join(', ')}`;
|
|
211
|
+
this.ensureConnected();
|
|
212
|
+
let query;
|
|
213
|
+
const params = { props: options.properties };
|
|
214
|
+
if (options.id) {
|
|
215
|
+
query = `MATCH (n) WHERE id(n) = $id SET n += $props RETURN n, id(n) as nodeId`;
|
|
216
|
+
params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
|
|
412
217
|
}
|
|
413
|
-
|
|
414
|
-
|
|
218
|
+
else {
|
|
219
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
220
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
221
|
+
query = `MATCH (n${labelClause})`;
|
|
222
|
+
if (options.where) {
|
|
223
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
|
|
224
|
+
query += ` WHERE ${clause}`;
|
|
225
|
+
Object.assign(params, whereParams);
|
|
226
|
+
}
|
|
227
|
+
query += ' SET n += $props RETURN n, id(n) as nodeId';
|
|
415
228
|
}
|
|
416
|
-
|
|
417
|
-
const result = await
|
|
229
|
+
const session = this.getSession(transaction);
|
|
230
|
+
const result = await session.run(query, params);
|
|
231
|
+
const nodes = result.records.map((record) => this.mapMemgraphNode(record.get('n'), record.get('nodeId')));
|
|
418
232
|
return {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
updated:
|
|
423
|
-
matchedCount: result.data.length,
|
|
424
|
-
modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
|
|
425
|
-
statistics: result.statistics,
|
|
233
|
+
node: nodes.length === 1 ? nodes[0] : undefined,
|
|
234
|
+
nodes: nodes.length > 1 ? nodes : undefined,
|
|
235
|
+
updatedCount: nodes.length,
|
|
236
|
+
updated: nodes.length > 0,
|
|
426
237
|
};
|
|
427
238
|
}
|
|
428
|
-
async deleteNode(
|
|
239
|
+
async deleteNode(options, transaction) {
|
|
429
240
|
var _a, _b;
|
|
430
|
-
|
|
241
|
+
this.ensureConnected();
|
|
242
|
+
let query;
|
|
431
243
|
const params = {};
|
|
432
|
-
|
|
433
|
-
if (options.id
|
|
434
|
-
|
|
435
|
-
params.
|
|
436
|
-
}
|
|
437
|
-
else if (options.labels) {
|
|
438
|
-
const labels = this.normalizeLabels(options.labels);
|
|
439
|
-
matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
|
|
244
|
+
const detach = options.detach ? 'DETACH ' : '';
|
|
245
|
+
if (options.id) {
|
|
246
|
+
query = `MATCH (n) WHERE id(n) = $id ${detach}DELETE n RETURN count(n) as count`;
|
|
247
|
+
params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
|
|
440
248
|
}
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
249
|
+
else {
|
|
250
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
251
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
252
|
+
query = `MATCH (n${labelClause})`;
|
|
253
|
+
if (options.where) {
|
|
254
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
|
|
255
|
+
query += ` WHERE ${clause}`;
|
|
256
|
+
Object.assign(params, whereParams);
|
|
257
|
+
}
|
|
258
|
+
query += ` ${detach}DELETE n RETURN count(n) as count`;
|
|
445
259
|
}
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
const
|
|
260
|
+
const session = this.getSession(transaction);
|
|
261
|
+
const result = await session.run(query, params);
|
|
262
|
+
const count = this.toNumber((_b = result.records[0]) === null || _b === void 0 ? void 0 : _b.get('count')) || 0;
|
|
449
263
|
return {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesDeleted) || 0,
|
|
453
|
-
deletedRelationshipsCount: ((_b = result.statistics) === null || _b === void 0 ? void 0 : _b.relationshipsDeleted) || 0,
|
|
454
|
-
statistics: result.statistics,
|
|
264
|
+
deleted: count > 0,
|
|
265
|
+
deletedCount: count,
|
|
455
266
|
};
|
|
456
267
|
}
|
|
457
|
-
async mergeNode(
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
const
|
|
461
|
-
|
|
268
|
+
async mergeNode(options, transaction) {
|
|
269
|
+
this.ensureConnected();
|
|
270
|
+
const labels = options.labels.join(':');
|
|
271
|
+
const matchProps = Object.entries(options.matchProperties)
|
|
272
|
+
.map(([key]) => `${key}: $match_${key}`)
|
|
273
|
+
.join(', ');
|
|
274
|
+
let query = `MERGE (n:${labels} {${matchProps}})`;
|
|
462
275
|
const params = {};
|
|
463
|
-
|
|
464
|
-
Object.entries(options.matchProperties).forEach(([key, value]
|
|
465
|
-
|
|
466
|
-
matchProps.push(`${this.escapeIdentifier(key)}: $${paramName}`);
|
|
467
|
-
params[paramName] = value;
|
|
276
|
+
// Add match properties to params
|
|
277
|
+
Object.entries(options.matchProperties).forEach(([key, value]) => {
|
|
278
|
+
params[`match_${key}`] = value;
|
|
468
279
|
});
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
280
|
+
if (options.onCreate) {
|
|
281
|
+
query += ' ON CREATE SET n += $onCreateProps';
|
|
282
|
+
params.onCreateProps = options.onCreate;
|
|
283
|
+
}
|
|
284
|
+
if (options.onMatch) {
|
|
285
|
+
query += ' ON MATCH SET n += $onMatchProps';
|
|
286
|
+
params.onMatchProps = options.onMatch;
|
|
287
|
+
}
|
|
288
|
+
query += ' RETURN n, id(n) as nodeId';
|
|
289
|
+
const session = this.getSession(transaction);
|
|
290
|
+
const result = await session.run(query, params);
|
|
291
|
+
const record = result.records[0];
|
|
292
|
+
const node = this.mapMemgraphNode(record.get('n'), record.get('nodeId'));
|
|
293
|
+
return {
|
|
294
|
+
node,
|
|
295
|
+
created: true, // Memgraph doesn't easily tell us if it was created or matched
|
|
296
|
+
merged: true,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
// ==================== LABEL MANAGEMENT ====================
|
|
300
|
+
async addLabels(options, transaction) {
|
|
301
|
+
this.ensureConnected();
|
|
302
|
+
const labels = options.labels.map(l => `:\`${l}\``).join('');
|
|
303
|
+
const query = `
|
|
304
|
+
MATCH (n)
|
|
305
|
+
WHERE id(n) = $id
|
|
306
|
+
SET n${labels}
|
|
307
|
+
RETURN n, id(n) as nodeId
|
|
308
|
+
`;
|
|
309
|
+
const params = {
|
|
310
|
+
id: typeof options.id === 'number' ? options.id : parseInt(options.id, 10),
|
|
311
|
+
};
|
|
312
|
+
const session = this.getSession(transaction);
|
|
313
|
+
const result = await session.run(query, params);
|
|
314
|
+
if (result.records.length === 0) {
|
|
315
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
478
316
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
317
|
+
const record = result.records[0];
|
|
318
|
+
const node = this.mapMemgraphNode(record.get('n'), record.get('nodeId'));
|
|
319
|
+
return {
|
|
320
|
+
node,
|
|
321
|
+
addedLabels: options.labels,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
async removeLabels(options, transaction) {
|
|
325
|
+
this.ensureConnected();
|
|
326
|
+
const labels = options.labels.map(l => `:\`${l}\``).join('');
|
|
327
|
+
const query = `
|
|
328
|
+
MATCH (n)
|
|
329
|
+
WHERE id(n) = $id
|
|
330
|
+
REMOVE n${labels}
|
|
331
|
+
RETURN n, id(n) as nodeId
|
|
332
|
+
`;
|
|
333
|
+
const params = {
|
|
334
|
+
id: typeof options.id === 'number' ? options.id : parseInt(options.id, 10),
|
|
335
|
+
};
|
|
336
|
+
const session = this.getSession(transaction);
|
|
337
|
+
const result = await session.run(query, params);
|
|
338
|
+
if (result.records.length === 0) {
|
|
339
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
487
340
|
}
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesCreated) || 0) > 0;
|
|
341
|
+
const record = result.records[0];
|
|
342
|
+
const node = this.mapMemgraphNode(record.get('n'), record.get('nodeId'));
|
|
491
343
|
return {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
344
|
+
node,
|
|
345
|
+
removedLabels: options.labels,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
async setLabels(options, transaction) {
|
|
349
|
+
this.ensureConnected();
|
|
350
|
+
// First get current labels
|
|
351
|
+
const getQuery = `
|
|
352
|
+
MATCH (n)
|
|
353
|
+
WHERE id(n) = $id
|
|
354
|
+
RETURN labels(n) as currentLabels
|
|
355
|
+
`;
|
|
356
|
+
const params = {
|
|
357
|
+
id: typeof options.id === 'number' ? options.id : parseInt(options.id, 10),
|
|
358
|
+
};
|
|
359
|
+
const session = this.getSession(transaction);
|
|
360
|
+
const getResult = await session.run(getQuery, params);
|
|
361
|
+
if (getResult.records.length === 0) {
|
|
362
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
363
|
+
}
|
|
364
|
+
const previousLabels = getResult.records[0].get('currentLabels');
|
|
365
|
+
// Remove all existing labels and add new ones
|
|
366
|
+
const removeLabels = previousLabels.map(l => `:\`${l}\``).join('');
|
|
367
|
+
const addLabels = options.labels.map(l => `:\`${l}\``).join('');
|
|
368
|
+
const setQuery = `
|
|
369
|
+
MATCH (n)
|
|
370
|
+
WHERE id(n) = $id
|
|
371
|
+
REMOVE n${removeLabels}
|
|
372
|
+
SET n${addLabels}
|
|
373
|
+
RETURN n, id(n) as nodeId
|
|
374
|
+
`;
|
|
375
|
+
const result = await session.run(setQuery, params);
|
|
376
|
+
const node = this.mapMemgraphNode(result.records[0].get('n'), result.records[0].get('nodeId'));
|
|
377
|
+
return {
|
|
378
|
+
node,
|
|
379
|
+
previousLabels,
|
|
380
|
+
newLabels: options.labels,
|
|
498
381
|
};
|
|
499
382
|
}
|
|
500
383
|
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
501
|
-
async createRelationship(
|
|
502
|
-
|
|
503
|
-
const startTime = Date.now();
|
|
504
|
-
const params = {};
|
|
505
|
-
const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
|
|
506
|
-
const toMatch = this.buildNodeReference(options.toNode, 'to', params);
|
|
507
|
-
let propsClause = '';
|
|
508
|
-
if (options.properties && Object.keys(options.properties).length > 0) {
|
|
509
|
-
const { clause, params: propParams } = this.buildPropertiesClause(options.properties, 'rel_');
|
|
510
|
-
propsClause = ` ${clause}`;
|
|
511
|
-
Object.assign(params, propParams);
|
|
512
|
-
}
|
|
384
|
+
async createRelationship(options, transaction) {
|
|
385
|
+
this.ensureConnected();
|
|
513
386
|
const query = `
|
|
514
|
-
MATCH
|
|
515
|
-
|
|
516
|
-
|
|
387
|
+
MATCH (a), (b)
|
|
388
|
+
WHERE id(a) = $startId AND id(b) = $endId
|
|
389
|
+
CREATE (a)-[r:${options.type} $props]->(b)
|
|
390
|
+
RETURN r, id(r) as relId, id(a) as startId, id(b) as endId
|
|
517
391
|
`;
|
|
518
|
-
const
|
|
392
|
+
const params = {
|
|
393
|
+
startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
|
|
394
|
+
endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
|
|
395
|
+
props: options.properties || {},
|
|
396
|
+
};
|
|
397
|
+
const session = this.getSession(transaction);
|
|
398
|
+
const result = await session.run(query, params);
|
|
399
|
+
const record = result.records[0];
|
|
400
|
+
const rel = record.get('r');
|
|
519
401
|
return {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
|
|
523
|
-
created: (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0,
|
|
524
|
-
statistics: result.statistics,
|
|
402
|
+
relationship: this.mapMemgraphRelationship(rel, record.get('relId'), record.get('startId'), record.get('endId')),
|
|
403
|
+
created: true,
|
|
525
404
|
};
|
|
526
405
|
}
|
|
527
|
-
async findRelationships(
|
|
528
|
-
|
|
406
|
+
async findRelationships(options, transaction) {
|
|
407
|
+
this.ensureConnected();
|
|
408
|
+
const types = options.type
|
|
409
|
+
? (Array.isArray(options.type) ? options.type.join('|') : options.type)
|
|
410
|
+
: (options.types ? options.types.join('|') : '');
|
|
411
|
+
const typeClause = types ? `:${types}` : '';
|
|
412
|
+
let query = `MATCH (a)-[r${typeClause}]->(b)`;
|
|
529
413
|
const params = {};
|
|
530
|
-
|
|
531
|
-
if (options.
|
|
532
|
-
|
|
533
|
-
|
|
414
|
+
const conditions = [];
|
|
415
|
+
if (options.startNodeId) {
|
|
416
|
+
conditions.push('id(a) = $startId');
|
|
417
|
+
params.startId = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10);
|
|
534
418
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
let query = `MATCH (from)${directionStart}[r${typePattern}]${directionEnd}(to)`;
|
|
539
|
-
const whereParts = [];
|
|
540
|
-
if (options.fromNode && options.fromNode.id) {
|
|
541
|
-
params.fromId = typeof options.fromNode.id === 'string'
|
|
542
|
-
? parseInt(options.fromNode.id, 10)
|
|
543
|
-
: options.fromNode.id;
|
|
544
|
-
whereParts.push('id(from) = $fromId');
|
|
545
|
-
}
|
|
546
|
-
if (options.toNode && options.toNode.id) {
|
|
547
|
-
params.toId = typeof options.toNode.id === 'string'
|
|
548
|
-
? parseInt(options.toNode.id, 10)
|
|
549
|
-
: options.toNode.id;
|
|
550
|
-
whereParts.push('id(to) = $toId');
|
|
551
|
-
}
|
|
552
|
-
if (options.properties) {
|
|
553
|
-
Object.entries(options.properties).forEach(([key, value], index) => {
|
|
554
|
-
const paramName = `rel_prop_${index}`;
|
|
555
|
-
whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
556
|
-
params[paramName] = value;
|
|
557
|
-
});
|
|
419
|
+
if (options.endNodeId) {
|
|
420
|
+
conditions.push('id(b) = $endId');
|
|
421
|
+
params.endId = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10);
|
|
558
422
|
}
|
|
559
|
-
if (
|
|
560
|
-
|
|
423
|
+
if (options.where) {
|
|
424
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
|
|
425
|
+
conditions.push(clause);
|
|
426
|
+
Object.assign(params, whereParams);
|
|
561
427
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const orderParts = options.orderBy.map(o => `r.${this.escapeIdentifier(o.property)} ${o.direction}`);
|
|
565
|
-
query += ` ORDER BY ${orderParts.join(', ')}`;
|
|
428
|
+
if (conditions.length > 0) {
|
|
429
|
+
query += ` WHERE ${conditions.join(' AND ')}`;
|
|
566
430
|
}
|
|
567
|
-
|
|
431
|
+
query += ' RETURN r, id(r) as relId, id(a) as startId, id(b) as endId';
|
|
432
|
+
if (options.skip) {
|
|
568
433
|
query += ` SKIP ${options.skip}`;
|
|
569
434
|
}
|
|
570
|
-
if (options.limit
|
|
435
|
+
if (options.limit) {
|
|
571
436
|
query += ` LIMIT ${options.limit}`;
|
|
572
437
|
}
|
|
573
|
-
const
|
|
574
|
-
const
|
|
438
|
+
const session = this.getSession(transaction);
|
|
439
|
+
const result = await session.run(query, params);
|
|
440
|
+
const relationships = result.records.map((record) => this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId')));
|
|
575
441
|
return {
|
|
576
|
-
success: true,
|
|
577
|
-
executionTime: Date.now() - startTime,
|
|
578
442
|
relationships,
|
|
579
443
|
count: relationships.length,
|
|
580
|
-
hasMore: options.limit !== undefined && relationships.length === options.limit,
|
|
581
444
|
};
|
|
582
445
|
}
|
|
583
|
-
async findRelationshipById(
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
|
|
446
|
+
async findRelationshipById(id, transaction) {
|
|
447
|
+
this.ensureConnected();
|
|
448
|
+
const query = `
|
|
449
|
+
MATCH (a)-[r]->(b)
|
|
450
|
+
WHERE id(r) = $id
|
|
451
|
+
RETURN r, id(r) as relId, id(a) as startId, id(b) as endId
|
|
452
|
+
`;
|
|
453
|
+
const session = this.getSession(transaction);
|
|
454
|
+
const result = await session.run(query, {
|
|
455
|
+
id: typeof id === 'number' ? id : parseInt(id, 10),
|
|
456
|
+
});
|
|
457
|
+
if (result.records.length === 0) {
|
|
587
458
|
return null;
|
|
588
459
|
}
|
|
589
|
-
|
|
460
|
+
const record = result.records[0];
|
|
461
|
+
return this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId'));
|
|
590
462
|
}
|
|
591
|
-
async updateRelationship(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
const params = {};
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
const setParts = [];
|
|
604
|
-
if (options.set) {
|
|
605
|
-
Object.entries(options.set).forEach(([key, value], index) => {
|
|
606
|
-
const paramName = `set_${index}`;
|
|
607
|
-
setParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
608
|
-
params[paramName] = value;
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
let query = matchClause;
|
|
612
|
-
if (setParts.length > 0) {
|
|
613
|
-
query += ` SET ${setParts.join(', ')}`;
|
|
463
|
+
async updateRelationship(options, transaction) {
|
|
464
|
+
this.ensureConnected();
|
|
465
|
+
let query;
|
|
466
|
+
const params = { props: options.properties };
|
|
467
|
+
if (options.id) {
|
|
468
|
+
query = `
|
|
469
|
+
MATCH (a)-[r]->(b)
|
|
470
|
+
WHERE id(r) = $id
|
|
471
|
+
SET r += $props
|
|
472
|
+
RETURN r, id(r) as relId, id(a) as startId, id(b) as endId
|
|
473
|
+
`;
|
|
474
|
+
params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
|
|
614
475
|
}
|
|
615
|
-
|
|
616
|
-
|
|
476
|
+
else {
|
|
477
|
+
const typeClause = options.type ? `:${options.type}` : '';
|
|
478
|
+
query = `MATCH (a)-[r${typeClause}]->(b)`;
|
|
479
|
+
if (options.where) {
|
|
480
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
|
|
481
|
+
query += ` WHERE ${clause}`;
|
|
482
|
+
Object.assign(params, whereParams);
|
|
483
|
+
}
|
|
484
|
+
query += ' SET r += $props RETURN r, id(r) as relId, id(a) as startId, id(b) as endId';
|
|
617
485
|
}
|
|
618
|
-
|
|
619
|
-
const result = await
|
|
486
|
+
const session = this.getSession(transaction);
|
|
487
|
+
const result = await session.run(query, params);
|
|
488
|
+
const relationships = result.records.map((record) => this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId')));
|
|
620
489
|
return {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
updated:
|
|
625
|
-
matchedCount: result.data.length,
|
|
626
|
-
modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
|
|
627
|
-
statistics: result.statistics,
|
|
490
|
+
relationship: relationships.length === 1 ? relationships[0] : undefined,
|
|
491
|
+
relationships: relationships.length > 1 ? relationships : undefined,
|
|
492
|
+
updatedCount: relationships.length,
|
|
493
|
+
updated: relationships.length > 0,
|
|
628
494
|
};
|
|
629
495
|
}
|
|
630
|
-
async deleteRelationship(
|
|
496
|
+
async deleteRelationship(options, transaction) {
|
|
631
497
|
var _a;
|
|
632
|
-
|
|
498
|
+
this.ensureConnected();
|
|
499
|
+
let query;
|
|
633
500
|
const params = {};
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
params.relId = typeof options.id === 'string' ? parseInt(options.id, 10) : options.id;
|
|
501
|
+
if (options.id) {
|
|
502
|
+
query = `MATCH ()-[r]->() WHERE id(r) = $id DELETE r RETURN count(r) as count`;
|
|
503
|
+
params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
|
|
638
504
|
}
|
|
639
|
-
else
|
|
640
|
-
const
|
|
641
|
-
|
|
505
|
+
else {
|
|
506
|
+
const typeClause = options.type ? `:${options.type}` : '';
|
|
507
|
+
query = `MATCH (a)-[r${typeClause}]->(b)`;
|
|
508
|
+
const conditions = [];
|
|
509
|
+
if (options.startNodeId) {
|
|
510
|
+
conditions.push('id(a) = $startId');
|
|
511
|
+
params.startId = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10);
|
|
512
|
+
}
|
|
513
|
+
if (options.endNodeId) {
|
|
514
|
+
conditions.push('id(b) = $endId');
|
|
515
|
+
params.endId = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10);
|
|
516
|
+
}
|
|
517
|
+
if (options.where) {
|
|
518
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
|
|
519
|
+
conditions.push(clause);
|
|
520
|
+
Object.assign(params, whereParams);
|
|
521
|
+
}
|
|
522
|
+
if (conditions.length > 0) {
|
|
523
|
+
query += ` WHERE ${conditions.join(' AND ')}`;
|
|
524
|
+
}
|
|
525
|
+
query += ' DELETE r RETURN count(r) as count';
|
|
642
526
|
}
|
|
643
|
-
const
|
|
644
|
-
const result = await
|
|
527
|
+
const session = this.getSession(transaction);
|
|
528
|
+
const result = await session.run(query, params);
|
|
529
|
+
const count = this.toNumber((_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0;
|
|
645
530
|
return {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsDeleted) || 0,
|
|
649
|
-
statistics: result.statistics,
|
|
531
|
+
deleted: count > 0,
|
|
532
|
+
deletedCount: count,
|
|
650
533
|
};
|
|
651
534
|
}
|
|
652
|
-
async mergeRelationship(
|
|
653
|
-
|
|
654
|
-
const startTime = Date.now();
|
|
655
|
-
const params = {};
|
|
656
|
-
const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
|
|
657
|
-
const toMatch = this.buildNodeReference(options.toNode, 'to', params);
|
|
535
|
+
async mergeRelationship(options, transaction) {
|
|
536
|
+
this.ensureConnected();
|
|
658
537
|
let matchPropsClause = '';
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
538
|
+
const params = {
|
|
539
|
+
startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
|
|
540
|
+
endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
|
|
541
|
+
};
|
|
542
|
+
if (options.matchProperties) {
|
|
543
|
+
const matchProps = Object.entries(options.matchProperties)
|
|
544
|
+
.map(([key]) => `${key}: $match_${key}`)
|
|
545
|
+
.join(', ');
|
|
546
|
+
matchPropsClause = ` {${matchProps}}`;
|
|
547
|
+
Object.entries(options.matchProperties).forEach(([key, value]) => {
|
|
548
|
+
params[`match_${key}`] = value;
|
|
549
|
+
});
|
|
663
550
|
}
|
|
664
551
|
let query = `
|
|
665
|
-
MATCH
|
|
666
|
-
|
|
552
|
+
MATCH (a), (b)
|
|
553
|
+
WHERE id(a) = $startId AND id(b) = $endId
|
|
554
|
+
MERGE (a)-[r:${options.type}${matchPropsClause}]->(b)
|
|
667
555
|
`;
|
|
668
|
-
if (options.onCreate
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
matchSetProps.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
682
|
-
params[paramName] = value;
|
|
683
|
-
});
|
|
684
|
-
query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
|
|
685
|
-
}
|
|
686
|
-
query += ' RETURN r';
|
|
687
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
688
|
-
const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0;
|
|
556
|
+
if (options.onCreate) {
|
|
557
|
+
query += ' ON CREATE SET r += $onCreateProps';
|
|
558
|
+
params.onCreateProps = options.onCreate;
|
|
559
|
+
}
|
|
560
|
+
if (options.onMatch) {
|
|
561
|
+
query += ' ON MATCH SET r += $onMatchProps';
|
|
562
|
+
params.onMatchProps = options.onMatch;
|
|
563
|
+
}
|
|
564
|
+
query += ' RETURN r, id(r) as relId, id(a) as startId, id(b) as endId';
|
|
565
|
+
const session = this.getSession(transaction);
|
|
566
|
+
const result = await session.run(query, params);
|
|
567
|
+
const record = result.records[0];
|
|
568
|
+
const relationship = this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId'));
|
|
689
569
|
return {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
created,
|
|
694
|
-
matched: !created,
|
|
695
|
-
statistics: result.statistics,
|
|
570
|
+
relationship,
|
|
571
|
+
created: true,
|
|
572
|
+
merged: true,
|
|
696
573
|
};
|
|
697
574
|
}
|
|
698
|
-
// ====================
|
|
699
|
-
async traverse(
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
const
|
|
575
|
+
// ==================== TRAVERSAL OPERATIONS ====================
|
|
576
|
+
async traverse(options, transaction) {
|
|
577
|
+
var _a;
|
|
578
|
+
this.ensureConnected();
|
|
579
|
+
const direction = this.getDirectionArrow(options.direction);
|
|
580
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
581
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
703
582
|
const minDepth = options.minDepth || 1;
|
|
704
|
-
const maxDepth = options.maxDepth ||
|
|
705
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
706
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
707
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
583
|
+
const maxDepth = options.maxDepth || 3;
|
|
708
584
|
const query = `
|
|
709
|
-
MATCH ${
|
|
710
|
-
|
|
711
|
-
${options.limit ? `WITH path LIMIT ${options.limit}` : ''}
|
|
585
|
+
MATCH path = (start)${direction.left}[${relClause}*${minDepth}..${maxDepth}]${direction.right}(end)
|
|
586
|
+
WHERE id(start) = $startId
|
|
712
587
|
RETURN path
|
|
588
|
+
${options.limit ? `LIMIT ${options.limit}` : ''}
|
|
713
589
|
`;
|
|
714
|
-
const
|
|
715
|
-
|
|
590
|
+
const params = {
|
|
591
|
+
startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
|
|
592
|
+
};
|
|
593
|
+
const session = this.getSession(transaction);
|
|
594
|
+
const result = await session.run(query, params);
|
|
595
|
+
const paths = result.records.map((record) => this.mapMemgraphPath(record.get('path')));
|
|
596
|
+
// Collect unique nodes and relationships
|
|
716
597
|
const nodesMap = new Map();
|
|
717
598
|
const relsMap = new Map();
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
paths.push(parsedPath);
|
|
722
|
-
parsedPath.nodes.forEach(n => nodesMap.set(String(n.id), n));
|
|
723
|
-
parsedPath.relationships.forEach(r => relsMap.set(String(r.id), r));
|
|
724
|
-
}
|
|
599
|
+
paths.forEach(path => {
|
|
600
|
+
path.nodes.forEach(node => nodesMap.set(String(node.id), node));
|
|
601
|
+
path.relationships.forEach(rel => relsMap.set(String(rel.id), rel));
|
|
725
602
|
});
|
|
726
603
|
return {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
paths: options.returnPaths ? paths : undefined,
|
|
730
|
-
nodes: options.returnNodes ? Array.from(nodesMap.values()) : undefined,
|
|
604
|
+
paths,
|
|
605
|
+
nodes: Array.from(nodesMap.values()),
|
|
731
606
|
relationships: Array.from(relsMap.values()),
|
|
732
607
|
count: paths.length,
|
|
733
608
|
};
|
|
734
609
|
}
|
|
735
|
-
async shortestPath(
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const
|
|
739
|
-
const
|
|
740
|
-
const maxDepth = options.maxDepth
|
|
741
|
-
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
757
|
-
else if (options.returnAllShortest) {
|
|
758
|
-
query = `
|
|
759
|
-
MATCH ${startNodeMatch}, ${endNodeMatch}
|
|
760
|
-
MATCH path = allShortestPaths((start)${dirStart}[${maxDepth}]${dirEnd}(end))
|
|
761
|
-
RETURN path
|
|
762
|
-
`;
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
query = `
|
|
766
|
-
MATCH ${startNodeMatch}, ${endNodeMatch}
|
|
767
|
-
MATCH path = shortestPath((start)${dirStart}[${maxDepth}]${dirEnd}(end))
|
|
768
|
-
RETURN path
|
|
769
|
-
`;
|
|
770
|
-
}
|
|
771
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
772
|
-
if (result.data.length === 0) {
|
|
773
|
-
return {
|
|
774
|
-
success: true,
|
|
775
|
-
executionTime: Date.now() - startTime,
|
|
776
|
-
found: false,
|
|
777
|
-
};
|
|
610
|
+
async shortestPath(options, transaction) {
|
|
611
|
+
var _a;
|
|
612
|
+
this.ensureConnected();
|
|
613
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
614
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
615
|
+
const maxDepth = options.maxDepth || 15;
|
|
616
|
+
// Use BFS for shortest path in Memgraph
|
|
617
|
+
const query = `
|
|
618
|
+
MATCH (start), (end)
|
|
619
|
+
WHERE id(start) = $startId AND id(end) = $endId
|
|
620
|
+
MATCH path = shortestPath((start)-[${relClause}*..${maxDepth}]-(end))
|
|
621
|
+
RETURN path
|
|
622
|
+
`;
|
|
623
|
+
const params = {
|
|
624
|
+
startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
|
|
625
|
+
endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
|
|
626
|
+
};
|
|
627
|
+
const session = this.getSession(transaction);
|
|
628
|
+
const result = await session.run(query, params);
|
|
629
|
+
if (result.records.length === 0) {
|
|
630
|
+
return { path: null, found: false };
|
|
778
631
|
}
|
|
779
|
-
const
|
|
780
|
-
const parsedPath = this.parsePath(row.path);
|
|
781
|
-
if (row.weight !== undefined) {
|
|
782
|
-
return Object.assign(Object.assign({}, parsedPath), { totalWeight: row.weight, weights: [] });
|
|
783
|
-
}
|
|
784
|
-
return parsedPath;
|
|
785
|
-
});
|
|
632
|
+
const path = this.mapMemgraphPath(result.records[0].get('path'));
|
|
786
633
|
return {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
path: options.returnAllShortest ? undefined : paths[0],
|
|
790
|
-
paths: options.returnAllShortest ? paths : undefined,
|
|
634
|
+
path,
|
|
635
|
+
length: path.length,
|
|
791
636
|
found: true,
|
|
792
|
-
|
|
793
|
-
|
|
637
|
+
totalWeight: options.weightProperty
|
|
638
|
+
? path.relationships.reduce((sum, r) => sum + (r.properties[options.weightProperty] || 0), 0)
|
|
639
|
+
: undefined,
|
|
794
640
|
};
|
|
795
641
|
}
|
|
796
|
-
async allPaths(
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
const
|
|
642
|
+
async allPaths(options, transaction) {
|
|
643
|
+
var _a;
|
|
644
|
+
this.ensureConnected();
|
|
645
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
646
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
801
647
|
const minDepth = options.minDepth || 1;
|
|
802
|
-
const maxDepth = options.maxDepth ||
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
MATCH ${
|
|
808
|
-
MATCH path = (start)${dirStart}[*${minDepth}..${maxDepth}]${dirEnd}(end)
|
|
648
|
+
const maxDepth = options.maxDepth || 5;
|
|
649
|
+
const limit = options.limit || options.maxPaths;
|
|
650
|
+
const query = `
|
|
651
|
+
MATCH (start), (end)
|
|
652
|
+
WHERE id(start) = $startId AND id(end) = $endId
|
|
653
|
+
MATCH path = (start)-[${relClause}*${minDepth}..${maxDepth}]-(end)
|
|
809
654
|
RETURN path
|
|
655
|
+
${limit ? `LIMIT ${limit}` : ''}
|
|
810
656
|
`;
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
const
|
|
657
|
+
const params = {
|
|
658
|
+
startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
|
|
659
|
+
endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
|
|
660
|
+
};
|
|
661
|
+
const session = this.getSession(transaction);
|
|
662
|
+
const result = await session.run(query, params);
|
|
663
|
+
const paths = result.records.map((record) => this.mapMemgraphPath(record.get('path')));
|
|
816
664
|
return {
|
|
817
|
-
success: true,
|
|
818
|
-
executionTime: Date.now() - startTime,
|
|
819
665
|
paths,
|
|
820
666
|
count: paths.length,
|
|
667
|
+
total: paths.length,
|
|
821
668
|
};
|
|
822
669
|
}
|
|
823
|
-
async
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
const labels = node.labels
|
|
830
|
-
? ':' + (Array.isArray(node.labels) ? node.labels : [node.labels])
|
|
831
|
-
.map(l => this.escapeIdentifier(l)).join(':')
|
|
832
|
-
: '';
|
|
833
|
-
let props = '';
|
|
834
|
-
if (node.properties && Object.keys(node.properties).length > 0) {
|
|
835
|
-
const { clause, params: nodeParams } = this.buildPropertiesClause(node.properties, `${node.variable}_`);
|
|
836
|
-
props = ` ${clause}`;
|
|
837
|
-
Object.assign(params, nodeParams);
|
|
838
|
-
}
|
|
839
|
-
nodePatterns.push(`(${node.variable}${labels}${props})`);
|
|
840
|
-
});
|
|
841
|
-
const matchClauses = [];
|
|
842
|
-
if (pattern.relationships.length === 0) {
|
|
843
|
-
matchClauses.push(`MATCH ${nodePatterns.join(', ')}`);
|
|
844
|
-
}
|
|
845
|
-
else {
|
|
846
|
-
pattern.relationships.forEach(rel => {
|
|
847
|
-
const relVar = rel.variable || '';
|
|
848
|
-
const types = rel.type
|
|
849
|
-
? ':' + (Array.isArray(rel.type) ? rel.type : [rel.type])
|
|
850
|
-
.map(t => this.escapeIdentifier(t)).join('|')
|
|
851
|
-
: '';
|
|
852
|
-
const dirStart = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
853
|
-
const dirEnd = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
854
|
-
rel.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
855
|
-
let hops = '';
|
|
856
|
-
if (rel.minHops !== undefined || rel.maxHops !== undefined) {
|
|
857
|
-
const min = rel.minHops || '';
|
|
858
|
-
const max = rel.maxHops || '';
|
|
859
|
-
hops = `*${min}..${max}`;
|
|
860
|
-
}
|
|
861
|
-
matchClauses.push(`MATCH (${rel.startNode})${dirStart}[${relVar}${types}${hops}]${dirEnd}(${rel.endNode})`);
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
let query = matchClauses.join(' ');
|
|
865
|
-
if (pattern.where) {
|
|
866
|
-
const conditions = pattern.where.conditions
|
|
867
|
-
.map(c => c.expression)
|
|
868
|
-
.join(pattern.where.operator === 'OR' ? ' OR ' : ' AND ');
|
|
869
|
-
query += ` WHERE ${conditions}`;
|
|
870
|
-
}
|
|
871
|
-
const returnVars = options.return || pattern.nodes.map(n => n.variable);
|
|
872
|
-
query += ` RETURN ${returnVars.join(', ')}`;
|
|
873
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
874
|
-
const orderParts = options.orderBy.map(o => `${o.expression} ${o.direction}`);
|
|
875
|
-
query += ` ORDER BY ${orderParts.join(', ')}`;
|
|
876
|
-
}
|
|
877
|
-
if (options.skip !== undefined) {
|
|
878
|
-
query += ` SKIP ${options.skip}`;
|
|
879
|
-
}
|
|
880
|
-
if (options.limit !== undefined) {
|
|
881
|
-
query += ` LIMIT ${options.limit}`;
|
|
882
|
-
}
|
|
883
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
884
|
-
return {
|
|
885
|
-
success: true,
|
|
886
|
-
executionTime: Date.now() - startTime,
|
|
887
|
-
matches: result.data,
|
|
888
|
-
count: result.data.length,
|
|
889
|
-
hasMore: options.limit !== undefined && result.data.length === options.limit,
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
async extractSubgraph(connection, options, transaction) {
|
|
893
|
-
const startTime = Date.now();
|
|
894
|
-
const params = {};
|
|
895
|
-
const startNodes = Array.isArray(options.startNodes) ? options.startNodes : [options.startNodes];
|
|
896
|
-
const startMatches = startNodes.map((node, idx) => this.buildNodeSelectorMatch(node, `start${idx}`, params, `start${idx}_`));
|
|
897
|
-
const maxDepth = options.maxDepth || 3;
|
|
898
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
899
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
900
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
901
|
-
const query = `
|
|
902
|
-
MATCH ${startMatches.join(', ')}
|
|
903
|
-
WITH [${startNodes.map((_, i) => `start${i}`).join(', ')}] AS starts
|
|
904
|
-
UNWIND starts AS start
|
|
905
|
-
MATCH path = (start)${dirStart}[*0..${maxDepth}]${dirEnd}(n)
|
|
906
|
-
WITH COLLECT(DISTINCT n) AS nodes, COLLECT(relationships(path)) AS rels
|
|
907
|
-
UNWIND rels AS relList
|
|
908
|
-
UNWIND relList AS r
|
|
909
|
-
RETURN nodes, COLLECT(DISTINCT r) AS relationships
|
|
910
|
-
`;
|
|
911
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
912
|
-
const nodes = [];
|
|
913
|
-
const relationships = [];
|
|
914
|
-
if (result.data.length > 0) {
|
|
915
|
-
const row = result.data[0];
|
|
916
|
-
if (row.nodes) {
|
|
917
|
-
row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
|
|
918
|
-
}
|
|
919
|
-
if (row.relationships) {
|
|
920
|
-
row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return {
|
|
924
|
-
success: true,
|
|
925
|
-
executionTime: Date.now() - startTime,
|
|
926
|
-
subgraph: {
|
|
927
|
-
nodes,
|
|
928
|
-
relationships,
|
|
929
|
-
nodeCount: nodes.length,
|
|
930
|
-
relationshipCount: relationships.length,
|
|
931
|
-
},
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
async getNeighborhood(connection, options, transaction) {
|
|
935
|
-
const startTime = Date.now();
|
|
936
|
-
const params = {};
|
|
937
|
-
const centerMatch = this.buildNodeSelectorMatch(options.node, 'center', params);
|
|
670
|
+
async getNeighborhood(options, transaction) {
|
|
671
|
+
var _a;
|
|
672
|
+
this.ensureConnected();
|
|
673
|
+
const direction = this.getDirectionArrow(options.direction);
|
|
674
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
675
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
938
676
|
const depth = options.depth || 1;
|
|
939
|
-
|
|
940
|
-
if (options.relationshipTypes && options.relationshipTypes.length > 0) {
|
|
941
|
-
relTypes = ':' + options.relationshipTypes.map(t => this.escapeIdentifier(t)).join('|');
|
|
942
|
-
}
|
|
943
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
944
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
945
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
677
|
+
const limit = options.limit;
|
|
946
678
|
const query = `
|
|
947
|
-
MATCH
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
RETURN nodes, COLLECT(DISTINCT r) AS relationships
|
|
679
|
+
MATCH (start)
|
|
680
|
+
WHERE id(start) = $nodeId
|
|
681
|
+
MATCH path = (start)${direction.left}[r${relClause}*1..${depth}]${direction.right}(neighbor)
|
|
682
|
+
RETURN DISTINCT neighbor, id(neighbor) as neighborId, r
|
|
683
|
+
${limit ? `LIMIT ${limit}` : ''}
|
|
953
684
|
`;
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
685
|
+
const params = {
|
|
686
|
+
nodeId: typeof options.nodeId === 'number' ? options.nodeId : parseInt(options.nodeId, 10),
|
|
687
|
+
};
|
|
688
|
+
const session = this.getSession(transaction);
|
|
689
|
+
const result = await session.run(query, params);
|
|
690
|
+
const nodesMap = new Map();
|
|
691
|
+
const relationshipsSet = [];
|
|
692
|
+
result.records.forEach((record) => {
|
|
693
|
+
const neighbor = record.get('neighbor');
|
|
694
|
+
const neighborId = record.get('neighborId');
|
|
695
|
+
const nodeKey = String(this.toNumber(neighborId));
|
|
696
|
+
if (!nodesMap.has(nodeKey)) {
|
|
697
|
+
nodesMap.set(nodeKey, this.mapMemgraphNode(neighbor, neighborId));
|
|
961
698
|
}
|
|
962
|
-
|
|
963
|
-
|
|
699
|
+
const rels = record.get('r');
|
|
700
|
+
if (Array.isArray(rels)) {
|
|
701
|
+
rels.forEach((rel) => {
|
|
702
|
+
relationshipsSet.push(this.mapMemgraphRelationship(rel, rel.identity, rel.start, rel.end));
|
|
703
|
+
});
|
|
964
704
|
}
|
|
965
|
-
}
|
|
705
|
+
});
|
|
966
706
|
return {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
relationships,
|
|
971
|
-
levels: new Map(),
|
|
707
|
+
nodes: Array.from(nodesMap.values()),
|
|
708
|
+
relationships: relationshipsSet,
|
|
709
|
+
depth,
|
|
972
710
|
};
|
|
973
711
|
}
|
|
974
|
-
async findConnectedComponents(
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
`;
|
|
712
|
+
async findConnectedComponents(options, transaction) {
|
|
713
|
+
var _a;
|
|
714
|
+
this.ensureConnected();
|
|
715
|
+
// Memgraph has MAGE library for graph algorithms
|
|
716
|
+
// Use weakly connected components algorithm
|
|
717
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
718
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
982
719
|
try {
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
720
|
+
// Try using MAGE library first (if installed)
|
|
721
|
+
const query = `
|
|
722
|
+
CALL weakly_connected_components.get()
|
|
723
|
+
YIELD node, component_id
|
|
724
|
+
WITH component_id, collect(node) as nodes
|
|
725
|
+
RETURN nodes, size(nodes) as size, component_id
|
|
726
|
+
ORDER BY size DESC
|
|
727
|
+
`;
|
|
728
|
+
const session = this.getSession(transaction);
|
|
729
|
+
const result = await session.run(query, {});
|
|
730
|
+
const components = result.records.map((record) => ({
|
|
731
|
+
nodes: record.get('nodes').map((n) => this.mapMemgraphNode(n, n.identity)),
|
|
732
|
+
size: this.toNumber(record.get('size')),
|
|
988
733
|
}));
|
|
989
|
-
if (options.minSize) {
|
|
990
|
-
return {
|
|
991
|
-
success: true,
|
|
992
|
-
executionTime: Date.now() - startTime,
|
|
993
|
-
components: components.filter(c => c.size >= options.minSize),
|
|
994
|
-
count: components.filter(c => c.size >= options.minSize).length,
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
734
|
return {
|
|
998
|
-
success: true,
|
|
999
|
-
executionTime: Date.now() - startTime,
|
|
1000
735
|
components,
|
|
1001
736
|
count: components.length,
|
|
1002
737
|
};
|
|
1003
738
|
}
|
|
1004
|
-
catch (
|
|
1005
|
-
|
|
739
|
+
catch (_b) {
|
|
740
|
+
// Fallback to basic Cypher implementation
|
|
741
|
+
const query = `
|
|
742
|
+
MATCH (n${labelClause})
|
|
743
|
+
WITH collect(n) as allNodes
|
|
744
|
+
UNWIND allNodes as node
|
|
745
|
+
MATCH path = (node)-[*]-(connected)
|
|
746
|
+
WITH node, collect(DISTINCT connected) + [node] as component
|
|
747
|
+
WITH collect(DISTINCT component) as allComponents
|
|
748
|
+
UNWIND allComponents as comp
|
|
749
|
+
WITH comp, size(comp) as compSize
|
|
750
|
+
RETURN comp as nodes, compSize as size
|
|
751
|
+
ORDER BY size DESC
|
|
752
|
+
`;
|
|
753
|
+
const session = this.getSession(transaction);
|
|
754
|
+
const result = await session.run(query, {});
|
|
755
|
+
const components = result.records.map((record) => ({
|
|
756
|
+
nodes: record.get('nodes').map((n) => this.mapMemgraphNode(n, n.identity)),
|
|
757
|
+
size: this.toNumber(record.get('size')),
|
|
758
|
+
}));
|
|
759
|
+
return {
|
|
760
|
+
components,
|
|
761
|
+
count: components.length,
|
|
762
|
+
};
|
|
1006
763
|
}
|
|
1007
764
|
}
|
|
1008
765
|
// ==================== AGGREGATION OPERATIONS ====================
|
|
1009
|
-
async countNodes(
|
|
766
|
+
async countNodes(labels, where, transaction) {
|
|
1010
767
|
var _a;
|
|
1011
|
-
|
|
768
|
+
this.ensureConnected();
|
|
769
|
+
const labelClause = (labels === null || labels === void 0 ? void 0 : labels.length) ? `:${labels.join(':')}` : '';
|
|
770
|
+
let query = `MATCH (n${labelClause})`;
|
|
1012
771
|
const params = {};
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
let query = `MATCH (n${labelStr})`;
|
|
1019
|
-
if (where && Object.keys(where).length > 0) {
|
|
1020
|
-
const whereParts = [];
|
|
1021
|
-
Object.entries(where).forEach(([key, value], index) => {
|
|
1022
|
-
const paramName = `where_${index}`;
|
|
1023
|
-
whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1024
|
-
params[paramName] = value;
|
|
1025
|
-
});
|
|
1026
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
772
|
+
if (where) {
|
|
773
|
+
const { clause, params: whereParams } = this.buildWhereClause(where, 'n');
|
|
774
|
+
query += ` WHERE ${clause}`;
|
|
775
|
+
Object.assign(params, whereParams);
|
|
1027
776
|
}
|
|
1028
|
-
query += ' RETURN count(n)
|
|
1029
|
-
const
|
|
777
|
+
query += ' RETURN count(n) as count';
|
|
778
|
+
const session = this.getSession(transaction);
|
|
779
|
+
const result = await session.run(query, params);
|
|
1030
780
|
return {
|
|
1031
|
-
|
|
1032
|
-
executionTime: Date.now() - startTime,
|
|
1033
|
-
count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
|
|
781
|
+
count: this.toNumber((_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0,
|
|
1034
782
|
};
|
|
1035
783
|
}
|
|
1036
|
-
async countRelationships(
|
|
784
|
+
async countRelationships(types, where, transaction) {
|
|
1037
785
|
var _a;
|
|
1038
|
-
|
|
786
|
+
this.ensureConnected();
|
|
787
|
+
const typeClause = (types === null || types === void 0 ? void 0 : types.length) ? `:${types.join('|')}` : '';
|
|
788
|
+
let query = `MATCH ()-[r${typeClause}]->()`;
|
|
1039
789
|
const params = {};
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
}
|
|
1045
|
-
let query = `MATCH ()-[r${typeStr}]->()`;
|
|
1046
|
-
if (where && Object.keys(where).length > 0) {
|
|
1047
|
-
const whereParts = [];
|
|
1048
|
-
Object.entries(where).forEach(([key, value], index) => {
|
|
1049
|
-
const paramName = `where_${index}`;
|
|
1050
|
-
whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1051
|
-
params[paramName] = value;
|
|
1052
|
-
});
|
|
1053
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
790
|
+
if (where) {
|
|
791
|
+
const { clause, params: whereParams } = this.buildWhereClause(where, 'r');
|
|
792
|
+
query += ` WHERE ${clause}`;
|
|
793
|
+
Object.assign(params, whereParams);
|
|
1054
794
|
}
|
|
1055
|
-
query += ' RETURN count(r)
|
|
1056
|
-
const
|
|
795
|
+
query += ' RETURN count(r) as count';
|
|
796
|
+
const session = this.getSession(transaction);
|
|
797
|
+
const result = await session.run(query, params);
|
|
1057
798
|
return {
|
|
1058
|
-
|
|
1059
|
-
executionTime: Date.now() - startTime,
|
|
1060
|
-
count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
|
|
799
|
+
count: this.toNumber((_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0,
|
|
1061
800
|
};
|
|
1062
801
|
}
|
|
1063
|
-
async getStatistics(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
RETURN nodeCount, count(r) AS relCount
|
|
1070
|
-
`;
|
|
1071
|
-
const result = await this.executeRaw(connection, { query }, transaction);
|
|
1072
|
-
const row = result.data[0] || {};
|
|
802
|
+
async getStatistics(transaction) {
|
|
803
|
+
var _a, _b;
|
|
804
|
+
this.ensureConnected();
|
|
805
|
+
const session = this.getSession(transaction);
|
|
806
|
+
const nodeCountResult = await session.run('MATCH (n) RETURN count(n) as count');
|
|
807
|
+
const relCountResult = await session.run('MATCH ()-[r]->() RETURN count(r) as count');
|
|
1073
808
|
return {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
nodeCount: this.toNumber(row.nodeCount || 0),
|
|
1077
|
-
relationshipCount: this.toNumber(row.relCount || 0),
|
|
1078
|
-
labelCounts: {},
|
|
1079
|
-
relationshipTypeCounts: {},
|
|
809
|
+
nodeCount: this.toNumber((_a = nodeCountResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0,
|
|
810
|
+
relationshipCount: this.toNumber((_b = relCountResult.records[0]) === null || _b === void 0 ? void 0 : _b.get('count')) || 0,
|
|
1080
811
|
};
|
|
1081
812
|
}
|
|
1082
813
|
// ==================== SEARCH OPERATIONS ====================
|
|
1083
|
-
async fullTextSearch(
|
|
1084
|
-
|
|
1085
|
-
// Memgraph
|
|
814
|
+
async fullTextSearch(options, transaction) {
|
|
815
|
+
this.ensureConnected();
|
|
816
|
+
// Memgraph supports text search through MAGE text_search module
|
|
817
|
+
// Use the index name to search
|
|
1086
818
|
const query = `
|
|
1087
|
-
CALL
|
|
819
|
+
CALL text_search.search($indexName, $searchQuery, $limit)
|
|
1088
820
|
YIELD node, score
|
|
1089
|
-
|
|
1090
|
-
RETURN node${options.score ? ', score' : ''}
|
|
1091
|
-
${options.limit ? `LIMIT ${options.limit}` : ''}
|
|
821
|
+
RETURN node, id(node) as nodeId, score
|
|
1092
822
|
`;
|
|
1093
|
-
const
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
return node;
|
|
823
|
+
const session = this.getSession(transaction);
|
|
824
|
+
const result = await session.run(query, {
|
|
825
|
+
indexName: options.indexName,
|
|
826
|
+
searchQuery: options.query,
|
|
827
|
+
limit: options.limit || 100,
|
|
1100
828
|
});
|
|
829
|
+
const nodes = result.records.map((r) => this.mapMemgraphNode(r.get('node'), r.get('nodeId')));
|
|
830
|
+
const scores = result.records.map((r) => r.get('score') || 1.0);
|
|
1101
831
|
return {
|
|
1102
|
-
success: true,
|
|
1103
|
-
executionTime: Date.now() - startTime,
|
|
1104
832
|
nodes,
|
|
1105
|
-
|
|
833
|
+
scores,
|
|
1106
834
|
};
|
|
1107
835
|
}
|
|
1108
|
-
async vectorSearch(
|
|
1109
|
-
// Memgraph doesn't
|
|
1110
|
-
|
|
836
|
+
async vectorSearch(_options, _transaction) {
|
|
837
|
+
// Memgraph doesn't natively support vector search yet
|
|
838
|
+
// This would require a custom implementation or external service
|
|
839
|
+
throw graph_error_1.GraphError.unsupportedOperationError('Vector search is not natively supported in Memgraph. Consider using an external vector database.', this.graphType);
|
|
840
|
+
}
|
|
841
|
+
// ==================== RAW QUERY ====================
|
|
842
|
+
async query(options, transaction) {
|
|
843
|
+
var _a, _b;
|
|
844
|
+
this.ensureConnected();
|
|
845
|
+
const session = this.getSession(transaction);
|
|
846
|
+
const result = await session.run(options.query, options.params || {});
|
|
847
|
+
return {
|
|
848
|
+
records: result.records.map((r) => r.toObject()),
|
|
849
|
+
summary: {
|
|
850
|
+
resultAvailableAfter: this.toNumber((_a = result.summary) === null || _a === void 0 ? void 0 : _a.resultAvailableAfter),
|
|
851
|
+
resultConsumedAfter: this.toNumber((_b = result.summary) === null || _b === void 0 ? void 0 : _b.resultConsumedAfter),
|
|
852
|
+
},
|
|
853
|
+
};
|
|
1111
854
|
}
|
|
1112
855
|
// ==================== SCHEMA OPERATIONS ====================
|
|
1113
|
-
async
|
|
1114
|
-
|
|
856
|
+
async createNodeIndex(options) {
|
|
857
|
+
this.ensureConnected();
|
|
858
|
+
// Memgraph uses CREATE INDEX ON :Label(property)
|
|
859
|
+
const query = `CREATE INDEX ON :${options.label}(${options.properties.join(', ')})`;
|
|
860
|
+
const session = this.getSession();
|
|
861
|
+
await session.run(query);
|
|
862
|
+
return { created: true, name: options.name };
|
|
863
|
+
}
|
|
864
|
+
async createNodeConstraint(options) {
|
|
865
|
+
this.ensureConnected();
|
|
1115
866
|
let query;
|
|
1116
|
-
const
|
|
1117
|
-
switch (
|
|
1118
|
-
case
|
|
1119
|
-
|
|
867
|
+
const property = options.property || (options.properties && options.properties[0]);
|
|
868
|
+
switch (options.type) {
|
|
869
|
+
case 'UNIQUE':
|
|
870
|
+
// Memgraph uses CREATE CONSTRAINT ON (n:Label) ASSERT n.property IS UNIQUE
|
|
871
|
+
query = `CREATE CONSTRAINT ON (n:${options.label}) ASSERT n.${property} IS UNIQUE`;
|
|
1120
872
|
break;
|
|
1121
|
-
case
|
|
1122
|
-
query = `CREATE CONSTRAINT ON (n:${
|
|
873
|
+
case 'EXISTS':
|
|
874
|
+
query = `CREATE CONSTRAINT ON (n:${options.label}) ASSERT EXISTS (n.${property})`;
|
|
1123
875
|
break;
|
|
1124
876
|
default:
|
|
1125
|
-
throw
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
877
|
+
throw graph_error_1.GraphError.validationError(`Unsupported constraint type: ${options.type}`);
|
|
878
|
+
}
|
|
879
|
+
const session = this.getSession();
|
|
880
|
+
await session.run(query);
|
|
881
|
+
return { created: true, name: options.name };
|
|
882
|
+
}
|
|
883
|
+
async createRelationshipIndex(options) {
|
|
884
|
+
this.ensureConnected();
|
|
885
|
+
// Memgraph relationship indexes
|
|
886
|
+
const query = `CREATE INDEX ON :${options.type}(${options.properties.join(', ')})`;
|
|
887
|
+
const session = this.getSession();
|
|
888
|
+
await session.run(query);
|
|
889
|
+
return { created: true, name: options.name };
|
|
890
|
+
}
|
|
891
|
+
async listIndexes() {
|
|
892
|
+
this.ensureConnected();
|
|
893
|
+
const query = 'SHOW INDEX INFO';
|
|
894
|
+
const session = this.getSession();
|
|
895
|
+
const result = await session.run(query);
|
|
896
|
+
const indexes = result.records.map((r) => ({
|
|
897
|
+
name: r.get('index name') || '',
|
|
898
|
+
labelOrType: r.get('label') || '',
|
|
899
|
+
properties: [r.get('property') || ''],
|
|
900
|
+
unique: false, // Memgraph doesn't distinguish in SHOW INDEX INFO
|
|
901
|
+
type: r.get('index type') || 'BTREE',
|
|
902
|
+
state: 'ONLINE',
|
|
903
|
+
}));
|
|
904
|
+
return { indexes };
|
|
1134
905
|
}
|
|
1135
|
-
async
|
|
1136
|
-
|
|
906
|
+
async listConstraints() {
|
|
907
|
+
this.ensureConnected();
|
|
908
|
+
const query = 'SHOW CONSTRAINT INFO';
|
|
909
|
+
const session = this.getSession();
|
|
910
|
+
const result = await session.run(query);
|
|
911
|
+
const constraints = result.records.map((r) => ({
|
|
912
|
+
name: `constraint_${r.get('label')}_${r.get('property')}`,
|
|
913
|
+
label: r.get('label') || '',
|
|
914
|
+
property: r.get('property') || '',
|
|
915
|
+
type: r.get('constraint type') || 'UNIQUE',
|
|
916
|
+
}));
|
|
917
|
+
return { constraints };
|
|
1137
918
|
}
|
|
1138
|
-
async
|
|
1139
|
-
|
|
1140
|
-
// Memgraph
|
|
1141
|
-
|
|
919
|
+
async dropIndex(name) {
|
|
920
|
+
this.ensureConnected();
|
|
921
|
+
// In Memgraph, we need label and property to drop index
|
|
922
|
+
// This is a simplified version
|
|
923
|
+
const query = `DROP INDEX ON :${name}`;
|
|
924
|
+
const session = this.getSession();
|
|
1142
925
|
try {
|
|
1143
|
-
await
|
|
926
|
+
await session.run(query);
|
|
927
|
+
return { dropped: true };
|
|
1144
928
|
}
|
|
1145
929
|
catch (_a) {
|
|
1146
|
-
|
|
1147
|
-
const existsQuery = `DROP CONSTRAINT ON (n) ASSERT EXISTS (n.${name})`;
|
|
1148
|
-
await this.executeRaw(connection, { query: existsQuery }, transaction);
|
|
930
|
+
return { dropped: false };
|
|
1149
931
|
}
|
|
1150
|
-
return {
|
|
1151
|
-
success: true,
|
|
1152
|
-
executionTime: Date.now() - startTime,
|
|
1153
|
-
name,
|
|
1154
|
-
dropped: true,
|
|
1155
|
-
};
|
|
1156
932
|
}
|
|
1157
|
-
async
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
933
|
+
async dropConstraint(name) {
|
|
934
|
+
this.ensureConnected();
|
|
935
|
+
// Memgraph requires the full constraint definition to drop
|
|
936
|
+
// This is a simplified version that might need adjustment
|
|
937
|
+
const query = `DROP CONSTRAINT ON (n:${name}) ASSERT n.id IS UNIQUE`;
|
|
938
|
+
const session = this.getSession();
|
|
939
|
+
try {
|
|
940
|
+
await session.run(query);
|
|
941
|
+
return { dropped: true };
|
|
942
|
+
}
|
|
943
|
+
catch (_a) {
|
|
944
|
+
return { dropped: false };
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
// ==================== SCHEMA INTROSPECTION ====================
|
|
948
|
+
async listLabels() {
|
|
949
|
+
var _a, _b, _c, _d;
|
|
950
|
+
this.ensureConnected();
|
|
951
|
+
const session = this.getSession();
|
|
952
|
+
// Get all labels using Memgraph's CALL mg.labels()
|
|
953
|
+
const labelsResult = await session.run('CALL mg.labels() YIELD label RETURN label');
|
|
954
|
+
const labelNames = labelsResult.records.map((r) => r.get('label'));
|
|
955
|
+
const labels = [];
|
|
956
|
+
for (const labelName of labelNames) {
|
|
957
|
+
// Get count for each label
|
|
958
|
+
const countResult = await session.run(`MATCH (n:\`${labelName}\`) RETURN count(n) as count`);
|
|
959
|
+
const count = ((_c = (_b = (_a = countResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber) === null || _c === void 0 ? void 0 : _c.call(_b)) ||
|
|
960
|
+
((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
|
|
961
|
+
// Get properties for a sample of nodes with this label
|
|
962
|
+
const propsResult = await session.run(`MATCH (n:\`${labelName}\`) WITH n LIMIT 100
|
|
963
|
+
UNWIND keys(n) as key
|
|
964
|
+
RETURN DISTINCT key`);
|
|
965
|
+
const properties = propsResult.records.map((r) => ({
|
|
966
|
+
name: r.get('key'),
|
|
967
|
+
type: 'unknown',
|
|
968
|
+
}));
|
|
969
|
+
labels.push({
|
|
970
|
+
name: labelName,
|
|
971
|
+
count: typeof count === 'number' ? count : Number(count),
|
|
972
|
+
properties,
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
return { labels };
|
|
976
|
+
}
|
|
977
|
+
async listRelationshipTypes() {
|
|
978
|
+
var _a, _b, _c, _d;
|
|
979
|
+
this.ensureConnected();
|
|
980
|
+
const session = this.getSession();
|
|
981
|
+
// Get all relationship types using Memgraph's CALL mg.relationship_types()
|
|
982
|
+
const typesResult = await session.run('CALL mg.relationship_types() YIELD relationshipType RETURN relationshipType');
|
|
983
|
+
const typeNames = typesResult.records.map((r) => r.get('relationshipType'));
|
|
984
|
+
const types = [];
|
|
985
|
+
for (const typeName of typeNames) {
|
|
986
|
+
// Get count for each type
|
|
987
|
+
const countResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() RETURN count(r) as count`);
|
|
988
|
+
const count = ((_c = (_b = (_a = countResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber) === null || _c === void 0 ? void 0 : _c.call(_b)) ||
|
|
989
|
+
((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
|
|
990
|
+
// Get source and target label information
|
|
991
|
+
const endpointsResult = await session.run(`MATCH (a)-[r:\`${typeName}\`]->(b)
|
|
992
|
+
WITH labels(a) as fromLabels, labels(b) as toLabels
|
|
993
|
+
RETURN DISTINCT fromLabels[0] as fromLabel, toLabels[0] as toLabel
|
|
994
|
+
LIMIT 10`);
|
|
995
|
+
const fromLabelsArray = endpointsResult.records
|
|
996
|
+
.map((r) => r.get('fromLabel'))
|
|
997
|
+
.filter((l) => Boolean(l));
|
|
998
|
+
const fromLabels = [...new Set(fromLabelsArray)];
|
|
999
|
+
const toLabelsArray = endpointsResult.records
|
|
1000
|
+
.map((r) => r.get('toLabel'))
|
|
1001
|
+
.filter((l) => Boolean(l));
|
|
1002
|
+
const toLabels = [...new Set(toLabelsArray)];
|
|
1003
|
+
// Get properties for relationships of this type
|
|
1004
|
+
const propsResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() WITH r LIMIT 100
|
|
1005
|
+
UNWIND keys(r) as key
|
|
1006
|
+
RETURN DISTINCT key`);
|
|
1007
|
+
const properties = propsResult.records.map((r) => ({
|
|
1008
|
+
name: r.get('key'),
|
|
1009
|
+
type: 'unknown',
|
|
1010
|
+
}));
|
|
1011
|
+
types.push({
|
|
1012
|
+
type: typeName,
|
|
1013
|
+
count: typeof count === 'number' ? count : Number(count),
|
|
1014
|
+
fromLabels,
|
|
1015
|
+
toLabels,
|
|
1016
|
+
properties: properties.length > 0 ? properties : undefined,
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
return { types };
|
|
1173
1020
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1021
|
+
// ==================== TRANSACTION OPERATIONS ====================
|
|
1022
|
+
async beginTransaction(_options) {
|
|
1023
|
+
this.ensureConnected();
|
|
1024
|
+
const session = this.driver.session();
|
|
1025
|
+
const tx = session.beginTransaction();
|
|
1179
1026
|
return {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1027
|
+
id: `tx_${Date.now()}`,
|
|
1028
|
+
status: enums_1.GraphTransactionStatus.ACTIVE,
|
|
1029
|
+
client: tx,
|
|
1030
|
+
nativeTransaction: tx,
|
|
1031
|
+
startTime: new Date(),
|
|
1032
|
+
commit: async () => {
|
|
1033
|
+
await tx.commit();
|
|
1034
|
+
await session.close();
|
|
1035
|
+
},
|
|
1036
|
+
rollback: async () => {
|
|
1037
|
+
await tx.rollback();
|
|
1038
|
+
await session.close();
|
|
1039
|
+
},
|
|
1184
1040
|
};
|
|
1185
1041
|
}
|
|
1186
|
-
async
|
|
1187
|
-
|
|
1042
|
+
async commitTransaction(transaction) {
|
|
1043
|
+
if (transaction.commit) {
|
|
1044
|
+
await transaction.commit();
|
|
1045
|
+
}
|
|
1188
1046
|
}
|
|
1189
|
-
async
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
await this.executeRaw(connection, { query }, transaction);
|
|
1194
|
-
return {
|
|
1195
|
-
success: true,
|
|
1196
|
-
executionTime: Date.now() - startTime,
|
|
1197
|
-
name,
|
|
1198
|
-
dropped: true,
|
|
1199
|
-
};
|
|
1047
|
+
async rollbackTransaction(transaction) {
|
|
1048
|
+
if (transaction.rollback) {
|
|
1049
|
+
await transaction.rollback();
|
|
1050
|
+
}
|
|
1200
1051
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1052
|
+
// ==================== MEMGRAPH-SPECIFIC FEATURES ====================
|
|
1053
|
+
/**
|
|
1054
|
+
* Create a trigger in Memgraph
|
|
1055
|
+
*/
|
|
1056
|
+
async createTrigger(name, event, target, procedure) {
|
|
1057
|
+
this.ensureConnected();
|
|
1058
|
+
const eventClause = `${event === 'CREATE' ? 'CREATED' : event === 'UPDATE' ? 'UPDATED' : 'DELETED'}`;
|
|
1059
|
+
const targetClause = target === 'NODE' ? 'VERTEX' : 'EDGE';
|
|
1060
|
+
const query = `
|
|
1061
|
+
CREATE TRIGGER ${name}
|
|
1062
|
+
ON ${eventClause} ${targetClause}
|
|
1063
|
+
EXECUTE ${procedure}
|
|
1064
|
+
`;
|
|
1065
|
+
const session = this.getSession();
|
|
1066
|
+
await session.run(query);
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Drop a trigger in Memgraph
|
|
1070
|
+
*/
|
|
1071
|
+
async dropTrigger(name) {
|
|
1072
|
+
this.ensureConnected();
|
|
1073
|
+
const query = `DROP TRIGGER ${name}`;
|
|
1074
|
+
const session = this.getSession();
|
|
1075
|
+
await session.run(query);
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* List all triggers in Memgraph
|
|
1079
|
+
*/
|
|
1080
|
+
async listTriggers() {
|
|
1081
|
+
this.ensureConnected();
|
|
1082
|
+
const query = 'SHOW TRIGGERS';
|
|
1083
|
+
const session = this.getSession();
|
|
1084
|
+
const result = await session.run(query);
|
|
1085
|
+
return result.records.map((r) => ({
|
|
1086
|
+
name: r.get('trigger name'),
|
|
1087
|
+
statement: r.get('statement'),
|
|
1212
1088
|
}));
|
|
1213
|
-
return {
|
|
1214
|
-
success: true,
|
|
1215
|
-
executionTime: Date.now() - startTime,
|
|
1216
|
-
indexes,
|
|
1217
|
-
};
|
|
1218
1089
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1090
|
+
/**
|
|
1091
|
+
* Create a stream consumer in Memgraph
|
|
1092
|
+
*/
|
|
1093
|
+
async createStream(name, type, topics, transformationProcedure, config) {
|
|
1094
|
+
this.ensureConnected();
|
|
1095
|
+
const configStr = Object.entries(config)
|
|
1096
|
+
.map(([k, v]) => `${k} = '${v}'`)
|
|
1097
|
+
.join(', ');
|
|
1098
|
+
const query = `
|
|
1099
|
+
CREATE ${type} STREAM ${name}
|
|
1100
|
+
TOPICS ${topics.join(', ')}
|
|
1101
|
+
TRANSFORM ${transformationProcedure}
|
|
1102
|
+
${configStr ? `CONFIGS { ${configStr} }` : ''}
|
|
1103
|
+
`;
|
|
1104
|
+
const session = this.getSession();
|
|
1105
|
+
await session.run(query);
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Run a MAGE algorithm (if installed)
|
|
1109
|
+
*/
|
|
1110
|
+
async runMageAlgorithm(algorithm, params = {}) {
|
|
1111
|
+
this.ensureConnected();
|
|
1112
|
+
const paramsList = Object.entries(params)
|
|
1113
|
+
.map(([k]) => `${k}: $${k}`)
|
|
1114
|
+
.join(', ');
|
|
1115
|
+
const query = `CALL ${algorithm}(${paramsList ? `{${paramsList}}` : ''}) YIELD *`;
|
|
1116
|
+
const session = this.getSession();
|
|
1117
|
+
const result = await session.run(query, params);
|
|
1118
|
+
return result.records.map((r) => r.toObject());
|
|
1240
1119
|
}
|
|
1241
|
-
|
|
1120
|
+
// ==================== UTILITY METHODS ====================
|
|
1121
|
+
buildWhereClause(where, alias = 'n') {
|
|
1122
|
+
const conditions = [];
|
|
1242
1123
|
const params = {};
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1247
|
-
|
|
1124
|
+
let paramIndex = 0;
|
|
1125
|
+
const processCondition = (key, value, prefix = '') => {
|
|
1126
|
+
const fullKey = prefix ? `${prefix}_${key}` : key;
|
|
1127
|
+
const paramName = `param_${paramIndex++}`;
|
|
1128
|
+
if (key === '$AND') {
|
|
1129
|
+
const subConditions = [];
|
|
1130
|
+
if (Array.isArray(value)) {
|
|
1131
|
+
value.forEach((v) => {
|
|
1132
|
+
Object.entries(v).forEach(([k, val]) => {
|
|
1133
|
+
processCondition(k, val, fullKey);
|
|
1134
|
+
subConditions.push(conditions.pop());
|
|
1135
|
+
});
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
else {
|
|
1139
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
1140
|
+
processCondition(k, v, fullKey);
|
|
1141
|
+
subConditions.push(conditions.pop());
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
conditions.push(`(${subConditions.join(' AND ')})`);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
if (key === '$OR') {
|
|
1148
|
+
const subConditions = [];
|
|
1149
|
+
if (Array.isArray(value)) {
|
|
1150
|
+
value.forEach((v) => {
|
|
1151
|
+
Object.entries(v).forEach(([k, val]) => {
|
|
1152
|
+
processCondition(k, val, fullKey);
|
|
1153
|
+
subConditions.push(conditions.pop());
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
else {
|
|
1158
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
1159
|
+
processCondition(k, v, fullKey);
|
|
1160
|
+
subConditions.push(conditions.pop());
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
conditions.push(`(${subConditions.join(' OR ')})`);
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
1167
|
+
Object.entries(value).forEach(([op, opValue]) => {
|
|
1168
|
+
const opParamName = `${paramName}_${op.toLowerCase()}`;
|
|
1169
|
+
switch (op) {
|
|
1170
|
+
case '$GT':
|
|
1171
|
+
conditions.push(`${alias}.${key} > $${opParamName}`);
|
|
1172
|
+
params[opParamName] = opValue;
|
|
1173
|
+
break;
|
|
1174
|
+
case '$GTE':
|
|
1175
|
+
conditions.push(`${alias}.${key} >= $${opParamName}`);
|
|
1176
|
+
params[opParamName] = opValue;
|
|
1177
|
+
break;
|
|
1178
|
+
case '$LT':
|
|
1179
|
+
conditions.push(`${alias}.${key} < $${opParamName}`);
|
|
1180
|
+
params[opParamName] = opValue;
|
|
1181
|
+
break;
|
|
1182
|
+
case '$LTE':
|
|
1183
|
+
conditions.push(`${alias}.${key} <= $${opParamName}`);
|
|
1184
|
+
params[opParamName] = opValue;
|
|
1185
|
+
break;
|
|
1186
|
+
case '$NE':
|
|
1187
|
+
conditions.push(`${alias}.${key} <> $${opParamName}`);
|
|
1188
|
+
params[opParamName] = opValue;
|
|
1189
|
+
break;
|
|
1190
|
+
case '$IN':
|
|
1191
|
+
conditions.push(`${alias}.${key} IN $${opParamName}`);
|
|
1192
|
+
params[opParamName] = opValue;
|
|
1193
|
+
break;
|
|
1194
|
+
case '$NOT_IN':
|
|
1195
|
+
conditions.push(`NOT ${alias}.${key} IN $${opParamName}`);
|
|
1196
|
+
params[opParamName] = opValue;
|
|
1197
|
+
break;
|
|
1198
|
+
case '$CONTAINS':
|
|
1199
|
+
conditions.push(`${alias}.${key} CONTAINS $${opParamName}`);
|
|
1200
|
+
params[opParamName] = opValue;
|
|
1201
|
+
break;
|
|
1202
|
+
case '$STARTS_WITH':
|
|
1203
|
+
conditions.push(`${alias}.${key} STARTS WITH $${opParamName}`);
|
|
1204
|
+
params[opParamName] = opValue;
|
|
1205
|
+
break;
|
|
1206
|
+
case '$ENDS_WITH':
|
|
1207
|
+
conditions.push(`${alias}.${key} ENDS WITH $${opParamName}`);
|
|
1208
|
+
params[opParamName] = opValue;
|
|
1209
|
+
break;
|
|
1210
|
+
case '$EXISTS':
|
|
1211
|
+
if (opValue) {
|
|
1212
|
+
conditions.push(`${alias}.${key} IS NOT NULL`);
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
conditions.push(`${alias}.${key} IS NULL`);
|
|
1216
|
+
}
|
|
1217
|
+
break;
|
|
1218
|
+
case '$REGEX':
|
|
1219
|
+
conditions.push(`${alias}.${key} =~ $${opParamName}`);
|
|
1220
|
+
params[opParamName] = opValue;
|
|
1221
|
+
break;
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1226
|
+
conditions.push(`${alias}.${key} = $${paramName}`);
|
|
1227
|
+
params[paramName] = value;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
Object.entries(where).forEach(([key, value]) => {
|
|
1231
|
+
processCondition(key, value);
|
|
1248
1232
|
});
|
|
1249
1233
|
return {
|
|
1250
|
-
clause:
|
|
1234
|
+
clause: conditions.join(' AND ') || 'true',
|
|
1251
1235
|
params,
|
|
1252
1236
|
};
|
|
1253
1237
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.NODE_ERROR, 'Cannot parse null node');
|
|
1258
|
-
}
|
|
1259
|
-
if (nativeNode.identity !== undefined) {
|
|
1260
|
-
return {
|
|
1261
|
-
id: this.toNumber(nativeNode.identity),
|
|
1262
|
-
labels: nativeNode.labels || [],
|
|
1263
|
-
properties: this.convertProperties(nativeNode.properties),
|
|
1264
|
-
};
|
|
1238
|
+
parseError(error) {
|
|
1239
|
+
if (error instanceof graph_error_1.GraphError) {
|
|
1240
|
+
return error;
|
|
1265
1241
|
}
|
|
1242
|
+
return graph_error_1.GraphError.queryError(String(error));
|
|
1243
|
+
}
|
|
1244
|
+
// ==================== PRIVATE HELPER METHODS ====================
|
|
1245
|
+
mapMemgraphNode(node, nodeId) {
|
|
1246
|
+
const id = nodeId !== undefined ? this.toNumber(nodeId) : this.toNumber(node.identity);
|
|
1266
1247
|
return {
|
|
1267
|
-
id:
|
|
1268
|
-
labels:
|
|
1269
|
-
properties: (
|
|
1248
|
+
id: String(id),
|
|
1249
|
+
labels: node.labels || [],
|
|
1250
|
+
properties: this.convertProperties(node.properties || {}),
|
|
1270
1251
|
};
|
|
1271
1252
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
if (nativeRelationship.identity !== undefined) {
|
|
1277
|
-
return {
|
|
1278
|
-
id: this.toNumber(nativeRelationship.identity),
|
|
1279
|
-
type: nativeRelationship.type,
|
|
1280
|
-
startNodeId: this.toNumber(nativeRelationship.start),
|
|
1281
|
-
endNodeId: this.toNumber(nativeRelationship.end),
|
|
1282
|
-
properties: this.convertProperties(nativeRelationship.properties),
|
|
1283
|
-
};
|
|
1284
|
-
}
|
|
1253
|
+
mapMemgraphRelationship(rel, relId, startId, endId) {
|
|
1254
|
+
const id = relId !== undefined ? this.toNumber(relId) : this.toNumber(rel.identity);
|
|
1255
|
+
const start = startId !== undefined ? this.toNumber(startId) : this.toNumber(rel.start);
|
|
1256
|
+
const end = endId !== undefined ? this.toNumber(endId) : this.toNumber(rel.end);
|
|
1285
1257
|
return {
|
|
1286
|
-
id:
|
|
1287
|
-
type:
|
|
1288
|
-
startNodeId:
|
|
1289
|
-
endNodeId:
|
|
1290
|
-
properties: (
|
|
1258
|
+
id: String(id),
|
|
1259
|
+
type: rel.type,
|
|
1260
|
+
startNodeId: String(start),
|
|
1261
|
+
endNodeId: String(end),
|
|
1262
|
+
properties: this.convertProperties(rel.properties || {}),
|
|
1291
1263
|
};
|
|
1292
1264
|
}
|
|
1293
|
-
|
|
1294
|
-
if (!nativePath) {
|
|
1295
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.PATH_ERROR, 'Cannot parse null path');
|
|
1296
|
-
}
|
|
1265
|
+
mapMemgraphPath(path) {
|
|
1297
1266
|
const nodes = [];
|
|
1298
1267
|
const relationships = [];
|
|
1299
|
-
if (
|
|
1300
|
-
|
|
1301
|
-
if (
|
|
1302
|
-
nodes.push(this.
|
|
1268
|
+
if (path.segments) {
|
|
1269
|
+
path.segments.forEach((segment, index) => {
|
|
1270
|
+
if (index === 0) {
|
|
1271
|
+
nodes.push(this.mapMemgraphNode(segment.start, segment.start.identity));
|
|
1303
1272
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1273
|
+
nodes.push(this.mapMemgraphNode(segment.end, segment.end.identity));
|
|
1274
|
+
relationships.push(this.mapMemgraphRelationship(segment.relationship, segment.relationship.identity, segment.start.identity, segment.end.identity));
|
|
1306
1275
|
});
|
|
1307
1276
|
}
|
|
1308
1277
|
return {
|
|
1309
1278
|
nodes,
|
|
1310
1279
|
relationships,
|
|
1311
1280
|
length: relationships.length,
|
|
1312
|
-
start: nodes[0],
|
|
1313
|
-
end: nodes[nodes.length - 1],
|
|
1314
1281
|
};
|
|
1315
1282
|
}
|
|
1316
|
-
|
|
1283
|
+
convertProperties(props) {
|
|
1284
|
+
const result = {};
|
|
1285
|
+
for (const [key, value] of Object.entries(props)) {
|
|
1286
|
+
result[key] = this.convertValue(value);
|
|
1287
|
+
}
|
|
1288
|
+
return result;
|
|
1289
|
+
}
|
|
1317
1290
|
convertValue(value) {
|
|
1318
|
-
|
|
1291
|
+
var _a, _b, _c;
|
|
1292
|
+
if (value === null || value === undefined) {
|
|
1319
1293
|
return value;
|
|
1320
|
-
// Handle Neo4j Integer type (used by Bolt protocol)
|
|
1321
|
-
if (value && typeof value.toNumber === 'function') {
|
|
1322
|
-
return value.toNumber();
|
|
1323
1294
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1295
|
+
// Handle Integer type (from neo4j-driver)
|
|
1296
|
+
if (typeof value === 'object' && ((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Integer') {
|
|
1297
|
+
return this.toNumber(value);
|
|
1326
1298
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
if (value.segments !== undefined) {
|
|
1331
|
-
return this.parsePath(value);
|
|
1299
|
+
// Handle Date types
|
|
1300
|
+
if (typeof value === 'object' && (((_b = value.constructor) === null || _b === void 0 ? void 0 : _b.name) === 'Date' || ((_c = value.constructor) === null || _c === void 0 ? void 0 : _c.name) === 'DateTime')) {
|
|
1301
|
+
return new Date(value.toString());
|
|
1332
1302
|
}
|
|
1333
1303
|
if (Array.isArray(value)) {
|
|
1334
1304
|
return value.map(v => this.convertValue(v));
|
|
1335
1305
|
}
|
|
1336
|
-
if (typeof value === 'object') {
|
|
1337
|
-
const converted = {};
|
|
1338
|
-
Object.entries(value).forEach(([key, val]) => {
|
|
1339
|
-
converted[key] = this.convertValue(val);
|
|
1340
|
-
});
|
|
1341
|
-
return converted;
|
|
1342
|
-
}
|
|
1343
1306
|
return value;
|
|
1344
1307
|
}
|
|
1345
|
-
convertProperties(properties) {
|
|
1346
|
-
if (!properties)
|
|
1347
|
-
return {};
|
|
1348
|
-
const converted = {};
|
|
1349
|
-
Object.entries(properties).forEach(([key, value]) => {
|
|
1350
|
-
converted[key] = this.convertValue(value);
|
|
1351
|
-
});
|
|
1352
|
-
return converted;
|
|
1353
|
-
}
|
|
1354
1308
|
toNumber(value) {
|
|
1355
|
-
if (value
|
|
1356
|
-
return
|
|
1309
|
+
if (value === null || value === undefined) {
|
|
1310
|
+
return 0;
|
|
1357
1311
|
}
|
|
1358
1312
|
if (typeof value === 'number') {
|
|
1359
1313
|
return value;
|
|
1360
1314
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
normalizeLabels(labels) {
|
|
1364
|
-
return Array.isArray(labels) ? labels : [labels];
|
|
1365
|
-
}
|
|
1366
|
-
buildPropertiesClause(properties, prefix = '') {
|
|
1367
|
-
const params = {};
|
|
1368
|
-
const propParts = [];
|
|
1369
|
-
Object.entries(properties).forEach(([key, value], index) => {
|
|
1370
|
-
const paramName = `${prefix}prop_${index}`;
|
|
1371
|
-
propParts.push(`${this.escapeIdentifier(key)}: $${paramName}`);
|
|
1372
|
-
params[paramName] = value;
|
|
1373
|
-
});
|
|
1374
|
-
return {
|
|
1375
|
-
clause: `{${propParts.join(', ')}}`,
|
|
1376
|
-
params,
|
|
1377
|
-
};
|
|
1378
|
-
}
|
|
1379
|
-
buildNodeReference(ref, alias, params, prefix = '') {
|
|
1380
|
-
let pattern = `(${alias}`;
|
|
1381
|
-
if (ref.labels) {
|
|
1382
|
-
const labels = this.normalizeLabels(ref.labels);
|
|
1383
|
-
pattern += ':' + labels.map(l => this.escapeIdentifier(l)).join(':');
|
|
1384
|
-
}
|
|
1385
|
-
pattern += ')';
|
|
1386
|
-
if (ref.id !== undefined) {
|
|
1387
|
-
const paramName = `${prefix}id`;
|
|
1388
|
-
params[paramName] = typeof ref.id === 'string' ? parseInt(ref.id, 10) : ref.id;
|
|
1389
|
-
pattern += ` WHERE id(${alias}) = $${paramName}`;
|
|
1315
|
+
if (typeof value === 'object' && typeof value.toNumber === 'function') {
|
|
1316
|
+
return value.toNumber();
|
|
1390
1317
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
case
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
case
|
|
1406
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} IS NOT NULL`;
|
|
1407
|
-
break;
|
|
1408
|
-
case node_types_1.NodeComparisonOperator.IN:
|
|
1409
|
-
case node_types_1.NodeComparisonOperator.NOT_IN:
|
|
1410
|
-
params[paramName] = where.value;
|
|
1411
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
|
|
1412
|
-
break;
|
|
1413
|
-
case node_types_1.NodeComparisonOperator.CONTAINS:
|
|
1414
|
-
params[paramName] = where.value;
|
|
1415
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} CONTAINS $${paramName}`;
|
|
1416
|
-
break;
|
|
1417
|
-
case node_types_1.NodeComparisonOperator.STARTS_WITH:
|
|
1418
|
-
params[paramName] = where.value;
|
|
1419
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} STARTS WITH $${paramName}`;
|
|
1420
|
-
break;
|
|
1421
|
-
case node_types_1.NodeComparisonOperator.ENDS_WITH:
|
|
1422
|
-
params[paramName] = where.value;
|
|
1423
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} ENDS WITH $${paramName}`;
|
|
1424
|
-
break;
|
|
1425
|
-
case node_types_1.NodeComparisonOperator.REGEX:
|
|
1426
|
-
params[paramName] = where.value;
|
|
1427
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} =~ $${paramName}`;
|
|
1428
|
-
break;
|
|
1318
|
+
if (typeof value === 'object' && typeof value.toInt === 'function') {
|
|
1319
|
+
return value.toInt();
|
|
1320
|
+
}
|
|
1321
|
+
return parseInt(String(value), 10) || 0;
|
|
1322
|
+
}
|
|
1323
|
+
getDirectionArrow(direction) {
|
|
1324
|
+
switch (direction) {
|
|
1325
|
+
case enums_1.TraversalDirection.OUTGOING:
|
|
1326
|
+
case 'OUTGOING':
|
|
1327
|
+
return { left: '-', right: '->' };
|
|
1328
|
+
case enums_1.TraversalDirection.INCOMING:
|
|
1329
|
+
case 'INCOMING':
|
|
1330
|
+
return { left: '<-', right: '-' };
|
|
1331
|
+
case enums_1.TraversalDirection.BOTH:
|
|
1332
|
+
case 'BOTH':
|
|
1429
1333
|
default:
|
|
1430
|
-
|
|
1431
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
|
|
1432
|
-
}
|
|
1433
|
-
if (where.and && where.and.length > 0) {
|
|
1434
|
-
const andClauses = where.and.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 1));
|
|
1435
|
-
condition = `(${condition} AND ${andClauses.join(' AND ')})`;
|
|
1436
|
-
}
|
|
1437
|
-
if (where.or && where.or.length > 0) {
|
|
1438
|
-
const orClauses = where.or.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 100));
|
|
1439
|
-
condition = `(${condition} OR ${orClauses.join(' OR ')})`;
|
|
1334
|
+
return { left: '-', right: '-' };
|
|
1440
1335
|
}
|
|
1441
|
-
return condition;
|
|
1442
|
-
}
|
|
1443
|
-
buildNodeSelectorMatch(selector, alias, params, prefix = '') {
|
|
1444
|
-
let pattern = `(${alias}`;
|
|
1445
|
-
if (selector.labels) {
|
|
1446
|
-
const labels = this.normalizeLabels(selector.labels);
|
|
1447
|
-
pattern += ':' + labels.map((l) => this.escapeIdentifier(l)).join(':');
|
|
1448
|
-
}
|
|
1449
|
-
pattern += ')';
|
|
1450
|
-
const whereParts = [];
|
|
1451
|
-
if (selector.id !== undefined) {
|
|
1452
|
-
const paramName = `${prefix}id`;
|
|
1453
|
-
params[paramName] = typeof selector.id === 'string' ? parseInt(selector.id, 10) : selector.id;
|
|
1454
|
-
whereParts.push(`id(${alias}) = $${paramName}`);
|
|
1455
|
-
}
|
|
1456
|
-
if (selector.properties && Object.keys(selector.properties).length > 0) {
|
|
1457
|
-
Object.entries(selector.properties).forEach(([key, value], index) => {
|
|
1458
|
-
const paramName = `${prefix}prop_${index}`;
|
|
1459
|
-
whereParts.push(`${alias}.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1460
|
-
params[paramName] = value;
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
if (selector.where) {
|
|
1464
|
-
const { clause, params: whereParams } = this.buildWhereFromClause(selector.where, alias, prefix);
|
|
1465
|
-
whereParts.push(clause);
|
|
1466
|
-
Object.assign(params, whereParams);
|
|
1467
|
-
}
|
|
1468
|
-
if (whereParts.length > 0) {
|
|
1469
|
-
return `${pattern} WHERE ${whereParts.join(' AND ')}`;
|
|
1470
|
-
}
|
|
1471
|
-
return pattern;
|
|
1472
|
-
}
|
|
1473
|
-
parseStatistics(counters) {
|
|
1474
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1475
|
-
if (!counters)
|
|
1476
|
-
return undefined;
|
|
1477
|
-
return {
|
|
1478
|
-
nodesCreated: ((_a = counters.nodesCreated) === null || _a === void 0 ? void 0 : _a.call(counters)) || 0,
|
|
1479
|
-
nodesDeleted: ((_b = counters.nodesDeleted) === null || _b === void 0 ? void 0 : _b.call(counters)) || 0,
|
|
1480
|
-
relationshipsCreated: ((_c = counters.relationshipsCreated) === null || _c === void 0 ? void 0 : _c.call(counters)) || 0,
|
|
1481
|
-
relationshipsDeleted: ((_d = counters.relationshipsDeleted) === null || _d === void 0 ? void 0 : _d.call(counters)) || 0,
|
|
1482
|
-
propertiesSet: ((_e = counters.propertiesSet) === null || _e === void 0 ? void 0 : _e.call(counters)) || 0,
|
|
1483
|
-
labelsAdded: ((_f = counters.labelsAdded) === null || _f === void 0 ? void 0 : _f.call(counters)) || 0,
|
|
1484
|
-
labelsRemoved: ((_g = counters.labelsRemoved) === null || _g === void 0 ? void 0 : _g.call(counters)) || 0,
|
|
1485
|
-
containsUpdates: ((_h = counters.containsUpdates) === null || _h === void 0 ? void 0 : _h.call(counters)) || false,
|
|
1486
|
-
};
|
|
1487
1336
|
}
|
|
1488
1337
|
}
|
|
1489
1338
|
exports.MemgraphAdapter = MemgraphAdapter;
|
|
1490
|
-
exports.default = MemgraphAdapter;
|
|
1491
1339
|
//# sourceMappingURL=memgraph.adapter.js.map
|