@ductape/sdk 0.0.4-v59 → 0.0.4-v60
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/dist/agents/agents.service.d.ts +8 -2
- package/dist/agents/agents.service.js +5 -0
- package/dist/agents/agents.service.js.map +1 -1
- package/dist/agents/types/agents.types.d.ts +2 -0
- package/dist/agents/types/agents.types.js.map +1 -1
- package/dist/agents/vector-store-adapter.js +5 -5
- package/dist/agents/vector-store-adapter.js.map +1 -1
- package/dist/api/services/appApi.service.d.ts +3 -3
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +1 -1
- package/dist/api/services/productsApi.service.js +20 -13
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/secretsApi.service.d.ts +12 -0
- package/dist/api/services/secretsApi.service.js +30 -2
- package/dist/api/services/secretsApi.service.js.map +1 -1
- package/dist/api/services/workspaceApi.service.d.ts +8 -0
- package/dist/api/services/workspaceApi.service.js +20 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +2 -0
- package/dist/api/urls.js +10 -15
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/auth.utils.d.ts +1 -3
- package/dist/api/utils/auth.utils.js.map +1 -1
- package/dist/apps/utils/oauth-manager.js +27 -3
- package/dist/apps/utils/oauth-manager.js.map +1 -1
- package/dist/brokers/brokers.service.d.ts +8 -0
- package/dist/brokers/brokers.service.js +50 -4
- package/dist/brokers/brokers.service.js.map +1 -1
- package/dist/brokers/types/index.d.ts +26 -0
- package/dist/brokers/utils/providers/kafka.service.d.ts +7 -0
- package/dist/brokers/utils/providers/kafka.service.js +102 -23
- package/dist/brokers/utils/providers/kafka.service.js.map +1 -1
- package/dist/brokers/utils/providers/rabbitmq.service.d.ts +2 -1
- package/dist/brokers/utils/providers/rabbitmq.service.js +99 -15
- package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -1
- package/dist/database/adapters/cassandra.adapter.d.ts +1 -0
- package/dist/database/adapters/cassandra.adapter.js +100 -44
- package/dist/database/adapters/cassandra.adapter.js.map +1 -1
- package/dist/database/adapters/dynamodb.adapter.d.ts +1 -0
- package/dist/database/adapters/dynamodb.adapter.js +89 -20
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/mongodb.adapter.d.ts +1 -0
- package/dist/database/adapters/mongodb.adapter.js +123 -45
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +1 -0
- package/dist/database/adapters/mysql.adapter.js +125 -48
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +5 -0
- package/dist/database/adapters/postgresql.adapter.js +151 -50
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +15 -1
- package/dist/database/databases.service.js +143 -2
- package/dist/database/databases.service.js.map +1 -1
- package/dist/database/operators/aggregation-builder.d.ts +11 -8
- package/dist/database/operators/aggregation-builder.js +184 -89
- package/dist/database/operators/aggregation-builder.js.map +1 -1
- package/dist/database/operators/query-builder.d.ts +23 -19
- package/dist/database/operators/query-builder.js +77 -45
- package/dist/database/operators/query-builder.js.map +1 -1
- package/dist/database/types/aggregation.interface.d.ts +21 -15
- package/dist/database/types/query.interface.d.ts +27 -21
- package/dist/database/types/write.interface.d.ts +20 -12
- package/dist/graph/adapters/arangodb.adapter.js +61 -22
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
- package/dist/graph/adapters/memgraph.adapter.js +22 -16
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
- package/dist/graph/adapters/neo4j.adapter.js +51 -21
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
- package/dist/graph/adapters/neptune.adapter.js +32 -16
- package/dist/graph/adapters/neptune.adapter.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +24 -2
- package/dist/graph/graphs.service.js +238 -28
- package/dist/graph/graphs.service.js.map +1 -1
- package/dist/graph/types/connection.interface.d.ts +8 -0
- package/dist/graph/types/query.interface.d.ts +21 -14
- package/dist/index.d.ts +367 -20
- package/dist/index.js +510 -48
- package/dist/index.js.map +1 -1
- package/dist/inputs/inputs.service.d.ts +1 -1
- package/dist/notifications/notifications.service.d.ts +7 -2
- package/dist/notifications/notifications.service.js +2 -0
- package/dist/notifications/notifications.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +5 -1
- package/dist/processor/services/processor.service.js +35 -2
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/products/services/products.service.d.ts +76 -2
- package/dist/products/services/products.service.js +984 -27
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productAgent.validator.js +52 -4
- package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +2 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +1 -7
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productVector.validator.js +4 -4
- package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +2 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +4 -1
- package/dist/resilience/fallback.service.js +8 -10
- package/dist/resilience/fallback.service.js.map +1 -1
- package/dist/resilience/healthcheck.service.d.ts +6 -1
- package/dist/resilience/healthcheck.service.js +9 -0
- package/dist/resilience/healthcheck.service.js.map +1 -1
- package/dist/resilience/quota.service.d.ts +4 -1
- package/dist/resilience/quota.service.js +2 -0
- package/dist/resilience/quota.service.js.map +1 -1
- package/dist/resilience/resilience.service.d.ts +4 -1
- package/dist/resilience/resilience.service.js.map +1 -1
- package/dist/secrets/secrets.service.d.ts +11 -1
- package/dist/secrets/secrets.service.js +109 -10
- package/dist/secrets/secrets.service.js.map +1 -1
- package/dist/storage/storage.service.d.ts +4 -1
- package/dist/storage/storage.service.js +6 -1
- package/dist/storage/storage.service.js.map +1 -1
- package/dist/test/index.js +1 -3
- package/dist/test/index.js.map +1 -1
- package/dist/test/test.broker.kafka.d.ts +1 -0
- package/dist/test/test.broker.kafka.js +172 -0
- package/dist/test/test.broker.kafka.js.map +1 -0
- package/dist/test/test.broker.nats.d.ts +1 -0
- package/dist/test/test.broker.nats.js +193 -0
- package/dist/test/test.broker.nats.js.map +1 -0
- package/dist/test/test.broker.pubsub.d.ts +1 -0
- package/dist/test/test.broker.pubsub.js +171 -0
- package/dist/test/test.broker.pubsub.js.map +1 -0
- package/dist/test/test.broker.rabbitmq.d.ts +1 -0
- package/dist/test/test.broker.rabbitmq.js +164 -0
- package/dist/test/test.broker.rabbitmq.js.map +1 -0
- package/dist/test/test.broker.redis.d.ts +1 -0
- package/dist/test/test.broker.redis.js +168 -0
- package/dist/test/test.broker.redis.js.map +1 -0
- package/dist/test/test.broker.sqs.d.ts +1 -0
- package/dist/test/test.broker.sqs.js +158 -0
- package/dist/test/test.broker.sqs.js.map +1 -0
- package/dist/test/test.caches.d.ts +1 -0
- package/dist/test/test.caches.js +231 -0
- package/dist/test/test.caches.js.map +1 -0
- package/dist/test/test.database.dynamo.d.ts +1 -0
- package/dist/test/test.database.dynamo.js +265 -0
- package/dist/test/test.database.dynamo.js.map +1 -0
- package/dist/test/test.database.js +2 -2
- package/dist/test/test.database.js.map +1 -1
- package/dist/test/test.database.mongo.d.ts +1 -0
- package/dist/test/test.database.mongo.js +371 -0
- package/dist/test/test.database.mongo.js.map +1 -0
- package/dist/test/test.database.mysql.d.ts +1 -0
- package/dist/test/test.database.mysql.js +415 -0
- package/dist/test/test.database.mysql.js.map +1 -0
- package/dist/test/test.database.postgres.d.ts +1 -0
- package/dist/test/test.database.postgres.js +412 -0
- package/dist/test/test.database.postgres.js.map +1 -0
- package/dist/test/test.email.brevo.d.ts +1 -0
- package/dist/test/test.email.brevo.js +326 -0
- package/dist/test/test.email.brevo.js.map +1 -0
- package/dist/test/test.email.mailgun.d.ts +1 -0
- package/dist/test/test.email.mailgun.js +352 -0
- package/dist/test/test.email.mailgun.js.map +1 -0
- package/dist/test/test.email.postmark.d.ts +1 -0
- package/dist/test/test.email.postmark.js +316 -0
- package/dist/test/test.email.postmark.js.map +1 -0
- package/dist/test/test.email.sendgrid.d.ts +1 -0
- package/dist/test/test.email.sendgrid.js +365 -0
- package/dist/test/test.email.sendgrid.js.map +1 -0
- package/dist/test/test.email.smtp.d.ts +1 -0
- package/dist/test/test.email.smtp.js +323 -0
- package/dist/test/test.email.smtp.js.map +1 -0
- package/dist/test/test.graph.arangodb.d.ts +1 -0
- package/dist/test/test.graph.arangodb.js +358 -0
- package/dist/test/test.graph.arangodb.js.map +1 -0
- package/dist/test/test.graph.memgraph.d.ts +1 -0
- package/dist/test/test.graph.memgraph.js +320 -0
- package/dist/test/test.graph.memgraph.js.map +1 -0
- package/dist/test/test.graph.neo4j.d.ts +1 -0
- package/dist/test/test.graph.neo4j.js +218 -0
- package/dist/test/test.graph.neo4j.js.map +1 -0
- package/dist/test/test.graph.neptune.d.ts +1 -0
- package/dist/test/test.graph.neptune.js +331 -0
- package/dist/test/test.graph.neptune.js.map +1 -0
- package/dist/test/test.notifications.d.ts +1 -0
- package/dist/test/test.notifications.js +198 -0
- package/dist/test/test.notifications.js.map +1 -0
- package/dist/test/test.push.expo.d.ts +1 -0
- package/dist/test/test.push.expo.js +442 -0
- package/dist/test/test.push.expo.js.map +1 -0
- package/dist/test/test.push.firebase.d.ts +1 -0
- package/dist/test/test.push.firebase.js +409 -0
- package/dist/test/test.push.firebase.js.map +1 -0
- package/dist/test/test.session.d.ts +1 -0
- package/dist/test/test.session.js +299 -0
- package/dist/test/test.session.js.map +1 -0
- package/dist/test/test.sms.nexmo.d.ts +1 -0
- package/dist/test/test.sms.nexmo.js +278 -0
- package/dist/test/test.sms.nexmo.js.map +1 -0
- package/dist/test/test.sms.twilio.d.ts +1 -0
- package/dist/test/test.sms.twilio.js +275 -0
- package/dist/test/test.sms.twilio.js.map +1 -0
- package/dist/test/test.storage.js +169 -299
- package/dist/test/test.storage.js.map +1 -1
- package/dist/test/test.vector.pinecone.d.ts +1 -0
- package/dist/test/test.vector.pinecone.js +238 -0
- package/dist/test/test.vector.pinecone.js.map +1 -0
- package/dist/test/test.vector.qdrant.d.ts +1 -0
- package/dist/test/test.vector.qdrant.js +307 -0
- package/dist/test/test.vector.qdrant.js.map +1 -0
- package/dist/test/test.vector.weaviate.d.ts +1 -0
- package/dist/test/test.vector.weaviate.js +325 -0
- package/dist/test/test.vector.weaviate.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +6 -2
- package/dist/types/enums.d.ts +2 -0
- package/dist/types/enums.js +2 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +2 -4
- package/dist/types/index.types.js +0 -1
- package/dist/types/index.types.js.map +1 -1
- package/dist/types/processor.types.d.ts +18 -0
- package/dist/types/productsBuilder.types.d.ts +19 -15
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/requests.types.d.ts +2 -0
- package/dist/utils/index.js +23 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/vector/adapters/base.adapter.d.ts +1 -1
- package/dist/vector/adapters/memory.adapter.d.ts +1 -1
- package/dist/vector/adapters/memory.adapter.js +1 -1
- package/dist/vector/adapters/memory.adapter.js.map +1 -1
- package/dist/vector/adapters/pinecone.adapter.d.ts +1 -1
- package/dist/vector/adapters/pinecone.adapter.js +1 -1
- package/dist/vector/adapters/pinecone.adapter.js.map +1 -1
- package/dist/vector/adapters/qdrant.adapter.d.ts +1 -1
- package/dist/vector/adapters/qdrant.adapter.js +1 -1
- package/dist/vector/adapters/qdrant.adapter.js.map +1 -1
- package/dist/vector/adapters/weaviate.adapter.d.ts +1 -1
- package/dist/vector/adapters/weaviate.adapter.js +1 -1
- package/dist/vector/adapters/weaviate.adapter.js.map +1 -1
- package/dist/vector/index.d.ts +2 -2
- package/dist/vector/index.js +2 -2
- package/dist/vector/utils/vector-error.js +0 -1
- package/dist/vector/utils/vector-error.js.map +1 -1
- package/dist/vector/vector-database.service.d.ts +9 -6
- package/dist/vector/vector-database.service.js +7 -6
- package/dist/vector/vector-database.service.js.map +1 -1
- package/dist/vector/vector.service.d.ts +3 -3
- package/dist/vector/vector.service.js +12 -9
- package/dist/vector/vector.service.js.map +1 -1
- package/dist/workflows/workflow-executor.d.ts +4 -1
- package/dist/workflows/workflow-executor.js +10 -2
- package/dist/workflows/workflow-executor.js.map +1 -1
- package/dist/workflows/workflows.service.d.ts +8 -2
- package/dist/workflows/workflows.service.js +66 -41
- package/dist/workflows/workflows.service.js.map +1 -1
- package/package.json +29 -4
|
@@ -91,6 +91,7 @@ class GraphService {
|
|
|
91
91
|
this.adapterFactory = new adapter_factory_1.GraphAdapterFactory();
|
|
92
92
|
if (config) {
|
|
93
93
|
this.config = config;
|
|
94
|
+
this._privateKey = config.private_key || '';
|
|
94
95
|
// Initialize CacheManager if Redis client is provided
|
|
95
96
|
if (config.redis_client) {
|
|
96
97
|
this.cacheManager = new cache_manager_1.CacheManager({
|
|
@@ -131,6 +132,7 @@ class GraphService {
|
|
|
131
132
|
user_id: this.config.user_id,
|
|
132
133
|
token: this.config.token,
|
|
133
134
|
env_type: this.config.env_type,
|
|
135
|
+
access_key: this.config.access_key,
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
/**
|
|
@@ -180,6 +182,7 @@ class GraphService {
|
|
|
180
182
|
user_id: this.config.user_id,
|
|
181
183
|
token: this.config.token,
|
|
182
184
|
env_type: this.config.env_type,
|
|
185
|
+
private_key: this._privateKey,
|
|
183
186
|
});
|
|
184
187
|
}
|
|
185
188
|
// ==================== GRAPH REGISTRATION ====================
|
|
@@ -202,42 +205,106 @@ class GraphService {
|
|
|
202
205
|
* ```
|
|
203
206
|
*/
|
|
204
207
|
async create(graphConfig, productTag) {
|
|
205
|
-
var _a;
|
|
208
|
+
var _a, _b, _c;
|
|
209
|
+
console.log('[GraphService.create] Starting with config:', JSON.stringify({
|
|
210
|
+
name: graphConfig.name,
|
|
211
|
+
tag: graphConfig.tag,
|
|
212
|
+
type: graphConfig.type,
|
|
213
|
+
envs: (_a = graphConfig.envs) === null || _a === void 0 ? void 0 : _a.map(e => {
|
|
214
|
+
var _a;
|
|
215
|
+
return ({
|
|
216
|
+
slug: e.slug,
|
|
217
|
+
connection_url: ((_a = e.connection_url) === null || _a === void 0 ? void 0 : _a.substring(0, 30)) + '...',
|
|
218
|
+
hasUsername: !!e.username,
|
|
219
|
+
hasPassword: !!e.password,
|
|
220
|
+
database: e.database,
|
|
221
|
+
graphName: e.graphName,
|
|
222
|
+
});
|
|
223
|
+
}),
|
|
224
|
+
}, null, 2));
|
|
206
225
|
// Validate required fields
|
|
207
|
-
if (!graphConfig.name || !graphConfig.tag || !graphConfig.type || !((
|
|
226
|
+
if (!graphConfig.name || !graphConfig.tag || !graphConfig.type || !((_b = graphConfig.envs) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
208
227
|
throw graph_error_1.GraphError.validationError('Graph configuration requires name, tag, type, and at least one environment');
|
|
209
228
|
}
|
|
229
|
+
const exists = await this.fetchGraphFromProduct(productTag, graphConfig.tag);
|
|
230
|
+
if (exists) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
210
233
|
// Validate graph type
|
|
211
234
|
if (!this.adapterFactory.isSupported(graphConfig.type)) {
|
|
212
235
|
throw graph_error_1.GraphError.validationError(`Unsupported graph type: ${graphConfig.type}. ` +
|
|
213
236
|
`Supported types: ${this.adapterFactory.getSupportedTypes().join(', ')}`);
|
|
214
237
|
}
|
|
238
|
+
// Process sensitive fields - store as secrets if not already secret references
|
|
239
|
+
const processedEnvs = [];
|
|
240
|
+
console.log('[GraphService.create] Secrets service available:', !!(0, secrets_1.getSecretsService)());
|
|
241
|
+
console.log('[GraphService.create] ProductTag:', productTag);
|
|
242
|
+
for (const env of graphConfig.envs) {
|
|
243
|
+
console.log(`[GraphService.create] Processing env '${env.slug}':`, {
|
|
244
|
+
hasConnectionUrl: !!env.connection_url,
|
|
245
|
+
hasGraphName: !!env.graphName,
|
|
246
|
+
hasRegion: !!env.region,
|
|
247
|
+
hasUsername: !!env.username,
|
|
248
|
+
hasPassword: !!env.password,
|
|
249
|
+
});
|
|
250
|
+
// Store all sensitive fields as secrets
|
|
251
|
+
const connectionUrl = productTag
|
|
252
|
+
? await this.storeAsSecretIfNeeded(env.connection_url, productTag, graphConfig.tag, env.slug, 'url', `Graph connection URL for ${graphConfig.tag} in ${env.slug}`)
|
|
253
|
+
: env.connection_url;
|
|
254
|
+
const graphName = productTag
|
|
255
|
+
? await this.storeAsSecretIfNeeded(env.graphName, productTag, graphConfig.tag, env.slug, 'graphName', `Graph name for ${graphConfig.tag} in ${env.slug}`)
|
|
256
|
+
: env.graphName;
|
|
257
|
+
const region = productTag
|
|
258
|
+
? await this.storeAsSecretIfNeeded(env.region, productTag, graphConfig.tag, env.slug, 'region', `AWS region for ${graphConfig.tag} in ${env.slug}`)
|
|
259
|
+
: env.region;
|
|
260
|
+
const username = productTag
|
|
261
|
+
? await this.storeAsSecretIfNeeded(env.username, productTag, graphConfig.tag, env.slug, 'username', `Username for ${graphConfig.tag} in ${env.slug}`)
|
|
262
|
+
: env.username;
|
|
263
|
+
const password = productTag
|
|
264
|
+
? await this.storeAsSecretIfNeeded(env.password, productTag, graphConfig.tag, env.slug, 'password', `Password for ${graphConfig.tag} in ${env.slug}`)
|
|
265
|
+
: env.password;
|
|
266
|
+
processedEnvs.push(Object.assign(Object.assign({}, env), { connection_url: connectionUrl || env.connection_url, graphName,
|
|
267
|
+
region,
|
|
268
|
+
username,
|
|
269
|
+
password }));
|
|
270
|
+
console.log(`[GraphService.create] Processed env '${env.slug}' - secrets stored`);
|
|
271
|
+
}
|
|
215
272
|
// If productTag is provided, use ProductBuilder to persist to backend
|
|
216
273
|
if (productTag) {
|
|
274
|
+
console.log('[GraphService.create] Persisting to backend with productTag:', productTag);
|
|
217
275
|
const builder = await this.getProductBuilder(productTag);
|
|
218
276
|
const productGraph = {
|
|
219
277
|
name: graphConfig.name,
|
|
220
278
|
tag: graphConfig.tag,
|
|
221
279
|
description: graphConfig.description,
|
|
222
280
|
type: graphConfig.type,
|
|
223
|
-
envs:
|
|
281
|
+
envs: processedEnvs.map((env) => ({
|
|
224
282
|
slug: env.slug,
|
|
225
283
|
connection_url: env.connection_url,
|
|
226
284
|
description: env.description,
|
|
227
285
|
database: env.database,
|
|
228
286
|
graphName: env.graphName,
|
|
229
287
|
region: env.region,
|
|
288
|
+
username: env.username,
|
|
289
|
+
password: env.password,
|
|
230
290
|
})),
|
|
231
291
|
};
|
|
232
292
|
await builder.createGraph(productGraph);
|
|
233
293
|
}
|
|
234
|
-
// Store locally
|
|
235
|
-
|
|
294
|
+
// Store locally with processed envs
|
|
295
|
+
const processedConfig = Object.assign(Object.assign({}, graphConfig), { envs: processedEnvs });
|
|
296
|
+
this.localConfigs.set(graphConfig.tag, processedConfig);
|
|
297
|
+
console.log('[GraphService.create] Stored in localConfigs');
|
|
236
298
|
// Create adapters for each environment
|
|
237
|
-
for (const envConfig of
|
|
299
|
+
for (const envConfig of processedEnvs) {
|
|
238
300
|
const contextKey = `${graphConfig.tag}:${envConfig.slug}`;
|
|
239
301
|
const adapter = this.adapterFactory.create(graphConfig.type);
|
|
240
302
|
this.adapters.set(contextKey, adapter);
|
|
303
|
+
console.log(`[GraphService.create] Creating context for ${contextKey}:`, {
|
|
304
|
+
hasUsername: !!envConfig.username,
|
|
305
|
+
hasPassword: !!envConfig.password,
|
|
306
|
+
connectionUrl: ((_c = envConfig.connection_url) === null || _c === void 0 ? void 0 : _c.substring(0, 30)) + '...',
|
|
307
|
+
});
|
|
241
308
|
// Store connection context (not connected yet)
|
|
242
309
|
this.connectionContexts.set(contextKey, {
|
|
243
310
|
graph: graphConfig.tag,
|
|
@@ -249,8 +316,83 @@ class GraphService {
|
|
|
249
316
|
description: graphConfig.description,
|
|
250
317
|
database: envConfig.database,
|
|
251
318
|
graphName: envConfig.graphName,
|
|
319
|
+
username: envConfig.username,
|
|
320
|
+
password: envConfig.password,
|
|
252
321
|
});
|
|
253
322
|
}
|
|
323
|
+
console.log('[GraphService.create] Completed successfully');
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Generate a secret key for graph configuration field
|
|
327
|
+
* Format: GRAPH_{PRODUCT}_{ASSET_TAG}_{ENV}_{KEY}
|
|
328
|
+
*
|
|
329
|
+
* Where:
|
|
330
|
+
* - PRODUCT = productTag.split('.')[1] (second part after workspace)
|
|
331
|
+
* - ASSET_TAG = if graphTag starts with same workspace prefix, use second part; otherwise sanitize full tag
|
|
332
|
+
* - All parts are automatically capitalized
|
|
333
|
+
*/
|
|
334
|
+
generateGraphSecretKey(productTag, graphTag, envSlug, field) {
|
|
335
|
+
const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
|
|
336
|
+
// Support both ':' and '.' delimiters for product tags (e.g., 'ductape:rematch' or 'ductape.rematch')
|
|
337
|
+
const productParts = productTag.includes(':') ? productTag.split(':') : productTag.split('.');
|
|
338
|
+
const product = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
|
|
339
|
+
const workspace = productParts[0];
|
|
340
|
+
// Support both ':' and '.' delimiters for graph tags
|
|
341
|
+
const graphParts = graphTag.includes(':') ? graphTag.split(':') : graphTag.split('.');
|
|
342
|
+
let assetTag;
|
|
343
|
+
if (graphParts.length > 1 && graphParts[0] === workspace) {
|
|
344
|
+
// Same workspace prefix, use second part
|
|
345
|
+
assetTag = graphParts[1];
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
// Different or no prefix, use full tag
|
|
349
|
+
assetTag = graphTag;
|
|
350
|
+
}
|
|
351
|
+
return `GRAPH_${sanitize(product)}_${sanitize(assetTag)}_${sanitize(envSlug)}_${sanitize(field)}`;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Store a value as a secret if it exists and is not already a secret reference
|
|
355
|
+
* @returns The secret reference if stored, or the original value
|
|
356
|
+
*/
|
|
357
|
+
async storeAsSecretIfNeeded(value, productTag, graphTag, envSlug, fieldName, description) {
|
|
358
|
+
if (!value) {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
362
|
+
const secretCheck = (0, secrets_1.isSecretReference)(value);
|
|
363
|
+
console.log(`[GraphService.storeAsSecretIfNeeded] Processing '${fieldName}' for env '${envSlug}':`, {
|
|
364
|
+
isSecretReference: secretCheck.isSecret,
|
|
365
|
+
hasValue: !!value,
|
|
366
|
+
});
|
|
367
|
+
// If not already a secret reference and we have a secrets service, store it as a secret
|
|
368
|
+
if (!secretCheck.isSecret && secretsService && productTag) {
|
|
369
|
+
const secretKey = this.generateGraphSecretKey(productTag, graphTag, envSlug, fieldName);
|
|
370
|
+
try {
|
|
371
|
+
const exists = await secretsService.exists(secretKey);
|
|
372
|
+
console.log(`[GraphService.storeAsSecretIfNeeded] Secret '${secretKey}' exists:`, exists);
|
|
373
|
+
if (exists) {
|
|
374
|
+
await secretsService.update(secretKey, { value });
|
|
375
|
+
console.log(`[GraphService.storeAsSecretIfNeeded] Updated existing secret '${secretKey}'`);
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
await secretsService.create({
|
|
379
|
+
key: secretKey,
|
|
380
|
+
value,
|
|
381
|
+
description,
|
|
382
|
+
scope: [productTag, graphTag],
|
|
383
|
+
envs: [envSlug],
|
|
384
|
+
});
|
|
385
|
+
console.log(`[GraphService.storeAsSecretIfNeeded] Created new secret '${secretKey}'`);
|
|
386
|
+
}
|
|
387
|
+
return `$Secret{${secretKey}}`;
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
console.warn(`[GraphService.storeAsSecretIfNeeded] Failed to store '${fieldName}' as secret: ${secretKey}`, error);
|
|
391
|
+
// Continue with the original value
|
|
392
|
+
return value;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return value;
|
|
254
396
|
}
|
|
255
397
|
/**
|
|
256
398
|
* Fetch all registered graphs for a product
|
|
@@ -315,6 +457,8 @@ class GraphService {
|
|
|
315
457
|
database: env.database,
|
|
316
458
|
graphName: env.graphName,
|
|
317
459
|
region: env.region,
|
|
460
|
+
username: env.username,
|
|
461
|
+
password: env.password,
|
|
318
462
|
})),
|
|
319
463
|
};
|
|
320
464
|
await builder.updateGraph(graphTag, productGraphUpdates);
|
|
@@ -331,7 +475,7 @@ class GraphService {
|
|
|
331
475
|
const contextKey = `${graphTag}:${envConfig.slug}`;
|
|
332
476
|
const existingContext = this.connectionContexts.get(contextKey);
|
|
333
477
|
if (existingContext) {
|
|
334
|
-
this.connectionContexts.set(contextKey, Object.assign(Object.assign({}, existingContext), { connectionUrl: envConfig.connection_url, database: envConfig.database, graphName: envConfig.graphName }));
|
|
478
|
+
this.connectionContexts.set(contextKey, Object.assign(Object.assign({}, existingContext), { connectionUrl: envConfig.connection_url, database: envConfig.database, graphName: envConfig.graphName, username: envConfig.username, password: envConfig.password }));
|
|
335
479
|
}
|
|
336
480
|
}
|
|
337
481
|
}
|
|
@@ -394,6 +538,8 @@ class GraphService {
|
|
|
394
538
|
database: env.database,
|
|
395
539
|
graphName: env.graphName,
|
|
396
540
|
region: env.region,
|
|
541
|
+
username: env.username,
|
|
542
|
+
password: env.password,
|
|
397
543
|
})),
|
|
398
544
|
};
|
|
399
545
|
}
|
|
@@ -412,19 +558,40 @@ class GraphService {
|
|
|
412
558
|
* ```
|
|
413
559
|
*/
|
|
414
560
|
async connect(config) {
|
|
415
|
-
var _a, _b, _c, _d, _e, _f;
|
|
561
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
416
562
|
const process_id = (0, processor_utils_1.generateObjectId)();
|
|
417
563
|
const contextKey = `${config.graph}:${config.env}`;
|
|
564
|
+
console.log('[GraphService.connect] Starting connection:', {
|
|
565
|
+
graph: config.graph,
|
|
566
|
+
env: config.env,
|
|
567
|
+
product: config.product,
|
|
568
|
+
contextKey,
|
|
569
|
+
});
|
|
418
570
|
// Get adapter
|
|
419
571
|
let adapter = this.adapters.get(contextKey);
|
|
420
572
|
let context = this.connectionContexts.get(contextKey);
|
|
573
|
+
console.log('[GraphService.connect] Initial lookup:', {
|
|
574
|
+
hasAdapter: !!adapter,
|
|
575
|
+
hasContext: !!context,
|
|
576
|
+
});
|
|
421
577
|
// If not locally registered, try to fetch from API
|
|
422
578
|
if (!adapter || !context) {
|
|
579
|
+
console.log('[GraphService.connect] Not locally registered, fetching from API...');
|
|
423
580
|
// Initialize product builder to get productId for logging
|
|
424
581
|
if (config.product) {
|
|
425
582
|
await this.getProductBuilder(config.product);
|
|
426
583
|
}
|
|
427
584
|
const graphConfig = await this.fetchGraphFromProduct(config.product, config.graph);
|
|
585
|
+
console.log('[GraphService.connect] Fetched graph config:', graphConfig ? {
|
|
586
|
+
tag: graphConfig.tag,
|
|
587
|
+
type: graphConfig.type,
|
|
588
|
+
envsCount: (_a = graphConfig.envs) === null || _a === void 0 ? void 0 : _a.length,
|
|
589
|
+
envs: (_b = graphConfig.envs) === null || _b === void 0 ? void 0 : _b.map(e => ({
|
|
590
|
+
slug: e.slug,
|
|
591
|
+
hasUsername: !!e.username,
|
|
592
|
+
hasPassword: !!e.password,
|
|
593
|
+
})),
|
|
594
|
+
} : null);
|
|
428
595
|
if (!graphConfig) {
|
|
429
596
|
throw graph_error_1.GraphError.notFoundError(`Graph '${config.graph}' not found in product '${config.product}'`);
|
|
430
597
|
}
|
|
@@ -436,40 +603,80 @@ class GraphService {
|
|
|
436
603
|
if (!adapter || !context) {
|
|
437
604
|
throw graph_error_1.GraphError.configurationError(`Failed to initialize adapter for ${contextKey}`);
|
|
438
605
|
}
|
|
606
|
+
console.log('[GraphService.connect] Context loaded:', {
|
|
607
|
+
graph: context.graph,
|
|
608
|
+
env: context.env,
|
|
609
|
+
type: context.type,
|
|
610
|
+
hasUsername: !!context.username,
|
|
611
|
+
hasPassword: !!context.password,
|
|
612
|
+
connectionUrl: ((_c = context.connectionUrl) === null || _c === void 0 ? void 0 : _c.substring(0, 30)) + '...',
|
|
613
|
+
});
|
|
439
614
|
// Initialize logging
|
|
440
615
|
this.initializeLogService();
|
|
441
616
|
const baseLogs = {
|
|
442
617
|
product_tag: config.product || '',
|
|
443
|
-
workspace_id: ((
|
|
618
|
+
workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
|
|
444
619
|
env: config.env,
|
|
445
620
|
process_id,
|
|
446
621
|
type: logs_types_1.LogEventTypes.GRAPH,
|
|
447
622
|
parent_tag: config.graph,
|
|
448
623
|
data: { graph: config.graph, env: config.env },
|
|
449
624
|
};
|
|
450
|
-
(
|
|
625
|
+
(_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { message: 'Graph connect - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
|
|
451
626
|
try {
|
|
452
|
-
// Resolve secret references in
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
if
|
|
456
|
-
|
|
457
|
-
if (
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
627
|
+
// Resolve all secret references in the context
|
|
628
|
+
const secretsService = (0, secrets_1.getSecretsService)();
|
|
629
|
+
console.log('[GraphService.connect] Secrets service available:', !!secretsService);
|
|
630
|
+
// Helper function to resolve a value if it's a secret reference
|
|
631
|
+
const resolveSecret = async (value, fieldName) => {
|
|
632
|
+
if (!value)
|
|
633
|
+
return undefined;
|
|
634
|
+
const secretCheck = (0, secrets_1.isSecretReference)(value);
|
|
635
|
+
console.log(`[GraphService.connect] Secret check for ${fieldName}:`, {
|
|
636
|
+
isSecret: secretCheck.isSecret,
|
|
637
|
+
secretKey: secretCheck.isSecret ? secretCheck.key : null,
|
|
638
|
+
});
|
|
639
|
+
if (secretCheck.isSecret) {
|
|
640
|
+
if (secretsService) {
|
|
641
|
+
console.log(`[GraphService.connect] Resolving secret for ${fieldName}:`, secretCheck.key);
|
|
642
|
+
const resolved = await secretsService.resolve(value, { env: config.env });
|
|
643
|
+
console.log(`[GraphService.connect] Secret resolved successfully for ${fieldName}`);
|
|
644
|
+
return resolved.value;
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
throw graph_error_1.GraphError.configurationError(`${fieldName} contains secret reference '${value}' but secrets service is not initialized. ` +
|
|
648
|
+
`Please ensure the Ductape client is properly initialized.`);
|
|
649
|
+
}
|
|
464
650
|
}
|
|
651
|
+
return value;
|
|
652
|
+
};
|
|
653
|
+
// Resolve all sensitive fields
|
|
654
|
+
const connectionUrl = await resolveSecret(context.connectionUrl, 'connectionUrl');
|
|
655
|
+
const graphName = await resolveSecret(context.graphName, 'graphName');
|
|
656
|
+
const username = await resolveSecret(context.username, 'username');
|
|
657
|
+
const password = await resolveSecret(context.password, 'password');
|
|
658
|
+
if (!connectionUrl) {
|
|
659
|
+
throw graph_error_1.GraphError.configurationError('Connection URL is required');
|
|
465
660
|
}
|
|
466
|
-
// Connect
|
|
661
|
+
// Connect with auth credentials if provided
|
|
662
|
+
const authConfig = username && password
|
|
663
|
+
? { username, password }
|
|
664
|
+
: undefined;
|
|
665
|
+
console.log('[GraphService.connect] Calling adapter.connect with:', {
|
|
666
|
+
hasConnectionUrl: !!connectionUrl,
|
|
667
|
+
database: context.database,
|
|
668
|
+
graphName: graphName || context.graphName,
|
|
669
|
+
hasAuth: !!authConfig,
|
|
670
|
+
authUsername: (authConfig === null || authConfig === void 0 ? void 0 : authConfig.username) ? '***' : undefined,
|
|
671
|
+
});
|
|
467
672
|
const result = await adapter.connect({
|
|
468
673
|
connectionUrl,
|
|
469
674
|
database: context.database,
|
|
470
|
-
graphName: context.graphName,
|
|
675
|
+
graphName: graphName || context.graphName,
|
|
471
676
|
options: config.options,
|
|
677
|
+
auth: authConfig,
|
|
472
678
|
});
|
|
679
|
+
console.log('[GraphService.connect] Connection result:', result);
|
|
473
680
|
// Update context
|
|
474
681
|
context.connected = result.connected;
|
|
475
682
|
context.product = config.product;
|
|
@@ -478,13 +685,13 @@ class GraphService {
|
|
|
478
685
|
this.currentContext = context;
|
|
479
686
|
// Initialize transaction manager
|
|
480
687
|
this.transactionManager = new transaction_manager_1.GraphTransactionManager(adapter);
|
|
481
|
-
(
|
|
482
|
-
(
|
|
688
|
+
(_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { message: 'Graph connect - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
|
|
689
|
+
(_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
|
|
483
690
|
return result;
|
|
484
691
|
}
|
|
485
692
|
catch (error) {
|
|
486
|
-
(
|
|
487
|
-
await ((
|
|
693
|
+
(_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { message: 'Graph connect - failed', failed_execution: true, data: { graph: config.graph, env: config.env, error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
|
|
694
|
+
await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
|
|
488
695
|
throw error;
|
|
489
696
|
}
|
|
490
697
|
}
|
|
@@ -503,6 +710,9 @@ class GraphService {
|
|
|
503
710
|
database: context.database,
|
|
504
711
|
graphName: context.graphName,
|
|
505
712
|
options: config.options,
|
|
713
|
+
auth: context.username && context.password
|
|
714
|
+
? { username: context.username, password: context.password }
|
|
715
|
+
: undefined,
|
|
506
716
|
});
|
|
507
717
|
}
|
|
508
718
|
/**
|