@ductape/sdk 0.1.7 → 0.1.9

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 (105) hide show
  1. package/dist/api/services/cloudApi.service.d.ts +31 -0
  2. package/dist/api/services/cloudApi.service.js +103 -0
  3. package/dist/api/services/cloudApi.service.js.map +1 -0
  4. package/dist/api/services/productsApi.service.d.ts +17 -0
  5. package/dist/api/services/productsApi.service.js +18 -4
  6. package/dist/api/services/productsApi.service.js.map +1 -1
  7. package/dist/api/urls.d.ts +9 -0
  8. package/dist/api/urls.js +13 -3
  9. package/dist/api/urls.js.map +1 -1
  10. package/dist/api/utils/integration-api-error.d.ts +6 -0
  11. package/dist/api/utils/integration-api-error.js +45 -0
  12. package/dist/api/utils/integration-api-error.js.map +1 -0
  13. package/dist/apps/utils/credential-manager.d.ts +2 -2
  14. package/dist/apps/utils/credential-manager.js +2 -2
  15. package/dist/apps/utils/oauth-manager.d.ts +5 -5
  16. package/dist/apps/utils/oauth-manager.js +5 -5
  17. package/dist/brokers/brokers.service.js +29 -8
  18. package/dist/brokers/brokers.service.js.map +1 -1
  19. package/dist/cache/cache.service.d.ts +2 -0
  20. package/dist/cache/cache.service.js +9 -4
  21. package/dist/cache/cache.service.js.map +1 -1
  22. package/dist/cache/types/index.d.ts +2 -0
  23. package/dist/cloud/cloud-runtime.util.d.ts +22 -0
  24. package/dist/cloud/cloud-runtime.util.js +61 -0
  25. package/dist/cloud/cloud-runtime.util.js.map +1 -0
  26. package/dist/cloud/cloud.service.d.ts +43 -0
  27. package/dist/cloud/cloud.service.js +121 -0
  28. package/dist/cloud/cloud.service.js.map +1 -0
  29. package/dist/cloud/index.d.ts +5 -0
  30. package/dist/cloud/index.js +25 -0
  31. package/dist/cloud/index.js.map +1 -0
  32. package/dist/cloud/types/cloud.types.d.ts +140 -0
  33. package/dist/cloud/types/cloud.types.js +6 -0
  34. package/dist/cloud/types/cloud.types.js.map +1 -0
  35. package/dist/cloud/types/index.d.ts +1 -0
  36. package/dist/cloud/types/index.js +18 -0
  37. package/dist/cloud/types/index.js.map +1 -0
  38. package/dist/database/databases.service.d.ts +30 -0
  39. package/dist/database/databases.service.js +86 -10
  40. package/dist/database/databases.service.js.map +1 -1
  41. package/dist/database/index.d.ts +1 -1
  42. package/dist/database/index.js.map +1 -1
  43. package/dist/database/types/connection.interface.d.ts +4 -0
  44. package/dist/graph/graphs.service.d.ts +16 -0
  45. package/dist/graph/graphs.service.js +110 -20
  46. package/dist/graph/graphs.service.js.map +1 -1
  47. package/dist/graph/index.d.ts +1 -0
  48. package/dist/graph/index.js.map +1 -1
  49. package/dist/graph/types/connection.interface.d.ts +12 -0
  50. package/dist/index.d.ts +225 -13
  51. package/dist/index.js +152 -114
  52. package/dist/index.js.map +1 -1
  53. package/dist/notifications/notifications.service.d.ts +2 -0
  54. package/dist/notifications/notifications.service.js +10 -5
  55. package/dist/notifications/notifications.service.js.map +1 -1
  56. package/dist/notifications/types/notifications.types.d.ts +2 -0
  57. package/dist/products/services/products.service.d.ts +3 -1
  58. package/dist/products/services/products.service.js +8 -0
  59. package/dist/products/services/products.service.js.map +1 -1
  60. package/dist/products/validators/joi-validators/update.dataValue.validator.js +2 -1
  61. package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
  62. package/dist/resilience/fallback.service.d.ts +2 -0
  63. package/dist/resilience/fallback.service.js +6 -1
  64. package/dist/resilience/fallback.service.js.map +1 -1
  65. package/dist/resilience/healthcheck.service.d.ts +2 -0
  66. package/dist/resilience/healthcheck.service.js +21 -14
  67. package/dist/resilience/healthcheck.service.js.map +1 -1
  68. package/dist/resilience/quota.service.d.ts +2 -0
  69. package/dist/resilience/quota.service.js +6 -1
  70. package/dist/resilience/quota.service.js.map +1 -1
  71. package/dist/resilience/types/index.d.ts +2 -0
  72. package/dist/runtime/runtime-defaults.d.ts +28 -0
  73. package/dist/runtime/runtime-defaults.js +38 -0
  74. package/dist/runtime/runtime-defaults.js.map +1 -0
  75. package/dist/sessions/sessions.service.d.ts +2 -0
  76. package/dist/sessions/sessions.service.js +15 -10
  77. package/dist/sessions/sessions.service.js.map +1 -1
  78. package/dist/sessions/types/index.d.ts +3 -0
  79. package/dist/storage/storage.service.d.ts +2 -0
  80. package/dist/storage/storage.service.js +43 -10
  81. package/dist/storage/storage.service.js.map +1 -1
  82. package/dist/storage/types/index.d.ts +3 -0
  83. package/dist/storage/utils/storage.util.js +42 -12
  84. package/dist/storage/utils/storage.util.js.map +1 -1
  85. package/dist/types/enums.d.ts +2 -1
  86. package/dist/types/enums.js +1 -0
  87. package/dist/types/enums.js.map +1 -1
  88. package/dist/types/index.types.d.ts +8 -1
  89. package/dist/types/index.types.js +9 -0
  90. package/dist/types/index.types.js.map +1 -1
  91. package/dist/types/productsBuilder.types.d.ts +24 -7
  92. package/dist/types/productsBuilder.types.js.map +1 -1
  93. package/dist/vector/index.d.ts +2 -1
  94. package/dist/vector/index.js +3 -1
  95. package/dist/vector/index.js.map +1 -1
  96. package/dist/vector/utils/index.d.ts +1 -0
  97. package/dist/vector/utils/index.js +3 -1
  98. package/dist/vector/utils/index.js.map +1 -1
  99. package/dist/vector/utils/metadata-schema.d.ts +14 -0
  100. package/dist/vector/utils/metadata-schema.js +79 -0
  101. package/dist/vector/utils/metadata-schema.js.map +1 -0
  102. package/dist/vector/vector-database.service.d.ts +27 -0
  103. package/dist/vector/vector-database.service.js +73 -2
  104. package/dist/vector/vector-database.service.js.map +1 -1
  105. package/package.json +6 -3
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.cacheLogger = exports.CacheError = exports.CacheService = exports.SessionError = exports.SessionsService = exports.generateSignedUrl = exports.listBlobsInCloud = exports.deleteBlobFromCloud = exports.downloadBlobFromCloud = exports.uploadBlobToCloud = exports.StorageError = exports.StorageService = exports.createMemoryAdapter = exports.createWeaviateAdapter = exports.createQdrantAdapter = exports.createPineconeAdapter = exports.createVectorStoreAdapter = exports.VectorServiceAdapter = exports.OpenAIProvider = exports.AnthropicProvider = exports.createLLMProvider = exports.MemoryManager = exports.ToolRegistry = exports.AgentContext = exports.AgentExecutor = exports.agentsService = exports.AgentError = exports.AgentsService = exports.createWorkflow = exports.WorkflowBuilder = exports.workflowService = exports.WorkflowError = exports.WorkflowService = exports.GraphAdapterFactory = exports.MemgraphAdapter = exports.ArangoDBAdapter = exports.NeptuneAdapter = exports.Neo4jAdapter = exports.BaseGraphAdapter = exports.GraphError = exports.GraphSortOrder = exports.GraphFeature = exports.GraphErrorType = exports.GraphTransactionStatus = exports.GraphIsolationLevel = exports.NodeConstraintType = exports.NodeIndexType = exports.TraversalDirection = exports.GraphType = exports.GraphService = void 0;
51
- exports.mightContainSecrets = exports.findAllSecretReferences = exports.extractSecretKeys = exports.containsSecretReferences = exports.isSecretReference = exports.SecretResolutionError = exports.SecretRevokedError = exports.SecretExpiredError = exports.SecretEnvironmentError = exports.SecretScopeError = exports.SecretNotFoundError = exports.SECRET_PATTERN_GLOBAL = exports.SECRET_PATTERN = exports.SecretsService = exports.VectorFeature = exports.VectorErrorType = exports.VectorIndexType = exports.DistanceMetric = exports.VectorDBType = exports.MemoryAdapter = exports.WeaviateAdapter = exports.QdrantAdapter = exports.PineconeAdapter = exports.BaseVectorAdapter = exports.VectorError = exports.VectorDatabaseService = exports.SmsProvider = exports.PushNotificationProvider = exports.NotificationChannelType = exports.notificationsService = exports.NotificationsService = exports.getSqsQueueUrl = exports.isValidSqsUrl = exports.parseEventString = exports.loadBrokerService = exports.GooglePubSubService = exports.RedisService = exports.SQSService = exports.KafkaService = exports.RabbitMQService = exports.BrokerError = exports.BrokersService = exports.CacheLogger = void 0;
51
+ exports.CloudError = exports.CloudService = exports.mightContainSecrets = exports.findAllSecretReferences = exports.extractSecretKeys = exports.containsSecretReferences = exports.isSecretReference = exports.SecretResolutionError = exports.SecretRevokedError = exports.SecretExpiredError = exports.SecretEnvironmentError = exports.SecretScopeError = exports.SecretNotFoundError = exports.SECRET_PATTERN_GLOBAL = exports.SECRET_PATTERN = exports.SecretsService = exports.VectorFeature = exports.VectorErrorType = exports.VectorIndexType = exports.DistanceMetric = exports.VectorDBType = exports.MemoryAdapter = exports.WeaviateAdapter = exports.QdrantAdapter = exports.PineconeAdapter = exports.BaseVectorAdapter = exports.VectorError = exports.VectorDatabaseService = exports.SmsProvider = exports.PushNotificationProvider = exports.NotificationChannelType = exports.notificationsService = exports.NotificationsService = exports.getSqsQueueUrl = exports.isValidSqsUrl = exports.parseEventString = exports.loadBrokerService = exports.GooglePubSubService = exports.RedisService = exports.SQSService = exports.KafkaService = exports.RabbitMQService = exports.BrokerError = exports.BrokersService = exports.CacheLogger = void 0;
52
52
  const appApi_service_1 = require("./api/services/appApi.service");
