@ductape/sdk 0.1.20 → 0.1.21

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 (79) hide show
  1. package/dist/agents/agents.service.d.ts +2 -0
  2. package/dist/agents/agents.service.js +26 -3
  3. package/dist/agents/agents.service.js.map +1 -1
  4. package/dist/api/services/logsApi.service.js +5 -1
  5. package/dist/api/services/logsApi.service.js.map +1 -1
  6. package/dist/api/services/productsApi.service.d.ts +111 -0
  7. package/dist/api/services/productsApi.service.js +90 -0
  8. package/dist/api/services/productsApi.service.js.map +1 -1
  9. package/dist/api/urls.d.ts +7 -0
  10. package/dist/api/urls.js +14 -7
  11. package/dist/api/urls.js.map +1 -1
  12. package/dist/apps/services/app.service.js +7 -2
  13. package/dist/apps/services/app.service.js.map +1 -1
  14. package/dist/brokers/brokers.service.js +20 -12
  15. package/dist/brokers/brokers.service.js.map +1 -1
  16. package/dist/database/adapters/mysql.adapter.js +8 -3
  17. package/dist/database/adapters/mysql.adapter.js.map +1 -1
  18. package/dist/database/adapters/postgresql.adapter.js +6 -2
  19. package/dist/database/adapters/postgresql.adapter.js.map +1 -1
  20. package/dist/database/databases.service.d.ts +10 -1
  21. package/dist/database/databases.service.js +84 -27
  22. package/dist/database/databases.service.js.map +1 -1
  23. package/dist/graph/graphs.service.d.ts +7 -3
  24. package/dist/graph/graphs.service.js +67 -31
  25. package/dist/graph/graphs.service.js.map +1 -1
  26. package/dist/index.d.ts +9 -2
  27. package/dist/index.js +32 -93
  28. package/dist/index.js.map +1 -1
  29. package/dist/logs/logs.service.d.ts +3 -1
  30. package/dist/logs/logs.service.js +12 -2
  31. package/dist/logs/logs.service.js.map +1 -1
  32. package/dist/logs/logs.types.d.ts +4 -0
  33. package/dist/logs/logs.types.js.map +1 -1
  34. package/dist/notifications/notifications.service.d.ts +6 -0
  35. package/dist/notifications/notifications.service.js +54 -17
  36. package/dist/notifications/notifications.service.js.map +1 -1
  37. package/dist/processor/services/processor.service.d.ts +0 -14
  38. package/dist/processor/services/processor.service.js +6 -72
  39. package/dist/processor/services/processor.service.js.map +1 -1
  40. package/dist/products/bootstrap-cache.d.ts +22 -0
  41. package/dist/products/bootstrap-cache.js +78 -0
  42. package/dist/products/bootstrap-cache.js.map +1 -0
  43. package/dist/products/services/products.service.d.ts +46 -3
  44. package/dist/products/services/products.service.js +304 -125
  45. package/dist/products/services/products.service.js.map +1 -1
  46. package/dist/products/validators/joi-validators/create.productFallback.validator.js +1 -1
  47. package/dist/products/validators/joi-validators/create.productGraph.validator.js +7 -0
  48. package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
  49. package/dist/products/validators/joi-validators/create.productQuota.validator.js +1 -1
  50. package/dist/products/validators/joi-validators/create.productVector.validator.js +6 -0
  51. package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -1
  52. package/dist/products/validators/joi-validators/update.productFallback.validator.js +1 -1
  53. package/dist/products/validators/joi-validators/update.productGraph.validator.js +9 -0
  54. package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
  55. package/dist/products/validators/joi-validators/update.productQuota.validator.js +1 -1
  56. package/dist/resilience/fallback.service.d.ts +3 -0
  57. package/dist/resilience/fallback.service.js +49 -14
  58. package/dist/resilience/fallback.service.js.map +1 -1
  59. package/dist/resilience/healthcheck.service.d.ts +3 -0
  60. package/dist/resilience/healthcheck.service.js +57 -7
  61. package/dist/resilience/healthcheck.service.js.map +1 -1
  62. package/dist/resilience/quota.service.d.ts +3 -0
  63. package/dist/resilience/quota.service.js +49 -14
  64. package/dist/resilience/quota.service.js.map +1 -1
  65. package/dist/resilience/resilience-execution.utils.d.ts +22 -0
  66. package/dist/resilience/resilience-execution.utils.js +81 -0
  67. package/dist/resilience/resilience-execution.utils.js.map +1 -0
  68. package/dist/sessions/sessions.service.d.ts +9 -1
  69. package/dist/sessions/sessions.service.js +125 -49
  70. package/dist/sessions/sessions.service.js.map +1 -1
  71. package/dist/types/index.types.d.ts +8 -0
  72. package/dist/types/index.types.js.map +1 -1
  73. package/dist/types/processor.types.d.ts +3 -0
  74. package/dist/types/processor.types.js.map +1 -1
  75. package/dist/types/requests.types.d.ts +4 -0
  76. package/dist/vector/vector-database.service.d.ts +6 -0
  77. package/dist/vector/vector-database.service.js +66 -8
  78. package/dist/vector/vector-database.service.js.map +1 -1
  79. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -464,7 +464,7 @@ class Ductape {
464
464
  this.redisClient = undefined;
465
465
  }
