@ductape/sdk 0.1.8 → 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 (1000) hide show
  1. package/dist/agents/agent-context.d.ts +100 -0
  2. package/dist/agents/agent-context.js +604 -0
  3. package/dist/agents/agent-context.js.map +1 -0
  4. package/dist/agents/agent-executor.d.ts +180 -0
  5. package/dist/agents/agent-executor.js +715 -0
  6. package/dist/agents/agent-executor.js.map +1 -0
  7. package/dist/agents/agents.service.d.ts +310 -0
  8. package/dist/agents/agents.service.js +1255 -0
  9. package/dist/agents/agents.service.js.map +1 -0
  10. package/dist/agents/index.d.ts +55 -0
  11. package/dist/agents/index.js +110 -0
  12. package/dist/agents/index.js.map +1 -0
  13. package/dist/agents/memory-manager.d.ts +182 -0
  14. package/dist/agents/memory-manager.js +383 -0
  15. package/dist/agents/memory-manager.js.map +1 -0
  16. package/dist/agents/tool-registry.d.ts +141 -0
  17. package/dist/agents/tool-registry.js +355 -0
  18. package/dist/agents/tool-registry.js.map +1 -0
  19. package/dist/agents/types/agents.types.d.ts +1240 -0
  20. package/dist/agents/types/agents.types.js +12 -0
  21. package/dist/agents/types/agents.types.js.map +1 -0
  22. package/dist/agents/types/index.d.ts +6 -0
  23. package/dist/agents/types/index.js +23 -0
  24. package/dist/agents/types/index.js.map +1 -0
  25. package/dist/agents/vector-store-adapter.d.ts +108 -0
  26. package/dist/agents/vector-store-adapter.js +213 -0
  27. package/dist/agents/vector-store-adapter.js.map +1 -0
  28. package/dist/api/services/appApi.service.d.ts +78 -0
  29. package/dist/api/services/appApi.service.js +303 -0
  30. package/dist/api/services/appApi.service.js.map +1 -0
  31. package/dist/api/services/cloudApi.service.d.ts +31 -0
  32. package/dist/api/services/cloudApi.service.js +103 -0
  33. package/dist/api/services/cloudApi.service.js.map +1 -0
  34. package/dist/api/services/logsApi.service.d.ts +62 -0
  35. package/dist/api/services/logsApi.service.js +67 -0
  36. package/dist/api/services/logsApi.service.js.map +1 -0
  37. package/dist/api/services/pricingApi.service.d.ts +10 -0
  38. package/dist/api/services/pricingApi.service.js +34 -0
  39. package/dist/api/services/pricingApi.service.js.map +1 -0
  40. package/dist/api/services/processorApi.service.d.ts +927 -0
  41. package/dist/api/services/processorApi.service.js +787 -0
  42. package/dist/api/services/processorApi.service.js.map +1 -0
  43. package/dist/api/services/productsApi.service.d.ts +167 -0
  44. package/dist/api/services/productsApi.service.js +293 -0
  45. package/dist/api/services/productsApi.service.js.map +1 -0
  46. package/dist/api/services/resilienceApi.service.d.ts +106 -0
  47. package/dist/api/services/resilienceApi.service.js +224 -0
  48. package/dist/api/services/resilienceApi.service.js.map +1 -0
  49. package/dist/api/services/secretsApi.service.d.ts +51 -0
  50. package/dist/api/services/secretsApi.service.js +126 -0
  51. package/dist/api/services/secretsApi.service.js.map +1 -0
  52. package/dist/api/services/userApi.service.d.ts +10 -0
  53. package/dist/api/services/userApi.service.js +20 -0
  54. package/dist/api/services/userApi.service.js.map +1 -0
  55. package/dist/api/services/webhooksApi.service.d.ts +14 -0
  56. package/dist/api/services/webhooksApi.service.js +65 -0
  57. package/dist/api/services/webhooksApi.service.js.map +1 -0
  58. package/dist/api/services/workflowApi.service.d.ts +199 -0
  59. package/dist/api/services/workflowApi.service.js +201 -0
  60. package/dist/api/services/workflowApi.service.js.map +1 -0
  61. package/dist/api/services/workspaceApi.service.d.ts +20 -0
  62. package/dist/api/services/workspaceApi.service.js +54 -0
  63. package/dist/api/services/workspaceApi.service.js.map +1 -0
  64. package/dist/api/urls.d.ts +145 -0
  65. package/dist/api/urls.js +195 -0
  66. package/dist/api/urls.js.map +1 -0
  67. package/dist/api/utils/auth.utils.d.ts +10 -0
  68. package/dist/api/utils/auth.utils.js +24 -0
  69. package/dist/api/utils/auth.utils.js.map +1 -0
  70. package/dist/api/utils/cache.utils.d.ts +3 -0
  71. package/dist/api/utils/cache.utils.js +18 -0
  72. package/dist/api/utils/cache.utils.js.map +1 -0
  73. package/dist/api/utils/integration-api-error.d.ts +6 -0
  74. package/dist/api/utils/integration-api-error.js +45 -0
  75. package/dist/api/utils/integration-api-error.js.map +1 -0
  76. package/dist/api/utils/strings.utils.d.ts +7 -0
  77. package/dist/api/utils/strings.utils.js +64 -0
  78. package/dist/api/utils/strings.utils.js.map +1 -0
  79. package/dist/apps/services/app.service.d.ts +126 -0
  80. package/dist/apps/services/app.service.js +1436 -0
  81. package/dist/apps/services/app.service.js.map +1 -0
  82. package/dist/apps/utils/auth-context-manager.d.ts +137 -0
  83. package/dist/apps/utils/auth-context-manager.js +248 -0
  84. package/dist/apps/utils/auth-context-manager.js.map +1 -0
  85. package/dist/apps/utils/credential-manager.d.ts +128 -0
  86. package/dist/apps/utils/credential-manager.js +199 -0
  87. package/dist/apps/utils/credential-manager.js.map +1 -0
  88. package/dist/apps/utils/index.d.ts +10 -0
  89. package/dist/apps/utils/index.js +54 -0
  90. package/dist/apps/utils/index.js.map +1 -0
  91. package/dist/apps/utils/input-helpers.d.ts +67 -0
  92. package/dist/apps/utils/input-helpers.js +185 -0
  93. package/dist/apps/utils/input-helpers.js.map +1 -0
  94. package/dist/apps/utils/input-resolver.d.ts +165 -0
  95. package/dist/apps/utils/input-resolver.js +477 -0
  96. package/dist/apps/utils/input-resolver.js.map +1 -0
  97. package/dist/apps/utils/oauth-manager.d.ts +196 -0
  98. package/dist/apps/utils/oauth-manager.js +429 -0
  99. package/dist/apps/utils/oauth-manager.js.map +1 -0
  100. package/dist/apps/utils/objects.utils.d.ts +4 -0
  101. package/dist/apps/utils/objects.utils.js +59 -0
  102. package/dist/apps/utils/objects.utils.js.map +1 -0
  103. package/dist/apps/utils/string.utils.d.ts +9 -0
  104. package/dist/apps/utils/string.utils.js +89 -0
  105. package/dist/apps/utils/string.utils.js.map +1 -0
  106. package/dist/apps/validators/index.d.ts +17 -0
  107. package/dist/apps/validators/index.js +39 -0
  108. package/dist/apps/validators/index.js.map +1 -0
  109. package/dist/apps/validators/joi-validators/create.app.validator.d.ts +3 -0
  110. package/dist/apps/validators/joi-validators/create.app.validator.js +43 -0
  111. package/dist/apps/validators/joi-validators/create.app.validator.js.map +1 -0
  112. package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +3 -0
  113. package/dist/apps/validators/joi-validators/create.appAction.validator.js +72 -0
  114. package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -0
  115. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.d.ts +7 -0
  116. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.js +81 -0
  117. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.js.map +1 -0
  118. package/dist/apps/validators/joi-validators/create.appAuth.validator.d.ts +3 -0
  119. package/dist/apps/validators/joi-validators/create.appAuth.validator.js +64 -0
  120. package/dist/apps/validators/joi-validators/create.appAuth.validator.js.map +1 -0
  121. package/dist/apps/validators/joi-validators/create.appBody.validators.d.ts +4 -0
  122. package/dist/apps/validators/joi-validators/create.appBody.validators.js +44 -0
  123. package/dist/apps/validators/joi-validators/create.appBody.validators.js.map +1 -0
  124. package/dist/apps/validators/joi-validators/create.appConstants.validator.d.ts +4 -0
  125. package/dist/apps/validators/joi-validators/create.appConstants.validator.js +45 -0
  126. package/dist/apps/validators/joi-validators/create.appConstants.validator.js.map +1 -0
  127. package/dist/apps/validators/joi-validators/create.appEnv.validator.d.ts +4 -0
  128. package/dist/apps/validators/joi-validators/create.appEnv.validator.js +50 -0
  129. package/dist/apps/validators/joi-validators/create.appEnv.validator.js.map +1 -0
  130. package/dist/apps/validators/joi-validators/create.appVariable.validator.d.ts +4 -0
  131. package/dist/apps/validators/joi-validators/create.appVariable.validator.js +47 -0
  132. package/dist/apps/validators/joi-validators/create.appVariable.validator.js.map +1 -0
  133. package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +4 -0
  134. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +60 -0
  135. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -0
  136. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.d.ts +3 -0
  137. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js +48 -0
  138. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js.map +1 -0
  139. package/dist/apps/validators/joi-validators/sample.validator.d.ts +6 -0
  140. package/dist/apps/validators/joi-validators/sample.validator.js +65 -0
  141. package/dist/apps/validators/joi-validators/sample.validator.js.map +1 -0
  142. package/dist/apps/validators/joi-validators/update.app.validator.d.ts +4 -0
  143. package/dist/apps/validators/joi-validators/update.app.validator.js +66 -0
  144. package/dist/apps/validators/joi-validators/update.app.validator.js.map +1 -0
  145. package/dist/apps/validators/joi-validators/update.appAction.validator.d.ts +4 -0
  146. package/dist/apps/validators/joi-validators/update.appAction.validator.js +76 -0
  147. package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -0
  148. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +3 -0
  149. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +57 -0
  150. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -0
  151. package/dist/apps/validators/joi-validators/update.appAuth.validator.d.ts +4 -0
  152. package/dist/apps/validators/joi-validators/update.appAuth.validator.js +52 -0
  153. package/dist/apps/validators/joi-validators/update.appAuth.validator.js.map +1 -0
  154. package/dist/apps/validators/joi-validators/update.appConstants.validator.d.ts +4 -0
  155. package/dist/apps/validators/joi-validators/update.appConstants.validator.js +45 -0
  156. package/dist/apps/validators/joi-validators/update.appConstants.validator.js.map +1 -0
  157. package/dist/apps/validators/joi-validators/update.appEnv.validator.d.ts +4 -0
  158. package/dist/apps/validators/joi-validators/update.appEnv.validator.js +50 -0
  159. package/dist/apps/validators/joi-validators/update.appEnv.validator.js.map +1 -0
  160. package/dist/apps/validators/joi-validators/update.appVariables.validator.d.ts +4 -0
  161. package/dist/apps/validators/joi-validators/update.appVariables.validator.js +47 -0
  162. package/dist/apps/validators/joi-validators/update.appVariables.validator.js.map +1 -0
  163. package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +4 -0
  164. package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +59 -0
  165. package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -0
  166. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.d.ts +3 -0
  167. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js +48 -0
  168. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js.map +1 -0
  169. package/dist/apps/validators/joi-validators/update.validation.entityData.validator.d.ts +3 -0
  170. package/dist/apps/validators/joi-validators/update.validation.entityData.validator.js +60 -0
  171. package/dist/apps/validators/joi-validators/update.validation.entityData.validator.js.map +1 -0
  172. package/dist/bin.d.ts +26 -0
  173. package/dist/bin.js +28 -0
  174. package/dist/bin.js.map +1 -0
  175. package/dist/brokers/brokers.service.d.ts +438 -0
  176. package/dist/brokers/brokers.service.js +1315 -0
  177. package/dist/brokers/brokers.service.js.map +1 -0
  178. package/dist/brokers/index.d.ts +46 -0
  179. package/dist/brokers/index.js +83 -0
  180. package/dist/brokers/index.js.map +1 -0
  181. package/dist/brokers/types/index.d.ts +569 -0
  182. package/dist/brokers/types/index.js +8 -0
  183. package/dist/brokers/types/index.js.map +1 -0
  184. package/dist/brokers/utils/broker.util.d.ts +33 -0
  185. package/dist/brokers/utils/broker.util.js +125 -0
  186. package/dist/brokers/utils/broker.util.js.map +1 -0
  187. package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
  188. package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
  189. package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
  190. package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
  191. package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
  192. package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
  193. package/dist/brokers/utils/providers/index.d.ts +6 -0
  194. package/dist/brokers/utils/providers/index.js +16 -0
  195. package/dist/brokers/utils/providers/index.js.map +1 -0
  196. package/dist/brokers/utils/providers/kafka.service.d.ts +23 -0
  197. package/dist/brokers/utils/providers/kafka.service.js +131 -0
  198. package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
  199. package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
  200. package/dist/brokers/utils/providers/nats.service.js +63 -0
  201. package/dist/brokers/utils/providers/nats.service.js.map +1 -0
  202. package/dist/brokers/utils/providers/rabbitmq.service.d.ts +25 -0
  203. package/dist/brokers/utils/providers/rabbitmq.service.js +138 -0
  204. package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
  205. package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
  206. package/dist/brokers/utils/providers/redis.service.js +93 -0
  207. package/dist/brokers/utils/providers/redis.service.js.map +1 -0
  208. package/dist/cache/cache.manager.d.ts +308 -0
  209. package/dist/cache/cache.manager.js +900 -0
  210. package/dist/cache/cache.manager.js.map +1 -0
  211. package/dist/cache/cache.service.d.ts +194 -0
  212. package/dist/cache/cache.service.js +601 -0
  213. package/dist/cache/cache.service.js.map +1 -0
  214. package/dist/cache/index.d.ts +52 -0
  215. package/dist/cache/index.js +81 -0
  216. package/dist/cache/index.js.map +1 -0
  217. package/dist/cache/types/index.d.ts +114 -0
  218. package/dist/cache/types/index.js +6 -0
  219. package/dist/cache/types/index.js.map +1 -0
  220. package/dist/clients/apps.client.d.ts +4 -0
  221. package/dist/clients/apps.client.js +31 -0
  222. package/dist/clients/apps.client.js.map +1 -0
  223. package/dist/clients/email.client.d.ts +4 -0
  224. package/dist/clients/email.client.js +29 -0
  225. package/dist/clients/email.client.js.map +1 -0
  226. package/dist/clients/expo.client.d.ts +3 -0
  227. package/dist/clients/expo.client.js +28 -0
  228. package/dist/clients/expo.client.js.map +1 -0
  229. package/dist/clients/function.client.d.ts +3 -0
  230. package/dist/clients/function.client.js +27 -0
  231. package/dist/clients/function.client.js.map +1 -0
  232. package/dist/clients/http.client.d.ts +3 -0
  233. package/dist/clients/http.client.js +27 -0
  234. package/dist/clients/http.client.js.map +1 -0
  235. package/dist/clients/logs.client.d.ts +4 -0
  236. package/dist/clients/logs.client.js +34 -0
  237. package/dist/clients/logs.client.js.map +1 -0
  238. package/dist/clients/pricing.client.d.ts +4 -0
  239. package/dist/clients/pricing.client.js +34 -0
  240. package/dist/clients/pricing.client.js.map +1 -0
  241. package/dist/clients/products.client.d.ts +3 -0
  242. package/dist/clients/products.client.js +32 -0
  243. package/dist/clients/products.client.js.map +1 -0
  244. package/dist/clients/users.client.d.ts +4 -0
  245. package/dist/clients/users.client.js +34 -0
  246. package/dist/clients/users.client.js.map +1 -0
  247. package/dist/clients/webhooks.client.d.ts +4 -0
  248. package/dist/clients/webhooks.client.js +34 -0
  249. package/dist/clients/webhooks.client.js.map +1 -0
  250. package/dist/clients/workspace.client.d.ts +7 -0
  251. package/dist/clients/workspace.client.js +39 -0
  252. package/dist/clients/workspace.client.js.map +1 -0
  253. package/dist/cloud/cloud-runtime.util.d.ts +22 -0
  254. package/dist/cloud/cloud-runtime.util.js +61 -0
  255. package/dist/cloud/cloud-runtime.util.js.map +1 -0
  256. package/dist/cloud/cloud.service.d.ts +43 -0
  257. package/dist/cloud/cloud.service.js +121 -0
  258. package/dist/cloud/cloud.service.js.map +1 -0
  259. package/dist/cloud/index.d.ts +5 -0
  260. package/dist/cloud/index.js +25 -0
  261. package/dist/cloud/index.js.map +1 -0
  262. package/dist/cloud/types/cloud.types.d.ts +140 -0
  263. package/dist/cloud/types/cloud.types.js +6 -0
  264. package/dist/cloud/types/cloud.types.js.map +1 -0
  265. package/dist/cloud/types/index.d.ts +1 -0
  266. package/dist/cloud/types/index.js +18 -0
  267. package/dist/cloud/types/index.js.map +1 -0
  268. package/dist/database/actions/action-manager.d.ts +170 -0
  269. package/dist/database/actions/action-manager.js +465 -0
  270. package/dist/database/actions/action-manager.js.map +1 -0
  271. package/dist/database/actions/index.d.ts +6 -0
  272. package/dist/database/actions/index.js +13 -0
  273. package/dist/database/actions/index.js.map +1 -0
  274. package/dist/database/adapters/adapter.factory.d.ts +62 -0
  275. package/dist/database/adapters/adapter.factory.js +97 -0
  276. package/dist/database/adapters/adapter.factory.js.map +1 -0
  277. package/dist/database/adapters/base.adapter.d.ts +423 -0
  278. package/dist/database/adapters/base.adapter.js +260 -0
  279. package/dist/database/adapters/base.adapter.js.map +1 -0
  280. package/dist/database/adapters/cassandra.adapter.d.ts +92 -0
  281. package/dist/database/adapters/cassandra.adapter.js +1091 -0
  282. package/dist/database/adapters/cassandra.adapter.js.map +1 -0
  283. package/dist/database/adapters/dynamodb.adapter.d.ts +110 -0
  284. package/dist/database/adapters/dynamodb.adapter.js +1564 -0
  285. package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
  286. package/dist/database/adapters/index.d.ts +11 -0
  287. package/dist/database/adapters/index.js +27 -0
  288. package/dist/database/adapters/index.js.map +1 -0
  289. package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
  290. package/dist/database/adapters/mariadb.adapter.js +247 -0
  291. package/dist/database/adapters/mariadb.adapter.js.map +1 -0
  292. package/dist/database/adapters/mongodb.adapter.d.ts +121 -0
  293. package/dist/database/adapters/mongodb.adapter.js +1284 -0
  294. package/dist/database/adapters/mongodb.adapter.js.map +1 -0
  295. package/dist/database/adapters/mysql.adapter.d.ts +86 -0
  296. package/dist/database/adapters/mysql.adapter.js +1371 -0
  297. package/dist/database/adapters/mysql.adapter.js.map +1 -0
  298. package/dist/database/adapters/postgresql.adapter.d.ts +90 -0
  299. package/dist/database/adapters/postgresql.adapter.js +1487 -0
  300. package/dist/database/adapters/postgresql.adapter.js.map +1 -0
  301. package/dist/database/databases.service.d.ts +1526 -0
  302. package/dist/database/databases.service.js +3370 -0
  303. package/dist/database/databases.service.js.map +1 -0
  304. package/dist/database/index.d.ts +46 -0
  305. package/dist/database/index.js +109 -0
  306. package/dist/database/index.js.map +1 -0
  307. package/dist/database/migrations/index.d.ts +6 -0
  308. package/dist/database/migrations/index.js +12 -0
  309. package/dist/database/migrations/index.js.map +1 -0
  310. package/dist/database/migrations/migration-engine.d.ts +136 -0
  311. package/dist/database/migrations/migration-engine.js +1421 -0
  312. package/dist/database/migrations/migration-engine.js.map +1 -0
  313. package/dist/database/operators/aggregation-builder.d.ts +67 -0
  314. package/dist/database/operators/aggregation-builder.js +841 -0
  315. package/dist/database/operators/aggregation-builder.js.map +1 -0
  316. package/dist/database/operators/index.d.ts +7 -0
  317. package/dist/database/operators/index.js +15 -0
  318. package/dist/database/operators/index.js.map +1 -0
  319. package/dist/database/operators/query-builder.d.ts +69 -0
  320. package/dist/database/operators/query-builder.js +447 -0
  321. package/dist/database/operators/query-builder.js.map +1 -0
  322. package/dist/database/presave/decrypt.d.ts +25 -0
  323. package/dist/database/presave/decrypt.js +146 -0
  324. package/dist/database/presave/decrypt.js.map +1 -0
  325. package/dist/database/presave/index.d.ts +9 -0
  326. package/dist/database/presave/index.js +18 -0
  327. package/dist/database/presave/index.js.map +1 -0
  328. package/dist/database/presave/presave-processor.d.ts +148 -0
  329. package/dist/database/presave/presave-processor.js +702 -0
  330. package/dist/database/presave/presave-processor.js.map +1 -0
  331. package/dist/database/schema/index.d.ts +7 -0
  332. package/dist/database/schema/index.js +13 -0
  333. package/dist/database/schema/index.js.map +1 -0
  334. package/dist/database/schema/schema-manager.d.ts +258 -0
  335. package/dist/database/schema/schema-manager.js +638 -0
  336. package/dist/database/schema/schema-manager.js.map +1 -0
  337. package/dist/database/transactions/index.d.ts +6 -0
  338. package/dist/database/transactions/index.js +13 -0
  339. package/dist/database/transactions/index.js.map +1 -0
  340. package/dist/database/transactions/transaction-manager.d.ts +113 -0
  341. package/dist/database/transactions/transaction-manager.js +344 -0
  342. package/dist/database/transactions/transaction-manager.js.map +1 -0
  343. package/dist/database/triggers/index.d.ts +7 -0
  344. package/dist/database/triggers/index.js +14 -0
  345. package/dist/database/triggers/index.js.map +1 -0
  346. package/dist/database/triggers/trigger-processor.d.ts +239 -0
  347. package/dist/database/triggers/trigger-processor.js +1034 -0
  348. package/dist/database/triggers/trigger-processor.js.map +1 -0
  349. package/dist/database/types/action.interface.d.ts +148 -0
  350. package/dist/database/types/action.interface.js +6 -0
  351. package/dist/database/types/action.interface.js.map +1 -0
  352. package/dist/database/types/aggregation.interface.d.ts +185 -0
  353. package/dist/database/types/aggregation.interface.js +6 -0
  354. package/dist/database/types/aggregation.interface.js.map +1 -0
  355. package/dist/database/types/connection.interface.d.ts +141 -0
  356. package/dist/database/types/connection.interface.js +6 -0
  357. package/dist/database/types/connection.interface.js.map +1 -0
  358. package/dist/database/types/dashboard.interface.d.ts +74 -0
  359. package/dist/database/types/dashboard.interface.js +7 -0
  360. package/dist/database/types/dashboard.interface.js.map +1 -0
  361. package/dist/database/types/enums.d.ts +195 -0
  362. package/dist/database/types/enums.js +244 -0
  363. package/dist/database/types/enums.js.map +1 -0
  364. package/dist/database/types/index.d.ts +15 -0
  365. package/dist/database/types/index.js +31 -0
  366. package/dist/database/types/index.js.map +1 -0
  367. package/dist/database/types/migration.interface.d.ts +686 -0
  368. package/dist/database/types/migration.interface.js +9 -0
  369. package/dist/database/types/migration.interface.js.map +1 -0
  370. package/dist/database/types/presave.interface.d.ts +292 -0
  371. package/dist/database/types/presave.interface.js +60 -0
  372. package/dist/database/types/presave.interface.js.map +1 -0
  373. package/dist/database/types/query.interface.d.ts +205 -0
  374. package/dist/database/types/query.interface.js +6 -0
  375. package/dist/database/types/query.interface.js.map +1 -0
  376. package/dist/database/types/schema.interface.d.ts +412 -0
  377. package/dist/database/types/schema.interface.js +6 -0
  378. package/dist/database/types/schema.interface.js.map +1 -0
  379. package/dist/database/types/transaction.interface.d.ts +84 -0
  380. package/dist/database/types/transaction.interface.js +6 -0
  381. package/dist/database/types/transaction.interface.js.map +1 -0
  382. package/dist/database/types/trigger.interface.d.ts +612 -0
  383. package/dist/database/types/trigger.interface.js +121 -0
  384. package/dist/database/types/trigger.interface.js.map +1 -0
  385. package/dist/database/types/write.interface.d.ts +216 -0
  386. package/dist/database/types/write.interface.js +6 -0
  387. package/dist/database/types/write.interface.js.map +1 -0
  388. package/dist/database/utils/database-error.d.ts +96 -0
  389. package/dist/database/utils/database-error.js +221 -0
  390. package/dist/database/utils/database-error.js.map +1 -0
  391. package/dist/database/utils/index.d.ts +6 -0
  392. package/dist/database/utils/index.js +11 -0
  393. package/dist/database/utils/index.js.map +1 -0
  394. package/dist/graph/adapters/adapter.factory.d.ts +47 -0
  395. package/dist/graph/adapters/adapter.factory.js +77 -0
  396. package/dist/graph/adapters/adapter.factory.js.map +1 -0
  397. package/dist/graph/adapters/arangodb.adapter.d.ts +86 -0
  398. package/dist/graph/adapters/arangodb.adapter.js +1588 -0
  399. package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
  400. package/dist/graph/adapters/base.adapter.d.ts +264 -0
  401. package/dist/graph/adapters/base.adapter.js +156 -0
  402. package/dist/graph/adapters/base.adapter.js.map +1 -0
  403. package/dist/graph/adapters/index.d.ts +11 -0
  404. package/dist/graph/adapters/index.js +21 -0
  405. package/dist/graph/adapters/index.js.map +1 -0
  406. package/dist/graph/adapters/memgraph.adapter.d.ts +110 -0
  407. package/dist/graph/adapters/memgraph.adapter.js +1452 -0
  408. package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
  409. package/dist/graph/adapters/neo4j.adapter.d.ts +81 -0
  410. package/dist/graph/adapters/neo4j.adapter.js +1317 -0
  411. package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
  412. package/dist/graph/adapters/neptune.adapter.d.ts +82 -0
  413. package/dist/graph/adapters/neptune.adapter.js +1369 -0
  414. package/dist/graph/adapters/neptune.adapter.js.map +1 -0
  415. package/dist/graph/graphs.service.d.ts +633 -0
  416. package/dist/graph/graphs.service.js +2684 -0
  417. package/dist/graph/graphs.service.js.map +1 -0
  418. package/dist/graph/index.d.ts +58 -0
  419. package/dist/graph/index.js +77 -0
  420. package/dist/graph/index.js.map +1 -0
  421. package/dist/graph/transactions/index.d.ts +4 -0
  422. package/dist/graph/transactions/index.js +9 -0
  423. package/dist/graph/transactions/index.js.map +1 -0
  424. package/dist/graph/transactions/transaction-manager.d.ts +61 -0
  425. package/dist/graph/transactions/transaction-manager.js +126 -0
  426. package/dist/graph/transactions/transaction-manager.js.map +1 -0
  427. package/dist/graph/types/connection.interface.d.ts +161 -0
  428. package/dist/graph/types/connection.interface.js +9 -0
  429. package/dist/graph/types/connection.interface.js.map +1 -0
  430. package/dist/graph/types/enums.d.ts +101 -0
  431. package/dist/graph/types/enums.js +114 -0
  432. package/dist/graph/types/enums.js.map +1 -0
  433. package/dist/graph/types/index.d.ts +13 -0
  434. package/dist/graph/types/index.js +20 -0
  435. package/dist/graph/types/index.js.map +1 -0
  436. package/dist/graph/types/node.interface.d.ts +248 -0
  437. package/dist/graph/types/node.interface.js +9 -0
  438. package/dist/graph/types/node.interface.js.map +1 -0
  439. package/dist/graph/types/query.interface.d.ts +175 -0
  440. package/dist/graph/types/query.interface.js +9 -0
  441. package/dist/graph/types/query.interface.js.map +1 -0
  442. package/dist/graph/types/relationship.interface.d.ts +207 -0
  443. package/dist/graph/types/relationship.interface.js +9 -0
  444. package/dist/graph/types/relationship.interface.js.map +1 -0
  445. package/dist/graph/types/schema.interface.d.ts +295 -0
  446. package/dist/graph/types/schema.interface.js +9 -0
  447. package/dist/graph/types/schema.interface.js.map +1 -0
  448. package/dist/graph/types/transaction.interface.d.ts +55 -0
  449. package/dist/graph/types/transaction.interface.js +9 -0
  450. package/dist/graph/types/transaction.interface.js.map +1 -0
  451. package/dist/graph/types/traversal.interface.d.ts +181 -0
  452. package/dist/graph/types/traversal.interface.js +9 -0
  453. package/dist/graph/types/traversal.interface.js.map +1 -0
  454. package/dist/graph/utils/graph-error.d.ts +71 -0
  455. package/dist/graph/utils/graph-error.js +142 -0
  456. package/dist/graph/utils/graph-error.js.map +1 -0
  457. package/dist/graph/utils/index.d.ts +4 -0
  458. package/dist/graph/utils/index.js +9 -0
  459. package/dist/graph/utils/index.js.map +1 -0
  460. package/dist/imports/imports.repo.d.ts +0 -0
  461. package/dist/imports/imports.repo.js +1 -0
  462. package/dist/imports/imports.repo.js.map +1 -0
  463. package/dist/imports/imports.service.d.ts +23 -0
  464. package/dist/imports/imports.service.js +71 -0
  465. package/dist/imports/imports.service.js.map +1 -0
  466. package/dist/imports/imports.types.d.ts +350 -0
  467. package/dist/imports/imports.types.js +33 -0
  468. package/dist/imports/imports.types.js.map +1 -0
  469. package/dist/imports/openAPI3.0.types.d.ts +52 -0
  470. package/dist/imports/openAPI3.0.types.js +3 -0
  471. package/dist/imports/openAPI3.0.types.js.map +1 -0
  472. package/dist/imports/repos/openApi.repo.d.ts +6 -0
  473. package/dist/imports/repos/openApi.repo.js +422 -0
  474. package/dist/imports/repos/openApi.repo.js.map +1 -0
  475. package/dist/imports/repos/postmanV21.repo.d.ts +14 -0
  476. package/dist/imports/repos/postmanV21.repo.js +257 -0
  477. package/dist/imports/repos/postmanV21.repo.js.map +1 -0
  478. package/dist/imports/utils/imports.utils.d.ts +80 -0
  479. package/dist/imports/utils/imports.utils.js +114 -0
  480. package/dist/imports/utils/imports.utils.js.map +1 -0
  481. package/dist/imports/validators/index.d.ts +0 -0
  482. package/dist/imports/validators/index.js +1 -0
  483. package/dist/imports/validators/index.js.map +1 -0
  484. package/dist/imports/validators/joi-validators/postmanV21.validator.d.ts +5 -0
  485. package/dist/imports/validators/joi-validators/postmanV21.validator.js +96 -0
  486. package/dist/imports/validators/joi-validators/postmanV21.validator.js.map +1 -0
  487. package/dist/index.d.ts +4233 -0
  488. package/dist/index.js +5933 -0
  489. package/dist/index.js.map +1 -0
  490. package/dist/init.interface.d.ts +407 -0
  491. package/dist/init.interface.js +3 -0
  492. package/dist/init.interface.js.map +1 -0
  493. package/dist/inputs/inputs.repo.d.ts +7 -0
  494. package/dist/inputs/inputs.repo.js +16 -0
  495. package/dist/inputs/inputs.repo.js.map +1 -0
  496. package/dist/inputs/inputs.service.d.ts +61 -0
  497. package/dist/inputs/inputs.service.js +468 -0
  498. package/dist/inputs/inputs.service.js.map +1 -0
  499. package/dist/inputs/utils/inputs.utils.create.d.ts +11 -0
  500. package/dist/inputs/utils/inputs.utils.create.js +273 -0
  501. package/dist/inputs/utils/inputs.utils.create.js.map +1 -0
  502. package/dist/inputs/validators/inputs.validator.parse.d.ts +4 -0
  503. package/dist/inputs/validators/inputs.validator.parse.js +53 -0
  504. package/dist/inputs/validators/inputs.validator.parse.js.map +1 -0
  505. package/dist/jobs/index.d.ts +38 -0
  506. package/dist/jobs/index.js +50 -0
  507. package/dist/jobs/index.js.map +1 -0
  508. package/dist/jobs/jobs.service.d.ts +154 -0
  509. package/dist/jobs/jobs.service.js +491 -0
  510. package/dist/jobs/jobs.service.js.map +1 -0
  511. package/dist/jobs/jobs.state.d.ts +113 -0
  512. package/dist/jobs/jobs.state.js +447 -0
  513. package/dist/jobs/jobs.state.js.map +1 -0
  514. package/dist/jobs/types.d.ts +449 -0
  515. package/dist/jobs/types.js +74 -0
  516. package/dist/jobs/types.js.map +1 -0
  517. package/dist/logs/logs.repo.d.ts +6 -0
  518. package/dist/logs/logs.repo.js +12 -0
  519. package/dist/logs/logs.repo.js.map +1 -0
  520. package/dist/logs/logs.service.d.ts +30 -0
  521. package/dist/logs/logs.service.js +89 -0
  522. package/dist/logs/logs.service.js.map +1 -0
  523. package/dist/logs/logs.types.d.ts +85 -0
  524. package/dist/logs/logs.types.js +52 -0
  525. package/dist/logs/logs.types.js.map +1 -0
  526. package/dist/logs/utils/logs.utils.create.d.ts +0 -0
  527. package/dist/logs/utils/logs.utils.create.js +1 -0
  528. package/dist/logs/utils/logs.utils.create.js.map +1 -0
  529. package/dist/logs/utils/logs.utils.errors.d.ts +2 -0
  530. package/dist/logs/utils/logs.utils.errors.js +8 -0
  531. package/dist/logs/utils/logs.utils.errors.js.map +1 -0
  532. package/dist/models/index.d.ts +6 -0
  533. package/dist/models/index.js +11 -0
  534. package/dist/models/index.js.map +1 -0
  535. package/dist/models/models.service.d.ts +137 -0
  536. package/dist/models/models.service.js +195 -0
  537. package/dist/models/models.service.js.map +1 -0
  538. package/dist/notifications/index.d.ts +13 -0
  539. package/dist/notifications/index.js +26 -0
  540. package/dist/notifications/index.js.map +1 -0
  541. package/dist/notifications/notifications.service.d.ts +270 -0
  542. package/dist/notifications/notifications.service.js +912 -0
  543. package/dist/notifications/notifications.service.js.map +1 -0
  544. package/dist/notifications/types/index.d.ts +4 -0
  545. package/dist/notifications/types/index.js +21 -0
  546. package/dist/notifications/types/index.js.map +1 -0
  547. package/dist/notifications/types/notifications.types.d.ts +456 -0
  548. package/dist/notifications/types/notifications.types.js +51 -0
  549. package/dist/notifications/types/notifications.types.js.map +1 -0
  550. package/dist/parsers/index.d.ts +3 -0
  551. package/dist/parsers/index.js +27 -0
  552. package/dist/parsers/index.js.map +1 -0
  553. package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
  554. package/dist/parsers/pipelines/postman.pipelines.js +103 -0
  555. package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
  556. package/dist/parsers/types/postman.types.d.ts +200 -0
  557. package/dist/parsers/types/postman.types.js +3 -0
  558. package/dist/parsers/types/postman.types.js.map +1 -0
  559. package/dist/parsers/utils/postman.utils.d.ts +12 -0
  560. package/dist/parsers/utils/postman.utils.js +116 -0
  561. package/dist/parsers/utils/postman.utils.js.map +1 -0
  562. package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
  563. package/dist/parsers/validators/postman-auth.validators.js +127 -0
  564. package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
  565. package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
  566. package/dist/parsers/validators/postman-request.validators.js +139 -0
  567. package/dist/parsers/validators/postman-request.validators.js.map +1 -0
  568. package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
  569. package/dist/parsers/validators/postman-response.validators.js +150 -0
  570. package/dist/parsers/validators/postman-response.validators.js.map +1 -0
  571. package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
  572. package/dist/parsers/validators/postman-variable.validators.js +163 -0
  573. package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
  574. package/dist/pricing/pricing.repo.d.ts +0 -0
  575. package/dist/pricing/pricing.repo.js +1 -0
  576. package/dist/pricing/pricing.repo.js.map +1 -0
  577. package/dist/pricing/pricing.service.d.ts +24 -0
  578. package/dist/pricing/pricing.service.js +51 -0
  579. package/dist/pricing/pricing.service.js.map +1 -0
  580. package/dist/pricing/pricing.types.d.ts +76 -0
  581. package/dist/pricing/pricing.types.js +21 -0
  582. package/dist/pricing/pricing.types.js.map +1 -0
  583. package/dist/pricing/utils/string.utils.d.ts +1 -0
  584. package/dist/pricing/utils/string.utils.js +9 -0
  585. package/dist/pricing/utils/string.utils.js.map +1 -0
  586. package/dist/processor/repos/mongo.repo.d.ts +39 -0
  587. package/dist/processor/repos/mongo.repo.js +260 -0
  588. package/dist/processor/repos/mongo.repo.js.map +1 -0
  589. package/dist/processor/repos/postgres.repo.d.ts +31 -0
  590. package/dist/processor/repos/postgres.repo.js +185 -0
  591. package/dist/processor/repos/postgres.repo.js.map +1 -0
  592. package/dist/processor/repos/sms.repo.d.ts +39 -0
  593. package/dist/processor/repos/sms.repo.js +124 -0
  594. package/dist/processor/repos/sms.repo.js.map +1 -0
  595. package/dist/processor/services/processor.service.d.ts +465 -0
  596. package/dist/processor/services/processor.service.js +5343 -0
  597. package/dist/processor/services/processor.service.js.map +1 -0
  598. package/dist/processor/services/request.service.d.ts +36 -0
  599. package/dist/processor/services/request.service.js +304 -0
  600. package/dist/processor/services/request.service.js.map +1 -0
  601. package/dist/processor/types/request.types.d.ts +14 -0
  602. package/dist/processor/types/request.types.js +3 -0
  603. package/dist/processor/types/request.types.js.map +1 -0
  604. package/dist/processor/utils/processor.utils.d.ts +104 -0
  605. package/dist/processor/utils/processor.utils.js +1066 -0
  606. package/dist/processor/utils/processor.utils.js.map +1 -0
  607. package/dist/processor/utils/request.utils.d.ts +20 -0
  608. package/dist/processor/utils/request.utils.js +113 -0
  609. package/dist/processor/utils/request.utils.js.map +1 -0
  610. package/dist/processor/utils/storage.util.d.ts +8 -0
  611. package/dist/processor/utils/storage.util.js +106 -0
  612. package/dist/processor/utils/storage.util.js.map +1 -0
  613. package/dist/products/services/products.service.d.ts +579 -0
  614. package/dist/products/services/products.service.js +5853 -0
  615. package/dist/products/services/products.service.js.map +1 -0
  616. package/dist/products/utils/crypt.utils.d.ts +1 -0
  617. package/dist/products/utils/crypt.utils.js +17 -0
  618. package/dist/products/utils/crypt.utils.js.map +1 -0
  619. package/dist/products/utils/functions.utils.d.ts +13 -0
  620. package/dist/products/utils/functions.utils.js +294 -0
  621. package/dist/products/utils/functions.utils.js.map +1 -0
  622. package/dist/products/utils/objects.utils.d.ts +13 -0
  623. package/dist/products/utils/objects.utils.js +89 -0
  624. package/dist/products/utils/objects.utils.js.map +1 -0
  625. package/dist/products/utils/string.utils.d.ts +12 -0
  626. package/dist/products/utils/string.utils.js +168 -0
  627. package/dist/products/utils/string.utils.js.map +1 -0
  628. package/dist/products/validators/index.d.ts +33 -0
  629. package/dist/products/validators/index.js +75 -0
  630. package/dist/products/validators/index.js.map +1 -0
  631. package/dist/products/validators/joi-validators/create.html.validator.d.ts +2 -0
  632. package/dist/products/validators/joi-validators/create.html.validator.js +55 -0
  633. package/dist/products/validators/joi-validators/create.html.validator.js.map +1 -0
  634. package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
  635. package/dist/products/validators/joi-validators/create.productAgent.validator.js +266 -0
  636. package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
  637. package/dist/products/validators/joi-validators/create.productApp.validator.d.ts +4 -0
  638. package/dist/products/validators/joi-validators/create.productApp.validator.js +61 -0
  639. package/dist/products/validators/joi-validators/create.productApp.validator.js.map +1 -0
  640. package/dist/products/validators/joi-validators/create.productCache.validator.d.ts +3 -0
  641. package/dist/products/validators/joi-validators/create.productCache.validator.js +46 -0
  642. package/dist/products/validators/joi-validators/create.productCache.validator.js.map +1 -0
  643. package/dist/products/validators/joi-validators/create.productDatabase.validator.d.ts +3 -0
  644. package/dist/products/validators/joi-validators/create.productDatabase.validator.js +77 -0
  645. package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -0
  646. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +7 -0
  647. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +194 -0
  648. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -0
  649. package/dist/products/validators/joi-validators/create.productDatabaseMigration.validator.d.ts +4 -0
  650. package/dist/products/validators/joi-validators/create.productDatabaseMigration.validator.js +63 -0
  651. package/dist/products/validators/joi-validators/create.productDatabaseMigration.validator.js.map +1 -0
  652. package/dist/products/validators/joi-validators/create.productEnv.validator.d.ts +3 -0
  653. package/dist/products/validators/joi-validators/create.productEnv.validator.js +45 -0
  654. package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -0
  655. package/dist/products/validators/joi-validators/create.productFallback.validator.d.ts +3 -0
  656. package/dist/products/validators/joi-validators/create.productFallback.validator.js +64 -0
  657. package/dist/products/validators/joi-validators/create.productFallback.validator.js.map +1 -0
  658. package/dist/products/validators/joi-validators/create.productFeature.validator.d.ts +14 -0
  659. package/dist/products/validators/joi-validators/create.productFeature.validator.js +140 -0
  660. package/dist/products/validators/joi-validators/create.productFeature.validator.js.map +1 -0
  661. package/dist/products/validators/joi-validators/create.productFunction.validator.d.ts +3 -0
  662. package/dist/products/validators/joi-validators/create.productFunction.validator.js +57 -0
  663. package/dist/products/validators/joi-validators/create.productFunction.validator.js.map +1 -0
  664. package/dist/products/validators/joi-validators/create.productGraph.validator.d.ts +3 -0
  665. package/dist/products/validators/joi-validators/create.productGraph.validator.js +89 -0
  666. package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
  667. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
  668. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
  669. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
  670. package/dist/products/validators/joi-validators/create.productJob.validator.d.ts +12 -0
  671. package/dist/products/validators/joi-validators/create.productJob.validator.js +60 -0
  672. package/dist/products/validators/joi-validators/create.productJob.validator.js.map +1 -0
  673. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.d.ts +3 -0
  674. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +52 -0
  675. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -0
  676. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.d.ts +3 -0
  677. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +193 -0
  678. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -0
  679. package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
  680. package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
  681. package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
  682. package/dist/products/validators/joi-validators/create.productNotification.validator.d.ts +4 -0
  683. package/dist/products/validators/joi-validators/create.productNotification.validator.js +241 -0
  684. package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -0
  685. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.d.ts +3 -0
  686. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.js +57 -0
  687. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.js.map +1 -0
  688. package/dist/products/validators/joi-validators/create.productNotifications.validator.d.ts +0 -0
  689. package/dist/products/validators/joi-validators/create.productNotifications.validator.js +1 -0
  690. package/dist/products/validators/joi-validators/create.productNotifications.validator.js.map +1 -0
  691. package/dist/products/validators/joi-validators/create.productQuota.validator.d.ts +3 -0
  692. package/dist/products/validators/joi-validators/create.productQuota.validator.js +67 -0
  693. package/dist/products/validators/joi-validators/create.productQuota.validator.js.map +1 -0
  694. package/dist/products/validators/joi-validators/create.productStorage.validator.d.ts +3 -0
  695. package/dist/products/validators/joi-validators/create.productStorage.validator.js +158 -0
  696. package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -0
  697. package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
  698. package/dist/products/validators/joi-validators/create.productVector.validator.js +136 -0
  699. package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
  700. package/dist/products/validators/joi-validators/create.products.validator.d.ts +3 -0
  701. package/dist/products/validators/joi-validators/create.products.validator.js +43 -0
  702. package/dist/products/validators/joi-validators/create.products.validator.js.map +1 -0
  703. package/dist/products/validators/joi-validators/create.requestAction.validator.d.ts +2 -0
  704. package/dist/products/validators/joi-validators/create.requestAction.validator.js +45 -0
  705. package/dist/products/validators/joi-validators/create.requestAction.validator.js.map +1 -0
  706. package/dist/products/validators/joi-validators/create.userAuth.validator.d.ts +3 -0
  707. package/dist/products/validators/joi-validators/create.userAuth.validator.js +48 -0
  708. package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -0
  709. package/dist/products/validators/joi-validators/register.productWebhooks.validator.d.ts +3 -0
  710. package/dist/products/validators/joi-validators/register.productWebhooks.validator.js +48 -0
  711. package/dist/products/validators/joi-validators/register.productWebhooks.validator.js.map +1 -0
  712. package/dist/products/validators/joi-validators/update.dataValue.validator.d.ts +3 -0
  713. package/dist/products/validators/joi-validators/update.dataValue.validator.js +104 -0
  714. package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -0
  715. package/dist/products/validators/joi-validators/update.productApp.validator.d.ts +3 -0
  716. package/dist/products/validators/joi-validators/update.productApp.validator.js +42 -0
  717. package/dist/products/validators/joi-validators/update.productApp.validator.js.map +1 -0
  718. package/dist/products/validators/joi-validators/update.productCache.validator.d.ts +3 -0
  719. package/dist/products/validators/joi-validators/update.productCache.validator.js +45 -0
  720. package/dist/products/validators/joi-validators/update.productCache.validator.js.map +1 -0
  721. package/dist/products/validators/joi-validators/update.productDatabase.validator.d.ts +3 -0
  722. package/dist/products/validators/joi-validators/update.productDatabase.validator.js +76 -0
  723. package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -0
  724. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +3 -0
  725. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +79 -0
  726. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -0
  727. package/dist/products/validators/joi-validators/update.productDatabaseMigration.validator.d.ts +4 -0
  728. package/dist/products/validators/joi-validators/update.productDatabaseMigration.validator.js +64 -0
  729. package/dist/products/validators/joi-validators/update.productDatabaseMigration.validator.js.map +1 -0
  730. package/dist/products/validators/joi-validators/update.productEnv.validator.d.ts +3 -0
  731. package/dist/products/validators/joi-validators/update.productEnv.validator.js +46 -0
  732. package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -0
  733. package/dist/products/validators/joi-validators/update.productFallback.validator.d.ts +3 -0
  734. package/dist/products/validators/joi-validators/update.productFallback.validator.js +60 -0
  735. package/dist/products/validators/joi-validators/update.productFallback.validator.js.map +1 -0
  736. package/dist/products/validators/joi-validators/update.productFeature.validator.d.ts +3 -0
  737. package/dist/products/validators/joi-validators/update.productFeature.validator.js +53 -0
  738. package/dist/products/validators/joi-validators/update.productFeature.validator.js.map +1 -0
  739. package/dist/products/validators/joi-validators/update.productFunction.validator.d.ts +3 -0
  740. package/dist/products/validators/joi-validators/update.productFunction.validator.js +41 -0
  741. package/dist/products/validators/joi-validators/update.productFunction.validator.js.map +1 -0
  742. package/dist/products/validators/joi-validators/update.productGraph.validator.d.ts +3 -0
  743. package/dist/products/validators/joi-validators/update.productGraph.validator.js +88 -0
  744. package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
  745. package/dist/products/validators/joi-validators/update.productJob.validator.d.ts +3 -0
  746. package/dist/products/validators/joi-validators/update.productJob.validator.js +50 -0
  747. package/dist/products/validators/joi-validators/update.productJob.validator.js.map +1 -0
  748. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.d.ts +3 -0
  749. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +52 -0
  750. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -0
  751. package/dist/products/validators/joi-validators/update.productNotification.validator.d.ts +3 -0
  752. package/dist/products/validators/joi-validators/update.productNotification.validator.js +47 -0
  753. package/dist/products/validators/joi-validators/update.productNotification.validator.js.map +1 -0
  754. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.d.ts +3 -0
  755. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js +58 -0
  756. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js.map +1 -0
  757. package/dist/products/validators/joi-validators/update.productQuota.validator.d.ts +3 -0
  758. package/dist/products/validators/joi-validators/update.productQuota.validator.js +64 -0
  759. package/dist/products/validators/joi-validators/update.productQuota.validator.js.map +1 -0
  760. package/dist/products/validators/joi-validators/update.userAuth.validator.d.ts +3 -0
  761. package/dist/products/validators/joi-validators/update.userAuth.validator.js +48 -0
  762. package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -0
  763. package/dist/resilience/fallback.service.d.ts +143 -0
  764. package/dist/resilience/fallback.service.js +771 -0
  765. package/dist/resilience/fallback.service.js.map +1 -0
  766. package/dist/resilience/healthcheck.service.d.ts +165 -0
  767. package/dist/resilience/healthcheck.service.js +1019 -0
  768. package/dist/resilience/healthcheck.service.js.map +1 -0
  769. package/dist/resilience/index.d.ts +104 -0
  770. package/dist/resilience/index.js +140 -0
  771. package/dist/resilience/index.js.map +1 -0
  772. package/dist/resilience/quota.service.d.ts +85 -0
  773. package/dist/resilience/quota.service.js +523 -0
  774. package/dist/resilience/quota.service.js.map +1 -0
  775. package/dist/resilience/resilience.service.d.ts +98 -0
  776. package/dist/resilience/resilience.service.js +560 -0
  777. package/dist/resilience/resilience.service.js.map +1 -0
  778. package/dist/resilience/types/index.d.ts +515 -0
  779. package/dist/resilience/types/index.js +29 -0
  780. package/dist/resilience/types/index.js.map +1 -0
  781. package/dist/runtime/runtime-defaults.d.ts +28 -0
  782. package/dist/runtime/runtime-defaults.js +38 -0
  783. package/dist/runtime/runtime-defaults.js.map +1 -0
  784. package/dist/secrets/index.d.ts +10 -0
  785. package/dist/secrets/index.js +33 -0
  786. package/dist/secrets/index.js.map +1 -0
  787. package/dist/secrets/secrets.resolver.d.ts +52 -0
  788. package/dist/secrets/secrets.resolver.js +236 -0
  789. package/dist/secrets/secrets.resolver.js.map +1 -0
  790. package/dist/secrets/secrets.service.d.ts +93 -0
  791. package/dist/secrets/secrets.service.js +246 -0
  792. package/dist/secrets/secrets.service.js.map +1 -0
  793. package/dist/secrets/secrets.types.d.ts +188 -0
  794. package/dist/secrets/secrets.types.js +87 -0
  795. package/dist/secrets/secrets.types.js.map +1 -0
  796. package/dist/sessions/index.d.ts +50 -0
  797. package/dist/sessions/index.js +96 -0
  798. package/dist/sessions/index.js.map +1 -0
  799. package/dist/sessions/sessions.helper.d.ts +88 -0
  800. package/dist/sessions/sessions.helper.js +190 -0
  801. package/dist/sessions/sessions.helper.js.map +1 -0
  802. package/dist/sessions/sessions.resolver.d.ts +188 -0
  803. package/dist/sessions/sessions.resolver.js +603 -0
  804. package/dist/sessions/sessions.resolver.js.map +1 -0
  805. package/dist/sessions/sessions.service.d.ts +196 -0
  806. package/dist/sessions/sessions.service.js +993 -0
  807. package/dist/sessions/sessions.service.js.map +1 -0
  808. package/dist/sessions/types/index.d.ts +347 -0
  809. package/dist/sessions/types/index.js +6 -0
  810. package/dist/sessions/types/index.js.map +1 -0
  811. package/dist/storage/index.d.ts +66 -0
  812. package/dist/storage/index.js +99 -0
  813. package/dist/storage/index.js.map +1 -0
  814. package/dist/storage/storage.service.d.ts +179 -0
  815. package/dist/storage/storage.service.js +938 -0
  816. package/dist/storage/storage.service.js.map +1 -0
  817. package/dist/storage/types/index.d.ts +273 -0
  818. package/dist/storage/types/index.js +6 -0
  819. package/dist/storage/types/index.js.map +1 -0
  820. package/dist/storage/utils/storage.util.d.ts +62 -0
  821. package/dist/storage/utils/storage.util.js +623 -0
  822. package/dist/storage/utils/storage.util.js.map +1 -0
  823. package/dist/types/actions.types.d.ts +0 -0
  824. package/dist/types/actions.types.js +1 -0
  825. package/dist/types/actions.types.js.map +1 -0
  826. package/dist/types/appBuilder.types.d.ts +316 -0
  827. package/dist/types/appBuilder.types.js +3 -0
  828. package/dist/types/appBuilder.types.js.map +1 -0
  829. package/dist/types/database.types.d.ts +9 -0
  830. package/dist/types/database.types.js +3 -0
  831. package/dist/types/database.types.js.map +1 -0
  832. package/dist/types/enums.d.ts +232 -0
  833. package/dist/types/enums.js +262 -0
  834. package/dist/types/enums.js.map +1 -0
  835. package/dist/types/index.d.ts +12 -0
  836. package/dist/types/index.js +29 -0
  837. package/dist/types/index.js.map +1 -0
  838. package/dist/types/index.types.d.ts +37 -0
  839. package/dist/types/index.types.js +18 -0
  840. package/dist/types/index.types.js.map +1 -0
  841. package/dist/types/inputs.types.d.ts +114 -0
  842. package/dist/types/inputs.types.js +44 -0
  843. package/dist/types/inputs.types.js.map +1 -0
  844. package/dist/types/logs.types.d.ts +19 -0
  845. package/dist/types/logs.types.js +8 -0
  846. package/dist/types/logs.types.js.map +1 -0
  847. package/dist/types/pricing.types.d.ts +4 -0
  848. package/dist/types/pricing.types.js +3 -0
  849. package/dist/types/pricing.types.js.map +1 -0
  850. package/dist/types/processor.types.d.ts +602 -0
  851. package/dist/types/processor.types.js +19 -0
  852. package/dist/types/processor.types.js.map +1 -0
  853. package/dist/types/productsBuilder.types.d.ts +1583 -0
  854. package/dist/types/productsBuilder.types.js +303 -0
  855. package/dist/types/productsBuilder.types.js.map +1 -0
  856. package/dist/types/request-tracker.interface.d.ts +0 -0
  857. package/dist/types/request-tracker.interface.js +1 -0
  858. package/dist/types/request-tracker.interface.js.map +1 -0
  859. package/dist/types/requests.types.d.ts +8 -0
  860. package/dist/types/requests.types.js +3 -0
  861. package/dist/types/requests.types.js.map +1 -0
  862. package/dist/types/workspaces.types.d.ts +28 -0
  863. package/dist/types/workspaces.types.js +4 -0
  864. package/dist/types/workspaces.types.js.map +1 -0
  865. package/dist/utils/constants.d.ts +1 -0
  866. package/dist/utils/constants.js +5 -0
  867. package/dist/utils/constants.js.map +1 -0
  868. package/dist/utils/index.d.ts +2 -0
  869. package/dist/utils/index.js +109 -0
  870. package/dist/utils/index.js.map +1 -0
  871. package/dist/vector/actions/action-manager.d.ts +140 -0
  872. package/dist/vector/actions/action-manager.js +356 -0
  873. package/dist/vector/actions/action-manager.js.map +1 -0
  874. package/dist/vector/adapters/base.adapter.d.ts +169 -0
  875. package/dist/vector/adapters/base.adapter.js +218 -0
  876. package/dist/vector/adapters/base.adapter.js.map +1 -0
  877. package/dist/vector/adapters/index.d.ts +10 -0
  878. package/dist/vector/adapters/index.js +19 -0
  879. package/dist/vector/adapters/index.js.map +1 -0
  880. package/dist/vector/adapters/memory.adapter.d.ts +85 -0
  881. package/dist/vector/adapters/memory.adapter.js +505 -0
  882. package/dist/vector/adapters/memory.adapter.js.map +1 -0
  883. package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
  884. package/dist/vector/adapters/pinecone.adapter.js +433 -0
  885. package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
  886. package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
  887. package/dist/vector/adapters/qdrant.adapter.js +442 -0
  888. package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
  889. package/dist/vector/adapters/weaviate.adapter.d.ts +68 -0
  890. package/dist/vector/adapters/weaviate.adapter.js +661 -0
  891. package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
  892. package/dist/vector/index.d.ts +37 -0
  893. package/dist/vector/index.js +72 -0
  894. package/dist/vector/index.js.map +1 -0
  895. package/dist/vector/types/action.interface.d.ts +195 -0
  896. package/dist/vector/types/action.interface.js +100 -0
  897. package/dist/vector/types/action.interface.js.map +1 -0
  898. package/dist/vector/types/connection.interface.d.ts +151 -0
  899. package/dist/vector/types/connection.interface.js +8 -0
  900. package/dist/vector/types/connection.interface.js.map +1 -0
  901. package/dist/vector/types/embedding.interface.d.ts +144 -0
  902. package/dist/vector/types/embedding.interface.js +8 -0
  903. package/dist/vector/types/embedding.interface.js.map +1 -0
  904. package/dist/vector/types/enums.d.ts +104 -0
  905. package/dist/vector/types/enums.js +113 -0
  906. package/dist/vector/types/enums.js.map +1 -0
  907. package/dist/vector/types/index.d.ts +11 -0
  908. package/dist/vector/types/index.js +23 -0
  909. package/dist/vector/types/index.js.map +1 -0
  910. package/dist/vector/types/vector.interface.d.ts +315 -0
  911. package/dist/vector/types/vector.interface.js +8 -0
  912. package/dist/vector/types/vector.interface.js.map +1 -0
  913. package/dist/vector/utils/index.d.ts +7 -0
  914. package/dist/vector/utils/index.js +13 -0
  915. package/dist/vector/utils/index.js.map +1 -0
  916. package/dist/vector/utils/metadata-schema.d.ts +14 -0
  917. package/dist/vector/utils/metadata-schema.js +79 -0
  918. package/dist/vector/utils/metadata-schema.js.map +1 -0
  919. package/dist/vector/utils/vector-error.d.ts +69 -0
  920. package/dist/vector/utils/vector-error.js +116 -0
  921. package/dist/vector/utils/vector-error.js.map +1 -0
  922. package/dist/vector/vector-database.service.d.ts +511 -0
  923. package/dist/vector/vector-database.service.js +1073 -0
  924. package/dist/vector/vector-database.service.js.map +1 -0
  925. package/dist/vector/vector.service.d.ts +283 -0
  926. package/dist/vector/vector.service.js +544 -0
  927. package/dist/vector/vector.service.js.map +1 -0
  928. package/dist/warehouse/executor/index.d.ts +5 -0
  929. package/dist/warehouse/executor/index.js +12 -0
  930. package/dist/warehouse/executor/index.js.map +1 -0
  931. package/dist/warehouse/executor/joins/index.d.ts +5 -0
  932. package/dist/warehouse/executor/joins/index.js +11 -0
  933. package/dist/warehouse/executor/joins/index.js.map +1 -0
  934. package/dist/warehouse/executor/joins/join-executor.d.ts +101 -0
  935. package/dist/warehouse/executor/joins/join-executor.js +493 -0
  936. package/dist/warehouse/executor/joins/join-executor.js.map +1 -0
  937. package/dist/warehouse/executor/joins/semantic-join.d.ts +64 -0
  938. package/dist/warehouse/executor/joins/semantic-join.js +241 -0
  939. package/dist/warehouse/executor/joins/semantic-join.js.map +1 -0
  940. package/dist/warehouse/executor/single-source-executor.d.ts +155 -0
  941. package/dist/warehouse/executor/single-source-executor.js +573 -0
  942. package/dist/warehouse/executor/single-source-executor.js.map +1 -0
  943. package/dist/warehouse/index.d.ts +79 -0
  944. package/dist/warehouse/index.js +111 -0
  945. package/dist/warehouse/index.js.map +1 -0
  946. package/dist/warehouse/parser/index.d.ts +4 -0
  947. package/dist/warehouse/parser/index.js +10 -0
  948. package/dist/warehouse/parser/index.js.map +1 -0
  949. package/dist/warehouse/parser/query-parser.d.ts +181 -0
  950. package/dist/warehouse/parser/query-parser.js +415 -0
  951. package/dist/warehouse/parser/query-parser.js.map +1 -0
  952. package/dist/warehouse/registry/data-source-registry.d.ts +207 -0
  953. package/dist/warehouse/registry/data-source-registry.js +396 -0
  954. package/dist/warehouse/registry/data-source-registry.js.map +1 -0
  955. package/dist/warehouse/registry/index.d.ts +4 -0
  956. package/dist/warehouse/registry/index.js +9 -0
  957. package/dist/warehouse/registry/index.js.map +1 -0
  958. package/dist/warehouse/transactions/index.d.ts +4 -0
  959. package/dist/warehouse/transactions/index.js +9 -0
  960. package/dist/warehouse/transactions/index.js.map +1 -0
  961. package/dist/warehouse/transactions/saga-orchestrator.d.ts +92 -0
  962. package/dist/warehouse/transactions/saga-orchestrator.js +383 -0
  963. package/dist/warehouse/transactions/saga-orchestrator.js.map +1 -0
  964. package/dist/warehouse/types/index.d.ts +9 -0
  965. package/dist/warehouse/types/index.js +33 -0
  966. package/dist/warehouse/types/index.js.map +1 -0
  967. package/dist/warehouse/types/join.interface.d.ts +225 -0
  968. package/dist/warehouse/types/join.interface.js +87 -0
  969. package/dist/warehouse/types/join.interface.js.map +1 -0
  970. package/dist/warehouse/types/query.interface.d.ts +232 -0
  971. package/dist/warehouse/types/query.interface.js +9 -0
  972. package/dist/warehouse/types/query.interface.js.map +1 -0
  973. package/dist/warehouse/types/transaction.interface.d.ts +236 -0
  974. package/dist/warehouse/types/transaction.interface.js +74 -0
  975. package/dist/warehouse/types/transaction.interface.js.map +1 -0
  976. package/dist/warehouse/types/where.interface.d.ts +208 -0
  977. package/dist/warehouse/types/where.interface.js +89 -0
  978. package/dist/warehouse/types/where.interface.js.map +1 -0
  979. package/dist/warehouse/warehouse.service.d.ts +200 -0
  980. package/dist/warehouse/warehouse.service.js +470 -0
  981. package/dist/warehouse/warehouse.service.js.map +1 -0
  982. package/dist/workflows/index.d.ts +30 -0
  983. package/dist/workflows/index.js +64 -0
  984. package/dist/workflows/index.js.map +1 -0
  985. package/dist/workflows/types/index.d.ts +6 -0
  986. package/dist/workflows/types/index.js +23 -0
  987. package/dist/workflows/types/index.js.map +1 -0
  988. package/dist/workflows/types/workflows.types.d.ts +1095 -0
  989. package/dist/workflows/types/workflows.types.js +13 -0
  990. package/dist/workflows/types/workflows.types.js.map +1 -0
  991. package/dist/workflows/workflow-builder.d.ts +70 -0
  992. package/dist/workflows/workflow-builder.js +353 -0
  993. package/dist/workflows/workflow-builder.js.map +1 -0
  994. package/dist/workflows/workflow-executor.d.ts +289 -0
  995. package/dist/workflows/workflow-executor.js +2467 -0
  996. package/dist/workflows/workflow-executor.js.map +1 -0
  997. package/dist/workflows/workflows.service.d.ts +412 -0
  998. package/dist/workflows/workflows.service.js +2233 -0
  999. package/dist/workflows/workflows.service.js.map +1 -0
  1000. package/package.json +3 -2
