@ductape/sdk 0.0.4-v5 → 0.0.4-v51
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/api/services/appApi.service.d.ts +48 -2
- package/dist/api/services/appApi.service.js +101 -2
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/pricingApi.service.d.ts +10 -0
- package/dist/api/services/pricingApi.service.js +34 -0
- package/dist/api/services/pricingApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +12 -2
- package/dist/api/services/processorApi.service.js +12 -2
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +40 -1
- package/dist/api/services/productsApi.service.js +105 -1
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/userApi.service.js +1 -0
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workspaceApi.service.js +1 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +75 -0
- package/dist/api/services/workspaceSecretsApi.service.js +62 -0
- package/dist/api/services/workspaceSecretsApi.service.js.map +1 -0
- package/dist/api/urls.d.ts +6 -1
- package/dist/api/urls.js +12 -2
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.d.ts +1 -1
- package/dist/api/utils/cache.utils.js +10 -4
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/api/utils/strings.utils.d.ts +2 -0
- package/dist/api/utils/strings.utils.js +14 -0
- package/dist/api/utils/strings.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +51 -33
- package/dist/apps/services/app.service.js +488 -244
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js +21 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +2 -15
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +2 -14
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/clients/pricing.client.d.ts +3 -0
- package/dist/clients/pricing.client.js +33 -0
- package/dist/clients/pricing.client.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +176 -0
- package/dist/database/adapters/base.adapter.js +31 -0
- package/dist/database/adapters/base.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +91 -0
- package/dist/database/adapters/dynamodb.adapter.js +1608 -0
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +71 -0
- package/dist/database/adapters/mongodb.adapter.js +1072 -0
- package/dist/database/adapters/mongodb.adapter.js.map +1 -0
- package/dist/database/adapters/mysql.adapter.d.ts +146 -0
- package/dist/database/adapters/mysql.adapter.js +1492 -0
- package/dist/database/adapters/mysql.adapter.js.map +1 -0
- package/dist/database/adapters/postgresql.adapter.d.ts +147 -0
- package/dist/database/adapters/postgresql.adapter.js +1603 -0
- package/dist/database/adapters/postgresql.adapter.js.map +1 -0
- package/dist/database/database.service.d.ts +232 -0
- package/dist/database/database.service.js +802 -0
- package/dist/database/database.service.js.map +1 -0
- package/dist/database/index.d.ts +18 -0
- package/dist/database/index.js +98 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/types/aggregation.types.d.ts +261 -0
- package/dist/database/types/aggregation.types.js +21 -0
- package/dist/database/types/aggregation.types.js.map +1 -0
- package/dist/database/types/connection.types.d.ts +132 -0
- package/dist/database/types/connection.types.js +6 -0
- package/dist/database/types/connection.types.js.map +1 -0
- package/dist/database/types/database.types.d.ts +175 -0
- package/dist/database/types/database.types.js +75 -0
- package/dist/database/types/database.types.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -0
- package/dist/database/types/index.js +37 -0
- package/dist/database/types/index.js.map +1 -0
- package/dist/database/types/index.types.d.ts +220 -0
- package/dist/database/types/index.types.js +27 -0
- package/dist/database/types/index.types.js.map +1 -0
- package/dist/database/types/migration.types.d.ts +205 -0
- package/dist/database/types/migration.types.js +44 -0
- package/dist/database/types/migration.types.js.map +1 -0
- package/dist/database/types/query.types.d.ts +305 -0
- package/dist/database/types/query.types.js +57 -0
- package/dist/database/types/query.types.js.map +1 -0
- package/dist/database/types/result.types.d.ts +220 -0
- package/dist/database/types/result.types.js +6 -0
- package/dist/database/types/result.types.js.map +1 -0
- package/dist/database/types/schema.types.d.ts +190 -0
- package/dist/database/types/schema.types.js +69 -0
- package/dist/database/types/schema.types.js.map +1 -0
- package/dist/database/utils/helpers.d.ts +66 -0
- package/dist/database/utils/helpers.js +501 -0
- package/dist/database/utils/helpers.js.map +1 -0
- package/dist/database/utils/migration.utils.d.ts +151 -0
- package/dist/database/utils/migration.utils.js +476 -0
- package/dist/database/utils/migration.utils.js.map +1 -0
- package/dist/database/utils/transaction.d.ts +64 -0
- package/dist/database/utils/transaction.js +130 -0
- package/dist/database/utils/transaction.js.map +1 -0
- package/dist/database/validators/connection.validator.d.ts +20 -0
- package/dist/database/validators/connection.validator.js +267 -0
- package/dist/database/validators/connection.validator.js.map +1 -0
- package/dist/database/validators/query.validator.d.ts +31 -0
- package/dist/database/validators/query.validator.js +305 -0
- package/dist/database/validators/query.validator.js.map +1 -0
- package/dist/database/validators/schema.validator.d.ts +31 -0
- package/dist/database/validators/schema.validator.js +334 -0
- package/dist/database/validators/schema.validator.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +80 -0
- package/dist/graph/adapters/arangodb.adapter.js +1393 -0
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
- package/dist/graph/adapters/base.adapter.d.ts +228 -0
- package/dist/graph/adapters/base.adapter.js +38 -0
- package/dist/graph/adapters/base.adapter.js.map +1 -0
- package/dist/graph/adapters/index.d.ts +10 -0
- package/dist/graph/adapters/index.js +23 -0
- package/dist/graph/adapters/index.js.map +1 -0
- package/dist/graph/adapters/memgraph.adapter.d.ts +85 -0
- package/dist/graph/adapters/memgraph.adapter.js +1491 -0
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
- package/dist/graph/adapters/neo4j.adapter.d.ts +88 -0
- package/dist/graph/adapters/neo4j.adapter.js +1861 -0
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
- package/dist/graph/adapters/neptune.adapter.d.ts +87 -0
- package/dist/graph/adapters/neptune.adapter.js +1430 -0
- package/dist/graph/adapters/neptune.adapter.js.map +1 -0
- package/dist/graph/graph.service.d.ts +278 -0
- package/dist/graph/graph.service.js +687 -0
- package/dist/graph/graph.service.js.map +1 -0
- package/dist/graph/index.d.ts +11 -0
- package/dist/graph/index.js +42 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/types/connection.types.d.ts +158 -0
- package/dist/graph/types/connection.types.js +43 -0
- package/dist/graph/types/connection.types.js.map +1 -0
- package/dist/graph/types/graph.types.d.ts +144 -0
- package/dist/graph/types/graph.types.js +84 -0
- package/dist/graph/types/graph.types.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -0
- package/dist/graph/types/index.js +35 -0
- package/dist/graph/types/index.js.map +1 -0
- package/dist/graph/types/node.types.d.ts +193 -0
- package/dist/graph/types/node.types.js +49 -0
- package/dist/graph/types/node.types.js.map +1 -0
- package/dist/graph/types/path.types.d.ts +224 -0
- package/dist/graph/types/path.types.js +38 -0
- package/dist/graph/types/path.types.js.map +1 -0
- package/dist/graph/types/query.types.d.ts +247 -0
- package/dist/graph/types/query.types.js +23 -0
- package/dist/graph/types/query.types.js.map +1 -0
- package/dist/graph/types/relationship.types.d.ts +224 -0
- package/dist/graph/types/relationship.types.js +35 -0
- package/dist/graph/types/relationship.types.js.map +1 -0
- package/dist/graph/types/result.types.d.ts +237 -0
- package/dist/graph/types/result.types.js +7 -0
- package/dist/graph/types/result.types.js.map +1 -0
- package/dist/graph/validators/index.d.ts +81 -0
- package/dist/graph/validators/index.js +243 -0
- package/dist/graph/validators/index.js.map +1 -0
- package/dist/imports/imports.service.d.ts +3 -3
- package/dist/imports/imports.service.js +7 -7
- package/dist/imports/imports.service.js.map +1 -1
- package/dist/imports/imports.types.d.ts +8 -0
- package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
- package/dist/imports/repos/postmanV21.repo.js +29 -2
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +1244 -150
- package/dist/index.js +1309 -209
- package/dist/index.js.map +1 -1
- package/dist/inputs/inputs.service.js +2 -2
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/inputs/utils/inputs.utils.create.js +1 -1
- package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
- package/dist/logs/logs.types.d.ts +5 -0
- package/dist/logs/logs.types.js +1 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +27 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
- package/dist/parsers/pipelines/postman.pipelines.js +103 -0
- package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
- package/dist/parsers/types/postman.types.d.ts +200 -0
- package/dist/parsers/types/postman.types.js +3 -0
- package/dist/parsers/types/postman.types.js.map +1 -0
- package/dist/parsers/utils/postman.utils.d.ts +12 -0
- package/dist/parsers/utils/postman.utils.js +116 -0
- package/dist/parsers/utils/postman.utils.js.map +1 -0
- package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
- package/dist/parsers/validators/postman-auth.validators.js +127 -0
- package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
- package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-request.validators.js +139 -0
- package/dist/parsers/validators/postman-request.validators.js.map +1 -0
- package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-response.validators.js +150 -0
- package/dist/parsers/validators/postman-response.validators.js.map +1 -0
- package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
- package/dist/parsers/validators/postman-variable.validators.js +163 -0
- package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
- package/dist/pricing/pricing.repo.d.ts +0 -0
- package/dist/pricing/pricing.repo.js +1 -0
- package/dist/pricing/pricing.repo.js.map +1 -0
- package/dist/pricing/pricing.service.d.ts +24 -0
- package/dist/pricing/pricing.service.js +51 -0
- package/dist/pricing/pricing.service.js.map +1 -0
- package/dist/pricing/pricing.types.d.ts +76 -0
- package/dist/pricing/pricing.types.js +21 -0
- package/dist/pricing/pricing.types.js.map +1 -0
- package/dist/pricing/utils/string.utils.d.ts +1 -0
- package/dist/pricing/utils/string.utils.js +9 -0
- package/dist/pricing/utils/string.utils.js.map +1 -0
- package/dist/processor/repos/sms.repo.d.ts +4 -4
- package/dist/processor/repos/sms.repo.js +23 -10
- package/dist/processor/repos/sms.repo.js.map +1 -1
- package/dist/processor/services/messagebrokers/kafka.service.js +0 -2
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +9 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +40 -11
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +38 -10
- package/dist/processor/services/processor.service.js +533 -248
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/request.service.d.ts +36 -0
- package/dist/processor/services/request.service.js +304 -0
- package/dist/processor/services/request.service.js.map +1 -0
- package/dist/processor/types/request.types.d.ts +14 -0
- package/dist/processor/types/request.types.js +3 -0
- package/dist/processor/types/request.types.js.map +1 -0
- package/dist/processor/utils/processor.utils.d.ts +3 -0
- package/dist/processor/utils/processor.utils.js +84 -22
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/processor/utils/request.utils.d.ts +20 -0
- package/dist/processor/utils/request.utils.js +113 -0
- package/dist/processor/utils/request.utils.js.map +1 -0
- package/dist/products/services/products.service.d.ts +114 -77
- package/dist/products/services/products.service.js +805 -362
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/services/utils/crypt.utils.d.ts +1 -0
- package/dist/products/services/utils/crypt.utils.js +17 -0
- package/dist/products/services/utils/crypt.utils.js.map +1 -0
- package/dist/products/services/utils/functions.utils.d.ts +13 -0
- package/dist/products/services/utils/functions.utils.js +289 -0
- package/dist/products/services/utils/functions.utils.js.map +1 -0
- package/dist/products/services/utils/objects.utils.d.ts +13 -0
- package/dist/products/services/utils/objects.utils.js +89 -0
- package/dist/products/services/utils/objects.utils.js.map +1 -0
- package/dist/products/services/utils/string.utils.d.ts +12 -0
- package/dist/products/services/utils/string.utils.js +168 -0
- package/dist/products/services/utils/string.utils.js.map +1 -0
- package/dist/products/utils/string.utils.d.ts +1 -1
- package/dist/products/utils/string.utils.js +14 -2
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +4 -1
- package/dist/products/validators/index.js +7 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +15 -4
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +501 -109
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +82 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +14 -0
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +696 -0
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +9 -4
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +5 -2
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.dataValue.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +6 -0
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +28 -26
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
- package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +87 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +7 -0
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +72 -0
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -1
- package/dist/test/test.health.d.ts +1 -0
- package/dist/test/test.health.js +49 -0
- package/dist/test/test.health.js.map +1 -0
- package/dist/test/test.import.js +51 -4
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.imports.js +22 -7
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +1 -0
- package/dist/test/test.notifiers.js +85 -0
- package/dist/test/test.notifiers.js.map +1 -0
- package/dist/test/test.processor.js +30 -115
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.products.d.ts +1 -0
- package/dist/test/test.products.js +49 -0
- package/dist/test/test.products.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/appBuilder.types.d.ts +5 -12
- package/dist/types/enums.d.ts +4 -1
- package/dist/types/enums.js +3 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +4 -0
- package/dist/types/pricing.types.d.ts +4 -0
- package/dist/types/pricing.types.js +3 -0
- package/dist/types/pricing.types.js.map +1 -0
- package/dist/types/processor.types.d.ts +67 -11
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +132 -14
- package/dist/types/productsBuilder.types.js +69 -4
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/request-tracker.interface.d.ts +0 -0
- package/dist/types/request-tracker.interface.js +1 -0
- package/dist/types/request-tracker.interface.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/package.json +17 -3
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Graph Service
|
|
4
|
+
* Main entry point for graph database operations in Ductape SDK
|
|
5
|
+
*
|
|
6
|
+
* Provides a unified interface for interacting with graph databases
|
|
7
|
+
* including Neo4j, AWS Neptune, ArangoDB, and Memgraph
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.GraphService = void 0;
|
|
14
|
+
exports.createGraphService = createGraphService;
|
|
15
|
+
const adapters_1 = require("./adapters");
|
|
16
|
+
const graph_types_1 = require("./types/graph.types");
|
|
17
|
+
const connection_types_1 = require("./types/connection.types");
|
|
18
|
+
const products_service_1 = __importDefault(require("../products/services/products.service"));
|
|
19
|
+
const productsBuilder_types_1 = require("../types/productsBuilder.types");
|
|
20
|
+
const index_types_1 = require("../types/index.types");
|
|
21
|
+
const logs_service_1 = __importDefault(require("../logs/logs.service"));
|
|
22
|
+
const logs_types_1 = require("../logs/logs.types");
|
|
23
|
+
const uuid_1 = require("uuid");
|
|
24
|
+
/**
|
|
25
|
+
* Graph Service Class
|
|
26
|
+
* Provides a high-level API for graph database operations
|
|
27
|
+
*/
|
|
28
|
+
class GraphService {
|
|
29
|
+
constructor(config) {
|
|
30
|
+
this.adapters = new Map();
|
|
31
|
+
this.connectionPool = new Map();
|
|
32
|
+
this.currentConnection = null;
|
|
33
|
+
this.currentAdapter = null;
|
|
34
|
+
this.config = config;
|
|
35
|
+
this.initializeAdapters();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Initialize all supported adapters
|
|
39
|
+
*/
|
|
40
|
+
initializeAdapters() {
|
|
41
|
+
this.adapters.set(graph_types_1.GraphDatabaseType.NEO4J, new adapters_1.Neo4jAdapter());
|
|
42
|
+
this.adapters.set(graph_types_1.GraphDatabaseType.NEPTUNE, new adapters_1.NeptuneAdapter());
|
|
43
|
+
this.adapters.set(graph_types_1.GraphDatabaseType.ARANGODB, new adapters_1.ArangoDBAdapter());
|
|
44
|
+
this.adapters.set(graph_types_1.GraphDatabaseType.MEMGRAPH, new adapters_1.MemgraphAdapter());
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get adapter for a specific database type
|
|
48
|
+
*/
|
|
49
|
+
getAdapter(type) {
|
|
50
|
+
const adapter = this.adapters.get(type);
|
|
51
|
+
if (!adapter) {
|
|
52
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `No adapter available for database type: ${type}`);
|
|
53
|
+
}
|
|
54
|
+
return adapter;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate a unique connection key
|
|
58
|
+
*/
|
|
59
|
+
getConnectionKey(config) {
|
|
60
|
+
const baseKey = `${config.type}-${config.env}`;
|
|
61
|
+
if (config.connectionTag) {
|
|
62
|
+
return `${baseKey}-${config.connectionTag}`;
|
|
63
|
+
}
|
|
64
|
+
return baseKey;
|
|
65
|
+
}
|
|
66
|
+
// ==================== CONNECTION MANAGEMENT ====================
|
|
67
|
+
/**
|
|
68
|
+
* Connect to a graph database
|
|
69
|
+
*/
|
|
70
|
+
async connect(config) {
|
|
71
|
+
let resolvedConfig;
|
|
72
|
+
if ((0, connection_types_1.isProductGraphConfig)(config)) {
|
|
73
|
+
// Resolve product-based configuration
|
|
74
|
+
resolvedConfig = await this.resolveProductConfig(config);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
resolvedConfig = config;
|
|
78
|
+
}
|
|
79
|
+
const connectionKey = this.getConnectionKey(resolvedConfig);
|
|
80
|
+
// Check if connection already exists in pool
|
|
81
|
+
const pooled = this.connectionPool.get(connectionKey);
|
|
82
|
+
if (pooled && pooled.connection.isConnected()) {
|
|
83
|
+
pooled.inUse = true;
|
|
84
|
+
pooled.lastUsed = new Date();
|
|
85
|
+
this.currentConnection = pooled.connection;
|
|
86
|
+
this.currentAdapter = pooled.adapter;
|
|
87
|
+
return pooled.connection;
|
|
88
|
+
}
|
|
89
|
+
// Create new connection
|
|
90
|
+
const adapter = this.getAdapter(resolvedConfig.type);
|
|
91
|
+
const connection = await adapter.connect(resolvedConfig);
|
|
92
|
+
// Add to pool
|
|
93
|
+
this.connectionPool.set(connectionKey, {
|
|
94
|
+
connection,
|
|
95
|
+
adapter,
|
|
96
|
+
lastUsed: new Date(),
|
|
97
|
+
inUse: true,
|
|
98
|
+
});
|
|
99
|
+
this.currentConnection = connection;
|
|
100
|
+
this.currentAdapter = adapter;
|
|
101
|
+
return connection;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Disconnect from a graph database
|
|
105
|
+
*/
|
|
106
|
+
async disconnect(connection) {
|
|
107
|
+
const conn = connection || this.currentConnection;
|
|
108
|
+
if (!conn) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// Find in pool and mark as not in use
|
|
112
|
+
for (const [key, pooled] of this.connectionPool.entries()) {
|
|
113
|
+
if (pooled.connection === conn) {
|
|
114
|
+
pooled.inUse = false;
|
|
115
|
+
await pooled.adapter.disconnect(conn);
|
|
116
|
+
this.connectionPool.delete(key);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (conn === this.currentConnection) {
|
|
121
|
+
this.currentConnection = null;
|
|
122
|
+
this.currentAdapter = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Disconnect all connections
|
|
127
|
+
*/
|
|
128
|
+
async disconnectAll() {
|
|
129
|
+
for (const [key, pooled] of this.connectionPool.entries()) {
|
|
130
|
+
await pooled.adapter.disconnect(pooled.connection);
|
|
131
|
+
}
|
|
132
|
+
this.connectionPool.clear();
|
|
133
|
+
this.currentConnection = null;
|
|
134
|
+
this.currentAdapter = null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Test a connection
|
|
138
|
+
*/
|
|
139
|
+
async testConnection(config) {
|
|
140
|
+
if (config) {
|
|
141
|
+
const connection = await this.connect(config);
|
|
142
|
+
const adapter = this.currentAdapter;
|
|
143
|
+
const result = await adapter.testConnection(connection);
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
if (!this.currentConnection || !this.currentAdapter) {
|
|
147
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'No active connection. Call connect() first or provide a config.');
|
|
148
|
+
}
|
|
149
|
+
return this.currentAdapter.testConnection(this.currentConnection);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get database info
|
|
153
|
+
*/
|
|
154
|
+
async getDatabaseInfo() {
|
|
155
|
+
this.ensureConnection();
|
|
156
|
+
return this.currentAdapter.getDatabaseInfo(this.currentConnection);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Resolve product-based configuration
|
|
160
|
+
* In a real implementation, this would fetch config from Ductape API
|
|
161
|
+
*/
|
|
162
|
+
async resolveProductConfig(config) {
|
|
163
|
+
// This would typically call the Ductape API to get the actual connection config
|
|
164
|
+
// For now, throw an error indicating this needs to be implemented
|
|
165
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Product-based graph configuration requires Ductape API integration. Use direct connection config instead.');
|
|
166
|
+
}
|
|
167
|
+
// ==================== TRANSACTION MANAGEMENT ====================
|
|
168
|
+
/**
|
|
169
|
+
* Begin a transaction
|
|
170
|
+
*/
|
|
171
|
+
async beginTransaction(options) {
|
|
172
|
+
this.ensureConnection();
|
|
173
|
+
return this.currentAdapter.beginTransaction(this.currentConnection, options);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Commit a transaction
|
|
177
|
+
*/
|
|
178
|
+
async commitTransaction(transaction) {
|
|
179
|
+
this.ensureConnection();
|
|
180
|
+
return this.currentAdapter.commitTransaction(this.currentConnection, transaction);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Rollback a transaction
|
|
184
|
+
*/
|
|
185
|
+
async rollbackTransaction(transaction) {
|
|
186
|
+
this.ensureConnection();
|
|
187
|
+
return this.currentAdapter.rollbackTransaction(this.currentConnection, transaction);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Execute operations within a transaction
|
|
191
|
+
*/
|
|
192
|
+
async executeTransaction(callback, options) {
|
|
193
|
+
this.ensureConnection();
|
|
194
|
+
return this.currentAdapter.executeTransaction(this.currentConnection, callback, options);
|
|
195
|
+
}
|
|
196
|
+
// ==================== RAW QUERY ====================
|
|
197
|
+
/**
|
|
198
|
+
* Execute a raw query
|
|
199
|
+
*/
|
|
200
|
+
async query(query, params, options) {
|
|
201
|
+
this.ensureConnection();
|
|
202
|
+
return this.currentAdapter.executeRaw(this.currentConnection, Object.assign({ query, params }, options));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Execute a raw query with full options
|
|
206
|
+
*/
|
|
207
|
+
async executeRaw(options, transaction) {
|
|
208
|
+
this.ensureConnection();
|
|
209
|
+
return this.currentAdapter.executeRaw(this.currentConnection, options, transaction);
|
|
210
|
+
}
|
|
211
|
+
// ==================== NODE OPERATIONS ====================
|
|
212
|
+
/**
|
|
213
|
+
* Create a node
|
|
214
|
+
*/
|
|
215
|
+
async createNode(options, transaction) {
|
|
216
|
+
this.ensureConnection();
|
|
217
|
+
return this.currentAdapter.createNode(this.currentConnection, options, transaction);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Find nodes
|
|
221
|
+
*/
|
|
222
|
+
async findNodes(options, transaction) {
|
|
223
|
+
this.ensureConnection();
|
|
224
|
+
return this.currentAdapter.findNodes(this.currentConnection, options, transaction);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Find a single node by ID
|
|
228
|
+
*/
|
|
229
|
+
async findNodeById(id, transaction) {
|
|
230
|
+
this.ensureConnection();
|
|
231
|
+
return this.currentAdapter.findNodeById(this.currentConnection, id, transaction);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Update a node
|
|
235
|
+
*/
|
|
236
|
+
async updateNode(options, transaction) {
|
|
237
|
+
this.ensureConnection();
|
|
238
|
+
return this.currentAdapter.updateNode(this.currentConnection, options, transaction);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Delete node(s)
|
|
242
|
+
*/
|
|
243
|
+
async deleteNode(options, transaction) {
|
|
244
|
+
this.ensureConnection();
|
|
245
|
+
return this.currentAdapter.deleteNode(this.currentConnection, options, transaction);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Merge a node (create if not exists, update if exists)
|
|
249
|
+
*/
|
|
250
|
+
async mergeNode(options, transaction) {
|
|
251
|
+
this.ensureConnection();
|
|
252
|
+
return this.currentAdapter.mergeNode(this.currentConnection, options, transaction);
|
|
253
|
+
}
|
|
254
|
+
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
255
|
+
/**
|
|
256
|
+
* Create a relationship
|
|
257
|
+
*/
|
|
258
|
+
async createRelationship(options, transaction) {
|
|
259
|
+
this.ensureConnection();
|
|
260
|
+
return this.currentAdapter.createRelationship(this.currentConnection, options, transaction);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Find relationships
|
|
264
|
+
*/
|
|
265
|
+
async findRelationships(options, transaction) {
|
|
266
|
+
this.ensureConnection();
|
|
267
|
+
return this.currentAdapter.findRelationships(this.currentConnection, options, transaction);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Find a single relationship by ID
|
|
271
|
+
*/
|
|
272
|
+
async findRelationshipById(id, transaction) {
|
|
273
|
+
this.ensureConnection();
|
|
274
|
+
return this.currentAdapter.findRelationshipById(this.currentConnection, id, transaction);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Update a relationship
|
|
278
|
+
*/
|
|
279
|
+
async updateRelationship(options, transaction) {
|
|
280
|
+
this.ensureConnection();
|
|
281
|
+
return this.currentAdapter.updateRelationship(this.currentConnection, options, transaction);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Delete relationship(s)
|
|
285
|
+
*/
|
|
286
|
+
async deleteRelationship(options, transaction) {
|
|
287
|
+
this.ensureConnection();
|
|
288
|
+
return this.currentAdapter.deleteRelationship(this.currentConnection, options, transaction);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Merge a relationship
|
|
292
|
+
*/
|
|
293
|
+
async mergeRelationship(options, transaction) {
|
|
294
|
+
this.ensureConnection();
|
|
295
|
+
return this.currentAdapter.mergeRelationship(this.currentConnection, options, transaction);
|
|
296
|
+
}
|
|
297
|
+
// ==================== PATH & TRAVERSAL OPERATIONS ====================
|
|
298
|
+
/**
|
|
299
|
+
* Traverse the graph
|
|
300
|
+
*/
|
|
301
|
+
async traverse(options, transaction) {
|
|
302
|
+
this.ensureConnection();
|
|
303
|
+
return this.currentAdapter.traverse(this.currentConnection, options, transaction);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Find shortest path
|
|
307
|
+
*/
|
|
308
|
+
async shortestPath(options, transaction) {
|
|
309
|
+
this.ensureConnection();
|
|
310
|
+
return this.currentAdapter.shortestPath(this.currentConnection, options, transaction);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Find all paths between nodes
|
|
314
|
+
*/
|
|
315
|
+
async allPaths(options, transaction) {
|
|
316
|
+
this.ensureConnection();
|
|
317
|
+
return this.currentAdapter.allPaths(this.currentConnection, options, transaction);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Match a graph pattern
|
|
321
|
+
*/
|
|
322
|
+
async matchPattern(options, transaction) {
|
|
323
|
+
this.ensureConnection();
|
|
324
|
+
return this.currentAdapter.matchPattern(this.currentConnection, options, transaction);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Extract a subgraph
|
|
328
|
+
*/
|
|
329
|
+
async extractSubgraph(options, transaction) {
|
|
330
|
+
this.ensureConnection();
|
|
331
|
+
return this.currentAdapter.extractSubgraph(this.currentConnection, options, transaction);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get node neighborhood
|
|
335
|
+
*/
|
|
336
|
+
async getNeighborhood(options, transaction) {
|
|
337
|
+
this.ensureConnection();
|
|
338
|
+
return this.currentAdapter.getNeighborhood(this.currentConnection, options, transaction);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Find connected components
|
|
342
|
+
*/
|
|
343
|
+
async findConnectedComponents(options, transaction) {
|
|
344
|
+
this.ensureConnection();
|
|
345
|
+
return this.currentAdapter.findConnectedComponents(this.currentConnection, options, transaction);
|
|
346
|
+
}
|
|
347
|
+
// ==================== AGGREGATION OPERATIONS ====================
|
|
348
|
+
/**
|
|
349
|
+
* Count nodes
|
|
350
|
+
*/
|
|
351
|
+
async countNodes(labels, where, transaction) {
|
|
352
|
+
this.ensureConnection();
|
|
353
|
+
return this.currentAdapter.countNodes(this.currentConnection, labels, where, transaction);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Count relationships
|
|
357
|
+
*/
|
|
358
|
+
async countRelationships(type, where, transaction) {
|
|
359
|
+
this.ensureConnection();
|
|
360
|
+
return this.currentAdapter.countRelationships(this.currentConnection, type, where, transaction);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Get graph statistics
|
|
364
|
+
*/
|
|
365
|
+
async getStatistics(transaction) {
|
|
366
|
+
this.ensureConnection();
|
|
367
|
+
return this.currentAdapter.getStatistics(this.currentConnection, transaction);
|
|
368
|
+
}
|
|
369
|
+
// ==================== SEARCH OPERATIONS ====================
|
|
370
|
+
/**
|
|
371
|
+
* Full-text search
|
|
372
|
+
*/
|
|
373
|
+
async fullTextSearch(options, transaction) {
|
|
374
|
+
this.ensureConnection();
|
|
375
|
+
return this.currentAdapter.fullTextSearch(this.currentConnection, options, transaction);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Vector similarity search
|
|
379
|
+
*/
|
|
380
|
+
async vectorSearch(options, transaction) {
|
|
381
|
+
this.ensureConnection();
|
|
382
|
+
return this.currentAdapter.vectorSearch(this.currentConnection, options, transaction);
|
|
383
|
+
}
|
|
384
|
+
// ==================== SCHEMA OPERATIONS ====================
|
|
385
|
+
/**
|
|
386
|
+
* Create a constraint on nodes
|
|
387
|
+
*/
|
|
388
|
+
async createNodeConstraint(constraint, transaction) {
|
|
389
|
+
this.ensureConnection();
|
|
390
|
+
return this.currentAdapter.createNodeConstraint(this.currentConnection, constraint, transaction);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Create a constraint on relationships
|
|
394
|
+
*/
|
|
395
|
+
async createRelationshipConstraint(constraint, transaction) {
|
|
396
|
+
this.ensureConnection();
|
|
397
|
+
return this.currentAdapter.createRelationshipConstraint(this.currentConnection, constraint, transaction);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Drop a constraint
|
|
401
|
+
*/
|
|
402
|
+
async dropConstraint(name, transaction) {
|
|
403
|
+
this.ensureConnection();
|
|
404
|
+
return this.currentAdapter.dropConstraint(this.currentConnection, name, transaction);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* List all constraints
|
|
408
|
+
*/
|
|
409
|
+
async listConstraints(transaction) {
|
|
410
|
+
this.ensureConnection();
|
|
411
|
+
return this.currentAdapter.listConstraints(this.currentConnection, transaction);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Create an index on nodes
|
|
415
|
+
*/
|
|
416
|
+
async createNodeIndex(index, transaction) {
|
|
417
|
+
this.ensureConnection();
|
|
418
|
+
return this.currentAdapter.createNodeIndex(this.currentConnection, index, transaction);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Create an index on relationships
|
|
422
|
+
*/
|
|
423
|
+
async createRelationshipIndex(index, transaction) {
|
|
424
|
+
this.ensureConnection();
|
|
425
|
+
return this.currentAdapter.createRelationshipIndex(this.currentConnection, index, transaction);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Drop an index
|
|
429
|
+
*/
|
|
430
|
+
async dropIndex(name, transaction) {
|
|
431
|
+
this.ensureConnection();
|
|
432
|
+
return this.currentAdapter.dropIndex(this.currentConnection, name, transaction);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* List all indexes
|
|
436
|
+
*/
|
|
437
|
+
async listIndexes(transaction) {
|
|
438
|
+
this.ensureConnection();
|
|
439
|
+
return this.currentAdapter.listIndexes(this.currentConnection, transaction);
|
|
440
|
+
}
|
|
441
|
+
// ==================== EXECUTE ACTION METHODS ====================
|
|
442
|
+
/**
|
|
443
|
+
* Execute a graph action by tag
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* await ductape.graph.execute({
|
|
448
|
+
* product: 'my-product',
|
|
449
|
+
* env: 'production',
|
|
450
|
+
* graph: 'my-graph',
|
|
451
|
+
* action: 'find-users',
|
|
452
|
+
* input: { name: 'John' }
|
|
453
|
+
* });
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
async execute(options) {
|
|
457
|
+
const { product, env, graph, action: actionTag, input = {} } = options;
|
|
458
|
+
const startTime = Date.now();
|
|
459
|
+
const processId = (0, uuid_1.v4)();
|
|
460
|
+
let logService = null;
|
|
461
|
+
const productTag = product;
|
|
462
|
+
try {
|
|
463
|
+
// Create ProductBuilder instance to fetch action
|
|
464
|
+
const productBuilder = new products_service_1.default({
|
|
465
|
+
workspace_id: this.config.workspace_id,
|
|
466
|
+
user_id: this.config.user_id,
|
|
467
|
+
public_key: this.config.public_key,
|
|
468
|
+
token: this.config.token,
|
|
469
|
+
env_type: this.config.env_type || index_types_1.EnvType.PRODUCTION,
|
|
470
|
+
redis_client: this.config.redis_client,
|
|
471
|
+
});
|
|
472
|
+
// Initialize the product
|
|
473
|
+
await productBuilder.initializeProductByTag(product);
|
|
474
|
+
// Initialize LogsService for fire-and-forget logging
|
|
475
|
+
logService = new logs_service_1.default({
|
|
476
|
+
workspace_id: this.config.workspace_id,
|
|
477
|
+
user_id: this.config.user_id,
|
|
478
|
+
public_key: this.config.public_key,
|
|
479
|
+
token: this.config.token,
|
|
480
|
+
product_id: productBuilder.fetchProductId(),
|
|
481
|
+
env_type: this.config.env_type || index_types_1.EnvType.PRODUCTION,
|
|
482
|
+
app_id: null,
|
|
483
|
+
});
|
|
484
|
+
// Fetch the graph action
|
|
485
|
+
const fullActionTag = `${graph}:${actionTag}`;
|
|
486
|
+
const graphAction = await productBuilder.fetchGraphAction(fullActionTag);
|
|
487
|
+
if (!graphAction) {
|
|
488
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.QUERY_ERROR, `Graph action '${fullActionTag}' not found in product '${product}'`);
|
|
489
|
+
}
|
|
490
|
+
// Connect to the graph database using product config
|
|
491
|
+
await this.connect({
|
|
492
|
+
env,
|
|
493
|
+
product,
|
|
494
|
+
graph,
|
|
495
|
+
});
|
|
496
|
+
// Process the action template with input parameters
|
|
497
|
+
const processedQuery = this.processActionTemplate(graphAction, input);
|
|
498
|
+
// Execute based on action type
|
|
499
|
+
let result;
|
|
500
|
+
switch (graphAction.type) {
|
|
501
|
+
case productsBuilder_types_1.GraphActionTypes.FIND_NODES:
|
|
502
|
+
result = await this.findNodes(processedQuery).then(res => res.nodes);
|
|
503
|
+
break;
|
|
504
|
+
case productsBuilder_types_1.GraphActionTypes.FIND_NODE_BY_ID:
|
|
505
|
+
result = await this.findNodeById(processedQuery.id).then(res => res);
|
|
506
|
+
break;
|
|
507
|
+
case productsBuilder_types_1.GraphActionTypes.CREATE_NODE:
|
|
508
|
+
result = await this.createNode(processedQuery).then(res => res.node);
|
|
509
|
+
break;
|
|
510
|
+
case productsBuilder_types_1.GraphActionTypes.UPDATE_NODE:
|
|
511
|
+
result = await this.updateNode(processedQuery).then(res => res.node);
|
|
512
|
+
break;
|
|
513
|
+
case productsBuilder_types_1.GraphActionTypes.DELETE_NODE:
|
|
514
|
+
result = await this.deleteNode(processedQuery).then(res => res);
|
|
515
|
+
break;
|
|
516
|
+
case productsBuilder_types_1.GraphActionTypes.MERGE_NODE:
|
|
517
|
+
result = await this.mergeNode(processedQuery).then(res => res.node);
|
|
518
|
+
break;
|
|
519
|
+
case productsBuilder_types_1.GraphActionTypes.FIND_RELATIONSHIPS:
|
|
520
|
+
result = await this.findRelationships(processedQuery).then(res => res.relationships);
|
|
521
|
+
break;
|
|
522
|
+
case productsBuilder_types_1.GraphActionTypes.CREATE_RELATIONSHIP:
|
|
523
|
+
result = await this.createRelationship(processedQuery).then(res => res.relationship);
|
|
524
|
+
break;
|
|
525
|
+
case productsBuilder_types_1.GraphActionTypes.UPDATE_RELATIONSHIP:
|
|
526
|
+
result = await this.updateRelationship(processedQuery).then(res => res.relationship);
|
|
527
|
+
break;
|
|
528
|
+
case productsBuilder_types_1.GraphActionTypes.DELETE_RELATIONSHIP:
|
|
529
|
+
result = await this.deleteRelationship(processedQuery).then(res => res);
|
|
530
|
+
break;
|
|
531
|
+
case productsBuilder_types_1.GraphActionTypes.MERGE_RELATIONSHIP:
|
|
532
|
+
result = await this.mergeRelationship(processedQuery).then(res => res.relationship);
|
|
533
|
+
break;
|
|
534
|
+
case productsBuilder_types_1.GraphActionTypes.TRAVERSE:
|
|
535
|
+
result = await this.traverse(processedQuery).then(res => res);
|
|
536
|
+
break;
|
|
537
|
+
case productsBuilder_types_1.GraphActionTypes.SHORTEST_PATH:
|
|
538
|
+
result = await this.shortestPath(processedQuery).then(res => res);
|
|
539
|
+
break;
|
|
540
|
+
case productsBuilder_types_1.GraphActionTypes.RAW_QUERY:
|
|
541
|
+
result = await this.query(processedQuery.query, processedQuery.params).then(res => res.data);
|
|
542
|
+
break;
|
|
543
|
+
default:
|
|
544
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.QUERY_ERROR, `Unsupported action type: ${graphAction.type}`);
|
|
545
|
+
}
|
|
546
|
+
// Fire-and-forget success logging
|
|
547
|
+
if (logService) {
|
|
548
|
+
logService.add({
|
|
549
|
+
process_id: processId,
|
|
550
|
+
product_tag: productTag,
|
|
551
|
+
env,
|
|
552
|
+
type: logs_types_1.LogEventTypes.GRAPH_ACTION,
|
|
553
|
+
action: fullActionTag,
|
|
554
|
+
status: logs_types_1.LogEventStatus.SUCCESS,
|
|
555
|
+
start: startTime,
|
|
556
|
+
end: Date.now(),
|
|
557
|
+
data: { action: actionTag, graph, actionType: graphAction.type },
|
|
558
|
+
});
|
|
559
|
+
logService.publish().catch(() => { }); // Silent fail - don't affect main request
|
|
560
|
+
}
|
|
561
|
+
return result;
|
|
562
|
+
}
|
|
563
|
+
catch (error) {
|
|
564
|
+
// Fire-and-forget failure logging
|
|
565
|
+
if (logService) {
|
|
566
|
+
logService.add({
|
|
567
|
+
process_id: processId,
|
|
568
|
+
product_tag: productTag,
|
|
569
|
+
env,
|
|
570
|
+
type: logs_types_1.LogEventTypes.GRAPH_ACTION,
|
|
571
|
+
action: `${graph}:${actionTag}`,
|
|
572
|
+
status: logs_types_1.LogEventStatus.FAIL,
|
|
573
|
+
start: startTime,
|
|
574
|
+
end: Date.now(),
|
|
575
|
+
data: { action: actionTag, graph, error: error.message },
|
|
576
|
+
});
|
|
577
|
+
logService.publish().catch(() => { }); // Silent fail - don't affect main request
|
|
578
|
+
}
|
|
579
|
+
if (error instanceof graph_types_1.GraphError) {
|
|
580
|
+
throw error;
|
|
581
|
+
}
|
|
582
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.QUERY_ERROR, `Failed to execute graph action: ${error.message}`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Process action template with input parameters
|
|
587
|
+
*/
|
|
588
|
+
processActionTemplate(action, input) {
|
|
589
|
+
let template = action.template;
|
|
590
|
+
// If template is a string, parse it as JSON
|
|
591
|
+
if (typeof template === 'string') {
|
|
592
|
+
try {
|
|
593
|
+
template = JSON.parse(template);
|
|
594
|
+
}
|
|
595
|
+
catch (_a) {
|
|
596
|
+
// If it's not valid JSON, return it as a raw query
|
|
597
|
+
return { query: this.replaceTemplateParams(template, input), params: input };
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
// Deep clone to avoid mutation
|
|
601
|
+
const processed = JSON.parse(JSON.stringify(template));
|
|
602
|
+
// Replace parameters in the template
|
|
603
|
+
return this.replaceParamsInObject(processed, input);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Replace template parameters with actual values
|
|
607
|
+
*/
|
|
608
|
+
replaceTemplateParams(template, params) {
|
|
609
|
+
let result = template;
|
|
610
|
+
for (const [key, value] of Object.entries(params)) {
|
|
611
|
+
const placeholder = new RegExp(`\\{\\{${key}\\}\\}`, 'g');
|
|
612
|
+
result = result.replace(placeholder, typeof value === 'string' ? value : JSON.stringify(value));
|
|
613
|
+
}
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Recursively replace parameters in an object
|
|
618
|
+
*/
|
|
619
|
+
replaceParamsInObject(obj, params) {
|
|
620
|
+
if (typeof obj === 'string') {
|
|
621
|
+
// Check if it's a parameter placeholder
|
|
622
|
+
const match = obj.match(/^\{\{(\w+)\}\}$/);
|
|
623
|
+
if (match) {
|
|
624
|
+
const paramName = match[1];
|
|
625
|
+
return params[paramName] !== undefined ? params[paramName] : obj;
|
|
626
|
+
}
|
|
627
|
+
// Replace inline parameters
|
|
628
|
+
return this.replaceTemplateParams(obj, params);
|
|
629
|
+
}
|
|
630
|
+
if (Array.isArray(obj)) {
|
|
631
|
+
return obj.map(item => this.replaceParamsInObject(item, params));
|
|
632
|
+
}
|
|
633
|
+
if (obj && typeof obj === 'object') {
|
|
634
|
+
const result = {};
|
|
635
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
636
|
+
result[key] = this.replaceParamsInObject(value, params);
|
|
637
|
+
}
|
|
638
|
+
return result;
|
|
639
|
+
}
|
|
640
|
+
return obj;
|
|
641
|
+
}
|
|
642
|
+
// ==================== UTILITY METHODS ====================
|
|
643
|
+
/**
|
|
644
|
+
* Get the current connection
|
|
645
|
+
*/
|
|
646
|
+
getConnection() {
|
|
647
|
+
return this.currentConnection;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Get the current adapter
|
|
651
|
+
*/
|
|
652
|
+
getCurrentAdapter() {
|
|
653
|
+
return this.currentAdapter;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Get supported database types
|
|
657
|
+
*/
|
|
658
|
+
getSupportedDatabaseTypes() {
|
|
659
|
+
return Array.from(this.adapters.keys());
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Check if a database type is supported
|
|
663
|
+
*/
|
|
664
|
+
isDatabaseTypeSupported(type) {
|
|
665
|
+
return this.adapters.has(type);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Ensure there's an active connection
|
|
669
|
+
*/
|
|
670
|
+
ensureConnection() {
|
|
671
|
+
if (!this.currentConnection || !this.currentAdapter) {
|
|
672
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'No active connection. Call connect() first.');
|
|
673
|
+
}
|
|
674
|
+
if (!this.currentConnection.isConnected()) {
|
|
675
|
+
throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Connection is not active. Reconnect required.');
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
exports.GraphService = GraphService;
|
|
680
|
+
/**
|
|
681
|
+
* Create a new GraphService instance
|
|
682
|
+
*/
|
|
683
|
+
function createGraphService(config) {
|
|
684
|
+
return new GraphService(config);
|
|
685
|
+
}
|
|
686
|
+
exports.default = GraphService;
|
|
687
|
+
//# sourceMappingURL=graph.service.js.map
|