466
466
  }
467
- constructor({ accessKey, redis_url, product, env, local }) {
467
+ constructor({ accessKey, redis_url, product, env, local, ip_address, language }) {
468
468
  this.productBuilders = new Map();
469
469
  this.appBuilders = new Map();
470
470
  // Cached service instances (lazily initialized after auth)
@@ -479,6 +479,7 @@ class Ductape {
479
479
  this._jobsService = null;
480
480
  this._secretsService = null;
481
481
  this._cloudService = null;
482
+ this._sessionsService = null;
482
483
  this._privateKey = null;
483
484
  this._quotaService = null;
484
485
  this._fallbackService = null;
@@ -607,9 +608,9 @@ class Ductape {
607
608
  * @param {string} appTag - The app tag.
608
609
  * @returns {Promise<IAppAccess>} The result of the connection.
609
610
  */
610
- connect: async (product, appTag) => {
611
+ connect: async (product, appTag, options) => {
611
612
  const builder = await this.getProductBuilder(product);
612
- return builder.createAppAccessTag(appTag);
613
+ return builder.createAppAccessTag(appTag, options === null || options === void 0 ? void 0 : options.appId);
613
614
  },
614
615
  /**
615
616
  * Adds an app to a product.
@@ -5213,6 +5214,8 @@ class Ductape {
5213
5214
  const productTag = product === null || product === void 0 ? void 0 : product.trim();
5214
5215
  const envSlug = env === null || env === void 0 ? void 0 : env.trim();
5215
5216
  this.accessKey = accessKey;
5217
+ this.clientIpAddress = (ip_address === null || ip_address === void 0 ? void 0 : ip_address.trim()) || undefined;
5218
+ this.clientLanguage = (language === null || language === void 0 ? void 0 : language.trim()) || undefined;
5216
5219
  this.environment =
5217
5220
  local === true
5218
5221
  ? index_types_1.EnvType.LOCAL
@@ -5531,29 +5534,18 @@ class Ductape {
5531
5534
  }
5532
5535
  }
5533
5536
  createNewLogger(product_id, app_id) {
5537
+ return new logs_service_1.default(Object.assign(Object.assign({}, this.builderInit()), { product_id,
5538
+ app_id }));
5539
+ }
5540
+ /** Shared auth + client context fields for service constructors. */
5541
+ builderInit(extra = {}) {
5534
5542
  var _a;
5535
- return new logs_service_1.default({
5536
- workspace_id: this.workspace_id,
5537
- public_key: this.public_key,
5538
- user_id: this.user_id,
5539
- token: this.token,
5540
- product_id,
5541
- env_type: this.environment,
5542
- app_id,
5543
- workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
5544
- });
5543
+ return Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, access_key: this.accessKey, workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined, ip_address: this.clientIpAddress, language: this.clientLanguage }, extra);
5545
5544
  }
5546
5545
  async createNewProductBuilder() {
5547
5546
  const subCheck = false;
5548
5547
  await this.initUserAuth(subCheck);
5549
- return new products_service_1.default({
5550
- workspace_id: this.workspace_id,
5551
- public_key: this.public_key,
5552
- user_id: this.user_id,
5553
- token: this.token,
5554
- env_type: this.environment,
5555
- access_key: this.accessKey,
5556
- });
5548
+ return new products_service_1.default(this.builderInit());
5557
5549
  }
5558
5550
  async createNewProcessor() {
5559
5551
  const subCheck = false;
@@ -5562,41 +5554,17 @@ class Ductape {
5562
5554
  if (this.redis_url && !this.jobsQueue) {
5563
5555
  await this.monitor();
5564
5556
  }
5565
- return new processor_service_1.default({
5566
- workspace_id: this.workspace_id,
5567
- public_key: this.public_key,
5568
- user_id: this.user_id,
5569
- token: this.token,
5570
- env_type: this.environment,
5571
- redis_client: this.redisClient,
5572
- queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
5573
- access_key: this.accessKey,
5574
- private_key: this._privateKey,
5575
- });
5557
+ return new processor_service_1.default(Object.assign(Object.assign({}, this.builderInit()), { redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey }));
5576
5558
  }
5577
5559
  async createNewImporter() {
5578
5560
  const subCheck = false;
5579
5561
  await this.initUserAuth(subCheck);
5580
- return new imports_service_1.default({
5581
- workspace_id: this.workspace_id,
5582
- public_key: this.public_key,
5583
- user_id: this.user_id,
5584
- token: this.token,
5585
- env_type: this.environment,
5586
- access_key: this.accessKey,
5587
- });
5562
+ return new imports_service_1.default(this.builderInit());
5588
5563
  }
5589
5564
  async createNewAppBuilder() {
5590
5565
  const subCheck = false;
5591
5566
  await this.initUserAuth(subCheck);
5592
- return new app_service_1.default({
5593
- workspace_id: this.workspace_id,
5594
- public_key: this.public_key,
5595
- user_id: this.user_id,
5596
- token: this.token,
5597
- env_type: this.environment,
5598
- access_key: this.accessKey,
5599
- });
5567
+ return new app_service_1.default(this.builderInit());
5600
5568
  }
5601
5569
  /**
5602
5570
  * Create a new DatabaseService instance with authenticated config
@@ -5613,7 +5581,7 @@ class Ductape {
5613
5581
  await this.connectCacheRedis();
5614
5582
  // Return cached instance if available, otherwise create new
5615
5583
  if (!this._databaseService) {
5616
- this._databaseService = new database_1.DatabaseService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, private_key: this._privateKey, access_key: this.accessKey, redis_client: this.redisClient }, this.runtimeDefaultsForServices()));
5584
+ this._databaseService = new database_1.DatabaseService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { private_key: this._privateKey, redis_client: this.redisClient }), this.runtimeDefaultsForServices()));
5617
5585
  }
5618
5586
  return this._databaseService;
5619
5587
  }
@@ -5629,7 +5597,7 @@ class Ductape {
5629
5597
  // Connect to Redis for caching (if configured)
5630
5598
  await this.connectCacheRedis();
5631
5599
  if (!this._graphService) {
5632
- this._graphService = new graph_1.GraphService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, private_key: this._privateKey, access_key: this.accessKey, redis_client: this.redisClient }, this.runtimeDefaultsForServices()));
5600
+ this._graphService = new graph_1.GraphService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { private_key: this._privateKey, redis_client: this.redisClient }), this.runtimeDefaultsForServices()));
5633
5601
  }
5634
5602
  return this._graphService;
5635
5603
  }
@@ -5643,15 +5611,7 @@ class Ductape {
5643
5611
  // Ensure secrets service is initialized so workflow steps can resolve $Secret{...} / $secret{...} in configs (broker, storage, etc.)
5644
5612
  await this.createNewSecretsService();
5645
5613
  if (!this._workflowService) {
5646
- this._workflowService = new workflows_1.WorkflowService({
5647
- workspace_id: this.workspace_id,
5648
- public_key: this.public_key,
5649
- user_id: this.user_id,
5650
- token: this.token,
5651
- env_type: this.environment,
5652
- private_key: this._privateKey,
5653
- access_key: this.accessKey,
5654
- });
5614
+ this._workflowService = new workflows_1.WorkflowService(Object.assign(Object.assign({}, this.builderInit()), { private_key: this._privateKey }));
5655
5615
  }
5656
5616
  return this._workflowService;
5657
5617
  }
@@ -5665,16 +5625,7 @@ class Ductape {
5665
5625
  // Ensure secrets service is initialized for secret storage/resolution
5666
5626
  await this.createNewSecretsService();
5667
5627
  if (!this._agentsService) {
5668
- this._agentsService = new agents_1.AgentsService({
5669
- workspace_id: this.workspace_id,
5670
- public_key: this.public_key,
5671
- user_id: this.user_id,
5672
- token: this.token,
5673
- env_type: this.environment,
5674
- redis_client: this.redisClient,
5675
- private_key: this._privateKey,
5676
- access_key: this.accessKey,
5677
- });
5628
+ this._agentsService = new agents_1.AgentsService(Object.assign(Object.assign({}, this.builderInit()), { redis_client: this.redisClient, private_key: this._privateKey }));
5678
5629
  }
5679
5630
  return this._agentsService;
5680
5631
  }
@@ -5686,11 +5637,7 @@ class Ductape {
5686
5637
  const subCheck = false;
5687
5638
  await this.initUserAuth(subCheck);
5688
5639
  if (!this._modelService) {
5689
- this._modelService = new models_1.ModelService({
5690
- workspace_id: this.workspace_id,
5691
- user_id: this.user_id,
5692
- env_type: this.environment,
5693
- }, this.getProductBuilder.bind(this));
5640
+ this._modelService = new models_1.ModelService(Object.assign({}, this.builderInit()), this.getProductBuilder.bind(this));
5694
5641
  }
5695
5642
  return this._modelService;
5696
5643
  }
@@ -5706,7 +5653,7 @@ class Ductape {
5706
5653
  // Connect to Redis for caching (if configured)
5707
5654
  await this.connectCacheRedis();
5708
5655
  if (!this._vectorService) {
5709
- this._vectorService = new vector_1.VectorDatabaseService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, private_key: this._privateKey, access_key: this.accessKey, redis_client: this.redisClient }, this.runtimeDefaultsForServices()));
5656
+ this._vectorService = new vector_1.VectorDatabaseService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { private_key: this._privateKey, redis_client: this.redisClient }), this.runtimeDefaultsForServices()));
5710
5657
  }
5711
5658
  return this._vectorService;
5712
5659
  }
@@ -5737,11 +5684,10 @@ class Ductape {
5737
5684
  * @returns CacheService instance
5738
5685
  */
5739
5686
  async createNewCacheService() {
5740
- var _a;
5741
5687
  const subCheck = false;
5742
5688
  await this.initUserAuth(subCheck);
5743
5689
  if (!this._cacheService) {
5744
- this._cacheService = new cache_1.CacheService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, access_key: this.accessKey, workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined }, this.runtimeDefaultsForServices()));
5690
+ this._cacheService = new cache_1.CacheService(Object.assign(Object.assign({}, this.builderInit()), this.runtimeDefaultsForServices()));
5745
5691
  }
5746
5692
  return this._cacheService;
5747
5693
  }
@@ -5831,10 +5777,12 @@ class Ductape {
5831
5777
  * @returns SessionsService instance
5832
5778
  */
5833
5779
  async createNewSessionsService() {
5834
- var _a;
5835
5780
  const subCheck = false;
5836
5781
  await this.initUserAuth(subCheck);
5837
- return new sessions_1.SessionsService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, access_key: this.accessKey, redis_client: this.redisClient, workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined }, this.runtimeDefaultsForServices()));
5782
+ if (!this._sessionsService) {
5783
+ this._sessionsService = new sessions_1.SessionsService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { redis_client: this.redisClient }), this.runtimeDefaultsForServices()));
5784
+ }
5785
+ return this._sessionsService;
5838
5786
  }
