@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.
Files changed (251) hide show
  1. package/dist/agents/agents.service.d.ts +8 -2
  2. package/dist/agents/agents.service.js +5 -0
  3. package/dist/agents/agents.service.js.map +1 -1
  4. package/dist/agents/types/agents.types.d.ts +2 -0
  5. package/dist/agents/types/agents.types.js.map +1 -1
  6. package/dist/agents/vector-store-adapter.js +5 -5
  7. package/dist/agents/vector-store-adapter.js.map +1 -1
  8. package/dist/api/services/appApi.service.d.ts +3 -3
  9. package/dist/api/services/appApi.service.js.map +1 -1
  10. package/dist/api/services/productsApi.service.d.ts +1 -1
  11. package/dist/api/services/productsApi.service.js +20 -13
  12. package/dist/api/services/productsApi.service.js.map +1 -1
  13. package/dist/api/services/secretsApi.service.d.ts +12 -0
  14. package/dist/api/services/secretsApi.service.js +30 -2
  15. package/dist/api/services/secretsApi.service.js.map +1 -1
  16. package/dist/api/services/workspaceApi.service.d.ts +8 -0
  17. package/dist/api/services/workspaceApi.service.js +20 -0
  18. package/dist/api/services/workspaceApi.service.js.map +1 -1
  19. package/dist/api/urls.d.ts +2 -0
  20. package/dist/api/urls.js +10 -15
  21. package/dist/api/urls.js.map +1 -1
  22. package/dist/api/utils/auth.utils.d.ts +1 -3
  23. package/dist/api/utils/auth.utils.js.map +1 -1
  24. package/dist/apps/utils/oauth-manager.js +27 -3
  25. package/dist/apps/utils/oauth-manager.js.map +1 -1
  26. package/dist/brokers/brokers.service.d.ts +8 -0
  27. package/dist/brokers/brokers.service.js +50 -4
  28. package/dist/brokers/brokers.service.js.map +1 -1
  29. package/dist/brokers/types/index.d.ts +26 -0
  30. package/dist/brokers/utils/providers/kafka.service.d.ts +7 -0
  31. package/dist/brokers/utils/providers/kafka.service.js +102 -23
  32. package/dist/brokers/utils/providers/kafka.service.js.map +1 -1
  33. package/dist/brokers/utils/providers/rabbitmq.service.d.ts +2 -1
  34. package/dist/brokers/utils/providers/rabbitmq.service.js +99 -15
  35. package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -1
  36. package/dist/database/adapters/cassandra.adapter.d.ts +1 -0
  37. package/dist/database/adapters/cassandra.adapter.js +100 -44
  38. package/dist/database/adapters/cassandra.adapter.js.map +1 -1
  39. package/dist/database/adapters/dynamodb.adapter.d.ts +1 -0
  40. package/dist/database/adapters/dynamodb.adapter.js +89 -20
  41. package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
  42. package/dist/database/adapters/mongodb.adapter.d.ts +1 -0
  43. package/dist/database/adapters/mongodb.adapter.js +123 -45
  44. package/dist/database/adapters/mongodb.adapter.js.map +1 -1
  45. package/dist/database/adapters/mysql.adapter.d.ts +1 -0
  46. package/dist/database/adapters/mysql.adapter.js +125 -48
  47. package/dist/database/adapters/mysql.adapter.js.map +1 -1
  48. package/dist/database/adapters/postgresql.adapter.d.ts +5 -0
  49. package/dist/database/adapters/postgresql.adapter.js +151 -50
  50. package/dist/database/adapters/postgresql.adapter.js.map +1 -1
  51. package/dist/database/databases.service.d.ts +15 -1
  52. package/dist/database/databases.service.js +143 -2
  53. package/dist/database/databases.service.js.map +1 -1
  54. package/dist/database/operators/aggregation-builder.d.ts +11 -8
  55. package/dist/database/operators/aggregation-builder.js +184 -89
  56. package/dist/database/operators/aggregation-builder.js.map +1 -1
  57. package/dist/database/operators/query-builder.d.ts +23 -19
  58. package/dist/database/operators/query-builder.js +77 -45
  59. package/dist/database/operators/query-builder.js.map +1 -1
  60. package/dist/database/types/aggregation.interface.d.ts +21 -15
  61. package/dist/database/types/query.interface.d.ts +27 -21
  62. package/dist/database/types/write.interface.d.ts +20 -12
  63. package/dist/graph/adapters/arangodb.adapter.js +61 -22
  64. package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
  65. package/dist/graph/adapters/memgraph.adapter.js +22 -16
  66. package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
  67. package/dist/graph/adapters/neo4j.adapter.js +51 -21
  68. package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
  69. package/dist/graph/adapters/neptune.adapter.js +32 -16
  70. package/dist/graph/adapters/neptune.adapter.js.map +1 -1
  71. package/dist/graph/graphs.service.d.ts +24 -2
  72. package/dist/graph/graphs.service.js +238 -28
  73. package/dist/graph/graphs.service.js.map +1 -1
  74. package/dist/graph/types/connection.interface.d.ts +8 -0
  75. package/dist/graph/types/query.interface.d.ts +21 -14
  76. package/dist/index.d.ts +367 -20
  77. package/dist/index.js +510 -48
  78. package/dist/index.js.map +1 -1
  79. package/dist/inputs/inputs.service.d.ts +1 -1
  80. package/dist/notifications/notifications.service.d.ts +7 -2
  81. package/dist/notifications/notifications.service.js +2 -0
  82. package/dist/notifications/notifications.service.js.map +1 -1
  83. package/dist/processor/services/processor.service.d.ts +5 -1
  84. package/dist/processor/services/processor.service.js +35 -2
  85. package/dist/processor/services/processor.service.js.map +1 -1
  86. package/dist/products/services/products.service.d.ts +76 -2
  87. package/dist/products/services/products.service.js +984 -27
  88. package/dist/products/services/products.service.js.map +1 -1
  89. package/dist/products/validators/joi-validators/create.productAgent.validator.js +52 -4
  90. package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -1
  91. package/dist/products/validators/joi-validators/create.productGraph.validator.js +2 -0
  92. package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
  93. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +1 -7
  94. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
  95. package/dist/products/validators/joi-validators/create.productVector.validator.js +4 -4
  96. package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -1
  97. package/dist/products/validators/joi-validators/update.productGraph.validator.js +2 -0
  98. package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
  99. package/dist/resilience/fallback.service.d.ts +4 -1
  100. package/dist/resilience/fallback.service.js +8 -10
  101. package/dist/resilience/fallback.service.js.map +1 -1
  102. package/dist/resilience/healthcheck.service.d.ts +6 -1
  103. package/dist/resilience/healthcheck.service.js +9 -0
  104. package/dist/resilience/healthcheck.service.js.map +1 -1
  105. package/dist/resilience/quota.service.d.ts +4 -1
  106. package/dist/resilience/quota.service.js +2 -0
  107. package/dist/resilience/quota.service.js.map +1 -1
  108. package/dist/resilience/resilience.service.d.ts +4 -1
  109. package/dist/resilience/resilience.service.js.map +1 -1
  110. package/dist/secrets/secrets.service.d.ts +11 -1
  111. package/dist/secrets/secrets.service.js +109 -10
  112. package/dist/secrets/secrets.service.js.map +1 -1
  113. package/dist/storage/storage.service.d.ts +4 -1
  114. package/dist/storage/storage.service.js +6 -1
  115. package/dist/storage/storage.service.js.map +1 -1
  116. package/dist/test/index.js +1 -3
  117. package/dist/test/index.js.map +1 -1
  118. package/dist/test/test.broker.kafka.d.ts +1 -0
  119. package/dist/test/test.broker.kafka.js +172 -0
  120. package/dist/test/test.broker.kafka.js.map +1 -0
  121. package/dist/test/test.broker.nats.d.ts +1 -0
  122. package/dist/test/test.broker.nats.js +193 -0
  123. package/dist/test/test.broker.nats.js.map +1 -0
  124. package/dist/test/test.broker.pubsub.d.ts +1 -0
  125. package/dist/test/test.broker.pubsub.js +171 -0
  126. package/dist/test/test.broker.pubsub.js.map +1 -0
  127. package/dist/test/test.broker.rabbitmq.d.ts +1 -0
  128. package/dist/test/test.broker.rabbitmq.js +164 -0
  129. package/dist/test/test.broker.rabbitmq.js.map +1 -0
  130. package/dist/test/test.broker.redis.d.ts +1 -0
  131. package/dist/test/test.broker.redis.js +168 -0
  132. package/dist/test/test.broker.redis.js.map +1 -0
  133. package/dist/test/test.broker.sqs.d.ts +1 -0
  134. package/dist/test/test.broker.sqs.js +158 -0
  135. package/dist/test/test.broker.sqs.js.map +1 -0
  136. package/dist/test/test.caches.d.ts +1 -0
  137. package/dist/test/test.caches.js +231 -0
  138. package/dist/test/test.caches.js.map +1 -0
  139. package/dist/test/test.database.dynamo.d.ts +1 -0
  140. package/dist/test/test.database.dynamo.js +265 -0
  141. package/dist/test/test.database.dynamo.js.map +1 -0
  142. package/dist/test/test.database.js +2 -2
  143. package/dist/test/test.database.js.map +1 -1
  144. package/dist/test/test.database.mongo.d.ts +1 -0
  145. package/dist/test/test.database.mongo.js +371 -0
  146. package/dist/test/test.database.mongo.js.map +1 -0
  147. package/dist/test/test.database.mysql.d.ts +1 -0
  148. package/dist/test/test.database.mysql.js +415 -0
  149. package/dist/test/test.database.mysql.js.map +1 -0
  150. package/dist/test/test.database.postgres.d.ts +1 -0
  151. package/dist/test/test.database.postgres.js +412 -0
  152. package/dist/test/test.database.postgres.js.map +1 -0
  153. package/dist/test/test.email.brevo.d.ts +1 -0
  154. package/dist/test/test.email.brevo.js +326 -0
  155. package/dist/test/test.email.brevo.js.map +1 -0
  156. package/dist/test/test.email.mailgun.d.ts +1 -0
  157. package/dist/test/test.email.mailgun.js +352 -0
  158. package/dist/test/test.email.mailgun.js.map +1 -0
  159. package/dist/test/test.email.postmark.d.ts +1 -0
  160. package/dist/test/test.email.postmark.js +316 -0
  161. package/dist/test/test.email.postmark.js.map +1 -0
  162. package/dist/test/test.email.sendgrid.d.ts +1 -0
  163. package/dist/test/test.email.sendgrid.js +365 -0
  164. package/dist/test/test.email.sendgrid.js.map +1 -0
  165. package/dist/test/test.email.smtp.d.ts +1 -0
  166. package/dist/test/test.email.smtp.js +323 -0
  167. package/dist/test/test.email.smtp.js.map +1 -0
  168. package/dist/test/test.graph.arangodb.d.ts +1 -0
  169. package/dist/test/test.graph.arangodb.js +358 -0
  170. package/dist/test/test.graph.arangodb.js.map +1 -0
  171. package/dist/test/test.graph.memgraph.d.ts +1 -0
  172. package/dist/test/test.graph.memgraph.js +320 -0
  173. package/dist/test/test.graph.memgraph.js.map +1 -0
  174. package/dist/test/test.graph.neo4j.d.ts +1 -0
  175. package/dist/test/test.graph.neo4j.js +218 -0
  176. package/dist/test/test.graph.neo4j.js.map +1 -0
  177. package/dist/test/test.graph.neptune.d.ts +1 -0
  178. package/dist/test/test.graph.neptune.js +331 -0
  179. package/dist/test/test.graph.neptune.js.map +1 -0
  180. package/dist/test/test.notifications.d.ts +1 -0
  181. package/dist/test/test.notifications.js +198 -0
  182. package/dist/test/test.notifications.js.map +1 -0
  183. package/dist/test/test.push.expo.d.ts +1 -0
  184. package/dist/test/test.push.expo.js +442 -0
  185. package/dist/test/test.push.expo.js.map +1 -0
  186. package/dist/test/test.push.firebase.d.ts +1 -0
  187. package/dist/test/test.push.firebase.js +409 -0
  188. package/dist/test/test.push.firebase.js.map +1 -0
  189. package/dist/test/test.session.d.ts +1 -0
  190. package/dist/test/test.session.js +299 -0
  191. package/dist/test/test.session.js.map +1 -0
  192. package/dist/test/test.sms.nexmo.d.ts +1 -0
  193. package/dist/test/test.sms.nexmo.js +278 -0
  194. package/dist/test/test.sms.nexmo.js.map +1 -0
  195. package/dist/test/test.sms.twilio.d.ts +1 -0
  196. package/dist/test/test.sms.twilio.js +275 -0
  197. package/dist/test/test.sms.twilio.js.map +1 -0
  198. package/dist/test/test.storage.js +169 -299
  199. package/dist/test/test.storage.js.map +1 -1
  200. package/dist/test/test.vector.pinecone.d.ts +1 -0
  201. package/dist/test/test.vector.pinecone.js +238 -0
  202. package/dist/test/test.vector.pinecone.js.map +1 -0
  203. package/dist/test/test.vector.qdrant.d.ts +1 -0
  204. package/dist/test/test.vector.qdrant.js +307 -0
  205. package/dist/test/test.vector.qdrant.js.map +1 -0
  206. package/dist/test/test.vector.weaviate.d.ts +1 -0
  207. package/dist/test/test.vector.weaviate.js +325 -0
  208. package/dist/test/test.vector.weaviate.js.map +1 -0
  209. package/dist/types/appBuilder.types.d.ts +6 -2
  210. package/dist/types/enums.d.ts +2 -0
  211. package/dist/types/enums.js +2 -0
  212. package/dist/types/enums.js.map +1 -1
  213. package/dist/types/index.types.d.ts +2 -4
  214. package/dist/types/index.types.js +0 -1
  215. package/dist/types/index.types.js.map +1 -1
  216. package/dist/types/processor.types.d.ts +18 -0
  217. package/dist/types/productsBuilder.types.d.ts +19 -15
  218. package/dist/types/productsBuilder.types.js.map +1 -1
  219. package/dist/types/requests.types.d.ts +2 -0
  220. package/dist/utils/index.js +23 -4
  221. package/dist/utils/index.js.map +1 -1
  222. package/dist/vector/adapters/base.adapter.d.ts +1 -1
  223. package/dist/vector/adapters/memory.adapter.d.ts +1 -1
  224. package/dist/vector/adapters/memory.adapter.js +1 -1
  225. package/dist/vector/adapters/memory.adapter.js.map +1 -1
  226. package/dist/vector/adapters/pinecone.adapter.d.ts +1 -1
  227. package/dist/vector/adapters/pinecone.adapter.js +1 -1
  228. package/dist/vector/adapters/pinecone.adapter.js.map +1 -1
  229. package/dist/vector/adapters/qdrant.adapter.d.ts +1 -1
  230. package/dist/vector/adapters/qdrant.adapter.js +1 -1
  231. package/dist/vector/adapters/qdrant.adapter.js.map +1 -1
  232. package/dist/vector/adapters/weaviate.adapter.d.ts +1 -1
  233. package/dist/vector/adapters/weaviate.adapter.js +1 -1
  234. package/dist/vector/adapters/weaviate.adapter.js.map +1 -1
  235. package/dist/vector/index.d.ts +2 -2
  236. package/dist/vector/index.js +2 -2
  237. package/dist/vector/utils/vector-error.js +0 -1
  238. package/dist/vector/utils/vector-error.js.map +1 -1
  239. package/dist/vector/vector-database.service.d.ts +9 -6
  240. package/dist/vector/vector-database.service.js +7 -6
  241. package/dist/vector/vector-database.service.js.map +1 -1
  242. package/dist/vector/vector.service.d.ts +3 -3
  243. package/dist/vector/vector.service.js +12 -9
  244. package/dist/vector/vector.service.js.map +1 -1
  245. package/dist/workflows/workflow-executor.d.ts +4 -1
  246. package/dist/workflows/workflow-executor.js +10 -2
  247. package/dist/workflows/workflow-executor.js.map +1 -1
  248. package/dist/workflows/workflows.service.d.ts +8 -2
  249. package/dist/workflows/workflows.service.js +66 -41
  250. package/dist/workflows/workflows.service.js.map +1 -1
  251. package/package.json +29 -4
