@ductape/sdk 0.0.4-v51 → 0.0.4-v52

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 (868) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/agent-context.d.ts +98 -0
  3. package/dist/agents/agent-context.js +588 -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 +304 -0
  9. package/dist/agents/agents.service.js +1244 -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 +1225 -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.js +4 -5
  30. package/dist/api/services/appApi.service.js.map +1 -1
  31. package/dist/api/services/processorApi.service.d.ts +322 -0
  32. package/dist/api/services/processorApi.service.js +252 -0
  33. package/dist/api/services/processorApi.service.js.map +1 -1
  34. package/dist/api/services/productsApi.service.d.ts +69 -1
  35. package/dist/api/services/productsApi.service.js +67 -31
  36. package/dist/api/services/productsApi.service.js.map +1 -1
  37. package/dist/api/services/resilienceApi.service.d.ts +106 -0
  38. package/dist/api/services/resilienceApi.service.js +224 -0
  39. package/dist/api/services/resilienceApi.service.js.map +1 -0
  40. package/dist/api/services/secretsApi.service.d.ts +38 -0
  41. package/dist/api/services/secretsApi.service.js +96 -0
  42. package/dist/api/services/secretsApi.service.js.map +1 -0
  43. package/dist/api/services/userApi.service.js +0 -1
  44. package/dist/api/services/userApi.service.js.map +1 -1
  45. package/dist/api/services/workflowApi.service.d.ts +199 -0
  46. package/dist/api/services/workflowApi.service.js +183 -0
  47. package/dist/api/services/workflowApi.service.js.map +1 -0
  48. package/dist/api/services/workspaceApi.service.js +0 -1
  49. package/dist/api/services/workspaceApi.service.js.map +1 -1
  50. package/dist/api/urls.d.ts +57 -0
  51. package/dist/api/urls.js +68 -1
  52. package/dist/api/urls.js.map +1 -1
  53. package/dist/api/utils/cache.utils.js +4 -10
  54. package/dist/api/utils/cache.utils.js.map +1 -1
  55. package/dist/apps/services/app.service.d.ts +0 -10
  56. package/dist/apps/services/app.service.js +74 -30
  57. package/dist/apps/services/app.service.js.map +1 -1
  58. package/dist/apps/utils/auth-context-manager.d.ts +137 -0
  59. package/dist/apps/utils/auth-context-manager.js +248 -0
  60. package/dist/apps/utils/auth-context-manager.js.map +1 -0
  61. package/dist/apps/utils/credential-manager.d.ts +128 -0
  62. package/dist/apps/utils/credential-manager.js +199 -0
  63. package/dist/apps/utils/credential-manager.js.map +1 -0
  64. package/dist/apps/utils/index.d.ts +10 -0
  65. package/dist/apps/utils/index.js +54 -0
  66. package/dist/apps/utils/index.js.map +1 -0
  67. package/dist/apps/utils/input-helpers.d.ts +67 -0
  68. package/dist/apps/utils/input-helpers.js +185 -0
  69. package/dist/apps/utils/input-helpers.js.map +1 -0
  70. package/dist/apps/utils/input-resolver.d.ts +165 -0
  71. package/dist/apps/utils/input-resolver.js +477 -0
  72. package/dist/apps/utils/input-resolver.js.map +1 -0
  73. package/dist/apps/utils/oauth-manager.d.ts +196 -0
  74. package/dist/apps/utils/oauth-manager.js +405 -0
  75. package/dist/apps/utils/oauth-manager.js.map +1 -0
  76. package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +2 -1
  77. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +15 -2
  78. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
  79. package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +2 -1
  80. package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +14 -2
  81. package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
  82. package/dist/bin.d.ts +26 -0
  83. package/dist/bin.js +28 -0
  84. package/dist/bin.js.map +1 -0
  85. package/dist/brokers/brokers.service.d.ts +257 -0
  86. package/dist/brokers/brokers.service.js +604 -0
  87. package/dist/brokers/brokers.service.js.map +1 -0
  88. package/dist/brokers/index.d.ts +46 -0
  89. package/dist/brokers/index.js +83 -0
  90. package/dist/brokers/index.js.map +1 -0
  91. package/dist/brokers/types/index.d.ts +288 -0
  92. package/dist/brokers/types/index.js +8 -0
  93. package/dist/brokers/types/index.js.map +1 -0
  94. package/dist/brokers/utils/broker.util.d.ts +33 -0
  95. package/dist/brokers/utils/broker.util.js +125 -0
  96. package/dist/brokers/utils/broker.util.js.map +1 -0
  97. package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
  98. package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
  99. package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
  100. package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
  101. package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
  102. package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
  103. package/dist/brokers/utils/providers/index.d.ts +6 -0
  104. package/dist/brokers/utils/providers/index.js +16 -0
  105. package/dist/brokers/utils/providers/index.js.map +1 -0
  106. package/dist/brokers/utils/providers/kafka.service.d.ts +16 -0
  107. package/dist/brokers/utils/providers/kafka.service.js +52 -0
  108. package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
  109. package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
  110. package/dist/brokers/utils/providers/nats.service.js +63 -0
  111. package/dist/brokers/utils/providers/nats.service.js.map +1 -0
  112. package/dist/brokers/utils/providers/rabbitmq.service.d.ts +14 -0
  113. package/dist/brokers/utils/providers/rabbitmq.service.js +67 -0
  114. package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
  115. package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
  116. package/dist/brokers/utils/providers/redis.service.js +93 -0
  117. package/dist/brokers/utils/providers/redis.service.js.map +1 -0
  118. package/dist/cache/cache.manager.d.ts +159 -0
  119. package/dist/cache/cache.manager.js +265 -0
  120. package/dist/cache/cache.manager.js.map +1 -0
  121. package/dist/cache/cache.service.d.ts +186 -0
  122. package/dist/cache/cache.service.js +437 -0
  123. package/dist/cache/cache.service.js.map +1 -0
  124. package/dist/cache/index.d.ts +52 -0
  125. package/dist/cache/index.js +79 -0
  126. package/dist/cache/index.js.map +1 -0
  127. package/dist/cache/types/index.d.ts +106 -0
  128. package/dist/cache/types/index.js +6 -0
  129. package/dist/cache/types/index.js.map +1 -0
  130. package/dist/database/actions/action-manager.d.ts +170 -0
  131. package/dist/database/actions/action-manager.js +465 -0
  132. package/dist/database/actions/action-manager.js.map +1 -0
  133. package/dist/database/actions/index.d.ts +6 -0
  134. package/dist/database/actions/index.js +13 -0
  135. package/dist/database/actions/index.js.map +1 -0
  136. package/dist/database/adapters/adapter.factory.d.ts +62 -0
  137. package/dist/database/adapters/adapter.factory.js +97 -0
  138. package/dist/database/adapters/adapter.factory.js.map +1 -0
  139. package/dist/database/adapters/base.adapter.d.ts +307 -90
  140. package/dist/database/adapters/base.adapter.js +139 -20
  141. package/dist/database/adapters/base.adapter.js.map +1 -1
  142. package/dist/database/adapters/cassandra.adapter.d.ts +90 -0
  143. package/dist/database/adapters/cassandra.adapter.js +1019 -0
  144. package/dist/database/adapters/cassandra.adapter.js.map +1 -0
  145. package/dist/database/adapters/dynamodb.adapter.d.ts +94 -77
  146. package/dist/database/adapters/dynamodb.adapter.js +1162 -1305
  147. package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
  148. package/dist/database/adapters/index.d.ts +11 -0
  149. package/dist/database/adapters/index.js +27 -0
  150. package/dist/database/adapters/index.js.map +1 -0
  151. package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
  152. package/dist/database/adapters/mariadb.adapter.js +247 -0
  153. package/dist/database/adapters/mariadb.adapter.js.map +1 -0
  154. package/dist/database/adapters/mongodb.adapter.d.ts +105 -57
  155. package/dist/database/adapters/mongodb.adapter.js +941 -838
  156. package/dist/database/adapters/mongodb.adapter.js.map +1 -1
  157. package/dist/database/adapters/mysql.adapter.d.ts +76 -138
  158. package/dist/database/adapters/mysql.adapter.js +990 -1246
  159. package/dist/database/adapters/mysql.adapter.js.map +1 -1
  160. package/dist/database/adapters/postgresql.adapter.d.ts +75 -139
  161. package/dist/database/adapters/postgresql.adapter.js +1076 -1346
  162. package/dist/database/adapters/postgresql.adapter.js.map +1 -1
  163. package/dist/database/databases.service.d.ts +1374 -0
  164. package/dist/database/databases.service.js +2680 -0
  165. package/dist/database/databases.service.js.map +1 -0
  166. package/dist/database/index.d.ts +41 -13
  167. package/dist/database/index.js +97 -86
  168. package/dist/database/index.js.map +1 -1
  169. package/dist/database/migrations/index.d.ts +6 -0
  170. package/dist/database/migrations/index.js +12 -0
  171. package/dist/database/migrations/index.js.map +1 -0
  172. package/dist/database/migrations/migration-engine.d.ts +132 -0
  173. package/dist/database/migrations/migration-engine.js +1356 -0
  174. package/dist/database/migrations/migration-engine.js.map +1 -0
  175. package/dist/database/operators/aggregation-builder.d.ts +64 -0
  176. package/dist/database/operators/aggregation-builder.js +746 -0
  177. package/dist/database/operators/aggregation-builder.js.map +1 -0
  178. package/dist/database/operators/index.d.ts +7 -0
  179. package/dist/database/operators/index.js +15 -0
  180. package/dist/database/operators/index.js.map +1 -0
  181. package/dist/database/operators/query-builder.d.ts +55 -0
  182. package/dist/database/operators/query-builder.js +365 -0
  183. package/dist/database/operators/query-builder.js.map +1 -0
  184. package/dist/database/presave/decrypt.d.ts +25 -0
  185. package/dist/database/presave/decrypt.js +146 -0
  186. package/dist/database/presave/decrypt.js.map +1 -0
  187. package/dist/database/presave/index.d.ts +9 -0
  188. package/dist/database/presave/index.js +18 -0
  189. package/dist/database/presave/index.js.map +1 -0
  190. package/dist/database/presave/presave-processor.d.ts +148 -0
  191. package/dist/database/presave/presave-processor.js +702 -0
  192. package/dist/database/presave/presave-processor.js.map +1 -0
  193. package/dist/database/schema/index.d.ts +7 -0
  194. package/dist/database/schema/index.js +13 -0
  195. package/dist/database/schema/index.js.map +1 -0
  196. package/dist/database/schema/schema-manager.d.ts +258 -0
  197. package/dist/database/schema/schema-manager.js +637 -0
  198. package/dist/database/schema/schema-manager.js.map +1 -0
  199. package/dist/database/transactions/index.d.ts +6 -0
  200. package/dist/database/transactions/index.js +13 -0
  201. package/dist/database/transactions/index.js.map +1 -0
  202. package/dist/database/transactions/transaction-manager.d.ts +113 -0
  203. package/dist/database/transactions/transaction-manager.js +344 -0
  204. package/dist/database/transactions/transaction-manager.js.map +1 -0
  205. package/dist/database/triggers/index.d.ts +7 -0
  206. package/dist/database/triggers/index.js +14 -0
  207. package/dist/database/triggers/index.js.map +1 -0
  208. package/dist/database/triggers/trigger-processor.d.ts +239 -0
  209. package/dist/database/triggers/trigger-processor.js +1034 -0
  210. package/dist/database/triggers/trigger-processor.js.map +1 -0
  211. package/dist/database/types/action.interface.d.ts +148 -0
  212. package/dist/database/types/action.interface.js +6 -0
  213. package/dist/database/types/action.interface.js.map +1 -0
  214. package/dist/database/types/aggregation.interface.d.ts +179 -0
  215. package/dist/database/types/aggregation.interface.js +6 -0
  216. package/dist/database/types/aggregation.interface.js.map +1 -0
  217. package/dist/database/types/connection.interface.d.ts +137 -0
  218. package/dist/database/types/connection.interface.js +6 -0
  219. package/dist/database/types/connection.interface.js.map +1 -0
  220. package/dist/database/types/enums.d.ts +195 -0
  221. package/dist/database/types/enums.js +244 -0
  222. package/dist/database/types/enums.js.map +1 -0
  223. package/dist/database/types/index.d.ts +12 -10
  224. package/dist/database/types/index.js +26 -32
  225. package/dist/database/types/index.js.map +1 -1
  226. package/dist/database/types/migration.interface.d.ts +686 -0
  227. package/dist/database/types/migration.interface.js +9 -0
  228. package/dist/database/types/migration.interface.js.map +1 -0
  229. package/dist/database/types/presave.interface.d.ts +292 -0
  230. package/dist/database/types/presave.interface.js +60 -0
  231. package/dist/database/types/presave.interface.js.map +1 -0
  232. package/dist/database/types/query.interface.d.ts +199 -0
  233. package/dist/database/types/query.interface.js +6 -0
  234. package/dist/database/types/query.interface.js.map +1 -0
  235. package/dist/database/types/schema.interface.d.ts +398 -0
  236. package/dist/database/types/schema.interface.js +6 -0
  237. package/dist/database/types/schema.interface.js.map +1 -0
  238. package/dist/database/types/transaction.interface.d.ts +84 -0
  239. package/dist/database/types/transaction.interface.js +6 -0
  240. package/dist/database/types/transaction.interface.js.map +1 -0
  241. package/dist/database/types/trigger.interface.d.ts +612 -0
  242. package/dist/database/types/trigger.interface.js +121 -0
  243. package/dist/database/types/trigger.interface.js.map +1 -0
  244. package/dist/database/types/write.interface.d.ts +208 -0
  245. package/dist/database/types/write.interface.js +6 -0
  246. package/dist/database/types/write.interface.js.map +1 -0
  247. package/dist/database/utils/database-error.d.ts +96 -0
  248. package/dist/database/utils/database-error.js +221 -0
  249. package/dist/database/utils/database-error.js.map +1 -0
  250. package/dist/database/utils/index.d.ts +6 -0
  251. package/dist/database/utils/index.js +11 -0
  252. package/dist/database/utils/index.js.map +1 -0
  253. package/dist/graph/adapters/adapter.factory.d.ts +47 -0
  254. package/dist/graph/adapters/adapter.factory.js +77 -0
  255. package/dist/graph/adapters/adapter.factory.js.map +1 -0
  256. package/dist/graph/adapters/arangodb.adapter.d.ts +78 -72
  257. package/dist/graph/adapters/arangodb.adapter.js +1310 -1220
  258. package/dist/graph/adapters/arangodb.adapter.js.map +1 -1
  259. package/dist/graph/adapters/base.adapter.d.ts +135 -118
  260. package/dist/graph/adapters/base.adapter.js +46 -20
  261. package/dist/graph/adapters/base.adapter.js.map +1 -1
  262. package/dist/graph/adapters/index.d.ts +5 -4
  263. package/dist/graph/adapters/index.js +6 -8
  264. package/dist/graph/adapters/index.js.map +1 -1
  265. package/dist/graph/adapters/memgraph.adapter.d.ts +98 -73
  266. package/dist/graph/adapters/memgraph.adapter.js +1050 -1202
  267. package/dist/graph/adapters/memgraph.adapter.js.map +1 -1
  268. package/dist/graph/adapters/neo4j.adapter.d.ts +71 -78
  269. package/dist/graph/adapters/neo4j.adapter.js +912 -1605
  270. package/dist/graph/adapters/neo4j.adapter.js.map +1 -1
  271. package/dist/graph/adapters/neptune.adapter.d.ts +76 -81
  272. package/dist/graph/adapters/neptune.adapter.js +1095 -1228
  273. package/dist/graph/adapters/neptune.adapter.js.map +1 -1
  274. package/dist/graph/graphs.service.d.ts +524 -0
  275. package/dist/graph/graphs.service.js +1683 -0
  276. package/dist/graph/graphs.service.js.map +1 -0
  277. package/dist/graph/index.d.ts +54 -8
  278. package/dist/graph/index.js +67 -32
  279. package/dist/graph/index.js.map +1 -1
  280. package/dist/graph/transactions/index.d.ts +4 -0
  281. package/dist/graph/transactions/index.js +9 -0
  282. package/dist/graph/transactions/index.js.map +1 -0
  283. package/dist/graph/transactions/transaction-manager.d.ts +61 -0
  284. package/dist/graph/transactions/transaction-manager.js +126 -0
  285. package/dist/graph/transactions/transaction-manager.js.map +1 -0
  286. package/dist/graph/types/connection.interface.d.ts +141 -0
  287. package/dist/graph/types/connection.interface.js +9 -0
  288. package/dist/graph/types/connection.interface.js.map +1 -0
  289. package/dist/graph/types/enums.d.ts +101 -0
  290. package/dist/graph/types/enums.js +114 -0
  291. package/dist/graph/types/enums.js.map +1 -0
  292. package/dist/graph/types/index.d.ts +11 -9
  293. package/dist/graph/types/index.js +15 -30
  294. package/dist/graph/types/index.js.map +1 -1
  295. package/dist/graph/types/node.interface.d.ts +248 -0
  296. package/dist/graph/types/node.interface.js +9 -0
  297. package/dist/graph/types/node.interface.js.map +1 -0
  298. package/dist/graph/types/query.interface.d.ts +168 -0
  299. package/dist/graph/types/query.interface.js +9 -0
  300. package/dist/graph/types/query.interface.js.map +1 -0
  301. package/dist/graph/types/relationship.interface.d.ts +207 -0
  302. package/dist/graph/types/relationship.interface.js +9 -0
  303. package/dist/graph/types/relationship.interface.js.map +1 -0
  304. package/dist/graph/types/schema.interface.d.ts +295 -0
  305. package/dist/graph/types/schema.interface.js +9 -0
  306. package/dist/graph/types/schema.interface.js.map +1 -0
  307. package/dist/graph/types/transaction.interface.d.ts +55 -0
  308. package/dist/graph/types/transaction.interface.js +9 -0
  309. package/dist/graph/types/transaction.interface.js.map +1 -0
  310. package/dist/graph/types/traversal.interface.d.ts +181 -0
  311. package/dist/graph/types/traversal.interface.js +9 -0
  312. package/dist/graph/types/traversal.interface.js.map +1 -0
  313. package/dist/graph/utils/graph-error.d.ts +71 -0
  314. package/dist/graph/utils/graph-error.js +142 -0
  315. package/dist/graph/utils/graph-error.js.map +1 -0
  316. package/dist/graph/utils/index.d.ts +4 -0
  317. package/dist/graph/utils/index.js +9 -0
  318. package/dist/graph/utils/index.js.map +1 -0
  319. package/dist/index.d.ts +1905 -875
  320. package/dist/index.js +3063 -1282
  321. package/dist/index.js.map +1 -1
  322. package/dist/init.interface.d.ts +407 -0
  323. package/dist/init.interface.js +3 -0
  324. package/dist/init.interface.js.map +1 -0
  325. package/dist/jobs/index.d.ts +38 -0
  326. package/dist/jobs/index.js +50 -0
  327. package/dist/jobs/index.js.map +1 -0
  328. package/dist/jobs/jobs.service.d.ts +154 -0
  329. package/dist/jobs/jobs.service.js +491 -0
  330. package/dist/jobs/jobs.service.js.map +1 -0
  331. package/dist/jobs/jobs.state.d.ts +113 -0
  332. package/dist/jobs/jobs.state.js +447 -0
  333. package/dist/jobs/jobs.state.js.map +1 -0
  334. package/dist/jobs/types.d.ts +449 -0
  335. package/dist/jobs/types.js +74 -0
  336. package/dist/jobs/types.js.map +1 -0
  337. package/dist/logs/logs.types.d.ts +12 -2
  338. package/dist/logs/logs.types.js +5 -1
  339. package/dist/logs/logs.types.js.map +1 -1
  340. package/dist/models/index.d.ts +6 -0
  341. package/dist/models/index.js +11 -0
  342. package/dist/models/index.js.map +1 -0
  343. package/dist/models/models.service.d.ts +137 -0
  344. package/dist/models/models.service.js +195 -0
  345. package/dist/models/models.service.js.map +1 -0
  346. package/dist/notifications/index.d.ts +13 -0
  347. package/dist/notifications/index.js +26 -0
  348. package/dist/notifications/index.js.map +1 -0
  349. package/dist/notifications/notifications.service.d.ts +252 -0
  350. package/dist/notifications/notifications.service.js +654 -0
  351. package/dist/notifications/notifications.service.js.map +1 -0
  352. package/dist/notifications/types/index.d.ts +4 -0
  353. package/dist/notifications/types/index.js +21 -0
  354. package/dist/notifications/types/index.js.map +1 -0
  355. package/dist/notifications/types/notifications.types.d.ts +400 -0
  356. package/dist/notifications/types/notifications.types.js +49 -0
  357. package/dist/notifications/types/notifications.types.js.map +1 -0
  358. package/dist/processor/services/messagebrokers/kafka.service.js +2 -0
  359. package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
  360. package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +1 -9
  361. package/dist/processor/services/messagebrokers/rabbitmq.service.js +11 -40
  362. package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
  363. package/dist/processor/services/processor.service.d.ts +86 -70
  364. package/dist/processor/services/processor.service.js +1353 -1259
  365. package/dist/processor/services/processor.service.js.map +1 -1
  366. package/dist/processor/utils/processor.utils.js +5 -1
  367. package/dist/processor/utils/processor.utils.js.map +1 -1
  368. package/dist/products/services/products.service.d.ts +167 -25
  369. package/dist/products/services/products.service.js +1248 -412
  370. package/dist/products/services/products.service.js.map +1 -1
  371. package/dist/products/validators/index.d.ts +6 -3
  372. package/dist/products/validators/index.js +14 -5
  373. package/dist/products/validators/index.js.map +1 -1
  374. package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
  375. package/dist/products/validators/joi-validators/create.productAgent.validator.js +218 -0
  376. package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
  377. package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
  378. package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
  379. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +4 -15
  380. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +109 -501
  381. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
  382. package/dist/products/validators/joi-validators/create.productGraph.validator.js +14 -9
  383. package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -1
  384. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +0 -1
  385. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
  386. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +87 -30
  387. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
  388. package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
  389. package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
  390. package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
  391. package/dist/products/validators/joi-validators/create.productNotification.validator.js +135 -50
  392. package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
  393. package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
  394. package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
  395. package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
  396. package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
  397. package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
  398. package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
  399. package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
  400. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +0 -6
  401. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +26 -28
  402. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
  403. package/dist/products/validators/joi-validators/update.productGraph.validator.js +11 -12
  404. package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -1
  405. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +0 -1
  406. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
  407. package/dist/resilience/fallback.service.d.ts +88 -0
  408. package/dist/resilience/fallback.service.js +511 -0
  409. package/dist/resilience/fallback.service.js.map +1 -0
  410. package/dist/resilience/healthcheck.service.d.ts +106 -0
  411. package/dist/resilience/healthcheck.service.js +379 -0
  412. package/dist/resilience/healthcheck.service.js.map +1 -0
  413. package/dist/resilience/index.d.ts +104 -0
  414. package/dist/resilience/index.js +140 -0
  415. package/dist/resilience/index.js.map +1 -0
  416. package/dist/resilience/quota.service.d.ts +90 -0
  417. package/dist/resilience/quota.service.js +519 -0
  418. package/dist/resilience/quota.service.js.map +1 -0
  419. package/dist/resilience/resilience.service.d.ts +95 -0
  420. package/dist/resilience/resilience.service.js +525 -0
  421. package/dist/resilience/resilience.service.js.map +1 -0
  422. package/dist/resilience/types/index.d.ts +479 -0
  423. package/dist/resilience/types/index.js +26 -0
  424. package/dist/resilience/types/index.js.map +1 -0
  425. package/dist/secrets/index.d.ts +10 -0
  426. package/dist/secrets/index.js +33 -0
  427. package/dist/secrets/index.js.map +1 -0
  428. package/dist/secrets/secrets.resolver.d.ts +52 -0
  429. package/dist/secrets/secrets.resolver.js +233 -0
  430. package/dist/secrets/secrets.resolver.js.map +1 -0
  431. package/dist/secrets/secrets.service.d.ts +83 -0
  432. package/dist/secrets/secrets.service.js +159 -0
  433. package/dist/secrets/secrets.service.js.map +1 -0
  434. package/dist/secrets/secrets.types.d.ts +188 -0
  435. package/dist/secrets/secrets.types.js +87 -0
  436. package/dist/secrets/secrets.types.js.map +1 -0
  437. package/dist/sessions/index.d.ts +50 -0
  438. package/dist/sessions/index.js +93 -0
  439. package/dist/sessions/index.js.map +1 -0
  440. package/dist/sessions/sessions.helper.d.ts +68 -0
  441. package/dist/sessions/sessions.helper.js +116 -0
  442. package/dist/sessions/sessions.helper.js.map +1 -0
  443. package/dist/sessions/sessions.resolver.d.ts +150 -0
  444. package/dist/sessions/sessions.resolver.js +356 -0
  445. package/dist/sessions/sessions.resolver.js.map +1 -0
  446. package/dist/sessions/sessions.service.d.ts +170 -0
  447. package/dist/sessions/sessions.service.js +736 -0
  448. package/dist/sessions/sessions.service.js.map +1 -0
  449. package/dist/sessions/types/index.d.ts +290 -0
  450. package/dist/sessions/types/index.js +6 -0
  451. package/dist/sessions/types/index.js.map +1 -0
  452. package/dist/storage/index.d.ts +66 -0
  453. package/dist/storage/index.js +98 -0
  454. package/dist/storage/index.js.map +1 -0
  455. package/dist/storage/storage.service.d.ts +123 -0
  456. package/dist/storage/storage.service.js +478 -0
  457. package/dist/storage/storage.service.js.map +1 -0
  458. package/dist/storage/types/index.d.ts +207 -0
  459. package/dist/storage/types/index.js +6 -0
  460. package/dist/storage/types/index.js.map +1 -0
  461. package/dist/storage/utils/storage.util.d.ts +51 -0
  462. package/dist/storage/utils/storage.util.js +402 -0
  463. package/dist/storage/utils/storage.util.js.map +1 -0
  464. package/dist/test/index.d.ts +3 -0
  465. package/dist/test/index.js +13 -0
  466. package/dist/test/index.js.map +1 -0
  467. package/dist/test/test.appBuilder.d.ts +0 -1
  468. package/dist/test/test.appBuilder.js +0 -15
  469. package/dist/test/test.appBuilder.js.map +1 -1
  470. package/dist/test/test.database.js +140 -0
  471. package/dist/test/test.database.js.map +1 -0
  472. package/dist/test/test.health.d.ts +0 -1
  473. package/dist/test/test.health.js +0 -48
  474. package/dist/test/test.health.js.map +1 -1
  475. package/dist/test/test.import.d.ts +0 -1
  476. package/dist/test/test.import.js +0 -1506
  477. package/dist/test/test.import.js.map +1 -1
  478. package/dist/test/test.import.openapi.d.ts +0 -1
  479. package/dist/test/test.import.openapi.js +0 -75
  480. package/dist/test/test.import.openapi.js.map +1 -1
  481. package/dist/test/test.imports.d.ts +0 -1
  482. package/dist/test/test.imports.js +0 -76
  483. package/dist/test/test.imports.js.map +1 -1
  484. package/dist/test/test.logs.d.ts +0 -1
  485. package/dist/test/test.logs.js +0 -17
  486. package/dist/test/test.logs.js.map +1 -1
  487. package/dist/test/test.notifiers.d.ts +0 -1
  488. package/dist/test/test.notifiers.js +0 -84
  489. package/dist/test/test.notifiers.js.map +1 -1
  490. package/dist/test/test.processor.d.ts +0 -1
  491. package/dist/test/test.processor.js +0 -37
  492. package/dist/test/test.processor.js.map +1 -1
  493. package/dist/test/test.productBuilder.d.ts +0 -1
  494. package/dist/test/test.productBuilder.js +0 -660
  495. package/dist/test/test.productBuilder.js.map +1 -1
  496. package/dist/test/test.products.d.ts +0 -1
  497. package/dist/test/test.products.js +0 -48
  498. package/dist/test/test.products.js.map +1 -1
  499. package/dist/test/test.storage.js +332 -0
  500. package/dist/test/test.storage.js.map +1 -0
  501. package/dist/test/test.triggers.js +314 -0
  502. package/dist/test/test.triggers.js.map +1 -0
  503. package/dist/types/appBuilder.types.d.ts +1 -1
  504. package/dist/types/enums.d.ts +6 -1
  505. package/dist/types/enums.js +5 -0
  506. package/dist/types/enums.js.map +1 -1
  507. package/dist/types/processor.types.d.ts +197 -35
  508. package/dist/types/processor.types.js +9 -1
  509. package/dist/types/processor.types.js.map +1 -1
  510. package/dist/types/productsBuilder.types.d.ts +837 -75
  511. package/dist/types/productsBuilder.types.js +168 -62
  512. package/dist/types/productsBuilder.types.js.map +1 -1
  513. package/dist/utils/index.d.ts +0 -2
  514. package/dist/utils/index.js +2 -49
  515. package/dist/utils/index.js.map +1 -1
  516. package/dist/vector/adapters/base.adapter.d.ts +152 -0
  517. package/dist/vector/adapters/base.adapter.js +137 -0
  518. package/dist/vector/adapters/base.adapter.js.map +1 -0
  519. package/dist/vector/adapters/index.d.ts +10 -0
  520. package/dist/vector/adapters/index.js +19 -0
  521. package/dist/vector/adapters/index.js.map +1 -0
  522. package/dist/vector/adapters/memory.adapter.d.ts +85 -0
  523. package/dist/vector/adapters/memory.adapter.js +505 -0
  524. package/dist/vector/adapters/memory.adapter.js.map +1 -0
  525. package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
  526. package/dist/vector/adapters/pinecone.adapter.js +400 -0
  527. package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
  528. package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
  529. package/dist/vector/adapters/qdrant.adapter.js +392 -0
  530. package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
  531. package/dist/vector/adapters/weaviate.adapter.d.ts +64 -0
  532. package/dist/vector/adapters/weaviate.adapter.js +478 -0
  533. package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
  534. package/dist/vector/index.d.ts +47 -0
  535. package/dist/vector/index.js +72 -0
  536. package/dist/vector/index.js.map +1 -0
  537. package/dist/vector/types/connection.interface.d.ts +151 -0
  538. package/dist/vector/types/connection.interface.js +8 -0
  539. package/dist/vector/types/connection.interface.js.map +1 -0
  540. package/dist/vector/types/embedding.interface.d.ts +144 -0
  541. package/dist/vector/types/embedding.interface.js +8 -0
  542. package/dist/vector/types/embedding.interface.js.map +1 -0
  543. package/dist/vector/types/enums.d.ts +104 -0
  544. package/dist/vector/types/enums.js +113 -0
  545. package/dist/vector/types/enums.js.map +1 -0
  546. package/dist/vector/types/index.d.ts +9 -0
  547. package/dist/vector/types/index.js +16 -0
  548. package/dist/vector/types/index.js.map +1 -0
  549. package/dist/vector/types/vector.interface.d.ts +315 -0
  550. package/dist/vector/types/vector.interface.js +8 -0
  551. package/dist/vector/types/vector.interface.js.map +1 -0
  552. package/dist/vector/utils/index.d.ts +6 -0
  553. package/dist/vector/utils/index.js +11 -0
  554. package/dist/vector/utils/index.js.map +1 -0
  555. package/dist/vector/utils/vector-error.d.ts +69 -0
  556. package/dist/vector/utils/vector-error.js +117 -0
  557. package/dist/vector/utils/vector-error.js.map +1 -0
  558. package/dist/vector/vector-database.service.d.ts +405 -0
  559. package/dist/vector/vector-database.service.js +544 -0
  560. package/dist/vector/vector-database.service.js.map +1 -0
  561. package/dist/vector/vector.service.d.ts +245 -0
  562. package/dist/vector/vector.service.js +381 -0
  563. package/dist/vector/vector.service.js.map +1 -0
  564. package/dist/workflows/index.d.ts +30 -0
  565. package/dist/workflows/index.js +64 -0
  566. package/dist/workflows/index.js.map +1 -0
  567. package/dist/workflows/types/index.d.ts +6 -0
  568. package/dist/workflows/types/index.js +23 -0
  569. package/dist/workflows/types/index.js.map +1 -0
  570. package/dist/workflows/types/workflows.types.d.ts +1035 -0
  571. package/dist/workflows/types/workflows.types.js +13 -0
  572. package/dist/workflows/types/workflows.types.js.map +1 -0
  573. package/dist/workflows/workflow-builder.d.ts +70 -0
  574. package/dist/workflows/workflow-builder.js +338 -0
  575. package/dist/workflows/workflow-builder.js.map +1 -0
  576. package/dist/workflows/workflow-executor.d.ts +205 -0
  577. package/dist/workflows/workflow-executor.js +1186 -0
  578. package/dist/workflows/workflow-executor.js.map +1 -0
  579. package/dist/workflows/workflows.service.d.ts +398 -0
  580. package/dist/workflows/workflows.service.js +1595 -0
  581. package/dist/workflows/workflows.service.js.map +1 -0
  582. package/package.json +16 -13
  583. package/dist/actions/actions.repo.d.ts +0 -0
  584. package/dist/actions/actions.repo.js +0 -13
  585. package/dist/actions/actions.repo.js.map +0 -1
  586. package/dist/actions/actions.service.d.ts +0 -0
  587. package/dist/actions/actions.service.js +0 -24
  588. package/dist/actions/actions.service.js.map +0 -1
  589. package/dist/actions/utils/actions.util.read.d.ts +0 -0
  590. package/dist/actions/utils/actions.util.read.js +0 -427
  591. package/dist/actions/utils/actions.util.read.js.map +0 -1
  592. package/dist/api/services/integrationsApi.service.d.ts +0 -18
  593. package/dist/api/services/integrationsApi.service.js +0 -80
  594. package/dist/api/services/integrationsApi.service.js.map +0 -1
  595. package/dist/api/services/workspaceSecretsApi.service.d.ts +0 -75
  596. package/dist/api/services/workspaceSecretsApi.service.js +0 -62
  597. package/dist/api/services/workspaceSecretsApi.service.js.map +0 -1
  598. package/dist/appBuilder/services/app.service.d.ts +0 -111
  599. package/dist/appBuilder/services/app.service.js +0 -737
  600. package/dist/appBuilder/services/app.service.js.map +0 -1
  601. package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
  602. package/dist/appBuilder/services/appBuilder.service.js +0 -662
  603. package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
  604. package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
  605. package/dist/appBuilder/utils/objects.utils.js +0 -9
  606. package/dist/appBuilder/utils/objects.utils.js.map +0 -1
  607. package/dist/appBuilder/utils/string.utils.d.ts +0 -2
  608. package/dist/appBuilder/utils/string.utils.js +0 -57
  609. package/dist/appBuilder/utils/string.utils.js.map +0 -1
  610. package/dist/appBuilder/validators/index.d.ts +0 -19
  611. package/dist/appBuilder/validators/index.js +0 -40
  612. package/dist/appBuilder/validators/index.js.map +0 -1
  613. package/dist/appBuilder/validators/joi-validators/create.app.validator.d.ts +0 -3
  614. package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
  615. package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
  616. package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
  617. package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
  618. package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
  619. package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
  620. package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
  621. package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
  622. package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
  623. package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
  624. package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
  625. package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
  626. package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
  627. package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
  628. package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
  629. package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
  630. package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
  631. package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
  632. package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
  633. package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
  634. package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
  635. package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
  636. package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
  637. package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
  638. package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
  639. package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
  640. package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
  641. package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
  642. package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
  643. package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
  644. package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
  645. package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
  646. package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
  647. package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
  648. package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
  649. package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
  650. package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
  651. package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
  652. package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
  653. package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
  654. package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
  655. package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
  656. package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
  657. package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
  658. package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
  659. package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
  660. package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
  661. package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
  662. package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
  663. package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
  664. package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
  665. package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
  666. package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
  667. package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts +0 -3
  668. package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
  669. package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
  670. package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
  671. package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
  672. package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
  673. package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
  674. package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
  675. package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
  676. package/dist/clients/integrations.client.d.ts +0 -2
  677. package/dist/clients/integrations.client.js +0 -26
  678. package/dist/clients/integrations.client.js.map +0 -1
  679. package/dist/database/database.service.d.ts +0 -232
  680. package/dist/database/database.service.js +0 -802
  681. package/dist/database/database.service.js.map +0 -1
  682. package/dist/database/types/aggregation.types.d.ts +0 -261
  683. package/dist/database/types/aggregation.types.js +0 -21
  684. package/dist/database/types/aggregation.types.js.map +0 -1
  685. package/dist/database/types/connection.types.d.ts +0 -132
  686. package/dist/database/types/connection.types.js +0 -6
  687. package/dist/database/types/connection.types.js.map +0 -1
  688. package/dist/database/types/database.types.d.ts +0 -175
  689. package/dist/database/types/database.types.js +0 -75
  690. package/dist/database/types/database.types.js.map +0 -1
  691. package/dist/database/types/index.types.d.ts +0 -220
  692. package/dist/database/types/index.types.js +0 -27
  693. package/dist/database/types/index.types.js.map +0 -1
  694. package/dist/database/types/migration.types.d.ts +0 -205
  695. package/dist/database/types/migration.types.js +0 -44
  696. package/dist/database/types/migration.types.js.map +0 -1
  697. package/dist/database/types/query.types.d.ts +0 -305
  698. package/dist/database/types/query.types.js +0 -57
  699. package/dist/database/types/query.types.js.map +0 -1
  700. package/dist/database/types/result.types.d.ts +0 -220
  701. package/dist/database/types/result.types.js +0 -6
  702. package/dist/database/types/result.types.js.map +0 -1
  703. package/dist/database/types/schema.types.d.ts +0 -190
  704. package/dist/database/types/schema.types.js +0 -69
  705. package/dist/database/types/schema.types.js.map +0 -1
  706. package/dist/database/utils/helpers.d.ts +0 -66
  707. package/dist/database/utils/helpers.js +0 -501
  708. package/dist/database/utils/helpers.js.map +0 -1
  709. package/dist/database/utils/migration.utils.d.ts +0 -151
  710. package/dist/database/utils/migration.utils.js +0 -476
  711. package/dist/database/utils/migration.utils.js.map +0 -1
  712. package/dist/database/utils/transaction.d.ts +0 -64
  713. package/dist/database/utils/transaction.js +0 -130
  714. package/dist/database/utils/transaction.js.map +0 -1
  715. package/dist/database/validators/connection.validator.d.ts +0 -20
  716. package/dist/database/validators/connection.validator.js +0 -267
  717. package/dist/database/validators/connection.validator.js.map +0 -1
  718. package/dist/database/validators/query.validator.d.ts +0 -31
  719. package/dist/database/validators/query.validator.js +0 -305
  720. package/dist/database/validators/query.validator.js.map +0 -1
  721. package/dist/database/validators/schema.validator.d.ts +0 -31
  722. package/dist/database/validators/schema.validator.js +0 -334
  723. package/dist/database/validators/schema.validator.js.map +0 -1
  724. package/dist/graph/graph.service.d.ts +0 -278
  725. package/dist/graph/graph.service.js +0 -687
  726. package/dist/graph/graph.service.js.map +0 -1
  727. package/dist/graph/types/connection.types.d.ts +0 -158
  728. package/dist/graph/types/connection.types.js +0 -43
  729. package/dist/graph/types/connection.types.js.map +0 -1
  730. package/dist/graph/types/graph.types.d.ts +0 -144
  731. package/dist/graph/types/graph.types.js +0 -84
  732. package/dist/graph/types/graph.types.js.map +0 -1
  733. package/dist/graph/types/node.types.d.ts +0 -193
  734. package/dist/graph/types/node.types.js +0 -49
  735. package/dist/graph/types/node.types.js.map +0 -1
  736. package/dist/graph/types/path.types.d.ts +0 -224
  737. package/dist/graph/types/path.types.js +0 -38
  738. package/dist/graph/types/path.types.js.map +0 -1
  739. package/dist/graph/types/query.types.d.ts +0 -247
  740. package/dist/graph/types/query.types.js +0 -23
  741. package/dist/graph/types/query.types.js.map +0 -1
  742. package/dist/graph/types/relationship.types.d.ts +0 -224
  743. package/dist/graph/types/relationship.types.js +0 -35
  744. package/dist/graph/types/relationship.types.js.map +0 -1
  745. package/dist/graph/types/result.types.d.ts +0 -237
  746. package/dist/graph/types/result.types.js +0 -7
  747. package/dist/graph/types/result.types.js.map +0 -1
  748. package/dist/graph/validators/index.d.ts +0 -81
  749. package/dist/graph/validators/index.js +0 -243
  750. package/dist/graph/validators/index.js.map +0 -1
  751. package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
  752. package/dist/integrationsBuilder/services/integration.service.js +0 -1148
  753. package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
  754. package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
  755. package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
  756. package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
  757. package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
  758. package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
  759. package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
  760. package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
  761. package/dist/integrationsBuilder/utils/string.utils.js +0 -9
  762. package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
  763. package/dist/integrationsBuilder/validators/index.d.ts +0 -18
  764. package/dist/integrationsBuilder/validators/index.js +0 -38
  765. package/dist/integrationsBuilder/validators/index.js.map +0 -1
  766. package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
  767. package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
  768. package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
  769. package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
  770. package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
  771. package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
  772. package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
  773. package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
  774. package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
  775. package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
  776. package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
  777. package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
  778. package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
  779. package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
  780. package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
  781. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
  782. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
  783. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
  784. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
  785. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
  786. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
  787. package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
  788. package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
  789. package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
  790. package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
  791. package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
  792. package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
  793. package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
  794. package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
  795. package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
  796. package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
  797. package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
  798. package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
  799. package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
  800. package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
  801. package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
  802. package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
  803. package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
  804. package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
  805. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
  806. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
  807. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
  808. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
  809. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
  810. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
  811. package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
  812. package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
  813. package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
  814. package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
  815. package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
  816. package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
  817. package/dist/postman.d.ts +0 -1
  818. package/dist/postman.js +0 -21674
  819. package/dist/postman.js.map +0 -1
  820. package/dist/processor/utils/mongo.util.d.ts +0 -0
  821. package/dist/processor/utils/mongo.util.js +0 -152
  822. package/dist/processor/utils/mongo.util.js.map +0 -1
  823. package/dist/processor/utils/postgres.util.d.ts +0 -14
  824. package/dist/processor/utils/postgres.util.js +0 -83
  825. package/dist/processor/utils/postgres.util.js.map +0 -1
  826. package/dist/products/services/utils/crypt.utils.d.ts +0 -1
  827. package/dist/products/services/utils/crypt.utils.js +0 -17
  828. package/dist/products/services/utils/crypt.utils.js.map +0 -1
  829. package/dist/products/services/utils/functions.utils.d.ts +0 -13
  830. package/dist/products/services/utils/functions.utils.js +0 -289
  831. package/dist/products/services/utils/functions.utils.js.map +0 -1
  832. package/dist/products/services/utils/objects.utils.d.ts +0 -13
  833. package/dist/products/services/utils/objects.utils.js +0 -89
  834. package/dist/products/services/utils/objects.utils.js.map +0 -1
  835. package/dist/products/services/utils/string.utils.d.ts +0 -12
  836. package/dist/products/services/utils/string.utils.js +0 -168
  837. package/dist/products/services/utils/string.utils.js.map +0 -1
  838. package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
  839. package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
  840. package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
  841. package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +0 -14
  842. package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +0 -696
  843. package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +0 -1
  844. package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +0 -7
  845. package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +0 -72
  846. package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +0 -1
  847. package/dist/test.appBuilder.js +0 -14
  848. package/dist/test.appBuilder.js.map +0 -1
  849. package/dist/test.import.d.ts +0 -0
  850. package/dist/test.import.js +0 -24
  851. package/dist/test.import.js.map +0 -1
  852. package/dist/test.imports.js +0 -28
  853. package/dist/test.imports.js.map +0 -1
  854. package/dist/test.integrationBuilder.js +0 -276
  855. package/dist/test.integrationBuilder.js.map +0 -1
  856. package/dist/test.processor.d.ts +0 -1
  857. package/dist/test.processor.js +0 -23
  858. package/dist/test.processor.js.map +0 -1
  859. package/dist/test.utils.d.ts +0 -1
  860. package/dist/test.utils.js +0 -25
  861. package/dist/test.utils.js.map +0 -1
  862. package/dist/tsconfig.tsbuildinfo +0 -1
  863. package/dist/types/integrationsBuilder.types.d.ts +0 -276
  864. package/dist/types/integrationsBuilder.types.js +0 -51
  865. package/dist/types/integrationsBuilder.types.js.map +0 -1
  866. /package/dist/{test.appBuilder.d.ts → test/test.database.d.ts} +0 -0
  867. /package/dist/{test.imports.d.ts → test/test.storage.d.ts} +0 -0
  868. /package/dist/{test.integrationBuilder.d.ts → test/test.triggers.d.ts} +0 -0
