@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
@@ -58,6 +58,7 @@ const logs_service_1 = __importDefault(require("../logs/logs.service"));
58
58
  const logs_types_1 = require("../logs/logs.types");
59
59
  const processor_utils_1 = require("../processor/utils/processor.utils");
60
60
  const secrets_1 = require("../secrets");
61
+ const cloud_runtime_util_1 = require("../cloud/cloud-runtime.util");
61
62
  const sharedGraphRegistry = new Map();
62
63
  const sharedGraphConnectInFlight = new Map();
63
64
  function getSharedGraphKey(workspaceId, product, graph, env) {
@@ -93,6 +94,7 @@ class GraphService {
93
94
  this.cacheManager = null;
94
95
  /** Private keys cache for products (keyed by product tag) */
95
96
  this.privateKeys = new Map();
97
+ this.runtimeDefaults = {};
96
98
  // ==================== GRAPH ACTIONS ====================
97
99
  /** Local cache of graph actions */
98
100
  this.actions = new Map();
@@ -105,6 +107,12 @@ class GraphService {
105
107
  if (config) {
106
108
  this.config = config;
107
109
  this._privateKey = config.private_key || '';
110
+ if (config.default_product || config.default_env) {
111
+ this.runtimeDefaults = {
112
+ default_product: config.default_product,
113
+ default_env: config.default_env,
114
+ };
115
+ }
108
116
  // Initialize CacheManager (Redis is optional - Tier 1 internal cache and Tier 3 remote cache always work)
109
117
  this.cacheManager = new cache_manager_1.CacheManager({
110
118
  workspace_id: config.workspace_id,
@@ -123,6 +131,21 @@ class GraphService {
123
131
  updateConfig(config) {
124
132
  this.config = config;
125
133
  }
134
+ mergeGraphConnectionConfig(config) {
135
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
136
+ const product = ((_a = config.product) === null || _a === void 0 ? void 0 : _a.trim()) ||
137
+ ((_c = (_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.product) === null || _c === void 0 ? void 0 : _c.trim()) ||
138
+ ((_d = this.runtimeDefaults.default_product) === null || _d === void 0 ? void 0 : _d.trim()) ||
139
+ ((_f = (_e = this.config) === null || _e === void 0 ? void 0 : _e.default_product) === null || _f === void 0 ? void 0 : _f.trim());
140
+ const env = ((_g = config.env) === null || _g === void 0 ? void 0 : _g.trim()) ||
141
+ ((_j = (_h = this.currentContext) === null || _h === void 0 ? void 0 : _h.env) === null || _j === void 0 ? void 0 : _j.trim()) ||
142
+ ((_k = this.runtimeDefaults.default_env) === null || _k === void 0 ? void 0 : _k.trim()) ||
143
+ ((_m = (_l = this.config) === null || _l === void 0 ? void 0 : _l.default_env) === null || _m === void 0 ? void 0 : _m.trim());
144
+ if (!product || !env) {
145
+ throw new Error('product and env are required. Pass them in graph.connect() or set both on the Ductape constructor.');
146
+ }
147
+ return Object.assign(Object.assign({}, config), { product, env });
148
+ }
126
149
  /**
127
150
  * Get service configuration
128
151
  */
@@ -323,6 +346,10 @@ class GraphService {
323
346
  graphName: envConfig.graphName,
324
347
  username: envConfig.username,
325
348
  password: envConfig.password,
349
+ region: envConfig.region,
350
+ iamAuth: envConfig.iamAuth,
351
+ authMode: envConfig.authMode,
352
+ cloudConnectionId: envConfig.cloudConnectionId,
326
353
  });
327
354
  }
328
355
  }
@@ -563,8 +590,11 @@ class GraphService {
563
590
  database: env.database,
564
591
  graphName: env.graphName,
565
592
  region: env.region,
593
+ iamAuth: env.iamAuth,
566
594
  username: env.username,
567
595
  password: env.password,
596
+ authMode: env.authMode,
597
+ cloudConnectionId: env.cloudConnectionId,
568
598
  })),
569
599
  };
570
600
  }
@@ -584,6 +614,7 @@ class GraphService {
584
614
  */
585
615
  async connect(config) {
586
616
  var _a, _b, _c;
617
+ config = this.mergeGraphConnectionConfig(config);
587
618
  const process_id = (0, processor_utils_1.generateObjectId)();
588
619
  const start = Date.now();
589
620
  const contextKey = `${config.graph}:${config.env}`;
@@ -710,7 +741,7 @@ class GraphService {
710
741
  return entry;
711
742
  }
712
743
  async runGraphConnect(config, contextKey, adapter, context, process_id, start) {
713
- var _a, _b, _c, _d, _e;
744
+ var _a, _b, _c, _d, _e, _f, _g, _h;
714
745
  this.initializeLogService();
715
746
  const envValue = config.env || '';
716
747
  const baseLogs = {
@@ -732,24 +763,58 @@ class GraphService {
732
763
  this.logService.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph connect - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
733
764
  }
734
765
  try {
735
- const secretsService = (0, secrets_1.getSecretsService)();
736
- const resolveSecret = async (value, fieldName) => {
737
- if (!value)
738
- return undefined;
739
- const secretCheck = (0, secrets_1.isSecretReference)(value);
740
- if (secretCheck.isSecret) {
741
- if (secretsService) {
742
- const resolved = await secretsService.resolve(value, { env: config.env });
743
- return resolved.value;
766
+ let connectionUrl = context.connectionUrl;
767
+ let graphName = context.graphName;
768
+ let username = context.username;
769
+ let password = context.password;
770
+ if (this.config && (context.authMode === 'cloud_connection' || context.cloudConnectionId)) {
771
+ const resolvedEnv = await (0, cloud_runtime_util_1.resolveCloudLinkedEnvConfig)({
772
+ connection_url: context.connectionUrl,
773
+ graphName: context.graphName,
774
+ username: context.username,
775
+ password: context.password,
776
+ region: context.region,
777
+ iamAuth: context.iamAuth,
778
+ authMode: context.authMode,
779
+ cloudConnectionId: context.cloudConnectionId,
780
+ }, {
781
+ environment: this.config.env_type,
782
+ auth: {
783
+ token: this.config.token,
784
+ public_key: this.config.public_key,
785
+ user_id: this.config.user_id,
786
+ workspace_id: this.config.workspace_id,
787
+ access_key: this.config.access_key,
788
+ },
789
+ productTag: config.product || '',
790
+ componentTag: config.graph,
791
+ envSlug: config.env,
792
+ });
793
+ connectionUrl = String(resolvedEnv.connection_url || connectionUrl);
794
+ graphName = (_d = resolvedEnv.graphName) !== null && _d !== void 0 ? _d : graphName;
795
+ username = (_e = resolvedEnv.username) !== null && _e !== void 0 ? _e : username;
796
+ password = (_f = resolvedEnv.password) !== null && _f !== void 0 ? _f : password;
797
+ }
798
+ else {
799
+ const secretsService = (0, secrets_1.getSecretsService)();
800
+ const resolveSecret = async (value, fieldName) => {
801
+ if (!value)
802
+ return undefined;
803
+ const secretCheck = (0, secrets_1.isSecretReference)(value);
804
+ if (secretCheck.isSecret) {
805
+ if (secretsService) {
806
+ const resolved = await secretsService.resolve(value, { env: config.env });
807
+ return resolved.value;
808
+ }
809
+ throw graph_error_1.GraphError.configurationError(`${fieldName} contains secret reference but secrets service is not initialized.`);
744
810
  }
745
- throw graph_error_1.GraphError.configurationError(`${fieldName} contains secret reference but secrets service is not initialized.`);
746
- }
747
- return value;
748
- };
749
- const connectionUrl = await resolveSecret(context.connectionUrl, 'connectionUrl');
750
- const graphName = await resolveSecret(context.graphName, 'graphName');
751
- const username = await resolveSecret(context.username, 'username');
752
- const password = await resolveSecret(context.password, 'password');
811
+ return value;
812
+ };
813
+ connectionUrl = (await resolveSecret(context.connectionUrl, 'connectionUrl')) || connectionUrl;
814
+ graphName = await resolveSecret(context.graphName, 'graphName');
815
+ username = await resolveSecret(context.username, 'username');
816
+ password = await resolveSecret(context.password, 'password');
817
+ }
753
818
  if (!connectionUrl)
754
819
  throw graph_error_1.GraphError.configurationError('Connection URL is required');
755
820
  const result = await adapter.connect({
@@ -765,7 +830,7 @@ class GraphService {
765
830
  this.currentContext = context;
766
831
  this.transactionManager = new transaction_manager_1.GraphTransactionManager(adapter);
767
832
  const end = Date.now();
768
- const lastSuccess = (_d = lastGraphConnectLogAt.get(logKey)) !== null && _d !== void 0 ? _d : {};
833
+ const lastSuccess = (_g = lastGraphConnectLogAt.get(logKey)) !== null && _g !== void 0 ? _g : {};
769
834
  if (this.logService && (!lastSuccess.success || end - lastSuccess.success >= GRAPH_CONNECT_LOG_DEBOUNCE_MS)) {
770
835
  lastGraphConnectLogAt.set(logKey, Object.assign(Object.assign({}, lastSuccess), { success: end }));
771
836
  this.logService.add(Object.assign(Object.assign({}, baseLogs), { start, end, message: 'Graph connect - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
@@ -775,7 +840,7 @@ class GraphService {
775
840
  }
776
841
  catch (error) {
777
842
  const end = Date.now();
778
- const lastFail = (_e = lastGraphConnectLogAt.get(logKey)) !== null && _e !== void 0 ? _e : {};
843
+ const lastFail = (_h = lastGraphConnectLogAt.get(logKey)) !== null && _h !== void 0 ? _h : {};
779
844
  if (this.logService && (!lastFail.failed || end - lastFail.failed >= GRAPH_CONNECT_LOG_DEBOUNCE_MS)) {
780
845
  lastGraphConnectLogAt.set(logKey, Object.assign(Object.assign({}, lastFail), { failed: end }));
781
846
  this.logService.add(Object.assign(Object.assign({}, baseLogs), { start,
@@ -1786,6 +1851,31 @@ class GraphService {
1786
1851
  return adapter.listRelationshipTypes();
1787
1852
  });
1788
1853
  }
1854
+ /**
1855
+ * Get a normalized graph schema snapshot (labels, relationship types, indexes, constraints).
1856
+ * Useful for generating accurate executable payload templates and metadata UIs.
1857
+ */
1858
+ async getSchemaSnapshot() {
1859
+ const context = this.currentContext;
1860
+ if (!context) {
1861
+ throw graph_error_1.GraphError.configurationError('No active graph connection context. Call connect() before getSchemaSnapshot().');
1862
+ }
1863
+ const [labels, relationshipTypes, indexes, constraints] = await Promise.all([
1864
+ this.listLabels(),
1865
+ this.listRelationshipTypes(),
1866
+ this.listIndexes(),
1867
+ this.listConstraints(),
1868
+ ]);
1869
+ return {
1870
+ graph: context.graph,
1871
+ env: context.env,
1872
+ labels: labels.labels,
1873
+ relationshipTypes: relationshipTypes.types,
1874
+ indexes: indexes.indexes,
1875
+ constraints: constraints.constraints,
1876
+ generatedAt: new Date().toISOString(),
1877
+ };
1878
+ }
1789
1879
  /**
1790
1880
  * Generate a URL-safe tag from a name
1791
1881
  */