package/dist/index.js CHANGED
@@ -32,6 +32,17 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __rest = (this && this.__rest) || function (s, e) {
36
+ var t = {};
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
+ t[p] = s[p];
39
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
+ t[p[i]] = s[p[i]];
43
+ }
44
+ return t;
45
+ };
35
46
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
47
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
48
  };
@@ -52,7 +63,6 @@ const productsApi_service_1 = require("./api/services/productsApi.service");
52
63
  const imports_service_1 = __importDefault(require("./imports/imports.service"));
53
64
  const processor_service_1 = __importDefault(require("./processor/services/processor.service"));
54
65
  const logs_service_1 = __importDefault(require("./logs/logs.service"));
55
- const utils_1 = require("./utils");
56
66
  const mime = __importStar(require("mime-types"));
57
67
  const processor_utils_1 = require("./processor/utils/processor.utils");
58
68
  const database_1 = require("./database");
@@ -409,7 +419,7 @@ class Ductape {
409
419
  }
410
420
  return await Promise.resolve().then(() => __importStar(require('ioredis')));
411
421
  }
412
- constructor({ workspace_id, private_key, user_id, env_type, redis_url }) {
422
+ constructor({ accessKey, env_type, redis_url }) {
413
423
  this.productBuilders = new Map();
414
424
  this.appBuilders = new Map();
415
425
  // Cached service instances (lazily initialized after auth)
@@ -422,6 +432,7 @@ class Ductape {
422
432
  this._cacheService = null;
423
433
  this._jobsService = null;
424
434
  this._secretsService = null;
435
+ this._privateKey = null;
425
436
  this._quotaService = null;
426
437
  this._fallbackService = null;
427
438
  this._healthcheckService = null;
@@ -1027,9 +1038,17 @@ class Ductape {
1027
1038
  * @param {IProductStorage} data - The storage data.
1028
1039
  * @returns {Promise<void>} Resolves when the storage is created. Throws on error.
1029
1040
  */
1030
- create: async (product, data) => {
1041
+ create: async (data) => {
1042
+ // Ensure secrets service is initialized for secret storage
1043
+ await this.createNewSecretsService();
1044
+ const { product } = data, storageData = __rest(data, ["product"]);
1031
1045
  const builder = await this.getProductBuilder(product);
1032
- return builder.createStorage(data);
1046
+ return builder.createStorage(storageData);
1047
+ },
1048
+ /**
1049
+ * Creates a storage for a product (alternative method).
1050
+ const builder = await this.getProductBuilder(product);
1051
+ return builder.createStorage(data);
1033
1052
  },
1034
1053
  /**
1035
1054
  * Fetches all storages for a product.
@@ -1058,6 +1077,8 @@ class Ductape {
1058
1077
  * @returns {Promise<void>} Resolves when the storage is updated. Throws on error.
1059
1078
  */
1060
1079
  update: async (product, tag, data) => {
1080
+ // Ensure secrets service is initialized for secret storage
1081
+ await this.createNewSecretsService();
1061
1082
  const builder = await this.getProductBuilder(product);
1062
1083
  return builder.updateStorage(tag, data);
1063
1084
  },
@@ -1278,16 +1299,17 @@ class Ductape {
1278
1299
  /**
1279
1300
  * Events-related operations for managing product events (message brokers).
1280
1301
  */
1281
- this.events = {
1302
+ this.messaging = {
1282
1303
  /**
1283
1304
  * Creates a message broker for a product.
1284
1305
  * @param {string} product - The product tag.
1285
1306
  * @param {Partial<IProductMessageBroker>} data - The message broker data.
1286
1307
  * @returns {Promise<void>} Resolves when the message broker is created. Throws on error.
1287
1308
  */
1288
- create: async (product, data) => {
1309
+ create: async (data) => {
1310
+ const { product } = data, brokerData = __rest(data, ["product"]);
1289
1311
  const builder = await this.getProductBuilder(product);
1290
- return builder.createMessageBroker(data);
1312
+ return builder.createMessageBroker(brokerData);
1291
1313
  },
1292
1314
  /**
1293
1315
  * Fetches all message brokers for a product.
@@ -1384,23 +1406,23 @@ class Ductape {
1384
1406
  * message: { orderId: '123', status: 'pending' }
1385
1407
  * });
1386
1408
  */
1387
- publish: async (data) => {
1409
+ produce: async (data) => {
1388
1410
  const brokersService = await this.createNewBrokersService();
1389
1411
  return brokersService.publish(data);
1390
1412
  },
1391
1413
  /**
1392
- * Subscribes to a message broker topic.
1414
+ * consume to a message broker topic.
1393
1415
  * @param data - The subscribe input.
1394
1416
  * @returns The result of the subscribe operation.
1395
1417
  * @example
1396
- * await ductape.events.subscribe({
1418
+ * await ductape.events.consume({
1397
1419
  * product: 'my-product',
1398
1420
  * env: 'production',
1399
1421
  * event: 'broker-tag:topic-tag',
1400
1422
  * callback: async (message) => console.log(message)
1401
1423
  * });
1402
1424
  */
1403
- subscribe: async (data) => {
1425
+ consume: async (data) => {
1404
1426
  const brokersService = await this.createNewBrokersService();
1405
1427
  return brokersService.subscribe(data);
1406
1428
  },
@@ -2115,17 +2137,18 @@ class Ductape {
2115
2137
  * @param {string} [productTag] - The product tag.
2116
2138
  * @returns {Promise<void>} Resolves when the graph is created.
2117
2139
  */
2118
- create: async (graphConfig, productTag) => {
2140
+ create: async (graphConfig) => {
2119
2141
  const graphService = await this.createNewGraphService();
2120
- return graphService.create(graphConfig, productTag);
2142
+ const { product: productTag } = graphConfig, config = __rest(graphConfig, ["product"]);
2143
+ return graphService.create(config, productTag);
2121
2144
  },
2122
2145
  /**
2123
2146
  * Fetches a graph configuration by tag.
2124
- * @param {string} graphTag - The graph tag.
2125
2147
  * @param {string} [productTag] - The product tag.
2148
+ * @param {string} graphTag - The graph tag.
2126
2149
  * @returns {Promise<any>} The fetched graph configuration.
2127
2150
  */
2128
- fetch: async (graphTag, productTag) => {
2151
+ fetch: async (productTag, graphTag) => {
2129
2152
  const graphService = await this.createNewGraphService();
2130
2153
  return graphService.fetch(graphTag, productTag);
2131
2154
  },
@@ -2140,12 +2163,12 @@ class Ductape {
2140
2163
  },
2141
2164
  /**
2142
2165
  * Updates a graph configuration by tag.
2166
+ * @param {string} [productTag] - The product tag.
2143
2167
  * @param {string} graphTag - The graph tag.
2144
2168
  * @param {any} updates - The updates to apply.
2145
- * @param {string} [productTag] - The product tag.
2146
2169
  * @returns {Promise<void>} Resolves when the graph is updated.
2147
2170
  */
2148
- update: async (graphTag, updates, productTag) => {
2171
+ update: async (productTag, graphTag, updates) => {
2149
2172
  const graphService = await this.createNewGraphService();
2150
2173
  return graphService.update(graphTag, updates, productTag);
2151
2174
  },
@@ -2703,11 +2726,356 @@ class Ductape {
2703
2726
  */
2704
2727
  this.vector = {
2705
2728
  /**
2706
- * Get the underlying VectorDatabaseService instance
2729
+ * Get the underlying VectorDatabaseService instance for advanced operations.
2730
+ * @returns {Promise<VectorDatabaseService>} The vector database service instance.
2707
2731
  */
2708
2732
  getService: async () => {
2709
2733
  return this.createNewVectorService();
2710
2734
  },
2735
+ // ==================== CRUD OPERATIONS ====================
2736
+ /**
2737
+ * Creates a vector database configuration for a product.
2738
+ * @param {ICreateVectorDbOptions} options - The vector configuration options.
2739
+ * @returns {Promise<void>} Resolves when the vector config is created.
2740
+ */
2741
+ create: async (options) => {
2742
+ const vectorService = await this.createNewVectorService();
2743
+ return vectorService.create(options);
2744
+ },
2745
+ /**
2746
+ * Fetches a vector database configuration by tag.
2747
+ * @param {IFetchVectorOptions} options - The fetch options.
2748
+ * @returns {Promise<IProductVector | null>} The fetched vector configuration.
2749
+ */
2750
+ fetch: async (options) => {
2751
+ const vectorService = await this.createNewVectorService();
2752
+ return vectorService.fetch(options);
2753
+ },
2754
+ /**
2755
+ * Fetches all vector database configurations for a product.
2756
+ * @param {object} options - The fetch options containing product tag.
2757
+ * @returns {Promise<IProductVector[]>} The list of vector configurations.
2758
+ */
2759
+ list: async (options) => {
2760
+ const vectorService = await this.createNewVectorService();
2761
+ return vectorService.fetchAll(options);
2762
+ },
2763
+ /**
2764
+ * Updates a vector database configuration.
2765
+ * @param {IUpdateVectorDbOptions} options - The update options.
2766
+ * @returns {Promise<void>} Resolves when the vector config is updated.
2767
+ */
2768
+ update: async (options) => {
2769
+ const vectorService = await this.createNewVectorService();
2770
+ return vectorService.update(options);
2771
+ },
2772
+ /**
2773
+ * Deletes a vector database configuration.
2774
+ * @param {IDeleteVectorConfigOptions} options - The delete options.
2775
+ * @returns {Promise<void>} Resolves when the vector config is deleted.
2776
+ */
2777
+ delete: async (options) => {
2778
+ const vectorService = await this.createNewVectorService();
2779
+ return vectorService.delete(options);
2780
+ },
2781
+ // ==================== CONNECTION MANAGEMENT ====================
2782
+ /**
2783
+ * Connects to a vector database.
2784
+ * @param {object} options - Connection options with product, env, and vector.
2785
+ * @returns {Promise<VectorService>} The connected vector service.
2786
+ */
2787
+ connect: async (options) => {
2788
+ const vectorService = await this.createNewVectorService();
2789
+ return vectorService.connect(options);
2790
+ },
2791
+ /**
2792
+ * Disconnects from a specific vector database.
2793
+ * @param {object} options - Disconnect options with product, env, and vector.
2794
+ * @returns {Promise<void>} Resolves when disconnected.
2795
+ */
2796
+ disconnect: async (options) => {
2797
+ const vectorService = await this.createNewVectorService();
2798
+ return vectorService.disconnect(options);
2799
+ },
2800
+ /**
2801
+ * Disconnects all cached vector database connections.
2802
+ * @returns {Promise<void>} Resolves when all connections are closed.
2803
+ */
2804
+ disconnectAll: async () => {
2805
+ const vectorService = await this.createNewVectorService();
2806
+ return vectorService.disconnectAll();
2807
+ },
2808
+ // ==================== VECTOR OPERATIONS ====================
2809
+ /**
2810
+ * Query vectors by similarity.
2811
+ * @param {IProductVectorQueryOptions} options - The query options.
2812
+ * @returns {Promise<IQueryVectorsResult>} The query results.
2813
+ */
2814
+ query: async (options) => {
2815
+ const vectorService = await this.createNewVectorService();
2816
+ return vectorService.query(options);
2817
+ },
2818
+ /**
2819
+ * Upsert vectors (insert or update).
2820
+ * @param {IProductVectorUpsertOptions} options - The upsert options.
2821
+ * @returns {Promise<IUpsertVectorsResult>} The upsert result.
2822
+ */
2823
+ upsert: async (options) => {
2824
+ const vectorService = await this.createNewVectorService();
2825
+ return vectorService.upsert(options);
2826
+ },
2827
+ /**
2828
+ * Fetch vectors by IDs.
2829
+ * @param {IProductVectorFetchOptions} options - The fetch options.
2830
+ * @returns {Promise<IFetchVectorsResult>} The fetched vectors.
2831
+ */
2832
+ fetchVectors: async (options) => {
2833
+ const vectorService = await this.createNewVectorService();
2834
+ return vectorService.fetchVectors(options);
2835
+ },
2836
+ /**
2837
+ * Delete vectors by IDs.
2838
+ * @param {IProductVectorDeleteOptions} options - The delete options.
2839
+ * @returns {Promise<IDeleteVectorsResult>} The delete result.
2840
+ */
2841
+ deleteVectors: async (options) => {
2842
+ const vectorService = await this.createNewVectorService();
2843
+ return vectorService.deleteVectors(options);
2844
+ },
2845
+ /**
2846
+ * Find similar vectors to a given vector.
2847
+ * @param {object} options - Find similar options with product, env, tag, vector, and topK.
2848
+ * @returns {Promise<IQueryVectorsResult>} The similar vectors.
2849
+ */
2850
+ findSimilar: async (options) => {
2851
+ const { product, env, vector, values, topK = 10 } = options, rest = __rest(options, ["product", "env", "vector", "values", "topK"]);
2852
+ const vectorService = await this.createNewVectorService();
2853
+ const service = await vectorService.connect({ product, env, vector });
2854
+ return service.findSimilar(values, topK, rest);
2855
+ },
2856
+ /**
2857
+ * Upsert a single vector.
2858
+ * @param {object} options - Single vector upsert options.
2859
+ * @returns {Promise<IUpsertVectorsResult>} The upsert result.
2860
+ */
2861
+ upsertOne: async (options) => {
2862
+ const { product, env, tag, id, values, metadata, namespace } = options;
2863
+ const vectorService = await this.createNewVectorService();
2864
+ const service = await vectorService.connect({ product, env, vector: tag });
2865
+ return service.upsertOne(id, values, metadata, namespace);
2866
+ },
2867
+ /**
2868
+ * Fetch a single vector by ID.
2869
+ * @param {object} options - Single vector fetch options.
2870
+ * @returns {Promise<IVector | null>} The fetched vector or null.
2871
+ */
2872
+ fetchOne: async (options) => {
2873
+ const { product, env, vector, id, namespace } = options;
2874
+ const vectorService = await this.createNewVectorService();
2875
+ const service = await vectorService.connect({ product, env, vector });
2876
+ return service.fetchOne(id, namespace);
2877
+ },
2878
+ /**
2879
+ * Update a single vector.
2880
+ * @param {object} options - Update options.
2881
+ * @returns {Promise<IUpdateVectorResult>} The update result.
2882
+ */
2883
+ updateVector: async (options) => {
2884
+ const { product, env, vector } = options, updateOptions = __rest(options, ["product", "env", "vector"]);
2885
+ const vectorService = await this.createNewVectorService();
2886
+ const service = await vectorService.connect({ product, env, vector });
2887
+ return service.update(updateOptions);
2888
+ },
2889
+ /**
2890
+ * Update vector metadata.
2891
+ * @param {object} options - Update metadata options.
2892
+ * @returns {Promise<IUpdateVectorResult>} The update result.
2893
+ */
2894
+ updateMetadata: async (options) => {
2895
+ const { product, env, vector, id, metadata, merge, namespace } = options;
2896
+ const vectorService = await this.createNewVectorService();
2897
+ const service = await vectorService.connect({ product, env, vector });
2898
+ return service.updateMetadata(id, metadata, { merge, namespace });
2899
+ },
2900
+ /**
2901
+ * Delete vectors by IDs (convenience method).
2902
+ * @param {object} options - Delete by IDs options.
2903
+ * @returns {Promise<IDeleteVectorsResult>} The delete result.
2904
+ */
2905
+ deleteByIds: async (options) => {
2906
+ const { product, env, vector, ids, namespace } = options;
2907
+ const vectorService = await this.createNewVectorService();
2908
+ const service = await vectorService.connect({ product, env, vector });
2909
+ return service.deleteByIds(ids, namespace);
2910
+ },
2911
+ /**
2912
+ * Delete all vectors in a namespace.
2913
+ * @param {object} options - Delete all options.
2914
+ * @returns {Promise<IDeleteVectorsResult>} The delete result.
2915
+ */
2916
+ deleteAll: async (options) => {
2917
+ const { product, env, vector, namespace } = options;
2918
+ const vectorService = await this.createNewVectorService();
2919
+ const service = await vectorService.connect({ product, env, vector });
2920
+ return service.deleteAll(namespace);
2921
+ },
2922
+ /**
2923
+ * List vector IDs.
2924
+ * @param {object} options - List options.
2925
+ * @returns {Promise<IListVectorsResult>} The list result.
2926
+ */
2927
+ listVectors: async (options) => {
2928
+ const { product, env, vector } = options, listOptions = __rest(options, ["product", "env", "vector"]);
2929
+ const vectorService = await this.createNewVectorService();
2930
+ const service = await vectorService.connect({ product, env, vector });
2931
+ return service.list(listOptions);
2932
+ },
2933
+ /**
2934
+ * List all vector IDs (paginated).
2935
+ * @param {object} options - List all options.
2936
+ * @returns {Promise<string[]>} All vector IDs.
2937
+ */
2938
+ listAllVectors: async (options) => {
2939
+ const { product, env, vector, namespace, prefix } = options;
2940
+ const vectorService = await this.createNewVectorService();
2941
+ const service = await vectorService.connect({ product, env, vector });
2942
+ return service.listAll({ namespace, prefix });
2943
+ },
2944
+ // ==================== NAMESPACE OPERATIONS ====================
2945
+ /**
2946
+ * List available namespaces.
2947
+ * @param {object} options - Namespace list options.
2948
+ * @returns {Promise<IListNamespacesResult>} The namespaces.
2949
+ */
2950
+ listNamespaces: async (options) => {
2951
+ const { product, env, vector } = options;
2952
+ const vectorService = await this.createNewVectorService();
2953
+ const service = await vectorService.connect({ product, env, vector });
2954
+ return service.listNamespaces();
2955
+ },
2956
+ /**
2957
+ * Delete a namespace.
2958
+ * @param {object} options - Namespace delete options.
2959
+ * @returns {Promise<void>} Resolves when deleted.
2960
+ */
2961
+ deleteNamespace: async (options) => {
2962
+ const { product, env, vector, namespace } = options;
2963
+ const vectorService = await this.createNewVectorService();
2964
+ const service = await vectorService.connect({ product, env, vector });
2965
+ return service.deleteNamespace(namespace);
2966
+ },
2967
+ // ==================== INDEX OPERATIONS ====================
2968
+ /**
2969
+ * Describe the current index.
2970
+ * @param {object} options - Index describe options.
2971
+ * @returns {Promise<IVectorIndexInfo>} The index info.
2972
+ */
2973
+ describeIndex: async (options) => {
2974
+ const { product, env, vector } = options;
2975
+ const vectorService = await this.createNewVectorService();
2976
+ const service = await vectorService.connect({ product, env, vector });
2977
+ return service.describeIndex();
2978
+ },
2979
+ /**
2980
+ * Get index statistics.
2981
+ * @param {object} options - Stats options.
2982
+ * @returns {Promise<IVectorIndexStats>} The index stats.
2983
+ */
2984
+ getStats: async (options) => {
2985
+ const { product, env, vector } = options;
2986
+ const vectorService = await this.createNewVectorService();
2987
+ const service = await vectorService.connect({ product, env, vector });
2988
+ return service.getStats();
2989
+ },
2990
+ /**
2991
+ * Create a new index.
2992
+ * @param {object} options - Create index options.
2993
+ * @returns {Promise<ICreateIndexResult>} The create result.
2994
+ */
2995
+ createIndex: async (options) => {
2996
+ const { product, env, vector } = options, createOptions = __rest(options, ["product", "env", "vector"]);
2997
+ const vectorService = await this.createNewVectorService();
2998
+ const service = await vectorService.connect({ product, env, vector });
2999
+ return service.createIndex(createOptions);
3000
+ },
3001
+ /**
3002
+ * Delete an index.
3003
+ * @param {object} options - Delete index options.
3004
+ * @returns {Promise<IDeleteIndexResult>} The delete result.
3005
+ */
3006
+ deleteIndex: async (options) => {
3007
+ const { product, env, vector, name } = options;
3008
+ const vectorService = await this.createNewVectorService();
3009
+ const service = await vectorService.connect({ product, env, vector });
3010
+ return service.deleteIndex({ name });
3011
+ },
3012
+ /**
3013
+ * List all indexes.
3014
+ * @param {object} options - List indexes options.
3015
+ * @returns {Promise<IVectorIndexInfo[]>} The list of indexes.
3016
+ */
3017
+ listIndexes: async (options) => {
3018
+ const { product, env, vector } = options;
3019
+ const vectorService = await this.createNewVectorService();
3020
+ const service = await vectorService.connect({ product, env, vector });
3021
+ return service.listIndexes();
3022
+ },
3023
+ // ==================== UTILITY METHODS ====================
3024
+ /**
3025
+ * Count vectors in the index.
3026
+ * @param {object} options - Count options.
3027
+ * @returns {Promise<number>} The vector count.
3028
+ */
3029
+ count: async (options) => {
3030
+ const { product, env, vector, namespace } = options;
3031
+ const vectorService = await this.createNewVectorService();
3032
+ const service = await vectorService.connect({ product, env, vector });
3033
+ return service.count(namespace);
3034
+ },
3035
+ /**
3036
+ * Check if a vector exists.
3037
+ * @param {object} options - Exists check options.
3038
+ * @returns {Promise<boolean>} True if exists.
3039
+ */
3040
+ exists: async (options) => {
3041
+ const { product, env, vector, id, namespace } = options;
3042
+ const vectorService = await this.createNewVectorService();
3043
+ const service = await vectorService.connect({ product, env, vector });
3044
+ return service.exists(id, namespace);
3045
+ },
3046
+ /**
3047
+ * Test connection to a vector database.
3048
+ * @param {object} options - Test connection options.
3049
+ * @returns {Promise<boolean>} True if connection is healthy.
3050
+ */
3051
+ testConnection: async (options) => {
3052
+ const { product, env, vector } = options;
3053
+ const vectorService = await this.createNewVectorService();
3054
+ const service = await vectorService.connect({ product, env, vector });
3055
+ return service.testConnection();
3056
+ },
3057
+ /**
3058
+ * Check if a feature is supported.
3059
+ * @param {object} options - Feature check options.
3060
+ * @returns {Promise<boolean>} True if supported.
3061
+ */
3062
+ supportsFeature: async (options) => {
3063
+ const { product, env, vector, feature } = options;
3064
+ const vectorService = await this.createNewVectorService();
3065
+ const service = await vectorService.connect({ product, env, vector });
3066
+ return service.supportsFeature(feature);
3067
+ },
3068
+ /**
3069
+ * Get all supported features.
3070
+ * @param {object} options - Get features options.
3071
+ * @returns {Promise<VectorFeature[]>} The supported features.
3072
+ */
3073
+ getSupportedFeatures: async (options) => {
3074
+ const { product, env, vector } = options;
3075
+ const vectorService = await this.createNewVectorService();
3076
+ const service = await vectorService.connect({ product, env, vector });
3077
+ return service.getSupportedFeatures();
3078
+ },
2711
3079
  };
2712
3080
  /**
2713
3081
  * Job-related operations for managing product jobs.
@@ -2988,7 +3356,7 @@ class Ductape {
2988
3356
  * const secrets = await ductape.secrets.fetchAll();
2989
3357
  * secrets.forEach(s => console.log(s.key, s.description));
2990
3358
  */
2991
- fetchAll: async () => {
3359
+ list: async () => {
2992
3360
  const service = await this.createNewSecretsService();
2993
3361
  return service.fetchAll();
2994
3362
  },
@@ -3105,9 +3473,10 @@ class Ductape {
3105
3473
  * @param {IProductCache} data - The cache data.
3106
3474
  * @returns {Promise<void>} Resolves when the cache is created. Throws on error.
3107
3475
  */
3108
- create: async (product, data) => {
3476
+ create: async (data) => {
3477
+ const { product } = data, config = __rest(data, ["product"]);
3109
3478
  const builder = await this.getProductBuilder(product);
3110
- return builder.createCache(data);
3479
+ return builder.createCache(config);
3111
3480
  },
3112
3481
  /**
3113
3482
  * Fetches all caches for a product.
@@ -3856,6 +4225,7 @@ class Ductape {
3856
4225
  * @returns {Promise<any>} The fetched log data.
3857
4226
  */
3858
4227
  fetch: async (params) => {
4228
+ var _a, _b;
3859
4229
  if (!this.loggerService) {
3860
4230
  throw new Error('Logger service not initialized. Call logs.init() first');
3861
4231
  }
@@ -3863,15 +4233,16 @@ class Ductape {
3863
4233
  return await this.loggerService.fetch(params);
3864
4234
  }
3865
4235
  catch (e) {
3866
- const error = e.response ? e.response.data.errors : e.toString();
3867
- throw error;
4236
+ const error = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || e.message || 'Unknown error';
4237
+ throw new Error(error);
3868
4238
  }
3869
4239
  },
3870
4240
  publish: async () => { },
3871
4241
  };
3872
- this.workspace_id = workspace_id;
3873
- this.private_key = private_key;
3874
- this.user_id = user_id;
4242
+ if (typeof window !== 'undefined') {
4243
+ throw new Error('Ductape SDK can only be initialized in a server environment.');
4244
+ }
4245
+ this.accessKey = accessKey;
3875
4246
  this.environment = env_type || index_types_1.EnvType.PRODUCTION;
3876
4247
  this.userApi = new userApi_service_1.UserApiService(this.environment);
3877
4248
  this.appApi = new appApi_service_1.AppApiService(this.environment);
@@ -3880,7 +4251,7 @@ class Ductape {
3880
4251
  this.redis_url = redis_url;
3881
4252
  // Services are lazily initialized via factory methods (createNewDatabaseService, etc.)
3882
4253
  // This ensures initUserAuth() is called before service creation
3883
- return (0, utils_1.createDeepProxy)(this, this.environment);
4254
+ //return createDeepProxy(this, this.environment);
3884
4255
  }
3885
4256
  async loadBullMQ() {
3886
4257
  if (typeof window !== 'undefined') {
@@ -4069,6 +4440,8 @@ class Ductape {
4069
4440
  async getProductBuilder(product) {
4070
4441
  if (!this.token)
4071
4442
  await this.initUserAuth();
4443
+ // Ensure secrets service is initialized for operations that may need it
4444
+ await this.createNewSecretsService();
4072
4445
  let builder = this.productBuilders.get(product);
4073
4446
  if (!builder) {
4074
4447
  builder = await this.createNewProductBuilder();
@@ -4099,6 +4472,7 @@ class Ductape {
4099
4472
  return this.createNewAppBuilder();
4100
4473
  }
4101
4474
  async initUserAuth(subCheck = true) {
4475
+ var _a, _b;
4102
4476
  // Skip if already authenticated with valid credentials
4103
4477
  if (this.token && this.public_key) {
4104
4478
  return;
@@ -4115,11 +4489,27 @@ class Ductape {
4115
4489
  }
4116
4490
  }
4117
4491
  try {
4118
- await this.validateWorkspace(subCheck);
4492
+ //await this.validateWorkspace(subCheck);
4493
+ // Fetch private key using the dedicated endpoint for secrets encryption
4494
+ // This is more secure as it doesn't expose the full workspace data
4495
+ if (!this._privateKey) {
4496
+ try {
4497
+ this._privateKey = await this.workspaceApi.fetchPrivateKey({
4498
+ token: this.token,
4499
+ public_key: this.public_key,
4500
+ user_id: this.user_id,
4501
+ workspace_id: this.workspace_id,
4502
+ }, this.accessKey);
4503
+ }
4504
+ catch (e) {
4505
+ // Don't throw - private key is only needed for secrets encryption
4506
+ }
4507
+ }
4119
4508
  }
4120
4509
  catch (e) {
4121
- const error = e.response ? e.response.data.errors : e.toString();
4122
- throw error;
4510
+ const error = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || e.message || 'Unknown error';
4511
+ console.log("Errr", e);
4512
+ throw new Error(error);
4123
4513
  }
4124
4514
  }
4125
4515
  createNewLogger(product_id, app_id) {
@@ -4142,6 +4532,7 @@ class Ductape {
4142
4532
  user_id: this.user_id,
4143
4533
  token: this.token,
4144
4534
  env_type: this.environment,
4535
+ access_key: this.accessKey,
4145
4536
  });
4146
4537
  }
4147
4538
  async createNewProcessor() {
@@ -4155,6 +4546,8 @@ class Ductape {
4155
4546
  env_type: this.environment,
4156
4547
  redis_client: this.redisClient,
4157
4548
  queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
4549
+ access_key: this.accessKey,
4550
+ private_key: this._privateKey,
4158
4551
  });
4159
4552
  }
4160
4553
  async createNewImporter() {
@@ -4166,6 +4559,7 @@ class Ductape {
4166
4559
  user_id: this.user_id,
4167
4560
  token: this.token,
4168
4561
  env_type: this.environment,
4562
+ access_key: this.accessKey,
4169
4563
  });
4170
4564
  }
4171
4565
  async createNewAppBuilder() {
@@ -4177,6 +4571,7 @@ class Ductape {
4177
4571
  user_id: this.user_id,
4178
4572
  token: this.token,
4179
4573
  env_type: this.environment,
4574
+ access_key: this.accessKey,
4180
4575
  });
4181
4576
  }
4182
4577
  /**
@@ -4185,7 +4580,11 @@ class Ductape {
4185
4580
  */
4186
4581
  async createNewDatabaseService() {
4187
4582
  const subCheck = false;
4188
- await this.initUserAuth(subCheck);
4583
+ if (!this.token || !this.public_key) {
4584
+ await this.initUserAuth(subCheck);
4585
+ }
4586
+ // Ensure secrets service is initialized for automatic secret storage
4587
+ await this.createNewSecretsService();
4189
4588
  // Return cached instance if available, otherwise create new
4190
4589
  if (!this._databaseService) {
4191
4590
  this._databaseService = new database_1.DatabaseService({
@@ -4194,6 +4593,8 @@ class Ductape {
4194
4593
  user_id: this.user_id,
4195
4594
  token: this.token,
4196
4595
  env_type: this.environment,
4596
+ private_key: this._privateKey,
4597
+ access_key: this.accessKey,
4197
4598
  });
4198
4599
  }
4199
4600
  return this._databaseService;
@@ -4205,6 +4606,8 @@ class Ductape {
4205
4606
  async createNewGraphService() {
4206
4607
  const subCheck = false;
4207
4608
  await this.initUserAuth(subCheck);
4609
+ // Ensure secrets service is initialized for secret storage/resolution
4610
+ await this.createNewSecretsService();
4208
4611
  if (!this._graphService) {
4209
4612
  this._graphService = new graph_1.GraphService({
4210
4613
  workspace_id: this.workspace_id,
@@ -4212,6 +4615,8 @@ class Ductape {
4212
4615
  user_id: this.user_id,
4213
4616
  token: this.token,
4214
4617
  env_type: this.environment,
4618
+ private_key: this._privateKey,
4619
+ access_key: this.accessKey,
4215
4620
  });
4216
4621
  }
4217
4622
  return this._graphService;
@@ -4230,6 +4635,8 @@ class Ductape {
4230
4635
  user_id: this.user_id,
4231
4636
  token: this.token,
4232
4637
  env_type: this.environment,
4638
+ private_key: this._privateKey,
4639
+ access_key: this.accessKey,
4233
4640
  });
4234
4641
  }
4235
4642
  return this._workflowService;
@@ -4248,6 +4655,9 @@ class Ductape {
4248
4655
  user_id: this.user_id,
4249
4656
  token: this.token,
4250
4657
  env_type: this.environment,
4658
+ redis_client: this.redisClient,
4659
+ private_key: this._privateKey,
4660
+ access_key: this.accessKey,
4251
4661
  });
4252
4662
  }
4253
4663
  return this._agentsService;
@@ -4275,6 +4685,8 @@ class Ductape {
4275
4685
  async createNewVectorService() {
4276
4686
  const subCheck = false;
4277
4687
  await this.initUserAuth(subCheck);
4688
+ // Ensure secrets service is initialized for secret storage/resolution
4689
+ await this.createNewSecretsService();
4278
4690
  if (!this._vectorService) {
4279
4691
  this._vectorService = new vector_1.VectorDatabaseService({
4280
4692
  workspace_id: this.workspace_id,
@@ -4282,6 +4694,8 @@ class Ductape {
4282
4694
  user_id: this.user_id,
4283
4695
  token: this.token,
4284
4696
  env_type: this.environment,
4697
+ private_key: this._privateKey,
4698
+ access_key: this.accessKey,
4285
4699
  });
4286
4700
  }
4287
4701
  return this._vectorService;
@@ -4328,7 +4742,25 @@ class Ductape {
4328
4742
  }
4329
4743
  async createNewSecretsService() {
4330
4744
  const subCheck = false;
4331
- await this.initUserAuth(subCheck);
4745
+ if (!this.token || !this.public_key) {
4746
+ await this.initUserAuth(subCheck);
4747
+ }
4748
+ // Private key is now fetched during initUserAuth() using the dedicated /private-key endpoint
4749
+ // If for some reason it's not cached, fetch it now
4750
+ if (!this._privateKey) {
4751
+ console.warn('[Secrets] Private key not cached, fetching now...');
4752
+ try {
4753
+ this._privateKey = await this.workspaceApi.fetchPrivateKey({
4754
+ token: this.token,
4755
+ public_key: this.public_key,
4756
+ user_id: this.user_id,
4757
+ workspace_id: this.workspace_id,
4758
+ }, this.accessKey);
4759
+ }
4760
+ catch (e) {
4761
+ console.error('[Secrets] Failed to fetch private key:', e);
4762
+ }
4763
+ }
4332
4764
  if (!this._secretsService) {
4333
4765
  this._secretsService = new secrets_1.SecretsService({
4334
4766
  environment: this.environment,
@@ -4337,7 +4769,10 @@ class Ductape {
4337
4769
  public_key: this.public_key,
4338
4770
  user_id: this.user_id,
4339
4771
  workspace_id: this.workspace_id,
4772
+ access_key: this.accessKey,
4773
+ private_key: this._privateKey,
4340
4774
  }),
4775
+ getPrivateKey: () => this._privateKey,
4341
4776
  });
4342
4777
  // Set the global instance for use by other services (e.g., database, storage)
4343
4778
  (0, secrets_1.setSecretsService)(this._secretsService);
@@ -4372,6 +4807,7 @@ class Ductape {
4372
4807
  user_id: this.user_id,
4373
4808
  token: this.token,
4374
4809
  env_type: this.environment,
4810
+ private_key: this._privateKey,
4375
4811
  });
4376
4812
  }
4377
4813
  /**
@@ -4405,6 +4841,7 @@ class Ductape {
4405
4841
  env_type: this.environment,
4406
4842
  redis_client: this.redisClient,
4407
4843
  queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
4844
+ private_key: this._privateKey,
4408
4845
  });
4409
4846
  }
4410
4847
  return this._quotaService;
@@ -4425,6 +4862,7 @@ class Ductape {
4425
4862
  env_type: this.environment,
4426
4863
  redis_client: this.redisClient,
4427
4864
  queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
4865
+ private_key: this._privateKey,
4428
4866
  });
4429
4867
  }
4430
4868
  return this._fallbackService;
@@ -4445,16 +4883,18 @@ class Ductape {
4445
4883
  env_type: this.environment,
4446
4884
  redis_client: this.redisClient,
4447
4885
  queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
4886
+ private_key: this._privateKey,
4887
+ access_key: this.accessKey,
4448
4888
  });
4449
4889
  }
4450
4890
  return this._healthcheckService;
4451
4891
  }
4452
4892
  async fetchSession() {
4453
4893
  try {
4454
- if (!this.public_key && this.private_key)
4894
+ if (!this.public_key && this.accessKey)
4455
4895
  await this.refreshUserAccessToken();
4456
- if (!this.public_key && !this.private_key)
4457
- throw new Error('No user private/public keys');
4896
+ if (!this.public_key && !this.accessKey)
4897
+ throw new Error('No accessKey provided');
4458
4898
  this.session = await this.appApi.fetchAppBuilderSession({
4459
4899
  public_key: this.public_key,
4460
4900
  user_id: this.user_id,
@@ -4469,6 +4909,7 @@ class Ductape {
4469
4909
  }
4470
4910
  }
4471
4911
  async validateWorkspace(subCheck = true) {
4912
+ var _a, _b;
4472
4913
  try {
4473
4914
  const workspace = await this.workspaceApi.fetchWorkspaceById({
4474
4915
  token: this.token,
@@ -4480,11 +4921,29 @@ class Ductape {
4480
4921
  throw new Error(`Workspace does not exist`);
4481
4922
  }
4482
4923
  catch (e) {
4483
- const error = e.response ? e.response.data.errors : e.toString();
4484
- throw error;
4924
+ // Safely extract error message
4925
+ let error;
4926
+ if ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) {
4927
+ if (typeof e.response.data.errors === 'string') {
4928
+ error = e.response.data.errors;
4929
+ }
4930
+ else {
4931
+ try {
4932
+ error = JSON.stringify(e.response.data.errors);
4933
+ }
4934
+ catch (_c) {
4935
+ error = 'Error parsing response';
4936
+ }
4937
+ }
4938
+ }
4939
+ else {
4940
+ error = e.message || 'Unknown error';
4941
+ }
4942
+ throw new Error(error);
4485
4943
  }
4486
4944
  }
4487
4945
  async createNewAppBuilderSession() {
4946
+ var _a, _b;
4488
4947
  try {
4489
4948
  this.session = await this.appApi.createAppBuilderSession({
4490
4949
  token: this.token,
@@ -4494,26 +4953,28 @@ class Ductape {
4494
4953
  });
4495
4954
  }
4496
4955
  catch (e) {
4497
- const error = e.response ? e.response.data.errors : e.toString();
4498
- throw error;
4956
+ const error = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || e.message || 'Unknown error';
4957
+ throw new Error(error);
4499
4958
  }
4500
4959
  }
4501
4960
  async refreshUserAccessToken() {
4961
+ var _a, _b;
4502
4962
  try {
4503
4963
  const validUser = await this.userApi.fetchUserByPrivateKey({
4504
- private_key: this.private_key,
4505
- workspace_id: this.workspace_id,
4506
- user_id: this.user_id,
4964
+ accessKey: this.accessKey,
4507
4965
  });
4508
4966
  this.token = validUser.auth_token;
4509
4967
  this.public_key = validUser.public_key;
4968
+ this.user_id = validUser.user_id;
4969
+ this.workspace_id = validUser.workspace_id;
4510
4970
  }
4511
4971
  catch (e) {
4512
- const error = e.response ? e.response.data.errors : e.toString();
4513
- throw error;
4972
+ const error = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || e.message || 'Unknown error';
4973
+ throw new Error(error);
4514
4974
  }
4515
4975
  }
4516
4976
  async fetchWorkspaceApps(status) {
4977
+ var _a, _b;
4517
4978
  try {
4518
4979
  if (!this.public_key || !this.token)
4519
4980
  throw new Error('User session not initiated');
@@ -4526,11 +4987,12 @@ class Ductape {
4526
4987
  return this.apps;
4527
4988
  }
4528
4989
  catch (e) {
4529
- const error = e.response ? e.response.data.errors : e.toString();
4530
- throw error;
4990
+ const error = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || e.message || 'Unknown error';
4991
+ throw new Error(error);
4531
4992
  }
4532
4993
  }
4533
4994
  async fetchWorkspaceProjects(status) {
4995
+ var _a, _b;
4534
4996
  try {
4535
4997
  if (!this.public_key || !this.token)
4536
4998
  throw new Error('User session not initiated');
@@ -4543,8 +5005,8 @@ class Ductape {
4543
5005
  return this.products;
4544
5006
  }
4545
5007
  catch (e) {
4546
- const error = e.response ? e.response.data.errors : e.toString();
4547
- throw error;
5008
+ const error = ((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || e.message || 'Unknown error';
5009
+ throw new Error(error);
4548
5010
  }
4549
5011
  }
4550
5012
  /**