@ductape/sdk 0.0.4-v51 → 0.0.4-v53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/agent-context.d.ts +98 -0
- package/dist/agents/agent-context.js +588 -0
- package/dist/agents/agent-context.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +180 -0
- package/dist/agents/agent-executor.js +715 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/agents.service.d.ts +304 -0
- package/dist/agents/agents.service.js +1244 -0
- package/dist/agents/agents.service.js.map +1 -0
- package/dist/agents/index.d.ts +55 -0
- package/dist/agents/index.js +110 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/memory-manager.d.ts +182 -0
- package/dist/agents/memory-manager.js +383 -0
- package/dist/agents/memory-manager.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +141 -0
- package/dist/agents/tool-registry.js +355 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/agents/types/agents.types.d.ts +1225 -0
- package/dist/agents/types/agents.types.js +12 -0
- package/dist/agents/types/agents.types.js.map +1 -0
- package/dist/agents/types/index.d.ts +6 -0
- package/dist/agents/types/index.js +23 -0
- package/dist/agents/types/index.js.map +1 -0
- package/dist/agents/vector-store-adapter.d.ts +108 -0
- package/dist/agents/vector-store-adapter.js +213 -0
- package/dist/agents/vector-store-adapter.js.map +1 -0
- package/dist/api/services/appApi.service.js +4 -5
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +322 -0
- package/dist/api/services/processorApi.service.js +252 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +69 -1
- package/dist/api/services/productsApi.service.js +67 -31
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/resilienceApi.service.d.ts +106 -0
- package/dist/api/services/resilienceApi.service.js +224 -0
- package/dist/api/services/resilienceApi.service.js.map +1 -0
- package/dist/api/services/secretsApi.service.d.ts +38 -0
- package/dist/api/services/secretsApi.service.js +96 -0
- package/dist/api/services/secretsApi.service.js.map +1 -0
- package/dist/api/services/userApi.service.js +0 -1
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workflowApi.service.d.ts +199 -0
- package/dist/api/services/workflowApi.service.js +183 -0
- package/dist/api/services/workflowApi.service.js.map +1 -0
- package/dist/api/services/workspaceApi.service.js +0 -1
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +57 -0
- package/dist/api/urls.js +68 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.js +4 -10
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +0 -10
- package/dist/apps/services/app.service.js +74 -30
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/utils/auth-context-manager.d.ts +137 -0
- package/dist/apps/utils/auth-context-manager.js +248 -0
- package/dist/apps/utils/auth-context-manager.js.map +1 -0
- package/dist/apps/utils/credential-manager.d.ts +128 -0
- package/dist/apps/utils/credential-manager.js +199 -0
- package/dist/apps/utils/credential-manager.js.map +1 -0
- package/dist/apps/utils/index.d.ts +10 -0
- package/dist/apps/utils/index.js +54 -0
- package/dist/apps/utils/index.js.map +1 -0
- package/dist/apps/utils/input-helpers.d.ts +67 -0
- package/dist/apps/utils/input-helpers.js +185 -0
- package/dist/apps/utils/input-helpers.js.map +1 -0
- package/dist/apps/utils/input-resolver.d.ts +165 -0
- package/dist/apps/utils/input-resolver.js +477 -0
- package/dist/apps/utils/input-resolver.js.map +1 -0
- package/dist/apps/utils/oauth-manager.d.ts +196 -0
- package/dist/apps/utils/oauth-manager.js +405 -0
- package/dist/apps/utils/oauth-manager.js.map +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/bin.d.ts +26 -0
- package/dist/bin.js +28 -0
- package/dist/bin.js.map +1 -0
- package/dist/brokers/brokers.service.d.ts +257 -0
- package/dist/brokers/brokers.service.js +604 -0
- package/dist/brokers/brokers.service.js.map +1 -0
- package/dist/brokers/index.d.ts +46 -0
- package/dist/brokers/index.js +83 -0
- package/dist/brokers/index.js.map +1 -0
- package/dist/brokers/types/index.d.ts +288 -0
- package/dist/brokers/types/index.js +8 -0
- package/dist/brokers/types/index.js.map +1 -0
- package/dist/brokers/utils/broker.util.d.ts +33 -0
- package/dist/brokers/utils/broker.util.js +125 -0
- package/dist/brokers/utils/broker.util.js.map +1 -0
- package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
- package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
- package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
- package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
- package/dist/brokers/utils/providers/index.d.ts +6 -0
- package/dist/brokers/utils/providers/index.js +16 -0
- package/dist/brokers/utils/providers/index.js.map +1 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +16 -0
- package/dist/brokers/utils/providers/kafka.service.js +52 -0
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
- package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
- package/dist/brokers/utils/providers/nats.service.js +63 -0
- package/dist/brokers/utils/providers/nats.service.js.map +1 -0
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +14 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
- package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
- package/dist/brokers/utils/providers/redis.service.js +93 -0
- package/dist/brokers/utils/providers/redis.service.js.map +1 -0
- package/dist/cache/cache.manager.d.ts +159 -0
- package/dist/cache/cache.manager.js +265 -0
- package/dist/cache/cache.manager.js.map +1 -0
- package/dist/cache/cache.service.d.ts +186 -0
- package/dist/cache/cache.service.js +437 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.js +79 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types/index.d.ts +106 -0
- package/dist/cache/types/index.js +6 -0
- package/dist/cache/types/index.js.map +1 -0
- package/dist/database/actions/action-manager.d.ts +170 -0
- package/dist/database/actions/action-manager.js +465 -0
- package/dist/database/actions/action-manager.js.map +1 -0
- package/dist/database/actions/index.d.ts +6 -0
- package/dist/database/actions/index.js +13 -0
- package/dist/database/actions/index.js.map +1 -0
- package/dist/database/adapters/adapter.factory.d.ts +62 -0
- package/dist/database/adapters/adapter.factory.js +97 -0
- package/dist/database/adapters/adapter.factory.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +307 -90
- package/dist/database/adapters/base.adapter.js +139 -20
- package/dist/database/adapters/base.adapter.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
- package/dist/database/adapters/cassandra.adapter.js +1019 -0
- package/dist/database/adapters/cassandra.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
- package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/index.d.ts +11 -0
- package/dist/database/adapters/index.js +27 -0
- package/dist/database/adapters/index.js.map +1 -0
- package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
- package/dist/database/adapters/mariadb.adapter.js +247 -0
- package/dist/database/adapters/mariadb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +105 -57
- package/dist/database/adapters/mongodb.adapter.js +941 -838
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +76 -138
- package/dist/database/adapters/mysql.adapter.js +990 -1246
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
- package/dist/database/adapters/postgresql.adapter.js +1076 -1346
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +1374 -0
- package/dist/database/databases.service.js +2680 -0
- package/dist/database/databases.service.js.map +1 -0
- package/dist/database/index.d.ts +41 -13
- package/dist/database/index.js +97 -86
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/index.d.ts +6 -0
- package/dist/database/migrations/index.js +12 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/migrations/migration-engine.d.ts +132 -0
- package/dist/database/migrations/migration-engine.js +1356 -0
- package/dist/database/migrations/migration-engine.js.map +1 -0
- package/dist/database/operators/aggregation-builder.d.ts +64 -0
- package/dist/database/operators/aggregation-builder.js +746 -0
- package/dist/database/operators/aggregation-builder.js.map +1 -0
- package/dist/database/operators/index.d.ts +7 -0
- package/dist/database/operators/index.js +15 -0
- package/dist/database/operators/index.js.map +1 -0
- package/dist/database/operators/query-builder.d.ts +55 -0
- package/dist/database/operators/query-builder.js +365 -0
- package/dist/database/operators/query-builder.js.map +1 -0
- package/dist/database/presave/decrypt.d.ts +25 -0
- package/dist/database/presave/decrypt.js +146 -0
- package/dist/database/presave/decrypt.js.map +1 -0
- package/dist/database/presave/index.d.ts +9 -0
- package/dist/database/presave/index.js +18 -0
- package/dist/database/presave/index.js.map +1 -0
- package/dist/database/presave/presave-processor.d.ts +148 -0
- package/dist/database/presave/presave-processor.js +702 -0
- package/dist/database/presave/presave-processor.js.map +1 -0
- package/dist/database/schema/index.d.ts +7 -0
- package/dist/database/schema/index.js +13 -0
- package/dist/database/schema/index.js.map +1 -0
- package/dist/database/schema/schema-manager.d.ts +258 -0
- package/dist/database/schema/schema-manager.js +637 -0
- package/dist/database/schema/schema-manager.js.map +1 -0
- package/dist/database/transactions/index.d.ts +6 -0
- package/dist/database/transactions/index.js +13 -0
- package/dist/database/transactions/index.js.map +1 -0
- package/dist/database/transactions/transaction-manager.d.ts +113 -0
- package/dist/database/transactions/transaction-manager.js +344 -0
- package/dist/database/transactions/transaction-manager.js.map +1 -0
- package/dist/database/triggers/index.d.ts +7 -0
- package/dist/database/triggers/index.js +14 -0
- package/dist/database/triggers/index.js.map +1 -0
- package/dist/database/triggers/trigger-processor.d.ts +239 -0
- package/dist/database/triggers/trigger-processor.js +1034 -0
- package/dist/database/triggers/trigger-processor.js.map +1 -0
- package/dist/database/types/action.interface.d.ts +148 -0
- package/dist/database/types/action.interface.js +6 -0
- package/dist/database/types/action.interface.js.map +1 -0
- package/dist/database/types/aggregation.interface.d.ts +179 -0
- package/dist/database/types/aggregation.interface.js +6 -0
- package/dist/database/types/aggregation.interface.js.map +1 -0
- package/dist/database/types/connection.interface.d.ts +137 -0
- package/dist/database/types/connection.interface.js +6 -0
- package/dist/database/types/connection.interface.js.map +1 -0
- package/dist/database/types/enums.d.ts +195 -0
- package/dist/database/types/enums.js +244 -0
- package/dist/database/types/enums.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -10
- package/dist/database/types/index.js +26 -32
- package/dist/database/types/index.js.map +1 -1
- package/dist/database/types/migration.interface.d.ts +686 -0
- package/dist/database/types/migration.interface.js +9 -0
- package/dist/database/types/migration.interface.js.map +1 -0
- package/dist/database/types/presave.interface.d.ts +292 -0
- package/dist/database/types/presave.interface.js +60 -0
- package/dist/database/types/presave.interface.js.map +1 -0
- package/dist/database/types/query.interface.d.ts +199 -0
- package/dist/database/types/query.interface.js +6 -0
- package/dist/database/types/query.interface.js.map +1 -0
- package/dist/database/types/schema.interface.d.ts +398 -0
- package/dist/database/types/schema.interface.js +6 -0
- package/dist/database/types/schema.interface.js.map +1 -0
- package/dist/database/types/transaction.interface.d.ts +84 -0
- package/dist/database/types/transaction.interface.js +6 -0
- package/dist/database/types/transaction.interface.js.map +1 -0
- package/dist/database/types/trigger.interface.d.ts +612 -0
- package/dist/database/types/trigger.interface.js +121 -0
- package/dist/database/types/trigger.interface.js.map +1 -0
- package/dist/database/types/write.interface.d.ts +208 -0
- package/dist/database/types/write.interface.js +6 -0
- package/dist/database/types/write.interface.js.map +1 -0
- package/dist/database/utils/database-error.d.ts +96 -0
- package/dist/database/utils/database-error.js +221 -0
- package/dist/database/utils/database-error.js.map +1 -0
- package/dist/database/utils/index.d.ts +6 -0
- package/dist/database/utils/index.js +11 -0
- package/dist/database/utils/index.js.map +1 -0
- package/dist/graph/adapters/adapter.factory.d.ts +47 -0
- package/dist/graph/adapters/adapter.factory.js +77 -0
- package/dist/graph/adapters/adapter.factory.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +78 -72
- package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/base.adapter.d.ts +135 -118
- package/dist/graph/adapters/base.adapter.js +46 -20
- package/dist/graph/adapters/base.adapter.js.map +1 -1
- package/dist/graph/adapters/index.d.ts +5 -4
- package/dist/graph/adapters/index.js +6 -8
- package/dist/graph/adapters/index.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
- package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
- package/dist/graph/adapters/neo4j.adapter.js +912 -1605
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
- package/dist/graph/adapters/neptune.adapter.js +1095 -1228
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +524 -0
- package/dist/graph/graphs.service.js +1683 -0
- package/dist/graph/graphs.service.js.map +1 -0
- package/dist/graph/index.d.ts +54 -8
- package/dist/graph/index.js +67 -32
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/transactions/index.d.ts +4 -0
- package/dist/graph/transactions/index.js +9 -0
- package/dist/graph/transactions/index.js.map +1 -0
- package/dist/graph/transactions/transaction-manager.d.ts +61 -0
- package/dist/graph/transactions/transaction-manager.js +126 -0
- package/dist/graph/transactions/transaction-manager.js.map +1 -0
- package/dist/graph/types/connection.interface.d.ts +141 -0
- package/dist/graph/types/connection.interface.js +9 -0
- package/dist/graph/types/connection.interface.js.map +1 -0
- package/dist/graph/types/enums.d.ts +101 -0
- package/dist/graph/types/enums.js +114 -0
- package/dist/graph/types/enums.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -9
- package/dist/graph/types/index.js +15 -30
- package/dist/graph/types/index.js.map +1 -1
- package/dist/graph/types/node.interface.d.ts +248 -0
- package/dist/graph/types/node.interface.js +9 -0
- package/dist/graph/types/node.interface.js.map +1 -0
- package/dist/graph/types/query.interface.d.ts +168 -0
- package/dist/graph/types/query.interface.js +9 -0
- package/dist/graph/types/query.interface.js.map +1 -0
- package/dist/graph/types/relationship.interface.d.ts +207 -0
- package/dist/graph/types/relationship.interface.js +9 -0
- package/dist/graph/types/relationship.interface.js.map +1 -0
- package/dist/graph/types/schema.interface.d.ts +295 -0
- package/dist/graph/types/schema.interface.js +9 -0
- package/dist/graph/types/schema.interface.js.map +1 -0
- package/dist/graph/types/transaction.interface.d.ts +55 -0
- package/dist/graph/types/transaction.interface.js +9 -0
- package/dist/graph/types/transaction.interface.js.map +1 -0
- package/dist/graph/types/traversal.interface.d.ts +181 -0
- package/dist/graph/types/traversal.interface.js +9 -0
- package/dist/graph/types/traversal.interface.js.map +1 -0
- package/dist/graph/utils/graph-error.d.ts +71 -0
- package/dist/graph/utils/graph-error.js +142 -0
- package/dist/graph/utils/graph-error.js.map +1 -0
- package/dist/graph/utils/index.d.ts +4 -0
- package/dist/graph/utils/index.js +9 -0
- package/dist/graph/utils/index.js.map +1 -0
- package/dist/index.d.ts +1905 -875
- package/dist/index.js +3063 -1282
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +407 -0
- package/dist/init.interface.js +3 -0
- package/dist/init.interface.js.map +1 -0
- package/dist/jobs/index.d.ts +38 -0
- package/dist/jobs/index.js +50 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/jobs.service.d.ts +154 -0
- package/dist/jobs/jobs.service.js +491 -0
- package/dist/jobs/jobs.service.js.map +1 -0
- package/dist/jobs/jobs.state.d.ts +113 -0
- package/dist/jobs/jobs.state.js +447 -0
- package/dist/jobs/jobs.state.js.map +1 -0
- package/dist/jobs/types.d.ts +449 -0
- package/dist/jobs/types.js +74 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logs/logs.types.d.ts +12 -2
- package/dist/logs/logs.types.js +5 -1
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +11 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/models.service.d.ts +137 -0
- package/dist/models/models.service.js +195 -0
- package/dist/models/models.service.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.js +26 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notifications.service.d.ts +252 -0
- package/dist/notifications/notifications.service.js +654 -0
- package/dist/notifications/notifications.service.js.map +1 -0
- package/dist/notifications/types/index.d.ts +4 -0
- package/dist/notifications/types/index.js +21 -0
- package/dist/notifications/types/index.js.map +1 -0
- package/dist/notifications/types/notifications.types.d.ts +400 -0
- package/dist/notifications/types/notifications.types.js +49 -0
- package/dist/notifications/types/notifications.types.js.map +1 -0
- package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +86 -70
- package/dist/processor/services/processor.service.js +1353 -1259
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +5 -1
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/services/products.service.d.ts +167 -25
- package/dist/products/services/products.service.js +1248 -412
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +6 -3
- package/dist/products/validators/index.js +14 -5
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +218 -0
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +4 -15
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
- package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +135 -50
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
- package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +0 -6
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +88 -0
- package/dist/resilience/fallback.service.js +511 -0
- package/dist/resilience/fallback.service.js.map +1 -0
- package/dist/resilience/healthcheck.service.d.ts +106 -0
- package/dist/resilience/healthcheck.service.js +379 -0
- package/dist/resilience/healthcheck.service.js.map +1 -0
- package/dist/resilience/index.d.ts +104 -0
- package/dist/resilience/index.js +140 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/quota.service.d.ts +90 -0
- package/dist/resilience/quota.service.js +519 -0
- package/dist/resilience/quota.service.js.map +1 -0
- package/dist/resilience/resilience.service.d.ts +95 -0
- package/dist/resilience/resilience.service.js +525 -0
- package/dist/resilience/resilience.service.js.map +1 -0
- package/dist/resilience/types/index.d.ts +479 -0
- package/dist/resilience/types/index.js +26 -0
- package/dist/resilience/types/index.js.map +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.js +33 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/secrets.resolver.d.ts +52 -0
- package/dist/secrets/secrets.resolver.js +233 -0
- package/dist/secrets/secrets.resolver.js.map +1 -0
- package/dist/secrets/secrets.service.d.ts +83 -0
- package/dist/secrets/secrets.service.js +159 -0
- package/dist/secrets/secrets.service.js.map +1 -0
- package/dist/secrets/secrets.types.d.ts +188 -0
- package/dist/secrets/secrets.types.js +87 -0
- package/dist/secrets/secrets.types.js.map +1 -0
- package/dist/sessions/index.d.ts +50 -0
- package/dist/sessions/index.js +93 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/sessions.helper.d.ts +68 -0
- package/dist/sessions/sessions.helper.js +116 -0
- package/dist/sessions/sessions.helper.js.map +1 -0
- package/dist/sessions/sessions.resolver.d.ts +150 -0
- package/dist/sessions/sessions.resolver.js +356 -0
- package/dist/sessions/sessions.resolver.js.map +1 -0
- package/dist/sessions/sessions.service.d.ts +170 -0
- package/dist/sessions/sessions.service.js +736 -0
- package/dist/sessions/sessions.service.js.map +1 -0
- package/dist/sessions/types/index.d.ts +290 -0
- package/dist/sessions/types/index.js +6 -0
- package/dist/sessions/types/index.js.map +1 -0
- package/dist/storage/index.d.ts +66 -0
- package/dist/storage/index.js +98 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/storage.service.d.ts +123 -0
- package/dist/storage/storage.service.js +478 -0
- package/dist/storage/storage.service.js.map +1 -0
- package/dist/storage/types/index.d.ts +207 -0
- package/dist/storage/types/index.js +6 -0
- package/dist/storage/types/index.js.map +1 -0
- package/dist/storage/utils/storage.util.d.ts +51 -0
- package/dist/storage/utils/storage.util.js +402 -0
- package/dist/storage/utils/storage.util.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.js +13 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test.appBuilder.d.ts +0 -1
- package/dist/test/test.appBuilder.js +0 -15
- package/dist/test/test.appBuilder.js.map +1 -1
- package/dist/test/test.database.js +140 -0
- package/dist/test/test.database.js.map +1 -0
- package/dist/test/test.health.d.ts +0 -1
- package/dist/test/test.health.js +0 -48
- package/dist/test/test.health.js.map +1 -1
- package/dist/test/test.import.d.ts +0 -1
- package/dist/test/test.import.js +0 -1506
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.import.openapi.d.ts +0 -1
- package/dist/test/test.import.openapi.js +0 -75
- package/dist/test/test.import.openapi.js.map +1 -1
- package/dist/test/test.imports.d.ts +0 -1
- package/dist/test/test.imports.js +0 -76
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.logs.d.ts +0 -1
- package/dist/test/test.logs.js +0 -17
- package/dist/test/test.logs.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +0 -1
- package/dist/test/test.notifiers.js +0 -84
- package/dist/test/test.notifiers.js.map +1 -1
- package/dist/test/test.processor.d.ts +0 -1
- package/dist/test/test.processor.js +0 -37
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.productBuilder.d.ts +0 -1
- package/dist/test/test.productBuilder.js +0 -660
- package/dist/test/test.productBuilder.js.map +1 -1
- package/dist/test/test.products.d.ts +0 -1
- package/dist/test/test.products.js +0 -48
- package/dist/test/test.products.js.map +1 -1
- package/dist/test/test.storage.js +332 -0
- package/dist/test/test.storage.js.map +1 -0
- package/dist/test/test.triggers.js +314 -0
- package/dist/test/test.triggers.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/dist/types/enums.d.ts +6 -1
- package/dist/types/enums.js +5 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/processor.types.d.ts +197 -35
- package/dist/types/processor.types.js +9 -1
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +837 -75
- package/dist/types/productsBuilder.types.js +168 -62
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +2 -49
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +152 -0
- package/dist/vector/adapters/base.adapter.js +137 -0
- package/dist/vector/adapters/base.adapter.js.map +1 -0
- package/dist/vector/adapters/index.d.ts +10 -0
- package/dist/vector/adapters/index.js +19 -0
- package/dist/vector/adapters/index.js.map +1 -0
- package/dist/vector/adapters/memory.adapter.d.ts +85 -0
- package/dist/vector/adapters/memory.adapter.js +505 -0
- package/dist/vector/adapters/memory.adapter.js.map +1 -0
- package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
- package/dist/vector/adapters/pinecone.adapter.js +400 -0
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
- package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
- package/dist/vector/adapters/qdrant.adapter.js +392 -0
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
- package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
- package/dist/vector/adapters/weaviate.adapter.js +478 -0
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
- package/dist/vector/index.d.ts +47 -0
- package/dist/vector/index.js +72 -0
- package/dist/vector/index.js.map +1 -0
- package/dist/vector/types/connection.interface.d.ts +151 -0
- package/dist/vector/types/connection.interface.js +8 -0
- package/dist/vector/types/connection.interface.js.map +1 -0
- package/dist/vector/types/embedding.interface.d.ts +144 -0
- package/dist/vector/types/embedding.interface.js +8 -0
- package/dist/vector/types/embedding.interface.js.map +1 -0
- package/dist/vector/types/enums.d.ts +104 -0
- package/dist/vector/types/enums.js +113 -0
- package/dist/vector/types/enums.js.map +1 -0
- package/dist/vector/types/index.d.ts +9 -0
- package/dist/vector/types/index.js +16 -0
- package/dist/vector/types/index.js.map +1 -0
- package/dist/vector/types/vector.interface.d.ts +315 -0
- package/dist/vector/types/vector.interface.js +8 -0
- package/dist/vector/types/vector.interface.js.map +1 -0
- package/dist/vector/utils/index.d.ts +6 -0
- package/dist/vector/utils/index.js +11 -0
- package/dist/vector/utils/index.js.map +1 -0
- package/dist/vector/utils/vector-error.d.ts +69 -0
- package/dist/vector/utils/vector-error.js +117 -0
- package/dist/vector/utils/vector-error.js.map +1 -0
- package/dist/vector/vector-database.service.d.ts +405 -0
- package/dist/vector/vector-database.service.js +544 -0
- package/dist/vector/vector-database.service.js.map +1 -0
- package/dist/vector/vector.service.d.ts +245 -0
- package/dist/vector/vector.service.js +381 -0
- package/dist/vector/vector.service.js.map +1 -0
- package/dist/workflows/index.d.ts +30 -0
- package/dist/workflows/index.js +64 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/types/index.d.ts +6 -0
- package/dist/workflows/types/index.js +23 -0
- package/dist/workflows/types/index.js.map +1 -0
- package/dist/workflows/types/workflows.types.d.ts +1035 -0
- package/dist/workflows/types/workflows.types.js +13 -0
- package/dist/workflows/types/workflows.types.js.map +1 -0
- package/dist/workflows/workflow-builder.d.ts +70 -0
- package/dist/workflows/workflow-builder.js +338 -0
- package/dist/workflows/workflow-builder.js.map +1 -0
- package/dist/workflows/workflow-executor.d.ts +205 -0
- package/dist/workflows/workflow-executor.js +1186 -0
- package/dist/workflows/workflow-executor.js.map +1 -0
- package/dist/workflows/workflows.service.d.ts +398 -0
- package/dist/workflows/workflows.service.js +1595 -0
- package/dist/workflows/workflows.service.js.map +1 -0
- package/package.json +16 -13
- package/dist/actions/actions.repo.d.ts +0 -0
- package/dist/actions/actions.repo.js +0 -13
- package/dist/actions/actions.repo.js.map +0 -1
- package/dist/actions/actions.service.d.ts +0 -0
- package/dist/actions/actions.service.js +0 -24
- package/dist/actions/actions.service.js.map +0 -1
- package/dist/actions/utils/actions.util.read.d.ts +0 -0
- package/dist/actions/utils/actions.util.read.js +0 -427
- package/dist/actions/utils/actions.util.read.js.map +0 -1
- package/dist/api/services/integrationsApi.service.d.ts +0 -18
- package/dist/api/services/integrationsApi.service.js +0 -80
- package/dist/api/services/integrationsApi.service.js.map +0 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +0 -75
- package/dist/api/services/workspaceSecretsApi.service.js +0 -62
- package/dist/api/services/workspaceSecretsApi.service.js.map +0 -1
- package/dist/appBuilder/services/app.service.d.ts +0 -111
- package/dist/appBuilder/services/app.service.js +0 -737
- package/dist/appBuilder/services/app.service.js.map +0 -1
- package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
- package/dist/appBuilder/services/appBuilder.service.js +0 -662
- package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
- package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
- package/dist/appBuilder/utils/objects.utils.js +0 -9
- package/dist/appBuilder/utils/objects.utils.js.map +0 -1
- package/dist/appBuilder/utils/string.utils.d.ts +0 -2
- package/dist/appBuilder/utils/string.utils.js +0 -57
- package/dist/appBuilder/utils/string.utils.js.map +0 -1
- package/dist/appBuilder/validators/index.d.ts +0 -19
- package/dist/appBuilder/validators/index.js +0 -40
- package/dist/appBuilder/validators/index.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.app.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
- package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
- package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
- package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
- package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
- package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
- package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
- package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
- package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
- package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
- package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
- package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
- package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
- package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
- package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts +0 -3
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
- package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
- package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
- package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
- package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
- package/dist/clients/integrations.client.d.ts +0 -2
- package/dist/clients/integrations.client.js +0 -26
- package/dist/clients/integrations.client.js.map +0 -1
- package/dist/database/database.service.d.ts +0 -232
- package/dist/database/database.service.js +0 -802
- package/dist/database/database.service.js.map +0 -1
- package/dist/database/types/aggregation.types.d.ts +0 -261
- package/dist/database/types/aggregation.types.js +0 -21
- package/dist/database/types/aggregation.types.js.map +0 -1
- package/dist/database/types/connection.types.d.ts +0 -132
- package/dist/database/types/connection.types.js +0 -6
- package/dist/database/types/connection.types.js.map +0 -1
- package/dist/database/types/database.types.d.ts +0 -175
- package/dist/database/types/database.types.js +0 -75
- package/dist/database/types/database.types.js.map +0 -1
- package/dist/database/types/index.types.d.ts +0 -220
- package/dist/database/types/index.types.js +0 -27
- package/dist/database/types/index.types.js.map +0 -1
- package/dist/database/types/migration.types.d.ts +0 -205
- package/dist/database/types/migration.types.js +0 -44
- package/dist/database/types/migration.types.js.map +0 -1
- package/dist/database/types/query.types.d.ts +0 -305
- package/dist/database/types/query.types.js +0 -57
- package/dist/database/types/query.types.js.map +0 -1
- package/dist/database/types/result.types.d.ts +0 -220
- package/dist/database/types/result.types.js +0 -6
- package/dist/database/types/result.types.js.map +0 -1
- package/dist/database/types/schema.types.d.ts +0 -190
- package/dist/database/types/schema.types.js +0 -69
- package/dist/database/types/schema.types.js.map +0 -1
- package/dist/database/utils/helpers.d.ts +0 -66
- package/dist/database/utils/helpers.js +0 -501
- package/dist/database/utils/helpers.js.map +0 -1
- package/dist/database/utils/migration.utils.d.ts +0 -151
- package/dist/database/utils/migration.utils.js +0 -476
- package/dist/database/utils/migration.utils.js.map +0 -1
- package/dist/database/utils/transaction.d.ts +0 -64
- package/dist/database/utils/transaction.js +0 -130
- package/dist/database/utils/transaction.js.map +0 -1
- package/dist/database/validators/connection.validator.d.ts +0 -20
- package/dist/database/validators/connection.validator.js +0 -267
- package/dist/database/validators/connection.validator.js.map +0 -1
- package/dist/database/validators/query.validator.d.ts +0 -31
- package/dist/database/validators/query.validator.js +0 -305
- package/dist/database/validators/query.validator.js.map +0 -1
- package/dist/database/validators/schema.validator.d.ts +0 -31
- package/dist/database/validators/schema.validator.js +0 -334
- package/dist/database/validators/schema.validator.js.map +0 -1
- package/dist/graph/graph.service.d.ts +0 -278
- package/dist/graph/graph.service.js +0 -687
- package/dist/graph/graph.service.js.map +0 -1
- package/dist/graph/types/connection.types.d.ts +0 -158
- package/dist/graph/types/connection.types.js +0 -43
- package/dist/graph/types/connection.types.js.map +0 -1
- package/dist/graph/types/graph.types.d.ts +0 -144
- package/dist/graph/types/graph.types.js +0 -84
- package/dist/graph/types/graph.types.js.map +0 -1
- package/dist/graph/types/node.types.d.ts +0 -193
- package/dist/graph/types/node.types.js +0 -49
- package/dist/graph/types/node.types.js.map +0 -1
- package/dist/graph/types/path.types.d.ts +0 -224
- package/dist/graph/types/path.types.js +0 -38
- package/dist/graph/types/path.types.js.map +0 -1
- package/dist/graph/types/query.types.d.ts +0 -247
- package/dist/graph/types/query.types.js +0 -23
- package/dist/graph/types/query.types.js.map +0 -1
- package/dist/graph/types/relationship.types.d.ts +0 -224
- package/dist/graph/types/relationship.types.js +0 -35
- package/dist/graph/types/relationship.types.js.map +0 -1
- package/dist/graph/types/result.types.d.ts +0 -237
- package/dist/graph/types/result.types.js +0 -7
- package/dist/graph/types/result.types.js.map +0 -1
- package/dist/graph/validators/index.d.ts +0 -81
- package/dist/graph/validators/index.js +0 -243
- package/dist/graph/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
- package/dist/integrationsBuilder/services/integration.service.js +0 -1148
- package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
- package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
- package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
- package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
- package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
- package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
- package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
- package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
- package/dist/integrationsBuilder/utils/string.utils.js +0 -9
- package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
- package/dist/integrationsBuilder/validators/index.d.ts +0 -18
- package/dist/integrationsBuilder/validators/index.js +0 -38
- package/dist/integrationsBuilder/validators/index.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
- package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
- package/dist/postman.d.ts +0 -1
- package/dist/postman.js +0 -21674
- package/dist/postman.js.map +0 -1
- package/dist/processor/utils/mongo.util.d.ts +0 -0
- package/dist/processor/utils/mongo.util.js +0 -152
- package/dist/processor/utils/mongo.util.js.map +0 -1
- package/dist/processor/utils/postgres.util.d.ts +0 -14
- package/dist/processor/utils/postgres.util.js +0 -83
- package/dist/processor/utils/postgres.util.js.map +0 -1
- package/dist/products/services/utils/crypt.utils.d.ts +0 -1
- package/dist/products/services/utils/crypt.utils.js +0 -17
- package/dist/products/services/utils/crypt.utils.js.map +0 -1
- package/dist/products/services/utils/functions.utils.d.ts +0 -13
- package/dist/products/services/utils/functions.utils.js +0 -289
- package/dist/products/services/utils/functions.utils.js.map +0 -1
- package/dist/products/services/utils/objects.utils.d.ts +0 -13
- package/dist/products/services/utils/objects.utils.js +0 -89
- package/dist/products/services/utils/objects.utils.js.map +0 -1
- package/dist/products/services/utils/string.utils.d.ts +0 -12
- package/dist/products/services/utils/string.utils.js +0 -168
- package/dist/products/services/utils/string.utils.js.map +0 -1
- package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
- package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
- package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +0 -1
- package/dist/test.appBuilder.js +0 -14
- package/dist/test.appBuilder.js.map +0 -1
- package/dist/test.import.d.ts +0 -0
- package/dist/test.import.js +0 -24
- package/dist/test.import.js.map +0 -1
- package/dist/test.imports.js +0 -28
- package/dist/test.imports.js.map +0 -1
- package/dist/test.integrationBuilder.js +0 -276
- package/dist/test.integrationBuilder.js.map +0 -1
- package/dist/test.processor.d.ts +0 -1
- package/dist/test.processor.js +0 -23
- package/dist/test.processor.js.map +0 -1
- package/dist/test.utils.d.ts +0 -1
- package/dist/test.utils.js +0 -25
- package/dist/test.utils.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/integrationsBuilder.types.d.ts +0 -276
- package/dist/types/integrationsBuilder.types.js +0 -51
- package/dist/types/integrationsBuilder.types.js.map +0 -1
- /package/dist/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
- /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
- /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Neo4j Graph
|
|
4
|
-
*
|
|
3
|
+
* Neo4j Graph Adapter
|
|
4
|
+
*
|
|
5
|
+
* Adapter implementation for Neo4j graph database
|
|
6
|
+
* Uses the official neo4j-driver package
|
|
5
7
|
*/
|
|
6
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
9
|
if (k2 === undefined) k2 = k;
|
|
@@ -38,1824 +40,1129 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
40
|
})();
|
|
39
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
42
|
exports.Neo4jAdapter = void 0;
|
|
41
|
-
const
|
|
43
|
+
const enums_1 = require("../types/enums");
|
|
42
44
|
const base_adapter_1 = require("./base.adapter");
|
|
43
|
-
const
|
|
44
|
-
const node_types_1 = require("../types/node.types");
|
|
45
|
-
const relationship_types_1 = require("../types/relationship.types");
|
|
46
|
-
const path_types_1 = require("../types/path.types");
|
|
45
|
+
const graph_error_1 = require("../utils/graph-error");
|
|
47
46
|
/**
|
|
48
|
-
* Neo4j
|
|
47
|
+
* Neo4j adapter implementation
|
|
49
48
|
*/
|
|
50
|
-
class
|
|
51
|
-
constructor(
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
|
|
49
|
+
class Neo4jAdapter extends base_adapter_1.BaseGraphAdapter {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(...arguments);
|
|
52
|
+
this.graphType = enums_1.GraphType.NEO4J;
|
|
53
|
+
this.supportedFeatures = new Set([
|
|
54
|
+
enums_1.GraphFeature.TRANSACTIONS,
|
|
55
|
+
enums_1.GraphFeature.SCHEMA_INDEXES,
|
|
56
|
+
enums_1.GraphFeature.FULL_TEXT_SEARCH,
|
|
57
|
+
enums_1.GraphFeature.GRAPH_ALGORITHMS,
|
|
58
|
+
enums_1.GraphFeature.GEOSPATIAL,
|
|
59
|
+
]);
|
|
56
60
|
this.driver = null;
|
|
57
61
|
this.session = null;
|
|
58
|
-
this.id = id || `neo4j-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
59
|
-
this.createdAt = new Date();
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (this.status === graph_types_1.GraphConnectionStatus.CONNECTED) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
this.status = graph_types_1.GraphConnectionStatus.CONNECTING;
|
|
63
|
+
// ==================== CONNECTION MANAGEMENT ====================
|
|
64
|
+
async connect(options) {
|
|
67
65
|
try {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
connectionTimeout: this.config.connectionTimeout || 30000,
|
|
73
|
-
};
|
|
74
|
-
if (this.config.maxConnectionLifetime) {
|
|
75
|
-
driverConfig.maxConnectionLifetime = this.config.maxConnectionLifetime;
|
|
76
|
-
}
|
|
77
|
-
if (this.config.encrypted !== undefined) {
|
|
78
|
-
driverConfig.encrypted = this.config.encrypted;
|
|
79
|
-
}
|
|
80
|
-
if (this.config.trust) {
|
|
81
|
-
driverConfig.trust = this.config.trust;
|
|
82
|
-
}
|
|
83
|
-
if (this.config.trustedCertificates) {
|
|
84
|
-
driverConfig.trustedCertificates = this.config.trustedCertificates;
|
|
85
|
-
}
|
|
86
|
-
if ((_a = this.config.options) === null || _a === void 0 ? void 0 : _a.logging) {
|
|
87
|
-
driverConfig.logging = this.config.options.logging;
|
|
88
|
-
}
|
|
89
|
-
this.driver = neo4j_driver_1.default.driver(this.config.uri, authToken, driverConfig);
|
|
90
|
-
// Verify connectivity
|
|
66
|
+
const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
|
|
67
|
+
this.driver = neo4j.driver(options.connectionUrl, neo4j.auth.basic('neo4j', 'password'), // TODO: Extract from URL or options
|
|
68
|
+
options.options);
|
|
69
|
+
// Verify connection
|
|
91
70
|
await this.driver.verifyConnectivity();
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
async disconnect() {
|
|
101
|
-
if (this.session) {
|
|
102
|
-
await this.session.close();
|
|
103
|
-
this.session = null;
|
|
104
|
-
}
|
|
105
|
-
if (this.driver) {
|
|
106
|
-
await this.driver.close();
|
|
107
|
-
this.driver = null;
|
|
108
|
-
}
|
|
109
|
-
this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
|
|
110
|
-
}
|
|
111
|
-
isConnected() {
|
|
112
|
-
return this.status === graph_types_1.GraphConnectionStatus.CONNECTED && this.driver !== null;
|
|
113
|
-
}
|
|
114
|
-
getClient() {
|
|
115
|
-
if (!this.driver) {
|
|
116
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Neo4j driver not initialized. Call connect() first.');
|
|
117
|
-
}
|
|
118
|
-
return this.driver;
|
|
119
|
-
}
|
|
120
|
-
getSession() {
|
|
121
|
-
if (!this.driver) {
|
|
122
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Neo4j driver not initialized. Call connect() first.');
|
|
123
|
-
}
|
|
124
|
-
const sessionConfig = {};
|
|
125
|
-
if (this.config.database) {
|
|
126
|
-
sessionConfig.database = this.config.database;
|
|
127
|
-
}
|
|
128
|
-
this.session = this.driver.session(sessionConfig);
|
|
129
|
-
this.lastUsedAt = new Date();
|
|
130
|
-
return this.session;
|
|
131
|
-
}
|
|
132
|
-
getDatabase() {
|
|
133
|
-
return this.config.database || 'neo4j';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Neo4j transaction implementation
|
|
138
|
-
*/
|
|
139
|
-
class Neo4jTransaction {
|
|
140
|
-
constructor(connection, session, transaction) {
|
|
141
|
-
this.connection = connection;
|
|
142
|
-
this.session = session;
|
|
143
|
-
this.status = graph_types_1.GraphTransactionStatus.PENDING;
|
|
144
|
-
this.id = `tx-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
145
|
-
this.createdAt = new Date();
|
|
146
|
-
this.native = transaction;
|
|
147
|
-
this.status = graph_types_1.GraphTransactionStatus.ACTIVE;
|
|
148
|
-
}
|
|
149
|
-
async commit() {
|
|
150
|
-
if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
|
|
151
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Cannot commit transaction in ${this.status} state`);
|
|
152
|
-
}
|
|
153
|
-
try {
|
|
154
|
-
await this.native.commit();
|
|
155
|
-
this.status = graph_types_1.GraphTransactionStatus.COMMITTED;
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
this.status = graph_types_1.GraphTransactionStatus.FAILED;
|
|
159
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to commit transaction: ${error.message}`, error);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async rollback() {
|
|
163
|
-
if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
try {
|
|
167
|
-
await this.native.rollback();
|
|
168
|
-
this.status = graph_types_1.GraphTransactionStatus.ROLLED_BACK;
|
|
71
|
+
this.connected = true;
|
|
72
|
+
this.connectionUrl = options.connectionUrl;
|
|
73
|
+
return {
|
|
74
|
+
connected: true,
|
|
75
|
+
type: enums_1.GraphType.NEO4J,
|
|
76
|
+
latency: 0,
|
|
77
|
+
};
|
|
169
78
|
}
|
|
170
79
|
catch (error) {
|
|
171
|
-
this.
|
|
172
|
-
throw
|
|
80
|
+
this.connected = false;
|
|
81
|
+
throw graph_error_1.GraphError.connectionError(`Failed to connect to Neo4j: ${error.message}`, error);
|
|
173
82
|
}
|
|
174
83
|
}
|
|
175
|
-
|
|
176
|
-
return this.status === graph_types_1.GraphTransactionStatus.ACTIVE;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Neo4j Graph Database Adapter
|
|
181
|
-
*/
|
|
182
|
-
class Neo4jAdapter extends base_adapter_1.BaseGraphAdapter {
|
|
183
|
-
constructor() {
|
|
184
|
-
super(...arguments);
|
|
185
|
-
this.type = graph_types_1.GraphDatabaseType.NEO4J;
|
|
186
|
-
this.supportedLanguages = [graph_types_1.GraphQueryLanguage.CYPHER];
|
|
187
|
-
this.defaultLanguage = graph_types_1.GraphQueryLanguage.CYPHER;
|
|
188
|
-
}
|
|
189
|
-
// ==================== CONNECTION METHODS ====================
|
|
190
|
-
async connect(config) {
|
|
191
|
-
if (config.type !== graph_types_1.GraphDatabaseType.NEO4J) {
|
|
192
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Invalid config type ${config.type}. Expected ${graph_types_1.GraphDatabaseType.NEO4J}`);
|
|
193
|
-
}
|
|
194
|
-
const connection = new Neo4jConnection(config);
|
|
195
|
-
await connection.connect();
|
|
196
|
-
return connection;
|
|
197
|
-
}
|
|
198
|
-
async disconnect(connection) {
|
|
199
|
-
await connection.disconnect();
|
|
200
|
-
}
|
|
201
|
-
async testConnection(connection) {
|
|
84
|
+
async testConnection(options) {
|
|
202
85
|
var _a;
|
|
203
|
-
const startTime = Date.now();
|
|
204
86
|
try {
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const serverInfo = await
|
|
87
|
+
const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
|
|
88
|
+
const startTime = Date.now();
|
|
89
|
+
const testDriver = neo4j.driver(options.connectionUrl, neo4j.auth.basic('neo4j', 'password'), Object.assign(Object.assign({}, options.options), { connectionTimeout: 5000 }));
|
|
90
|
+
await testDriver.verifyConnectivity();
|
|
91
|
+
const serverInfo = await testDriver.getServerInfo();
|
|
92
|
+
await testDriver.close();
|
|
210
93
|
return {
|
|
211
94
|
connected: true,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
version: (_a = serverInfo.protocolVersion) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
216
|
-
responseTime: Date.now() - startTime,
|
|
95
|
+
type: enums_1.GraphType.NEO4J,
|
|
96
|
+
version: (_a = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.protocolVersion) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
97
|
+
latency: Date.now() - startTime,
|
|
217
98
|
};
|
|
218
99
|
}
|
|
219
100
|
catch (error) {
|
|
220
101
|
return {
|
|
221
102
|
connected: false,
|
|
222
|
-
|
|
223
|
-
databaseType: graph_types_1.GraphDatabaseType.NEO4J,
|
|
224
|
-
queryLanguage: graph_types_1.GraphQueryLanguage.CYPHER,
|
|
225
|
-
responseTime: Date.now() - startTime,
|
|
103
|
+
type: enums_1.GraphType.NEO4J,
|
|
226
104
|
error: error.message,
|
|
227
105
|
};
|
|
228
106
|
}
|
|
229
107
|
}
|
|
230
|
-
async
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const record = result.records[0];
|
|
235
|
-
return {
|
|
236
|
-
version: record.get('versions')[0],
|
|
237
|
-
edition: record.get('edition'),
|
|
238
|
-
features: [],
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
finally {
|
|
242
|
-
await session.close();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
// ==================== TRANSACTION METHODS ====================
|
|
246
|
-
async beginTransaction(connection, options) {
|
|
247
|
-
const session = connection.getSession();
|
|
248
|
-
const txConfig = {};
|
|
249
|
-
if (options === null || options === void 0 ? void 0 : options.timeout) {
|
|
250
|
-
txConfig.timeout = (0, neo4j_driver_1.int)(options.timeout);
|
|
108
|
+
async disconnect() {
|
|
109
|
+
if (this.session) {
|
|
110
|
+
await this.session.close();
|
|
111
|
+
this.session = null;
|
|
251
112
|
}
|
|
252
|
-
if (
|
|
253
|
-
|
|
113
|
+
if (this.driver) {
|
|
114
|
+
await this.driver.close();
|
|
115
|
+
this.driver = null;
|
|
254
116
|
}
|
|
255
|
-
|
|
256
|
-
? neo4j_driver_1.default.session.READ
|
|
257
|
-
: neo4j_driver_1.default.session.WRITE;
|
|
258
|
-
const transaction = session.beginTransaction(txConfig);
|
|
259
|
-
return new Neo4jTransaction(connection, session, transaction);
|
|
117
|
+
this.connected = false;
|
|
260
118
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
async rollbackTransaction(connection, transaction) {
|
|
265
|
-
await transaction.rollback();
|
|
266
|
-
}
|
|
267
|
-
// ==================== RAW QUERY METHODS ====================
|
|
268
|
-
async executeRaw(connection, options, transaction) {
|
|
269
|
-
const startTime = Date.now();
|
|
270
|
-
try {
|
|
271
|
-
let result;
|
|
272
|
-
if (transaction && transaction.isActive()) {
|
|
273
|
-
result = await transaction.native.run(options.query, options.params || {});
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
const session = connection.getSession();
|
|
277
|
-
try {
|
|
278
|
-
result = await session.run(options.query, options.params || {});
|
|
279
|
-
}
|
|
280
|
-
finally {
|
|
281
|
-
await session.close();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const records = result.records.map((record) => {
|
|
285
|
-
const obj = {};
|
|
286
|
-
record.keys.forEach((key) => {
|
|
287
|
-
obj[key] = this.convertNeo4jValue(record.get(key));
|
|
288
|
-
});
|
|
289
|
-
return obj;
|
|
290
|
-
});
|
|
291
|
-
return {
|
|
292
|
-
success: true,
|
|
293
|
-
executionTime: Date.now() - startTime,
|
|
294
|
-
data: records,
|
|
295
|
-
columns: result.records.length > 0 ? result.records[0].keys.map(k => String(k)) : [],
|
|
296
|
-
count: records.length,
|
|
297
|
-
statistics: this.parseStatistics(result.summary.counters),
|
|
298
|
-
};
|
|
119
|
+
getSession(transaction) {
|
|
120
|
+
if (transaction === null || transaction === void 0 ? void 0 : transaction.client) {
|
|
121
|
+
return transaction.client;
|
|
299
122
|
}
|
|
300
|
-
|
|
301
|
-
|
|
123
|
+
if (!this.session) {
|
|
124
|
+
this.session = this.driver.session();
|
|
302
125
|
}
|
|
126
|
+
return this.session;
|
|
303
127
|
}
|
|
304
128
|
// ==================== NODE OPERATIONS ====================
|
|
305
|
-
async createNode(
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
executionTime: Date.now() - startTime,
|
|
317
|
-
node,
|
|
318
|
-
created: true,
|
|
319
|
-
statistics: result.statistics,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
catch (error) {
|
|
323
|
-
if (options.onConflict === 'ignore') {
|
|
324
|
-
return {
|
|
325
|
-
success: true,
|
|
326
|
-
executionTime: Date.now() - startTime,
|
|
327
|
-
created: false,
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
throw error;
|
|
331
|
-
}
|
|
129
|
+
async createNode(options, transaction) {
|
|
130
|
+
const labels = options.labels.join(':');
|
|
131
|
+
const query = `CREATE (n:${labels} $props) RETURN n`;
|
|
132
|
+
const session = this.getSession(transaction);
|
|
133
|
+
const result = await session.run(query, { props: options.properties });
|
|
134
|
+
const record = result.records[0];
|
|
135
|
+
const node = record.get('n');
|
|
136
|
+
return {
|
|
137
|
+
node: this.mapNeo4jNode(node),
|
|
138
|
+
created: true,
|
|
139
|
+
};
|
|
332
140
|
}
|
|
333
|
-
async findNodes(
|
|
334
|
-
|
|
335
|
-
const labels = options.labels ?
|
|
336
|
-
const
|
|
337
|
-
let query = `MATCH (n${
|
|
141
|
+
async findNodes(options, transaction) {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
144
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
145
|
+
let query = `MATCH (n${labelClause})`;
|
|
338
146
|
const params = {};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
|
|
344
|
-
whereParts.push(clause);
|
|
345
|
-
Object.assign(params, whereParams);
|
|
346
|
-
}
|
|
347
|
-
if (options.properties) {
|
|
348
|
-
Object.entries(options.properties).forEach(([key, value], index) => {
|
|
349
|
-
const paramName = `prop_${index}`;
|
|
350
|
-
whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
351
|
-
params[paramName] = value;
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
if (whereParts.length > 0) {
|
|
355
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
// Return specific properties or entire node
|
|
359
|
-
if (options.returnProperties && options.returnProperties.length > 0) {
|
|
360
|
-
const props = options.returnProperties.map(p => `n.${this.escapeIdentifier(p)} AS ${p}`).join(', ');
|
|
361
|
-
query += ` RETURN ${props}`;
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
query += ` RETURN n`;
|
|
147
|
+
if (options.where) {
|
|
148
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
|
|
149
|
+
query += ` WHERE ${clause}`;
|
|
150
|
+
Object.assign(params, whereParams);
|
|
365
151
|
}
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
const
|
|
369
|
-
query += ` ORDER BY ${
|
|
152
|
+
query += ' RETURN n';
|
|
153
|
+
if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
|
|
154
|
+
const orderClauses = options.orderBy.map(o => `n.${o.property} ${o.direction.toUpperCase()}`);
|
|
155
|
+
query += ` ORDER BY ${orderClauses.join(', ')}`;
|
|
370
156
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
query += ` SKIP ${options.skip}`;
|
|
157
|
+
if (options.offset) {
|
|
158
|
+
query += ` SKIP ${options.offset}`;
|
|
374
159
|
}
|
|
375
|
-
if (options.limit
|
|
160
|
+
if (options.limit) {
|
|
376
161
|
query += ` LIMIT ${options.limit}`;
|
|
377
162
|
}
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
// Reconstruct node from properties
|
|
382
|
-
return {
|
|
383
|
-
id: '',
|
|
384
|
-
labels: [],
|
|
385
|
-
properties: row,
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
return this.parseNode(row.n);
|
|
389
|
-
});
|
|
163
|
+
const session = this.getSession(transaction);
|
|
164
|
+
const result = await session.run(query, params);
|
|
165
|
+
const nodes = result.records.map((record) => this.mapNeo4jNode(record.get('n')));
|
|
390
166
|
return {
|
|
391
|
-
success: true,
|
|
392
|
-
executionTime: Date.now() - startTime,
|
|
393
167
|
nodes,
|
|
394
168
|
count: nodes.length,
|
|
395
|
-
hasMore: options.limit !== undefined && nodes.length === options.limit,
|
|
396
169
|
};
|
|
397
170
|
}
|
|
398
|
-
async findNodeById(
|
|
399
|
-
const query =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
171
|
+
async findNodeById(id, transaction) {
|
|
172
|
+
const query = `MATCH (n) WHERE elementId(n) = $id OR id(n) = $idNum RETURN n`;
|
|
173
|
+
const session = this.getSession(transaction);
|
|
174
|
+
const result = await session.run(query, {
|
|
175
|
+
id: String(id),
|
|
176
|
+
idNum: typeof id === 'number' ? id : parseInt(id, 10) || -1
|
|
177
|
+
});
|
|
178
|
+
if (result.records.length === 0) {
|
|
404
179
|
return null;
|
|
405
180
|
}
|
|
406
|
-
return this.
|
|
181
|
+
return this.mapNeo4jNode(result.records[0].get('n'));
|
|
407
182
|
}
|
|
408
|
-
async updateNode(
|
|
183
|
+
async updateNode(options, transaction) {
|
|
409
184
|
var _a;
|
|
410
|
-
|
|
411
|
-
const params = {};
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
matchClause = 'MATCH (n) WHERE elementId(n) = $nodeId';
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
matchClause = 'MATCH (n) WHERE id(n) = $nodeId';
|
|
420
|
-
}
|
|
421
|
-
params.nodeId = options.id;
|
|
422
|
-
}
|
|
423
|
-
else if (options.labels) {
|
|
424
|
-
const labels = this.normalizeLabels(options.labels);
|
|
425
|
-
matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
|
|
426
|
-
}
|
|
427
|
-
// Add WHERE clause
|
|
428
|
-
if (options.where) {
|
|
429
|
-
const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
|
|
430
|
-
matchClause += options.id === undefined && !options.labels ? ` WHERE ${clause}` : ` AND ${clause}`;
|
|
431
|
-
Object.assign(params, whereParams);
|
|
432
|
-
}
|
|
433
|
-
const setParts = [];
|
|
434
|
-
const removeParts = [];
|
|
435
|
-
// SET properties
|
|
436
|
-
if (options.set) {
|
|
437
|
-
Object.entries(options.set).forEach(([key, value], index) => {
|
|
438
|
-
const paramName = `set_${index}`;
|
|
439
|
-
setParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
440
|
-
params[paramName] = value;
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
// Add labels
|
|
444
|
-
if (options.addLabels && options.addLabels.length > 0) {
|
|
445
|
-
setParts.push(`n:${options.addLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
|
|
446
|
-
}
|
|
447
|
-
// REMOVE properties
|
|
448
|
-
if (options.remove && options.remove.length > 0) {
|
|
449
|
-
options.remove.forEach(prop => {
|
|
450
|
-
removeParts.push(`n.${this.escapeIdentifier(prop)}`);
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
// Remove labels
|
|
454
|
-
if (options.removeLabels && options.removeLabels.length > 0) {
|
|
455
|
-
removeParts.push(`n:${options.removeLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
|
|
456
|
-
}
|
|
457
|
-
let query = matchClause;
|
|
458
|
-
if (setParts.length > 0) {
|
|
459
|
-
query += ` SET ${setParts.join(', ')}`;
|
|
185
|
+
let query;
|
|
186
|
+
const params = { props: options.properties };
|
|
187
|
+
if (options.id) {
|
|
188
|
+
query = `MATCH (n) WHERE elementId(n) = $id OR id(n) = $idNum SET n += $props RETURN n`;
|
|
189
|
+
params.id = String(options.id);
|
|
190
|
+
params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
|
|
460
191
|
}
|
|
461
|
-
|
|
462
|
-
|
|
192
|
+
else {
|
|
193
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
194
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
195
|
+
query = `MATCH (n${labelClause})`;
|
|
196
|
+
if (options.where) {
|
|
197
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
|
|
198
|
+
query += ` WHERE ${clause}`;
|
|
199
|
+
Object.assign(params, whereParams);
|
|
200
|
+
}
|
|
201
|
+
query += ' SET n += $props RETURN n';
|
|
463
202
|
}
|
|
464
|
-
|
|
465
|
-
const result = await
|
|
203
|
+
const session = this.getSession(transaction);
|
|
204
|
+
const result = await session.run(query, params);
|
|
205
|
+
const nodes = result.records.map((record) => this.mapNeo4jNode(record.get('n')));
|
|
466
206
|
return {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
updated: result.data.length > 0,
|
|
471
|
-
matchedCount: result.data.length,
|
|
472
|
-
modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
|
|
473
|
-
statistics: result.statistics,
|
|
207
|
+
node: nodes.length === 1 ? nodes[0] : undefined,
|
|
208
|
+
nodes: nodes.length > 1 ? nodes : undefined,
|
|
209
|
+
updatedCount: nodes.length,
|
|
474
210
|
};
|
|
475
211
|
}
|
|
476
|
-
async deleteNode(
|
|
477
|
-
var _a, _b;
|
|
478
|
-
|
|
212
|
+
async deleteNode(options, transaction) {
|
|
213
|
+
var _a, _b, _c;
|
|
214
|
+
let query;
|
|
479
215
|
const params = {};
|
|
480
|
-
|
|
481
|
-
if (options.id
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
else {
|
|
486
|
-
matchClause = 'MATCH (n) WHERE id(n) = $nodeId';
|
|
487
|
-
}
|
|
488
|
-
params.nodeId = options.id;
|
|
216
|
+
const detach = options.detach ? 'DETACH ' : '';
|
|
217
|
+
if (options.id) {
|
|
218
|
+
query = `MATCH (n) WHERE elementId(n) = $id OR id(n) = $idNum ${detach}DELETE n RETURN count(n) as count`;
|
|
219
|
+
params.id = String(options.id);
|
|
220
|
+
params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
|
|
489
221
|
}
|
|
490
|
-
else
|
|
491
|
-
const labels =
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
222
|
+
else {
|
|
223
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
224
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
225
|
+
query = `MATCH (n${labelClause})`;
|
|
226
|
+
if (options.where) {
|
|
227
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
|
|
228
|
+
query += ` WHERE ${clause}`;
|
|
229
|
+
Object.assign(params, whereParams);
|
|
230
|
+
}
|
|
231
|
+
query += ` ${detach}DELETE n RETURN count(n) as count`;
|
|
498
232
|
}
|
|
499
|
-
const
|
|
500
|
-
const
|
|
501
|
-
const
|
|
233
|
+
const session = this.getSession(transaction);
|
|
234
|
+
const result = await session.run(query, params);
|
|
235
|
+
const count = ((_c = (_b = result.records[0]) === null || _b === void 0 ? void 0 : _b.get('count')) === null || _c === void 0 ? void 0 : _c.toNumber()) || 0;
|
|
502
236
|
return {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesDeleted) || 0,
|
|
506
|
-
deletedRelationshipsCount: ((_b = result.statistics) === null || _b === void 0 ? void 0 : _b.relationshipsDeleted) || 0,
|
|
507
|
-
statistics: result.statistics,
|
|
237
|
+
deleted: count > 0,
|
|
238
|
+
deletedCount: count,
|
|
508
239
|
};
|
|
509
240
|
}
|
|
510
|
-
async mergeNode(
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
241
|
+
async mergeNode(options, transaction) {
|
|
242
|
+
const labels = options.labels.join(':');
|
|
243
|
+
const matchProps = Object.entries(options.matchProperties)
|
|
244
|
+
.map(([key]) => `${key}: $match_${key}`)
|
|
245
|
+
.join(', ');
|
|
246
|
+
let query = `MERGE (n:${labels} {${matchProps}})`;
|
|
515
247
|
const params = {};
|
|
516
|
-
|
|
517
|
-
Object.entries(options.matchProperties).forEach(([key, value]
|
|
518
|
-
|
|
519
|
-
matchProps.push(`${this.escapeIdentifier(key)}: $${paramName}`);
|
|
520
|
-
params[paramName] = value;
|
|
248
|
+
// Add match properties to params
|
|
249
|
+
Object.entries(options.matchProperties).forEach(([key, value]) => {
|
|
250
|
+
params[`match_${key}`] = value;
|
|
521
251
|
});
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const paramName = `match_set_${index}`;
|
|
536
|
-
matchSetProps.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
537
|
-
params[paramName] = value;
|
|
538
|
-
});
|
|
539
|
-
query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
|
|
540
|
-
}
|
|
541
|
-
query += ' RETURN n';
|
|
542
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
543
|
-
const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesCreated) || 0) > 0;
|
|
252
|
+
if (options.onCreate) {
|
|
253
|
+
query += ' ON CREATE SET n += $onCreateProps';
|
|
254
|
+
params.onCreateProps = options.onCreate;
|
|
255
|
+
}
|
|
256
|
+
if (options.onMatch) {
|
|
257
|
+
query += ' ON MATCH SET n += $onMatchProps';
|
|
258
|
+
params.onMatchProps = options.onMatch;
|
|
259
|
+
}
|
|
260
|
+
query += ' RETURN n, EXISTS((n)--()) as existed';
|
|
261
|
+
const session = this.getSession(transaction);
|
|
262
|
+
const result = await session.run(query, params);
|
|
263
|
+
const record = result.records[0];
|
|
264
|
+
const node = this.mapNeo4jNode(record.get('n'));
|
|
544
265
|
return {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
|
|
548
|
-
created,
|
|
549
|
-
matched: !created,
|
|
550
|
-
statistics: result.statistics,
|
|
266
|
+
node,
|
|
267
|
+
created: !record.get('existed'),
|
|
551
268
|
};
|
|
552
269
|
}
|
|
553
|
-
// ====================
|
|
554
|
-
async
|
|
555
|
-
|
|
556
|
-
const startTime = Date.now();
|
|
557
|
-
const params = {};
|
|
558
|
-
const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
|
|
559
|
-
const toMatch = this.buildNodeReference(options.toNode, 'to', params);
|
|
560
|
-
let propsClause = '';
|
|
561
|
-
if (options.properties && Object.keys(options.properties).length > 0) {
|
|
562
|
-
const { clause, params: propParams } = this.buildPropertiesClause(options.properties, 'rel_');
|
|
563
|
-
propsClause = ` ${clause}`;
|
|
564
|
-
Object.assign(params, propParams);
|
|
565
|
-
}
|
|
270
|
+
// ==================== LABEL MANAGEMENT ====================
|
|
271
|
+
async addLabels(options, transaction) {
|
|
272
|
+
const labels = options.labels.map(l => `:\`${l}\``).join('');
|
|
566
273
|
const query = `
|
|
567
|
-
MATCH
|
|
568
|
-
|
|
569
|
-
|
|
274
|
+
MATCH (n)
|
|
275
|
+
WHERE elementId(n) = $id OR id(n) = $idNum
|
|
276
|
+
SET n${labels}
|
|
277
|
+
RETURN n, labels(n) as newLabels
|
|
570
278
|
`;
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
executionTime: Date.now() - startTime,
|
|
575
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
|
|
576
|
-
created: (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0,
|
|
577
|
-
statistics: result.statistics,
|
|
279
|
+
const params = {
|
|
280
|
+
id: String(options.id),
|
|
281
|
+
idNum: typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1,
|
|
578
282
|
};
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
// Build relationship type pattern
|
|
584
|
-
let typePattern = '';
|
|
585
|
-
if (options.type) {
|
|
586
|
-
const types = Array.isArray(options.type) ? options.type : [options.type];
|
|
587
|
-
typePattern = ':' + types.map(t => this.escapeIdentifier(t)).join('|');
|
|
588
|
-
}
|
|
589
|
-
// Build direction pattern
|
|
590
|
-
const directionStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
591
|
-
const directionEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
592
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
593
|
-
let query = `MATCH (from)${directionStart}[r${typePattern}]${directionEnd}(to)`;
|
|
594
|
-
const whereParts = [];
|
|
595
|
-
// From node filter
|
|
596
|
-
if (options.fromNode) {
|
|
597
|
-
const fromWhere = this.buildNodeReferenceWhere(options.fromNode, 'from', params, 'from_');
|
|
598
|
-
if (fromWhere)
|
|
599
|
-
whereParts.push(fromWhere);
|
|
600
|
-
}
|
|
601
|
-
// To node filter
|
|
602
|
-
if (options.toNode) {
|
|
603
|
-
const toWhere = this.buildNodeReferenceWhere(options.toNode, 'to', params, 'to_');
|
|
604
|
-
if (toWhere)
|
|
605
|
-
whereParts.push(toWhere);
|
|
606
|
-
}
|
|
607
|
-
// Relationship properties filter
|
|
608
|
-
if (options.where) {
|
|
609
|
-
const { clause, params: whereParams } = this.buildRelationshipWhereClause(options.where, 'r');
|
|
610
|
-
whereParts.push(clause);
|
|
611
|
-
Object.assign(params, whereParams);
|
|
612
|
-
}
|
|
613
|
-
if (options.properties) {
|
|
614
|
-
Object.entries(options.properties).forEach(([key, value], index) => {
|
|
615
|
-
const paramName = `rel_prop_${index}`;
|
|
616
|
-
whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
617
|
-
params[paramName] = value;
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
if (whereParts.length > 0) {
|
|
621
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
622
|
-
}
|
|
623
|
-
// Return clause
|
|
624
|
-
if (options.includeNodes) {
|
|
625
|
-
query += ' RETURN r, from, to';
|
|
283
|
+
const session = this.getSession(transaction);
|
|
284
|
+
const result = await session.run(query, params);
|
|
285
|
+
if (result.records.length === 0) {
|
|
286
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
626
287
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
// ORDER BY
|
|
631
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
632
|
-
const orderParts = options.orderBy.map(o => `r.${this.escapeIdentifier(o.property)} ${o.direction}`);
|
|
633
|
-
query += ` ORDER BY ${orderParts.join(', ')}`;
|
|
634
|
-
}
|
|
635
|
-
// SKIP and LIMIT
|
|
636
|
-
if (options.skip !== undefined) {
|
|
637
|
-
query += ` SKIP ${options.skip}`;
|
|
638
|
-
}
|
|
639
|
-
if (options.limit !== undefined) {
|
|
640
|
-
query += ` LIMIT ${options.limit}`;
|
|
641
|
-
}
|
|
642
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
643
|
-
const relationships = result.data.map(row => this.parseRelationship(row.r));
|
|
288
|
+
const record = result.records[0];
|
|
289
|
+
const node = this.mapNeo4jNode(record.get('n'));
|
|
644
290
|
return {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
relationships,
|
|
648
|
-
count: relationships.length,
|
|
649
|
-
hasMore: options.limit !== undefined && relationships.length === options.limit,
|
|
291
|
+
node,
|
|
292
|
+
addedLabels: options.labels,
|
|
650
293
|
};
|
|
651
294
|
}
|
|
652
|
-
async
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
if (typeof options.id === 'string') {
|
|
669
|
-
matchClause = 'MATCH ()-[r]->() WHERE elementId(r) = $relId';
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
matchClause = 'MATCH ()-[r]->() WHERE id(r) = $relId';
|
|
673
|
-
}
|
|
674
|
-
params.relId = options.id;
|
|
675
|
-
}
|
|
676
|
-
else if (options.type) {
|
|
677
|
-
matchClause = `MATCH ()-[r:${this.escapeIdentifier(options.type)}]->()`;
|
|
678
|
-
}
|
|
679
|
-
if (options.where) {
|
|
680
|
-
const { clause, params: whereParams } = this.buildRelationshipWhereClause(options.where, 'r');
|
|
681
|
-
matchClause += options.id === undefined && !options.type ? ` WHERE ${clause}` : ` AND ${clause}`;
|
|
682
|
-
Object.assign(params, whereParams);
|
|
683
|
-
}
|
|
684
|
-
const setParts = [];
|
|
685
|
-
const removeParts = [];
|
|
686
|
-
if (options.set) {
|
|
687
|
-
Object.entries(options.set).forEach(([key, value], index) => {
|
|
688
|
-
const paramName = `set_${index}`;
|
|
689
|
-
setParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
690
|
-
params[paramName] = value;
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
if (options.remove && options.remove.length > 0) {
|
|
694
|
-
options.remove.forEach(prop => {
|
|
695
|
-
removeParts.push(`r.${this.escapeIdentifier(prop)}`);
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
let query = matchClause;
|
|
699
|
-
if (setParts.length > 0) {
|
|
700
|
-
query += ` SET ${setParts.join(', ')}`;
|
|
701
|
-
}
|
|
702
|
-
if (removeParts.length > 0) {
|
|
703
|
-
query += ` REMOVE ${removeParts.join(', ')}`;
|
|
295
|
+
async removeLabels(options, transaction) {
|
|
296
|
+
const labels = options.labels.map(l => `:\`${l}\``).join('');
|
|
297
|
+
const query = `
|
|
298
|
+
MATCH (n)
|
|
299
|
+
WHERE elementId(n) = $id OR id(n) = $idNum
|
|
300
|
+
REMOVE n${labels}
|
|
301
|
+
RETURN n, labels(n) as newLabels
|
|
302
|
+
`;
|
|
303
|
+
const params = {
|
|
304
|
+
id: String(options.id),
|
|
305
|
+
idNum: typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1,
|
|
306
|
+
};
|
|
307
|
+
const session = this.getSession(transaction);
|
|
308
|
+
const result = await session.run(query, params);
|
|
309
|
+
if (result.records.length === 0) {
|
|
310
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
704
311
|
}
|
|
705
|
-
|
|
706
|
-
const
|
|
312
|
+
const record = result.records[0];
|
|
313
|
+
const node = this.mapNeo4jNode(record.get('n'));
|
|
707
314
|
return {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
|
|
711
|
-
updated: result.data.length > 0,
|
|
712
|
-
matchedCount: result.data.length,
|
|
713
|
-
modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
|
|
714
|
-
statistics: result.statistics,
|
|
315
|
+
node,
|
|
316
|
+
removedLabels: options.labels,
|
|
715
317
|
};
|
|
716
318
|
}
|
|
717
|
-
async
|
|
718
|
-
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
319
|
+
async setLabels(options, transaction) {
|
|
320
|
+
// First get current labels
|
|
321
|
+
const getQuery = `
|
|
322
|
+
MATCH (n)
|
|
323
|
+
WHERE elementId(n) = $id OR id(n) = $idNum
|
|
324
|
+
RETURN labels(n) as currentLabels
|
|
325
|
+
`;
|
|
326
|
+
const params = {
|
|
327
|
+
id: String(options.id),
|
|
328
|
+
idNum: typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1,
|
|
329
|
+
};
|
|
330
|
+
const session = this.getSession(transaction);
|
|
331
|
+
const getResult = await session.run(getQuery, params);
|
|
332
|
+
if (getResult.records.length === 0) {
|
|
333
|
+
throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
|
|
334
|
+
}
|
|
335
|
+
const previousLabels = getResult.records[0].get('currentLabels');
|
|
336
|
+
// Remove all existing labels and add new ones
|
|
337
|
+
const removeLabels = previousLabels.map(l => `:\`${l}\``).join('');
|
|
338
|
+
const addLabels = options.labels.map(l => `:\`${l}\``).join('');
|
|
339
|
+
const setQuery = `
|
|
340
|
+
MATCH (n)
|
|
341
|
+
WHERE elementId(n) = $id OR id(n) = $idNum
|
|
342
|
+
REMOVE n${removeLabels}
|
|
343
|
+
SET n${addLabels}
|
|
344
|
+
RETURN n
|
|
345
|
+
`;
|
|
346
|
+
const result = await session.run(setQuery, params);
|
|
347
|
+
const node = this.mapNeo4jNode(result.records[0].get('n'));
|
|
742
348
|
return {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
statistics: result.statistics,
|
|
349
|
+
node,
|
|
350
|
+
previousLabels,
|
|
351
|
+
newLabels: options.labels,
|
|
747
352
|
};
|
|
748
353
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
const { clause, params: matchParams } = this.buildPropertiesClause(options.matchProperties, 'match_');
|
|
758
|
-
matchPropsClause = ` ${clause}`;
|
|
759
|
-
Object.assign(params, matchParams);
|
|
760
|
-
}
|
|
761
|
-
let query = `
|
|
762
|
-
MATCH ${fromMatch}, ${toMatch}
|
|
763
|
-
MERGE (from)-[r:${this.escapeIdentifier(options.type)}${matchPropsClause}]->(to)
|
|
354
|
+
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
355
|
+
async createRelationship(options, transaction) {
|
|
356
|
+
const query = `
|
|
357
|
+
MATCH (a), (b)
|
|
358
|
+
WHERE (elementId(a) = $startId OR id(a) = $startIdNum)
|
|
359
|
+
AND (elementId(b) = $endId OR id(b) = $endIdNum)
|
|
360
|
+
CREATE (a)-[r:${options.type} $props]->(b)
|
|
361
|
+
RETURN r, elementId(a) as startId, elementId(b) as endId
|
|
764
362
|
`;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
Object.entries(options.onMatch).forEach(([key, value], index) => {
|
|
777
|
-
const paramName = `match_set_${index}`;
|
|
778
|
-
matchSetProps.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
779
|
-
params[paramName] = value;
|
|
780
|
-
});
|
|
781
|
-
query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
|
|
782
|
-
}
|
|
783
|
-
query += ' RETURN r';
|
|
784
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
785
|
-
const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0;
|
|
363
|
+
const params = {
|
|
364
|
+
startId: String(options.startNodeId),
|
|
365
|
+
startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
|
|
366
|
+
endId: String(options.endNodeId),
|
|
367
|
+
endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
|
|
368
|
+
props: options.properties || {},
|
|
369
|
+
};
|
|
370
|
+
const session = this.getSession(transaction);
|
|
371
|
+
const result = await session.run(query, params);
|
|
372
|
+
const record = result.records[0];
|
|
373
|
+
const rel = record.get('r');
|
|
786
374
|
return {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
|
|
790
|
-
created,
|
|
791
|
-
matched: !created,
|
|
792
|
-
statistics: result.statistics,
|
|
375
|
+
relationship: this.mapNeo4jRelationship(rel, record.get('startId'), record.get('endId')),
|
|
376
|
+
created: true,
|
|
793
377
|
};
|
|
794
378
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
379
|
+
async findRelationships(options, transaction) {
|
|
380
|
+
const types = options.type
|
|
381
|
+
? (Array.isArray(options.type) ? options.type.join('|') : options.type)
|
|
382
|
+
: '';
|
|
383
|
+
const typeClause = types ? `:${types}` : '';
|
|
384
|
+
let query = `MATCH (a)-[r${typeClause}]->(b)`;
|
|
798
385
|
const params = {};
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
const depthPattern = minDepth === maxDepth ? `*${minDepth}` : `*${minDepth}..${maxDepth}`;
|
|
805
|
-
// Build direction
|
|
806
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
807
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
808
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
809
|
-
let query = `
|
|
810
|
-
MATCH ${startNodeMatch}
|
|
811
|
-
MATCH path = (start)${dirStart}[${relPattern}${depthPattern}]${dirEnd}(end)
|
|
812
|
-
`;
|
|
813
|
-
// Add filters
|
|
814
|
-
if (options.filters) {
|
|
815
|
-
const filterParts = [];
|
|
816
|
-
if (options.filters.nodeLabels && options.filters.nodeLabels.length > 0) {
|
|
817
|
-
const labelConditions = options.filters.nodeLabels
|
|
818
|
-
.map(l => `'${l}' IN labels(end)`)
|
|
819
|
-
.join(' OR ');
|
|
820
|
-
filterParts.push(`(${labelConditions})`);
|
|
821
|
-
}
|
|
822
|
-
if (options.filters.stopAtLabels && options.filters.stopAtLabels.length > 0) {
|
|
823
|
-
const stopConditions = options.filters.stopAtLabels
|
|
824
|
-
.map(l => `NOT '${l}' IN labels(end)`)
|
|
825
|
-
.join(' AND ');
|
|
826
|
-
filterParts.push(`(${stopConditions})`);
|
|
827
|
-
}
|
|
828
|
-
if (filterParts.length > 0) {
|
|
829
|
-
query += ` WHERE ${filterParts.join(' AND ')}`;
|
|
830
|
-
}
|
|
386
|
+
const conditions = [];
|
|
387
|
+
if (options.startNodeId) {
|
|
388
|
+
conditions.push('(elementId(a) = $startId OR id(a) = $startIdNum)');
|
|
389
|
+
params.startId = String(options.startNodeId);
|
|
390
|
+
params.startIdNum = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1;
|
|
831
391
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
392
|
+
if (options.endNodeId) {
|
|
393
|
+
conditions.push('(elementId(b) = $endId OR id(b) = $endIdNum)');
|
|
394
|
+
params.endId = String(options.endNodeId);
|
|
395
|
+
params.endIdNum = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1;
|
|
836
396
|
}
|
|
837
|
-
if (options.
|
|
838
|
-
|
|
397
|
+
if (options.where) {
|
|
398
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
|
|
399
|
+
conditions.push(clause);
|
|
400
|
+
Object.assign(params, whereParams);
|
|
401
|
+
}
|
|
402
|
+
if (conditions.length > 0) {
|
|
403
|
+
query += ` WHERE ${conditions.join(' AND ')}`;
|
|
839
404
|
}
|
|
840
|
-
|
|
841
|
-
|
|
405
|
+
query += ' RETURN r, elementId(a) as startId, elementId(b) as endId';
|
|
406
|
+
if (options.offset) {
|
|
407
|
+
query += ` SKIP ${options.offset}`;
|
|
842
408
|
}
|
|
843
|
-
query += ` RETURN ${returnParts.join(', ')}`;
|
|
844
409
|
if (options.limit) {
|
|
845
410
|
query += ` LIMIT ${options.limit}`;
|
|
846
411
|
}
|
|
847
|
-
const
|
|
848
|
-
const
|
|
849
|
-
const
|
|
850
|
-
const relsSet = new Map();
|
|
851
|
-
result.data.forEach(row => {
|
|
852
|
-
if (row.path) {
|
|
853
|
-
const parsedPath = this.parsePath(row.path);
|
|
854
|
-
paths.push(parsedPath);
|
|
855
|
-
parsedPath.nodes.forEach(n => nodesSet.set(String(n.id), n));
|
|
856
|
-
parsedPath.relationships.forEach(r => relsSet.set(String(r.id), r));
|
|
857
|
-
}
|
|
858
|
-
if (row.nodes) {
|
|
859
|
-
row.nodes.forEach((n) => {
|
|
860
|
-
const parsed = this.parseNode(n);
|
|
861
|
-
nodesSet.set(String(parsed.id), parsed);
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
});
|
|
412
|
+
const session = this.getSession(transaction);
|
|
413
|
+
const result = await session.run(query, params);
|
|
414
|
+
const relationships = result.records.map((record) => this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId')));
|
|
865
415
|
return {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
paths: options.returnPaths ? paths : undefined,
|
|
869
|
-
nodes: options.returnNodes ? Array.from(nodesSet.values()) : undefined,
|
|
870
|
-
relationships: Array.from(relsSet.values()),
|
|
871
|
-
count: paths.length,
|
|
416
|
+
relationships,
|
|
417
|
+
count: relationships.length,
|
|
872
418
|
};
|
|
873
419
|
}
|
|
874
|
-
async
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
// Use APOC for weighted shortest path
|
|
888
|
-
query = `
|
|
889
|
-
MATCH ${startNodeMatch}, ${endNodeMatch}
|
|
890
|
-
CALL apoc.algo.dijkstra(start, end, '${relPattern}', '${options.weightProperty}')
|
|
891
|
-
YIELD path, weight
|
|
892
|
-
RETURN path, weight
|
|
893
|
-
`;
|
|
420
|
+
async findRelationshipById(id, transaction) {
|
|
421
|
+
const query = `
|
|
422
|
+
MATCH (a)-[r]->(b)
|
|
423
|
+
WHERE elementId(r) = $id OR id(r) = $idNum
|
|
424
|
+
RETURN r, elementId(a) as startId, elementId(b) as endId
|
|
425
|
+
`;
|
|
426
|
+
const session = this.getSession(transaction);
|
|
427
|
+
const result = await session.run(query, {
|
|
428
|
+
id: String(id),
|
|
429
|
+
idNum: typeof id === 'number' ? id : parseInt(id, 10) || -1,
|
|
430
|
+
});
|
|
431
|
+
if (result.records.length === 0) {
|
|
432
|
+
return null;
|
|
894
433
|
}
|
|
895
|
-
|
|
434
|
+
const record = result.records[0];
|
|
435
|
+
return this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId'));
|
|
436
|
+
}
|
|
437
|
+
async updateRelationship(options, transaction) {
|
|
438
|
+
let query;
|
|
439
|
+
const params = { props: options.properties };
|
|
440
|
+
if (options.id) {
|
|
896
441
|
query = `
|
|
897
|
-
MATCH
|
|
898
|
-
|
|
899
|
-
|
|
442
|
+
MATCH (a)-[r]->(b)
|
|
443
|
+
WHERE elementId(r) = $id OR id(r) = $idNum
|
|
444
|
+
SET r += $props
|
|
445
|
+
RETURN r, elementId(a) as startId, elementId(b) as endId
|
|
900
446
|
`;
|
|
447
|
+
params.id = String(options.id);
|
|
448
|
+
params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
|
|
901
449
|
}
|
|
902
450
|
else {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
451
|
+
const typeClause = options.type ? `:${options.type}` : '';
|
|
452
|
+
query = `MATCH (a)-[r${typeClause}]->(b)`;
|
|
453
|
+
if (options.where) {
|
|
454
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
|
|
455
|
+
query += ` WHERE ${clause}`;
|
|
456
|
+
Object.assign(params, whereParams);
|
|
457
|
+
}
|
|
458
|
+
query += ' SET r += $props RETURN r, elementId(a) as startId, elementId(b) as endId';
|
|
908
459
|
}
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
460
|
+
const session = this.getSession(transaction);
|
|
461
|
+
const result = await session.run(query, params);
|
|
462
|
+
const relationships = result.records.map((record) => this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId')));
|
|
463
|
+
return {
|
|
464
|
+
relationship: relationships.length === 1 ? relationships[0] : undefined,
|
|
465
|
+
relationships: relationships.length > 1 ? relationships : undefined,
|
|
466
|
+
updatedCount: relationships.length,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
async deleteRelationship(options, transaction) {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
let query;
|
|
472
|
+
const params = {};
|
|
473
|
+
if (options.id) {
|
|
474
|
+
query = `MATCH ()-[r]->() WHERE elementId(r) = $id OR id(r) = $idNum DELETE r RETURN count(r) as count`;
|
|
475
|
+
params.id = String(options.id);
|
|
476
|
+
params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
|
|
916
477
|
}
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
|
|
478
|
+
else {
|
|
479
|
+
const typeClause = options.type ? `:${options.type}` : '';
|
|
480
|
+
query = `MATCH (a)-[r${typeClause}]->(b)`;
|
|
481
|
+
const conditions = [];
|
|
482
|
+
if (options.startNodeId) {
|
|
483
|
+
conditions.push('(elementId(a) = $startId OR id(a) = $startIdNum)');
|
|
484
|
+
params.startId = String(options.startNodeId);
|
|
485
|
+
params.startIdNum = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1;
|
|
486
|
+
}
|
|
487
|
+
if (options.endNodeId) {
|
|
488
|
+
conditions.push('(elementId(b) = $endId OR id(b) = $endIdNum)');
|
|
489
|
+
params.endId = String(options.endNodeId);
|
|
490
|
+
params.endIdNum = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1;
|
|
921
491
|
}
|
|
922
|
-
|
|
923
|
-
|
|
492
|
+
if (options.where) {
|
|
493
|
+
const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
|
|
494
|
+
conditions.push(clause);
|
|
495
|
+
Object.assign(params, whereParams);
|
|
496
|
+
}
|
|
497
|
+
if (conditions.length > 0) {
|
|
498
|
+
query += ` WHERE ${conditions.join(' AND ')}`;
|
|
499
|
+
}
|
|
500
|
+
query += ' DELETE r RETURN count(r) as count';
|
|
501
|
+
}
|
|
502
|
+
const session = this.getSession(transaction);
|
|
503
|
+
const result = await session.run(query, params);
|
|
504
|
+
const count = ((_b = (_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0;
|
|
924
505
|
return {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
path: options.returnAllShortest ? undefined : paths[0],
|
|
928
|
-
paths: options.returnAllShortest ? paths : undefined,
|
|
929
|
-
found: true,
|
|
930
|
-
length: paths[0].length,
|
|
931
|
-
totalWeight: paths[0].totalWeight,
|
|
506
|
+
deleted: count > 0,
|
|
507
|
+
deletedCount: count,
|
|
932
508
|
};
|
|
933
509
|
}
|
|
934
|
-
async
|
|
935
|
-
const startTime = Date.now();
|
|
936
|
-
const params = {};
|
|
937
|
-
const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
|
|
938
|
-
const endNodeMatch = this.buildNodeSelectorMatch(options.endNode, 'end', params, 'end_');
|
|
939
|
-
const relPattern = this.buildTraversalRelPattern(options);
|
|
940
|
-
const minDepth = options.minDepth || 1;
|
|
941
|
-
const maxDepth = options.maxDepth || 10;
|
|
942
|
-
const depthPattern = `*${minDepth}..${maxDepth}`;
|
|
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 ? '->' : '-';
|
|
510
|
+
async mergeRelationship(options, transaction) {
|
|
946
511
|
let query = `
|
|
947
|
-
MATCH
|
|
948
|
-
|
|
512
|
+
MATCH (a), (b)
|
|
513
|
+
WHERE (elementId(a) = $startId OR id(a) = $startIdNum)
|
|
514
|
+
AND (elementId(b) = $endId OR id(b) = $endIdNum)
|
|
515
|
+
MERGE (a)-[r:${options.type}]->(b)
|
|
516
|
+
`;
|
|
517
|
+
const params = {
|
|
518
|
+
startId: String(options.startNodeId),
|
|
519
|
+
startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
|
|
520
|
+
endId: String(options.endNodeId),
|
|
521
|
+
endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
|
|
522
|
+
};
|
|
523
|
+
if (options.onCreate) {
|
|
524
|
+
query += ' ON CREATE SET r += $onCreateProps';
|
|
525
|
+
params.onCreateProps = options.onCreate;
|
|
526
|
+
}
|
|
527
|
+
if (options.onMatch) {
|
|
528
|
+
query += ' ON MATCH SET r += $onMatchProps';
|
|
529
|
+
params.onMatchProps = options.onMatch;
|
|
530
|
+
}
|
|
531
|
+
query += ' RETURN r, elementId(a) as startId, elementId(b) as endId';
|
|
532
|
+
const session = this.getSession(transaction);
|
|
533
|
+
const result = await session.run(query, params);
|
|
534
|
+
const record = result.records[0];
|
|
535
|
+
const relationship = this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId'));
|
|
536
|
+
// Check if relationship was created (no properties existed before)
|
|
537
|
+
const created = Object.keys(record.get('r').properties || {}).length === 0;
|
|
538
|
+
return {
|
|
539
|
+
relationship,
|
|
540
|
+
created,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
// ==================== TRAVERSAL OPERATIONS ====================
|
|
544
|
+
async traverse(options, transaction) {
|
|
545
|
+
var _a;
|
|
546
|
+
const direction = this.getDirectionArrow(options.direction);
|
|
547
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
548
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
549
|
+
const depthClause = `*1..${options.maxDepth || 3}`;
|
|
550
|
+
const query = `
|
|
551
|
+
MATCH path = (start)${direction.left}[${relClause}${depthClause}]${direction.right}(end)
|
|
552
|
+
WHERE elementId(start) = $startId OR id(start) = $startIdNum
|
|
949
553
|
RETURN path
|
|
554
|
+
${options.limit ? `LIMIT ${options.limit}` : ''}
|
|
950
555
|
`;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
const
|
|
556
|
+
const params = {
|
|
557
|
+
startId: String(options.startNodeId),
|
|
558
|
+
startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
|
|
559
|
+
};
|
|
560
|
+
const session = this.getSession(transaction);
|
|
561
|
+
const result = await session.run(query, params);
|
|
562
|
+
const paths = result.records.map((record) => this.mapNeo4jPath(record.get('path')));
|
|
956
563
|
return {
|
|
957
|
-
success: true,
|
|
958
|
-
executionTime: Date.now() - startTime,
|
|
959
564
|
paths,
|
|
960
565
|
count: paths.length,
|
|
961
566
|
};
|
|
962
567
|
}
|
|
963
|
-
async
|
|
964
|
-
|
|
965
|
-
const
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
// Just match nodes
|
|
986
|
-
matchClauses.push(`MATCH ${nodePatterns.join(', ')}`);
|
|
987
|
-
}
|
|
988
|
-
else {
|
|
989
|
-
pattern.relationships.forEach(rel => {
|
|
990
|
-
const startVar = rel.startNode;
|
|
991
|
-
const endVar = rel.endNode;
|
|
992
|
-
const relVar = rel.variable || '';
|
|
993
|
-
const types = rel.type
|
|
994
|
-
? ':' + (Array.isArray(rel.type) ? rel.type : [rel.type])
|
|
995
|
-
.map(t => this.escapeIdentifier(t)).join('|')
|
|
996
|
-
: '';
|
|
997
|
-
const dirStart = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
998
|
-
const dirEnd = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
999
|
-
rel.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
1000
|
-
let hops = '';
|
|
1001
|
-
if (rel.minHops !== undefined || rel.maxHops !== undefined) {
|
|
1002
|
-
const min = rel.minHops || '';
|
|
1003
|
-
const max = rel.maxHops || '';
|
|
1004
|
-
hops = `*${min}..${max}`;
|
|
1005
|
-
}
|
|
1006
|
-
matchClauses.push(`MATCH (${startVar})${dirStart}[${relVar}${types}${hops}]${dirEnd}(${endVar})`);
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
let query = matchClauses.join(' ');
|
|
1010
|
-
// WHERE clause
|
|
1011
|
-
if (pattern.where) {
|
|
1012
|
-
const conditions = pattern.where.conditions
|
|
1013
|
-
.map(c => c.expression)
|
|
1014
|
-
.join(pattern.where.operator === 'OR' ? ' OR ' : ' AND ');
|
|
1015
|
-
query += ` WHERE ${conditions}`;
|
|
1016
|
-
}
|
|
1017
|
-
// RETURN clause
|
|
1018
|
-
const returnVars = options.return || pattern.nodes.map(n => n.variable);
|
|
1019
|
-
query += ` RETURN ${returnVars.join(', ')}`;
|
|
1020
|
-
// ORDER BY
|
|
1021
|
-
if (options.orderBy && options.orderBy.length > 0) {
|
|
1022
|
-
const orderParts = options.orderBy.map(o => `${o.expression} ${o.direction}`);
|
|
1023
|
-
query += ` ORDER BY ${orderParts.join(', ')}`;
|
|
1024
|
-
}
|
|
1025
|
-
// SKIP and LIMIT
|
|
1026
|
-
if (options.skip !== undefined) {
|
|
1027
|
-
query += ` SKIP ${options.skip}`;
|
|
1028
|
-
}
|
|
1029
|
-
if (options.limit !== undefined) {
|
|
1030
|
-
query += ` LIMIT ${options.limit}`;
|
|
568
|
+
async shortestPath(options, transaction) {
|
|
569
|
+
var _a;
|
|
570
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
571
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
572
|
+
const maxDepth = options.maxDepth || 15;
|
|
573
|
+
const query = `
|
|
574
|
+
MATCH (start), (end)
|
|
575
|
+
WHERE (elementId(start) = $startId OR id(start) = $startIdNum)
|
|
576
|
+
AND (elementId(end) = $endId OR id(end) = $endIdNum)
|
|
577
|
+
MATCH path = shortestPath((start)-[${relClause}*..${maxDepth}]-(end))
|
|
578
|
+
RETURN path
|
|
579
|
+
`;
|
|
580
|
+
const params = {
|
|
581
|
+
startId: String(options.startNodeId),
|
|
582
|
+
startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
|
|
583
|
+
endId: String(options.endNodeId),
|
|
584
|
+
endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
|
|
585
|
+
};
|
|
586
|
+
const session = this.getSession(transaction);
|
|
587
|
+
const result = await session.run(query, params);
|
|
588
|
+
if (result.records.length === 0) {
|
|
589
|
+
return { path: null };
|
|
1031
590
|
}
|
|
1032
|
-
const
|
|
591
|
+
const path = this.mapNeo4jPath(result.records[0].get('path'));
|
|
1033
592
|
return {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
hasMore: options.limit !== undefined && result.data.length === options.limit,
|
|
593
|
+
path,
|
|
594
|
+
totalWeight: options.weightProperty
|
|
595
|
+
? path.relationships.reduce((sum, r) => sum + (r.properties[options.weightProperty] || 0), 0)
|
|
596
|
+
: undefined,
|
|
1039
597
|
};
|
|
1040
598
|
}
|
|
1041
|
-
async
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1044
|
-
const
|
|
1045
|
-
const
|
|
1046
|
-
const maxDepth = options.maxDepth ||
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
MATCH ${startMatches.join(', ')}
|
|
1055
|
-
WITH ${startVars}
|
|
1056
|
-
MATCH path = ${matchPaths.length > 0 ? matchPaths.replace(' OR ', '), (') : `(start0)${dirStart}[${relPattern}*0..${maxDepth}]${dirEnd}(n)`}
|
|
1057
|
-
WITH COLLECT(DISTINCT n) AS nodes, COLLECT(DISTINCT relationships(path)) AS rels
|
|
1058
|
-
UNWIND rels AS relList
|
|
1059
|
-
UNWIND relList AS r
|
|
1060
|
-
RETURN nodes, COLLECT(DISTINCT r) AS relationships
|
|
599
|
+
async allPaths(options, transaction) {
|
|
600
|
+
var _a;
|
|
601
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
602
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
603
|
+
const minDepth = options.minDepth || 1;
|
|
604
|
+
const maxDepth = options.maxDepth || 5;
|
|
605
|
+
const query = `
|
|
606
|
+
MATCH (start), (end)
|
|
607
|
+
WHERE (elementId(start) = $startId OR id(start) = $startIdNum)
|
|
608
|
+
AND (elementId(end) = $endId OR id(end) = $endIdNum)
|
|
609
|
+
MATCH path = (start)-[${relClause}*${minDepth}..${maxDepth}]-(end)
|
|
610
|
+
RETURN path
|
|
611
|
+
${options.limit ? `LIMIT ${options.limit}` : ''}
|
|
1061
612
|
`;
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
613
|
+
const params = {
|
|
614
|
+
startId: String(options.startNodeId),
|
|
615
|
+
startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
|
|
616
|
+
endId: String(options.endNodeId),
|
|
617
|
+
endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
|
|
618
|
+
};
|
|
619
|
+
const session = this.getSession(transaction);
|
|
620
|
+
const result = await session.run(query, params);
|
|
621
|
+
const paths = result.records.map((record) => this.mapNeo4jPath(record.get('path')));
|
|
1074
622
|
return {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
subgraph: {
|
|
1078
|
-
nodes,
|
|
1079
|
-
relationships,
|
|
1080
|
-
nodeCount: nodes.length,
|
|
1081
|
-
relationshipCount: relationships.length,
|
|
1082
|
-
},
|
|
623
|
+
paths,
|
|
624
|
+
count: paths.length,
|
|
1083
625
|
};
|
|
1084
626
|
}
|
|
1085
|
-
async getNeighborhood(
|
|
1086
|
-
|
|
1087
|
-
const
|
|
1088
|
-
const
|
|
627
|
+
async getNeighborhood(options, transaction) {
|
|
628
|
+
var _a;
|
|
629
|
+
const direction = this.getDirectionArrow(options.direction);
|
|
630
|
+
const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
|
|
631
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
1089
632
|
const depth = options.depth || 1;
|
|
1090
|
-
let relTypes = '';
|
|
1091
|
-
if (options.relationshipTypes && options.relationshipTypes.length > 0) {
|
|
1092
|
-
relTypes = ':' + options.relationshipTypes.map(t => this.escapeIdentifier(t)).join('|');
|
|
1093
|
-
}
|
|
1094
|
-
const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
|
|
1095
|
-
const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
|
|
1096
|
-
options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
|
|
1097
633
|
const query = `
|
|
1098
|
-
MATCH
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
maxLevel: ${depth}
|
|
1103
|
-
})
|
|
1104
|
-
YIELD nodes, relationships
|
|
1105
|
-
RETURN nodes, relationships
|
|
634
|
+
MATCH (start)
|
|
635
|
+
WHERE elementId(start) = $nodeId OR id(start) = $nodeIdNum
|
|
636
|
+
MATCH path = (start)${direction.left}[r${relClause}*1..${depth}]${direction.right}(neighbor)
|
|
637
|
+
RETURN DISTINCT neighbor, r
|
|
1106
638
|
`;
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
catch (_a) {
|
|
1121
|
-
// Fall back to non-APOC query
|
|
1122
|
-
result = await this.executeRaw(connection, { query: fallbackQuery, params }, transaction);
|
|
1123
|
-
}
|
|
1124
|
-
const nodes = [];
|
|
1125
|
-
const relationships = [];
|
|
1126
|
-
const levels = new Map();
|
|
1127
|
-
if (result.data.length > 0) {
|
|
1128
|
-
const row = result.data[0];
|
|
1129
|
-
if (row.nodes) {
|
|
1130
|
-
row.nodes.forEach((n) => {
|
|
1131
|
-
const parsed = this.parseNode(n);
|
|
1132
|
-
nodes.push(parsed);
|
|
1133
|
-
});
|
|
639
|
+
const params = {
|
|
640
|
+
nodeId: String(options.nodeId),
|
|
641
|
+
nodeIdNum: typeof options.nodeId === 'number' ? options.nodeId : parseInt(options.nodeId, 10) || -1,
|
|
642
|
+
};
|
|
643
|
+
const session = this.getSession(transaction);
|
|
644
|
+
const result = await session.run(query, params);
|
|
645
|
+
const nodesMap = new Map();
|
|
646
|
+
const relationshipsSet = [];
|
|
647
|
+
result.records.forEach((record) => {
|
|
648
|
+
const neighbor = record.get('neighbor');
|
|
649
|
+
const nodeId = neighbor.elementId || neighbor.identity.toString();
|
|
650
|
+
if (!nodesMap.has(nodeId)) {
|
|
651
|
+
nodesMap.set(nodeId, this.mapNeo4jNode(neighbor));
|
|
1134
652
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
653
|
+
const rels = record.get('r');
|
|
654
|
+
if (Array.isArray(rels)) {
|
|
655
|
+
rels.forEach((rel) => {
|
|
656
|
+
relationshipsSet.push(this.mapNeo4jRelationship(rel, rel.startNodeElementId || rel.start.toString(), rel.endNodeElementId || rel.end.toString()));
|
|
657
|
+
});
|
|
1137
658
|
}
|
|
1138
|
-
}
|
|
659
|
+
});
|
|
1139
660
|
return {
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
nodes,
|
|
1143
|
-
relationships,
|
|
1144
|
-
levels,
|
|
661
|
+
nodes: Array.from(nodesMap.values()),
|
|
662
|
+
relationships: relationshipsSet,
|
|
1145
663
|
};
|
|
1146
664
|
}
|
|
1147
|
-
async findConnectedComponents(
|
|
1148
|
-
|
|
1149
|
-
//
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
let relFilter = '';
|
|
1156
|
-
if (options.relationshipTypes && options.relationshipTypes.length > 0) {
|
|
1157
|
-
relFilter = ':' + options.relationshipTypes.map(t => this.escapeIdentifier(t)).join('|');
|
|
1158
|
-
}
|
|
1159
|
-
// Use GDS (Graph Data Science) library for connected components
|
|
665
|
+
async findConnectedComponents(options, transaction) {
|
|
666
|
+
var _a, _b;
|
|
667
|
+
// Note: This requires APOC or GDS library for efficient implementation
|
|
668
|
+
// Basic implementation using Cypher
|
|
669
|
+
const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
|
|
670
|
+
const labelClause = labels ? `:${labels}` : '';
|
|
671
|
+
const relTypes = ((_b = options.relationshipTypes) === null || _b === void 0 ? void 0 : _b.join('|')) || '';
|
|
672
|
+
const relClause = relTypes ? `:${relTypes}` : '';
|
|
1160
673
|
const query = `
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
})
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
${options.minSize ? `WHERE size(nodeIds) >= ${options.minSize}` : ''}
|
|
1168
|
-
RETURN componentId, nodeIds
|
|
1169
|
-
ORDER BY size(nodeIds) DESC
|
|
1170
|
-
`;
|
|
1171
|
-
// Fallback query without GDS
|
|
1172
|
-
const fallbackQuery = `
|
|
1173
|
-
MATCH (n${labelFilter})
|
|
1174
|
-
WITH COLLECT(n) AS allNodes
|
|
1175
|
-
UNWIND allNodes AS node
|
|
1176
|
-
MATCH path = (node)-[${relFilter}*]-(connected)
|
|
1177
|
-
WITH node, COLLECT(DISTINCT connected) + node AS component
|
|
1178
|
-
WITH COLLECT(DISTINCT component) AS allComponents
|
|
1179
|
-
UNWIND range(0, size(allComponents)-1) AS idx
|
|
1180
|
-
WITH idx AS componentId, allComponents[idx] AS component
|
|
1181
|
-
${options.minSize ? `WHERE size(component) >= ${options.minSize}` : ''}
|
|
1182
|
-
RETURN componentId, component AS nodes
|
|
674
|
+
MATCH (n${labelClause})
|
|
675
|
+
WITH collect(n) as nodes
|
|
676
|
+
UNWIND nodes as node
|
|
677
|
+
MATCH path = (node)-[${relClause}*]-(connected)
|
|
678
|
+
WITH node, collect(DISTINCT connected) as component
|
|
679
|
+
RETURN component
|
|
1183
680
|
`;
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
result = await this.executeRaw(connection, { query: fallbackQuery }, transaction);
|
|
1190
|
-
}
|
|
1191
|
-
const components = result.data.map((row, idx) => ({
|
|
1192
|
-
id: row.componentId || idx,
|
|
1193
|
-
nodes: (row.nodes || []).map((n) => this.parseNode(n)),
|
|
1194
|
-
size: row.nodeIds ? row.nodeIds.length : (row.nodes || []).length,
|
|
681
|
+
const session = this.getSession(transaction);
|
|
682
|
+
const result = await session.run(query, {});
|
|
683
|
+
const components = result.records.map((record) => ({
|
|
684
|
+
nodes: record.get('component').map((n) => this.mapNeo4jNode(n)),
|
|
685
|
+
size: record.get('component').length,
|
|
1195
686
|
}));
|
|
1196
687
|
return {
|
|
1197
|
-
success: true,
|
|
1198
|
-
executionTime: Date.now() - startTime,
|
|
1199
688
|
components,
|
|
1200
689
|
count: components.length,
|
|
1201
690
|
};
|
|
1202
691
|
}
|
|
1203
692
|
// ==================== AGGREGATION OPERATIONS ====================
|
|
1204
|
-
async countNodes(
|
|
1205
|
-
var _a;
|
|
1206
|
-
const
|
|
693
|
+
async countNodes(labels, where, transaction) {
|
|
694
|
+
var _a, _b;
|
|
695
|
+
const labelClause = (labels === null || labels === void 0 ? void 0 : labels.length) ? `:${labels.join(':')}` : '';
|
|
696
|
+
let query = `MATCH (n${labelClause})`;
|
|
1207
697
|
const params = {};
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1213
|
-
let query = `MATCH (n${labelStr})`;
|
|
1214
|
-
if (where && Object.keys(where).length > 0) {
|
|
1215
|
-
const whereParts = [];
|
|
1216
|
-
Object.entries(where).forEach(([key, value], index) => {
|
|
1217
|
-
const paramName = `where_${index}`;
|
|
1218
|
-
whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1219
|
-
params[paramName] = value;
|
|
1220
|
-
});
|
|
1221
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
698
|
+
if (where) {
|
|
699
|
+
const { clause, params: whereParams } = this.buildWhereClause(where, 'n');
|
|
700
|
+
query += ` WHERE ${clause}`;
|
|
701
|
+
Object.assign(params, whereParams);
|
|
1222
702
|
}
|
|
1223
|
-
query += ' RETURN count(n)
|
|
1224
|
-
const
|
|
703
|
+
query += ' RETURN count(n) as count';
|
|
704
|
+
const session = this.getSession(transaction);
|
|
705
|
+
const result = await session.run(query, params);
|
|
1225
706
|
return {
|
|
1226
|
-
|
|
1227
|
-
executionTime: Date.now() - startTime,
|
|
1228
|
-
count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
|
|
707
|
+
count: ((_b = (_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0,
|
|
1229
708
|
};
|
|
1230
709
|
}
|
|
1231
|
-
async countRelationships(
|
|
1232
|
-
var _a;
|
|
1233
|
-
const
|
|
710
|
+
async countRelationships(types, where, transaction) {
|
|
711
|
+
var _a, _b;
|
|
712
|
+
const typeClause = (types === null || types === void 0 ? void 0 : types.length) ? `:${types.join('|')}` : '';
|
|
713
|
+
let query = `MATCH ()-[r${typeClause}]->()`;
|
|
1234
714
|
const params = {};
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
}
|
|
1240
|
-
let query = `MATCH ()-[r${typeStr}]->()`;
|
|
1241
|
-
if (where && Object.keys(where).length > 0) {
|
|
1242
|
-
const whereParts = [];
|
|
1243
|
-
Object.entries(where).forEach(([key, value], index) => {
|
|
1244
|
-
const paramName = `where_${index}`;
|
|
1245
|
-
whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1246
|
-
params[paramName] = value;
|
|
1247
|
-
});
|
|
1248
|
-
query += ` WHERE ${whereParts.join(' AND ')}`;
|
|
715
|
+
if (where) {
|
|
716
|
+
const { clause, params: whereParams } = this.buildWhereClause(where, 'r');
|
|
717
|
+
query += ` WHERE ${clause}`;
|
|
718
|
+
Object.assign(params, whereParams);
|
|
1249
719
|
}
|
|
1250
|
-
query += ' RETURN count(r)
|
|
1251
|
-
const
|
|
720
|
+
query += ' RETURN count(r) as count';
|
|
721
|
+
const session = this.getSession(transaction);
|
|
722
|
+
const result = await session.run(query, params);
|
|
1252
723
|
return {
|
|
1253
|
-
|
|
1254
|
-
executionTime: Date.now() - startTime,
|
|
1255
|
-
count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
|
|
724
|
+
count: ((_b = (_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0,
|
|
1256
725
|
};
|
|
1257
726
|
}
|
|
1258
|
-
async getStatistics(
|
|
1259
|
-
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
`;
|
|
1264
|
-
// Fallback without APOC
|
|
1265
|
-
const fallbackQuery = `
|
|
1266
|
-
MATCH (n)
|
|
1267
|
-
WITH count(n) AS nodeCount
|
|
1268
|
-
MATCH ()-[r]->()
|
|
1269
|
-
WITH nodeCount, count(r) AS relCount
|
|
1270
|
-
RETURN nodeCount, relCount
|
|
1271
|
-
`;
|
|
1272
|
-
let result;
|
|
1273
|
-
try {
|
|
1274
|
-
result = await this.executeRaw(connection, { query }, transaction);
|
|
1275
|
-
}
|
|
1276
|
-
catch (_a) {
|
|
1277
|
-
result = await this.executeRaw(connection, { query: fallbackQuery }, transaction);
|
|
1278
|
-
}
|
|
1279
|
-
const row = result.data[0] || {};
|
|
727
|
+
async getStatistics(transaction) {
|
|
728
|
+
var _a, _b, _c, _d;
|
|
729
|
+
const session = this.getSession(transaction);
|
|
730
|
+
const nodeCountResult = await session.run('MATCH (n) RETURN count(n) as count');
|
|
731
|
+
const relCountResult = await session.run('MATCH ()-[r]->() RETURN count(r) as count');
|
|
1280
732
|
return {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
nodeCount: this.toNumber(row.nodeCount || 0),
|
|
1284
|
-
relationshipCount: this.toNumber(row.relCount || 0),
|
|
1285
|
-
labelCounts: row.labels || {},
|
|
1286
|
-
relationshipTypeCounts: row.relTypesCount || {},
|
|
733
|
+
nodeCount: ((_b = (_a = nodeCountResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0,
|
|
734
|
+
relationshipCount: ((_d = (_c = relCountResult.records[0]) === null || _c === void 0 ? void 0 : _c.get('count')) === null || _d === void 0 ? void 0 : _d.toNumber()) || 0,
|
|
1287
735
|
};
|
|
1288
736
|
}
|
|
1289
737
|
// ==================== SEARCH OPERATIONS ====================
|
|
1290
|
-
async fullTextSearch(
|
|
1291
|
-
const
|
|
1292
|
-
let query = `
|
|
738
|
+
async fullTextSearch(options, transaction) {
|
|
739
|
+
const query = `
|
|
1293
740
|
CALL db.index.fulltext.queryNodes($indexName, $searchQuery)
|
|
1294
741
|
YIELD node, score
|
|
742
|
+
RETURN node, score
|
|
743
|
+
${options.limit ? `LIMIT ${options.limit}` : ''}
|
|
1295
744
|
`;
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
query += ' RETURN node';
|
|
1301
|
-
if (options.score) {
|
|
1302
|
-
query += ', score';
|
|
1303
|
-
}
|
|
1304
|
-
if (options.limit) {
|
|
1305
|
-
query += ` LIMIT ${options.limit}`;
|
|
1306
|
-
}
|
|
1307
|
-
const params = {
|
|
1308
|
-
indexName: options.index,
|
|
745
|
+
const session = this.getSession(transaction);
|
|
746
|
+
const result = await session.run(query, {
|
|
747
|
+
indexName: options.indexName,
|
|
1309
748
|
searchQuery: options.query,
|
|
1310
|
-
};
|
|
1311
|
-
const result = await this.executeRaw(connection, { query, params }, transaction);
|
|
1312
|
-
const nodes = result.data.map(row => {
|
|
1313
|
-
const node = this.parseNode(row.node);
|
|
1314
|
-
if (options.score && row.score !== undefined) {
|
|
1315
|
-
return Object.assign(Object.assign({}, node), { score: row.score });
|
|
1316
|
-
}
|
|
1317
|
-
return node;
|
|
1318
749
|
});
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
nodes,
|
|
1323
|
-
count: nodes.length,
|
|
1324
|
-
};
|
|
750
|
+
const nodes = result.records.map((r) => this.mapNeo4jNode(r.get('node')));
|
|
751
|
+
const scores = result.records.map((r) => r.get('score'));
|
|
752
|
+
return { nodes, scores };
|
|
1325
753
|
}
|
|
1326
|
-
async vectorSearch(
|
|
1327
|
-
|
|
754
|
+
async vectorSearch(options, transaction) {
|
|
755
|
+
// Vector search requires Neo4j 5.13+ with vector index
|
|
1328
756
|
const query = `
|
|
1329
|
-
CALL db.index.vector.queryNodes($indexName, $
|
|
757
|
+
CALL db.index.vector.queryNodes($indexName, $topK, $vector)
|
|
1330
758
|
YIELD node, score
|
|
1331
|
-
${options.minScore ? `WHERE score >= ${options.minScore}` : ''}
|
|
1332
759
|
RETURN node, score
|
|
1333
760
|
`;
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1336
|
-
|
|
761
|
+
const session = this.getSession(transaction);
|
|
762
|
+
const result = await session.run(query, {
|
|
763
|
+
indexName: options.indexName,
|
|
764
|
+
topK: options.topK || 10,
|
|
1337
765
|
vector: options.vector,
|
|
1338
|
-
};
|
|
1339
|
-
const
|
|
1340
|
-
const
|
|
766
|
+
});
|
|
767
|
+
const nodes = result.records.map((r) => this.mapNeo4jNode(r.get('node')));
|
|
768
|
+
const scores = result.records.map((r) => r.get('score'));
|
|
769
|
+
return { nodes, scores };
|
|
770
|
+
}
|
|
771
|
+
// ==================== RAW QUERY ====================
|
|
772
|
+
async query(options, transaction) {
|
|
773
|
+
var _a, _b, _c, _d, _e, _f;
|
|
774
|
+
const session = this.getSession(transaction);
|
|
775
|
+
const result = await session.run(options.query, options.params || {});
|
|
1341
776
|
return {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
777
|
+
records: result.records.map((r) => r.toObject()),
|
|
778
|
+
summary: {
|
|
779
|
+
resultAvailableAfter: (_b = (_a = result.summary) === null || _a === void 0 ? void 0 : _a.resultAvailableAfter) === null || _b === void 0 ? void 0 : _b.toNumber(),
|
|
780
|
+
resultConsumedAfter: (_d = (_c = result.summary) === null || _c === void 0 ? void 0 : _c.resultConsumedAfter) === null || _d === void 0 ? void 0 : _d.toNumber(),
|
|
781
|
+
database: (_f = (_e = result.summary) === null || _e === void 0 ? void 0 : _e.database) === null || _f === void 0 ? void 0 : _f.name,
|
|
782
|
+
},
|
|
1346
783
|
};
|
|
1347
784
|
}
|
|
1348
785
|
// ==================== SCHEMA OPERATIONS ====================
|
|
1349
|
-
async
|
|
1350
|
-
const
|
|
786
|
+
async createNodeIndex(options) {
|
|
787
|
+
const properties = options.properties.map(p => `n.${p}`).join(', ');
|
|
788
|
+
const unique = options.unique ? 'UNIQUE' : '';
|
|
789
|
+
const query = `CREATE ${unique} INDEX ${options.name} IF NOT EXISTS FOR (n:${options.label}) ON (${properties})`;
|
|
790
|
+
const session = this.getSession();
|
|
791
|
+
await session.run(query);
|
|
792
|
+
return { created: true, name: options.name };
|
|
793
|
+
}
|
|
794
|
+
async createNodeConstraint(options) {
|
|
1351
795
|
let query;
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
query = `CREATE CONSTRAINT ${this.escapeIdentifier(constraint.name)} FOR (n:${this.escapeIdentifier(constraint.label)}) REQUIRE (${props}) IS UNIQUE`;
|
|
1356
|
-
break;
|
|
1357
|
-
case node_types_1.NodeConstraintType.EXISTS:
|
|
1358
|
-
query = `CREATE CONSTRAINT ${this.escapeIdentifier(constraint.name)} FOR (n:${this.escapeIdentifier(constraint.label)}) REQUIRE ${props} IS NOT NULL`;
|
|
796
|
+
switch (options.type) {
|
|
797
|
+
case 'UNIQUE':
|
|
798
|
+
query = `CREATE CONSTRAINT ${options.name} IF NOT EXISTS FOR (n:${options.label}) REQUIRE n.${options.property} IS UNIQUE`;
|
|
1359
799
|
break;
|
|
1360
|
-
case
|
|
1361
|
-
query = `CREATE CONSTRAINT ${
|
|
800
|
+
case 'EXISTS':
|
|
801
|
+
query = `CREATE CONSTRAINT ${options.name} IF NOT EXISTS FOR (n:${options.label}) REQUIRE n.${options.property} IS NOT NULL`;
|
|
1362
802
|
break;
|
|
1363
803
|
default:
|
|
1364
|
-
throw
|
|
804
|
+
throw graph_error_1.GraphError.validationError(`Unsupported constraint type: ${options.type}`);
|
|
1365
805
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
executionTime: Date.now() - startTime,
|
|
1370
|
-
name: constraint.name,
|
|
1371
|
-
created: true,
|
|
1372
|
-
};
|
|
806
|
+
const session = this.getSession();
|
|
807
|
+
await session.run(query);
|
|
808
|
+
return { created: true, name: options.name };
|
|
1373
809
|
}
|
|
1374
|
-
async
|
|
1375
|
-
const
|
|
1376
|
-
const
|
|
1377
|
-
const
|
|
1378
|
-
await
|
|
1379
|
-
return {
|
|
1380
|
-
success: true,
|
|
1381
|
-
executionTime: Date.now() - startTime,
|
|
1382
|
-
name: constraint.name,
|
|
1383
|
-
created: true,
|
|
1384
|
-
};
|
|
810
|
+
async createRelationshipIndex(options) {
|
|
811
|
+
const properties = options.properties.map(p => `r.${p}`).join(', ');
|
|
812
|
+
const query = `CREATE INDEX ${options.name} IF NOT EXISTS FOR ()-[r:${options.type}]-() ON (${properties})`;
|
|
813
|
+
const session = this.getSession();
|
|
814
|
+
await session.run(query);
|
|
815
|
+
return { created: true, name: options.name };
|
|
1385
816
|
}
|
|
1386
|
-
async
|
|
1387
|
-
const
|
|
1388
|
-
const
|
|
1389
|
-
await
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
817
|
+
async listIndexes() {
|
|
818
|
+
const query = 'SHOW INDEXES';
|
|
819
|
+
const session = this.getSession();
|
|
820
|
+
const result = await session.run(query);
|
|
821
|
+
const indexes = result.records.map((r) => {
|
|
822
|
+
var _a;
|
|
823
|
+
return ({
|
|
824
|
+
name: r.get('name'),
|
|
825
|
+
labelOrType: ((_a = r.get('labelsOrTypes')) === null || _a === void 0 ? void 0 : _a[0]) || '',
|
|
826
|
+
properties: r.get('properties') || [],
|
|
827
|
+
unique: r.get('uniqueness') === 'UNIQUE',
|
|
828
|
+
type: r.get('type'),
|
|
829
|
+
state: r.get('state'),
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
return { indexes };
|
|
1396
833
|
}
|
|
1397
|
-
async listConstraints(
|
|
1398
|
-
const startTime = Date.now();
|
|
834
|
+
async listConstraints() {
|
|
1399
835
|
const query = 'SHOW CONSTRAINTS';
|
|
1400
|
-
const
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
836
|
+
const session = this.getSession();
|
|
837
|
+
const result = await session.run(query);
|
|
838
|
+
const constraints = result.records.map((r) => {
|
|
839
|
+
var _a, _b;
|
|
840
|
+
return ({
|
|
841
|
+
name: r.get('name'),
|
|
842
|
+
label: ((_a = r.get('labelsOrTypes')) === null || _a === void 0 ? void 0 : _a[0]) || '',
|
|
843
|
+
property: ((_b = r.get('properties')) === null || _b === void 0 ? void 0 : _b[0]) || '',
|
|
844
|
+
type: r.get('type'),
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
return { constraints };
|
|
848
|
+
}
|
|
849
|
+
async dropIndex(name) {
|
|
850
|
+
const query = `DROP INDEX ${name} IF EXISTS`;
|
|
851
|
+
const session = this.getSession();
|
|
852
|
+
await session.run(query);
|
|
853
|
+
return { dropped: true };
|
|
854
|
+
}
|
|
855
|
+
async dropConstraint(name) {
|
|
856
|
+
const query = `DROP CONSTRAINT ${name} IF EXISTS`;
|
|
857
|
+
const session = this.getSession();
|
|
858
|
+
await session.run(query);
|
|
859
|
+
return { dropped: true };
|
|
860
|
+
}
|
|
861
|
+
// ==================== SCHEMA INTROSPECTION ====================
|
|
862
|
+
async listLabels() {
|
|
863
|
+
var _a, _b, _c, _d;
|
|
864
|
+
const session = this.getSession();
|
|
865
|
+
// Get all labels
|
|
866
|
+
const labelsResult = await session.run('CALL db.labels()');
|
|
867
|
+
const labelNames = labelsResult.records.map((r) => r.get('label'));
|
|
868
|
+
const labels = [];
|
|
869
|
+
for (const labelName of labelNames) {
|
|
870
|
+
// Get count for each label
|
|
871
|
+
const countResult = await session.run(`MATCH (n:\`${labelName}\`) RETURN count(n) as count`);
|
|
872
|
+
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)) ||
|
|
873
|
+
((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
|
|
874
|
+
// Get properties for a sample of nodes with this label
|
|
875
|
+
const propsResult = await session.run(`MATCH (n:\`${labelName}\`) WITH n LIMIT 100
|
|
876
|
+
UNWIND keys(n) as key
|
|
877
|
+
WITH key, n[key] as value
|
|
878
|
+
RETURN DISTINCT key,
|
|
879
|
+
CASE
|
|
880
|
+
WHEN value IS NULL THEN 'unknown'
|
|
881
|
+
WHEN toInteger(value) IS NOT NULL THEN 'number'
|
|
882
|
+
WHEN toFloat(value) IS NOT NULL THEN 'number'
|
|
883
|
+
WHEN value =~ '.*' THEN 'string'
|
|
884
|
+
WHEN value = true OR value = false THEN 'boolean'
|
|
885
|
+
WHEN date(value) IS NOT NULL THEN 'date'
|
|
886
|
+
WHEN datetime(value) IS NOT NULL THEN 'datetime'
|
|
887
|
+
WHEN point(value) IS NOT NULL THEN 'point'
|
|
888
|
+
WHEN value IS :: LIST THEN 'array'
|
|
889
|
+
ELSE 'unknown'
|
|
890
|
+
END as type`);
|
|
891
|
+
const properties = propsResult.records.map((r) => ({
|
|
892
|
+
name: r.get('key'),
|
|
893
|
+
type: this.mapNeo4jTypeToPropertyType(r.get('type')),
|
|
894
|
+
}));
|
|
895
|
+
labels.push({
|
|
896
|
+
name: labelName,
|
|
897
|
+
count: typeof count === 'number' ? count : Number(count),
|
|
898
|
+
properties,
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
return { labels };
|
|
902
|
+
}
|
|
903
|
+
async listRelationshipTypes() {
|
|
904
|
+
var _a, _b, _c, _d;
|
|
905
|
+
const session = this.getSession();
|
|
906
|
+
// Get all relationship types
|
|
907
|
+
const typesResult = await session.run('CALL db.relationshipTypes()');
|
|
908
|
+
const typeNames = typesResult.records.map((r) => r.get('relationshipType'));
|
|
909
|
+
const types = [];
|
|
910
|
+
for (const typeName of typeNames) {
|
|
911
|
+
// Get count for each type
|
|
912
|
+
const countResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() RETURN count(r) as count`);
|
|
913
|
+
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)) ||
|
|
914
|
+
((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
|
|
915
|
+
// Get source and target label information
|
|
916
|
+
const endpointsResult = await session.run(`MATCH (a)-[r:\`${typeName}\`]->(b)
|
|
917
|
+
WITH labels(a) as fromLabels, labels(b) as toLabels
|
|
918
|
+
RETURN DISTINCT fromLabels[0] as fromLabel, toLabels[0] as toLabel
|
|
919
|
+
LIMIT 10`);
|
|
920
|
+
const fromLabelsArray = endpointsResult.records
|
|
921
|
+
.map((r) => r.get('fromLabel'))
|
|
922
|
+
.filter((l) => Boolean(l));
|
|
923
|
+
const fromLabels = [...new Set(fromLabelsArray)];
|
|
924
|
+
const toLabelsArray = endpointsResult.records
|
|
925
|
+
.map((r) => r.get('toLabel'))
|
|
926
|
+
.filter((l) => Boolean(l));
|
|
927
|
+
const toLabels = [...new Set(toLabelsArray)];
|
|
928
|
+
// Get properties for relationships of this type
|
|
929
|
+
const propsResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() WITH r LIMIT 100
|
|
930
|
+
UNWIND keys(r) as key
|
|
931
|
+
RETURN DISTINCT key`);
|
|
932
|
+
const properties = propsResult.records.map((r) => ({
|
|
933
|
+
name: r.get('key'),
|
|
934
|
+
type: 'unknown',
|
|
935
|
+
}));
|
|
936
|
+
types.push({
|
|
937
|
+
type: typeName,
|
|
938
|
+
count: typeof count === 'number' ? count : Number(count),
|
|
939
|
+
fromLabels,
|
|
940
|
+
toLabels,
|
|
941
|
+
properties: properties.length > 0 ? properties : undefined,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
return { types };
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Map Neo4j type string to GraphPropertyType
|
|
948
|
+
*/
|
|
949
|
+
mapNeo4jTypeToPropertyType(typeStr) {
|
|
950
|
+
switch (typeStr === null || typeStr === void 0 ? void 0 : typeStr.toLowerCase()) {
|
|
951
|
+
case 'number':
|
|
952
|
+
case 'integer':
|
|
953
|
+
case 'float':
|
|
954
|
+
return 'number';
|
|
955
|
+
case 'string':
|
|
956
|
+
return 'string';
|
|
957
|
+
case 'boolean':
|
|
958
|
+
return 'boolean';
|
|
959
|
+
case 'date':
|
|
960
|
+
return 'date';
|
|
961
|
+
case 'datetime':
|
|
962
|
+
return 'datetime';
|
|
963
|
+
case 'point':
|
|
964
|
+
return 'point';
|
|
965
|
+
case 'array':
|
|
966
|
+
case 'list':
|
|
967
|
+
return 'array';
|
|
1437
968
|
default:
|
|
1438
|
-
|
|
969
|
+
return 'unknown';
|
|
1439
970
|
}
|
|
1440
|
-
await this.executeRaw(connection, { query }, transaction);
|
|
1441
|
-
return {
|
|
1442
|
-
success: true,
|
|
1443
|
-
executionTime: Date.now() - startTime,
|
|
1444
|
-
name: index.name,
|
|
1445
|
-
created: true,
|
|
1446
|
-
};
|
|
1447
971
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
const
|
|
1451
|
-
const
|
|
1452
|
-
await this.executeRaw(connection, { query }, transaction);
|
|
972
|
+
// ==================== TRANSACTION OPERATIONS ====================
|
|
973
|
+
async beginTransaction(options) {
|
|
974
|
+
const session = this.driver.session();
|
|
975
|
+
const tx = session.beginTransaction();
|
|
1453
976
|
return {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
977
|
+
id: `tx_${Date.now()}`,
|
|
978
|
+
status: enums_1.GraphTransactionStatus.ACTIVE,
|
|
979
|
+
client: tx,
|
|
980
|
+
commit: async () => {
|
|
981
|
+
await tx.commit();
|
|
982
|
+
await session.close();
|
|
983
|
+
},
|
|
984
|
+
rollback: async () => {
|
|
985
|
+
await tx.rollback();
|
|
986
|
+
await session.close();
|
|
987
|
+
},
|
|
1458
988
|
};
|
|
1459
989
|
}
|
|
1460
|
-
async
|
|
1461
|
-
|
|
1462
|
-
const query = `DROP INDEX ${this.escapeIdentifier(name)}`;
|
|
1463
|
-
await this.executeRaw(connection, { query }, transaction);
|
|
1464
|
-
return {
|
|
1465
|
-
success: true,
|
|
1466
|
-
executionTime: Date.now() - startTime,
|
|
1467
|
-
name,
|
|
1468
|
-
dropped: true,
|
|
1469
|
-
};
|
|
990
|
+
async commitTransaction(transaction) {
|
|
991
|
+
await transaction.commit();
|
|
1470
992
|
}
|
|
1471
|
-
async
|
|
1472
|
-
|
|
1473
|
-
const query = 'SHOW INDEXES';
|
|
1474
|
-
const result = await this.executeRaw(connection, { query }, transaction);
|
|
1475
|
-
const indexes = result.data.map(row => ({
|
|
1476
|
-
name: row.name,
|
|
1477
|
-
type: row.type,
|
|
1478
|
-
entityType: row.entityType,
|
|
1479
|
-
labelsOrTypes: row.labelsOrTypes || [],
|
|
1480
|
-
properties: row.properties || [],
|
|
1481
|
-
state: row.state,
|
|
1482
|
-
uniqueness: row.uniqueness,
|
|
1483
|
-
provider: row.provider,
|
|
1484
|
-
}));
|
|
1485
|
-
return {
|
|
1486
|
-
success: true,
|
|
1487
|
-
executionTime: Date.now() - startTime,
|
|
1488
|
-
indexes,
|
|
1489
|
-
};
|
|
993
|
+
async rollbackTransaction(transaction) {
|
|
994
|
+
await transaction.rollback();
|
|
1490
995
|
}
|
|
1491
996
|
// ==================== UTILITY METHODS ====================
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
|
|
1495
|
-
return identifier;
|
|
1496
|
-
}
|
|
1497
|
-
return `\`${identifier.replace(/`/g, '``')}\``;
|
|
1498
|
-
}
|
|
1499
|
-
escapeValue(value) {
|
|
1500
|
-
if (value === null)
|
|
1501
|
-
return 'null';
|
|
1502
|
-
if (typeof value === 'string')
|
|
1503
|
-
return `'${value.replace(/'/g, "\\'")}'`;
|
|
1504
|
-
if (typeof value === 'number')
|
|
1505
|
-
return String(value);
|
|
1506
|
-
if (typeof value === 'boolean')
|
|
1507
|
-
return value ? 'true' : 'false';
|
|
1508
|
-
if (value instanceof Date)
|
|
1509
|
-
return `datetime('${value.toISOString()}')`;
|
|
1510
|
-
if (Array.isArray(value))
|
|
1511
|
-
return `[${value.map(v => this.escapeValue(v)).join(', ')}]`;
|
|
1512
|
-
if (typeof value === 'object')
|
|
1513
|
-
return `{${Object.entries(value).map(([k, v]) => `${k}: ${this.escapeValue(v)}`).join(', ')}}`;
|
|
1514
|
-
return String(value);
|
|
1515
|
-
}
|
|
1516
|
-
buildWhereClause(where, variableName = 'n') {
|
|
997
|
+
buildWhereClause(where, alias = 'n') {
|
|
998
|
+
const conditions = [];
|
|
1517
999
|
const params = {};
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
|
|
1000
|
+
let paramIndex = 0;
|
|
1001
|
+
const processCondition = (key, value, prefix = '') => {
|
|
1002
|
+
const fullKey = prefix ? `${prefix}_${key}` : key;
|
|
1003
|
+
const paramName = `param_${paramIndex++}`;
|
|
1004
|
+
if (key === '$AND') {
|
|
1005
|
+
const subConditions = Object.entries(value).map(([k, v]) => {
|
|
1006
|
+
processCondition(k, v, fullKey);
|
|
1007
|
+
return conditions.pop();
|
|
1008
|
+
});
|
|
1009
|
+
conditions.push(`(${subConditions.join(' AND ')})`);
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
if (key === '$OR') {
|
|
1013
|
+
const subConditions = Object.entries(value).map(([k, v]) => {
|
|
1014
|
+
processCondition(k, v, fullKey);
|
|
1015
|
+
return conditions.pop();
|
|
1016
|
+
});
|
|
1017
|
+
conditions.push(`(${subConditions.join(' OR ')})`);
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
1021
|
+
Object.entries(value).forEach(([op, opValue]) => {
|
|
1022
|
+
const opParamName = `${paramName}_${op.toLowerCase()}`;
|
|
1023
|
+
switch (op) {
|
|
1024
|
+
case '$GT':
|
|
1025
|
+
conditions.push(`${alias}.${key} > $${opParamName}`);
|
|
1026
|
+
params[opParamName] = opValue;
|
|
1027
|
+
break;
|
|
1028
|
+
case '$GTE':
|
|
1029
|
+
conditions.push(`${alias}.${key} >= $${opParamName}`);
|
|
1030
|
+
params[opParamName] = opValue;
|
|
1031
|
+
break;
|
|
1032
|
+
case '$LT':
|
|
1033
|
+
conditions.push(`${alias}.${key} < $${opParamName}`);
|
|
1034
|
+
params[opParamName] = opValue;
|
|
1035
|
+
break;
|
|
1036
|
+
case '$LTE':
|
|
1037
|
+
conditions.push(`${alias}.${key} <= $${opParamName}`);
|
|
1038
|
+
params[opParamName] = opValue;
|
|
1039
|
+
break;
|
|
1040
|
+
case '$NE':
|
|
1041
|
+
conditions.push(`${alias}.${key} <> $${opParamName}`);
|
|
1042
|
+
params[opParamName] = opValue;
|
|
1043
|
+
break;
|
|
1044
|
+
case '$IN':
|
|
1045
|
+
conditions.push(`${alias}.${key} IN $${opParamName}`);
|
|
1046
|
+
params[opParamName] = opValue;
|
|
1047
|
+
break;
|
|
1048
|
+
case '$NOT_IN':
|
|
1049
|
+
conditions.push(`NOT ${alias}.${key} IN $${opParamName}`);
|
|
1050
|
+
params[opParamName] = opValue;
|
|
1051
|
+
break;
|
|
1052
|
+
case '$CONTAINS':
|
|
1053
|
+
conditions.push(`${alias}.${key} CONTAINS $${opParamName}`);
|
|
1054
|
+
params[opParamName] = opValue;
|
|
1055
|
+
break;
|
|
1056
|
+
case '$STARTS_WITH':
|
|
1057
|
+
conditions.push(`${alias}.${key} STARTS WITH $${opParamName}`);
|
|
1058
|
+
params[opParamName] = opValue;
|
|
1059
|
+
break;
|
|
1060
|
+
case '$ENDS_WITH':
|
|
1061
|
+
conditions.push(`${alias}.${key} ENDS WITH $${opParamName}`);
|
|
1062
|
+
params[opParamName] = opValue;
|
|
1063
|
+
break;
|
|
1064
|
+
case '$EXISTS':
|
|
1065
|
+
if (opValue) {
|
|
1066
|
+
conditions.push(`${alias}.${key} IS NOT NULL`);
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1069
|
+
conditions.push(`${alias}.${key} IS NULL`);
|
|
1070
|
+
}
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
conditions.push(`${alias}.${key} = $${paramName}`);
|
|
1077
|
+
params[paramName] = value;
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
Object.entries(where).forEach(([key, value]) => {
|
|
1081
|
+
processCondition(key, value);
|
|
1523
1082
|
});
|
|
1524
1083
|
return {
|
|
1525
|
-
clause:
|
|
1084
|
+
clause: conditions.join(' AND ') || 'true',
|
|
1526
1085
|
params,
|
|
1527
1086
|
};
|
|
1528
1087
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
if (nativeNode.identity !== undefined) {
|
|
1536
|
-
return {
|
|
1537
|
-
id: this.toNumber(nativeNode.identity),
|
|
1538
|
-
labels: nativeNode.labels || [],
|
|
1539
|
-
properties: this.convertProperties(nativeNode.properties),
|
|
1540
|
-
elementId: nativeNode.elementId,
|
|
1541
|
-
};
|
|
1542
|
-
}
|
|
1543
|
-
// Handle plain object (from raw query results)
|
|
1088
|
+
parseError(error) {
|
|
1089
|
+
return graph_error_1.GraphError.wrap(error);
|
|
1090
|
+
}
|
|
1091
|
+
// ==================== PRIVATE HELPER METHODS ====================
|
|
1092
|
+
mapNeo4jNode(node) {
|
|
1093
|
+
var _a;
|
|
1544
1094
|
return {
|
|
1545
|
-
id:
|
|
1546
|
-
labels:
|
|
1547
|
-
properties: (
|
|
1548
|
-
elementId:
|
|
1095
|
+
id: node.elementId || ((_a = node.identity) === null || _a === void 0 ? void 0 : _a.toString()) || '',
|
|
1096
|
+
labels: node.labels || [],
|
|
1097
|
+
properties: this.convertNeo4jProperties(node.properties || {}),
|
|
1098
|
+
elementId: node.elementId,
|
|
1549
1099
|
};
|
|
1550
1100
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.RELATIONSHIP_ERROR, 'Cannot parse null relationship');
|
|
1554
|
-
}
|
|
1555
|
-
// Handle Neo4j Relationship object
|
|
1556
|
-
if (nativeRelationship.identity !== undefined) {
|
|
1557
|
-
return {
|
|
1558
|
-
id: this.toNumber(nativeRelationship.identity),
|
|
1559
|
-
type: nativeRelationship.type,
|
|
1560
|
-
startNodeId: this.toNumber(nativeRelationship.start),
|
|
1561
|
-
endNodeId: this.toNumber(nativeRelationship.end),
|
|
1562
|
-
properties: this.convertProperties(nativeRelationship.properties),
|
|
1563
|
-
elementId: nativeRelationship.elementId,
|
|
1564
|
-
startNodeElementId: nativeRelationship.startNodeElementId,
|
|
1565
|
-
endNodeElementId: nativeRelationship.endNodeElementId,
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1101
|
+
mapNeo4jRelationship(rel, startId, endId) {
|
|
1102
|
+
var _a;
|
|
1568
1103
|
return {
|
|
1569
|
-
id:
|
|
1570
|
-
type:
|
|
1571
|
-
startNodeId:
|
|
1572
|
-
endNodeId:
|
|
1573
|
-
properties: (
|
|
1574
|
-
elementId:
|
|
1104
|
+
id: rel.elementId || ((_a = rel.identity) === null || _a === void 0 ? void 0 : _a.toString()) || '',
|
|
1105
|
+
type: rel.type,
|
|
1106
|
+
startNodeId: startId,
|
|
1107
|
+
endNodeId: endId,
|
|
1108
|
+
properties: this.convertNeo4jProperties(rel.properties || {}),
|
|
1109
|
+
elementId: rel.elementId,
|
|
1575
1110
|
};
|
|
1576
1111
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
if (nodes.length === 0) {
|
|
1587
|
-
nodes.push(this.parseNode(segment.start));
|
|
1588
|
-
}
|
|
1589
|
-
relationships.push(this.parseRelationship(segment.relationship));
|
|
1590
|
-
nodes.push(this.parseNode(segment.end));
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
else if (nativePath.nodes && nativePath.relationships) {
|
|
1594
|
-
nativePath.nodes.forEach((n) => nodes.push(this.parseNode(n)));
|
|
1595
|
-
nativePath.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
|
|
1596
|
-
}
|
|
1112
|
+
mapNeo4jPath(path) {
|
|
1113
|
+
const nodes = path.segments.reduce((acc, segment, index) => {
|
|
1114
|
+
if (index === 0) {
|
|
1115
|
+
acc.push(this.mapNeo4jNode(segment.start));
|
|
1116
|
+
}
|
|
1117
|
+
acc.push(this.mapNeo4jNode(segment.end));
|
|
1118
|
+
return acc;
|
|
1119
|
+
}, []);
|
|
1120
|
+
const relationships = path.segments.map((segment) => this.mapNeo4jRelationship(segment.relationship, segment.start.elementId || segment.start.identity.toString(), segment.end.elementId || segment.end.identity.toString()));
|
|
1597
1121
|
return {
|
|
1598
1122
|
nodes,
|
|
1599
1123
|
relationships,
|
|
1600
1124
|
length: relationships.length,
|
|
1601
|
-
start: nodes[0],
|
|
1602
|
-
end: nodes[nodes.length - 1],
|
|
1603
1125
|
};
|
|
1604
1126
|
}
|
|
1605
|
-
|
|
1127
|
+
convertNeo4jProperties(props) {
|
|
1128
|
+
const result = {};
|
|
1129
|
+
for (const [key, value] of Object.entries(props)) {
|
|
1130
|
+
result[key] = this.convertNeo4jValue(value);
|
|
1131
|
+
}
|
|
1132
|
+
return result;
|
|
1133
|
+
}
|
|
1606
1134
|
convertNeo4jValue(value) {
|
|
1607
|
-
|
|
1135
|
+
var _a, _b;
|
|
1136
|
+
if (value === null || value === undefined) {
|
|
1608
1137
|
return value;
|
|
1609
|
-
// Handle Neo4j Integer
|
|
1610
|
-
if (neo4j_driver_1.default.isInt(value)) {
|
|
1611
|
-
return this.toNumber(value);
|
|
1612
1138
|
}
|
|
1613
|
-
// Handle Neo4j
|
|
1614
|
-
if (value
|
|
1615
|
-
return
|
|
1616
|
-
}
|
|
1617
|
-
// Handle Neo4j Relationship
|
|
1618
|
-
if (value.type !== undefined && value.start !== undefined && value.end !== undefined) {
|
|
1619
|
-
return this.parseRelationship(value);
|
|
1139
|
+
// Handle Neo4j Integer type
|
|
1140
|
+
if (typeof value === 'object' && ((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Integer') {
|
|
1141
|
+
return value.toNumber();
|
|
1620
1142
|
}
|
|
1621
|
-
// Handle Neo4j
|
|
1622
|
-
if (value.
|
|
1623
|
-
return
|
|
1143
|
+
// Handle Neo4j Date types
|
|
1144
|
+
if (typeof value === 'object' && ((_b = value.constructor) === null || _b === void 0 ? void 0 : _b.name) === 'Date') {
|
|
1145
|
+
return new Date(value.toString());
|
|
1624
1146
|
}
|
|
1625
|
-
// Handle arrays
|
|
1626
1147
|
if (Array.isArray(value)) {
|
|
1627
1148
|
return value.map(v => this.convertNeo4jValue(v));
|
|
1628
1149
|
}
|
|
1629
|
-
// Handle objects
|
|
1630
|
-
if (typeof value === 'object') {
|
|
1631
|
-
const converted = {};
|
|
1632
|
-
Object.entries(value).forEach(([key, val]) => {
|
|
1633
|
-
converted[key] = this.convertNeo4jValue(val);
|
|
1634
|
-
});
|
|
1635
|
-
return converted;
|
|
1636
|
-
}
|
|
1637
1150
|
return value;
|
|
1638
1151
|
}
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
if (neo4j_driver_1.default.isInt(value)) {
|
|
1650
|
-
return value.toNumber();
|
|
1651
|
-
}
|
|
1652
|
-
if (typeof value === 'number') {
|
|
1653
|
-
return value;
|
|
1654
|
-
}
|
|
1655
|
-
return parseInt(value, 10) || 0;
|
|
1656
|
-
}
|
|
1657
|
-
normalizeLabels(labels) {
|
|
1658
|
-
return Array.isArray(labels) ? labels : [labels];
|
|
1659
|
-
}
|
|
1660
|
-
buildPropertiesClause(properties, prefix = '') {
|
|
1661
|
-
const params = {};
|
|
1662
|
-
const propParts = [];
|
|
1663
|
-
Object.entries(properties).forEach(([key, value], index) => {
|
|
1664
|
-
const paramName = `${prefix}prop_${index}`;
|
|
1665
|
-
propParts.push(`${this.escapeIdentifier(key)}: $${paramName}`);
|
|
1666
|
-
params[paramName] = value;
|
|
1667
|
-
});
|
|
1668
|
-
return {
|
|
1669
|
-
clause: `{${propParts.join(', ')}}`,
|
|
1670
|
-
params,
|
|
1671
|
-
};
|
|
1672
|
-
}
|
|
1673
|
-
buildNodeReference(ref, alias, params, prefix = '') {
|
|
1674
|
-
let pattern = `(${alias}`;
|
|
1675
|
-
if (ref.labels) {
|
|
1676
|
-
const labels = this.normalizeLabels(ref.labels);
|
|
1677
|
-
pattern += ':' + labels.map(l => this.escapeIdentifier(l)).join(':');
|
|
1678
|
-
}
|
|
1679
|
-
if (ref.id !== undefined) {
|
|
1680
|
-
const paramName = `${prefix}id`;
|
|
1681
|
-
params[paramName] = ref.id;
|
|
1682
|
-
pattern += ` {id: $${paramName}}`;
|
|
1683
|
-
}
|
|
1684
|
-
else if (ref.properties && Object.keys(ref.properties).length > 0) {
|
|
1685
|
-
const { clause, params: propParams } = this.buildPropertiesClause(ref.properties, prefix);
|
|
1686
|
-
pattern += ` ${clause}`;
|
|
1687
|
-
Object.assign(params, propParams);
|
|
1688
|
-
}
|
|
1689
|
-
pattern += ')';
|
|
1690
|
-
return pattern;
|
|
1691
|
-
}
|
|
1692
|
-
buildNodeReferenceWhere(ref, alias, params, prefix = '') {
|
|
1693
|
-
const parts = [];
|
|
1694
|
-
if (ref.id !== undefined) {
|
|
1695
|
-
const paramName = `${prefix}id`;
|
|
1696
|
-
params[paramName] = ref.id;
|
|
1697
|
-
if (typeof ref.id === 'string') {
|
|
1698
|
-
parts.push(`elementId(${alias}) = $${paramName}`);
|
|
1699
|
-
}
|
|
1700
|
-
else {
|
|
1701
|
-
parts.push(`id(${alias}) = $${paramName}`);
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
if (ref.labels) {
|
|
1705
|
-
const labels = this.normalizeLabels(ref.labels);
|
|
1706
|
-
labels.forEach(label => {
|
|
1707
|
-
parts.push(`'${label}' IN labels(${alias})`);
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
if (ref.properties) {
|
|
1711
|
-
Object.entries(ref.properties).forEach(([key, value], index) => {
|
|
1712
|
-
const paramName = `${prefix}prop_${index}`;
|
|
1713
|
-
parts.push(`${alias}.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1714
|
-
params[paramName] = value;
|
|
1715
|
-
});
|
|
1716
|
-
}
|
|
1717
|
-
return parts.join(' AND ');
|
|
1718
|
-
}
|
|
1719
|
-
buildWhereFromClause(where, alias, prefix = '') {
|
|
1720
|
-
const params = {};
|
|
1721
|
-
const clause = this.buildWhereCondition(where, alias, params, prefix);
|
|
1722
|
-
return { clause, params };
|
|
1723
|
-
}
|
|
1724
|
-
buildWhereCondition(where, alias, params, prefix, index = 0) {
|
|
1725
|
-
const paramName = `${prefix}where_${index}`;
|
|
1726
|
-
let condition;
|
|
1727
|
-
switch (where.operator) {
|
|
1728
|
-
case node_types_1.NodeComparisonOperator.IS_NULL:
|
|
1729
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} IS NULL`;
|
|
1730
|
-
break;
|
|
1731
|
-
case node_types_1.NodeComparisonOperator.IS_NOT_NULL:
|
|
1732
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} IS NOT NULL`;
|
|
1733
|
-
break;
|
|
1734
|
-
case node_types_1.NodeComparisonOperator.IN:
|
|
1735
|
-
case node_types_1.NodeComparisonOperator.NOT_IN:
|
|
1736
|
-
params[paramName] = where.value;
|
|
1737
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
|
|
1738
|
-
break;
|
|
1739
|
-
case node_types_1.NodeComparisonOperator.CONTAINS:
|
|
1740
|
-
params[paramName] = where.value;
|
|
1741
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} CONTAINS $${paramName}`;
|
|
1742
|
-
break;
|
|
1743
|
-
case node_types_1.NodeComparisonOperator.STARTS_WITH:
|
|
1744
|
-
params[paramName] = where.value;
|
|
1745
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} STARTS WITH $${paramName}`;
|
|
1746
|
-
break;
|
|
1747
|
-
case node_types_1.NodeComparisonOperator.ENDS_WITH:
|
|
1748
|
-
params[paramName] = where.value;
|
|
1749
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} ENDS WITH $${paramName}`;
|
|
1750
|
-
break;
|
|
1751
|
-
case node_types_1.NodeComparisonOperator.REGEX:
|
|
1752
|
-
params[paramName] = where.value;
|
|
1753
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} =~ $${paramName}`;
|
|
1754
|
-
break;
|
|
1152
|
+
getDirectionArrow(direction) {
|
|
1153
|
+
switch (direction) {
|
|
1154
|
+
case enums_1.TraversalDirection.OUTGOING:
|
|
1155
|
+
case 'OUTGOING':
|
|
1156
|
+
return { left: '-', right: '->' };
|
|
1157
|
+
case enums_1.TraversalDirection.INCOMING:
|
|
1158
|
+
case 'INCOMING':
|
|
1159
|
+
return { left: '<-', right: '-' };
|
|
1160
|
+
case enums_1.TraversalDirection.BOTH:
|
|
1161
|
+
case 'BOTH':
|
|
1755
1162
|
default:
|
|
1756
|
-
|
|
1757
|
-
condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
|
|
1758
|
-
}
|
|
1759
|
-
// Handle AND conditions
|
|
1760
|
-
if (where.and && where.and.length > 0) {
|
|
1761
|
-
const andClauses = where.and.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 1));
|
|
1762
|
-
condition = `(${condition} AND ${andClauses.join(' AND ')})`;
|
|
1763
|
-
}
|
|
1764
|
-
// Handle OR conditions
|
|
1765
|
-
if (where.or && where.or.length > 0) {
|
|
1766
|
-
const orClauses = where.or.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 100));
|
|
1767
|
-
condition = `(${condition} OR ${orClauses.join(' OR ')})`;
|
|
1768
|
-
}
|
|
1769
|
-
return condition;
|
|
1770
|
-
}
|
|
1771
|
-
buildRelationshipWhereClause(where, alias, prefix = '') {
|
|
1772
|
-
const params = {};
|
|
1773
|
-
const clause = this.buildRelationshipWhereCondition(where, alias, params, prefix);
|
|
1774
|
-
return { clause, params };
|
|
1775
|
-
}
|
|
1776
|
-
buildRelationshipWhereCondition(where, alias, params, prefix, index = 0) {
|
|
1777
|
-
const paramName = `${prefix}relwhere_${index}`;
|
|
1778
|
-
params[paramName] = where.value;
|
|
1779
|
-
let condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
|
|
1780
|
-
if (where.and && where.and.length > 0) {
|
|
1781
|
-
const andClauses = where.and.map((w, i) => this.buildRelationshipWhereCondition(w, alias, params, prefix, index + i + 1));
|
|
1782
|
-
condition = `(${condition} AND ${andClauses.join(' AND ')})`;
|
|
1783
|
-
}
|
|
1784
|
-
if (where.or && where.or.length > 0) {
|
|
1785
|
-
const orClauses = where.or.map((w, i) => this.buildRelationshipWhereCondition(w, alias, params, prefix, index + i + 100));
|
|
1786
|
-
condition = `(${condition} OR ${orClauses.join(' OR ')})`;
|
|
1163
|
+
return { left: '-', right: '-' };
|
|
1787
1164
|
}
|
|
1788
|
-
return condition;
|
|
1789
|
-
}
|
|
1790
|
-
buildNodeSelectorMatch(selector, alias, params, prefix = '') {
|
|
1791
|
-
let pattern = `(${alias}`;
|
|
1792
|
-
if (selector.labels) {
|
|
1793
|
-
const labels = this.normalizeLabels(selector.labels);
|
|
1794
|
-
pattern += ':' + labels.map((l) => this.escapeIdentifier(l)).join(':');
|
|
1795
|
-
}
|
|
1796
|
-
pattern += ')';
|
|
1797
|
-
const whereParts = [];
|
|
1798
|
-
if (selector.id !== undefined) {
|
|
1799
|
-
const paramName = `${prefix}id`;
|
|
1800
|
-
params[paramName] = selector.id;
|
|
1801
|
-
if (typeof selector.id === 'string') {
|
|
1802
|
-
whereParts.push(`elementId(${alias}) = $${paramName}`);
|
|
1803
|
-
}
|
|
1804
|
-
else {
|
|
1805
|
-
whereParts.push(`id(${alias}) = $${paramName}`);
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
if (selector.properties && Object.keys(selector.properties).length > 0) {
|
|
1809
|
-
Object.entries(selector.properties).forEach(([key, value], index) => {
|
|
1810
|
-
const paramName = `${prefix}prop_${index}`;
|
|
1811
|
-
whereParts.push(`${alias}.${this.escapeIdentifier(key)} = $${paramName}`);
|
|
1812
|
-
params[paramName] = value;
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
if (selector.where) {
|
|
1816
|
-
const { clause, params: whereParams } = this.buildWhereFromClause(selector.where, alias, prefix);
|
|
1817
|
-
whereParts.push(clause);
|
|
1818
|
-
Object.assign(params, whereParams);
|
|
1819
|
-
}
|
|
1820
|
-
if (whereParts.length > 0) {
|
|
1821
|
-
return `${pattern} WHERE ${whereParts.join(' AND ')}`;
|
|
1822
|
-
}
|
|
1823
|
-
return pattern;
|
|
1824
|
-
}
|
|
1825
|
-
buildTraversalRelPattern(options) {
|
|
1826
|
-
if (!options.relationships)
|
|
1827
|
-
return '';
|
|
1828
|
-
const patterns = Array.isArray(options.relationships)
|
|
1829
|
-
? options.relationships
|
|
1830
|
-
: [options.relationships];
|
|
1831
|
-
const types = patterns
|
|
1832
|
-
.filter((p) => p.type)
|
|
1833
|
-
.map((p) => {
|
|
1834
|
-
const types = Array.isArray(p.type) ? p.type : [p.type];
|
|
1835
|
-
return types.map((t) => this.escapeIdentifier(t));
|
|
1836
|
-
})
|
|
1837
|
-
.flat();
|
|
1838
|
-
return types.length > 0 ? ':' + types.join('|') : '';
|
|
1839
|
-
}
|
|
1840
|
-
parseStatistics(counters) {
|
|
1841
|
-
if (!counters)
|
|
1842
|
-
return undefined;
|
|
1843
|
-
return {
|
|
1844
|
-
nodesCreated: counters.nodesCreated ? counters.nodesCreated() : 0,
|
|
1845
|
-
nodesDeleted: counters.nodesDeleted ? counters.nodesDeleted() : 0,
|
|
1846
|
-
relationshipsCreated: counters.relationshipsCreated ? counters.relationshipsCreated() : 0,
|
|
1847
|
-
relationshipsDeleted: counters.relationshipsDeleted ? counters.relationshipsDeleted() : 0,
|
|
1848
|
-
propertiesSet: counters.propertiesSet ? counters.propertiesSet() : 0,
|
|
1849
|
-
labelsAdded: counters.labelsAdded ? counters.labelsAdded() : 0,
|
|
1850
|
-
labelsRemoved: counters.labelsRemoved ? counters.labelsRemoved() : 0,
|
|
1851
|
-
indexesAdded: counters.indexesAdded ? counters.indexesAdded() : 0,
|
|
1852
|
-
indexesRemoved: counters.indexesRemoved ? counters.indexesRemoved() : 0,
|
|
1853
|
-
constraintsAdded: counters.constraintsAdded ? counters.constraintsAdded() : 0,
|
|
1854
|
-
constraintsRemoved: counters.constraintsRemoved ? counters.constraintsRemoved() : 0,
|
|
1855
|
-
containsUpdates: counters.containsUpdates ? counters.containsUpdates() : false,
|
|
1856
|
-
};
|
|
1857
1165
|
}
|
|
1858
1166
|
}
|
|
1859
1167
|
exports.Neo4jAdapter = Neo4jAdapter;
|
|
1860
|
-
exports.default = Neo4jAdapter;
|
|
1861
1168
|
//# sourceMappingURL=neo4j.adapter.js.map
|