53
53
  const userApi_service_1 = require("./api/services/userApi.service");
54
54
  const workspaceApi_service_1 = require("./api/services/workspaceApi.service");
@@ -58,6 +58,7 @@ const products_service_1 = __importDefault(require("./products/services/products
58
58
  const fs_1 = require("fs");
59
59
  const types_1 = require("./types");
60
60
  const index_types_1 = require("./types/index.types");
61
+ const runtime_defaults_1 = require("./runtime/runtime-defaults");
61
62
  const enums_1 = require("./types/enums");
62
63
  const productsApi_service_1 = require("./api/services/productsApi.service");
63
64
  const imports_service_1 = __importDefault(require("./imports/imports.service"));
@@ -81,6 +82,7 @@ const jobs_1 = require("./jobs");
81
82
  const secrets_1 = require("./secrets");
82
83
  const warehouse_1 = require("./warehouse");
83
84
  const utils_1 = require("./apps/utils");
85
+ const cloud_1 = require("./cloud");
84
86
  /**
85
87
  * @typedef {Object} IProduct
86
88
  * @property {string} tag - Unique product tag.
@@ -412,6 +414,10 @@ Object.defineProperty(exports, "containsSecretReferences", { enumerable: true, g
412
414
  Object.defineProperty(exports, "extractSecretKeys", { enumerable: true, get: function () { return secrets_3.extractSecretKeys; } });
413
415
  Object.defineProperty(exports, "findAllSecretReferences", { enumerable: true, get: function () { return secrets_3.findAllSecretReferences; } });
414
416
  Object.defineProperty(exports, "mightContainSecrets", { enumerable: true, get: function () { return secrets_3.mightContainSecrets; } });
417
+ // Re-export Cloud module types and classes
418
+ var cloud_2 = require("./cloud");
419
+ Object.defineProperty(exports, "CloudService", { enumerable: true, get: function () { return cloud_2.CloudService; } });
420
+ Object.defineProperty(exports, "CloudError", { enumerable: true, get: function () { return cloud_2.CloudError; } });
415
421
  class Ductape {
416
422
  async loadRedis() {
417
423
  if (typeof window !== 'undefined') {
@@ -451,7 +457,7 @@ class Ductape {
451
457
  this.redisClient = undefined;
452
458
  }
453
459
  }
454
- constructor({ accessKey, env_type, redis_url }) {
460
+ constructor({ accessKey, redis_url, product, env, local }) {
455
461
  this.productBuilders = new Map();
456
462
  this.appBuilders = new Map();
457
463
  // Cached service instances (lazily initialized after auth)
@@ -465,6 +471,7 @@ class Ductape {
465
471
  this._cacheService = null;
466
472
  this._jobsService = null;
467
473
  this._secretsService = null;
474
+ this._cloudService = null;
468
475
  this._privateKey = null;
469
476
  this._quotaService = null;
470
477
  this._fallbackService = null;
@@ -1839,7 +1846,7 @@ class Ductape {
1839
1846
  send: async (options) => {
1840
1847
  var _a, _b;
1841
1848
  const processorService = await this.createNewProcessor();
1842
- const { product, env, notification, input, session, cache } = options;
1849
+ const { product, env, notification, input, session, cache } = this.mergeRuntime(options);
1843
1850
  return processorService.processNotification({
1844
1851
  product,
1845
1852
  env,
@@ -1871,7 +1878,7 @@ class Ductape {
1871
1878
  push: {
1872
1879
  send: async (options) => {
1873
1880
  const processorService = await this.createNewProcessor();
1874
- const { product, env, notification, input, session, cache } = options;
1881
+ const { product, env, notification, input, session, cache } = this.mergeRuntime(options);
1875
1882
  return processorService.processNotification({
1876
1883
  product,
1877
1884
  env,
@@ -1905,7 +1912,7 @@ class Ductape {
1905
1912
  send: async (options) => {
1906
1913
  var _a;
1907
1914
  const processorService = await this.createNewProcessor();
1908
- const { product, env, notification, input, session, cache } = options;
1915
+ const { product, env, notification, input, session, cache } = this.mergeRuntime(options);
1909
1916
  return processorService.processNotification({
1910
1917
  product,
1911
1918
  env,
@@ -1937,7 +1944,7 @@ class Ductape {
1937
1944
  send: async (options) => {
1938
1945
  var _a, _b, _c, _d;
1939
1946
  const processorService = await this.createNewProcessor();
1940
- const { product, env, notification, input, session, cache } = options;
1947
+ const { product, env, notification, input, session, cache } = this.mergeRuntime(options);
1941
1948
  return processorService.processNotification({
1942
1949
  product,
1943
1950
  env,
@@ -4231,6 +4238,76 @@ class Ductape {
4231
4238
  return this.createNewSecretsService();
4232
4239
  },
4233
4240
  };
4241
+ /**
4242
+ * Cloud provider connections (AWS, GCP, Azure) for discovering, importing, and provisioning resources.
4243
+ *
4244
+ * @example
4245
+ * const setup = await ductape.cloud.connections.create({
4246
+ * provider: 'aws',
4247
+ * name: 'Production AWS',
4248
+ * scopes: ['storage', 'broker'],
4249
+ * });
4250
+ * await ductape.cloud.connections.complete(setup.connection.id, { role_arn: 'arn:aws:iam::123:role/Ductape' });
4251
+ */
4252
+ this.cloud = {
4253
+ connections: {
4254
+ create: async (input) => {
4255
+ const service = await this.createNewCloudService();
4256
+ return service.createConnection(input);
4257
+ },
4258
+ list: async () => {
4259
+ const service = await this.createNewCloudService();
4260
+ return service.listConnections();
4261
+ },
4262
+ fetch: async (connectionId) => {
4263
+ const service = await this.createNewCloudService();
4264
+ return service.fetchConnection(connectionId);
4265
+ },
4266
+ delete: async (connectionId) => {
4267
+ const service = await this.createNewCloudService();
4268
+ return service.deleteConnection(connectionId);
4269
+ },
4270
+ complete: async (connectionId, input) => {
4271
+ const service = await this.createNewCloudService();
4272
+ return service.completeConnection(connectionId, input);
4273
+ },
4274
+ validate: async (connectionId) => {
4275
+ const service = await this.createNewCloudService();
4276
+ return service.validateConnection(connectionId);
4277
+ },
4278
+ },
4279
+ resources: {
4280
+ list: async (input) => {
4281
+ const service = await this.createNewCloudService();
4282
+ return service.listResources(input);
4283
+ },
4284
+ import: async (input) => {
4285
+ const service = await this.createNewCloudService();
4286
+ return service.importResource(input);
4287
+ },
4288
+ importAndPersist: async (input) => {
4289
+ const service = await this.createNewCloudService();
4290
+ return service.importAndPersist(input);
4291
+ },
4292
+ provision: async (input) => {
4293
+ const service = await this.createNewCloudService();
4294
+ return service.provisionResource(input);
4295
+ },
4296
+ provisionAndPersist: async (input) => {
4297
+ const service = await this.createNewCloudService();
4298
+ return service.provisionAndPersist(input);
4299
+ },
4300
+ },
4301
+ credentials: {
4302
+ issue: async (input) => {
4303
+ const service = await this.createNewCloudService();
4304
+ return service.issueRuntimeCredentials(input);
4305
+ },
4306
+ },
4307
+ getService: async () => {
4308
+ return this.createNewCloudService();
4309
+ },
4310
+ };
4234
4311
  /**
4235
4312
  * Cache-related operations for managing product caches.
4236
4313
  */
@@ -4306,7 +4383,7 @@ class Ductape {
4306
4383
  */
4307
4384
  fetchValues: async (options) => {
4308
4385
  const cacheService = await this.createNewCacheService();
4309
- return cacheService.fetchValues(options);
4386
+ return cacheService.fetchValues(this.mergeRuntime(options));
4310
4387
  },
4311
4388
  /**
4312
4389
  * Fetch cache dashboard metrics.
@@ -4322,7 +4399,7 @@ class Ductape {
4322
4399
  */
4323
4400
  fetchDashboard: async (options) => {
4324
4401
  const cacheService = await this.createNewCacheService();
4325
- return cacheService.fetchDashboard(options);
4402
+ return cacheService.fetchDashboard(this.mergeRuntime(options));
4326
4403
  },
4327
4404
  /**
4328
4405
  * Get a cache value by key.
@@ -4353,7 +4430,7 @@ class Ductape {
4353
4430
  */
4354
4431
  set: async (options) => {
4355
4432
  const cacheService = await this.createNewCacheService();
4356
- return cacheService.set(options);
4433
+ return cacheService.set(this.mergeRuntime(options));
4357
4434
  },
4358
4435
  /**
4359
4436
  * Clear a cache value by key.
@@ -4383,7 +4460,7 @@ class Ductape {
4383
4460
  */
4384
4461
  clearAll: async (options) => {
4385
4462
  const cacheService = await this.createNewCacheService();
4386
- return cacheService.clearAll(options);
4463
+ return cacheService.clearAll(this.mergeRuntime(options));
4387
4464
  },
4388
4465
  };
4389
4466
  /**
@@ -4572,9 +4649,9 @@ class Ductape {
4572
4649
  },
4573
4650
  };
4574
4651
  /**
4575
- * Action-related operations for managing app actions.
4652
+ * API operations: run/dispatch app actions, credentials, OAuth, and app action CRUD.
4576
4653
  */
4577
- this.actions = {
4654
+ this.api = {
4578
4655
  /**
4579
4656
  * Imports actions for an app from a file.
4580
4657
  * @param {Object} params - The import parameters.
@@ -4652,7 +4729,7 @@ class Ductape {
4652
4729
  * @param {IActionProcessorInput} data - The action processor input.
4653
4730
  * @returns {Promise<any>} The result of the action processing.
4654
4731
  * @example
4655
- * await ductape.actions.run({
4732
+ * await ductape.api.run({
4656
4733
  * product: 'my-product',
4657
4734
  * env: 'production',
4658
4735
  * app: 'stripe',
@@ -4682,7 +4759,7 @@ class Ductape {
4682
4759
  * @returns {Promise<IDispatchResult>} The dispatch result with job ID and status.
4683
4760
  * @example
4684
4761
  * // Run once at a specific time
4685
- * await ductape.actions.dispatch({
4762
+ * await ductape.api.dispatch({
4686
4763
  * product: 'my-product',
4687
4764
  * env: 'production',
4688
4765
  * app: 'stripe',
@@ -4692,7 +4769,7 @@ class Ductape {
4692
4769
  * });
4693
4770
  *
4694
4771
  * // Run on a cron schedule
4695
- * await ductape.actions.dispatch({
4772
+ * await ductape.api.dispatch({
4696
4773
  * product: 'my-product',
4697
4774
  * env: 'production',
4698
4775
  * app: 'analytics',
@@ -4759,7 +4836,7 @@ class Ductape {
4759
4836
  * // Define app configuration and set credentials
4760
4837
  * const stripeConfig = { product: 'my-product', app: 'stripe', env: 'prd' };
4761
4838
  *
4762
- * ductape.actions.config({
4839
+ * ductape.api.config({
4763
4840
  * ...stripeConfig,
4764
4841
  * credentials: {
4765
4842
  * 'headers:Authorization': '$Secret{StripeApiKey}',
@@ -4767,7 +4844,7 @@ class Ductape {
4767
4844
  * });
4768
4845
  *
4769
4846
  * // Now all stripe actions automatically include the Authorization header
4770
- * await ductape.actions.run({
4847
+ * await ductape.api.run({
4771
4848
  * ...stripeConfig,
4772
4849
  * action: 'create-charge',
4773
4850
  * input: { amount: 1000, currency: 'usd' }
@@ -4781,8 +4858,8 @@ class Ductape {
4781
4858
  * Tokens are stored securely using $Secret{} and automatically refreshed when expired.
4782
4859
  * @param {IOAuthConfig} config - The OAuth configuration.
4783
4860
  * @example
4784
- * // Set up OAuth with automatic refresh using ductape.actions.run
4785
- * await ductape.actions.oauth({
4861
+ * // Set up OAuth with automatic refresh using ductape.api.run
4862
+ * await ductape.api.oauth({
4786
4863
  * product: 'my-product',
4787
4864
  * app: 'salesforce',
4788
4865
  * env: 'prd',
@@ -4795,8 +4872,8 @@ class Ductape {
4795
4872
  * 'headers:Authorization': `Bearer ${tokens.accessToken}`
4796
4873
  * }),
4797
4874
  * onExpiry: async (currentTokens) => {
4798
- * // Use ductape.actions.run to call your refresh token action
4799
- * const response = await ductape.actions.run({
4875
+ * // Use ductape.api.run to call your refresh token action
4876
+ * const response = await ductape.api.run({
4800
4877
  * product: 'my-product',
4801
4878
  * app: 'salesforce',
4802
4879
  * env: 'prd',
@@ -4818,7 +4895,7 @@ class Ductape {
4818
4895
  *
4819
4896
  * // Now all salesforce actions automatically include OAuth tokens
4820
4897
  * // and refresh automatically when expired
4821
- * await ductape.actions.run({
4898
+ * await ductape.api.run({
4822
4899
  * product: 'my-product',
4823
4900
  * app: 'salesforce',
4824
4901
  * env: 'prd',
@@ -5018,8 +5095,20 @@ class Ductape {
5018
5095
  if (typeof window !== 'undefined') {
5019
5096
  throw new Error('Ductape SDK can only be initialized in a server environment.');
5020
5097
  }
5098
+ const productTag = product === null || product === void 0 ? void 0 : product.trim();
5099
+ const envSlug = env === null || env === void 0 ? void 0 : env.trim();
5100
+ if (!productTag || !envSlug) {
5101
+ throw new Error('product and env are required on the Ductape constructor: new Ductape({ accessKey, product, env })');
5102
+ }
5021
5103
  this.accessKey = accessKey;
5022
- this.environment = env_type || index_types_1.EnvType.PRODUCTION;
5104
+ this.environment =
5105
+ local === true
5106
+ ? index_types_1.EnvType.LOCAL
5107
+ : local === false
5108
+ ? index_types_1.EnvType.PRODUCTION
5109
+ : (0, index_types_1.apiEnvironmentFromProcess)();
5110
+ this.defaultProduct = productTag;
5111
+ this.defaultEnv = envSlug;
5023
5112
  this.userApi = new userApi_service_1.UserApiService(this.environment);
5024
5113
  this.appApi = new appApi_service_1.AppApiService(this.environment);
5025
5114
  this.workspaceApi = new workspaceApi_service_1.WorkspaceApiService(this.environment);
@@ -5243,6 +5332,13 @@ class Ductape {
5243
5332
  setPublicKey(public_key) {
5244
5333
  this.public_key = public_key;
5245
5334
  }
5335
+ runtimeDefaultsForServices() {
5336
+ return { default_product: this.defaultProduct, default_env: this.defaultEnv };
5337
+ }
5338
+ /** Merge constructor product/env into call options (sessions, storage, cache, notifications, resilience, etc.). */
5339
+ mergeRuntime(options) {
5340
+ return (0, runtime_defaults_1.mergeProductEnv)(options, this.runtimeDefaultsForServices());
5341
+ }
5246
5342
  async getProductBuilder(product) {
5247
5343
  if (!this.token)
5248
5344
  await this.initUserAuth();
@@ -5277,6 +5373,10 @@ class Ductape {
5277
5373
  await this.initUserAuth();
5278
5374
  return this.createNewAppBuilder();
5279
5375
  }
5376
+ /** @deprecated Use {@link Ductape.api} instead. */
5377
+ get actions() {
5378
+ return this.api;
5379
+ }
5280
5380
  async initUserAuth(subCheck = true) {
5281
5381
  var _a, _b;
5282
5382
  // Skip if already authenticated with valid credentials
@@ -5401,16 +5501,7 @@ class Ductape {
5401
5501
  await this.connectCacheRedis();
5402
5502
  // Return cached instance if available, otherwise create new
5403
5503
  if (!this._databaseService) {
5404
- this._databaseService = new database_1.DatabaseService({
5405
- workspace_id: this.workspace_id,
5406
- public_key: this.public_key,
5407
- user_id: this.user_id,
5408
- token: this.token,
5409
- env_type: this.environment,
5410
- private_key: this._privateKey,
5411
- access_key: this.accessKey,
5412
- redis_client: this.redisClient, // Pass Redis client for caching
5413
- });
5504
+ 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()));
5414
5505
  }
5415
5506
  return this._databaseService;
5416
5507
  }
@@ -5426,16 +5517,7 @@ class Ductape {
5426
5517
  // Connect to Redis for caching (if configured)
5427
5518
  await this.connectCacheRedis();
5428
5519
  if (!this._graphService) {
5429
- this._graphService = new graph_1.GraphService({
5430
- workspace_id: this.workspace_id,
5431
- public_key: this.public_key,
5432
- user_id: this.user_id,
5433
- token: this.token,
5434
- env_type: this.environment,
5435
- private_key: this._privateKey,
5436
- access_key: this.accessKey,
5437
- redis_client: this.redisClient, // Pass Redis client for caching
5438
- });
5520
+ 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()));
5439
5521
  }
5440
5522
  return this._graphService;
5441
5523
  }
@@ -5512,16 +5594,7 @@ class Ductape {
5512
5594
  // Connect to Redis for caching (if configured)
5513
5595
  await this.connectCacheRedis();
5514
5596
  if (!this._vectorService) {
5515
- this._vectorService = new vector_1.VectorDatabaseService({
5516
- workspace_id: this.workspace_id,
5517
- public_key: this.public_key,
5518
- user_id: this.user_id,
5519
- token: this.token,
5520
- env_type: this.environment,
5521
- private_key: this._privateKey,
5522
- access_key: this.accessKey,
5523
- redis_client: this.redisClient, // Pass Redis client for caching
5524
- });
5597
+ 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()));
5525
5598
  }
5526
5599
  return this._vectorService;
5527
5600
  }