@@ -1,8 +1,17 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Memgraph Graph Database Adapter
4
- * Implements the BaseGraphAdapter for Memgraph using Cypher query language
5
- * Memgraph is Cypher-compatible and uses the Bolt protocol similar to Neo4j
4
+ *
5
+ * Implements the BaseGraphAdapter for Memgraph.
6
+ * Memgraph is a high-performance, in-memory graph database
7
+ * that is fully compatible with Neo4j's Bolt protocol and Cypher query language.
8
+ *
9
+ * Key features:
10
+ * - Cypher query language compatibility
11
+ * - Bolt protocol support
12
+ * - In-memory performance
13
+ * - Triggers and streams support
14
+ * - MAGE graph algorithms library
6
15
  */
7
16
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
17
  if (k2 === undefined) k2 = k;
@@ -40,1452 +49,1291 @@ var __importStar = (this && this.__importStar) || (function () {
40
49
  Object.defineProperty(exports, "__esModule", { value: true });
41
50
  exports.MemgraphAdapter = void 0;
42
51
  const base_adapter_1 = require("./base.adapter");
43
- const graph_types_1 = require("../types/graph.types");
44
- const node_types_1 = require("../types/node.types");
45
- const relationship_types_1 = require("../types/relationship.types");
52
+ const enums_1 = require("../types/enums");
53
+ const graph_error_1 = require("../utils/graph-error");
46
54
  /**
47
- * Memgraph connection implementation
48
- * Uses Bolt protocol which is compatible with neo4j-driver
55
+ * Memgraph adapter - Cypher-compatible graph database
56
+ * Uses the neo4j-driver package as Memgraph supports the Bolt protocol
49
57
  */
50
- class MemgraphConnection {
51
- constructor(config, id) {
52
- this.config = config;
53
- this.type = graph_types_1.GraphDatabaseType.MEMGRAPH;
54
- this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
55
- this.queryLanguage = graph_types_1.GraphQueryLanguage.CYPHER;
58
+ class MemgraphAdapter extends base_adapter_1.BaseGraphAdapter {
59
+ constructor() {
60
+ super(...arguments);
61
+ this.graphType = enums_1.GraphType.MEMGRAPH;
62
+ this.supportedFeatures = new Set([
63
+ enums_1.GraphFeature.TRANSACTIONS,
64
+ enums_1.GraphFeature.SCHEMA_INDEXES,
65
+ enums_1.GraphFeature.TRIGGERS,
66
+ enums_1.GraphFeature.CHANGE_STREAMS,
67
+ enums_1.GraphFeature.GRAPH_ALGORITHMS,
68
+ ]);
56
69
  this.driver = null;
57
- this.currentSession = null;
58
- this.id = id || `memgraph-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
59
- this.createdAt = new Date();
70
+ this.session = null;
60
71
  }
61
- async connect() {
62
- var _a;
63
- if (this.status === graph_types_1.GraphConnectionStatus.CONNECTED) {
64
- return;
65
- }
66
- this.status = graph_types_1.GraphConnectionStatus.CONNECTING;
72
+ // ==================== CONNECTION MANAGEMENT ====================
73
+ async connect(options) {
74
+ var _a, _b;
67
75
  try {
68
- // Use neo4j-driver which is compatible with Memgraph's Bolt protocol
76
+ // Memgraph uses the Bolt protocol, compatible with neo4j-driver
69
77
  const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
70
- const port = this.config.port || 7687;
71
- const uri = `bolt://${this.config.host}:${port}`;
72
- const authToken = this.config.username && this.config.password
73
- ? neo4j.default.auth.basic(this.config.username, this.config.password)
74
- : undefined;
75
- const driverConfig = {
76
- maxConnectionPoolSize: this.config.poolSize || 50,
77
- connectionTimeout: this.config.connectionTimeout || 30000,
78
- };
79
- if (this.config.encrypted !== undefined) {
80
- driverConfig.encrypted = this.config.encrypted;
81
- }
82
- if ((_a = this.config.options) === null || _a === void 0 ? void 0 : _a.trustAll) {
83
- driverConfig.trust = 'TRUST_ALL_CERTIFICATES';
84
- }
85
- this.driver = neo4j.default.driver(uri, authToken, driverConfig);
86
- // Verify connectivity
78
+ const auth = options.auth
79
+ ? neo4j.auth.basic(options.auth.username, options.auth.password)
80
+ : neo4j.auth.basic('', ''); // Memgraph can run without auth
81
+ this.driver = neo4j.driver(options.connectionUrl, auth, Object.assign(Object.assign({}, options.options), {
82
+ // Memgraph-specific settings
83
+ encrypted: (_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.encrypted) !== null && _b !== void 0 ? _b : false }));
84
+ // Verify connection
87
85
  await this.driver.verifyConnectivity();
88
- this.status = graph_types_1.GraphConnectionStatus.CONNECTED;
89
- this.lastUsedAt = new Date();
90
- }
91
- catch (error) {
92
- this.status = graph_types_1.GraphConnectionStatus.ERROR;
93
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, `Failed to connect to Memgraph: ${error.message}`, error);
94
- }
95
- }
96
- async disconnect() {
97
- if (this.currentSession) {
98
- await this.currentSession.close();
99
- this.currentSession = null;
100
- }
101
- if (this.driver) {
102
- await this.driver.close();
103
- this.driver = null;
104
- }
105
- this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
106
- }
107
- isConnected() {
108
- return this.status === graph_types_1.GraphConnectionStatus.CONNECTED && this.driver !== null;
109
- }
110
- getClient() {
111
- if (!this.driver) {
112
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Memgraph driver not initialized. Call connect() first.');
113
- }
114
- return this.driver;
115
- }
116
- getSession() {
117
- if (!this.driver) {
118
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Memgraph driver not initialized. Call connect() first.');
119
- }
120
- const sessionConfig = {};
121
- if (this.config.database) {
122
- sessionConfig.database = this.config.database;
123
- }
124
- this.currentSession = this.driver.session(sessionConfig);
125
- this.lastUsedAt = new Date();
126
- return this.currentSession;
127
- }
128
- }
129
- /**
130
- * Memgraph transaction implementation
131
- */
132
- class MemgraphTransaction {
133
- constructor(connection, session, transaction) {
134
- this.connection = connection;
135
- this.session = session;
136
- this.status = graph_types_1.GraphTransactionStatus.PENDING;
137
- this.id = `tx-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
138
- this.createdAt = new Date();
139
- this.native = transaction;
140
- this.status = graph_types_1.GraphTransactionStatus.ACTIVE;
141
- }
142
- async commit() {
143
- if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
144
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Cannot commit transaction in ${this.status} state`);
145
- }
146
- try {
147
- await this.native.commit();
148
- this.status = graph_types_1.GraphTransactionStatus.COMMITTED;
149
- }
150
- catch (error) {
151
- this.status = graph_types_1.GraphTransactionStatus.FAILED;
152
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to commit transaction: ${error.message}`, error);
153
- }
154
- }
155
- async rollback() {
156
- if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
157
- return;
158
- }
159
- try {
160
- await this.native.rollback();
161
- this.status = graph_types_1.GraphTransactionStatus.ROLLED_BACK;
86
+ this.connected = true;
87
+ this.connectionUrl = options.connectionUrl;
88
+ return {
89
+ connected: true,
90
+ type: enums_1.GraphType.MEMGRAPH,
91
+ latency: 0,
92
+ };
162
93
  }
163
94
  catch (error) {
164
- this.status = graph_types_1.GraphTransactionStatus.FAILED;
165
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to rollback transaction: ${error.message}`, error);
166
- }
167
- }
168
- isActive() {
169
- return this.status === graph_types_1.GraphTransactionStatus.ACTIVE;
170
- }
171
- }
172
- /**
173
- * Memgraph Graph Database Adapter
174
- */
175
- class MemgraphAdapter extends base_adapter_1.BaseGraphAdapter {
176
- constructor() {
177
- super(...arguments);
178
- this.type = graph_types_1.GraphDatabaseType.MEMGRAPH;
179
- this.supportedLanguages = [graph_types_1.GraphQueryLanguage.CYPHER];
180
- this.defaultLanguage = graph_types_1.GraphQueryLanguage.CYPHER;
181
- }
182
- // ==================== CONNECTION METHODS ====================
183
- async connect(config) {
184
- if (config.type !== graph_types_1.GraphDatabaseType.MEMGRAPH) {
185
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Invalid config type ${config.type}. Expected ${graph_types_1.GraphDatabaseType.MEMGRAPH}`);
95
+ this.connected = false;
96
+ throw graph_error_1.GraphError.connectionError(`Failed to connect to Memgraph: ${error.message}`, error);
186
97
  }
187
- const connection = new MemgraphConnection(config);
188
- await connection.connect();
189
- return connection;
190
- }
191
- async disconnect(connection) {
192
- await connection.disconnect();
193
98
  }
194
- async testConnection(connection) {
195
- const startTime = Date.now();
99
+ async testConnection(options) {
196
100
  try {
197
- const session = connection.getSession();
198
- const result = await session.run('RETURN 1 AS test');
101
+ const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
102
+ const startTime = Date.now();
103
+ const auth = options.auth
104
+ ? neo4j.auth.basic(options.auth.username, options.auth.password)
105
+ : neo4j.auth.basic('', '');
106
+ const testDriver = neo4j.driver(options.connectionUrl, auth, Object.assign(Object.assign({}, options.options), { connectionTimeout: 5000 }));
107
+ await testDriver.verifyConnectivity();
108
+ // Get Memgraph version
109
+ const session = testDriver.session();
110
+ const result = await session.run('CALL mg.info() YIELD key, value WHERE key = "version" RETURN value');
111
+ const version = result.records.length > 0 ? result.records[0].get('value') : 'unknown';
199
112
  await session.close();
113
+ await testDriver.close();
200
114
  return {
201
115
  connected: true,
202
- message: 'Connection successful',
203
- databaseType: graph_types_1.GraphDatabaseType.MEMGRAPH,
204
- queryLanguage: graph_types_1.GraphQueryLanguage.CYPHER,
205
- responseTime: Date.now() - startTime,
116
+ type: enums_1.GraphType.MEMGRAPH,
117
+ version,
118
+ latency: Date.now() - startTime,
206
119
  };
207
120
  }
208
121
  catch (error) {
209
122
  return {
210
123
  connected: false,
211
- message: 'Connection failed',
212
- databaseType: graph_types_1.GraphDatabaseType.MEMGRAPH,
213
- queryLanguage: graph_types_1.GraphQueryLanguage.CYPHER,
214
- responseTime: Date.now() - startTime,
124
+ type: enums_1.GraphType.MEMGRAPH,
215
125
  error: error.message,
216
126
  };
217
127
  }
218
128
  }
219
- async getDatabaseInfo(connection) {
220
- const session = connection.getSession();
221
- try {
222
- // Memgraph version query
223
- const result = await session.run('CALL mg.info() YIELD * RETURN *');
224
- const record = result.records[0];
225
- return {
226
- version: (record === null || record === void 0 ? void 0 : record.get('version')) || 'Unknown',
227
- edition: 'Memgraph',
228
- features: ['cypher', 'streaming', 'in-memory'],
229
- };
230
- }
231
- catch (_a) {
232
- // Fallback for older Memgraph versions
233
- return {
234
- version: 'Unknown',
235
- edition: 'Memgraph',
236
- features: ['cypher', 'streaming', 'in-memory'],
237
- };
129
+ async disconnect() {
130
+ if (this.session) {
131
+ await this.session.close();
132
+ this.session = null;
238
133
  }
239
- finally {
240
- await session.close();
134
+ if (this.driver) {
135
+ await this.driver.close();
136
+ this.driver = null;
241
137
  }
138
+ this.connected = false;
242
139
  }
243
- // ==================== TRANSACTION METHODS ====================
244
- async beginTransaction(connection, options) {
245
- const session = connection.getSession();
246
- const txConfig = {};
247
- if (options === null || options === void 0 ? void 0 : options.timeout) {
248
- txConfig.timeout = options.timeout;
140
+ getSession(transaction) {
141
+ if (transaction === null || transaction === void 0 ? void 0 : transaction.client) {
142
+ return transaction.client;
249
143
  }
250
- if (options === null || options === void 0 ? void 0 : options.metadata) {
251
- txConfig.metadata = options.metadata;
252
- }
253
- const transaction = session.beginTransaction(txConfig);
254
- return new MemgraphTransaction(connection, session, transaction);
255
- }
256
- async commitTransaction(connection, transaction) {
257
- await transaction.commit();
258
- }
259
- async rollbackTransaction(connection, transaction) {
260
- await transaction.rollback();
261
- }
262
- // ==================== RAW QUERY METHODS ====================
263
- async executeRaw(connection, options, transaction) {
264
- var _a;
265
- const startTime = Date.now();
266
- try {
267
- let result;
268
- if (transaction && transaction.isActive()) {
269
- result = await transaction.native.run(options.query, options.params || {});
270
- }
271
- else {
272
- const session = connection.getSession();
273
- try {
274
- result = await session.run(options.query, options.params || {});
275
- }
276
- finally {
277
- await session.close();
278
- }
279
- }
280
- const records = result.records.map((record) => {
281
- const obj = {};
282
- record.keys.forEach((key) => {
283
- obj[key] = this.convertValue(record.get(key));
284
- });
285
- return obj;
286
- });
287
- return {
288
- success: true,
289
- executionTime: Date.now() - startTime,
290
- data: records,
291
- columns: result.records.length > 0 ? [...result.records[0].keys] : [],
292
- count: records.length,
293
- statistics: this.parseStatistics((_a = result.summary) === null || _a === void 0 ? void 0 : _a.counters),
294
- };
295
- }
296
- catch (error) {
297
- throw this.wrapError(error, graph_types_1.GraphErrorType.QUERY_ERROR, `Query execution failed: ${error.message}`, options.query, options.params);
144
+ if (!this.session) {
145
+ this.ensureConnected();
146
+ this.session = this.driver.session();
298
147
  }
148
+ return this.session;
299
149
  }
300
150
  // ==================== NODE OPERATIONS ====================
301
- async createNode(connection, options, transaction) {
302
- const startTime = Date.now();
303
- const labels = this.normalizeLabels(options.labels);
304
- const labelStr = labels.map(l => this.escapeIdentifier(l)).join(':');
305
- const { clause: propsClause, params } = this.buildPropertiesClause(options.properties);
306
- const query = `CREATE (n:${labelStr} ${propsClause}) RETURN n`;
307
- const result = await this.executeRaw(connection, { query, params }, transaction);
151
+ async createNode(options, transaction) {
152
+ this.ensureConnected();
153
+ const labels = options.labels.join(':');
154
+ const query = `CREATE (n:${labels} $props) RETURN n, id(n) as nodeId`;
155
+ const session = this.getSession(transaction);
156
+ const result = await session.run(query, { props: options.properties });
157
+ const record = result.records[0];
158
+ const node = record.get('n');
159
+ const nodeId = record.get('nodeId');
308
160
  return {
309
- success: true,
310
- executionTime: Date.now() - startTime,
311
- node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
161
+ node: this.mapMemgraphNode(node, nodeId),
312
162
  created: true,
313
- statistics: result.statistics,
314
163
  };
315
164
  }
316
- async findNodes(connection, options, transaction) {
317
- const startTime = Date.now();
318
- const labels = options.labels ? this.normalizeLabels(options.labels) : [];
319
- const labelStr = labels.length > 0 ? ':' + labels.map(l => this.escapeIdentifier(l)).join(':') : '';
320
- let query = `MATCH (n${labelStr})`;
165
+ async findNodes(options, transaction) {
166
+ var _a, _b;
167
+ this.ensureConnected();
168
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
169
+ const labelClause = labels ? `:${labels}` : '';
170
+ let query = `MATCH (n${labelClause})`;
321
171
  const params = {};
322
- // Build WHERE clause
323
- const whereParts = [];
324
172
  if (options.where) {
325
- const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
326
- whereParts.push(clause);
173
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
174
+ query += ` WHERE ${clause}`;
327
175
  Object.assign(params, whereParams);
328
176
  }
329
- if (options.properties) {
330
- Object.entries(options.properties).forEach(([key, value], index) => {
331
- const paramName = `prop_${index}`;
332
- whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
333
- params[paramName] = value;
334
- });
335
- }
336
- if (whereParts.length > 0) {
337
- query += ` WHERE ${whereParts.join(' AND ')}`;
177
+ query += ' RETURN n, id(n) as nodeId';
178
+ if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
179
+ const orderClauses = options.orderBy.map(o => `n.${o.property} ${o.direction.toUpperCase()}`);
180
+ query += ` ORDER BY ${orderClauses.join(', ')}`;
338
181
  }
339
- query += ` RETURN n`;
340
- // ORDER BY
341
- if (options.orderBy && options.orderBy.length > 0) {
342
- const orderParts = options.orderBy.map(o => `n.${this.escapeIdentifier(o.property)} ${o.direction}`);
343
- query += ` ORDER BY ${orderParts.join(', ')}`;
344
- }
345
- // SKIP and LIMIT
346
- if (options.skip !== undefined) {
182
+ if (options.skip) {
347
183
  query += ` SKIP ${options.skip}`;
348
184
  }
349
- if (options.limit !== undefined) {
185
+ if (options.limit) {
350
186
  query += ` LIMIT ${options.limit}`;
351
187
  }
352
- const result = await this.executeRaw(connection, { query, params }, transaction);
353
- const nodes = result.data.map(row => this.parseNode(row.n));
188
+ const session = this.getSession(transaction);
189
+ const result = await session.run(query, params);
190
+ const nodes = result.records.map((record) => this.mapMemgraphNode(record.get('n'), record.get('nodeId')));
354
191
  return {
355
- success: true,
356
- executionTime: Date.now() - startTime,
357
192
  nodes,
358
193
  count: nodes.length,
359
- hasMore: options.limit !== undefined && nodes.length === options.limit,
360
194
  };
361
195
  }
362
- async findNodeById(connection, id, transaction) {
363
- // Memgraph uses internal IDs
364
- const query = `MATCH (n) WHERE id(n) = $id RETURN n`;
365
- const result = await this.executeRaw(connection, { query, params: { id: typeof id === 'string' ? parseInt(id, 10) : id } }, transaction);
366
- if (result.data.length === 0) {
196
+ async findNodeById(id, transaction) {
197
+ this.ensureConnected();
198
+ // Memgraph uses internal id() function
199
+ const query = `MATCH (n) WHERE id(n) = $id RETURN n, id(n) as nodeId`;
200
+ const session = this.getSession(transaction);
201
+ const result = await session.run(query, {
202
+ id: typeof id === 'number' ? id : parseInt(id, 10),
203
+ });
204
+ if (result.records.length === 0) {
367
205
  return null;
368
206
  }
369
- return this.parseNode(result.data[0].n);
207
+ return this.mapMemgraphNode(result.records[0].get('n'), result.records[0].get('nodeId'));
370
208
  }
371
- async updateNode(connection, options, transaction) {
209
+ async updateNode(options, transaction) {
372
210
  var _a;
373
- const startTime = Date.now();
374
- const params = {};
375
- let matchClause = 'MATCH (n)';
376
- if (options.id !== undefined) {
377
- matchClause = 'MATCH (n) WHERE id(n) = $nodeId';
378
- params.nodeId = typeof options.id === 'string' ? parseInt(options.id, 10) : options.id;
379
- }
380
- else if (options.labels) {
381
- const labels = this.normalizeLabels(options.labels);
382
- matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
383
- }
384
- if (options.where) {
385
- const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
386
- matchClause += options.id === undefined && !options.labels ? ` WHERE ${clause}` : ` AND ${clause}`;
387
- Object.assign(params, whereParams);
388
- }
389
- const setParts = [];
390
- const removeParts = [];
391
- if (options.set) {
392
- Object.entries(options.set).forEach(([key, value], index) => {
393
- const paramName = `set_${index}`;
394
- setParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
395
- params[paramName] = value;
396
- });
397
- }
398
- if (options.addLabels && options.addLabels.length > 0) {
399
- setParts.push(`n:${options.addLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
400
- }
401
- if (options.remove && options.remove.length > 0) {
402
- options.remove.forEach(prop => {
403
- removeParts.push(`n.${this.escapeIdentifier(prop)}`);
404
- });
405
- }
406
- if (options.removeLabels && options.removeLabels.length > 0) {
407
- removeParts.push(`n:${options.removeLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
408
- }
409
- let query = matchClause;
410
- if (setParts.length > 0) {
411
- query += ` SET ${setParts.join(', ')}`;
211
+ this.ensureConnected();
212
+ let query;
213
+ const params = { props: options.properties };
214
+ if (options.id) {
215
+ query = `MATCH (n) WHERE id(n) = $id SET n += $props RETURN n, id(n) as nodeId`;
216
+ params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
412
217
  }
413
- if (removeParts.length > 0) {
414
- query += ` REMOVE ${removeParts.join(', ')}`;
218
+ else {
219
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
220
+ const labelClause = labels ? `:${labels}` : '';
221
+ query = `MATCH (n${labelClause})`;
222
+ if (options.where) {
223
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
224
+ query += ` WHERE ${clause}`;
225
+ Object.assign(params, whereParams);
226
+ }
227
+ query += ' SET n += $props RETURN n, id(n) as nodeId';
415
228
  }
416
- query += ' RETURN n';
417
- const result = await this.executeRaw(connection, { query, params }, transaction);
229
+ const session = this.getSession(transaction);
230
+ const result = await session.run(query, params);
231
+ const nodes = result.records.map((record) => this.mapMemgraphNode(record.get('n'), record.get('nodeId')));
418
232
  return {
419
- success: true,
420
- executionTime: Date.now() - startTime,
421
- node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
422
- updated: result.data.length > 0,
423
- matchedCount: result.data.length,
424
- modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
425
- statistics: result.statistics,
233
+ node: nodes.length === 1 ? nodes[0] : undefined,
234
+ nodes: nodes.length > 1 ? nodes : undefined,
235
+ updatedCount: nodes.length,
236
+ updated: nodes.length > 0,
426
237
  };
427
238
  }
428
- async deleteNode(connection, options, transaction) {
239
+ async deleteNode(options, transaction) {
429
240
  var _a, _b;
430
- const startTime = Date.now();
241
+ this.ensureConnected();
242
+ let query;
431
243
  const params = {};
432
- let matchClause = 'MATCH (n)';
433
- if (options.id !== undefined) {
434
- matchClause = 'MATCH (n) WHERE id(n) = $nodeId';
435
- params.nodeId = typeof options.id === 'string' ? parseInt(options.id, 10) : options.id;
436
- }
437
- else if (options.labels) {
438
- const labels = this.normalizeLabels(options.labels);
439
- matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
244
+ const detach = options.detach ? 'DETACH ' : '';
245
+ if (options.id) {
246
+ query = `MATCH (n) WHERE id(n) = $id ${detach}DELETE n RETURN count(n) as count`;
247
+ params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
440
248
  }
441
- if (options.where) {
442
- const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
443
- matchClause += options.id === undefined && !options.labels ? ` WHERE ${clause}` : ` AND ${clause}`;
444
- Object.assign(params, whereParams);
249
+ else {
250
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
251
+ const labelClause = labels ? `:${labels}` : '';
252
+ query = `MATCH (n${labelClause})`;
253
+ if (options.where) {
254
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
255
+ query += ` WHERE ${clause}`;
256
+ Object.assign(params, whereParams);
257
+ }
258
+ query += ` ${detach}DELETE n RETURN count(n) as count`;
445
259
  }
446
- const deleteCmd = options.detach ? 'DETACH DELETE' : 'DELETE';
447
- const query = `${matchClause} ${deleteCmd} n`;
448
- const result = await this.executeRaw(connection, { query, params }, transaction);
260
+ const session = this.getSession(transaction);
261
+ const result = await session.run(query, params);
262
+ const count = this.toNumber((_b = result.records[0]) === null || _b === void 0 ? void 0 : _b.get('count')) || 0;
449
263
  return {
450
- success: true,
451
- executionTime: Date.now() - startTime,
452
- deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesDeleted) || 0,
453
- deletedRelationshipsCount: ((_b = result.statistics) === null || _b === void 0 ? void 0 : _b.relationshipsDeleted) || 0,
454
- statistics: result.statistics,
264
+ deleted: count > 0,
265
+ deletedCount: count,
455
266
  };
456
267
  }
457
- async mergeNode(connection, options, transaction) {
458
- var _a;
459
- const startTime = Date.now();
460
- const labels = this.normalizeLabels(options.labels);
461
- const labelStr = labels.map(l => this.escapeIdentifier(l)).join(':');
268
+ async mergeNode(options, transaction) {
269
+ this.ensureConnected();
270
+ const labels = options.labels.join(':');
271
+ const matchProps = Object.entries(options.matchProperties)
272
+ .map(([key]) => `${key}: $match_${key}`)
273
+ .join(', ');
274
+ let query = `MERGE (n:${labels} {${matchProps}})`;
462
275
  const params = {};
463
- const matchProps = [];
464
- Object.entries(options.matchProperties).forEach(([key, value], index) => {
465
- const paramName = `match_${index}`;
466
- matchProps.push(`${this.escapeIdentifier(key)}: $${paramName}`);
467
- params[paramName] = value;
276
+ // Add match properties to params
277
+ Object.entries(options.matchProperties).forEach(([key, value]) => {
278
+ params[`match_${key}`] = value;
468
279
  });
469
- let query = `MERGE (n:${labelStr} {${matchProps.join(', ')}})`;
470
- if (options.onCreate && Object.keys(options.onCreate).length > 0) {
471
- const createProps = [];
472
- Object.entries(options.onCreate).forEach(([key, value], index) => {
473
- const paramName = `create_${index}`;
474
- createProps.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
475
- params[paramName] = value;
476
- });
477
- query += ` ON CREATE SET ${createProps.join(', ')}`;
280
+ if (options.onCreate) {
281
+ query += ' ON CREATE SET n += $onCreateProps';
282
+ params.onCreateProps = options.onCreate;
283
+ }
284
+ if (options.onMatch) {
285
+ query += ' ON MATCH SET n += $onMatchProps';
286
+ params.onMatchProps = options.onMatch;
287
+ }
288
+ query += ' RETURN n, id(n) as nodeId';
289
+ const session = this.getSession(transaction);
290
+ const result = await session.run(query, params);
291
+ const record = result.records[0];
292
+ const node = this.mapMemgraphNode(record.get('n'), record.get('nodeId'));
293
+ return {
294
+ node,
295
+ created: true, // Memgraph doesn't easily tell us if it was created or matched
296
+ merged: true,
297
+ };
298
+ }
299
+ // ==================== LABEL MANAGEMENT ====================
300
+ async addLabels(options, transaction) {
301
+ this.ensureConnected();
302
+ const labels = options.labels.map(l => `:\`${l}\``).join('');
303
+ const query = `
304
+ MATCH (n)
305
+ WHERE id(n) = $id
306
+ SET n${labels}
307
+ RETURN n, id(n) as nodeId
308
+ `;
309
+ const params = {
310
+ id: typeof options.id === 'number' ? options.id : parseInt(options.id, 10),
311
+ };
312
+ const session = this.getSession(transaction);
313
+ const result = await session.run(query, params);
314
+ if (result.records.length === 0) {
315
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
478
316
  }
479
- if (options.onMatch && Object.keys(options.onMatch).length > 0) {
480
- const matchSetProps = [];
481
- Object.entries(options.onMatch).forEach(([key, value], index) => {
482
- const paramName = `match_set_${index}`;
483
- matchSetProps.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
484
- params[paramName] = value;
485
- });
486
- query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
317
+ const record = result.records[0];
318
+ const node = this.mapMemgraphNode(record.get('n'), record.get('nodeId'));
319
+ return {
320
+ node,
321
+ addedLabels: options.labels,
322
+ };
323
+ }
324
+ async removeLabels(options, transaction) {
325
+ this.ensureConnected();
326
+ const labels = options.labels.map(l => `:\`${l}\``).join('');
327
+ const query = `
328
+ MATCH (n)
329
+ WHERE id(n) = $id
330
+ REMOVE n${labels}
331
+ RETURN n, id(n) as nodeId
332
+ `;
333
+ const params = {
334
+ id: typeof options.id === 'number' ? options.id : parseInt(options.id, 10),
335
+ };
336
+ const session = this.getSession(transaction);
337
+ const result = await session.run(query, params);
338
+ if (result.records.length === 0) {
339
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
487
340
  }
488
- query += ' RETURN n';
489
- const result = await this.executeRaw(connection, { query, params }, transaction);
490
- const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesCreated) || 0) > 0;
341
+ const record = result.records[0];
342
+ const node = this.mapMemgraphNode(record.get('n'), record.get('nodeId'));
491
343
  return {
492
- success: true,
493
- executionTime: Date.now() - startTime,
494
- node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
495
- created,
496
- matched: !created,
497
- statistics: result.statistics,
344
+ node,
345
+ removedLabels: options.labels,
346
+ };
347
+ }
348
+ async setLabels(options, transaction) {
349
+ this.ensureConnected();
350
+ // First get current labels
351
+ const getQuery = `
352
+ MATCH (n)
353
+ WHERE id(n) = $id
354
+ RETURN labels(n) as currentLabels
355
+ `;
356
+ const params = {
357
+ id: typeof options.id === 'number' ? options.id : parseInt(options.id, 10),
358
+ };
359
+ const session = this.getSession(transaction);
360
+ const getResult = await session.run(getQuery, params);
361
+ if (getResult.records.length === 0) {
362
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
363
+ }
364
+ const previousLabels = getResult.records[0].get('currentLabels');
365
+ // Remove all existing labels and add new ones
366
+ const removeLabels = previousLabels.map(l => `:\`${l}\``).join('');
367
+ const addLabels = options.labels.map(l => `:\`${l}\``).join('');
368
+ const setQuery = `
369
+ MATCH (n)
370
+ WHERE id(n) = $id
371
+ REMOVE n${removeLabels}
372
+ SET n${addLabels}
373
+ RETURN n, id(n) as nodeId
374
+ `;
375
+ const result = await session.run(setQuery, params);
376
+ const node = this.mapMemgraphNode(result.records[0].get('n'), result.records[0].get('nodeId'));
377
+ return {
378
+ node,
379
+ previousLabels,
380
+ newLabels: options.labels,
498
381
  };
499
382
  }
500
383
  // ==================== RELATIONSHIP OPERATIONS ====================
501
- async createRelationship(connection, options, transaction) {
502
- var _a;
503
- const startTime = Date.now();
504
- const params = {};
505
- const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
506
- const toMatch = this.buildNodeReference(options.toNode, 'to', params);
507
- let propsClause = '';
508
- if (options.properties && Object.keys(options.properties).length > 0) {
509
- const { clause, params: propParams } = this.buildPropertiesClause(options.properties, 'rel_');
510
- propsClause = ` ${clause}`;
511
- Object.assign(params, propParams);
512
- }
384
+ async createRelationship(options, transaction) {
385
+ this.ensureConnected();
513
386
  const query = `
514
- MATCH ${fromMatch}, ${toMatch}
515
- CREATE (from)-[r:${this.escapeIdentifier(options.type)}${propsClause}]->(to)
516
- RETURN r
387
+ MATCH (a), (b)
388
+ WHERE id(a) = $startId AND id(b) = $endId
389
+ CREATE (a)-[r:${options.type} $props]->(b)
390
+ RETURN r, id(r) as relId, id(a) as startId, id(b) as endId
517
391
  `;
518
- const result = await this.executeRaw(connection, { query, params }, transaction);
392
+ const params = {
393
+ startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
394
+ endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
395
+ props: options.properties || {},
396
+ };
397
+ const session = this.getSession(transaction);
398
+ const result = await session.run(query, params);
399
+ const record = result.records[0];
400
+ const rel = record.get('r');
519
401
  return {
520
- success: true,
521
- executionTime: Date.now() - startTime,
522
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
523
- created: (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0,
524
- statistics: result.statistics,
402
+ relationship: this.mapMemgraphRelationship(rel, record.get('relId'), record.get('startId'), record.get('endId')),
403
+ created: true,
525
404
  };
526
405
  }
527
- async findRelationships(connection, options, transaction) {
528
- const startTime = Date.now();
406
+ async findRelationships(options, transaction) {
407
+ this.ensureConnected();
408
+ const types = options.type
409
+ ? (Array.isArray(options.type) ? options.type.join('|') : options.type)
410
+ : (options.types ? options.types.join('|') : '');
411
+ const typeClause = types ? `:${types}` : '';
412
+ let query = `MATCH (a)-[r${typeClause}]->(b)`;
529
413
  const params = {};
530
- let typePattern = '';
531
- if (options.type) {
532
- const types = Array.isArray(options.type) ? options.type : [options.type];
533
- typePattern = ':' + types.map(t => this.escapeIdentifier(t)).join('|');
414
+ const conditions = [];
415
+ if (options.startNodeId) {
416
+ conditions.push('id(a) = $startId');
417
+ params.startId = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10);
534
418
  }
535
- const directionStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
536
- const directionEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
537
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
538
- let query = `MATCH (from)${directionStart}[r${typePattern}]${directionEnd}(to)`;
539
- const whereParts = [];
540
- if (options.fromNode && options.fromNode.id) {
541
- params.fromId = typeof options.fromNode.id === 'string'
542
- ? parseInt(options.fromNode.id, 10)
543
- : options.fromNode.id;
544
- whereParts.push('id(from) = $fromId');
545
- }
546
- if (options.toNode && options.toNode.id) {
547
- params.toId = typeof options.toNode.id === 'string'
548
- ? parseInt(options.toNode.id, 10)
549
- : options.toNode.id;
550
- whereParts.push('id(to) = $toId');
551
- }
552
- if (options.properties) {
553
- Object.entries(options.properties).forEach(([key, value], index) => {
554
- const paramName = `rel_prop_${index}`;
555
- whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
556
- params[paramName] = value;
557
- });
419
+ if (options.endNodeId) {
420
+ conditions.push('id(b) = $endId');
421
+ params.endId = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10);
558
422
  }
559
- if (whereParts.length > 0) {
560
- query += ` WHERE ${whereParts.join(' AND ')}`;
423
+ if (options.where) {
424
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
425
+ conditions.push(clause);
426
+ Object.assign(params, whereParams);
561
427
  }
562
- query += options.includeNodes ? ' RETURN r, from, to' : ' RETURN r';
563
- if (options.orderBy && options.orderBy.length > 0) {
564
- const orderParts = options.orderBy.map(o => `r.${this.escapeIdentifier(o.property)} ${o.direction}`);
565
- query += ` ORDER BY ${orderParts.join(', ')}`;
428
+ if (conditions.length > 0) {
429
+ query += ` WHERE ${conditions.join(' AND ')}`;
566
430
  }
567
- if (options.skip !== undefined) {
431
+ query += ' RETURN r, id(r) as relId, id(a) as startId, id(b) as endId';
432
+ if (options.skip) {
568
433
  query += ` SKIP ${options.skip}`;
569
434
  }
570
- if (options.limit !== undefined) {
435
+ if (options.limit) {
571
436
  query += ` LIMIT ${options.limit}`;
572
437
  }
573
- const result = await this.executeRaw(connection, { query, params }, transaction);
574
- const relationships = result.data.map(row => this.parseRelationship(row.r));
438
+ const session = this.getSession(transaction);
439
+ const result = await session.run(query, params);
440
+ const relationships = result.records.map((record) => this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId')));
575
441
  return {
576
- success: true,
577
- executionTime: Date.now() - startTime,
578
442
  relationships,
579
443
  count: relationships.length,
580
- hasMore: options.limit !== undefined && relationships.length === options.limit,
581
444
  };
582
445
  }
583
- async findRelationshipById(connection, id, transaction) {
584
- const query = `MATCH ()-[r]->() WHERE id(r) = $id RETURN r`;
585
- const result = await this.executeRaw(connection, { query, params: { id: typeof id === 'string' ? parseInt(id, 10) : id } }, transaction);
586
- if (result.data.length === 0) {
446
+ async findRelationshipById(id, transaction) {
447
+ this.ensureConnected();
448
+ const query = `
449
+ MATCH (a)-[r]->(b)
450
+ WHERE id(r) = $id
451
+ RETURN r, id(r) as relId, id(a) as startId, id(b) as endId
452
+ `;
453
+ const session = this.getSession(transaction);
454
+ const result = await session.run(query, {
455
+ id: typeof id === 'number' ? id : parseInt(id, 10),
456
+ });
457
+ if (result.records.length === 0) {
587
458
  return null;
588
459
  }
589
- return this.parseRelationship(result.data[0].r);
460
+ const record = result.records[0];
461
+ return this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId'));
590
462
  }
591
- async updateRelationship(connection, options, transaction) {
592
- var _a;
593
- const startTime = Date.now();
594
- const params = {};
595
- let matchClause = 'MATCH ()-[r]->()';
596
- if (options.id !== undefined) {
597
- matchClause = 'MATCH ()-[r]->() WHERE id(r) = $relId';
598
- params.relId = typeof options.id === 'string' ? parseInt(options.id, 10) : options.id;
599
- }
600
- else if (options.type) {
601
- matchClause = `MATCH ()-[r:${this.escapeIdentifier(options.type)}]->()`;
602
- }
603
- const setParts = [];
604
- if (options.set) {
605
- Object.entries(options.set).forEach(([key, value], index) => {
606
- const paramName = `set_${index}`;
607
- setParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
608
- params[paramName] = value;
609
- });
610
- }
611
- let query = matchClause;
612
- if (setParts.length > 0) {
613
- query += ` SET ${setParts.join(', ')}`;
463
+ async updateRelationship(options, transaction) {
464
+ this.ensureConnected();
465
+ let query;
466
+ const params = { props: options.properties };
467
+ if (options.id) {
468
+ query = `
469
+ MATCH (a)-[r]->(b)
470
+ WHERE id(r) = $id
471
+ SET r += $props
472
+ RETURN r, id(r) as relId, id(a) as startId, id(b) as endId
473
+ `;
474
+ params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
614
475
  }
615
- if (options.remove && options.remove.length > 0) {
616
- query += ` REMOVE ${options.remove.map(p => `r.${this.escapeIdentifier(p)}`).join(', ')}`;
476
+ else {
477
+ const typeClause = options.type ? `:${options.type}` : '';
478
+ query = `MATCH (a)-[r${typeClause}]->(b)`;
479
+ if (options.where) {
480
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
481
+ query += ` WHERE ${clause}`;
482
+ Object.assign(params, whereParams);
483
+ }
484
+ query += ' SET r += $props RETURN r, id(r) as relId, id(a) as startId, id(b) as endId';
617
485
  }
618
- query += ' RETURN r';
619
- const result = await this.executeRaw(connection, { query, params }, transaction);
486
+ const session = this.getSession(transaction);
487
+ const result = await session.run(query, params);
488
+ const relationships = result.records.map((record) => this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId')));
620
489
  return {
621
- success: true,
622
- executionTime: Date.now() - startTime,
623
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
624
- updated: result.data.length > 0,
625
- matchedCount: result.data.length,
626
- modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
627
- statistics: result.statistics,
490
+ relationship: relationships.length === 1 ? relationships[0] : undefined,
491
+ relationships: relationships.length > 1 ? relationships : undefined,
492
+ updatedCount: relationships.length,
493
+ updated: relationships.length > 0,
628
494
  };
629
495
  }
630
- async deleteRelationship(connection, options, transaction) {
496
+ async deleteRelationship(options, transaction) {
631
497
  var _a;
632
- const startTime = Date.now();
498
+ this.ensureConnected();
499
+ let query;
633
500
  const params = {};
634
- let matchClause = 'MATCH ()-[r]->()';
635
- if (options.id !== undefined) {
636
- matchClause = 'MATCH ()-[r]->() WHERE id(r) = $relId';
637
- params.relId = typeof options.id === 'string' ? parseInt(options.id, 10) : options.id;
501
+ if (options.id) {
502
+ query = `MATCH ()-[r]->() WHERE id(r) = $id DELETE r RETURN count(r) as count`;
503
+ params.id = typeof options.id === 'number' ? options.id : parseInt(options.id, 10);
638
504
  }
639
- else if (options.type) {
640
- const types = Array.isArray(options.type) ? options.type : [options.type];
641
- matchClause = `MATCH ()-[r:${types.map(t => this.escapeIdentifier(t)).join('|')}]->()`;
505
+ else {
506
+ const typeClause = options.type ? `:${options.type}` : '';
507
+ query = `MATCH (a)-[r${typeClause}]->(b)`;
508
+ const conditions = [];
509
+ if (options.startNodeId) {
510
+ conditions.push('id(a) = $startId');
511
+ params.startId = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10);
512
+ }
513
+ if (options.endNodeId) {
514
+ conditions.push('id(b) = $endId');
515
+ params.endId = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10);
516
+ }
517
+ if (options.where) {
518
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
519
+ conditions.push(clause);
520
+ Object.assign(params, whereParams);
521
+ }
522
+ if (conditions.length > 0) {
523
+ query += ` WHERE ${conditions.join(' AND ')}`;
524
+ }
525
+ query += ' DELETE r RETURN count(r) as count';
642
526
  }
643
- const query = `${matchClause} DELETE r`;
644
- const result = await this.executeRaw(connection, { query, params }, transaction);
527
+ const session = this.getSession(transaction);
528
+ const result = await session.run(query, params);
529
+ const count = this.toNumber((_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0;
645
530
  return {
646
- success: true,
647
- executionTime: Date.now() - startTime,
648
- deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsDeleted) || 0,
649
- statistics: result.statistics,
531
+ deleted: count > 0,
532
+ deletedCount: count,
650
533
  };
651
534
  }
652
- async mergeRelationship(connection, options, transaction) {
653
- var _a;
654
- const startTime = Date.now();
655
- const params = {};
656
- const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
657
- const toMatch = this.buildNodeReference(options.toNode, 'to', params);
535
+ async mergeRelationship(options, transaction) {
536
+ this.ensureConnected();
658
537
  let matchPropsClause = '';
659
- if (options.matchProperties && Object.keys(options.matchProperties).length > 0) {
660
- const { clause, params: matchParams } = this.buildPropertiesClause(options.matchProperties, 'match_');
661
- matchPropsClause = ` ${clause}`;
662
- Object.assign(params, matchParams);
538
+ const params = {
539
+ startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
540
+ endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
541
+ };
542
+ if (options.matchProperties) {
543
+ const matchProps = Object.entries(options.matchProperties)
544
+ .map(([key]) => `${key}: $match_${key}`)
545
+ .join(', ');
546
+ matchPropsClause = ` {${matchProps}}`;
547
+ Object.entries(options.matchProperties).forEach(([key, value]) => {
548
+ params[`match_${key}`] = value;
549
+ });
663
550
  }
664
551
  let query = `
665
- MATCH ${fromMatch}, ${toMatch}
666
- MERGE (from)-[r:${this.escapeIdentifier(options.type)}${matchPropsClause}]->(to)
552
+ MATCH (a), (b)
553
+ WHERE id(a) = $startId AND id(b) = $endId
554
+ MERGE (a)-[r:${options.type}${matchPropsClause}]->(b)
667
555
  `;
668
- if (options.onCreate && Object.keys(options.onCreate).length > 0) {
669
- const createProps = [];
670
- Object.entries(options.onCreate).forEach(([key, value], index) => {
671
- const paramName = `create_${index}`;
672
- createProps.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
673
- params[paramName] = value;
674
- });
675
- query += ` ON CREATE SET ${createProps.join(', ')}`;
676
- }
677
- if (options.onMatch && Object.keys(options.onMatch).length > 0) {
678
- const matchSetProps = [];
679
- Object.entries(options.onMatch).forEach(([key, value], index) => {
680
- const paramName = `match_set_${index}`;
681
- matchSetProps.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
682
- params[paramName] = value;
683
- });
684
- query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
685
- }
686
- query += ' RETURN r';
687
- const result = await this.executeRaw(connection, { query, params }, transaction);
688
- const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0;
556
+ if (options.onCreate) {
557
+ query += ' ON CREATE SET r += $onCreateProps';
558
+ params.onCreateProps = options.onCreate;
559
+ }
560
+ if (options.onMatch) {
561
+ query += ' ON MATCH SET r += $onMatchProps';
562
+ params.onMatchProps = options.onMatch;
563
+ }
564
+ query += ' RETURN r, id(r) as relId, id(a) as startId, id(b) as endId';
565
+ const session = this.getSession(transaction);
566
+ const result = await session.run(query, params);
567
+ const record = result.records[0];
568
+ const relationship = this.mapMemgraphRelationship(record.get('r'), record.get('relId'), record.get('startId'), record.get('endId'));
689
569
  return {
690
- success: true,
691
- executionTime: Date.now() - startTime,
692
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
693
- created,
694
- matched: !created,
695
- statistics: result.statistics,
570
+ relationship,
571
+ created: true,
572
+ merged: true,
696
573
  };
697
574
  }
698
- // ==================== PATH & TRAVERSAL OPERATIONS ====================
699
- async traverse(connection, options, transaction) {
700
- const startTime = Date.now();
701
- const params = {};
702
- const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
575
+ // ==================== TRAVERSAL OPERATIONS ====================
576
+ async traverse(options, transaction) {
577
+ var _a;
578
+ this.ensureConnected();
579
+ const direction = this.getDirectionArrow(options.direction);
580
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
581
+ const relClause = relTypes ? `:${relTypes}` : '';
703
582
  const minDepth = options.minDepth || 1;
704
- const maxDepth = options.maxDepth || 10;
705
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
706
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
707
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
583
+ const maxDepth = options.maxDepth || 3;
708
584
  const query = `
709
- MATCH ${startNodeMatch}
710
- MATCH path = (start)${dirStart}[*${minDepth}..${maxDepth}]${dirEnd}(end)
711
- ${options.limit ? `WITH path LIMIT ${options.limit}` : ''}
585
+ MATCH path = (start)${direction.left}[${relClause}*${minDepth}..${maxDepth}]${direction.right}(end)
586
+ WHERE id(start) = $startId
712
587
  RETURN path
588
+ ${options.limit ? `LIMIT ${options.limit}` : ''}
713
589
  `;
714
- const result = await this.executeRaw(connection, { query, params }, transaction);
715
- const paths = [];
590
+ const params = {
591
+ startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
592
+ };
593
+ const session = this.getSession(transaction);
594
+ const result = await session.run(query, params);
595
+ const paths = result.records.map((record) => this.mapMemgraphPath(record.get('path')));
596
+ // Collect unique nodes and relationships
716
597
  const nodesMap = new Map();
717
598
  const relsMap = new Map();
718
- result.data.forEach(row => {
719
- if (row.path) {
720
- const parsedPath = this.parsePath(row.path);
721
- paths.push(parsedPath);
722
- parsedPath.nodes.forEach(n => nodesMap.set(String(n.id), n));
723
- parsedPath.relationships.forEach(r => relsMap.set(String(r.id), r));
724
- }
599
+ paths.forEach(path => {
600
+ path.nodes.forEach(node => nodesMap.set(String(node.id), node));
601
+ path.relationships.forEach(rel => relsMap.set(String(rel.id), rel));
725
602
  });
726
603
  return {
727
- success: true,
728
- executionTime: Date.now() - startTime,
729
- paths: options.returnPaths ? paths : undefined,
730
- nodes: options.returnNodes ? Array.from(nodesMap.values()) : undefined,
604
+ paths,
605
+ nodes: Array.from(nodesMap.values()),
731
606
  relationships: Array.from(relsMap.values()),
732
607
  count: paths.length,
733
608
  };
734
609
  }
735
- async shortestPath(connection, options, transaction) {
736
- const startTime = Date.now();
737
- const params = {};
738
- const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
739
- const endNodeMatch = this.buildNodeSelectorMatch(options.endNode, 'end', params, 'end_');
740
- const maxDepth = options.maxDepth ? `*..${options.maxDepth}` : '*';
741
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
742
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
743
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
744
- let query;
745
- if (options.weightProperty) {
746
- // Memgraph weighted shortest path using WSP
747
- query = `
748
- MATCH ${startNodeMatch}, ${endNodeMatch}
749
- CALL algo.shortestPath(start, end, {
750
- relationship: null,
751
- weight: '${options.weightProperty}',
752
- default: ${options.defaultWeight || 1}
753
- }) YIELD path, weight
754
- RETURN path, weight
755
- `;
756
- }
757
- else if (options.returnAllShortest) {
758
- query = `
759
- MATCH ${startNodeMatch}, ${endNodeMatch}
760
- MATCH path = allShortestPaths((start)${dirStart}[${maxDepth}]${dirEnd}(end))
761
- RETURN path
762
- `;
763
- }
764
- else {
765
- query = `
766
- MATCH ${startNodeMatch}, ${endNodeMatch}
767
- MATCH path = shortestPath((start)${dirStart}[${maxDepth}]${dirEnd}(end))
768
- RETURN path
769
- `;
770
- }
771
- const result = await this.executeRaw(connection, { query, params }, transaction);
772
- if (result.data.length === 0) {
773
- return {
774
- success: true,
775
- executionTime: Date.now() - startTime,
776
- found: false,
777
- };
610
+ async shortestPath(options, transaction) {
611
+ var _a;
612
+ this.ensureConnected();
613
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
614
+ const relClause = relTypes ? `:${relTypes}` : '';
615
+ const maxDepth = options.maxDepth || 15;
616
+ // Use BFS for shortest path in Memgraph
617
+ const query = `
618
+ MATCH (start), (end)
619
+ WHERE id(start) = $startId AND id(end) = $endId
620
+ MATCH path = shortestPath((start)-[${relClause}*..${maxDepth}]-(end))
621
+ RETURN path
622
+ `;
623
+ const params = {
624
+ startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
625
+ endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
626
+ };
627
+ const session = this.getSession(transaction);
628
+ const result = await session.run(query, params);
629
+ if (result.records.length === 0) {
630
+ return { path: null, found: false };
778
631
  }
779
- const paths = result.data.map(row => {
780
- const parsedPath = this.parsePath(row.path);
781
- if (row.weight !== undefined) {
782
- return Object.assign(Object.assign({}, parsedPath), { totalWeight: row.weight, weights: [] });
783
- }
784
- return parsedPath;
785
- });
632
+ const path = this.mapMemgraphPath(result.records[0].get('path'));
786
633
  return {
787
- success: true,
788
- executionTime: Date.now() - startTime,
789
- path: options.returnAllShortest ? undefined : paths[0],
790
- paths: options.returnAllShortest ? paths : undefined,
634
+ path,
635
+ length: path.length,
791
636
  found: true,
792
- length: paths[0].length,
793
- totalWeight: paths[0].totalWeight,
637
+ totalWeight: options.weightProperty
638
+ ? path.relationships.reduce((sum, r) => sum + (r.properties[options.weightProperty] || 0), 0)
639
+ : undefined,
794
640
  };
795
641
  }
796
- async allPaths(connection, options, transaction) {
797
- const startTime = Date.now();
798
- const params = {};
799
- const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
800
- const endNodeMatch = this.buildNodeSelectorMatch(options.endNode, 'end', params, 'end_');
642
+ async allPaths(options, transaction) {
643
+ var _a;
644
+ this.ensureConnected();
645
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
646
+ const relClause = relTypes ? `:${relTypes}` : '';
801
647
  const minDepth = options.minDepth || 1;
802
- const maxDepth = options.maxDepth || 10;
803
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
804
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
805
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
806
- let query = `
807
- MATCH ${startNodeMatch}, ${endNodeMatch}
808
- MATCH path = (start)${dirStart}[*${minDepth}..${maxDepth}]${dirEnd}(end)
648
+ const maxDepth = options.maxDepth || 5;
649
+ const limit = options.limit || options.maxPaths;
650
+ const query = `
651
+ MATCH (start), (end)
652
+ WHERE id(start) = $startId AND id(end) = $endId
653
+ MATCH path = (start)-[${relClause}*${minDepth}..${maxDepth}]-(end)
809
654
  RETURN path
655
+ ${limit ? `LIMIT ${limit}` : ''}
810
656
  `;
811
- if (options.limit) {
812
- query += ` LIMIT ${options.limit}`;
813
- }
814
- const result = await this.executeRaw(connection, { query, params }, transaction);
815
- const paths = result.data.map(row => this.parsePath(row.path));
657
+ const params = {
658
+ startId: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10),
659
+ endId: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10),
660
+ };
661
+ const session = this.getSession(transaction);
662
+ const result = await session.run(query, params);
663
+ const paths = result.records.map((record) => this.mapMemgraphPath(record.get('path')));
816
664
  return {
817
- success: true,
818
- executionTime: Date.now() - startTime,
819
665
  paths,
820
666
  count: paths.length,
667
+ total: paths.length,
821
668
  };
822
669
  }
823
- async matchPattern(connection, options, transaction) {
824
- const startTime = Date.now();
825
- const params = {};
826
- const { pattern } = options;
827
- const nodePatterns = [];
828
- pattern.nodes.forEach(node => {
829
- const labels = node.labels
830
- ? ':' + (Array.isArray(node.labels) ? node.labels : [node.labels])
831
- .map(l => this.escapeIdentifier(l)).join(':')
832
- : '';
833
- let props = '';
834
- if (node.properties && Object.keys(node.properties).length > 0) {
835
- const { clause, params: nodeParams } = this.buildPropertiesClause(node.properties, `${node.variable}_`);
836
- props = ` ${clause}`;
837
- Object.assign(params, nodeParams);
838
- }
839
- nodePatterns.push(`(${node.variable}${labels}${props})`);
840
- });
841
- const matchClauses = [];
842
- if (pattern.relationships.length === 0) {
843
- matchClauses.push(`MATCH ${nodePatterns.join(', ')}`);
844
- }
845
- else {
846
- pattern.relationships.forEach(rel => {
847
- const relVar = rel.variable || '';
848
- const types = rel.type
849
- ? ':' + (Array.isArray(rel.type) ? rel.type : [rel.type])
850
- .map(t => this.escapeIdentifier(t)).join('|')
851
- : '';
852
- const dirStart = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
853
- const dirEnd = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
854
- rel.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
855
- let hops = '';
856
- if (rel.minHops !== undefined || rel.maxHops !== undefined) {
857
- const min = rel.minHops || '';
858
- const max = rel.maxHops || '';
859
- hops = `*${min}..${max}`;
860
- }
861
- matchClauses.push(`MATCH (${rel.startNode})${dirStart}[${relVar}${types}${hops}]${dirEnd}(${rel.endNode})`);
862
- });
863
- }
864
- let query = matchClauses.join(' ');
865
- if (pattern.where) {
866
- const conditions = pattern.where.conditions
867
- .map(c => c.expression)
868
- .join(pattern.where.operator === 'OR' ? ' OR ' : ' AND ');
869
- query += ` WHERE ${conditions}`;
870
- }
871
- const returnVars = options.return || pattern.nodes.map(n => n.variable);
872
- query += ` RETURN ${returnVars.join(', ')}`;
873
- if (options.orderBy && options.orderBy.length > 0) {
874
- const orderParts = options.orderBy.map(o => `${o.expression} ${o.direction}`);
875
- query += ` ORDER BY ${orderParts.join(', ')}`;
876
- }
877
- if (options.skip !== undefined) {
878
- query += ` SKIP ${options.skip}`;
879
- }
880
- if (options.limit !== undefined) {
881
- query += ` LIMIT ${options.limit}`;
882
- }
883
- const result = await this.executeRaw(connection, { query, params }, transaction);
884
- return {
885
- success: true,
886
- executionTime: Date.now() - startTime,
887
- matches: result.data,
888
- count: result.data.length,
889
- hasMore: options.limit !== undefined && result.data.length === options.limit,
890
- };
891
- }
892
- async extractSubgraph(connection, options, transaction) {
893
- const startTime = Date.now();
894
- const params = {};
895
- const startNodes = Array.isArray(options.startNodes) ? options.startNodes : [options.startNodes];
896
- const startMatches = startNodes.map((node, idx) => this.buildNodeSelectorMatch(node, `start${idx}`, params, `start${idx}_`));
897
- const maxDepth = options.maxDepth || 3;
898
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
899
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
900
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
901
- const query = `
902
- MATCH ${startMatches.join(', ')}
903
- WITH [${startNodes.map((_, i) => `start${i}`).join(', ')}] AS starts
904
- UNWIND starts AS start
905
- MATCH path = (start)${dirStart}[*0..${maxDepth}]${dirEnd}(n)
906
- WITH COLLECT(DISTINCT n) AS nodes, COLLECT(relationships(path)) AS rels
907
- UNWIND rels AS relList
908
- UNWIND relList AS r
909
- RETURN nodes, COLLECT(DISTINCT r) AS relationships
910
- `;
911
- const result = await this.executeRaw(connection, { query, params }, transaction);
912
- const nodes = [];
913
- const relationships = [];
914
- if (result.data.length > 0) {
915
- const row = result.data[0];
916
- if (row.nodes) {
917
- row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
918
- }
919
- if (row.relationships) {
920
- row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
921
- }
922
- }
923
- return {
924
- success: true,
925
- executionTime: Date.now() - startTime,
926
- subgraph: {
927
- nodes,
928
- relationships,
929
- nodeCount: nodes.length,
930
- relationshipCount: relationships.length,
931
- },
932
- };
933
- }
934
- async getNeighborhood(connection, options, transaction) {
935
- const startTime = Date.now();
936
- const params = {};
937
- const centerMatch = this.buildNodeSelectorMatch(options.node, 'center', params);
670
+ async getNeighborhood(options, transaction) {
671
+ var _a;
672
+ this.ensureConnected();
673
+ const direction = this.getDirectionArrow(options.direction);
674
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
675
+ const relClause = relTypes ? `:${relTypes}` : '';
938
676
  const depth = options.depth || 1;
939
- let relTypes = '';
940
- if (options.relationshipTypes && options.relationshipTypes.length > 0) {
941
- relTypes = ':' + options.relationshipTypes.map(t => this.escapeIdentifier(t)).join('|');
942
- }
943
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
944
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
945
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
677
+ const limit = options.limit;
946
678
  const query = `
947
- MATCH ${centerMatch}
948
- MATCH path = (center)${dirStart}[${relTypes}*0..${depth}]${dirEnd}(n)
949
- WITH COLLECT(DISTINCT n) AS nodes, COLLECT(relationships(path)) AS rels
950
- UNWIND rels AS relList
951
- UNWIND relList AS r
952
- RETURN nodes, COLLECT(DISTINCT r) AS relationships
679
+ MATCH (start)
680
+ WHERE id(start) = $nodeId
681
+ MATCH path = (start)${direction.left}[r${relClause}*1..${depth}]${direction.right}(neighbor)
682
+ RETURN DISTINCT neighbor, id(neighbor) as neighborId, r
683
+ ${limit ? `LIMIT ${limit}` : ''}
953
684
  `;
954
- const result = await this.executeRaw(connection, { query, params }, transaction);
955
- const nodes = [];
956
- const relationships = [];
957
- if (result.data.length > 0) {
958
- const row = result.data[0];
959
- if (row.nodes) {
960
- row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
685
+ const params = {
686
+ nodeId: typeof options.nodeId === 'number' ? options.nodeId : parseInt(options.nodeId, 10),
687
+ };
688
+ const session = this.getSession(transaction);
689
+ const result = await session.run(query, params);
690
+ const nodesMap = new Map();
691
+ const relationshipsSet = [];
692
+ result.records.forEach((record) => {
693
+ const neighbor = record.get('neighbor');
694
+ const neighborId = record.get('neighborId');
695
+ const nodeKey = String(this.toNumber(neighborId));
696
+ if (!nodesMap.has(nodeKey)) {
697
+ nodesMap.set(nodeKey, this.mapMemgraphNode(neighbor, neighborId));
961
698
  }
962
- if (row.relationships) {
963
- row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
699
+ const rels = record.get('r');
700
+ if (Array.isArray(rels)) {
701
+ rels.forEach((rel) => {
702
+ relationshipsSet.push(this.mapMemgraphRelationship(rel, rel.identity, rel.start, rel.end));
703
+ });
964
704
  }
965
- }
705
+ });
966
706
  return {
967
- success: true,
968
- executionTime: Date.now() - startTime,
969
- nodes,
970
- relationships,
971
- levels: new Map(),
707
+ nodes: Array.from(nodesMap.values()),
708
+ relationships: relationshipsSet,
709
+ depth,
972
710
  };
973
711
  }
974
- async findConnectedComponents(connection, options, transaction) {
975
- const startTime = Date.now();
976
- // Memgraph has built-in algorithm support through MAGE library
977
- const query = `
978
- CALL algo.weaklyConnectedComponents() YIELD node, componentId
979
- RETURN componentId, COLLECT(node) AS nodes
980
- ORDER BY size(nodes) DESC
981
- `;
712
+ async findConnectedComponents(options, transaction) {
713
+ var _a;
714
+ this.ensureConnected();
715
+ // Memgraph has MAGE library for graph algorithms
716
+ // Use weakly connected components algorithm
717
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
718
+ const labelClause = labels ? `:${labels}` : '';
982
719
  try {
983
- const result = await this.executeRaw(connection, { query }, transaction);
984
- const components = result.data.map((row, idx) => ({
985
- id: row.componentId || idx,
986
- nodes: (row.nodes || []).map((n) => this.parseNode(n)),
987
- size: (row.nodes || []).length,
720
+ // Try using MAGE library first (if installed)
721
+ const query = `
722
+ CALL weakly_connected_components.get()
723
+ YIELD node, component_id
724
+ WITH component_id, collect(node) as nodes
725
+ RETURN nodes, size(nodes) as size, component_id
726
+ ORDER BY size DESC
727
+ `;
728
+ const session = this.getSession(transaction);
729
+ const result = await session.run(query, {});
730
+ const components = result.records.map((record) => ({
731
+ nodes: record.get('nodes').map((n) => this.mapMemgraphNode(n, n.identity)),
732
+ size: this.toNumber(record.get('size')),
988
733
  }));
989
- if (options.minSize) {
990
- return {
991
- success: true,
992
- executionTime: Date.now() - startTime,
993
- components: components.filter(c => c.size >= options.minSize),
994
- count: components.filter(c => c.size >= options.minSize).length,
995
- };
996
- }
997
734
  return {
998
- success: true,
999
- executionTime: Date.now() - startTime,
1000
735
  components,
1001
736
  count: components.length,
1002
737
  };
1003
738
  }
1004
- catch (_a) {
1005
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Connected components requires MAGE library in Memgraph');
739
+ catch (_b) {
740
+ // Fallback to basic Cypher implementation
741
+ const query = `
742
+ MATCH (n${labelClause})
743
+ WITH collect(n) as allNodes
744
+ UNWIND allNodes as node
745
+ MATCH path = (node)-[*]-(connected)
746
+ WITH node, collect(DISTINCT connected) + [node] as component
747
+ WITH collect(DISTINCT component) as allComponents
748
+ UNWIND allComponents as comp
749
+ WITH comp, size(comp) as compSize
750
+ RETURN comp as nodes, compSize as size
751
+ ORDER BY size DESC
752
+ `;
753
+ const session = this.getSession(transaction);
754
+ const result = await session.run(query, {});
755
+ const components = result.records.map((record) => ({
756
+ nodes: record.get('nodes').map((n) => this.mapMemgraphNode(n, n.identity)),
757
+ size: this.toNumber(record.get('size')),
758
+ }));
759
+ return {
760
+ components,
761
+ count: components.length,
762
+ };
1006
763
  }
1007
764
  }
1008
765
  // ==================== AGGREGATION OPERATIONS ====================
1009
- async countNodes(connection, labels, where, transaction) {
766
+ async countNodes(labels, where, transaction) {
1010
767
  var _a;
1011
- const startTime = Date.now();
768
+ this.ensureConnected();
769
+ const labelClause = (labels === null || labels === void 0 ? void 0 : labels.length) ? `:${labels.join(':')}` : '';
770
+ let query = `MATCH (n${labelClause})`;
1012
771
  const params = {};
1013
- let labelStr = '';
1014
- if (labels) {
1015
- const labelArr = Array.isArray(labels) ? labels : [labels];
1016
- labelStr = ':' + labelArr.map(l => this.escapeIdentifier(l)).join(':');
1017
- }
1018
- let query = `MATCH (n${labelStr})`;
1019
- if (where && Object.keys(where).length > 0) {
1020
- const whereParts = [];
1021
- Object.entries(where).forEach(([key, value], index) => {
1022
- const paramName = `where_${index}`;
1023
- whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
1024
- params[paramName] = value;
1025
- });
1026
- query += ` WHERE ${whereParts.join(' AND ')}`;
772
+ if (where) {
773
+ const { clause, params: whereParams } = this.buildWhereClause(where, 'n');
774
+ query += ` WHERE ${clause}`;
775
+ Object.assign(params, whereParams);
1027
776
  }
1028
- query += ' RETURN count(n) AS count';
1029
- const result = await this.executeRaw(connection, { query, params }, transaction);
777
+ query += ' RETURN count(n) as count';
778
+ const session = this.getSession(transaction);
779
+ const result = await session.run(query, params);
1030
780
  return {
1031
- success: true,
1032
- executionTime: Date.now() - startTime,
1033
- count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
781
+ count: this.toNumber((_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0,
1034
782
  };
1035
783
  }
1036
- async countRelationships(connection, type, where, transaction) {
784
+ async countRelationships(types, where, transaction) {
1037
785
  var _a;
1038
- const startTime = Date.now();
786
+ this.ensureConnected();
787
+ const typeClause = (types === null || types === void 0 ? void 0 : types.length) ? `:${types.join('|')}` : '';
788
+ let query = `MATCH ()-[r${typeClause}]->()`;
1039
789
  const params = {};
1040
- let typeStr = '';
1041
- if (type) {
1042
- const typeArr = Array.isArray(type) ? type : [type];
1043
- typeStr = ':' + typeArr.map(t => this.escapeIdentifier(t)).join('|');
1044
- }
1045
- let query = `MATCH ()-[r${typeStr}]->()`;
1046
- if (where && Object.keys(where).length > 0) {
1047
- const whereParts = [];
1048
- Object.entries(where).forEach(([key, value], index) => {
1049
- const paramName = `where_${index}`;
1050
- whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
1051
- params[paramName] = value;
1052
- });
1053
- query += ` WHERE ${whereParts.join(' AND ')}`;
790
+ if (where) {
791
+ const { clause, params: whereParams } = this.buildWhereClause(where, 'r');
792
+ query += ` WHERE ${clause}`;
793
+ Object.assign(params, whereParams);
1054
794
  }
1055
- query += ' RETURN count(r) AS count';
1056
- const result = await this.executeRaw(connection, { query, params }, transaction);
795
+ query += ' RETURN count(r) as count';
796
+ const session = this.getSession(transaction);
797
+ const result = await session.run(query, params);
1057
798
  return {
1058
- success: true,
1059
- executionTime: Date.now() - startTime,
1060
- count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
799
+ count: this.toNumber((_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0,
1061
800
  };
1062
801
  }
1063
- async getStatistics(connection, transaction) {
1064
- const startTime = Date.now();
1065
- const query = `
1066
- MATCH (n)
1067
- WITH count(n) AS nodeCount
1068
- MATCH ()-[r]->()
1069
- RETURN nodeCount, count(r) AS relCount
1070
- `;
1071
- const result = await this.executeRaw(connection, { query }, transaction);
1072
- const row = result.data[0] || {};
802
+ async getStatistics(transaction) {
803
+ var _a, _b;
804
+ this.ensureConnected();
805
+ const session = this.getSession(transaction);
806
+ const nodeCountResult = await session.run('MATCH (n) RETURN count(n) as count');
807
+ const relCountResult = await session.run('MATCH ()-[r]->() RETURN count(r) as count');
1073
808
  return {
1074
- success: true,
1075
- executionTime: Date.now() - startTime,
1076
- nodeCount: this.toNumber(row.nodeCount || 0),
1077
- relationshipCount: this.toNumber(row.relCount || 0),
1078
- labelCounts: {},
1079
- relationshipTypeCounts: {},
809
+ nodeCount: this.toNumber((_a = nodeCountResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) || 0,
810
+ relationshipCount: this.toNumber((_b = relCountResult.records[0]) === null || _b === void 0 ? void 0 : _b.get('count')) || 0,
1080
811
  };
1081
812
  }
1082
813
  // ==================== SEARCH OPERATIONS ====================
1083
- async fullTextSearch(connection, options, transaction) {
1084
- const startTime = Date.now();
1085
- // Memgraph uses text search index
814
+ async fullTextSearch(options, transaction) {
815
+ this.ensureConnected();
816
+ // Memgraph supports text search through MAGE text_search module
817
+ // Use the index name to search
1086
818
  const query = `
1087
- CALL mg.text_search('${options.index}', '${options.query}')
819
+ CALL text_search.search($indexName, $searchQuery, $limit)
1088
820
  YIELD node, score
1089
- ${options.labels ? `WHERE ${options.labels.map(l => `'${l}' IN labels(node)`).join(' OR ')}` : ''}
1090
- RETURN node${options.score ? ', score' : ''}
1091
- ${options.limit ? `LIMIT ${options.limit}` : ''}
821
+ RETURN node, id(node) as nodeId, score
1092
822
  `;
1093
- const result = await this.executeRaw(connection, { query }, transaction);
1094
- const nodes = result.data.map(row => {
1095
- const node = this.parseNode(row.node);
1096
- if (options.score && row.score !== undefined) {
1097
- return Object.assign(Object.assign({}, node), { score: row.score });
1098
- }
1099
- return node;
823
+ const session = this.getSession(transaction);
824
+ const result = await session.run(query, {
825
+ indexName: options.indexName,
826
+ searchQuery: options.query,
827
+ limit: options.limit || 100,
1100
828
  });
829
+ const nodes = result.records.map((r) => this.mapMemgraphNode(r.get('node'), r.get('nodeId')));
830
+ const scores = result.records.map((r) => r.get('score') || 1.0);
1101
831
  return {
1102
- success: true,
1103
- executionTime: Date.now() - startTime,
1104
832
  nodes,
1105
- count: nodes.length,
833
+ scores,
1106
834
  };
1107
835
  }
1108
- async vectorSearch(connection, options, transaction) {
1109
- // Memgraph doesn't have built-in vector search (as of early 2024)
1110
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Vector search is not natively supported in Memgraph');
836
+ async vectorSearch(_options, _transaction) {
837
+ // Memgraph doesn't natively support vector search yet
838
+ // This would require a custom implementation or external service
839
+ throw graph_error_1.GraphError.unsupportedOperationError('Vector search is not natively supported in Memgraph. Consider using an external vector database.', this.graphType);
840
+ }
841
+ // ==================== RAW QUERY ====================
842
+ async query(options, transaction) {
843
+ var _a, _b;
844
+ this.ensureConnected();
845
+ const session = this.getSession(transaction);
846
+ const result = await session.run(options.query, options.params || {});
847
+ return {
848
+ records: result.records.map((r) => r.toObject()),
849
+ summary: {
850
+ resultAvailableAfter: this.toNumber((_a = result.summary) === null || _a === void 0 ? void 0 : _a.resultAvailableAfter),
851
+ resultConsumedAfter: this.toNumber((_b = result.summary) === null || _b === void 0 ? void 0 : _b.resultConsumedAfter),
852
+ },
853
+ };
1111
854
  }
1112
855
  // ==================== SCHEMA OPERATIONS ====================
1113
- async createNodeConstraint(connection, constraint, transaction) {
1114
- const startTime = Date.now();
856
+ async createNodeIndex(options) {
857
+ this.ensureConnected();
858
+ // Memgraph uses CREATE INDEX ON :Label(property)
859
+ const query = `CREATE INDEX ON :${options.label}(${options.properties.join(', ')})`;
860
+ const session = this.getSession();
861
+ await session.run(query);
862
+ return { created: true, name: options.name };
863
+ }
864
+ async createNodeConstraint(options) {
865
+ this.ensureConnected();
1115
866
  let query;
1116
- const props = constraint.properties.join(', ');
1117
- switch (constraint.type) {
1118
- case node_types_1.NodeConstraintType.UNIQUE:
1119
- query = `CREATE CONSTRAINT ON (n:${this.escapeIdentifier(constraint.label)}) ASSERT n.${constraint.properties[0]} IS UNIQUE`;
867
+ const property = options.property || (options.properties && options.properties[0]);
868
+ switch (options.type) {
869
+ case 'UNIQUE':
870
+ // Memgraph uses CREATE CONSTRAINT ON (n:Label) ASSERT n.property IS UNIQUE
871
+ query = `CREATE CONSTRAINT ON (n:${options.label}) ASSERT n.${property} IS UNIQUE`;
1120
872
  break;
1121
- case node_types_1.NodeConstraintType.EXISTS:
1122
- query = `CREATE CONSTRAINT ON (n:${this.escapeIdentifier(constraint.label)}) ASSERT EXISTS (n.${constraint.properties[0]})`;
873
+ case 'EXISTS':
874
+ query = `CREATE CONSTRAINT ON (n:${options.label}) ASSERT EXISTS (n.${property})`;
1123
875
  break;
1124
876
  default:
1125
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Constraint type ${constraint.type} not supported in Memgraph`);
1126
- }
1127
- await this.executeRaw(connection, { query }, transaction);
1128
- return {
1129
- success: true,
1130
- executionTime: Date.now() - startTime,
1131
- name: constraint.name,
1132
- created: true,
1133
- };
877
+ throw graph_error_1.GraphError.validationError(`Unsupported constraint type: ${options.type}`);
878
+ }
879
+ const session = this.getSession();
880
+ await session.run(query);
881
+ return { created: true, name: options.name };
882
+ }
883
+ async createRelationshipIndex(options) {
884
+ this.ensureConnected();
885
+ // Memgraph relationship indexes
886
+ const query = `CREATE INDEX ON :${options.type}(${options.properties.join(', ')})`;
887
+ const session = this.getSession();
888
+ await session.run(query);
889
+ return { created: true, name: options.name };
890
+ }
891
+ async listIndexes() {
892
+ this.ensureConnected();
893
+ const query = 'SHOW INDEX INFO';
894
+ const session = this.getSession();
895
+ const result = await session.run(query);
896
+ const indexes = result.records.map((r) => ({
897
+ name: r.get('index name') || '',
898
+ labelOrType: r.get('label') || '',
899
+ properties: [r.get('property') || ''],
900
+ unique: false, // Memgraph doesn't distinguish in SHOW INDEX INFO
901
+ type: r.get('index type') || 'BTREE',
902
+ state: 'ONLINE',
903
+ }));
904
+ return { indexes };
1134
905
  }
1135
- async createRelationshipConstraint(connection, constraint, transaction) {
1136
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Relationship constraints are not supported in Memgraph');
906
+ async listConstraints() {
907
+ this.ensureConnected();
908
+ const query = 'SHOW CONSTRAINT INFO';
909
+ const session = this.getSession();
910
+ const result = await session.run(query);
911
+ const constraints = result.records.map((r) => ({
912
+ name: `constraint_${r.get('label')}_${r.get('property')}`,
913
+ label: r.get('label') || '',
914
+ property: r.get('property') || '',
915
+ type: r.get('constraint type') || 'UNIQUE',
916
+ }));
917
+ return { constraints };
1137
918
  }
1138
- async dropConstraint(connection, name, transaction) {
1139
- const startTime = Date.now();
1140
- // Memgraph constraint drop syntax
1141
- const query = `DROP CONSTRAINT ON (n) ASSERT n.${name} IS UNIQUE`;
919
+ async dropIndex(name) {
920
+ this.ensureConnected();
921
+ // In Memgraph, we need label and property to drop index
922
+ // This is a simplified version
923
+ const query = `DROP INDEX ON :${name}`;
924
+ const session = this.getSession();
1142
925
  try {
1143
- await this.executeRaw(connection, { query }, transaction);
926
+ await session.run(query);
927
+ return { dropped: true };
1144
928
  }
1145
929
  catch (_a) {
1146
- // Try existence constraint
1147
- const existsQuery = `DROP CONSTRAINT ON (n) ASSERT EXISTS (n.${name})`;
1148
- await this.executeRaw(connection, { query: existsQuery }, transaction);
930
+ return { dropped: false };
1149
931
  }
1150
- return {
1151
- success: true,
1152
- executionTime: Date.now() - startTime,
1153
- name,
1154
- dropped: true,
1155
- };
1156
932
  }
1157
- async listConstraints(connection, transaction) {
1158
- const startTime = Date.now();
1159
- const query = 'SHOW CONSTRAINT INFO';
1160
- const result = await this.executeRaw(connection, { query }, transaction);
1161
- const constraints = result.data.map((row) => ({
1162
- name: row.constraint_name || row.name || '',
1163
- type: row.type || 'UNIQUE',
1164
- entityType: 'NODE',
1165
- labelsOrTypes: [row.label || ''],
1166
- properties: [row.property || ''],
1167
- }));
1168
- return {
1169
- success: true,
1170
- executionTime: Date.now() - startTime,
1171
- constraints,
1172
- };
933
+ async dropConstraint(name) {
934
+ this.ensureConnected();
935
+ // Memgraph requires the full constraint definition to drop
936
+ // This is a simplified version that might need adjustment
937
+ const query = `DROP CONSTRAINT ON (n:${name}) ASSERT n.id IS UNIQUE`;
938
+ const session = this.getSession();
939
+ try {
940
+ await session.run(query);
941
+ return { dropped: true };
942
+ }
943
+ catch (_a) {
944
+ return { dropped: false };
945
+ }
946
+ }
947
+ // ==================== SCHEMA INTROSPECTION ====================
948
+ async listLabels() {
949
+ var _a, _b, _c, _d;
950
+ this.ensureConnected();
951
+ const session = this.getSession();
952
+ // Get all labels using Memgraph's CALL mg.labels()
953
+ const labelsResult = await session.run('CALL mg.labels() YIELD label RETURN label');
954
+ const labelNames = labelsResult.records.map((r) => r.get('label'));
955
+ const labels = [];
956
+ for (const labelName of labelNames) {
957
+ // Get count for each label
958
+ const countResult = await session.run(`MATCH (n:\`${labelName}\`) RETURN count(n) as count`);
959
+ const count = ((_c = (_b = (_a = countResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber) === null || _c === void 0 ? void 0 : _c.call(_b)) ||
960
+ ((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
961
+ // Get properties for a sample of nodes with this label
962
+ const propsResult = await session.run(`MATCH (n:\`${labelName}\`) WITH n LIMIT 100
963
+ UNWIND keys(n) as key
964
+ RETURN DISTINCT key`);
965
+ const properties = propsResult.records.map((r) => ({
966
+ name: r.get('key'),
967
+ type: 'unknown',
968
+ }));
969
+ labels.push({
970
+ name: labelName,
971
+ count: typeof count === 'number' ? count : Number(count),
972
+ properties,
973
+ });
974
+ }
975
+ return { labels };
976
+ }
977
+ async listRelationshipTypes() {
978
+ var _a, _b, _c, _d;
979
+ this.ensureConnected();
980
+ const session = this.getSession();
981
+ // Get all relationship types using Memgraph's CALL mg.relationship_types()
982
+ const typesResult = await session.run('CALL mg.relationship_types() YIELD relationshipType RETURN relationshipType');
983
+ const typeNames = typesResult.records.map((r) => r.get('relationshipType'));
984
+ const types = [];
985
+ for (const typeName of typeNames) {
986
+ // Get count for each type
987
+ const countResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() RETURN count(r) as count`);
988
+ const count = ((_c = (_b = (_a = countResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber) === null || _c === void 0 ? void 0 : _c.call(_b)) ||
989
+ ((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
990
+ // Get source and target label information
991
+ const endpointsResult = await session.run(`MATCH (a)-[r:\`${typeName}\`]->(b)
992
+ WITH labels(a) as fromLabels, labels(b) as toLabels
993
+ RETURN DISTINCT fromLabels[0] as fromLabel, toLabels[0] as toLabel
994
+ LIMIT 10`);
995
+ const fromLabelsArray = endpointsResult.records
996
+ .map((r) => r.get('fromLabel'))
997
+ .filter((l) => Boolean(l));
998
+ const fromLabels = [...new Set(fromLabelsArray)];
999
+ const toLabelsArray = endpointsResult.records
1000
+ .map((r) => r.get('toLabel'))
1001
+ .filter((l) => Boolean(l));
1002
+ const toLabels = [...new Set(toLabelsArray)];
1003
+ // Get properties for relationships of this type
1004
+ const propsResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() WITH r LIMIT 100
1005
+ UNWIND keys(r) as key
1006
+ RETURN DISTINCT key`);
1007
+ const properties = propsResult.records.map((r) => ({
1008
+ name: r.get('key'),
1009
+ type: 'unknown',
1010
+ }));
1011
+ types.push({
1012
+ type: typeName,
1013
+ count: typeof count === 'number' ? count : Number(count),
1014
+ fromLabels,
1015
+ toLabels,
1016
+ properties: properties.length > 0 ? properties : undefined,
1017
+ });
1018
+ }
1019
+ return { types };
1173
1020
  }
1174
- async createNodeIndex(connection, index, transaction) {
1175
- const startTime = Date.now();
1176
- const props = index.properties.map(p => `n.${this.escapeIdentifier(p)}`).join(', ');
1177
- const query = `CREATE INDEX ON :${this.escapeIdentifier(index.label)}(${index.properties.join(', ')})`;
1178
- await this.executeRaw(connection, { query }, transaction);
1021
+ // ==================== TRANSACTION OPERATIONS ====================
1022
+ async beginTransaction(_options) {
1023
+ this.ensureConnected();
1024
+ const session = this.driver.session();
1025
+ const tx = session.beginTransaction();
1179
1026
  return {
1180
- success: true,
1181
- executionTime: Date.now() - startTime,
1182
- name: index.name,
1183
- created: true,
1027
+ id: `tx_${Date.now()}`,
1028
+ status: enums_1.GraphTransactionStatus.ACTIVE,
1029
+ client: tx,
1030
+ nativeTransaction: tx,
1031
+ startTime: new Date(),
1032
+ commit: async () => {
1033
+ await tx.commit();
1034
+ await session.close();
1035
+ },
1036
+ rollback: async () => {
1037
+ await tx.rollback();
1038
+ await session.close();
1039
+ },
1184
1040
  };
1185
1041
  }
1186
- async createRelationshipIndex(connection, index, transaction) {
1187
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Relationship indexes are not directly supported in Memgraph');
1042
+ async commitTransaction(transaction) {
1043
+ if (transaction.commit) {
1044
+ await transaction.commit();
1045
+ }
1188
1046
  }
1189
- async dropIndex(connection, name, transaction) {
1190
- const startTime = Date.now();
1191
- // Memgraph requires label and property for index drop
1192
- const query = `DROP INDEX ON :${name}`;
1193
- await this.executeRaw(connection, { query }, transaction);
1194
- return {
1195
- success: true,
1196
- executionTime: Date.now() - startTime,
1197
- name,
1198
- dropped: true,
1199
- };
1047
+ async rollbackTransaction(transaction) {
1048
+ if (transaction.rollback) {
1049
+ await transaction.rollback();
1050
+ }
1200
1051
  }
1201
- async listIndexes(connection, transaction) {
1202
- const startTime = Date.now();
1203
- const query = 'SHOW INDEX INFO';
1204
- const result = await this.executeRaw(connection, { query }, transaction);
1205
- const indexes = result.data.map((row) => ({
1206
- name: `${row.label}_${row.property}`,
1207
- type: row.type || 'BTREE',
1208
- entityType: 'NODE',
1209
- labelsOrTypes: [row.label || ''],
1210
- properties: [row.property || ''],
1211
- state: 'ONLINE',
1052
+ // ==================== MEMGRAPH-SPECIFIC FEATURES ====================
1053
+ /**
1054
+ * Create a trigger in Memgraph
1055
+ */
1056
+ async createTrigger(name, event, target, procedure) {
1057
+ this.ensureConnected();
1058
+ const eventClause = `${event === 'CREATE' ? 'CREATED' : event === 'UPDATE' ? 'UPDATED' : 'DELETED'}`;
1059
+ const targetClause = target === 'NODE' ? 'VERTEX' : 'EDGE';
1060
+ const query = `
1061
+ CREATE TRIGGER ${name}
1062
+ ON ${eventClause} ${targetClause}
1063
+ EXECUTE ${procedure}
1064
+ `;
1065
+ const session = this.getSession();
1066
+ await session.run(query);
1067
+ }
1068
+ /**
1069
+ * Drop a trigger in Memgraph
1070
+ */
1071
+ async dropTrigger(name) {
1072
+ this.ensureConnected();
1073
+ const query = `DROP TRIGGER ${name}`;
1074
+ const session = this.getSession();
1075
+ await session.run(query);
1076
+ }
1077
+ /**
1078
+ * List all triggers in Memgraph
1079
+ */
1080
+ async listTriggers() {
1081
+ this.ensureConnected();
1082
+ const query = 'SHOW TRIGGERS';
1083
+ const session = this.getSession();
1084
+ const result = await session.run(query);
1085
+ return result.records.map((r) => ({
1086
+ name: r.get('trigger name'),
1087
+ statement: r.get('statement'),
1212
1088
  }));
1213
- return {
1214
- success: true,
1215
- executionTime: Date.now() - startTime,
1216
- indexes,
1217
- };
1218
1089
  }
1219
- // ==================== UTILITY METHODS ====================
1220
- escapeIdentifier(identifier) {
1221
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
1222
- return identifier;
1223
- }
1224
- return `\`${identifier.replace(/`/g, '``')}\``;
1225
- }
1226
- escapeValue(value) {
1227
- if (value === null)
1228
- return 'null';
1229
- if (typeof value === 'string')
1230
- return `'${value.replace(/'/g, "\\'")}'`;
1231
- if (typeof value === 'number')
1232
- return String(value);
1233
- if (typeof value === 'boolean')
1234
- return value ? 'true' : 'false';
1235
- if (value instanceof Date)
1236
- return `datetime('${value.toISOString()}')`;
1237
- if (Array.isArray(value))
1238
- return `[${value.map(v => this.escapeValue(v)).join(', ')}]`;
1239
- return String(value);
1090
+ /**
1091
+ * Create a stream consumer in Memgraph
1092
+ */
1093
+ async createStream(name, type, topics, transformationProcedure, config) {
1094
+ this.ensureConnected();
1095
+ const configStr = Object.entries(config)
1096
+ .map(([k, v]) => `${k} = '${v}'`)
1097
+ .join(', ');
1098
+ const query = `
1099
+ CREATE ${type} STREAM ${name}
1100
+ TOPICS ${topics.join(', ')}
1101
+ TRANSFORM ${transformationProcedure}
1102
+ ${configStr ? `CONFIGS { ${configStr} }` : ''}
1103
+ `;
1104
+ const session = this.getSession();
1105
+ await session.run(query);
1106
+ }
1107
+ /**
1108
+ * Run a MAGE algorithm (if installed)
1109
+ */
1110
+ async runMageAlgorithm(algorithm, params = {}) {
1111
+ this.ensureConnected();
1112
+ const paramsList = Object.entries(params)
1113
+ .map(([k]) => `${k}: $${k}`)
1114
+ .join(', ');
1115
+ const query = `CALL ${algorithm}(${paramsList ? `{${paramsList}}` : ''}) YIELD *`;
1116
+ const session = this.getSession();
1117
+ const result = await session.run(query, params);
1118
+ return result.records.map((r) => r.toObject());
1240
1119
  }
1241
- buildWhereClause(where, variableName = 'n') {
1120
+ // ==================== UTILITY METHODS ====================
1121
+ buildWhereClause(where, alias = 'n') {
1122
+ const conditions = [];
1242
1123
  const params = {};
1243
- const parts = [];
1244
- Object.entries(where).forEach(([key, value], index) => {
1245
- const paramName = `where_${index}`;
1246
- parts.push(`${variableName}.${this.escapeIdentifier(key)} = $${paramName}`);
1247
- params[paramName] = value;
1124
+ let paramIndex = 0;
1125
+ const processCondition = (key, value, prefix = '') => {
1126
+ const fullKey = prefix ? `${prefix}_${key}` : key;
1127
+ const paramName = `param_${paramIndex++}`;
1128
+ if (key === '$AND') {
1129
+ const subConditions = [];
1130
+ if (Array.isArray(value)) {
1131
+ value.forEach((v) => {
1132
+ Object.entries(v).forEach(([k, val]) => {
1133
+ processCondition(k, val, fullKey);
1134
+ subConditions.push(conditions.pop());
1135
+ });
1136
+ });
1137
+ }
1138
+ else {
1139
+ Object.entries(value).forEach(([k, v]) => {
1140
+ processCondition(k, v, fullKey);
1141
+ subConditions.push(conditions.pop());
1142
+ });
1143
+ }
1144
+ conditions.push(`(${subConditions.join(' AND ')})`);
1145
+ return;
1146
+ }
1147
+ if (key === '$OR') {
1148
+ const subConditions = [];
1149
+ if (Array.isArray(value)) {
1150
+ value.forEach((v) => {
1151
+ Object.entries(v).forEach(([k, val]) => {
1152
+ processCondition(k, val, fullKey);
1153
+ subConditions.push(conditions.pop());
1154
+ });
1155
+ });
1156
+ }
1157
+ else {
1158
+ Object.entries(value).forEach(([k, v]) => {
1159
+ processCondition(k, v, fullKey);
1160
+ subConditions.push(conditions.pop());
1161
+ });
1162
+ }
1163
+ conditions.push(`(${subConditions.join(' OR ')})`);
1164
+ return;
1165
+ }
1166
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
1167
+ Object.entries(value).forEach(([op, opValue]) => {
1168
+ const opParamName = `${paramName}_${op.toLowerCase()}`;
1169
+ switch (op) {
1170
+ case '$GT':
1171
+ conditions.push(`${alias}.${key} > $${opParamName}`);
1172
+ params[opParamName] = opValue;
1173
+ break;
1174
+ case '$GTE':
1175
+ conditions.push(`${alias}.${key} >= $${opParamName}`);
1176
+ params[opParamName] = opValue;
1177
+ break;
1178
+ case '$LT':
1179
+ conditions.push(`${alias}.${key} < $${opParamName}`);
1180
+ params[opParamName] = opValue;
1181
+ break;
1182
+ case '$LTE':
1183
+ conditions.push(`${alias}.${key} <= $${opParamName}`);
1184
+ params[opParamName] = opValue;
1185
+ break;
1186
+ case '$NE':
1187
+ conditions.push(`${alias}.${key} <> $${opParamName}`);
1188
+ params[opParamName] = opValue;
1189
+ break;
1190
+ case '$IN':
1191
+ conditions.push(`${alias}.${key} IN $${opParamName}`);
1192
+ params[opParamName] = opValue;
1193
+ break;
1194
+ case '$NOT_IN':
1195
+ conditions.push(`NOT ${alias}.${key} IN $${opParamName}`);
1196
+ params[opParamName] = opValue;
1197
+ break;
1198
+ case '$CONTAINS':
1199
+ conditions.push(`${alias}.${key} CONTAINS $${opParamName}`);
1200
+ params[opParamName] = opValue;
1201
+ break;
1202
+ case '$STARTS_WITH':
1203
+ conditions.push(`${alias}.${key} STARTS WITH $${opParamName}`);
1204
+ params[opParamName] = opValue;
1205
+ break;
1206
+ case '$ENDS_WITH':
1207
+ conditions.push(`${alias}.${key} ENDS WITH $${opParamName}`);
1208
+ params[opParamName] = opValue;
1209
+ break;
1210
+ case '$EXISTS':
1211
+ if (opValue) {
1212
+ conditions.push(`${alias}.${key} IS NOT NULL`);
1213
+ }
1214
+ else {
1215
+ conditions.push(`${alias}.${key} IS NULL`);
1216
+ }
1217
+ break;
1218
+ case '$REGEX':
1219
+ conditions.push(`${alias}.${key} =~ $${opParamName}`);
1220
+ params[opParamName] = opValue;
1221
+ break;
1222
+ }
1223
+ });
1224
+ }
1225
+ else {
1226
+ conditions.push(`${alias}.${key} = $${paramName}`);
1227
+ params[paramName] = value;
1228
+ }
1229
+ };
1230
+ Object.entries(where).forEach(([key, value]) => {
1231
+ processCondition(key, value);
1248
1232
  });
1249
1233
  return {
1250
- clause: parts.join(' AND '),
1234
+ clause: conditions.join(' AND ') || 'true',
1251
1235
  params,
1252
1236
  };
1253
1237
  }
1254
- // ==================== PROTECTED PARSER METHODS ====================
1255
- parseNode(nativeNode) {
1256
- if (!nativeNode) {
1257
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.NODE_ERROR, 'Cannot parse null node');
1258
- }
1259
- if (nativeNode.identity !== undefined) {
1260
- return {
1261
- id: this.toNumber(nativeNode.identity),
1262
- labels: nativeNode.labels || [],
1263
- properties: this.convertProperties(nativeNode.properties),
1264
- };
1238
+ parseError(error) {
1239
+ if (error instanceof graph_error_1.GraphError) {
1240
+ return error;
1265
1241
  }
1242
+ return graph_error_1.GraphError.queryError(String(error));
1243
+ }
1244
+ // ==================== PRIVATE HELPER METHODS ====================
1245
+ mapMemgraphNode(node, nodeId) {
1246
+ const id = nodeId !== undefined ? this.toNumber(nodeId) : this.toNumber(node.identity);
1266
1247
  return {
1267
- id: nativeNode.id || nativeNode.identity || '',
1268
- labels: nativeNode.labels || [],
1269
- properties: (nativeNode.properties || nativeNode),
1248
+ id: String(id),
1249
+ labels: node.labels || [],
1250
+ properties: this.convertProperties(node.properties || {}),
1270
1251
  };
1271
1252
  }
1272
- parseRelationship(nativeRelationship) {
1273
- if (!nativeRelationship) {
1274
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.RELATIONSHIP_ERROR, 'Cannot parse null relationship');
1275
- }
1276
- if (nativeRelationship.identity !== undefined) {
1277
- return {
1278
- id: this.toNumber(nativeRelationship.identity),
1279
- type: nativeRelationship.type,
1280
- startNodeId: this.toNumber(nativeRelationship.start),
1281
- endNodeId: this.toNumber(nativeRelationship.end),
1282
- properties: this.convertProperties(nativeRelationship.properties),
1283
- };
1284
- }
1253
+ mapMemgraphRelationship(rel, relId, startId, endId) {
1254
+ const id = relId !== undefined ? this.toNumber(relId) : this.toNumber(rel.identity);
1255
+ const start = startId !== undefined ? this.toNumber(startId) : this.toNumber(rel.start);
1256
+ const end = endId !== undefined ? this.toNumber(endId) : this.toNumber(rel.end);
1285
1257
  return {
1286
- id: nativeRelationship.id || nativeRelationship.identity || '',
1287
- type: nativeRelationship.type || '',
1288
- startNodeId: nativeRelationship.startNodeId || nativeRelationship.start || '',
1289
- endNodeId: nativeRelationship.endNodeId || nativeRelationship.end || '',
1290
- properties: (nativeRelationship.properties || nativeRelationship),
1258
+ id: String(id),
1259
+ type: rel.type,
1260
+ startNodeId: String(start),
1261
+ endNodeId: String(end),
1262
+ properties: this.convertProperties(rel.properties || {}),
1291
1263
  };
1292
1264
  }
1293
- parsePath(nativePath) {
1294
- if (!nativePath) {
1295
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.PATH_ERROR, 'Cannot parse null path');
1296
- }
1265
+ mapMemgraphPath(path) {
1297
1266
  const nodes = [];
1298
1267
  const relationships = [];
1299
- if (nativePath.segments) {
1300
- nativePath.segments.forEach((segment) => {
1301
- if (nodes.length === 0) {
1302
- nodes.push(this.parseNode(segment.start));
1268
+ if (path.segments) {
1269
+ path.segments.forEach((segment, index) => {
1270
+ if (index === 0) {
1271
+ nodes.push(this.mapMemgraphNode(segment.start, segment.start.identity));
1303
1272
  }
1304
- relationships.push(this.parseRelationship(segment.relationship));
1305
- nodes.push(this.parseNode(segment.end));
1273
+ nodes.push(this.mapMemgraphNode(segment.end, segment.end.identity));
1274
+ relationships.push(this.mapMemgraphRelationship(segment.relationship, segment.relationship.identity, segment.start.identity, segment.end.identity));
1306
1275
  });
1307
1276
  }
1308
1277
  return {
1309
1278
  nodes,
1310
1279
  relationships,
1311
1280
  length: relationships.length,
1312
- start: nodes[0],
1313
- end: nodes[nodes.length - 1],
1314
1281
  };
1315
1282
  }
1316
- // ==================== PRIVATE HELPER METHODS ====================
1283
+ convertProperties(props) {
1284
+ const result = {};
1285
+ for (const [key, value] of Object.entries(props)) {
1286
+ result[key] = this.convertValue(value);
1287
+ }
1288
+ return result;
1289
+ }
1317
1290
  convertValue(value) {
1318
- if (value === null || value === undefined)
1291
+ var _a, _b, _c;
1292
+ if (value === null || value === undefined) {
1319
1293
  return value;
1320
- // Handle Neo4j Integer type (used by Bolt protocol)
1321
- if (value && typeof value.toNumber === 'function') {
1322
- return value.toNumber();
1323
1294
  }
1324
- if (value.labels !== undefined && value.properties !== undefined) {
1325
- return this.parseNode(value);
1295
+ // Handle Integer type (from neo4j-driver)
1296
+ if (typeof value === 'object' && ((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Integer') {
1297
+ return this.toNumber(value);
1326
1298
  }
1327
- if (value.type !== undefined && value.start !== undefined && value.end !== undefined) {
1328
- return this.parseRelationship(value);
1329
- }
1330
- if (value.segments !== undefined) {
1331
- return this.parsePath(value);
1299
+ // Handle Date types
1300
+ if (typeof value === 'object' && (((_b = value.constructor) === null || _b === void 0 ? void 0 : _b.name) === 'Date' || ((_c = value.constructor) === null || _c === void 0 ? void 0 : _c.name) === 'DateTime')) {
1301
+ return new Date(value.toString());
1332
1302
  }
1333
1303
  if (Array.isArray(value)) {
1334
1304
  return value.map(v => this.convertValue(v));
1335
1305
  }
1336
- if (typeof value === 'object') {
1337
- const converted = {};
1338
- Object.entries(value).forEach(([key, val]) => {
1339
- converted[key] = this.convertValue(val);
1340
- });
1341
- return converted;
1342
- }
1343
1306
  return value;
1344
1307
  }
1345
- convertProperties(properties) {
1346
- if (!properties)
1347
- return {};
1348
- const converted = {};
1349
- Object.entries(properties).forEach(([key, value]) => {
1350
- converted[key] = this.convertValue(value);
1351
- });
1352
- return converted;
1353
- }
1354
1308
  toNumber(value) {
1355
- if (value && typeof value.toNumber === 'function') {
1356
- return value.toNumber();
1309
+ if (value === null || value === undefined) {
1310
+ return 0;
1357
1311
  }
1358
1312
  if (typeof value === 'number') {
1359
1313
  return value;
1360
1314
  }
1361
- return parseInt(value, 10) || 0;
1362
- }
1363
- normalizeLabels(labels) {
1364
- return Array.isArray(labels) ? labels : [labels];
1365
- }
1366
- buildPropertiesClause(properties, prefix = '') {
1367
- const params = {};
1368
- const propParts = [];
1369
- Object.entries(properties).forEach(([key, value], index) => {
1370
- const paramName = `${prefix}prop_${index}`;
1371
- propParts.push(`${this.escapeIdentifier(key)}: $${paramName}`);
1372
- params[paramName] = value;
1373
- });
1374
- return {
1375
- clause: `{${propParts.join(', ')}}`,
1376
- params,
1377
- };
1378
- }
1379
- buildNodeReference(ref, alias, params, prefix = '') {
1380
- let pattern = `(${alias}`;
1381
- if (ref.labels) {
1382
- const labels = this.normalizeLabels(ref.labels);
1383
- pattern += ':' + labels.map(l => this.escapeIdentifier(l)).join(':');
1384
- }
1385
- pattern += ')';
1386
- if (ref.id !== undefined) {
1387
- const paramName = `${prefix}id`;
1388
- params[paramName] = typeof ref.id === 'string' ? parseInt(ref.id, 10) : ref.id;
1389
- pattern += ` WHERE id(${alias}) = $${paramName}`;
1315
+ if (typeof value === 'object' && typeof value.toNumber === 'function') {
1316
+ return value.toNumber();
1390
1317
  }
1391
- return pattern;
1392
- }
1393
- buildWhereFromClause(where, alias, prefix = '') {
1394
- const params = {};
1395
- const clause = this.buildWhereCondition(where, alias, params, prefix);
1396
- return { clause, params };
1397
- }
1398
- buildWhereCondition(where, alias, params, prefix, index = 0) {
1399
- const paramName = `${prefix}where_${index}`;
1400
- let condition;
1401
- switch (where.operator) {
1402
- case node_types_1.NodeComparisonOperator.IS_NULL:
1403
- condition = `${alias}.${this.escapeIdentifier(where.property)} IS NULL`;
1404
- break;
1405
- case node_types_1.NodeComparisonOperator.IS_NOT_NULL:
1406
- condition = `${alias}.${this.escapeIdentifier(where.property)} IS NOT NULL`;
1407
- break;
1408
- case node_types_1.NodeComparisonOperator.IN:
1409
- case node_types_1.NodeComparisonOperator.NOT_IN:
1410
- params[paramName] = where.value;
1411
- condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
1412
- break;
1413
- case node_types_1.NodeComparisonOperator.CONTAINS:
1414
- params[paramName] = where.value;
1415
- condition = `${alias}.${this.escapeIdentifier(where.property)} CONTAINS $${paramName}`;
1416
- break;
1417
- case node_types_1.NodeComparisonOperator.STARTS_WITH:
1418
- params[paramName] = where.value;
1419
- condition = `${alias}.${this.escapeIdentifier(where.property)} STARTS WITH $${paramName}`;
1420
- break;
1421
- case node_types_1.NodeComparisonOperator.ENDS_WITH:
1422
- params[paramName] = where.value;
1423
- condition = `${alias}.${this.escapeIdentifier(where.property)} ENDS WITH $${paramName}`;
1424
- break;
1425
- case node_types_1.NodeComparisonOperator.REGEX:
1426
- params[paramName] = where.value;
1427
- condition = `${alias}.${this.escapeIdentifier(where.property)} =~ $${paramName}`;
1428
- break;
1318
+ if (typeof value === 'object' && typeof value.toInt === 'function') {
1319
+ return value.toInt();
1320
+ }
1321
+ return parseInt(String(value), 10) || 0;
1322
+ }
1323
+ getDirectionArrow(direction) {
1324
+ switch (direction) {
1325
+ case enums_1.TraversalDirection.OUTGOING:
1326
+ case 'OUTGOING':
1327
+ return { left: '-', right: '->' };
1328
+ case enums_1.TraversalDirection.INCOMING:
1329
+ case 'INCOMING':
1330
+ return { left: '<-', right: '-' };
1331
+ case enums_1.TraversalDirection.BOTH:
1332
+ case 'BOTH':
1429
1333
  default:
1430
- params[paramName] = where.value;
1431
- condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
1432
- }
1433
- if (where.and && where.and.length > 0) {
1434
- const andClauses = where.and.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 1));
1435
- condition = `(${condition} AND ${andClauses.join(' AND ')})`;
1436
- }
1437
- if (where.or && where.or.length > 0) {
1438
- const orClauses = where.or.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 100));
1439
- condition = `(${condition} OR ${orClauses.join(' OR ')})`;
1334
+ return { left: '-', right: '-' };
1440
1335
  }
1441
- return condition;
1442
- }
1443
- buildNodeSelectorMatch(selector, alias, params, prefix = '') {
1444
- let pattern = `(${alias}`;
1445
- if (selector.labels) {
1446
- const labels = this.normalizeLabels(selector.labels);
1447
- pattern += ':' + labels.map((l) => this.escapeIdentifier(l)).join(':');
1448
- }
1449
- pattern += ')';
1450
- const whereParts = [];
1451
- if (selector.id !== undefined) {
1452
- const paramName = `${prefix}id`;
1453
- params[paramName] = typeof selector.id === 'string' ? parseInt(selector.id, 10) : selector.id;
1454
- whereParts.push(`id(${alias}) = $${paramName}`);
1455
- }
1456
- if (selector.properties && Object.keys(selector.properties).length > 0) {
1457
- Object.entries(selector.properties).forEach(([key, value], index) => {
1458
- const paramName = `${prefix}prop_${index}`;
1459
- whereParts.push(`${alias}.${this.escapeIdentifier(key)} = $${paramName}`);
1460
- params[paramName] = value;
1461
- });
1462
- }
1463
- if (selector.where) {
1464
- const { clause, params: whereParams } = this.buildWhereFromClause(selector.where, alias, prefix);
1465
- whereParts.push(clause);
1466
- Object.assign(params, whereParams);
1467
- }
1468
- if (whereParts.length > 0) {
1469
- return `${pattern} WHERE ${whereParts.join(' AND ')}`;
1470
- }
1471
- return pattern;
1472
- }
1473
- parseStatistics(counters) {
1474
- var _a, _b, _c, _d, _e, _f, _g, _h;
1475
- if (!counters)
1476
- return undefined;
1477
- return {
1478
- nodesCreated: ((_a = counters.nodesCreated) === null || _a === void 0 ? void 0 : _a.call(counters)) || 0,
1479
- nodesDeleted: ((_b = counters.nodesDeleted) === null || _b === void 0 ? void 0 : _b.call(counters)) || 0,
1480
- relationshipsCreated: ((_c = counters.relationshipsCreated) === null || _c === void 0 ? void 0 : _c.call(counters)) || 0,
1481
- relationshipsDeleted: ((_d = counters.relationshipsDeleted) === null || _d === void 0 ? void 0 : _d.call(counters)) || 0,
1482
- propertiesSet: ((_e = counters.propertiesSet) === null || _e === void 0 ? void 0 : _e.call(counters)) || 0,
1483
- labelsAdded: ((_f = counters.labelsAdded) === null || _f === void 0 ? void 0 : _f.call(counters)) || 0,
1484
- labelsRemoved: ((_g = counters.labelsRemoved) === null || _g === void 0 ? void 0 : _g.call(counters)) || 0,
1485
- containsUpdates: ((_h = counters.containsUpdates) === null || _h === void 0 ? void 0 : _h.call(counters)) || false,
1486
- };
1487
1336
  }
1488
1337
  }
1489
1338
  exports.MemgraphAdapter = MemgraphAdapter;
1490
- exports.default = MemgraphAdapter;
1491
1339
  //# sourceMappingURL=memgraph.adapter.js.map