@ductape/sdk 0.1.110 → 0.1.113

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 (41) hide show
  1. package/dist/features/feature-executor.d.ts +9 -0
  2. package/dist/features/feature-executor.js +224 -70
  3. package/dist/features/feature-executor.js.map +1 -1
  4. package/dist/features/features.service.d.ts +5 -0
  5. package/dist/features/features.service.js +49 -7
  6. package/dist/features/features.service.js.map +1 -1
  7. package/dist/features/index.d.ts +2 -1
  8. package/dist/features/index.js +3 -1
  9. package/dist/features/index.js.map +1 -1
  10. package/dist/features/types/features.types.d.ts +9 -0
  11. package/dist/features/types/features.types.js.map +1 -1
  12. package/dist/functions/functions.runtime.d.ts +25 -0
  13. package/dist/functions/functions.runtime.js +254 -0
  14. package/dist/functions/functions.runtime.js.map +1 -0
  15. package/dist/functions/http-handler.d.ts +17 -0
  16. package/dist/functions/http-handler.js +51 -0
  17. package/dist/functions/http-handler.js.map +1 -0
  18. package/dist/functions/index.d.ts +3 -0
  19. package/dist/functions/index.js +20 -0
  20. package/dist/functions/index.js.map +1 -0
  21. package/dist/functions/types.d.ts +94 -0
  22. package/dist/functions/types.js +15 -0
  23. package/dist/functions/types.js.map +1 -0
  24. package/dist/graph/graphs.service.d.ts +1 -1
  25. package/dist/graph/graphs.service.js +73 -43
  26. package/dist/graph/graphs.service.js.map +1 -1
  27. package/dist/graph/types/traversal.interface.d.ts +2 -0
  28. package/dist/index.d.ts +16 -1
  29. package/dist/index.js +23 -3
  30. package/dist/index.js.map +1 -1
  31. package/dist/processor/services/processor.service.d.ts +6 -0
  32. package/dist/processor/services/processor.service.js +8 -13
  33. package/dist/processor/services/processor.service.js.map +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/types/productsBuilder.types.d.ts +3 -0
  36. package/dist/types/productsBuilder.types.js +2 -0
  37. package/dist/types/productsBuilder.types.js.map +1 -1
  38. package/dist/vector/vector-database.service.d.ts +2 -0
  39. package/dist/vector/vector-database.service.js +21 -12
  40. package/dist/vector/vector-database.service.js.map +1 -1
  41. package/package.json +1 -1
@@ -41,6 +41,17 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  return result;
42
42
  };
43
43
  })();
44
+ var __rest = (this && this.__rest) || function (s, e) {
45
+ var t = {};
46
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
47
+ t[p] = s[p];
48
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
49
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
50
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
51
+ t[p[i]] = s[p[i]];
52
+ }
53
+ return t;
54
+ };
44
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
45
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
46
57
  };
