@ductape/sdk 0.0.4-v103 → 0.0.4-v106

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 (203) hide show
  1. package/dist/agents/agents.service.js +6 -1
  2. package/dist/agents/agents.service.js.map +1 -1
  3. package/dist/api/services/logsApi.service.d.ts +51 -0
  4. package/dist/api/services/logsApi.service.js +14 -0
  5. package/dist/api/services/logsApi.service.js.map +1 -1
  6. package/dist/api/services/processorApi.service.d.ts +66 -0
  7. package/dist/api/services/processorApi.service.js +7 -0
  8. package/dist/api/services/processorApi.service.js.map +1 -1
  9. package/dist/api/urls.d.ts +1 -0
  10. package/dist/api/urls.js +3 -2
  11. package/dist/api/urls.js.map +1 -1
  12. package/dist/brokers/brokers.service.js +6 -1
  13. package/dist/brokers/brokers.service.js.map +1 -1
  14. package/dist/database/databases.service.d.ts +61 -0
  15. package/dist/database/databases.service.js +87 -6
  16. package/dist/database/databases.service.js.map +1 -1
  17. package/dist/database/types/dashboard.interface.d.ts +74 -0
  18. package/dist/database/types/dashboard.interface.js +7 -0
  19. package/dist/database/types/dashboard.interface.js.map +1 -0
  20. package/dist/database/types/index.d.ts +1 -0
  21. package/dist/graph/graphs.service.d.ts +49 -11
  22. package/dist/graph/graphs.service.js +645 -189
  23. package/dist/graph/graphs.service.js.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +2 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/logs/logs.types.d.ts +2 -2
  28. package/dist/notifications/notifications.service.js +28 -4
  29. package/dist/notifications/notifications.service.js.map +1 -1
  30. package/dist/processor/services/processor.service.js +24 -4
  31. package/dist/processor/services/processor.service.js.map +1 -1
  32. package/dist/sessions/sessions.helper.d.ts +23 -3
  33. package/dist/sessions/sessions.helper.js +20 -3
  34. package/dist/sessions/sessions.helper.js.map +1 -1
  35. package/dist/sessions/sessions.service.js +8 -0
  36. package/dist/sessions/sessions.service.js.map +1 -1
  37. package/dist/sessions/types/index.d.ts +33 -0
  38. package/dist/storage/storage.service.js +36 -6
  39. package/dist/storage/storage.service.js.map +1 -1
  40. package/dist/vector/vector-database.service.d.ts +2 -0
  41. package/dist/vector/vector-database.service.js +58 -14
  42. package/dist/vector/vector-database.service.js.map +1 -1
  43. package/dist/workflows/workflow-executor.d.ts +1 -1
  44. package/dist/workflows/workflow-executor.js.map +1 -1
  45. package/dist/workflows/workflows.service.js +12 -2
  46. package/dist/workflows/workflows.service.js.map +1 -1
  47. package/package.json +3 -1
  48. package/dist/processor/services/fallback.service.d.ts +0 -5
  49. package/dist/processor/services/fallback.service.js +0 -43
  50. package/dist/processor/services/fallback.service.js.map +0 -1
  51. package/dist/processor/services/messagebrokers/aws-sqs.service.d.ts +0 -15
  52. package/dist/processor/services/messagebrokers/aws-sqs.service.js +0 -77
  53. package/dist/processor/services/messagebrokers/aws-sqs.service.js.map +0 -1
  54. package/dist/processor/services/messagebrokers/google-pubsub.service.d.ts +0 -16
  55. package/dist/processor/services/messagebrokers/google-pubsub.service.js +0 -34
  56. package/dist/processor/services/messagebrokers/google-pubsub.service.js.map +0 -1
  57. package/dist/processor/services/messagebrokers/index.d.ts +0 -3
  58. package/dist/processor/services/messagebrokers/index.js +0 -26
  59. package/dist/processor/services/messagebrokers/index.js.map +0 -1
  60. package/dist/processor/services/messagebrokers/kafka.service.d.ts +0 -14
  61. package/dist/processor/services/messagebrokers/kafka.service.js +0 -45
  62. package/dist/processor/services/messagebrokers/kafka.service.js.map +0 -1
  63. package/dist/processor/services/messagebrokers/messagebrokers.type.d.ts +0 -6
  64. package/dist/processor/services/messagebrokers/messagebrokers.type.js +0 -3
  65. package/dist/processor/services/messagebrokers/messagebrokers.type.js.map +0 -1
  66. package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +0 -14
  67. package/dist/processor/services/messagebrokers/rabbitmq.service.js +0 -67
  68. package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +0 -1
  69. package/dist/processor/services/messagebrokers/redis.service.d.ts +0 -18
  70. package/dist/processor/services/messagebrokers/redis.service.js +0 -82
  71. package/dist/processor/services/messagebrokers/redis.service.js.map +0 -1
  72. package/dist/processor/services/quota.service.d.ts +0 -15
  73. package/dist/processor/services/quota.service.js +0 -63
  74. package/dist/processor/services/quota.service.js.map +0 -1
  75. package/dist/test/index.d.ts +0 -3
  76. package/dist/test/index.js +0 -11
  77. package/dist/test/index.js.map +0 -1
  78. package/dist/test/test.appBuilder.d.ts +0 -0
  79. package/dist/test/test.appBuilder.js +0 -1
  80. package/dist/test/test.appBuilder.js.map +0 -1
  81. package/dist/test/test.broker.kafka.d.ts +0 -1
  82. package/dist/test/test.broker.kafka.js +0 -172
  83. package/dist/test/test.broker.kafka.js.map +0 -1
  84. package/dist/test/test.broker.nats.d.ts +0 -1
  85. package/dist/test/test.broker.nats.js +0 -193
  86. package/dist/test/test.broker.nats.js.map +0 -1
  87. package/dist/test/test.broker.pubsub.d.ts +0 -1
  88. package/dist/test/test.broker.pubsub.js +0 -171
  89. package/dist/test/test.broker.pubsub.js.map +0 -1
  90. package/dist/test/test.broker.rabbitmq.d.ts +0 -1
  91. package/dist/test/test.broker.rabbitmq.js +0 -164
  92. package/dist/test/test.broker.rabbitmq.js.map +0 -1
  93. package/dist/test/test.broker.redis.d.ts +0 -1
  94. package/dist/test/test.broker.redis.js +0 -168
  95. package/dist/test/test.broker.redis.js.map +0 -1
  96. package/dist/test/test.broker.sqs.d.ts +0 -1
  97. package/dist/test/test.broker.sqs.js +0 -158
  98. package/dist/test/test.broker.sqs.js.map +0 -1
  99. package/dist/test/test.caches.d.ts +0 -1
  100. package/dist/test/test.caches.js +0 -231
  101. package/dist/test/test.caches.js.map +0 -1
  102. package/dist/test/test.database.d.ts +0 -1
  103. package/dist/test/test.database.dynamo.d.ts +0 -1
  104. package/dist/test/test.database.dynamo.js +0 -265
  105. package/dist/test/test.database.dynamo.js.map +0 -1
  106. package/dist/test/test.database.js +0 -140
  107. package/dist/test/test.database.js.map +0 -1
  108. package/dist/test/test.database.mongo.d.ts +0 -1
  109. package/dist/test/test.database.mongo.js +0 -371
  110. package/dist/test/test.database.mongo.js.map +0 -1
  111. package/dist/test/test.database.mysql.d.ts +0 -1
  112. package/dist/test/test.database.mysql.js +0 -415
  113. package/dist/test/test.database.mysql.js.map +0 -1
  114. package/dist/test/test.database.postgres.d.ts +0 -1
  115. package/dist/test/test.database.postgres.js +0 -412
  116. package/dist/test/test.database.postgres.js.map +0 -1
  117. package/dist/test/test.email.brevo.d.ts +0 -1
  118. package/dist/test/test.email.brevo.js +0 -326
  119. package/dist/test/test.email.brevo.js.map +0 -1
  120. package/dist/test/test.email.mailgun.d.ts +0 -1
  121. package/dist/test/test.email.mailgun.js +0 -352
  122. package/dist/test/test.email.mailgun.js.map +0 -1
  123. package/dist/test/test.email.postmark.d.ts +0 -1
  124. package/dist/test/test.email.postmark.js +0 -316
  125. package/dist/test/test.email.postmark.js.map +0 -1
  126. package/dist/test/test.email.sendgrid.d.ts +0 -1
  127. package/dist/test/test.email.sendgrid.js +0 -365
  128. package/dist/test/test.email.sendgrid.js.map +0 -1
  129. package/dist/test/test.email.smtp.d.ts +0 -1
  130. package/dist/test/test.email.smtp.js +0 -323
  131. package/dist/test/test.email.smtp.js.map +0 -1
  132. package/dist/test/test.graph.arangodb.d.ts +0 -1
  133. package/dist/test/test.graph.arangodb.js +0 -358
  134. package/dist/test/test.graph.arangodb.js.map +0 -1
  135. package/dist/test/test.graph.memgraph.d.ts +0 -1
  136. package/dist/test/test.graph.memgraph.js +0 -320
  137. package/dist/test/test.graph.memgraph.js.map +0 -1
  138. package/dist/test/test.graph.neo4j.d.ts +0 -1
  139. package/dist/test/test.graph.neo4j.js +0 -218
  140. package/dist/test/test.graph.neo4j.js.map +0 -1
  141. package/dist/test/test.graph.neptune.d.ts +0 -1
  142. package/dist/test/test.graph.neptune.js +0 -331
  143. package/dist/test/test.graph.neptune.js.map +0 -1
  144. package/dist/test/test.health.d.ts +0 -0
  145. package/dist/test/test.health.js +0 -1
  146. package/dist/test/test.health.js.map +0 -1
  147. package/dist/test/test.import.d.ts +0 -0
  148. package/dist/test/test.import.js +0 -1
  149. package/dist/test/test.import.js.map +0 -1
  150. package/dist/test/test.import.openapi.d.ts +0 -0
  151. package/dist/test/test.import.openapi.js +0 -1
  152. package/dist/test/test.import.openapi.js.map +0 -1
  153. package/dist/test/test.imports.d.ts +0 -1
  154. package/dist/test/test.imports.js +0 -21
  155. package/dist/test/test.imports.js.map +0 -1
  156. package/dist/test/test.logs.d.ts +0 -0
  157. package/dist/test/test.logs.js +0 -1
  158. package/dist/test/test.logs.js.map +0 -1
  159. package/dist/test/test.notifications.d.ts +0 -1
  160. package/dist/test/test.notifications.js +0 -198
  161. package/dist/test/test.notifications.js.map +0 -1
  162. package/dist/test/test.notifiers.d.ts +0 -0
  163. package/dist/test/test.notifiers.js +0 -1
  164. package/dist/test/test.notifiers.js.map +0 -1
  165. package/dist/test/test.processor.d.ts +0 -0
  166. package/dist/test/test.processor.js +0 -1
  167. package/dist/test/test.processor.js.map +0 -1
  168. package/dist/test/test.productBuilder.d.ts +0 -0
  169. package/dist/test/test.productBuilder.js +0 -1
  170. package/dist/test/test.productBuilder.js.map +0 -1
  171. package/dist/test/test.products.d.ts +0 -0
  172. package/dist/test/test.products.js +0 -1
  173. package/dist/test/test.products.js.map +0 -1
  174. package/dist/test/test.push.expo.d.ts +0 -1
  175. package/dist/test/test.push.expo.js +0 -442
  176. package/dist/test/test.push.expo.js.map +0 -1
  177. package/dist/test/test.push.firebase.d.ts +0 -1
  178. package/dist/test/test.push.firebase.js +0 -409
  179. package/dist/test/test.push.firebase.js.map +0 -1
  180. package/dist/test/test.session.d.ts +0 -1
  181. package/dist/test/test.session.js +0 -299
  182. package/dist/test/test.session.js.map +0 -1
  183. package/dist/test/test.sms.nexmo.d.ts +0 -1
  184. package/dist/test/test.sms.nexmo.js +0 -278
  185. package/dist/test/test.sms.nexmo.js.map +0 -1
  186. package/dist/test/test.sms.twilio.d.ts +0 -1
  187. package/dist/test/test.sms.twilio.js +0 -275
  188. package/dist/test/test.sms.twilio.js.map +0 -1
  189. package/dist/test/test.storage.d.ts +0 -1
  190. package/dist/test/test.storage.js +0 -202
  191. package/dist/test/test.storage.js.map +0 -1
  192. package/dist/test/test.triggers.d.ts +0 -1
  193. package/dist/test/test.triggers.js +0 -314
  194. package/dist/test/test.triggers.js.map +0 -1
  195. package/dist/test/test.vector.pinecone.d.ts +0 -1
  196. package/dist/test/test.vector.pinecone.js +0 -238
  197. package/dist/test/test.vector.pinecone.js.map +0 -1
  198. package/dist/test/test.vector.qdrant.d.ts +0 -1
  199. package/dist/test/test.vector.qdrant.js +0 -307
  200. package/dist/test/test.vector.qdrant.js.map +0 -1
  201. package/dist/test/test.vector.weaviate.d.ts +0 -1
  202. package/dist/test/test.vector.weaviate.js +0 -325
  203. package/dist/test/test.vector.weaviate.js.map +0 -1
