@ductape/sdk 0.0.4 → 0.0.6

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