@@ -1524,39 +1535,49 @@ class GraphService {
1524
1535
  * As documented in traversals.md
1525
1536
  */
1526
1537
  async traverse(options, transaction) {
1527
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1528
- await this.ensureConnectionFor(options);
1538
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1539
+ const { session } = options, rawTraverseOptions = __rest(options, ["session"]);
1540
+ let resolvedOptions = rawTraverseOptions;
1541
+ let sessionLogFields = {};
1542
+ if (session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1543
+ const builder = await this.getProductBuilder(this.currentContext.product);
1544
+ const privateKey = builder.fetchPrivateKey();
1545
+ if (privateKey) {
1546
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1547
+ const sessionResult = await processSessionForExecution(session, privateKey, rawTraverseOptions, this.currentContext.env, {
1548
+ fetchSessionSelector: async (sessionTag) => {
1549
+ const sessionConfig = await builder.fetchSession(sessionTag);
1550
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1551
+ },
1552
+ });
1553
+ if (sessionResult.error)
1554
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1555
+ resolvedOptions = sessionResult.input;
1556
+ sessionLogFields = sessionResult.logFields;
1557
+ }
1558
+ }
1559
+ await this.ensureConnectionFor(resolvedOptions);
1529
1560
  const process_id = (0, processor_utils_1.generateObjectId)();
1530
1561
  const start = Date.now();
1531
1562
  this.initializeLogService();
1532
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
1533
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
1534
- const baseLogs = {
1535
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
1536
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
1537
- env: envValue,
1538
- app_env: envValue,
1539
- process_id,
1540
- type: logs_types_1.LogEventTypes.GRAPH,
1541
- parent_tag: graphValue,
1542
- child_tag: 'traverse',
1543
- data: { startNodeId: options.startNodeId, operation: 'traverse', graph: graphValue, env: envValue, direction: options.direction, maxDepth: options.maxDepth, relationshipTypes: options.relationshipTypes },
1544
- };
1545
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph traverse - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1563
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1564
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1565
+ const baseLogs = Object.assign(Object.assign({ product_tag: ((_d = this.currentContext) === null || _d === void 0 ? void 0 : _d.product) || '', workspace_id: ((_e = this.config) === null || _e === void 0 ? void 0 : _e.workspace_id) || '', env: envValue, app_env: envValue, process_id, type: logs_types_1.LogEventTypes.GRAPH, parent_tag: graphValue, child_tag: 'traverse' }, sessionLogFields), { data: { startNodeId: resolvedOptions.startNodeId, operation: 'traverse', graph: graphValue, env: envValue, direction: resolvedOptions.direction, maxDepth: resolvedOptions.maxDepth, relationshipTypes: resolvedOptions.relationshipTypes } });
1566
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph traverse - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1546
1567
  try {
1547
1568
  const adapter = this.getAdapter();
1548
- const result = await adapter.traverse(options, transaction);
1569
+ const result = await adapter.traverse(resolvedOptions, transaction);
1549
1570
  const end = Date.now();
1550
- (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
1571
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1551
1572
  end, message: 'Graph traverse - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1552
- (_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
1573
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1553
1574
  return result;
1554
1575
  }
1555
1576
  catch (error) {
1556
1577
  const end = Date.now();
1557
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
1578
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1558
1579
  end, message: 'Graph traverse - failed', failed_execution: true, data: { startNodeId: options.startNodeId, operation: 'traverse', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1559
- (_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish().catch(() => { });
1580
+ (_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish().catch(() => { });
1560
1581
  throw error;
1561
1582
  }
1562
1583
  }
@@ -1751,41 +1772,50 @@ class GraphService {
1751
1772
  * );
1752
1773
  * ```
1753
1774
  */
1754
- async query(queryString, params, transaction) {
1755
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1775
+ async query(queryString, params, transaction, session) {
1776
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1756
1777
  const process_id = (0, processor_utils_1.generateObjectId)();
1757
1778
  const start = Date.now();
1758
1779
  this.initializeLogService();
1759
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
1760
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
1761
- const baseLogs = {
1762
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
1763
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
1764
- env: envValue,
1765
- app_env: envValue,
1766
- process_id,
1767
- type: logs_types_1.LogEventTypes.GRAPH,
1768
- parent_tag: graphValue,
1769
- child_tag: 'query',
1770
- data: { operation: 'query', graph: graphValue, env: envValue, query: queryString.substring(0, 200) },
1771
- };
1772
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph query - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1780
+ let resolvedParams = params;
1781
+ let sessionLogFields = {};
1782
+ if (session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1783
+ const builder = await this.getProductBuilder(this.currentContext.product);
1784
+ const privateKey = builder.fetchPrivateKey();
1785
+ if (privateKey) {
1786
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1787
+ const sessionResult = await processSessionForExecution(session, privateKey, params !== null && params !== void 0 ? params : {}, this.currentContext.env, {
1788
+ fetchSessionSelector: async (sessionTag) => {
1789
+ const sessionConfig = await builder.fetchSession(sessionTag);
1790
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1791
+ },
1792
+ });
1793
+ if (sessionResult.error)
1794
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1795
+ resolvedParams = sessionResult.input;
1796
+ sessionLogFields = sessionResult.logFields;
1797
+ }
1798
+ }
1799
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1800
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1801
+ const baseLogs = Object.assign(Object.assign({ product_tag: ((_d = this.currentContext) === null || _d === void 0 ? void 0 : _d.product) || '', workspace_id: ((_e = this.config) === null || _e === void 0 ? void 0 : _e.workspace_id) || '', env: envValue, app_env: envValue, process_id, type: logs_types_1.LogEventTypes.GRAPH, parent_tag: graphValue, child_tag: 'query' }, sessionLogFields), { data: { operation: 'query', graph: graphValue, env: envValue, query: queryString.substring(0, 200) } });
1802
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph query - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1773
1803
  try {
1774
1804
  const result = await this.executeWithRetry(async () => {
1775
1805
  const adapter = this.getAdapter();
1776
- return adapter.query({ query: queryString, params }, transaction);
1806
+ return adapter.query({ query: queryString, params: resolvedParams }, transaction);
1777
1807
  });
1778
1808
  const end = Date.now();
1779
- (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
1780
- end, message: 'Graph query - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS, data: { operation: 'query', graph: graphValue, env: envValue, recordCount: ((_g = result.records) === null || _g === void 0 ? void 0 : _g.length) || 0 } }));
1781
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1809
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1810
+ end, message: 'Graph query - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS, data: { operation: 'query', graph: graphValue, env: envValue, recordCount: ((_h = result.records) === null || _h === void 0 ? void 0 : _h.length) || 0 } }));
1811
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish();
1782
1812
  return result;
1783
1813
  }
1784
1814
  catch (error) {
1785
1815
  const end = Date.now();
1786
- (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1816
+ (_k = this.logService) === null || _k === void 0 ? void 0 : _k.add(Object.assign(Object.assign({}, baseLogs), { start,
1787
1817
  end, message: 'Graph query - failed', failed_execution: true, data: { operation: 'query', graph: graphValue, env: envValue, error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1788
- (_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish().catch(() => { });
1818
+ (_l = this.logService) === null || _l === void 0 ? void 0 : _l.publish().catch(() => { });
1789
1819
  throw error;
1790
1820
  }
1791
1821
  }