@@ -88,6 +88,11 @@ class GraphService {
88
88
  // ==================== GRAPH ACTIONS ====================
89
89
  /** Local cache of graph actions */
90
90
  this.actions = new Map();
91
+ // ==================== UTILITY METHODS ====================
92
+ /** Maximum retry attempts for auto-reconnection */
93
+ this.maxReconnectRetries = 2;
94
+ /** Flag to track if reconnection is in progress */
95
+ this.reconnecting = false;
91
96
  this.adapterFactory = new adapter_factory_1.GraphAdapterFactory();
92
97
  if (config) {
93
98
  this.config = config;
@@ -732,38 +737,50 @@ class GraphService {
732
737
  * As documented in nodes.md
733
738
  */
734
739
  async createNode(options, transaction) {
735
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
740
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
736
741
  const process_id = (0, processor_utils_1.generateObjectId)();
737
742
  const start = Date.now();
743
+ // Session log fields (will be populated if session is provided)
744
+ let sessionLogFields = {};
745
+ let resolvedOptions = options;
746
+ // Process session if provided
747
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
748
+ const builder = await this.getProductBuilder(this.currentContext.product);
749
+ const privateKey = builder.fetchPrivateKey();
750
+ if (privateKey) {
751
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
752
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
753
+ fetchSessionSelector: async (sessionTag) => {
754
+ const sessionConfig = await builder.fetchSession(sessionTag);
755
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
756
+ },
757
+ });
758
+ if (sessionResult.error) {
759
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
760
+ }
761
+ resolvedOptions = sessionResult.input;
762
+ sessionLogFields = sessionResult.logFields;
763
+ }
764
+ }
738
765
  this.initializeLogService();
739
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
740
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
741
- const baseLogs = {
742
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
743
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
744
- env: envValue,
745
- app_env: envValue,
746
- process_id,
747
- type: logs_types_1.LogEventTypes.GRAPH,
748
- parent_tag: graphValue,
749
- child_tag: 'createNode',
750
- data: { labels: options.labels, operation: 'createNode', graph: graphValue, env: envValue, properties: options.properties },
751
- };
752
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph createNode - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
766
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
767
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
768
+ const baseLogs = 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: 'createNode', data: { labels: resolvedOptions.labels, operation: 'createNode', graph: graphValue, env: envValue, properties: resolvedOptions.properties } }, sessionLogFields);
769
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph createNode - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
753
770
  try {
754
771
  const adapter = this.getAdapter();
755
- const result = await adapter.createNode(options, transaction);
772
+ const result = await adapter.createNode(resolvedOptions, transaction);
756
773
  const end = Date.now();
757
- (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
774
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
758
775
  end, message: 'Graph createNode - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
759
- (_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
776
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
760
777
  return result;
761
778
  }
762
779
  catch (error) {
763
780
  const end = Date.now();
764
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
765
- end, message: 'Graph createNode - failed', failed_execution: true, data: { labels: options.labels, operation: 'createNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
766
- await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
781
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
782
+ end, message: 'Graph createNode - failed', failed_execution: true, data: { labels: resolvedOptions.labels, operation: 'createNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
783
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
767
784
  throw error;
768
785
  }
769
786
  }
@@ -772,85 +789,97 @@ class GraphService {
772
789
  * As documented in nodes.md
773
790
  */
774
791
  async findNodes(options, transaction) {
775
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
792
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
776
793
  const process_id = (0, processor_utils_1.generateObjectId)();
777
794
  const start = Date.now();
795
+ // Session log fields (will be populated if session is provided)
796
+ let sessionLogFields = {};
797
+ let resolvedOptions = options;
798
+ // Process session if provided
799
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
800
+ const builder = await this.getProductBuilder(this.currentContext.product);
801
+ const privateKey = builder.fetchPrivateKey();
802
+ if (privateKey) {
803
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
804
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
805
+ fetchSessionSelector: async (sessionTag) => {
806
+ const sessionConfig = await builder.fetchSession(sessionTag);
807
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
808
+ },
809
+ });
810
+ if (sessionResult.error) {
811
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
812
+ }
813
+ resolvedOptions = sessionResult.input;
814
+ sessionLogFields = sessionResult.logFields;
815
+ }
816
+ }
778
817
  this.initializeLogService();
779
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
780
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
781
- const baseLogs = {
782
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
783
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
784
- env: envValue,
785
- app_env: envValue,
786
- process_id,
787
- type: logs_types_1.LogEventTypes.GRAPH,
788
- parent_tag: graphValue,
789
- child_tag: 'findNodes',
790
- data: { labels: options.labels, operation: 'findNodes', graph: graphValue, env: envValue, where: options.where, select: options.select, orderBy: options.orderBy, limit: options.limit, offset: options.offset },
791
- };
792
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph findNodes - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
818
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
819
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
820
+ const baseLogs = 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: 'findNodes', data: { labels: resolvedOptions.labels, operation: 'findNodes', graph: graphValue, env: envValue, where: resolvedOptions.where, select: resolvedOptions.select, orderBy: resolvedOptions.orderBy, limit: resolvedOptions.limit, offset: resolvedOptions.offset } }, sessionLogFields);
821
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph findNodes - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
793
822
  try {
794
823
  // Check cache if cache tag is provided
795
- const productTag = (_f = this.currentContext) === null || _f === void 0 ? void 0 : _f.product;
824
+ const productTag = (_g = this.currentContext) === null || _g === void 0 ? void 0 : _g.product;
796
825
  const privateKey = productTag ? this.privateKeys.get(productTag) : undefined;
797
- if (options.cache && this.cacheManager && privateKey) {
826
+ if (resolvedOptions.cache && this.cacheManager && privateKey) {
798
827
  const cacheOptions = {
799
- cache_tag: options.cache,
828
+ cache_tag: resolvedOptions.cache,
800
829
  product_tag: productTag || '',
801
- component_tag: ((_g = this.currentContext) === null || _g === void 0 ? void 0 : _g.graph) || '',
830
+ component_tag: ((_h = this.currentContext) === null || _h === void 0 ? void 0 : _h.graph) || '',
802
831
  component_type: 'graph',
803
832
  input: {
804
- labels: options.labels,
805
- where: options.where,
806
- select: options.select,
807
- orderBy: options.orderBy,
808
- limit: options.limit,
809
- offset: options.offset,
833
+ labels: resolvedOptions.labels,
834
+ where: resolvedOptions.where,
835
+ select: resolvedOptions.select,
836
+ orderBy: resolvedOptions.orderBy,
837
+ limit: resolvedOptions.limit,
838
+ offset: resolvedOptions.offset,
810
839
  },
811
840
  privateKey,
812
841
  };
813
842
  const cached = await this.cacheManager.fetch(cacheOptions);
814
843
  if (cached.hit && cached.data) {
815
844
  const end = Date.now();
816
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
845
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
817
846
  end, message: `Graph findNodes - cache hit (${cached.source})`, successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
818
- (_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish();
847
+ (_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish();
819
848
  return cached.data;
820
849
  }
821
850
  }
822
851
  const adapter = this.getAdapter();
823
- const result = await adapter.findNodes(options, transaction);
852
+ const result = await adapter.findNodes(resolvedOptions, transaction);
824
853
  // Store in cache if cache tag is provided
825
- if (options.cache && this.cacheManager && privateKey) {
854
+ if (resolvedOptions.cache && this.cacheManager && privateKey) {
826
855
  const cacheOptions = {
827
- cache_tag: options.cache,
856
+ cache_tag: resolvedOptions.cache,
828
857
  product_tag: productTag || '',
829
- component_tag: ((_k = this.currentContext) === null || _k === void 0 ? void 0 : _k.graph) || '',
858
+ component_tag: ((_l = this.currentContext) === null || _l === void 0 ? void 0 : _l.graph) || '',
830
859
  component_type: 'graph',
831
860
  input: {
832
- labels: options.labels,
833
- where: options.where,
834
- select: options.select,
835
- orderBy: options.orderBy,
836
- limit: options.limit,
837
- offset: options.offset,
861
+ labels: resolvedOptions.labels,
862
+ where: resolvedOptions.where,
863
+ select: resolvedOptions.select,
864
+ orderBy: resolvedOptions.orderBy,
865
+ limit: resolvedOptions.limit,
866
+ offset: resolvedOptions.offset,
838
867
  },
839
868
  privateKey,
840
869
  };
841
870
  await this.cacheManager.store(cacheOptions, result);
842
871
  }
843
872
  const end = Date.now();
844
- (_l = this.logService) === null || _l === void 0 ? void 0 : _l.add(Object.assign(Object.assign({}, baseLogs), { start,
873
+ (_m = this.logService) === null || _m === void 0 ? void 0 : _m.add(Object.assign(Object.assign({}, baseLogs), { start,
845
874
  end, message: 'Graph findNodes - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
846
- (_m = this.logService) === null || _m === void 0 ? void 0 : _m.publish();
875
+ (_o = this.logService) === null || _o === void 0 ? void 0 : _o.publish();
847
876
  return result;
848
877
  }
849
878
  catch (error) {
850
879
  const end = Date.now();
851
- (_o = this.logService) === null || _o === void 0 ? void 0 : _o.add(Object.assign(Object.assign({}, baseLogs), { start,
852
- end, message: 'Graph findNodes - failed', failed_execution: true, data: { labels: options.labels, operation: 'findNodes', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
853
- await ((_p = this.logService) === null || _p === void 0 ? void 0 : _p.publish());
880
+ (_p = this.logService) === null || _p === void 0 ? void 0 : _p.add(Object.assign(Object.assign({}, baseLogs), { start,
881
+ end, message: 'Graph findNodes - failed', failed_execution: true, data: { labels: resolvedOptions.labels, operation: 'findNodes', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
882
+ await ((_q = this.logService) === null || _q === void 0 ? void 0 : _q.publish());
854
883
  throw error;
855
884
  }
856
885
  }
@@ -859,46 +888,60 @@ class GraphService {
859
888
  * As documented in nodes.md
860
889
  */
861
890
  async findNodeById(id, transaction) {
862
- const adapter = this.getAdapter();
863
- return adapter.findNodeById(id, transaction);
891
+ return this.executeWithRetry(async () => {
892
+ const adapter = this.getAdapter();
893
+ return adapter.findNodeById(id, transaction);
894
+ });
864
895
  }
865
896
  /**
866
897
  * Update a node
867
898
  * As documented in nodes.md
868
899
  */
869
900
  async updateNode(options, transaction) {
870
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
901
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
871
902
  const process_id = (0, processor_utils_1.generateObjectId)();
872
903
  const start = Date.now();
904
+ // Session log fields (will be populated if session is provided)
905
+ let sessionLogFields = {};
906
+ let resolvedOptions = options;
907
+ // Process session if provided
908
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
909
+ const builder = await this.getProductBuilder(this.currentContext.product);
910
+ const privateKey = builder.fetchPrivateKey();
911
+ if (privateKey) {
912
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
913
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
914
+ fetchSessionSelector: async (sessionTag) => {
915
+ const sessionConfig = await builder.fetchSession(sessionTag);
916
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
917
+ },
918
+ });
919
+ if (sessionResult.error) {
920
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
921
+ }
922
+ resolvedOptions = sessionResult.input;
923
+ sessionLogFields = sessionResult.logFields;
924
+ }
925
+ }
873
926
  this.initializeLogService();
874
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
875
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
876
- const baseLogs = {
877
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
878
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
879
- env: envValue,
880
- app_env: envValue,
881
- process_id,
882
- type: logs_types_1.LogEventTypes.GRAPH,
883
- parent_tag: graphValue,
884
- child_tag: 'updateNode',
885
- data: { id: options.id, operation: 'updateNode', graph: graphValue, env: envValue, properties: options.properties, labels: options.labels },
886
- };
887
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph updateNode - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
927
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
928
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
929
+ const baseLogs = 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: 'updateNode', data: { id: resolvedOptions.id, operation: 'updateNode', graph: graphValue, env: envValue, properties: resolvedOptions.properties, labels: resolvedOptions.labels } }, sessionLogFields);
930
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph updateNode - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
888
931
  try {
889
932
  const adapter = this.getAdapter();
890
- const result = await adapter.updateNode(options, transaction);
933
+ const result = await adapter.updateNode(resolvedOptions, transaction);
891
934
  const end = Date.now();
892
- (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
935
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
893
936
  end, message: 'Graph updateNode - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
894
- (_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
937
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
895
938
  return result;
896
939
  }
897
940
  catch (error) {
898
941
  const end = Date.now();
899
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
900
- end, message: 'Graph updateNode - failed', failed_execution: true, data: { id: options.id, operation: 'updateNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
901
- await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
942
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
943
+ end, message: 'Graph updateNode - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'updateNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
944
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
902
945
  throw error;
903
946
  }
904
947
  }
@@ -907,38 +950,50 @@ class GraphService {
907
950
  * As documented in nodes.md
908
951
  */
909
952
  async deleteNode(options, transaction) {
910
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
953
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
911
954
  const process_id = (0, processor_utils_1.generateObjectId)();
912
955
  const start = Date.now();
956
+ // Session log fields (will be populated if session is provided)
957
+ let sessionLogFields = {};
958
+ let resolvedOptions = options;
959
+ // Process session if provided
960
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
961
+ const builder = await this.getProductBuilder(this.currentContext.product);
962
+ const privateKey = builder.fetchPrivateKey();
963
+ if (privateKey) {
964
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
965
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
966
+ fetchSessionSelector: async (sessionTag) => {
967
+ const sessionConfig = await builder.fetchSession(sessionTag);
968
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
969
+ },
970
+ });
971
+ if (sessionResult.error) {
972
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
973
+ }
974
+ resolvedOptions = sessionResult.input;
975
+ sessionLogFields = sessionResult.logFields;
976
+ }
977
+ }
913
978
  this.initializeLogService();
914
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
915
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
916
- const baseLogs = {
917
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
918
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
919
- env: envValue,
920
- app_env: envValue,
921
- process_id,
922
- type: logs_types_1.LogEventTypes.GRAPH,
923
- parent_tag: graphValue,
924
- child_tag: 'deleteNode',
925
- data: { id: options.id, operation: 'deleteNode', graph: graphValue, env: envValue, detach: options.detach },
926
- };
927
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph deleteNode - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
979
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
980
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
981
+ const baseLogs = 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: 'deleteNode', data: { id: resolvedOptions.id, operation: 'deleteNode', graph: graphValue, env: envValue, detach: resolvedOptions.detach } }, sessionLogFields);
982
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph deleteNode - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
928
983
  try {
929
984
  const adapter = this.getAdapter();
930
- const result = await adapter.deleteNode(options, transaction);
985
+ const result = await adapter.deleteNode(resolvedOptions, transaction);
931
986
  const end = Date.now();
932
- (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
987
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
933
988
  end, message: 'Graph deleteNode - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
934
- (_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
989
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
935
990
  return result;
936
991
  }
937
992
  catch (error) {
938
993
  const end = Date.now();
939
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
940
- end, message: 'Graph deleteNode - failed', failed_execution: true, data: { id: options.id, operation: 'deleteNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
941
- await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
994
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
995
+ end, message: 'Graph deleteNode - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'deleteNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
996
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
942
997
  throw error;
943
998
  }
944
999
  }
@@ -947,8 +1002,10 @@ class GraphService {
947
1002
  * As documented in nodes.md
948
1003
  */
949
1004
  async mergeNode(options, transaction) {
950
- const adapter = this.getAdapter();
951
- return adapter.mergeNode(options, transaction);
1005
+ return this.executeWithRetry(async () => {
1006
+ const adapter = this.getAdapter();
1007
+ return adapter.mergeNode(options, transaction);
1008
+ });
952
1009
  }
953
1010
  // ==================== LABEL MANAGEMENT ====================
954
1011
  /**
@@ -964,8 +1021,10 @@ class GraphService {
964
1021
  * ```
965
1022
  */
966
1023
  async addLabels(options, transaction) {
967
- const adapter = this.getAdapter();
968
- return adapter.addLabels(options, transaction);
1024
+ return this.executeWithRetry(async () => {
1025
+ const adapter = this.getAdapter();
1026
+ return adapter.addLabels(options, transaction);
1027
+ });
969
1028
  }
970
1029
  /**
971
1030
  * Remove labels from an existing node
@@ -980,8 +1039,10 @@ class GraphService {
980
1039
  * ```
981
1040
  */
982
1041
  async removeLabels(options, transaction) {
983
- const adapter = this.getAdapter();
984
- return adapter.removeLabels(options, transaction);
1042
+ return this.executeWithRetry(async () => {
1043
+ const adapter = this.getAdapter();
1044
+ return adapter.removeLabels(options, transaction);
1045
+ });
985
1046
  }
986
1047
  /**
987
1048
  * Set labels on a node (replaces all existing labels)
@@ -997,8 +1058,10 @@ class GraphService {
997
1058
  * ```
998
1059
  */
999
1060
  async setLabels(options, transaction) {
1000
- const adapter = this.getAdapter();
1001
- return adapter.setLabels(options, transaction);
1061
+ return this.executeWithRetry(async () => {
1062
+ const adapter = this.getAdapter();
1063
+ return adapter.setLabels(options, transaction);
1064
+ });
1002
1065
  }
1003
1066
  // ==================== RELATIONSHIP OPERATIONS ====================
1004
1067
  /**
@@ -1006,38 +1069,50 @@ class GraphService {
1006
1069
  * As documented in relationships.md
1007
1070
  */
1008
1071
  async createRelationship(options, transaction) {
1009
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1072
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1010
1073
  const process_id = (0, processor_utils_1.generateObjectId)();
1011
1074
  const start = Date.now();
1012
1075
  this.initializeLogService();
1013
- const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
1014
- const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
1015
- const baseLogs = {
1016
- product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
1017
- workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
1018
- env: envValue,
1019
- app_env: envValue,
1020
- process_id,
1021
- type: logs_types_1.LogEventTypes.GRAPH,
1022
- parent_tag: graphValue,
1023
- child_tag: 'createRelationship',
1024
- data: { type: options.type, operation: 'createRelationship', graph: graphValue, env: envValue, startNodeId: options.startNodeId, endNodeId: options.endNodeId, properties: options.properties },
1025
- };
1026
- (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph createRelationship - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1076
+ // Session log fields (will be populated if session is provided)
1077
+ let sessionLogFields = {};
1078
+ let resolvedOptions = options;
1079
+ // Process session if provided
1080
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1081
+ const builder = await this.getProductBuilder(this.currentContext.product);
1082
+ const privateKey = builder.fetchPrivateKey();
1083
+ if (privateKey) {
1084
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1085
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1086
+ fetchSessionSelector: async (sessionTag) => {
1087
+ const sessionConfig = await builder.fetchSession(sessionTag);
1088
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1089
+ },
1090
+ });
1091
+ if (sessionResult.error) {
1092
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1093
+ }
1094
+ resolvedOptions = sessionResult.input;
1095
+ sessionLogFields = sessionResult.logFields;
1096
+ }
1097
+ }
1098
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1099
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1100
+ const baseLogs = 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: 'createRelationship', data: { type: resolvedOptions.type, operation: 'createRelationship', graph: graphValue, env: envValue, startNodeId: resolvedOptions.startNodeId, endNodeId: resolvedOptions.endNodeId, properties: resolvedOptions.properties } }, sessionLogFields);
1101
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph createRelationship - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1027
1102
  try {
1028
1103
  const adapter = this.getAdapter();
1029
- const result = await adapter.createRelationship(options, transaction);
1104
+ const result = await adapter.createRelationship(resolvedOptions, transaction);
1030
1105
  const end = Date.now();
1031
- (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
1106
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1032
1107
  end, message: 'Graph createRelationship - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1033
- (_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
1108
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1034
1109
  return result;
1035
1110
  }
1036
1111
  catch (error) {
1037
1112
  const end = Date.now();
1038
- (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
1039
- end, message: 'Graph createRelationship - failed', failed_execution: true, data: { type: options.type, operation: 'createRelationship', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1040
- await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
1113
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1114
+ end, message: 'Graph createRelationship - failed', failed_execution: true, data: { type: resolvedOptions.type, operation: 'createRelationship', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1115
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1041
1116
  throw error;
1042
1117
  }
1043
1118
  }
@@ -1046,39 +1121,175 @@ class GraphService {
1046
1121
  * As documented in relationships.md
1047
1122
  */
1048
1123
  async findRelationships(options, transaction) {
1049
- const adapter = this.getAdapter();
1050
- return adapter.findRelationships(options, transaction);
1124
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1125
+ const process_id = (0, processor_utils_1.generateObjectId)();
1126
+ const start = Date.now();
1127
+ this.initializeLogService();
1128
+ // Session log fields (will be populated if session is provided)
1129
+ let sessionLogFields = {};
1130
+ let resolvedOptions = options;
1131
+ // Process session if provided
1132
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1133
+ const builder = await this.getProductBuilder(this.currentContext.product);
1134
+ const privateKey = builder.fetchPrivateKey();
1135
+ if (privateKey) {
1136
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1137
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1138
+ fetchSessionSelector: async (sessionTag) => {
1139
+ const sessionConfig = await builder.fetchSession(sessionTag);
1140
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1141
+ },
1142
+ });
1143
+ if (sessionResult.error) {
1144
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1145
+ }
1146
+ resolvedOptions = sessionResult.input;
1147
+ sessionLogFields = sessionResult.logFields;
1148
+ }
1149
+ }
1150
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1151
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1152
+ const baseLogs = 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: 'findRelationships', data: { type: resolvedOptions.type, operation: 'findRelationships', graph: graphValue, env: envValue } }, sessionLogFields);
1153
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph findRelationships - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1154
+ try {
1155
+ const adapter = this.getAdapter();
1156
+ const result = await adapter.findRelationships(resolvedOptions, transaction);
1157
+ const end = Date.now();
1158
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1159
+ end, message: 'Graph findRelationships - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1160
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1161
+ return result;
1162
+ }
1163
+ catch (error) {
1164
+ const end = Date.now();
1165
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1166
+ end, message: 'Graph findRelationships - failed', failed_execution: true, data: { type: resolvedOptions.type, operation: 'findRelationships', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1167
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1168
+ throw error;
1169
+ }
1051
1170
  }
1052
1171
  /**
1053
1172
  * Find a relationship by ID
1054
1173
  */
1055
1174
  async findRelationshipById(id, transaction) {
1056
- const adapter = this.getAdapter();
1057
- return adapter.findRelationshipById(id, transaction);
1175
+ return this.executeWithRetry(async () => {
1176
+ const adapter = this.getAdapter();
1177
+ return adapter.findRelationshipById(id, transaction);
1178
+ });
1058
1179
  }
1059
1180
  /**
1060
1181
  * Update a relationship
1061
1182
  * As documented in relationships.md
1062
1183
  */
1063
1184
  async updateRelationship(options, transaction) {
1064
- const adapter = this.getAdapter();
1065
- return adapter.updateRelationship(options, transaction);
1185
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1186
+ const process_id = (0, processor_utils_1.generateObjectId)();
1187
+ const start = Date.now();
1188
+ this.initializeLogService();
1189
+ // Session log fields (will be populated if session is provided)
1190
+ let sessionLogFields = {};
1191
+ let resolvedOptions = options;
1192
+ // Process session if provided
1193
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1194
+ const builder = await this.getProductBuilder(this.currentContext.product);
1195
+ const privateKey = builder.fetchPrivateKey();
1196
+ if (privateKey) {
1197
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1198
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1199
+ fetchSessionSelector: async (sessionTag) => {
1200
+ const sessionConfig = await builder.fetchSession(sessionTag);
1201
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1202
+ },
1203
+ });
1204
+ if (sessionResult.error) {
1205
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1206
+ }
1207
+ resolvedOptions = sessionResult.input;
1208
+ sessionLogFields = sessionResult.logFields;
1209
+ }
1210
+ }
1211
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1212
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1213
+ const baseLogs = 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: 'updateRelationship', data: { id: resolvedOptions.id, operation: 'updateRelationship', graph: graphValue, env: envValue } }, sessionLogFields);
1214
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph updateRelationship - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1215
+ try {
1216
+ const adapter = this.getAdapter();
1217
+ const result = await adapter.updateRelationship(resolvedOptions, transaction);
1218
+ const end = Date.now();
1219
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1220
+ end, message: 'Graph updateRelationship - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1221
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1222
+ return result;
1223
+ }
1224
+ catch (error) {
1225
+ const end = Date.now();
1226
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1227
+ end, message: 'Graph updateRelationship - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'updateRelationship', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1228
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1229
+ throw error;
1230
+ }
1066
1231
  }
1067
1232
  /**
1068
1233
  * Delete a relationship
1069
1234
  * As documented in relationships.md
1070
1235
  */
1071
1236
  async deleteRelationship(options, transaction) {
1072
- const adapter = this.getAdapter();
1073
- return adapter.deleteRelationship(options, transaction);
1237
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1238
+ const process_id = (0, processor_utils_1.generateObjectId)();
1239
+ const start = Date.now();
1240
+ this.initializeLogService();
1241
+ // Session log fields (will be populated if session is provided)
1242
+ let sessionLogFields = {};
1243
+ let resolvedOptions = options;
1244
+ // Process session if provided
1245
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1246
+ const builder = await this.getProductBuilder(this.currentContext.product);
1247
+ const privateKey = builder.fetchPrivateKey();
1248
+ if (privateKey) {
1249
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1250
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1251
+ fetchSessionSelector: async (sessionTag) => {
1252
+ const sessionConfig = await builder.fetchSession(sessionTag);
1253
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1254
+ },
1255
+ });
1256
+ if (sessionResult.error) {
1257
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1258
+ }
1259
+ resolvedOptions = sessionResult.input;
1260
+ sessionLogFields = sessionResult.logFields;
1261
+ }
1262
+ }
1263
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1264
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1265
+ const baseLogs = 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: 'deleteRelationship', data: { id: resolvedOptions.id, operation: 'deleteRelationship', graph: graphValue, env: envValue } }, sessionLogFields);
1266
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph deleteRelationship - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1267
+ try {
1268
+ const adapter = this.getAdapter();
1269
+ const result = await adapter.deleteRelationship(resolvedOptions, transaction);
1270
+ const end = Date.now();
1271
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1272
+ end, message: 'Graph deleteRelationship - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1273
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1274
+ return result;
1275
+ }
1276
+ catch (error) {
1277
+ const end = Date.now();
1278
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1279
+ end, message: 'Graph deleteRelationship - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'deleteRelationship', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1280
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1281
+ throw error;
1282
+ }
1074
1283
  }
1075
1284
  /**
1076
1285
  * Merge (upsert) a relationship
1077
1286
  * As documented in relationships.md
1078
1287
  */
1079
1288
  async mergeRelationship(options, transaction) {
1080
- const adapter = this.getAdapter();
1081
- return adapter.mergeRelationship(options, transaction);
1289
+ return this.executeWithRetry(async () => {
1290
+ const adapter = this.getAdapter();
1291
+ return adapter.mergeRelationship(options, transaction);
1292
+ });
1082
1293
  }
1083
1294
  // ==================== TRAVERSAL OPERATIONS ====================
1084
1295
  /**
@@ -1126,57 +1337,153 @@ class GraphService {
1126
1337
  * As documented in traversals.md
1127
1338
  */
1128
1339
  async shortestPath(options, transaction) {
1129
- const adapter = this.getAdapter();
1130
- return adapter.shortestPath(options, transaction);
1340
+ return this.executeWithRetry(async () => {
1341
+ const adapter = this.getAdapter();
1342
+ return adapter.shortestPath(options, transaction);
1343
+ });
1131
1344
  }
1132
1345
  /**
1133
1346
  * Find all paths between two nodes
1134
1347
  * As documented in traversals.md
1135
1348
  */
1136
1349
  async allPaths(options, transaction) {
1137
- const adapter = this.getAdapter();
1138
- return adapter.allPaths(options, transaction);
1350
+ return this.executeWithRetry(async () => {
1351
+ const adapter = this.getAdapter();
1352
+ return adapter.allPaths(options, transaction);
1353
+ });
1139
1354
  }
1140
1355
  /**
1141
1356
  * Get the neighborhood of a node
1142
1357
  * As documented in traversals.md
1143
1358
  */
1144
1359
  async getNeighborhood(options, transaction) {
1145
- const adapter = this.getAdapter();
1146
- return adapter.getNeighborhood(options, transaction);
1360
+ return this.executeWithRetry(async () => {
1361
+ const adapter = this.getAdapter();
1362
+ return adapter.getNeighborhood(options, transaction);
1363
+ });
1147
1364
  }
1148
1365
  /**
1149
1366
  * Find connected components in the graph
1150
1367
  * As documented in traversals.md
1151
1368
  */
1152
1369
  async findConnectedComponents(options, transaction) {
1153
- const adapter = this.getAdapter();
1154
- return adapter.findConnectedComponents(options, transaction);
1370
+ return this.executeWithRetry(async () => {
1371
+ const adapter = this.getAdapter();
1372
+ return adapter.findConnectedComponents(options, transaction);
1373
+ });
1155
1374
  }
1156
1375
  // ==================== AGGREGATION OPERATIONS ====================
1157
1376
  /**
1158
1377
  * Count nodes matching criteria
1159
1378
  * As documented in overview.md
1160
1379
  */
1161
- async countNodes(labels, where, transaction) {
1162
- const adapter = this.getAdapter();
1163
- return adapter.countNodes(labels, where, transaction);
1380
+ async countNodes(labels, where, transaction, session) {
1381
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1382
+ const process_id = (0, processor_utils_1.generateObjectId)();
1383
+ const start = Date.now();
1384
+ this.initializeLogService();
1385
+ // Session log fields (will be populated if session is provided)
1386
+ let sessionLogFields = {};
1387
+ let resolvedWhere = where;
1388
+ // Process session if provided
1389
+ if (session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1390
+ const builder = await this.getProductBuilder(this.currentContext.product);
1391
+ const privateKey = builder.fetchPrivateKey();
1392
+ if (privateKey) {
1393
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1394
+ const sessionResult = await processSessionForExecution(session, privateKey, { where }, this.currentContext.env, {
1395
+ fetchSessionSelector: async (sessionTag) => {
1396
+ const sessionConfig = await builder.fetchSession(sessionTag);
1397
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1398
+ },
1399
+ });
1400
+ if (sessionResult.error) {
1401
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1402
+ }
1403
+ resolvedWhere = sessionResult.input.where;
1404
+ sessionLogFields = sessionResult.logFields;
1405
+ }
1406
+ }
1407
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1408
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1409
+ const baseLogs = 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: 'countNodes', data: { labels, operation: 'countNodes', graph: graphValue, env: envValue } }, sessionLogFields);
1410
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph countNodes - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1411
+ try {
1412
+ const adapter = this.getAdapter();
1413
+ const result = await adapter.countNodes(labels, resolvedWhere, transaction);
1414
+ const end = Date.now();
1415
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1416
+ end, message: 'Graph countNodes - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1417
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1418
+ return result;
1419
+ }
1420
+ catch (error) {
1421
+ const end = Date.now();
1422
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1423
+ end, message: 'Graph countNodes - failed', failed_execution: true, data: { labels, operation: 'countNodes', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1424
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1425
+ throw error;
1426
+ }
1164
1427
  }
1165
1428
  /**
1166
1429
  * Count relationships matching criteria
1167
1430
  * As documented in overview.md
1168
1431
  */
1169
1432
  async countRelationships(types, where, transaction) {
1170
- const adapter = this.getAdapter();
1171
- return adapter.countRelationships(types, where, transaction);
1433
+ return this.executeWithRetry(async () => {
1434
+ const adapter = this.getAdapter();
1435
+ return adapter.countRelationships(types, where, transaction);
1436
+ });
1172
1437
  }
1173
1438
  /**
1174
1439
  * Get graph statistics
1175
1440
  * As documented in overview.md
1176
1441
  */
1177
- async getStatistics(transaction) {
1178
- const adapter = this.getAdapter();
1179
- return adapter.getStatistics(transaction);
1442
+ async getStatistics(transaction, session) {
1443
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1444
+ const process_id = (0, processor_utils_1.generateObjectId)();
1445
+ const start = Date.now();
1446
+ this.initializeLogService();
1447
+ // Session log fields (will be populated if session is provided)
1448
+ let sessionLogFields = {};
1449
+ // Process session if provided
1450
+ if (session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1451
+ const builder = await this.getProductBuilder(this.currentContext.product);
1452
+ const privateKey = builder.fetchPrivateKey();
1453
+ if (privateKey) {
1454
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1455
+ const sessionResult = await processSessionForExecution(session, privateKey, {}, this.currentContext.env, {
1456
+ fetchSessionSelector: async (sessionTag) => {
1457
+ const sessionConfig = await builder.fetchSession(sessionTag);
1458
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1459
+ },
1460
+ });
1461
+ if (sessionResult.error) {
1462
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1463
+ }
1464
+ sessionLogFields = sessionResult.logFields;
1465
+ }
1466
+ }
1467
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1468
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1469
+ const baseLogs = 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: 'getStatistics', data: { operation: 'getStatistics', graph: graphValue, env: envValue } }, sessionLogFields);
1470
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph getStatistics - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1471
+ try {
1472
+ const adapter = this.getAdapter();
1473
+ const result = await adapter.getStatistics(transaction);
1474
+ const end = Date.now();
1475
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1476
+ end, message: 'Graph getStatistics - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1477
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1478
+ return result;
1479
+ }
1480
+ catch (error) {
1481
+ const end = Date.now();
1482
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1483
+ end, message: 'Graph getStatistics - failed', failed_execution: true, data: { operation: 'getStatistics', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1484
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1485
+ throw error;
1486
+ }
1180
1487
  }
1181
1488
  // ==================== SEARCH OPERATIONS ====================
1182
1489
  /**
@@ -1184,16 +1491,20 @@ class GraphService {
1184
1491
  * As documented in overview.md
1185
1492
  */
1186
1493
  async fullTextSearch(options, transaction) {
1187
- const adapter = this.getAdapter();
1188
- return adapter.fullTextSearch(options, transaction);
1494
+ return this.executeWithRetry(async () => {
1495
+ const adapter = this.getAdapter();
1496
+ return adapter.fullTextSearch(options, transaction);
1497
+ });
1189
1498
  }
1190
1499
  /**
1191
1500
  * Vector similarity search
1192
1501
  * As documented in overview.md
1193
1502
  */
1194
1503
  async vectorSearch(options, transaction) {
1195
- const adapter = this.getAdapter();
1196
- return adapter.vectorSearch(options, transaction);
1504
+ return this.executeWithRetry(async () => {
1505
+ const adapter = this.getAdapter();
1506
+ return adapter.vectorSearch(options, transaction);
1507
+ });
1197
1508
  }
1198
1509
  // ==================== RAW QUERY ====================
1199
1510
  /**
@@ -1209,8 +1520,10 @@ class GraphService {
1209
1520
  * ```
1210
1521
  */
1211
1522
  async query(query, params, transaction) {
1212
- const adapter = this.getAdapter();
1213
- return adapter.query({ query, params }, transaction);
1523
+ return this.executeWithRetry(async () => {
1524
+ const adapter = this.getAdapter();
1525
+ return adapter.query({ query, params }, transaction);
1526
+ });
1214
1527
  }
1215
1528
  // ==================== SCHEMA OPERATIONS ====================
1216
1529
  /**
@@ -1218,52 +1531,66 @@ class GraphService {
1218
1531
  * As documented in overview.md
1219
1532
  */
1220
1533
  async createNodeIndex(options) {
1221
- const adapter = this.getAdapter();
1222
- return adapter.createNodeIndex(options);
1534
+ return this.executeWithRetry(async () => {
1535
+ const adapter = this.getAdapter();
1536
+ return adapter.createNodeIndex(options);
1537
+ });
1223
1538
  }
1224
1539
  /**
1225
1540
  * Create a node constraint
1226
1541
  * As documented in overview.md
1227
1542
  */
1228
1543
  async createNodeConstraint(options) {
1229
- const adapter = this.getAdapter();
1230
- return adapter.createNodeConstraint(options);
1544
+ return this.executeWithRetry(async () => {
1545
+ const adapter = this.getAdapter();
1546
+ return adapter.createNodeConstraint(options);
1547
+ });
1231
1548
  }
1232
1549
  /**
1233
1550
  * Create a relationship index
1234
1551
  */
1235
1552
  async createRelationshipIndex(options) {
1236
- const adapter = this.getAdapter();
1237
- return adapter.createRelationshipIndex(options);
1553
+ return this.executeWithRetry(async () => {
1554
+ const adapter = this.getAdapter();
1555
+ return adapter.createRelationshipIndex(options);
1556
+ });
1238
1557
  }
1239
1558
  /**
1240
1559
  * List all indexes
1241
1560
  * As documented in overview.md
1242
1561
  */
1243
1562
  async listIndexes() {
1244
- const adapter = this.getAdapter();
1245
- return adapter.listIndexes();
1563
+ return this.executeWithRetry(async () => {
1564
+ const adapter = this.getAdapter();
1565
+ return adapter.listIndexes();
1566
+ });
1246
1567
  }
1247
1568
  /**
1248
1569
  * List all constraints
1249
1570
  */
1250
1571
  async listConstraints() {
1251
- const adapter = this.getAdapter();
1252
- return adapter.listConstraints();
1572
+ return this.executeWithRetry(async () => {
1573
+ const adapter = this.getAdapter();
1574
+ return adapter.listConstraints();
1575
+ });
1253
1576
  }
1254
1577
  /**
1255
1578
  * Drop an index
1256
1579
  */
1257
1580
  async dropIndex(name) {
1258
- const adapter = this.getAdapter();
1259
- return adapter.dropIndex(name);
1581
+ return this.executeWithRetry(async () => {
1582
+ const adapter = this.getAdapter();
1583
+ return adapter.dropIndex(name);
1584
+ });
1260
1585
  }
1261
1586
  /**
1262
1587
  * Drop a constraint
1263
1588
  */
1264
1589
  async dropConstraint(name) {
1265
- const adapter = this.getAdapter();
1266
- return adapter.dropConstraint(name);
1590
+ return this.executeWithRetry(async () => {
1591
+ const adapter = this.getAdapter();
1592
+ return adapter.dropConstraint(name);
1593
+ });
1267
1594
  }
1268
1595
  // ==================== SCHEMA INTROSPECTION ====================
1269
1596
  /**
@@ -1271,16 +1598,20 @@ class GraphService {
1271
1598
  * Used for GraphExplorer sidebar
1272
1599
  */
1273
1600
  async listLabels() {
1274
- const adapter = this.getAdapter();
1275
- return adapter.listLabels();
1601
+ return this.executeWithRetry(async () => {
1602
+ const adapter = this.getAdapter();
1603
+ return adapter.listLabels();
1604
+ });
1276
1605
  }
1277
1606
  /**
1278
1607
  * List all relationship types with counts
1279
1608
  * Used for GraphExplorer sidebar
1280
1609
  */
1281
1610
  async listRelationshipTypes() {
1282
- const adapter = this.getAdapter();
1283
- return adapter.listRelationshipTypes();
1611
+ return this.executeWithRetry(async () => {
1612
+ const adapter = this.getAdapter();
1613
+ return adapter.listRelationshipTypes();
1614
+ });
1284
1615
  }
1285
1616
  /**
1286
1617
  * Generate a URL-safe tag from a name
@@ -1493,7 +1824,12 @@ class GraphService {
1493
1824
  const privateKey = builder.fetchPrivateKey();
1494
1825
  if (privateKey) {
1495
1826
  const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1496
- const sessionResult = await processSessionForExecution(options.session, privateKey, options, options.env);
1827
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, options.env, {
1828
+ fetchSessionSelector: async (sessionTag) => {
1829
+ const sessionConfig = await builder.fetchSession(sessionTag);
1830
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1831
+ },
1832
+ });
1497
1833
  if (sessionResult.error) {
1498
1834
  throw new Error(`Session validation failed: ${sessionResult.error}`);
1499
1835
  }
@@ -1890,9 +2226,8 @@ class GraphService {
1890
2226
  }
1891
2227
  return this.transactionManager.rollbackTransaction(transaction);
1892
2228
  }
1893
- // ==================== UTILITY METHODS ====================
1894
2229
  /**
1895
- * Get the current adapter
2230
+ * Get the current adapter (synchronous, throws if not connected)
1896
2231
  */
1897
2232
  getAdapter() {
1898
2233
  if (!this.currentContext) {
@@ -1908,6 +2243,127 @@ class GraphService {
1908
2243
  }
1909
2244
  return adapter;
1910
2245
  }
2246
+ /**
2247
+ * Get the current adapter with automatic reconnection on failure
2248
+ */
2249
+ async getAdapterWithReconnect() {
2250
+ if (!this.currentContext) {
2251
+ throw graph_error_1.GraphError.configurationError('No connection established. Please call connect() first.');
2252
+ }
2253
+ const contextKey = `${this.currentContext.graph}:${this.currentContext.env}`;
2254
+ const adapter = this.adapters.get(contextKey);
2255
+ if (!adapter) {
2256
+ throw graph_error_1.GraphError.configurationError(`Adapter not found for ${contextKey}`);
2257
+ }
2258
+ // If connected, return the adapter
2259
+ if (this.currentContext.connected && adapter.isConnected()) {
2260
+ return adapter;
2261
+ }
2262
+ // Connection lost - attempt to reconnect
2263
+ await this.attemptReconnect();
2264
+ // After reconnection, verify we're connected
2265
+ if (!this.currentContext.connected) {
2266
+ throw graph_error_1.GraphError.connectionError('Failed to reconnect to graph database');
2267
+ }
2268
+ return adapter;
2269
+ }
2270
+ /**
2271
+ * Attempt to reconnect to the graph database
2272
+ */
2273
+ async attemptReconnect() {
2274
+ var _a;
2275
+ if (this.reconnecting) {
2276
+ // Wait briefly if reconnection is already in progress
2277
+ await new Promise(resolve => setTimeout(resolve, 1000));
2278
+ if ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.connected)
2279
+ return;
2280
+ throw graph_error_1.GraphError.connectionError('Reconnection already in progress');
2281
+ }
2282
+ if (!this.currentContext) {
2283
+ throw graph_error_1.GraphError.configurationError('Cannot reconnect: no connection context available');
2284
+ }
2285
+ this.reconnecting = true;
2286
+ const { graph, env, product } = this.currentContext;
2287
+ try {
2288
+ console.log(`[GraphService] Attempting to reconnect to ${graph}:${env}...`);
2289
+ // Attempt to reconnect using stored context
2290
+ await this.connect({
2291
+ graph,
2292
+ env,
2293
+ product: product || '',
2294
+ });
2295
+ console.log(`[GraphService] Successfully reconnected to ${graph}:${env}`);
2296
+ }
2297
+ catch (error) {
2298
+ console.error(`[GraphService] Failed to reconnect to ${graph}:${env}:`, error);
2299
+ throw error;
2300
+ }
2301
+ finally {
2302
+ this.reconnecting = false;
2303
+ }
2304
+ }
2305
+ /**
2306
+ * Execute an operation with automatic retry on connection errors
2307
+ */
2308
+ async executeWithRetry(operation, retries = this.maxReconnectRetries) {
2309
+ let lastError = null;
2310
+ for (let attempt = 0; attempt <= retries; attempt++) {
2311
+ try {
2312
+ // Ensure we have a connected adapter before each attempt
2313
+ await this.getAdapterWithReconnect();
2314
+ return await operation();
2315
+ }
2316
+ catch (error) {
2317
+ lastError = error;
2318
+ // Check if this is a connection error
2319
+ if (!this.isConnectionError(error) || attempt === retries) {
2320
+ throw error;
2321
+ }
2322
+ console.log(`[GraphService] Connection error on attempt ${attempt + 1}/${retries + 1}, retrying...`);
2323
+ // Mark as disconnected and try to reconnect
2324
+ if (this.currentContext) {
2325
+ this.currentContext.connected = false;
2326
+ }
2327
+ // Small delay before retry (exponential backoff)
2328
+ await new Promise(resolve => setTimeout(resolve, 500 * (attempt + 1)));
2329
+ }
2330
+ }
2331
+ throw lastError || new Error('Operation failed after retries');
2332
+ }
2333
+ /**
2334
+ * Check if an error is a connection-related error that can be retried
2335
+ * Note: "No connection established" errors are NOT retriable - they indicate
2336
+ * connect() was never called, not that a connection was lost
2337
+ */
2338
+ isConnectionError(error) {
2339
+ var _a, _b, _c;
2340
+ const errorCode = ((_a = error.code) === null || _a === void 0 ? void 0 : _a.toString()) || '';
2341
+ const errorMessage = ((_b = error.message) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || '';
2342
+ const errorType = ((_c = error.type) === null || _c === void 0 ? void 0 : _c.toString()) || '';
2343
+ // Configuration errors should NOT be retried - they require explicit connect() call
2344
+ if (errorType === 'CONFIGURATION_ERROR' || errorMessage.includes('please call connect')) {
2345
+ return false;
2346
+ }
2347
+ return (errorCode === 'ECONNRESET' ||
2348
+ errorCode === 'ETIMEDOUT' ||
2349
+ errorCode === 'ENOTFOUND' ||
2350
+ errorCode === 'ECONNREFUSED' ||
2351
+ errorCode === 'EPIPE' ||
2352
+ errorCode === 'ServiceUnavailable' ||
2353
+ errorCode === 'SessionExpired' ||
2354
+ errorMessage.includes('connection terminated') ||
2355
+ errorMessage.includes('connection timeout') ||
2356
+ errorMessage.includes('connection refused') ||
2357
+ errorMessage.includes('connection lost') ||
2358
+ errorMessage.includes('connection closed') ||
2359
+ errorMessage.includes('socket hang up') ||
2360
+ errorMessage.includes('econnreset') ||
2361
+ errorMessage.includes('network error') ||
2362
+ errorMessage.includes('session expired') ||
2363
+ errorMessage.includes('service unavailable') ||
2364
+ errorMessage.includes('no longer valid') ||
2365
+ errorMessage.includes('pool is closed'));
2366
+ }
1911
2367
  /**
1912
2368
  * Fetch graph configuration from product API
1913
2369
  */