@@ -0,0 +1,2684 @@
1
+ "use strict";
2
+ /**
3
+ * Graph Service
4
+ *
5
+ * Main service class for graph database operations.
6
+ * Provides a unified API for working with different graph databases
7
+ * (Neo4j, Neptune, ArangoDB, Memgraph).
8
+ *
9
+ * Based on Ductape Graph API documentation.
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.GraphService = void 0;
49
+ const adapter_factory_1 = require("./adapters/adapter.factory");
50
+ const transaction_manager_1 = require("./transactions/transaction-manager");
51
+ const graph_error_1 = require("./utils/graph-error");
52
+ const products_service_1 = __importDefault(require("../products/services/products.service"));
53
+ const productsBuilder_types_1 = require("../types/productsBuilder.types");
54
+ const cache_manager_1 = require("../cache/cache.manager");
55
+ const processor_service_1 = __importDefault(require("../processor/services/processor.service"));
56
+ const crypto_1 = require("crypto");
57
+ const logs_service_1 = __importDefault(require("../logs/logs.service"));
58
+ const logs_types_1 = require("../logs/logs.types");
59
+ const processor_utils_1 = require("../processor/utils/processor.utils");
60
+ const secrets_1 = require("../secrets");
61
+ const cloud_runtime_util_1 = require("../cloud/cloud-runtime.util");
62
+ const sharedGraphRegistry = new Map();
63
+ const sharedGraphConnectInFlight = new Map();
64
+ function getSharedGraphKey(workspaceId, product, graph, env) {
65
+ return `${workspaceId}:${product}:${graph}:${env}`;
66
+ }
67
+ /** Log debounce: avoid duplicate connect logs across instances */
68
+ const lastGraphConnectLogAt = new Map();
69
+ const GRAPH_CONNECT_LOG_DEBOUNCE_MS = 15000;
70
+ /**
71
+ * Main graph database service
72
+ */
73
+ class GraphService {
74
+ constructor(config) {
75
+ /** Cache of adapters by connection key */
76
+ this.adapters = new Map();
77
+ /** Connection contexts */
78
+ this.connectionContexts = new Map();
79
+ /** Currently active connection context */
80
+ this.currentContext = null;
81
+ /** Transaction manager */
82
+ this.transactionManager = null;
83
+ /** Service configuration */
84
+ this.config = null;
85
+ /** Product builders cache */
86
+ this.productBuilders = new Map();
87
+ /** Local graph configurations */
88
+ this.localConfigs = new Map();
89
+ /** LogService instance for logging operations */
90
+ this.logService = null;
91
+ /** Current product ID for logging */
92
+ this.productId = '';
93
+ /** CacheManager for two-tier caching (Redis + remote) */
94
+ this.cacheManager = null;
95
+ /** Private keys cache for products (keyed by product tag) */
96
+ this.privateKeys = new Map();
97
+ this.runtimeDefaults = {};
98
+ // ==================== GRAPH ACTIONS ====================
99
+ /** Local cache of graph actions */
100
+ this.actions = new Map();
101
+ // ==================== UTILITY METHODS ====================
102
+ /** Maximum retry attempts for auto-reconnection */
103
+ this.maxReconnectRetries = 2;
104
+ /** Flag to track if reconnection is in progress */
105
+ this.reconnecting = false;
106
+ this.adapterFactory = new adapter_factory_1.GraphAdapterFactory();
107
+ if (config) {
108
+ this.config = config;
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
+ }
116
+ // Initialize CacheManager (Redis is optional - Tier 1 internal cache and Tier 3 remote cache always work)
117
+ this.cacheManager = new cache_manager_1.CacheManager({
118
+ workspace_id: config.workspace_id,
119
+ public_key: config.public_key,
120
+ user_id: config.user_id,
121
+ token: config.token,
122
+ env_type: config.env_type,
123
+ redis_client: config.redis_client, // Optional - Tier 2 cache
124
+ });
125
+ }
126
+ }
127
+ // ==================== CONFIGURATION ====================
128
+ /**
129
+ * Update service configuration
130
+ */
131
+ updateConfig(config) {
132
+ this.config = config;
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
+ }
149
+ /**
150
+ * Get service configuration
151
+ */
152
+ getConfig() {
153
+ return this.config;
154
+ }
155
+ // ==================== PRODUCT BUILDER MANAGEMENT ====================
156
+ /**
157
+ * Create a new ProductBuilder instance
158
+ */
159
+ createNewProductBuilder() {
160
+ if (!this.config) {
161
+ throw graph_error_1.GraphError.configurationError('GraphService not configured. Please provide config when initializing.');
162
+ }
163
+ return new products_service_1.default({
164
+ workspace_id: this.config.workspace_id,
165
+ public_key: this.config.public_key,
166
+ user_id: this.config.user_id,
167
+ token: this.config.token,
168
+ env_type: this.config.env_type,
169
+ access_key: this.config.access_key,
170
+ });
171
+ }
172
+ /**
173
+ * Get or create a ProductBuilder instance for the given product tag
174
+ */
175
+ async getProductBuilder(productTag) {
176
+ let builder = this.productBuilders.get(productTag);
177
+ if (!builder) {
178
+ builder = this.createNewProductBuilder();
179
+ await builder.initializeProductByTag(productTag);
180
+ this.productBuilders.set(productTag, builder);
181
+ // Update productId for logging
182
+ this.productId = builder.fetchProductId() || '';
183
+ // Cache private key for caching operations
184
+ const privateKey = builder.fetchPrivateKey();
185
+ if (privateKey) {
186
+ this.privateKeys.set(productTag, privateKey);
187
+ }
188
+ }
189
+ return builder;
190
+ }
191
+ /**
192
+ * Initialize logging service
193
+ */
194
+ initializeLogService() {
195
+ var _a;
196
+ if (!this.logService && this.config) {
197
+ this.logService = new logs_service_1.default({
198
+ product_id: this.productId,
199
+ workspace_id: this.config.workspace_id,
200
+ public_key: this.config.public_key,
201
+ user_id: this.config.user_id,
202
+ token: this.config.token,
203
+ env_type: this.config.env_type,
204
+ workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
205
+ });
206
+ }
207
+ }
208
+ /**
209
+ * Create a new ProcessorService instance for job scheduling
210
+ */
211
+ createNewProcessor() {
212
+ if (!this.config) {
213
+ throw graph_error_1.GraphError.configurationError('GraphService not configured. Please provide config when initializing.');
214
+ }
215
+ return new processor_service_1.default({
216
+ workspace_id: this.config.workspace_id,
217
+ public_key: this.config.public_key,
218
+ user_id: this.config.user_id,
219
+ token: this.config.token,
220
+ env_type: this.config.env_type,
221
+ private_key: this._privateKey,
222
+ });
223
+ }
224
+ // ==================== GRAPH REGISTRATION ====================
225
+ /**
226
+ * Register a new graph database
227
+ * As documented in getting-started.md
228
+ *
229
+ * @example
230
+ * ```ts
231
+ * await ductape.graph.create({
232
+ * name: 'Social Graph',
233
+ * tag: 'social-graph',
234
+ * type: 'neo4j',
235
+ * description: 'Stores user relationships',
236
+ * envs: [
237
+ * { slug: 'dev', connection_url: 'bolt://localhost:7687' },
238
+ * { slug: 'prd', connection_url: 'bolt://neo4j-prod:7687' },
239
+ * ],
240
+ * });
241
+ * ```
242
+ */
243
+ async create(graphConfig, productTag) {
244
+ var _a;
245
+ // Validate required fields
246
+ if (!graphConfig.name || !graphConfig.tag || !graphConfig.type || !((_a = graphConfig.envs) === null || _a === void 0 ? void 0 : _a.length)) {
247
+ throw graph_error_1.GraphError.validationError('Graph configuration requires name, tag, type, and at least one environment');
248
+ }
249
+ const exists = await this.fetchGraphByTag(productTag, graphConfig.tag);
250
+ if (exists) {
251
+ return;
252
+ }
253
+ // Validate graph type
254
+ if (!this.adapterFactory.isSupported(graphConfig.type)) {
255
+ throw graph_error_1.GraphError.validationError(`Unsupported graph type: ${graphConfig.type}. ` +
256
+ `Supported types: ${this.adapterFactory.getSupportedTypes().join(', ')}`);
257
+ }
258
+ // Process sensitive fields - store as secrets if not already secret references
259
+ const processedEnvs = [];
260
+ for (const env of graphConfig.envs) {
261
+ // Store all sensitive fields as secrets
262
+ const connectionUrl = productTag
263
+ ? await this.storeAsSecretIfNeeded(env.connection_url, productTag, graphConfig.tag, env.slug, 'url', `Graph connection URL for ${graphConfig.tag} in ${env.slug}`)
264
+ : env.connection_url;
265
+ const graphName = productTag
266
+ ? await this.storeAsSecretIfNeeded(env.graphName, productTag, graphConfig.tag, env.slug, 'graphName', `Graph name for ${graphConfig.tag} in ${env.slug}`)
267
+ : env.graphName;
268
+ const region = productTag
269
+ ? await this.storeAsSecretIfNeeded(env.region, productTag, graphConfig.tag, env.slug, 'region', `AWS region for ${graphConfig.tag} in ${env.slug}`)
270
+ : env.region;
271
+ const username = productTag
272
+ ? await this.storeAsSecretIfNeeded(env.username, productTag, graphConfig.tag, env.slug, 'username', `Username for ${graphConfig.tag} in ${env.slug}`)
273
+ : env.username;
274
+ const password = productTag
275
+ ? await this.storeAsSecretIfNeeded(env.password, productTag, graphConfig.tag, env.slug, 'password', `Password for ${graphConfig.tag} in ${env.slug}`)
276
+ : env.password;
277
+ processedEnvs.push(Object.assign(Object.assign({}, env), { connection_url: connectionUrl || env.connection_url, graphName,
278
+ region,
279
+ username,
280
+ password }));
281
+ }
282
+ // If productTag is provided, use ProductBuilder to persist to backend
283
+ if (productTag) {
284
+ const builder = await this.getProductBuilder(productTag);
285
+ const productGraph = {
286
+ name: graphConfig.name,
287
+ tag: graphConfig.tag,
288
+ description: graphConfig.description,
289
+ type: graphConfig.type,
290
+ envs: processedEnvs.map((env) => ({
291
+ slug: env.slug,
292
+ connection_url: env.connection_url,
293
+ description: env.description,
294
+ database: env.database,
295
+ graphName: env.graphName,
296
+ region: env.region,
297
+ username: env.username,
298
+ password: env.password,
299
+ })),
300
+ };
301
+ await builder.createGraph(productGraph);
302
+ }
303
+ // Create local adapters and connection contexts
304
+ const processedConfig = Object.assign(Object.assign({}, graphConfig), { envs: processedEnvs });
305
+ this.createAdapter(processedConfig);
306
+ }
307
+ /**
308
+ * Create local adapter and connection context for a graph configuration.
309
+ * This is a lightweight operation that only sets up local state without API calls.
310
+ * Use this when the graph config is already fetched/decrypted from the API.
311
+ *
312
+ * @param graphConfig - The graph configuration (already decrypted if from API)
313
+ */
314
+ createAdapter(graphConfig) {
315
+ var _a;
316
+ // Validate required fields
317
+ if (!graphConfig.tag || !graphConfig.type || !((_a = graphConfig.envs) === null || _a === void 0 ? void 0 : _a.length)) {
318
+ throw graph_error_1.GraphError.validationError('Graph configuration requires tag, type, and at least one environment');
319
+ }
320
+ // Validate graph type
321
+ if (!this.adapterFactory.isSupported(graphConfig.type)) {
322
+ throw graph_error_1.GraphError.validationError(`Unsupported graph type: ${graphConfig.type}. ` +
323
+ `Supported types: ${this.adapterFactory.getSupportedTypes().join(', ')}`);
324
+ }
325
+ // Store in local configs
326
+ this.localConfigs.set(graphConfig.tag, graphConfig);
327
+ // Create adapters and contexts for each environment
328
+ for (const envConfig of graphConfig.envs) {
329
+ const contextKey = `${graphConfig.tag}:${envConfig.slug}`;
330
+ // Skip if already exists
331
+ if (this.adapters.has(contextKey) && this.connectionContexts.has(contextKey)) {
332
+ continue;
333
+ }
334
+ const adapter = this.adapterFactory.create(graphConfig.type);
335
+ this.adapters.set(contextKey, adapter);
336
+ // Store connection context (not connected yet)
337
+ this.connectionContexts.set(contextKey, {
338
+ graph: graphConfig.tag,
339
+ env: envConfig.slug,
340
+ type: graphConfig.type,
341
+ connectionUrl: envConfig.connection_url,
342
+ connected: false,
343
+ name: graphConfig.name,
344
+ description: graphConfig.description,
345
+ database: envConfig.database,
346
+ graphName: envConfig.graphName,
347
+ username: envConfig.username,
348
+ password: envConfig.password,
349
+ region: envConfig.region,
350
+ iamAuth: envConfig.iamAuth,
351
+ authMode: envConfig.authMode,
352
+ cloudConnectionId: envConfig.cloudConnectionId,
353
+ });
354
+ }
355
+ }
356
+ /**
357
+ * Generate a secret key for graph configuration field
358
+ * Format: GRAPH_{PRODUCT}_{ASSET_TAG}_{ENV}_{KEY}
359
+ *
360
+ * Where:
361
+ * - PRODUCT = productTag.split('.')[1] (second part after workspace)
362
+ * - ASSET_TAG = if graphTag starts with same workspace prefix, use second part; otherwise sanitize full tag
363
+ * - All parts are automatically capitalized
364
+ */
365
+ generateGraphSecretKey(productTag, graphTag, envSlug, field) {
366
+ const sanitize = (str) => str.toUpperCase().replace(/[^A-Z0-9]/g, '_');
367
+ // Support both ':' and '.' delimiters for product tags (e.g., 'ductape:rematch' or 'ductape.rematch')
368
+ const productParts = productTag.includes(':') ? productTag.split(':') : productTag.split('.');
369
+ const product = productParts[1] || productParts[0]; // Use product name (index 1), fallback to index 0
370
+ const workspace = productParts[0];
371
+ // Support both ':' and '.' delimiters for graph tags
372
+ const graphParts = graphTag.includes(':') ? graphTag.split(':') : graphTag.split('.');
373
+ let assetTag;
374
+ if (graphParts.length > 1 && graphParts[0] === workspace) {
375
+ // Same workspace prefix, use second part
376
+ assetTag = graphParts[1];
377
+ }
378
+ else {
379
+ // Different or no prefix, use full tag
380
+ assetTag = graphTag;
381
+ }
382
+ return `GRAPH_${sanitize(product)}_${sanitize(assetTag)}_${sanitize(envSlug)}_${sanitize(field)}`;
383
+ }
384
+ /**
385
+ * Store a value as a secret if it exists and is not already a secret reference
386
+ * @returns The secret reference if stored, or the original value
387
+ */
388
+ async storeAsSecretIfNeeded(value, productTag, graphTag, envSlug, fieldName, description) {
389
+ if (!value) {
390
+ return undefined;
391
+ }
392
+ const secretsService = (0, secrets_1.getSecretsService)();
393
+ const secretCheck = (0, secrets_1.isSecretReference)(value);
394
+ console.log(`[GraphService.storeAsSecretIfNeeded] Processing '${fieldName}' for env '${envSlug}':`, {
395
+ isSecretReference: secretCheck.isSecret,
396
+ hasValue: !!value,
397
+ });
398
+ // If not already a secret reference and we have a secrets service, store it as a secret
399
+ if (!secretCheck.isSecret && secretsService && productTag) {
400
+ const secretKey = this.generateGraphSecretKey(productTag, graphTag, envSlug, fieldName);
401
+ try {
402
+ const exists = await secretsService.exists(secretKey);
403
+ console.log(`[GraphService.storeAsSecretIfNeeded] Secret '${secretKey}' exists:`, exists);
404
+ if (exists) {
405
+ await secretsService.update(secretKey, { value });
406
+ console.log(`[GraphService.storeAsSecretIfNeeded] Updated existing secret '${secretKey}'`);
407
+ }
408
+ else {
409
+ await secretsService.create({
410
+ key: secretKey,
411
+ value,
412
+ description,
413
+ scope: [productTag, graphTag],
414
+ envs: [envSlug],
415
+ });
416
+ console.log(`[GraphService.storeAsSecretIfNeeded] Created new secret '${secretKey}'`);
417
+ }
418
+ return `$Secret{${secretKey}}`;
419
+ }
420
+ catch (error) {
421
+ console.warn(`[GraphService.storeAsSecretIfNeeded] Failed to store '${fieldName}' as secret: ${secretKey}`, error);
422
+ // Continue with the original value
423
+ return value;
424
+ }
425
+ }
426
+ return value;
427
+ }
428
+ // ==================== PRODUCT COMPONENT FETCHING ====================
429
+ /**
430
+ * Fetch all graphs for a product using the product component fetcher
431
+ * @param productTag - The product tag
432
+ * @returns Array of IProductGraph objects
433
+ */
434
+ async fetchAllGraphs(productTag) {
435
+ const builder = await this.getProductBuilder(productTag);
436
+ return builder.fetchGraphs();
437
+ }
438
+ /**
439
+ * Fetch a specific graph by tag using the product component fetcher
440
+ * @param productTag - The product tag
441
+ * @param graphTag - The graph tag
442
+ * @returns The IProductGraph object or null if not found
443
+ */
444
+ async fetchGraphByTag(productTag, graphTag) {
445
+ const builder = await this.getProductBuilder(productTag);
446
+ return builder.fetchGraph(graphTag);
447
+ }
448
+ // ==================== GRAPH CONFIGURATION ====================
449
+ /**
450
+ * Fetch all registered graphs for a product
451
+ */
452
+ async fetchAll(productTag) {
453
+ // Return local configs if no product tag
454
+ if (!productTag) {
455
+ return Array.from(this.localConfigs.values());
456
+ }
457
+ // Fetch from API using ProductBuilder
458
+ try {
459
+ const builder = await this.getProductBuilder(productTag);
460
+ const graphs = await builder.fetchGraphs();
461
+ // Convert IProductGraph[] to IGraphConfig[]
462
+ return graphs.map((graph) => this.productGraphToConfig(graph));
463
+ }
464
+ catch (error) {
465
+ // Fall back to local configs if API fails
466
+ return Array.from(this.localConfigs.values());
467
+ }
468
+ }
469
+ /**
470
+ * Fetch a specific graph configuration
471
+ */
472
+ async fetch(graphTag, productTag) {
473
+ // If productTag is provided, fetch from API
474
+ if (productTag) {
475
+ try {
476
+ const builder = await this.getProductBuilder(productTag);
477
+ const graph = await builder.fetchGraph(graphTag);
478
+ if (graph) {
479
+ const config = this.productGraphToConfig(graph);
480
+ // Also update local cache
481
+ this.localConfigs.set(graphTag, config);
482
+ return config;
483
+ }
484
+ return null;
485
+ }
486
+ catch (error) {
487
+ // Fall back to local config
488
+ return this.localConfigs.get(graphTag) || null;
489
+ }
490
+ }
491
+ return this.localConfigs.get(graphTag) || null;
492
+ }
493
+ /**
494
+ * Update graph configuration
495
+ */
496
+ async update(graphTag, updates, productTag) {
497
+ var _a;
498
+ // If productTag is provided, use ProductBuilder to update in backend
499
+ if (productTag) {
500
+ const builder = await this.getProductBuilder(productTag);
501
+ const productGraphUpdates = {
502
+ name: updates.name,
503
+ description: updates.description,
504
+ type: updates.type,
505
+ envs: (_a = updates.envs) === null || _a === void 0 ? void 0 : _a.map((env) => ({
506
+ slug: env.slug,
507
+ connection_url: env.connection_url,
508
+ description: env.description,
509
+ database: env.database,
510
+ graphName: env.graphName,
511
+ region: env.region,
512
+ username: env.username,
513
+ password: env.password,
514
+ })),
515
+ };
516
+ await builder.updateGraph(graphTag, productGraphUpdates);
517
+ }
518
+ const existing = this.localConfigs.get(graphTag);
519
+ if (!existing && !productTag) {
520
+ throw graph_error_1.GraphError.notFoundError(`Graph '${graphTag}' not found`);
521
+ }
522
+ const updated = Object.assign(Object.assign(Object.assign({}, (existing || {})), updates), { tag: graphTag });
523
+ this.localConfigs.set(graphTag, updated);
524
+ // Update connection contexts
525
+ if (updates.envs) {
526
+ for (const envConfig of updates.envs) {
527
+ const contextKey = `${graphTag}:${envConfig.slug}`;
528
+ const existingContext = this.connectionContexts.get(contextKey);
529
+ if (existingContext) {
530
+ this.connectionContexts.set(contextKey, Object.assign(Object.assign({}, existingContext), { connectionUrl: envConfig.connection_url, database: envConfig.database, graphName: envConfig.graphName, username: envConfig.username, password: envConfig.password }));
531
+ }
532
+ }
533
+ }
534
+ }
535
+ /**
536
+ * Delete a graph configuration
537
+ */
538
+ async delete(graphTag, productTag) {
539
+ var _a;
540
+ // If productTag is provided, use ProductBuilder to delete from backend
541
+ if (productTag) {
542
+ const builder = await this.getProductBuilder(productTag);
543
+ await builder.deleteGraph(graphTag);
544
+ }
545
+ // Get local config to clean up adapters and contexts
546
+ const config = this.localConfigs.get(graphTag);
547
+ if (config) {
548
+ // Clean up adapters and contexts for each environment
549
+ for (const envConfig of config.envs) {
550
+ const contextKey = `${graphTag}:${envConfig.slug}`;
551
+ // Disconnect adapter if connected
552
+ const adapter = this.adapters.get(contextKey);
553
+ if (adapter) {
554
+ try {
555
+ await adapter.disconnect();
556
+ }
557
+ catch (error) {
558
+ // Ignore disconnect errors during cleanup
559
+ }
560
+ this.adapters.delete(contextKey);
561
+ }
562
+ // Remove connection context
563
+ this.connectionContexts.delete(contextKey);
564
+ }
565
+ // Remove from local configs
566
+ this.localConfigs.delete(graphTag);
567
+ // Clear current context if it was the deleted graph
568
+ if (((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.graph) === graphTag) {
569
+ this.currentContext = null;
570
+ this.transactionManager = null;
571
+ }
572
+ }
573
+ else if (!productTag) {
574
+ throw graph_error_1.GraphError.notFoundError(`Graph '${graphTag}' not found`);
575
+ }
576
+ }
577
+ /**
578
+ * Convert IProductGraph to IGraphConfig
579
+ */
580
+ productGraphToConfig(graph) {
581
+ return {
582
+ name: graph.name,
583
+ tag: graph.tag,
584
+ type: graph.type,
585
+ description: graph.description,
586
+ envs: graph.envs.map((env) => ({
587
+ slug: env.slug,
588
+ connection_url: env.connection_url,
589
+ description: env.description,
590
+ database: env.database,
591
+ graphName: env.graphName,
592
+ region: env.region,
593
+ iamAuth: env.iamAuth,
594
+ username: env.username,
595
+ password: env.password,
596
+ authMode: env.authMode,
597
+ cloudConnectionId: env.cloudConnectionId,
598
+ })),
599
+ };
600
+ }
601
+ // ==================== CONNECTION MANAGEMENT ====================
602
+ /**
603
+ * Connect to a graph database
604
+ * As documented in getting-started.md
605
+ *
606
+ * @example
607
+ * ```ts
608
+ * await ductape.graph.connect({
609
+ * env: 'dev',
610
+ * product: 'my-app',
611
+ * graph: 'social-graph',
612
+ * });
613
+ * ```
614
+ */
615
+ async connect(config) {
616
+ var _a, _b, _c;
617
+ config = this.mergeGraphConnectionConfig(config);
618
+ const process_id = (0, processor_utils_1.generateObjectId)();
619
+ const start = Date.now();
620
+ const contextKey = `${config.graph}:${config.env}`;
621
+ const workspaceId = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) !== null && _b !== void 0 ? _b : '';
622
+ const product = (_c = config.product) !== null && _c !== void 0 ? _c : '';
623
+ const useShared = workspaceId !== '' && product !== '';
624
+ if (useShared) {
625
+ const sharedKey = getSharedGraphKey(workspaceId, product, config.graph, config.env);
626
+ const existing = sharedGraphRegistry.get(sharedKey);
627
+ if (existing === null || existing === void 0 ? void 0 : existing.context.connected) {
628
+ this.adapters.set(contextKey, existing.adapter);
629
+ this.connectionContexts.set(contextKey, existing.context);
630
+ this.currentContext = existing.context;
631
+ this.transactionManager = new transaction_manager_1.GraphTransactionManager(existing.adapter);
632
+ return { connected: true, type: existing.context.type };
633
+ }
634
+ const inFlight = sharedGraphConnectInFlight.get(sharedKey);
635
+ if (inFlight) {
636
+ const entry = await inFlight;
637
+ this.adapters.set(contextKey, entry.adapter);
638
+ this.connectionContexts.set(contextKey, entry.context);
639
+ this.currentContext = entry.context;
640
+ this.transactionManager = new transaction_manager_1.GraphTransactionManager(entry.adapter);
641
+ return { connected: true, type: entry.context.type };
642
+ }
643
+ const createPromise = this.connectAndRegisterGraphShared(sharedKey, config, contextKey);
644
+ sharedGraphConnectInFlight.set(sharedKey, createPromise);
645
+ try {
646
+ const entry = await createPromise;
647
+ this.adapters.set(contextKey, entry.adapter);
648
+ this.connectionContexts.set(contextKey, entry.context);
649
+ this.currentContext = entry.context;
650
+ this.transactionManager = new transaction_manager_1.GraphTransactionManager(entry.adapter);
651
+ return { connected: true, type: entry.context.type };
652
+ }
653
+ finally {
654
+ sharedGraphConnectInFlight.delete(sharedKey);
655
+ }
656
+ }
657
+ let adapter = this.adapters.get(contextKey);
658
+ let context = this.connectionContexts.get(contextKey);
659
+ if (!adapter || !context) {
660
+ if (config.product)
661
+ await this.getProductBuilder(config.product);
662
+ const graphConfig = await this.fetchGraphFromProduct(config.product, config.graph);
663
+ if (!graphConfig) {
664
+ throw graph_error_1.GraphError.notFoundError(`Graph '${config.graph}' not found in product '${config.product}'`);
665
+ }
666
+ this.createAdapter(graphConfig);
667
+ adapter = this.adapters.get(contextKey);
668
+ context = this.connectionContexts.get(contextKey);
669
+ }
670
+ if (!adapter || !context) {
671
+ throw graph_error_1.GraphError.configurationError(`Failed to initialize adapter for ${contextKey}`);
672
+ }
673
+ return this.runGraphConnect(config, contextKey, adapter, context, process_id, start);
674
+ }
675
+ /**
676
+ * Disconnect any existing connection to this graph from the SDK (shared registry and this instance) before creating a fresh one.
677
+ */
678
+ async disconnectExistingForResource(sharedKey, contextKey, workspaceId, product, graph, env) {
679
+ const existingInRegistry = sharedGraphRegistry.get(sharedKey);
680
+ if (existingInRegistry) {
681
+ try {
682
+ await existingInRegistry.adapter.disconnect();
683
+ existingInRegistry.context.connected = false;
684
+ }
685
+ catch (_a) {
686
+ // Non-fatal
687
+ }
688
+ sharedGraphRegistry.delete(sharedKey);
689
+ }
690
+ const context = this.connectionContexts.get(contextKey);
691
+ if (context === null || context === void 0 ? void 0 : context.connected) {
692
+ const adapter = this.adapters.get(contextKey);
693
+ if (adapter) {
694
+ try {
695
+ if (this.transactionManager)
696
+ await this.transactionManager.rollbackAll();
697
+ await adapter.disconnect();
698
+ }
699
+ catch (_b) {
700
+ // Non-fatal
701
+ }
702
+ context.connected = false;
703
+ if (workspaceId && product) {
704
+ sharedGraphRegistry.delete(getSharedGraphKey(workspaceId, product, graph, env));
705
+ }
706
+ }
707
+ }
708
+ }
709
+ async connectAndRegisterGraphShared(sharedKey, config, contextKey) {
710
+ var _a, _b, _c;
711
+ const workspaceId = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) !== null && _b !== void 0 ? _b : '';
712
+ const product = (_c = config.product) !== null && _c !== void 0 ? _c : '';
713
+ await this.disconnectExistingForResource(sharedKey, contextKey, workspaceId, product, config.graph, config.env);
714
+ let adapter = this.adapters.get(contextKey);
715
+ let context = this.connectionContexts.get(contextKey);
716
+ if (!adapter || !context) {
717
+ if (config.product)
718
+ await this.getProductBuilder(config.product);
719
+ const graphConfig = await this.fetchGraphFromProduct(config.product, config.graph);
720
+ if (!graphConfig) {
721
+ throw graph_error_1.GraphError.notFoundError(`Graph '${config.graph}' not found in product '${config.product}'`);
722
+ }
723
+ this.createAdapter(graphConfig);
724
+ adapter = this.adapters.get(contextKey);
725
+ context = this.connectionContexts.get(contextKey);
726
+ }
727
+ await this.runGraphConnect(config, contextKey, adapter, context, (0, processor_utils_1.generateObjectId)(), Date.now());
728
+ const entry = { adapter, context };
729
+ const raceExisting = sharedGraphRegistry.get(sharedKey);
730
+ if (raceExisting) {
731
+ try {
732
+ await raceExisting.adapter.disconnect();
733
+ raceExisting.context.connected = false;
734
+ }
735
+ catch (_d) {
736
+ // Non-fatal
737
+ }
738
+ sharedGraphRegistry.delete(sharedKey);
739
+ }
740
+ sharedGraphRegistry.set(sharedKey, entry);
741
+ return entry;
742
+ }
743
+ async runGraphConnect(config, contextKey, adapter, context, process_id, start) {
744
+ var _a, _b, _c, _d, _e, _f, _g, _h;
745
+ this.initializeLogService();
746
+ const envValue = config.env || '';
747
+ const baseLogs = {
748
+ product_tag: config.product || '',
749
+ workspace_id: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) || '',
750
+ env: envValue,
751
+ app_env: envValue,
752
+ process_id,
753
+ type: logs_types_1.LogEventTypes.GRAPH,
754
+ parent_tag: config.graph,
755
+ child_tag: 'connect',
756
+ data: { graph: config.graph, env: envValue, operation: 'connect' },
757
+ };
758
+ const logKey = `${(_b = config.product) !== null && _b !== void 0 ? _b : ''}:${config.graph}:${config.env}`;
759
+ const now = Date.now();
760
+ const last = (_c = lastGraphConnectLogAt.get(logKey)) !== null && _c !== void 0 ? _c : {};
761
+ if (this.logService && (!last.initiated || now - last.initiated >= GRAPH_CONNECT_LOG_DEBOUNCE_MS)) {
762
+ lastGraphConnectLogAt.set(logKey, Object.assign(Object.assign({}, last), { initiated: now }));
763
+ this.logService.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph connect - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
764
+ }
765
+ try {
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.`);
810
+ }
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
+ }
818
+ if (!connectionUrl)
819
+ throw graph_error_1.GraphError.configurationError('Connection URL is required');
820
+ const result = await adapter.connect({
821
+ connectionUrl,
822
+ database: context.database,
823
+ graphName: graphName || context.graphName,
824
+ options: config.options,
825
+ auth: username && password ? { username, password } : undefined,
826
+ });
827
+ context.connected = result.connected;
828
+ context.product = config.product;
829
+ this.connectionContexts.set(contextKey, context);
830
+ this.currentContext = context;
831
+ this.transactionManager = new transaction_manager_1.GraphTransactionManager(adapter);
832
+ const end = Date.now();
833
+ const lastSuccess = (_g = lastGraphConnectLogAt.get(logKey)) !== null && _g !== void 0 ? _g : {};
834
+ if (this.logService && (!lastSuccess.success || end - lastSuccess.success >= GRAPH_CONNECT_LOG_DEBOUNCE_MS)) {
835
+ lastGraphConnectLogAt.set(logKey, Object.assign(Object.assign({}, lastSuccess), { success: end }));
836
+ this.logService.add(Object.assign(Object.assign({}, baseLogs), { start, end, message: 'Graph connect - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
837
+ this.logService.publish();
838
+ }
839
+ return result;
840
+ }
841
+ catch (error) {
842
+ const end = Date.now();
843
+ const lastFail = (_h = lastGraphConnectLogAt.get(logKey)) !== null && _h !== void 0 ? _h : {};
844
+ if (this.logService && (!lastFail.failed || end - lastFail.failed >= GRAPH_CONNECT_LOG_DEBOUNCE_MS)) {
845
+ lastGraphConnectLogAt.set(logKey, Object.assign(Object.assign({}, lastFail), { failed: end }));
846
+ this.logService.add(Object.assign(Object.assign({}, baseLogs), { start,
847
+ end, message: 'Graph connect - failed', failed_execution: true, data: { graph: config.graph, env: config.env, error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
848
+ await this.logService.publish();
849
+ }
850
+ throw error;
851
+ }
852
+ }
853
+ /**
854
+ * Test connection to a graph database
855
+ */
856
+ async testConnection(config) {
857
+ const contextKey = `${config.graph}:${config.env}`;
858
+ const context = this.connectionContexts.get(contextKey);
859
+ if (!context) {
860
+ throw graph_error_1.GraphError.notFoundError(`Graph configuration not found for ${config.graph}:${config.env}`);
861
+ }
862
+ const adapter = this.adapterFactory.create(context.type);
863
+ return adapter.testConnection({
864
+ connectionUrl: context.connectionUrl,
865
+ database: context.database,
866
+ graphName: context.graphName,
867
+ options: config.options,
868
+ auth: context.username && context.password ? { username: context.username, password: context.password } : undefined,
869
+ });
870
+ }
871
+ /**
872
+ * Disconnect from current graph
873
+ */
874
+ async disconnect() {
875
+ var _a, _b, _c;
876
+ if (this.currentContext) {
877
+ const contextKey = `${this.currentContext.graph}:${this.currentContext.env}`;
878
+ const adapter = this.adapters.get(contextKey);
879
+ if (adapter) {
880
+ if (this.transactionManager)
881
+ await this.transactionManager.rollbackAll();
882
+ await adapter.disconnect();
883
+ this.currentContext.connected = false;
884
+ const workspaceId = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) !== null && _b !== void 0 ? _b : '';
885
+ const product = (_c = this.currentContext.product) !== null && _c !== void 0 ? _c : '';
886
+ if (workspaceId && product) {
887
+ sharedGraphRegistry.delete(getSharedGraphKey(workspaceId, product, this.currentContext.graph, this.currentContext.env));
888
+ }
889
+ }
890
+ this.currentContext = null;
891
+ }
892
+ }
893
+ /**
894
+ * Disconnect from all graphs
895
+ */
896
+ async closeAll() {
897
+ var _a, _b, _c;
898
+ const workspaceId = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) !== null && _b !== void 0 ? _b : '';
899
+ for (const [key, adapter] of this.adapters.entries()) {
900
+ try {
901
+ await adapter.disconnect();
902
+ const context = this.connectionContexts.get(key);
903
+ if (context) {
904
+ context.connected = false;
905
+ const product = (_c = context.product) !== null && _c !== void 0 ? _c : '';
906
+ if (workspaceId && product) {
907
+ sharedGraphRegistry.delete(getSharedGraphKey(workspaceId, product, context.graph, context.env));
908
+ }
909
+ }
910
+ }
911
+ catch (error) {
912
+ console.error(`Failed to disconnect ${key}:`, error);
913
+ }
914
+ }
915
+ if (this.transactionManager)
916
+ await this.transactionManager.rollbackAll();
917
+ this.currentContext = null;
918
+ }
919
+ // ==================== NODE OPERATIONS ====================
920
+ /**
921
+ * Create a node
922
+ * As documented in nodes.md
923
+ */
924
+ async createNode(options, transaction) {
925
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
926
+ await this.ensureConnectionFor(options);
927
+ const process_id = (0, processor_utils_1.generateObjectId)();
928
+ const start = Date.now();
929
+ // Session log fields (will be populated if session is provided)
930
+ let sessionLogFields = {};
931
+ let resolvedOptions = options;
932
+ // Process session if provided
933
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
934
+ const builder = await this.getProductBuilder(this.currentContext.product);
935
+ const privateKey = builder.fetchPrivateKey();
936
+ if (privateKey) {
937
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
938
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
939
+ fetchSessionSelector: async (sessionTag) => {
940
+ const sessionConfig = await builder.fetchSession(sessionTag);
941
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
942
+ },
943
+ });
944
+ if (sessionResult.error) {
945
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
946
+ }
947
+ resolvedOptions = sessionResult.input;
948
+ sessionLogFields = sessionResult.logFields;
949
+ }
950
+ }
951
+ this.initializeLogService();
952
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
953
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
954
+ 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);
955
+ (_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 }));
956
+ try {
957
+ const adapter = this.getAdapter();
958
+ const result = await adapter.createNode(resolvedOptions, transaction);
959
+ const end = Date.now();
960
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
961
+ end, message: 'Graph createNode - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
962
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
963
+ return result;
964
+ }
965
+ catch (error) {
966
+ const end = Date.now();
967
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
968
+ end, message: 'Graph createNode - failed', failed_execution: true, data: { labels: resolvedOptions.labels, operation: 'createNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
969
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
970
+ throw error;
971
+ }
972
+ }
973
+ /**
974
+ * Find nodes by criteria
975
+ * As documented in nodes.md
976
+ */
977
+ async findNodes(options, transaction) {
978
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
979
+ await this.ensureConnectionFor(options);
980
+ const process_id = (0, processor_utils_1.generateObjectId)();
981
+ const start = Date.now();
982
+ // Session log fields (will be populated if session is provided)
983
+ let sessionLogFields = {};
984
+ let resolvedOptions = options;
985
+ // Process session if provided
986
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
987
+ const builder = await this.getProductBuilder(this.currentContext.product);
988
+ const privateKey = builder.fetchPrivateKey();
989
+ if (privateKey) {
990
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
991
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
992
+ fetchSessionSelector: async (sessionTag) => {
993
+ const sessionConfig = await builder.fetchSession(sessionTag);
994
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
995
+ },
996
+ });
997
+ if (sessionResult.error) {
998
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
999
+ }
1000
+ resolvedOptions = sessionResult.input;
1001
+ sessionLogFields = sessionResult.logFields;
1002
+ }
1003
+ }
1004
+ this.initializeLogService();
1005
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1006
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1007
+ 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);
1008
+ (_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 }));
1009
+ try {
1010
+ // Check cache if cache tag is provided
1011
+ const productTag = (_g = this.currentContext) === null || _g === void 0 ? void 0 : _g.product;
1012
+ const privateKey = productTag ? this.privateKeys.get(productTag) : undefined;
1013
+ if (resolvedOptions.cache && this.cacheManager && privateKey) {
1014
+ const cacheOptions = {
1015
+ cache_tag: resolvedOptions.cache,
1016
+ product_tag: productTag || '',
1017
+ component_tag: ((_h = this.currentContext) === null || _h === void 0 ? void 0 : _h.graph) || '',
1018
+ component_type: 'graph',
1019
+ input: {
1020
+ labels: resolvedOptions.labels,
1021
+ where: resolvedOptions.where,
1022
+ select: resolvedOptions.select,
1023
+ orderBy: resolvedOptions.orderBy,
1024
+ limit: resolvedOptions.limit,
1025
+ offset: resolvedOptions.offset,
1026
+ },
1027
+ privateKey,
1028
+ };
1029
+ const cached = await this.cacheManager.fetch(cacheOptions);
1030
+ if (cached.hit && cached.data) {
1031
+ const end = Date.now();
1032
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1033
+ end, message: `Graph findNodes - cache hit (${cached.source})`, successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS, cache_tag: resolvedOptions.cache, cache_key: cached.key, cache_status: true }));
1034
+ (_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish();
1035
+ return cached.data;
1036
+ }
1037
+ }
1038
+ const adapter = this.getAdapter();
1039
+ const result = await adapter.findNodes(resolvedOptions, transaction);
1040
+ // Store in cache if cache tag is provided
1041
+ if (resolvedOptions.cache && this.cacheManager && privateKey) {
1042
+ const cacheOptions = {
1043
+ cache_tag: resolvedOptions.cache,
1044
+ product_tag: productTag || '',
1045
+ component_tag: ((_l = this.currentContext) === null || _l === void 0 ? void 0 : _l.graph) || '',
1046
+ component_type: 'graph',
1047
+ input: {
1048
+ labels: resolvedOptions.labels,
1049
+ where: resolvedOptions.where,
1050
+ select: resolvedOptions.select,
1051
+ orderBy: resolvedOptions.orderBy,
1052
+ limit: resolvedOptions.limit,
1053
+ offset: resolvedOptions.offset,
1054
+ },
1055
+ privateKey,
1056
+ };
1057
+ this.cacheManager.store(cacheOptions, result); // Fire-and-forget
1058
+ }
1059
+ const end = Date.now();
1060
+ (_m = this.logService) === null || _m === void 0 ? void 0 : _m.add(Object.assign(Object.assign({}, baseLogs), { start,
1061
+ end, message: 'Graph findNodes - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1062
+ (_o = this.logService) === null || _o === void 0 ? void 0 : _o.publish();
1063
+ return result;
1064
+ }
1065
+ catch (error) {
1066
+ const end = Date.now();
1067
+ (_p = this.logService) === null || _p === void 0 ? void 0 : _p.add(Object.assign(Object.assign({}, baseLogs), { start,
1068
+ end, message: 'Graph findNodes - failed', failed_execution: true, data: { labels: resolvedOptions.labels, operation: 'findNodes', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1069
+ await ((_q = this.logService) === null || _q === void 0 ? void 0 : _q.publish());
1070
+ throw error;
1071
+ }
1072
+ }
1073
+ /**
1074
+ * Find a node by ID
1075
+ * As documented in nodes.md
1076
+ */
1077
+ async findNodeById(id, transaction) {
1078
+ return this.executeWithRetry(async () => {
1079
+ const adapter = this.getAdapter();
1080
+ return adapter.findNodeById(id, transaction);
1081
+ });
1082
+ }
1083
+ /**
1084
+ * Update a node
1085
+ * As documented in nodes.md
1086
+ */
1087
+ async updateNode(options, transaction) {
1088
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1089
+ await this.ensureConnectionFor(options);
1090
+ const process_id = (0, processor_utils_1.generateObjectId)();
1091
+ const start = Date.now();
1092
+ // Session log fields (will be populated if session is provided)
1093
+ let sessionLogFields = {};
1094
+ let resolvedOptions = options;
1095
+ // Process session if provided
1096
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1097
+ const builder = await this.getProductBuilder(this.currentContext.product);
1098
+ const privateKey = builder.fetchPrivateKey();
1099
+ if (privateKey) {
1100
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1101
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1102
+ fetchSessionSelector: async (sessionTag) => {
1103
+ const sessionConfig = await builder.fetchSession(sessionTag);
1104
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1105
+ },
1106
+ });
1107
+ if (sessionResult.error) {
1108
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1109
+ }
1110
+ resolvedOptions = sessionResult.input;
1111
+ sessionLogFields = sessionResult.logFields;
1112
+ }
1113
+ }
1114
+ this.initializeLogService();
1115
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1116
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1117
+ 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);
1118
+ (_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 }));
1119
+ try {
1120
+ const adapter = this.getAdapter();
1121
+ const result = await adapter.updateNode(resolvedOptions, transaction);
1122
+ const end = Date.now();
1123
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1124
+ end, message: 'Graph updateNode - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1125
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1126
+ return result;
1127
+ }
1128
+ catch (error) {
1129
+ const end = Date.now();
1130
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1131
+ end, message: 'Graph updateNode - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'updateNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1132
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1133
+ throw error;
1134
+ }
1135
+ }
1136
+ /**
1137
+ * Delete a node
1138
+ * As documented in nodes.md
1139
+ */
1140
+ async deleteNode(options, transaction) {
1141
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1142
+ await this.ensureConnectionFor(options);
1143
+ const process_id = (0, processor_utils_1.generateObjectId)();
1144
+ const start = Date.now();
1145
+ // Session log fields (will be populated if session is provided)
1146
+ let sessionLogFields = {};
1147
+ let resolvedOptions = options;
1148
+ // Process session if provided
1149
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1150
+ const builder = await this.getProductBuilder(this.currentContext.product);
1151
+ const privateKey = builder.fetchPrivateKey();
1152
+ if (privateKey) {
1153
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1154
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1155
+ fetchSessionSelector: async (sessionTag) => {
1156
+ const sessionConfig = await builder.fetchSession(sessionTag);
1157
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1158
+ },
1159
+ });
1160
+ if (sessionResult.error) {
1161
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1162
+ }
1163
+ resolvedOptions = sessionResult.input;
1164
+ sessionLogFields = sessionResult.logFields;
1165
+ }
1166
+ }
1167
+ this.initializeLogService();
1168
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1169
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1170
+ 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);
1171
+ (_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 }));
1172
+ try {
1173
+ const adapter = this.getAdapter();
1174
+ const result = await adapter.deleteNode(resolvedOptions, transaction);
1175
+ const end = Date.now();
1176
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1177
+ end, message: 'Graph deleteNode - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1178
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1179
+ return result;
1180
+ }
1181
+ catch (error) {
1182
+ const end = Date.now();
1183
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1184
+ end, message: 'Graph deleteNode - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'deleteNode', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1185
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1186
+ throw error;
1187
+ }
1188
+ }
1189
+ /**
1190
+ * Merge (upsert) a node
1191
+ * As documented in nodes.md
1192
+ */
1193
+ async mergeNode(options, transaction) {
1194
+ await this.ensureConnectionFor(options);
1195
+ return this.executeWithRetry(async () => {
1196
+ const adapter = this.getAdapter();
1197
+ return adapter.mergeNode(options, transaction);
1198
+ });
1199
+ }
1200
+ // ==================== LABEL MANAGEMENT ====================
1201
+ /**
1202
+ * Add labels to an existing node
1203
+ *
1204
+ * @example
1205
+ * ```ts
1206
+ * const result = await graphService.addLabels({
1207
+ * id: 'node-123',
1208
+ * labels: ['Admin', 'Verified'],
1209
+ * });
1210
+ * console.log(result.node.labels); // ['Person', 'Admin', 'Verified']
1211
+ * ```
1212
+ */
1213
+ async addLabels(options, transaction) {
1214
+ await this.ensureConnectionFor(options);
1215
+ return this.executeWithRetry(async () => {
1216
+ const adapter = this.getAdapter();
1217
+ return adapter.addLabels(options, transaction);
1218
+ });
1219
+ }
1220
+ /**
1221
+ * Remove labels from an existing node
1222
+ *
1223
+ * @example
1224
+ * ```ts
1225
+ * const result = await graphService.removeLabels({
1226
+ * id: 'node-123',
1227
+ * labels: ['Temporary'],
1228
+ * });
1229
+ * console.log(result.removedLabels); // ['Temporary']
1230
+ * ```
1231
+ */
1232
+ async removeLabels(options, transaction) {
1233
+ await this.ensureConnectionFor(options);
1234
+ return this.executeWithRetry(async () => {
1235
+ const adapter = this.getAdapter();
1236
+ return adapter.removeLabels(options, transaction);
1237
+ });
1238
+ }
1239
+ /**
1240
+ * Set labels on a node (replaces all existing labels)
1241
+ *
1242
+ * @example
1243
+ * ```ts
1244
+ * const result = await graphService.setLabels({
1245
+ * id: 'node-123',
1246
+ * labels: ['Person', 'Employee'],
1247
+ * });
1248
+ * console.log(result.previousLabels); // ['Person', 'Contractor']
1249
+ * console.log(result.newLabels); // ['Person', 'Employee']
1250
+ * ```
1251
+ */
1252
+ async setLabels(options, transaction) {
1253
+ await this.ensureConnectionFor(options);
1254
+ return this.executeWithRetry(async () => {
1255
+ const adapter = this.getAdapter();
1256
+ return adapter.setLabels(options, transaction);
1257
+ });
1258
+ }
1259
+ // ==================== RELATIONSHIP OPERATIONS ====================
1260
+ /**
1261
+ * Create a relationship
1262
+ * As documented in relationships.md
1263
+ */
1264
+ async createRelationship(options, transaction) {
1265
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1266
+ await this.ensureConnectionFor(options);
1267
+ const process_id = (0, processor_utils_1.generateObjectId)();
1268
+ const start = Date.now();
1269
+ this.initializeLogService();
1270
+ // Session log fields (will be populated if session is provided)
1271
+ let sessionLogFields = {};
1272
+ let resolvedOptions = options;
1273
+ // Process session if provided
1274
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1275
+ const builder = await this.getProductBuilder(this.currentContext.product);
1276
+ const privateKey = builder.fetchPrivateKey();
1277
+ if (privateKey) {
1278
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1279
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1280
+ fetchSessionSelector: async (sessionTag) => {
1281
+ const sessionConfig = await builder.fetchSession(sessionTag);
1282
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1283
+ },
1284
+ });
1285
+ if (sessionResult.error) {
1286
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1287
+ }
1288
+ resolvedOptions = sessionResult.input;
1289
+ sessionLogFields = sessionResult.logFields;
1290
+ }
1291
+ }
1292
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1293
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1294
+ 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);
1295
+ (_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 }));
1296
+ try {
1297
+ const adapter = this.getAdapter();
1298
+ const result = await adapter.createRelationship(resolvedOptions, transaction);
1299
+ const end = Date.now();
1300
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1301
+ end, message: 'Graph createRelationship - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1302
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1303
+ return result;
1304
+ }
1305
+ catch (error) {
1306
+ const end = Date.now();
1307
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1308
+ end, message: 'Graph createRelationship - failed', failed_execution: true, data: { type: resolvedOptions.type, operation: 'createRelationship', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1309
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1310
+ throw error;
1311
+ }
1312
+ }
1313
+ /**
1314
+ * Find relationships by criteria
1315
+ * As documented in relationships.md
1316
+ */
1317
+ async findRelationships(options, transaction) {
1318
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1319
+ await this.ensureConnectionFor(options);
1320
+ const process_id = (0, processor_utils_1.generateObjectId)();
1321
+ const start = Date.now();
1322
+ this.initializeLogService();
1323
+ // Session log fields (will be populated if session is provided)
1324
+ let sessionLogFields = {};
1325
+ let resolvedOptions = options;
1326
+ // Process session if provided
1327
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1328
+ const builder = await this.getProductBuilder(this.currentContext.product);
1329
+ const privateKey = builder.fetchPrivateKey();
1330
+ if (privateKey) {
1331
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1332
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1333
+ fetchSessionSelector: async (sessionTag) => {
1334
+ const sessionConfig = await builder.fetchSession(sessionTag);
1335
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1336
+ },
1337
+ });
1338
+ if (sessionResult.error) {
1339
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1340
+ }
1341
+ resolvedOptions = sessionResult.input;
1342
+ sessionLogFields = sessionResult.logFields;
1343
+ }
1344
+ }
1345
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1346
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1347
+ 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);
1348
+ (_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 }));
1349
+ try {
1350
+ const adapter = this.getAdapter();
1351
+ const result = await adapter.findRelationships(resolvedOptions, transaction);
1352
+ const end = Date.now();
1353
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1354
+ end, message: 'Graph findRelationships - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1355
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1356
+ return result;
1357
+ }
1358
+ catch (error) {
1359
+ const end = Date.now();
1360
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1361
+ end, message: 'Graph findRelationships - failed', failed_execution: true, data: { type: resolvedOptions.type, operation: 'findRelationships', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1362
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1363
+ throw error;
1364
+ }
1365
+ }
1366
+ /**
1367
+ * Find a relationship by ID
1368
+ */
1369
+ async findRelationshipById(id, transaction) {
1370
+ return this.executeWithRetry(async () => {
1371
+ const adapter = this.getAdapter();
1372
+ return adapter.findRelationshipById(id, transaction);
1373
+ });
1374
+ }
1375
+ /**
1376
+ * Update a relationship
1377
+ * As documented in relationships.md
1378
+ */
1379
+ async updateRelationship(options, transaction) {
1380
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1381
+ await this.ensureConnectionFor(options);
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 resolvedOptions = options;
1388
+ // Process session if provided
1389
+ if (options.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(options.session, privateKey, options, 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
+ resolvedOptions = sessionResult.input;
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: 'updateRelationship', data: { id: resolvedOptions.id, operation: 'updateRelationship', 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 updateRelationship - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
1411
+ try {
1412
+ const adapter = this.getAdapter();
1413
+ const result = await adapter.updateRelationship(resolvedOptions, 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 updateRelationship - 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 updateRelationship - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'updateRelationship', 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
+ }
1427
+ }
1428
+ /**
1429
+ * Delete a relationship
1430
+ * As documented in relationships.md
1431
+ */
1432
+ async deleteRelationship(options, transaction) {
1433
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1434
+ await this.ensureConnectionFor(options);
1435
+ const process_id = (0, processor_utils_1.generateObjectId)();
1436
+ const start = Date.now();
1437
+ this.initializeLogService();
1438
+ // Session log fields (will be populated if session is provided)
1439
+ let sessionLogFields = {};
1440
+ let resolvedOptions = options;
1441
+ // Process session if provided
1442
+ if (options.session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1443
+ const builder = await this.getProductBuilder(this.currentContext.product);
1444
+ const privateKey = builder.fetchPrivateKey();
1445
+ if (privateKey) {
1446
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1447
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, this.currentContext.env, {
1448
+ fetchSessionSelector: async (sessionTag) => {
1449
+ const sessionConfig = await builder.fetchSession(sessionTag);
1450
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1451
+ },
1452
+ });
1453
+ if (sessionResult.error) {
1454
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1455
+ }
1456
+ resolvedOptions = sessionResult.input;
1457
+ sessionLogFields = sessionResult.logFields;
1458
+ }
1459
+ }
1460
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1461
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1462
+ 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);
1463
+ (_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 }));
1464
+ try {
1465
+ const adapter = this.getAdapter();
1466
+ const result = await adapter.deleteRelationship(resolvedOptions, transaction);
1467
+ const end = Date.now();
1468
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1469
+ end, message: 'Graph deleteRelationship - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1470
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1471
+ return result;
1472
+ }
1473
+ catch (error) {
1474
+ const end = Date.now();
1475
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1476
+ end, message: 'Graph deleteRelationship - failed', failed_execution: true, data: { id: resolvedOptions.id, operation: 'deleteRelationship', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1477
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1478
+ throw error;
1479
+ }
1480
+ }
1481
+ /**
1482
+ * Merge (upsert) a relationship
1483
+ * As documented in relationships.md
1484
+ */
1485
+ async mergeRelationship(options, transaction) {
1486
+ await this.ensureConnectionFor(options);
1487
+ return this.executeWithRetry(async () => {
1488
+ const adapter = this.getAdapter();
1489
+ return adapter.mergeRelationship(options, transaction);
1490
+ });
1491
+ }
1492
+ // ==================== TRAVERSAL OPERATIONS ====================
1493
+ /**
1494
+ * Traverse the graph from a starting node
1495
+ * As documented in traversals.md
1496
+ */
1497
+ async traverse(options, transaction) {
1498
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1499
+ await this.ensureConnectionFor(options);
1500
+ const process_id = (0, processor_utils_1.generateObjectId)();
1501
+ const start = Date.now();
1502
+ this.initializeLogService();
1503
+ const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
1504
+ const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
1505
+ const baseLogs = {
1506
+ product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
1507
+ workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
1508
+ env: envValue,
1509
+ app_env: envValue,
1510
+ process_id,
1511
+ type: logs_types_1.LogEventTypes.GRAPH,
1512
+ parent_tag: graphValue,
1513
+ child_tag: 'traverse',
1514
+ data: { startNodeId: options.startNodeId, operation: 'traverse', graph: graphValue, env: envValue, direction: options.direction, maxDepth: options.maxDepth, relationshipTypes: options.relationshipTypes },
1515
+ };
1516
+ (_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 }));
1517
+ try {
1518
+ const adapter = this.getAdapter();
1519
+ const result = await adapter.traverse(options, transaction);
1520
+ const end = Date.now();
1521
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
1522
+ end, message: 'Graph traverse - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1523
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.publish();
1524
+ return result;
1525
+ }
1526
+ catch (error) {
1527
+ const end = Date.now();
1528
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.add(Object.assign(Object.assign({}, baseLogs), { start,
1529
+ end, message: 'Graph traverse - failed', failed_execution: true, data: { startNodeId: options.startNodeId, operation: 'traverse', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1530
+ await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
1531
+ throw error;
1532
+ }
1533
+ }
1534
+ /**
1535
+ * Find the shortest path between two nodes
1536
+ * As documented in traversals.md
1537
+ */
1538
+ async shortestPath(options, transaction) {
1539
+ await this.ensureConnectionFor(options);
1540
+ return this.executeWithRetry(async () => {
1541
+ const adapter = this.getAdapter();
1542
+ return adapter.shortestPath(options, transaction);
1543
+ });
1544
+ }
1545
+ /**
1546
+ * Find all paths between two nodes
1547
+ * As documented in traversals.md
1548
+ */
1549
+ async allPaths(options, transaction) {
1550
+ await this.ensureConnectionFor(options);
1551
+ return this.executeWithRetry(async () => {
1552
+ const adapter = this.getAdapter();
1553
+ return adapter.allPaths(options, transaction);
1554
+ });
1555
+ }
1556
+ /**
1557
+ * Get the neighborhood of a node
1558
+ * As documented in traversals.md
1559
+ */
1560
+ async getNeighborhood(options, transaction) {
1561
+ await this.ensureConnectionFor(options);
1562
+ return this.executeWithRetry(async () => {
1563
+ const adapter = this.getAdapter();
1564
+ return adapter.getNeighborhood(options, transaction);
1565
+ });
1566
+ }
1567
+ /**
1568
+ * Find connected components in the graph
1569
+ * As documented in traversals.md
1570
+ */
1571
+ async findConnectedComponents(options, transaction) {
1572
+ await this.ensureConnectionFor(options);
1573
+ return this.executeWithRetry(async () => {
1574
+ const adapter = this.getAdapter();
1575
+ return adapter.findConnectedComponents(options, transaction);
1576
+ });
1577
+ }
1578
+ // ==================== AGGREGATION OPERATIONS ====================
1579
+ /**
1580
+ * Count nodes matching criteria
1581
+ * As documented in overview.md
1582
+ */
1583
+ async countNodes(labels, where, transaction, session) {
1584
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1585
+ const process_id = (0, processor_utils_1.generateObjectId)();
1586
+ const start = Date.now();
1587
+ this.initializeLogService();
1588
+ // Session log fields (will be populated if session is provided)
1589
+ let sessionLogFields = {};
1590
+ let resolvedWhere = where;
1591
+ // Process session if provided
1592
+ if (session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1593
+ const builder = await this.getProductBuilder(this.currentContext.product);
1594
+ const privateKey = builder.fetchPrivateKey();
1595
+ if (privateKey) {
1596
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1597
+ const sessionResult = await processSessionForExecution(session, privateKey, { where }, this.currentContext.env, {
1598
+ fetchSessionSelector: async (sessionTag) => {
1599
+ const sessionConfig = await builder.fetchSession(sessionTag);
1600
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1601
+ },
1602
+ });
1603
+ if (sessionResult.error) {
1604
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1605
+ }
1606
+ resolvedWhere = sessionResult.input.where;
1607
+ sessionLogFields = sessionResult.logFields;
1608
+ }
1609
+ }
1610
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1611
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1612
+ 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);
1613
+ (_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 }));
1614
+ try {
1615
+ const adapter = this.getAdapter();
1616
+ const result = await adapter.countNodes(labels, resolvedWhere, transaction);
1617
+ const end = Date.now();
1618
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1619
+ end, message: 'Graph countNodes - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1620
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1621
+ return result;
1622
+ }
1623
+ catch (error) {
1624
+ const end = Date.now();
1625
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1626
+ end, message: 'Graph countNodes - failed', failed_execution: true, data: { labels, operation: 'countNodes', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1627
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1628
+ throw error;
1629
+ }
1630
+ }
1631
+ /**
1632
+ * Count relationships matching criteria
1633
+ * As documented in overview.md
1634
+ */
1635
+ async countRelationships(types, where, transaction) {
1636
+ return this.executeWithRetry(async () => {
1637
+ const adapter = this.getAdapter();
1638
+ return adapter.countRelationships(types, where, transaction);
1639
+ });
1640
+ }
1641
+ /**
1642
+ * Get graph statistics
1643
+ * As documented in overview.md
1644
+ */
1645
+ async getStatistics(transaction, session) {
1646
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1647
+ const process_id = (0, processor_utils_1.generateObjectId)();
1648
+ const start = Date.now();
1649
+ this.initializeLogService();
1650
+ // Session log fields (will be populated if session is provided)
1651
+ let sessionLogFields = {};
1652
+ // Process session if provided
1653
+ if (session && ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.product)) {
1654
+ const builder = await this.getProductBuilder(this.currentContext.product);
1655
+ const privateKey = builder.fetchPrivateKey();
1656
+ if (privateKey) {
1657
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
1658
+ const sessionResult = await processSessionForExecution(session, privateKey, {}, this.currentContext.env, {
1659
+ fetchSessionSelector: async (sessionTag) => {
1660
+ const sessionConfig = await builder.fetchSession(sessionTag);
1661
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
1662
+ },
1663
+ });
1664
+ if (sessionResult.error) {
1665
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
1666
+ }
1667
+ sessionLogFields = sessionResult.logFields;
1668
+ }
1669
+ }
1670
+ const envValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.env) || '';
1671
+ const graphValue = ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.graph) || '';
1672
+ 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);
1673
+ (_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 }));
1674
+ try {
1675
+ const adapter = this.getAdapter();
1676
+ const result = await adapter.getStatistics(transaction);
1677
+ const end = Date.now();
1678
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start,
1679
+ end, message: 'Graph getStatistics - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
1680
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1681
+ return result;
1682
+ }
1683
+ catch (error) {
1684
+ const end = Date.now();
1685
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1686
+ end, message: 'Graph getStatistics - failed', failed_execution: true, data: { operation: 'getStatistics', error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1687
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1688
+ throw error;
1689
+ }
1690
+ }
1691
+ // ==================== SEARCH OPERATIONS ====================
1692
+ /**
1693
+ * Full-text search
1694
+ * As documented in overview.md
1695
+ */
1696
+ async fullTextSearch(options, transaction) {
1697
+ return this.executeWithRetry(async () => {
1698
+ const adapter = this.getAdapter();
1699
+ return adapter.fullTextSearch(options, transaction);
1700
+ });
1701
+ }
1702
+ /**
1703
+ * Vector similarity search
1704
+ * As documented in overview.md
1705
+ */
1706
+ async vectorSearch(options, transaction) {
1707
+ return this.executeWithRetry(async () => {
1708
+ const adapter = this.getAdapter();
1709
+ return adapter.vectorSearch(options, transaction);
1710
+ });
1711
+ }
1712
+ // ==================== RAW QUERY ====================
1713
+ /**
1714
+ * Execute a raw query
1715
+ * As documented in overview.md
1716
+ *
1717
+ * @example
1718
+ * ```ts
1719
+ * const result = await ductape.graph.query(
1720
+ * 'MATCH (p:Person)-[:FRIENDS_WITH]->(f) WHERE p.name = $name RETURN f',
1721
+ * { name: 'Alice' }
1722
+ * );
1723
+ * ```
1724
+ */
1725
+ async query(queryString, params, transaction) {
1726
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1727
+ const process_id = (0, processor_utils_1.generateObjectId)();
1728
+ const start = Date.now();
1729
+ this.initializeLogService();
1730
+ const envValue = ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.env) || '';
1731
+ const graphValue = ((_b = this.currentContext) === null || _b === void 0 ? void 0 : _b.graph) || '';
1732
+ const baseLogs = {
1733
+ product_tag: ((_c = this.currentContext) === null || _c === void 0 ? void 0 : _c.product) || '',
1734
+ workspace_id: ((_d = this.config) === null || _d === void 0 ? void 0 : _d.workspace_id) || '',
1735
+ env: envValue,
1736
+ app_env: envValue,
1737
+ process_id,
1738
+ type: logs_types_1.LogEventTypes.GRAPH,
1739
+ parent_tag: graphValue,
1740
+ child_tag: 'query',
1741
+ data: { operation: 'query', graph: graphValue, env: envValue, query: queryString.substring(0, 200) },
1742
+ };
1743
+ (_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 }));
1744
+ try {
1745
+ const result = await this.executeWithRetry(async () => {
1746
+ const adapter = this.getAdapter();
1747
+ return adapter.query({ query: queryString, params }, transaction);
1748
+ });
1749
+ const end = Date.now();
1750
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.add(Object.assign(Object.assign({}, baseLogs), { start,
1751
+ 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 } }));
1752
+ (_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish();
1753
+ return result;
1754
+ }
1755
+ catch (error) {
1756
+ const end = Date.now();
1757
+ (_j = this.logService) === null || _j === void 0 ? void 0 : _j.add(Object.assign(Object.assign({}, baseLogs), { start,
1758
+ end, message: 'Graph query - failed', failed_execution: true, data: { operation: 'query', graph: graphValue, env: envValue, error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
1759
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
1760
+ throw error;
1761
+ }
1762
+ }
1763
+ // ==================== SCHEMA OPERATIONS ====================
1764
+ /**
1765
+ * Create a node index
1766
+ * As documented in overview.md
1767
+ */
1768
+ async createNodeIndex(options) {
1769
+ await this.ensureConnectionFor(options);
1770
+ return this.executeWithRetry(async () => {
1771
+ const adapter = this.getAdapter();
1772
+ return adapter.createNodeIndex(options);
1773
+ });
1774
+ }
1775
+ /**
1776
+ * Create a node constraint
1777
+ * As documented in overview.md
1778
+ */
1779
+ async createNodeConstraint(options) {
1780
+ await this.ensureConnectionFor(options);
1781
+ return this.executeWithRetry(async () => {
1782
+ const adapter = this.getAdapter();
1783
+ return adapter.createNodeConstraint(options);
1784
+ });
1785
+ }
1786
+ /**
1787
+ * Create a relationship index
1788
+ */
1789
+ async createRelationshipIndex(options) {
1790
+ await this.ensureConnectionFor(options);
1791
+ return this.executeWithRetry(async () => {
1792
+ const adapter = this.getAdapter();
1793
+ return adapter.createRelationshipIndex(options);
1794
+ });
1795
+ }
1796
+ /**
1797
+ * List all indexes
1798
+ * As documented in overview.md
1799
+ */
1800
+ async listIndexes() {
1801
+ return this.executeWithRetry(async () => {
1802
+ const adapter = this.getAdapter();
1803
+ return adapter.listIndexes();
1804
+ });
1805
+ }
1806
+ /**
1807
+ * List all constraints
1808
+ */
1809
+ async listConstraints() {
1810
+ return this.executeWithRetry(async () => {
1811
+ const adapter = this.getAdapter();
1812
+ return adapter.listConstraints();
1813
+ });
1814
+ }
1815
+ /**
1816
+ * Drop an index
1817
+ */
1818
+ async dropIndex(name) {
1819
+ return this.executeWithRetry(async () => {
1820
+ const adapter = this.getAdapter();
1821
+ return adapter.dropIndex(name);
1822
+ });
1823
+ }
1824
+ /**
1825
+ * Drop a constraint
1826
+ */
1827
+ async dropConstraint(name) {
1828
+ return this.executeWithRetry(async () => {
1829
+ const adapter = this.getAdapter();
1830
+ return adapter.dropConstraint(name);
1831
+ });
1832
+ }
1833
+ // ==================== SCHEMA INTROSPECTION ====================
1834
+ /**
1835
+ * List all node labels with counts and property information
1836
+ * Used for GraphExplorer sidebar
1837
+ */
1838
+ async listLabels() {
1839
+ return this.executeWithRetry(async () => {
1840
+ const adapter = this.getAdapter();
1841
+ return adapter.listLabels();
1842
+ });
1843
+ }
1844
+ /**
1845
+ * List all relationship types with counts
1846
+ * Used for GraphExplorer sidebar
1847
+ */
1848
+ async listRelationshipTypes() {
1849
+ return this.executeWithRetry(async () => {
1850
+ const adapter = this.getAdapter();
1851
+ return adapter.listRelationshipTypes();
1852
+ });
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
+ }
1879
+ /**
1880
+ * Generate a URL-safe tag from a name
1881
+ */
1882
+ generateActionTag(name) {
1883
+ return name
1884
+ .toLowerCase()
1885
+ .replace(/[^a-z0-9]+/g, '-')
1886
+ .replace(/^-+|-+$/g, '');
1887
+ }
1888
+ /**
1889
+ * Create a new graph action (saved parameterized query)
1890
+ *
1891
+ * @example
1892
+ * ```ts
1893
+ * const action = await graphService.createAction({
1894
+ * name: 'Find Persons',
1895
+ * description: 'Find persons with configurable limit',
1896
+ * operation: 'findNodes',
1897
+ * query: {
1898
+ * operation: 'findNodes',
1899
+ * options: { labels: ['Person'], limit: '{{limit}}' }
1900
+ * },
1901
+ * parameters: [
1902
+ * { name: 'limit', path: 'options.limit', defaultValue: 25, type: 'number' }
1903
+ * ]
1904
+ * }, 'my-product');
1905
+ * ```
1906
+ */
1907
+ async createAction(options, productTag) {
1908
+ var _a;
1909
+ const graphTag = options.graphTag || ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.graph);
1910
+ if (!graphTag) {
1911
+ throw graph_error_1.GraphError.configurationError('No graph specified. Please connect first or provide graphTag.');
1912
+ }
1913
+ const actionTag = this.generateActionTag(options.name);
1914
+ const now = new Date().toISOString();
1915
+ const action = {
1916
+ id: `action_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
1917
+ tag: actionTag,
1918
+ name: options.name,
1919
+ description: options.description,
1920
+ operation: options.operation,
1921
+ query: options.query,
1922
+ parameters: options.parameters,
1923
+ createdAt: now,
1924
+ graphTag,
1925
+ };
1926
+ // If productTag is provided, persist to backend using ProductBuilder
1927
+ if (productTag) {
1928
+ try {
1929
+ const builder = await this.getProductBuilder(productTag);
1930
+ await builder.createGraphAction(graphTag, action);
1931
+ }
1932
+ catch (error) {
1933
+ // Fall back to local storage if API fails
1934
+ console.warn('Failed to persist action to backend, storing locally:', error);
1935
+ }
1936
+ }
1937
+ // Store locally
1938
+ const graphActions = this.actions.get(graphTag) || [];
1939
+ graphActions.push(action);
1940
+ this.actions.set(graphTag, graphActions);
1941
+ return action;
1942
+ }
1943
+ /**
1944
+ * List all actions for a graph
1945
+ */
1946
+ async listActions(graphTag, productTag) {
1947
+ var _a;
1948
+ const tag = graphTag || ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.graph);
1949
+ if (!tag) {
1950
+ throw graph_error_1.GraphError.configurationError('No graph specified. Please connect first or provide graphTag.');
1951
+ }
1952
+ // If productTag is provided, fetch from backend using ProductBuilder
1953
+ if (productTag) {
1954
+ try {
1955
+ const builder = await this.getProductBuilder(productTag);
1956
+ const actions = await builder.fetchGraphActions(tag);
1957
+ // Update local cache
1958
+ this.actions.set(tag, actions);
1959
+ return { actions };
1960
+ }
1961
+ catch (error) {
1962
+ // Fall back to local cache
1963
+ console.warn('Failed to fetch actions from backend, using local cache:', error);
1964
+ }
1965
+ }
1966
+ const actions = this.actions.get(tag) || [];
1967
+ return { actions };
1968
+ }
1969
+ /**
1970
+ * Get a specific action by tag
1971
+ */
1972
+ async getAction(actionTag, graphTag, productTag) {
1973
+ var _a;
1974
+ const tag = graphTag || ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.graph);
1975
+ if (!tag) {
1976
+ throw graph_error_1.GraphError.configurationError('No graph specified. Please connect first or provide graphTag.');
1977
+ }
1978
+ // If productTag is provided, fetch from backend using ProductBuilder
1979
+ if (productTag) {
1980
+ try {
1981
+ const builder = await this.getProductBuilder(productTag);
1982
+ const action = await builder.fetchGraphAction(tag, actionTag);
1983
+ if (action) {
1984
+ // Update local cache
1985
+ const actions = this.actions.get(tag) || [];
1986
+ const existingIndex = actions.findIndex((a) => a.tag === actionTag);
1987
+ if (existingIndex >= 0) {
1988
+ actions[existingIndex] = action;
1989
+ }
1990
+ else {
1991
+ actions.push(action);
1992
+ }
1993
+ this.actions.set(tag, actions);
1994
+ return action;
1995
+ }
1996
+ }
1997
+ catch (error) {
1998
+ // Fall back to local cache
1999
+ console.warn('Failed to fetch action from backend, using local cache:', error);
2000
+ }
2001
+ }
2002
+ const actions = this.actions.get(tag) || [];
2003
+ return actions.find((a) => a.tag === actionTag) || null;
2004
+ }
2005
+ /**
2006
+ * Update an existing action
2007
+ */
2008
+ async updateAction(actionTag, updates, graphTag, productTag) {
2009
+ var _a, _b, _c, _d, _e;
2010
+ const tag = graphTag || ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.graph);
2011
+ if (!tag) {
2012
+ throw graph_error_1.GraphError.configurationError('No graph specified. Please connect first or provide graphTag.');
2013
+ }
2014
+ const actions = this.actions.get(tag) || [];
2015
+ const index = actions.findIndex((a) => a.tag === actionTag);
2016
+ if (index === -1) {
2017
+ throw graph_error_1.GraphError.notFoundError(`Action '${actionTag}' not found`);
2018
+ }
2019
+ const existing = actions[index];
2020
+ const updated = Object.assign(Object.assign({}, existing), { name: (_b = updates.name) !== null && _b !== void 0 ? _b : existing.name, description: (_c = updates.description) !== null && _c !== void 0 ? _c : existing.description, query: (_d = updates.query) !== null && _d !== void 0 ? _d : existing.query, parameters: (_e = updates.parameters) !== null && _e !== void 0 ? _e : existing.parameters, updatedAt: new Date().toISOString() });
2021
+ // If productTag is provided, persist to backend using ProductBuilder
2022
+ if (productTag) {
2023
+ try {
2024
+ const builder = await this.getProductBuilder(productTag);
2025
+ await builder.updateGraphAction(tag, actionTag, updated);
2026
+ }
2027
+ catch (error) {
2028
+ console.warn('Failed to update action in backend:', error);
2029
+ }
2030
+ }
2031
+ actions[index] = updated;
2032
+ this.actions.set(tag, actions);
2033
+ return updated;
2034
+ }
2035
+ /**
2036
+ * Delete an action
2037
+ */
2038
+ async deleteAction(actionTag, graphTag, productTag) {
2039
+ var _a;
2040
+ const tag = graphTag || ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.graph);
2041
+ if (!tag) {
2042
+ throw graph_error_1.GraphError.configurationError('No graph specified. Please connect first or provide graphTag.');
2043
+ }
2044
+ // If productTag is provided, delete from backend using ProductBuilder
2045
+ if (productTag) {
2046
+ try {
2047
+ const builder = await this.getProductBuilder(productTag);
2048
+ await builder.deleteGraphAction(tag, actionTag);
2049
+ }
2050
+ catch (error) {
2051
+ console.warn('Failed to delete action from backend:', error);
2052
+ }
2053
+ }
2054
+ const actions = this.actions.get(tag) || [];
2055
+ const filtered = actions.filter((a) => a.tag !== actionTag);
2056
+ if (filtered.length === actions.length) {
2057
+ throw graph_error_1.GraphError.notFoundError(`Action '${actionTag}' not found`);
2058
+ }
2059
+ this.actions.set(tag, filtered);
2060
+ }
2061
+ /**
2062
+ * Execute a graph action with parameter substitution
2063
+ *
2064
+ * @example
2065
+ * ```ts
2066
+ * const result = await graphService.execute({
2067
+ * product: 'my-app',
2068
+ * env: 'dev',
2069
+ * graph: 'social-graph',
2070
+ * action: 'find-persons',
2071
+ * input: { limit: 50 }
2072
+ * });
2073
+ * ```
2074
+ */
2075
+ async execute(options) {
2076
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2077
+ const process_id = (0, processor_utils_1.generateObjectId)();
2078
+ const startTime = Date.now();
2079
+ // Session log fields (will be populated if session is provided)
2080
+ let sessionLogFields = {};
2081
+ let resolvedOptions = options;
2082
+ // Initialize product builder and logging
2083
+ if (options.product) {
2084
+ const builder = await this.getProductBuilder(options.product);
2085
+ // Process session if provided
2086
+ if (options.session) {
2087
+ const privateKey = builder.fetchPrivateKey();
2088
+ if (privateKey) {
2089
+ const { processSessionForExecution } = await Promise.resolve().then(() => __importStar(require('../sessions')));
2090
+ const sessionResult = await processSessionForExecution(options.session, privateKey, options, options.env, {
2091
+ fetchSessionSelector: async (sessionTag) => {
2092
+ const sessionConfig = await builder.fetchSession(sessionTag);
2093
+ return sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.selector;
2094
+ },
2095
+ });
2096
+ if (sessionResult.error) {
2097
+ throw new Error(`Session validation failed: ${sessionResult.error}`);
2098
+ }
2099
+ resolvedOptions = sessionResult.input;
2100
+ sessionLogFields = sessionResult.logFields;
2101
+ }
2102
+ }
2103
+ }
2104
+ this.initializeLogService();
2105
+ const baseLogs = Object.assign({ product_tag: options.product || '', workspace_id: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) || '', env: options.env, process_id, type: logs_types_1.LogEventTypes.GRAPH, parent_tag: options.graph, child_tag: options.action, data: { graph: options.graph, action: options.action, operation: 'execute' } }, sessionLogFields);
2106
+ (_b = this.logService) === null || _b === void 0 ? void 0 : _b.add(Object.assign(Object.assign({}, baseLogs), { start: startTime, message: 'Graph action execute - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
2107
+ // Get the action
2108
+ const action = await this.getAction(resolvedOptions.action, resolvedOptions.graph);
2109
+ if (!action) {
2110
+ const end = Date.now();
2111
+ (_c = this.logService) === null || _c === void 0 ? void 0 : _c.add(Object.assign(Object.assign({}, baseLogs), { start: startTime, end, message: 'Graph action execute - failed', failed_execution: true, data: { graph: options.graph, action: options.action, error: `Action '${options.action}' not found` }, status: logs_types_1.LogEventStatus.FAIL }));
2112
+ await ((_d = this.logService) === null || _d === void 0 ? void 0 : _d.publish());
2113
+ return {
2114
+ success: false,
2115
+ executionTime: end - startTime,
2116
+ data: [],
2117
+ count: 0,
2118
+ error: `Action '${options.action}' not found`,
2119
+ };
2120
+ }
2121
+ try {
2122
+ // Build the query with parameter substitution
2123
+ const query = this.substituteParameters(action.query, action.parameters, resolvedOptions.input || {});
2124
+ // Execute based on operation type
2125
+ const result = await this.executeOperation(query);
2126
+ const end = Date.now();
2127
+ (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start: startTime, end, message: 'Graph action execute - success', successful_execution: true, status: logs_types_1.LogEventStatus.SUCCESS }));
2128
+ (_f = this.logService) === null || _f === void 0 ? void 0 : _f.publish();
2129
+ return {
2130
+ success: true,
2131
+ executionTime: end - startTime,
2132
+ data: result.data,
2133
+ count: result.data.length,
2134
+ };
2135
+ }
2136
+ catch (error) {
2137
+ const end = Date.now();
2138
+ (_g = this.logService) === null || _g === void 0 ? void 0 : _g.add(Object.assign(Object.assign({}, baseLogs), { start: startTime, end, message: 'Graph action execute - failed', failed_execution: true, data: { graph: options.graph, action: options.action, error: error.message || 'Execution failed' }, status: logs_types_1.LogEventStatus.FAIL }));
2139
+ await ((_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish());
2140
+ return {
2141
+ success: false,
2142
+ executionTime: end - startTime,
2143
+ data: [],
2144
+ count: 0,
2145
+ error: error.message || 'Execution failed',
2146
+ };
2147
+ }
2148
+ }
2149
+ // ==================== DISPATCH OPERATIONS ====================
2150
+ /**
2151
+ * Action dispatch operations - for predefined graph actions.
2152
+ */
2153
+ get action() {
2154
+ return {
2155
+ /**
2156
+ * Dispatches a graph action to run as a scheduled job.
2157
+ * @param {IGraphActionDispatchInput} data - The graph action dispatch input.
2158
+ * @returns {Promise<IDispatchResult>} The dispatch result with job ID and status.
2159
+ * @example
2160
+ * // Schedule a graph action to run in 1 hour
2161
+ * await ductape.graph.action.dispatch({
2162
+ * product: 'my-product',
2163
+ * env: 'production',
2164
+ * graph: 'social-graph',
2165
+ * event: 'compute-recommendations',
2166
+ * input: { userId: '123', limit: 10 },
2167
+ * schedule: { start_at: Date.now() + 3600000 }
2168
+ * });
2169
+ *
2170
+ * // Run on a cron schedule
2171
+ * await ductape.graph.action.dispatch({
2172
+ * product: 'my-product',
2173
+ * env: 'production',
2174
+ * graph: 'analytics-graph',
2175
+ * event: 'aggregate-metrics',
2176
+ * input: {},
2177
+ * schedule: { cron: '0 0 * * *' } // Daily at midnight
2178
+ * });
2179
+ */
2180
+ dispatch: async (data) => {
2181
+ const processorService = this.createNewProcessor();
2182
+ const productBuilder = await this.getProductBuilder(data.product);
2183
+ const schedule = data.schedule || {};
2184
+ const startAt = typeof schedule.start_at === 'string'
2185
+ ? new Date(schedule.start_at).getTime()
2186
+ : schedule.start_at || Date.now();
2187
+ // Generate job tag based on type, graph, and event
2188
+ const jobTag = `graph-action:${data.graph}:${data.event}`;
2189
+ // Check if job exists, if not create it
2190
+ const existingJob = await productBuilder.fetchJob(jobTag);
2191
+ if (!existingJob) {
2192
+ await productBuilder.createJob({
2193
+ tag: jobTag,
2194
+ name: `Graph Action: ${data.graph}/${data.event}`,
2195
+ description: `Auto-created job for graph action ${data.event} on graph ${data.graph}`,
2196
+ type: productsBuilder_types_1.JobEventTypes.GRAPH_ACTION,
2197
+ app: data.graph,
2198
+ event: data.event,
2199
+ executions: 0,
2200
+ intervals: schedule.every || 0,
2201
+ start_at: startAt,
2202
+ });
2203
+ }
2204
+ const jobInput = {
2205
+ product: data.product,
2206
+ env: data.env,
2207
+ event: jobTag,
2208
+ input: data.input,
2209
+ retries: data.retries || 0,
2210
+ start_at: startAt,
2211
+ session: data.session,
2212
+ cache: data.cache,
2213
+ repeat: schedule.cron || schedule.every
2214
+ ? {
2215
+ cron: schedule.cron,
2216
+ every: schedule.every,
2217
+ limit: schedule.limit,
2218
+ endDate: schedule.endDate,
2219
+ tz: schedule.tz,
2220
+ }
2221
+ : undefined,
2222
+ };
2223
+ await processorService.processJob(jobInput);
2224
+ const isRecurring = !!(schedule.cron || schedule.every);
2225
+ let nextRunAt;
2226
+ if (isRecurring && schedule.every) {
2227
+ nextRunAt = startAt + schedule.every;
2228
+ }
2229
+ return {
2230
+ job_id: (0, crypto_1.randomUUID)(),
2231
+ status: startAt > Date.now() ? 'scheduled' : 'queued',
2232
+ scheduled_at: startAt,
2233
+ recurring: isRecurring,
2234
+ next_run_at: nextRunAt,
2235
+ };
2236
+ },
2237
+ };
2238
+ }
2239
+ /**
2240
+ * Dispatches a graph operation to run as a scheduled job.
2241
+ * Use this for direct graph operations (traverse, query, createNode, deleteNodes, etc.).
2242
+ * @param {IGraphOperationDispatchInput} data - The graph operation dispatch input.
2243
+ * @returns {Promise<IDispatchResult>} The dispatch result with job ID and status.
2244
+ * @example
2245
+ * // Schedule a graph traversal operation
2246
+ * await ductape.graph.dispatch({
2247
+ * product: 'my-product',
2248
+ * env: 'production',
2249
+ * graph: 'social-graph',
2250
+ * operation: 'traverse',
2251
+ * input: { startNode: 'user:123', direction: 'outgoing', depth: 3 },
2252
+ * schedule: { start_at: Date.now() + 3600000 }
2253
+ * });
2254
+ *
2255
+ * // Run periodic graph cleanup
2256
+ * await ductape.graph.dispatch({
2257
+ * product: 'my-product',
2258
+ * env: 'production',
2259
+ * graph: 'session-graph',
2260
+ * operation: 'deleteNodes',
2261
+ * input: { filter: { expired: true } },
2262
+ * schedule: { cron: '0 4 * * *' } // Daily at 4 AM
2263
+ * });
2264
+ */
2265
+ async dispatch(data) {
2266
+ var _a, _b, _c, _d, _e, _f;
2267
+ const process_id = (0, processor_utils_1.generateObjectId)();
2268
+ const start = Date.now();
2269
+ const processorService = this.createNewProcessor();
2270
+ const productBuilder = await this.getProductBuilder(data.product);
2271
+ const schedule = data.schedule || {};
2272
+ const startAt = typeof schedule.start_at === 'string' ? new Date(schedule.start_at).getTime() : schedule.start_at || Date.now();
2273
+ // Generate job tag based on type, graph, and operation
2274
+ const jobTag = `graph-operation:${data.graph}:${data.operation}`;
2275
+ // Initialize logging
2276
+ this.initializeLogService();
2277
+ const baseLogs = {
2278
+ product_tag: data.product,
2279
+ workspace_id: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.workspace_id) || '',
2280
+ env: data.env,
2281
+ process_id,
2282
+ type: logs_types_1.LogEventTypes.GRAPH,
2283
+ parent_tag: data.graph,
2284
+ child_tag: data.operation,
2285
+ data: { graph: data.graph, operation: data.operation },
2286
+ };
2287
+ (_b = this.logService) === null || _b === void 0 ? void 0 : _b.add(Object.assign(Object.assign({}, baseLogs), { start, message: 'Graph dispatch - initiated', status: logs_types_1.LogEventStatus.PROCESSING }));
2288
+ try {
2289
+ // Check if job exists, if not create it
2290
+ const existingJob = await productBuilder.fetchJob(jobTag);
2291
+ if (!existingJob) {
2292
+ await productBuilder.createJob({
2293
+ tag: jobTag,
2294
+ name: `Graph Operation: ${data.graph}/${data.operation}`,
2295
+ description: `Auto-created job for graph operation ${data.operation} on graph ${data.graph}`,
2296
+ type: productsBuilder_types_1.JobEventTypes.GRAPH_OPERATION,
2297
+ app: data.graph,
2298
+ event: data.operation,
2299
+ executions: 0,
2300
+ intervals: schedule.every || 0,
2301
+ start_at: startAt,
2302
+ });
2303
+ }
2304
+ const jobInput = {
2305
+ product: data.product,
2306
+ env: data.env,
2307
+ event: jobTag,
2308
+ input: data.input,
2309
+ retries: data.retries || 0,
2310
+ start_at: startAt,
2311
+ session: data.session,
2312
+ cache: data.cache,
2313
+ repeat: schedule.cron || schedule.every
2314
+ ? {
2315
+ cron: schedule.cron,
2316
+ every: schedule.every,
2317
+ limit: schedule.limit,
2318
+ endDate: schedule.endDate,
2319
+ tz: schedule.tz,
2320
+ }
2321
+ : undefined,
2322
+ };
2323
+ await processorService.processJob(jobInput);
2324
+ const isRecurring = !!(schedule.cron || schedule.every);
2325
+ let nextRunAt;
2326
+ if (isRecurring && schedule.every) {
2327
+ nextRunAt = startAt + schedule.every;
2328
+ }
2329
+ const job_id = (0, crypto_1.randomUUID)();
2330
+ const end = Date.now();
2331
+ (_c = this.logService) === null || _c === void 0 ? void 0 : _c.add(Object.assign(Object.assign({}, baseLogs), { start,
2332
+ end, message: 'Graph dispatch - success', successful_execution: true, data: { graph: data.graph, operation: data.operation, job_id }, status: logs_types_1.LogEventStatus.SUCCESS }));
2333
+ (_d = this.logService) === null || _d === void 0 ? void 0 : _d.publish();
2334
+ return {
2335
+ job_id,
2336
+ status: startAt > Date.now() ? 'scheduled' : 'queued',
2337
+ scheduled_at: startAt,
2338
+ recurring: isRecurring,
2339
+ next_run_at: nextRunAt,
2340
+ };
2341
+ }
2342
+ catch (error) {
2343
+ const end = Date.now();
2344
+ (_e = this.logService) === null || _e === void 0 ? void 0 : _e.add(Object.assign(Object.assign({}, baseLogs), { start,
2345
+ end, message: 'Graph dispatch - failed', failed_execution: true, data: { graph: data.graph, operation: data.operation, error: String(error) }, status: logs_types_1.LogEventStatus.FAIL }));
2346
+ await ((_f = this.logService) === null || _f === void 0 ? void 0 : _f.publish());
2347
+ throw error;
2348
+ }
2349
+ }
2350
+ /**
2351
+ * Substitute parameter placeholders in a query object
2352
+ */
2353
+ substituteParameters(query, parameters, input) {
2354
+ var _a;
2355
+ // Deep clone the query
2356
+ const result = JSON.parse(JSON.stringify(query));
2357
+ // Substitute each parameter
2358
+ for (const param of parameters) {
2359
+ const value = (_a = input[param.name]) !== null && _a !== void 0 ? _a : param.defaultValue;
2360
+ this.setNestedValue(result, param.path, value);
2361
+ }
2362
+ return result;
2363
+ }
2364
+ /**
2365
+ * Set a nested value in an object using a dot-notation path
2366
+ */
2367
+ setNestedValue(obj, path, value) {
2368
+ const keys = path.replace(/\[(\d+)\]/g, '.$1').split('.');
2369
+ let current = obj;
2370
+ for (let i = 0; i < keys.length - 1; i++) {
2371
+ const key = keys[i];
2372
+ if (current[key] === undefined) {
2373
+ current[key] = {};
2374
+ }
2375
+ current = current[key];
2376
+ }
2377
+ current[keys[keys.length - 1]] = value;
2378
+ }
2379
+ /**
2380
+ * Execute an operation based on the query object
2381
+ */
2382
+ async executeOperation(query) {
2383
+ const { operation, options } = query;
2384
+ switch (operation) {
2385
+ case 'findNodes': {
2386
+ const result = await this.findNodes(options);
2387
+ return { data: result.nodes };
2388
+ }
2389
+ case 'findRelationships': {
2390
+ const result = await this.findRelationships(options);
2391
+ return { data: result.relationships };
2392
+ }
2393
+ case 'traverse': {
2394
+ const result = await this.traverse(options);
2395
+ return { data: result.paths };
2396
+ }
2397
+ case 'shortestPath': {
2398
+ const result = await this.shortestPath(options);
2399
+ return { data: result.path ? [result.path] : [] };
2400
+ }
2401
+ case 'allPaths': {
2402
+ const result = await this.allPaths(options);
2403
+ return { data: result.paths };
2404
+ }
2405
+ case 'getNeighborhood': {
2406
+ const result = await this.getNeighborhood(options);
2407
+ return { data: result.nodes };
2408
+ }
2409
+ case 'countNodes': {
2410
+ const result = await this.countNodes(options === null || options === void 0 ? void 0 : options.labels, options === null || options === void 0 ? void 0 : options.where);
2411
+ return { data: [{ count: result.count }] };
2412
+ }
2413
+ case 'countRelationships': {
2414
+ const result = await this.countRelationships(options === null || options === void 0 ? void 0 : options.types, options === null || options === void 0 ? void 0 : options.where);
2415
+ return { data: [{ count: result.count }] };
2416
+ }
2417
+ case 'getStatistics': {
2418
+ const result = await this.getStatistics();
2419
+ return { data: [result] };
2420
+ }
2421
+ case 'executeRaw':
2422
+ case 'query': {
2423
+ const result = await this.query(options.query, options.params);
2424
+ return { data: result.records };
2425
+ }
2426
+ default:
2427
+ throw new Error(`Unsupported operation: ${operation}`);
2428
+ }
2429
+ }
2430
+ // ==================== TRANSACTION OPERATIONS ====================
2431
+ /**
2432
+ * Execute operations within a transaction
2433
+ * As documented in transactions.md
2434
+ *
2435
+ * @example
2436
+ * ```ts
2437
+ * const result = await ductape.graph.executeTransaction(async (transaction) => {
2438
+ * const alice = await ductape.graph.createNode({
2439
+ * labels: ['Person'],
2440
+ * properties: { name: 'Alice' },
2441
+ * }, transaction);
2442
+ *
2443
+ * const bob = await ductape.graph.createNode({
2444
+ * labels: ['Person'],
2445
+ * properties: { name: 'Bob' },
2446
+ * }, transaction);
2447
+ *
2448
+ * await ductape.graph.createRelationship({
2449
+ * type: 'FRIENDS_WITH',
2450
+ * startNodeId: alice.node.id,
2451
+ * endNodeId: bob.node.id,
2452
+ * }, transaction);
2453
+ *
2454
+ * return { alice, bob };
2455
+ * });
2456
+ * ```
2457
+ */
2458
+ async executeTransaction(callback, options) {
2459
+ if (!this.transactionManager) {
2460
+ throw graph_error_1.GraphError.configurationError('No connection established. Please connect first.');
2461
+ }
2462
+ return this.transactionManager.executeTransaction(callback, options);
2463
+ }
2464
+ /**
2465
+ * Begin a manual transaction
2466
+ * As documented in transactions.md
2467
+ */
2468
+ async beginTransaction(options) {
2469
+ if (!this.transactionManager) {
2470
+ throw graph_error_1.GraphError.configurationError('No connection established. Please connect first.');
2471
+ }
2472
+ return this.transactionManager.beginTransaction(options);
2473
+ }
2474
+ /**
2475
+ * Commit a transaction
2476
+ */
2477
+ async commitTransaction(transaction) {
2478
+ if (!this.transactionManager) {
2479
+ throw graph_error_1.GraphError.configurationError('No connection established.');
2480
+ }
2481
+ return this.transactionManager.commitTransaction(transaction);
2482
+ }
2483
+ /**
2484
+ * Rollback a transaction
2485
+ */
2486
+ async rollbackTransaction(transaction) {
2487
+ if (!this.transactionManager) {
2488
+ throw graph_error_1.GraphError.configurationError('No connection established.');
2489
+ }
2490
+ return this.transactionManager.rollbackTransaction(transaction);
2491
+ }
2492
+ /**
2493
+ * Get the current adapter (synchronous, throws if not connected)
2494
+ */
2495
+ getAdapter() {
2496
+ if (!this.currentContext) {
2497
+ throw graph_error_1.GraphError.configurationError('No connection established. Please call connect() first.');
2498
+ }
2499
+ const contextKey = `${this.currentContext.graph}:${this.currentContext.env}`;
2500
+ const adapter = this.adapters.get(contextKey);
2501
+ if (!adapter) {
2502
+ throw graph_error_1.GraphError.configurationError(`Adapter not found for ${contextKey}`);
2503
+ }
2504
+ if (!this.currentContext.connected) {
2505
+ throw graph_error_1.GraphError.connectionError('Not connected to graph database');
2506
+ }
2507
+ return adapter;
2508
+ }
2509
+ /**
2510
+ * Ensure a connection exists for the given graph/env/product (connect on demand).
2511
+ * Use before getAdapter() when options include graph+env+product (e.g. from proxy).
2512
+ */
2513
+ async ensureConnectionFor(options) {
2514
+ if (!(options === null || options === void 0 ? void 0 : options.graph) || !(options === null || options === void 0 ? void 0 : options.env) || !(options === null || options === void 0 ? void 0 : options.product))
2515
+ return;
2516
+ const contextKey = `${options.graph}:${options.env}`;
2517
+ const existingAdapter = this.adapters.get(contextKey);
2518
+ const ctx = this.connectionContexts.get(contextKey);
2519
+ if (existingAdapter && (ctx === null || ctx === void 0 ? void 0 : ctx.connected)) {
2520
+ this.currentContext = ctx;
2521
+ this.transactionManager = new transaction_manager_1.GraphTransactionManager(existingAdapter);
2522
+ return;
2523
+ }
2524
+ await this.connect({ graph: options.graph, env: options.env, product: options.product });
2525
+ }
2526
+ /**
2527
+ * Get the current adapter with automatic reconnection on failure
2528
+ */
2529
+ async getAdapterWithReconnect() {
2530
+ if (!this.currentContext) {
2531
+ throw graph_error_1.GraphError.configurationError('No connection established. Please call connect() first.');
2532
+ }
2533
+ const contextKey = `${this.currentContext.graph}:${this.currentContext.env}`;
2534
+ const adapter = this.adapters.get(contextKey);
2535
+ if (!adapter) {
2536
+ throw graph_error_1.GraphError.configurationError(`Adapter not found for ${contextKey}`);
2537
+ }
2538
+ // If connected, return the adapter
2539
+ if (this.currentContext.connected && adapter.isConnected()) {
2540
+ return adapter;
2541
+ }
2542
+ // Connection lost - attempt to reconnect
2543
+ await this.attemptReconnect();
2544
+ // After reconnection, verify we're connected
2545
+ if (!this.currentContext.connected) {
2546
+ throw graph_error_1.GraphError.connectionError('Failed to reconnect to graph database');
2547
+ }
2548
+ return adapter;
2549
+ }
2550
+ /**
2551
+ * Attempt to reconnect to the graph database
2552
+ */
2553
+ async attemptReconnect() {
2554
+ var _a;
2555
+ if (this.reconnecting) {
2556
+ // Wait briefly if reconnection is already in progress
2557
+ await new Promise(resolve => setTimeout(resolve, 1000));
2558
+ if ((_a = this.currentContext) === null || _a === void 0 ? void 0 : _a.connected)
2559
+ return;
2560
+ throw graph_error_1.GraphError.connectionError('Reconnection already in progress');
2561
+ }
2562
+ if (!this.currentContext) {
2563
+ throw graph_error_1.GraphError.configurationError('Cannot reconnect: no connection context available');
2564
+ }
2565
+ this.reconnecting = true;
2566
+ const { graph, env, product } = this.currentContext;
2567
+ try {
2568
+ console.log(`[GraphService] Attempting to reconnect to ${graph}:${env}...`);
2569
+ // Attempt to reconnect using stored context
2570
+ await this.connect({
2571
+ graph,
2572
+ env,
2573
+ product: product || '',
2574
+ });
2575
+ console.log(`[GraphService] Successfully reconnected to ${graph}:${env}`);
2576
+ }
2577
+ catch (error) {
2578
+ console.error(`[GraphService] Failed to reconnect to ${graph}:${env}:`, error);
2579
+ throw error;
2580
+ }
2581
+ finally {
2582
+ this.reconnecting = false;
2583
+ }
2584
+ }
2585
+ /**
2586
+ * Execute an operation with automatic retry on connection errors
2587
+ */
2588
+ async executeWithRetry(operation, retries = this.maxReconnectRetries) {
2589
+ let lastError = null;
2590
+ for (let attempt = 0; attempt <= retries; attempt++) {
2591
+ try {
2592
+ // Ensure we have a connected adapter before each attempt
2593
+ await this.getAdapterWithReconnect();
2594
+ return await operation();
2595
+ }
2596
+ catch (error) {
2597
+ lastError = error;
2598
+ // Check if this is a connection error
2599
+ if (!this.isConnectionError(error) || attempt === retries) {
2600
+ throw error;
2601
+ }
2602
+ console.log(`[GraphService] Connection error on attempt ${attempt + 1}/${retries + 1}, retrying...`);
2603
+ // Mark as disconnected and try to reconnect
2604
+ if (this.currentContext) {
2605
+ this.currentContext.connected = false;
2606
+ }
2607
+ // Small delay before retry (exponential backoff)
2608
+ await new Promise(resolve => setTimeout(resolve, 500 * (attempt + 1)));
2609
+ }
2610
+ }
2611
+ throw lastError || new Error('Operation failed after retries');
2612
+ }
2613
+ /**
2614
+ * Check if an error is a connection-related error that can be retried
2615
+ * Note: "No connection established" errors are NOT retriable - they indicate
2616
+ * connect() was never called, not that a connection was lost
2617
+ */
2618
+ isConnectionError(error) {
2619
+ var _a, _b, _c;
2620
+ const errorCode = ((_a = error.code) === null || _a === void 0 ? void 0 : _a.toString()) || '';
2621
+ const errorMessage = ((_b = error.message) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || '';
2622
+ const errorType = ((_c = error.type) === null || _c === void 0 ? void 0 : _c.toString()) || '';
2623
+ // Configuration errors should NOT be retried - they require explicit connect() call
2624
+ if (errorType === 'CONFIGURATION_ERROR' || errorMessage.includes('please call connect')) {
2625
+ return false;
2626
+ }
2627
+ return (errorCode === 'ECONNRESET' ||
2628
+ errorCode === 'ETIMEDOUT' ||
2629
+ errorCode === 'ENOTFOUND' ||
2630
+ errorCode === 'ECONNREFUSED' ||
2631
+ errorCode === 'EPIPE' ||
2632
+ errorCode === 'ServiceUnavailable' ||
2633
+ errorCode === 'SessionExpired' ||
2634
+ errorMessage.includes('connection terminated') ||
2635
+ errorMessage.includes('connection timeout') ||
2636
+ errorMessage.includes('connection refused') ||
2637
+ errorMessage.includes('connection lost') ||
2638
+ errorMessage.includes('connection closed') ||
2639
+ errorMessage.includes('socket hang up') ||
2640
+ errorMessage.includes('econnreset') ||
2641
+ errorMessage.includes('network error') ||
2642
+ errorMessage.includes('session expired') ||
2643
+ errorMessage.includes('service unavailable') ||
2644
+ errorMessage.includes('no longer valid') ||
2645
+ errorMessage.includes('pool is closed'));
2646
+ }
2647
+ /**
2648
+ * Fetch graph configuration from product API
2649
+ */
2650
+ async fetchGraphFromProduct(productTag, graphTag) {
2651
+ try {
2652
+ const builder = await this.getProductBuilder(productTag);
2653
+ const graph = await builder.fetchGraph(graphTag);
2654
+ if (graph) {
2655
+ return this.productGraphToConfig(graph);
2656
+ }
2657
+ return null;
2658
+ }
2659
+ catch (error) {
2660
+ console.warn(`[GraphService] Failed to fetch graph '${graphTag}' from product '${productTag}':`, error);
2661
+ return null;
2662
+ }
2663
+ }
2664
+ /**
2665
+ * Get current connection context
2666
+ */
2667
+ getCurrentContext() {
2668
+ return this.currentContext;
2669
+ }
2670
+ /**
2671
+ * Check if a feature is supported by the current adapter
2672
+ */
2673
+ supportsFeature(feature) {
2674
+ try {
2675
+ const adapter = this.getAdapter();
2676
+ return adapter.supportsFeature(feature);
2677
+ }
2678
+ catch (_a) {
2679
+ return false;
2680
+ }
2681
+ }
2682
+ }
2683
+ exports.GraphService = GraphService;
2684
+ //# sourceMappingURL=graphs.service.js.map