5839
5787
  /**
5840
5788
  * Create a new StorageService instance with authenticated config
@@ -5847,14 +5795,13 @@ class Ductape {
5847
5795
  await this.createNewSecretsService();
5848
5796
  // Connect to Redis for caching (if configured)
5849
5797
  await this.connectCacheRedis();
5850
- return new storage_1.StorageService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, private_key: this._privateKey, redis_client: this.redisClient }, this.runtimeDefaultsForServices()));
5798
+ return new storage_1.StorageService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { private_key: this._privateKey, redis_client: this.redisClient }), this.runtimeDefaultsForServices()));
5851
5799
  }
5852
5800
  /**
5853
5801
  * Get or create a BrokersService instance with authenticated config (cached)
5854
5802
  * @returns BrokersService instance
5855
5803
  */
5856
5804
  async createNewBrokersService() {
5857
- var _a;
5858
5805
  // Return cached instance if available
5859
5806
  if (this._brokersService) {
5860
5807
  return this._brokersService;
@@ -5863,15 +5810,7 @@ class Ductape {
5863
5810
  await this.initUserAuth(subCheck);
5864
5811
  // Ensure secrets service is initialized for secret storage/resolution
5865
5812
  await this.createNewSecretsService();
5866
- this._brokersService = new brokers_1.BrokersService({
5867
- workspace_id: this.workspace_id,
5868
- public_key: this.public_key,
5869
- user_id: this.user_id,
5870
- token: this.token,
5871
- env_type: this.environment,
5872
- access_key: this.accessKey,
5873
- workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
5874
- });
5813
+ this._brokersService = new brokers_1.BrokersService(this.builderInit());
5875
5814
  return this._brokersService;
5876
5815
  }
5877
5816
  /**
@@ -5882,7 +5821,7 @@ class Ductape {
5882
5821
  const subCheck = false;
5883
5822
  await this.initUserAuth(subCheck);
5884
5823
  if (!this._quotaService) {
5885
- this._quotaService = new resilience_1.QuotaService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey, access_key: this.accessKey }, this.runtimeDefaultsForServices()));
5824
+ this._quotaService = new resilience_1.QuotaService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey }), this.runtimeDefaultsForServices()));
5886
5825
  }
5887
5826
  return this._quotaService;
5888
5827
  }
@@ -5894,7 +5833,7 @@ class Ductape {
5894
5833
  const subCheck = false;
5895
5834
  await this.initUserAuth(subCheck);
5896
5835
  if (!this._fallbackService) {
5897
- this._fallbackService = new resilience_1.FallbackService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey, access_key: this.accessKey }, this.runtimeDefaultsForServices()));
5836
+ this._fallbackService = new resilience_1.FallbackService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey }), this.runtimeDefaultsForServices()));
5898
5837
  }
5899
5838
  return this._fallbackService;
5900
5839
  }
@@ -5909,7 +5848,7 @@ class Ductape {
5909
5848
  // (DatabaseService, StorageService, WorkflowService, etc.) can resolve $secret{...}
5910
5849
  await this.createNewSecretsService();
5911
5850
  if (!this._healthcheckService) {
5912
- this._healthcheckService = new resilience_1.HealthcheckService(Object.assign({ workspace_id: this.workspace_id, public_key: this.public_key, user_id: this.user_id, token: this.token, env_type: this.environment, redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey, access_key: this.accessKey }, this.runtimeDefaultsForServices()));
5851
+ this._healthcheckService = new resilience_1.HealthcheckService(Object.assign(Object.assign(Object.assign({}, this.builderInit()), { redis_client: this.redisClient, queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }, private_key: this._privateKey }), this.runtimeDefaultsForServices()));
5913
5852
  }
5914
5853
  return this._healthcheckService;
5915
5854
  }