@@ -5556,15 +5629,7 @@ class Ductape {
5556
5629
  const subCheck = false;
5557
5630
  await this.initUserAuth(subCheck);
5558
5631
  if (!this._cacheService) {
5559
- this._cacheService = new cache_1.CacheService({
5560
- workspace_id: this.workspace_id,
5561
- public_key: this.public_key,
5562
- user_id: this.user_id,
5563
- token: this.token,
5564
- env_type: this.environment,
5565
- access_key: this.accessKey,
5566
- workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
5567
- });
5632
+ 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()));
5568
5633
  }
5569
5634
  return this._cacheService;
5570
5635
  }
@@ -5629,6 +5694,26 @@ class Ductape {
5629
5694
  }
5630
5695
  return this._secretsService;
5631
5696
  }
5697
+ async createNewCloudService() {
5698
+ const subCheck = false;
5699
+ if (!this.token || !this.public_key) {
5700
+ await this.initUserAuth(subCheck);
5701
+ }
5702
+ if (!this._cloudService) {
5703
+ this._cloudService = new cloud_1.CloudService({
5704
+ environment: this.environment,
5705
+ getAuth: () => ({
5706
+ token: this.token,
5707
+ public_key: this.public_key,
5708
+ user_id: this.user_id,
5709
+ workspace_id: this.workspace_id,
5710
+ access_key: this.accessKey,
5711
+ }),
5712
+ getProductBuilder: (productTag) => this.getProductBuilder(productTag),
5713
+ });
5714
+ }
5715
+ return this._cloudService;
5716
+ }
5632
5717
  /**
5633
5718
  * Create a new SessionsService instance with authenticated config
5634
5719
  * @returns SessionsService instance
@@ -5637,16 +5722,7 @@ class Ductape {
5637
5722
  var _a;
5638
5723
  const subCheck = false;
5639
5724
  await this.initUserAuth(subCheck);
5640
- return new sessions_1.SessionsService({
5641
- workspace_id: this.workspace_id,
5642
- public_key: this.public_key,
5643
- user_id: this.user_id,
5644
- token: this.token,
5645
- env_type: this.environment,
5646
- access_key: this.accessKey,
5647
- redis_client: this.redisClient,
5648
- workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
5649
- });
5725
+ 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()));
5650
5726
  }
5651
5727
  /**
5652
5728
  * Create a new StorageService instance with authenticated config
@@ -5659,15 +5735,7 @@ class Ductape {
5659
5735
  await this.createNewSecretsService();
5660
5736
  // Connect to Redis for caching (if configured)
5661
5737
  await this.connectCacheRedis();
5662
- return new storage_1.StorageService({
5663
- workspace_id: this.workspace_id,
5664
- public_key: this.public_key,
5665
- user_id: this.user_id,
5666
- token: this.token,
5667
- env_type: this.environment,
5668
- private_key: this._privateKey,
5669
- redis_client: this.redisClient, // Pass Redis client for caching
5670
- });
5738
+ 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()));
5671
5739
  }
5672
5740
  /**
5673
5741
  * Get or create a BrokersService instance with authenticated config (cached)
@@ -5702,17 +5770,7 @@ class Ductape {
5702
5770
  const subCheck = false;
5703
5771
  await this.initUserAuth(subCheck);
5704
5772
  if (!this._quotaService) {
5705
- this._quotaService = new resilience_1.QuotaService({
5706
- workspace_id: this.workspace_id,
5707
- public_key: this.public_key,
5708
- user_id: this.user_id,
5709
- token: this.token,
5710
- env_type: this.environment,
5711
- redis_client: this.redisClient,
5712
- queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
5713
- private_key: this._privateKey,
5714
- access_key: this.accessKey,
5715
- });
5773
+ 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()));
5716
5774
  }
5717
5775
  return this._quotaService;
5718
5776
  }
@@ -5724,17 +5782,7 @@ class Ductape {
5724
5782
  const subCheck = false;
5725
5783
  await this.initUserAuth(subCheck);
5726
5784
  if (!this._fallbackService) {
5727
- this._fallbackService = new resilience_1.FallbackService({
5728
- workspace_id: this.workspace_id,
5729
- public_key: this.public_key,
5730
- user_id: this.user_id,
5731
- token: this.token,
5732
- env_type: this.environment,
5733
- redis_client: this.redisClient,
5734
- queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
5735
- private_key: this._privateKey,
5736
- access_key: this.accessKey,
5737
- });
5785
+ 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()));
5738
5786
  }
5739
5787
  return this._fallbackService;
5740
5788
  }
@@ -5749,17 +5797,7 @@ class Ductape {
5749
5797
  // (DatabaseService, StorageService, WorkflowService, etc.) can resolve $secret{...}
5750
5798
  await this.createNewSecretsService();
5751
5799
  if (!this._healthcheckService) {
5752
- this._healthcheckService = new resilience_1.HealthcheckService({
5753
- workspace_id: this.workspace_id,
5754
- public_key: this.public_key,
5755
- user_id: this.user_id,
5756
- token: this.token,
5757
- env_type: this.environment,
5758
- redis_client: this.redisClient,
5759
- queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
5760
- private_key: this._privateKey,
5761
- access_key: this.accessKey,
5762
- });
5800
+ 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()));
5763
5801
  }
5764
5802
  return this._healthcheckService;
5765
5803
  }