@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,7 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * Neo4j Graph Database Adapter
4
- * Implements the BaseGraphAdapter for Neo4j databases using the official neo4j-driver
3
+ * Neo4j Graph Adapter
4
+ *
5
+ * Adapter implementation for Neo4j graph database
6
+ * Uses the official neo4j-driver package
5
7
  */
6
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
9
  if (k2 === undefined) k2 = k;
@@ -38,1824 +40,1129 @@ var __importStar = (this && this.__importStar) || (function () {
38
40
  })();
39
41
  Object.defineProperty(exports, "__esModule", { value: true });
40
42
  exports.Neo4jAdapter = void 0;
41
- const neo4j_driver_1 = __importStar(require("neo4j-driver"));
43
+ const enums_1 = require("../types/enums");
42
44
  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");
46
- const path_types_1 = require("../types/path.types");
45
+ const graph_error_1 = require("../utils/graph-error");
47
46
  /**
48
- * Neo4j connection implementation
47
+ * Neo4j adapter implementation
49
48
  */
50
- class Neo4jConnection {
51
- constructor(config, id) {
52
- this.config = config;
53
- this.type = graph_types_1.GraphDatabaseType.NEO4J;
54
- this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
55
- this.queryLanguage = graph_types_1.GraphQueryLanguage.CYPHER;
49
+ class Neo4jAdapter extends base_adapter_1.BaseGraphAdapter {
50
+ constructor() {
51
+ super(...arguments);
52
+ this.graphType = enums_1.GraphType.NEO4J;
53
+ this.supportedFeatures = new Set([
54
+ enums_1.GraphFeature.TRANSACTIONS,
55
+ enums_1.GraphFeature.SCHEMA_INDEXES,
56
+ enums_1.GraphFeature.FULL_TEXT_SEARCH,
57
+ enums_1.GraphFeature.GRAPH_ALGORITHMS,
58
+ enums_1.GraphFeature.GEOSPATIAL,
59
+ ]);
56
60
  this.driver = null;
57
61
  this.session = null;
58
- this.id = id || `neo4j-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
59
- this.createdAt = new Date();
60
62
  }
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;
63
+ // ==================== CONNECTION MANAGEMENT ====================
64
+ async connect(options) {
67
65
  try {
68
- const authToken = neo4j_driver_1.default.auth.basic(this.config.username, this.config.password);
69
- const driverConfig = {
70
- maxConnectionPoolSize: this.config.maxConnectionPoolSize || this.config.poolSize || 50,
71
- connectionAcquisitionTimeout: this.config.connectionAcquisitionTimeout || 60000,
72
- connectionTimeout: this.config.connectionTimeout || 30000,
73
- };
74
- if (this.config.maxConnectionLifetime) {
75
- driverConfig.maxConnectionLifetime = this.config.maxConnectionLifetime;
76
- }
77
- if (this.config.encrypted !== undefined) {
78
- driverConfig.encrypted = this.config.encrypted;
79
- }
80
- if (this.config.trust) {
81
- driverConfig.trust = this.config.trust;
82
- }
83
- if (this.config.trustedCertificates) {
84
- driverConfig.trustedCertificates = this.config.trustedCertificates;
85
- }
86
- if ((_a = this.config.options) === null || _a === void 0 ? void 0 : _a.logging) {
87
- driverConfig.logging = this.config.options.logging;
88
- }
89
- this.driver = neo4j_driver_1.default.driver(this.config.uri, authToken, driverConfig);
90
- // Verify connectivity
66
+ const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
67
+ this.driver = neo4j.driver(options.connectionUrl, neo4j.auth.basic('neo4j', 'password'), // TODO: Extract from URL or options
68
+ options.options);
69
+ // Verify connection
91
70
  await this.driver.verifyConnectivity();
92
- this.status = graph_types_1.GraphConnectionStatus.CONNECTED;
93
- this.lastUsedAt = new Date();
94
- }
95
- catch (error) {
96
- this.status = graph_types_1.GraphConnectionStatus.ERROR;
97
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, `Failed to connect to Neo4j: ${error.message}`, error);
98
- }
99
- }
100
- async disconnect() {
101
- if (this.session) {
102
- await this.session.close();
103
- this.session = null;
104
- }
105
- if (this.driver) {
106
- await this.driver.close();
107
- this.driver = null;
108
- }
109
- this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
110
- }
111
- isConnected() {
112
- return this.status === graph_types_1.GraphConnectionStatus.CONNECTED && this.driver !== null;
113
- }
114
- getClient() {
115
- if (!this.driver) {
116
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Neo4j driver not initialized. Call connect() first.');
117
- }
118
- return this.driver;
119
- }
120
- getSession() {
121
- if (!this.driver) {
122
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'Neo4j driver not initialized. Call connect() first.');
123
- }
124
- const sessionConfig = {};
125
- if (this.config.database) {
126
- sessionConfig.database = this.config.database;
127
- }
128
- this.session = this.driver.session(sessionConfig);
129
- this.lastUsedAt = new Date();
130
- return this.session;
131
- }
132
- getDatabase() {
133
- return this.config.database || 'neo4j';
134
- }
135
- }
136
- /**
137
- * Neo4j transaction implementation
138
- */
139
- class Neo4jTransaction {
140
- constructor(connection, session, transaction) {
141
- this.connection = connection;
142
- this.session = session;
143
- this.status = graph_types_1.GraphTransactionStatus.PENDING;
144
- this.id = `tx-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
145
- this.createdAt = new Date();
146
- this.native = transaction;
147
- this.status = graph_types_1.GraphTransactionStatus.ACTIVE;
148
- }
149
- async commit() {
150
- if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
151
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Cannot commit transaction in ${this.status} state`);
152
- }
153
- try {
154
- await this.native.commit();
155
- this.status = graph_types_1.GraphTransactionStatus.COMMITTED;
156
- }
157
- catch (error) {
158
- this.status = graph_types_1.GraphTransactionStatus.FAILED;
159
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to commit transaction: ${error.message}`, error);
160
- }
161
- }
162
- async rollback() {
163
- if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
164
- return;
165
- }
166
- try {
167
- await this.native.rollback();
168
- this.status = graph_types_1.GraphTransactionStatus.ROLLED_BACK;
71
+ this.connected = true;
72
+ this.connectionUrl = options.connectionUrl;
73
+ return {
74
+ connected: true,
75
+ type: enums_1.GraphType.NEO4J,
76
+ latency: 0,
77
+ };
169
78
  }
170
79
  catch (error) {
171
- this.status = graph_types_1.GraphTransactionStatus.FAILED;
172
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to rollback transaction: ${error.message}`, error);
80
+ this.connected = false;
81
+ throw graph_error_1.GraphError.connectionError(`Failed to connect to Neo4j: ${error.message}`, error);
173
82
  }
174
83
  }
175
- isActive() {
176
- return this.status === graph_types_1.GraphTransactionStatus.ACTIVE;
177
- }
178
- }
179
- /**
180
- * Neo4j Graph Database Adapter
181
- */
182
- class Neo4jAdapter extends base_adapter_1.BaseGraphAdapter {
183
- constructor() {
184
- super(...arguments);
185
- this.type = graph_types_1.GraphDatabaseType.NEO4J;
186
- this.supportedLanguages = [graph_types_1.GraphQueryLanguage.CYPHER];
187
- this.defaultLanguage = graph_types_1.GraphQueryLanguage.CYPHER;
188
- }
189
- // ==================== CONNECTION METHODS ====================
190
- async connect(config) {
191
- if (config.type !== graph_types_1.GraphDatabaseType.NEO4J) {
192
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Invalid config type ${config.type}. Expected ${graph_types_1.GraphDatabaseType.NEO4J}`);
193
- }
194
- const connection = new Neo4jConnection(config);
195
- await connection.connect();
196
- return connection;
197
- }
198
- async disconnect(connection) {
199
- await connection.disconnect();
200
- }
201
- async testConnection(connection) {
84
+ async testConnection(options) {
202
85
  var _a;
203
- const startTime = Date.now();
204
86
  try {
205
- const session = connection.getSession();
206
- const result = await session.run('RETURN 1 AS test');
207
- await session.close();
208
- const driver = connection.getClient();
209
- const serverInfo = await driver.getServerInfo();
87
+ const neo4j = await Promise.resolve().then(() => __importStar(require('neo4j-driver')));
88
+ const startTime = Date.now();
89
+ const testDriver = neo4j.driver(options.connectionUrl, neo4j.auth.basic('neo4j', 'password'), Object.assign(Object.assign({}, options.options), { connectionTimeout: 5000 }));
90
+ await testDriver.verifyConnectivity();
91
+ const serverInfo = await testDriver.getServerInfo();
92
+ await testDriver.close();
210
93
  return {
211
94
  connected: true,
212
- message: 'Connection successful',
213
- databaseType: graph_types_1.GraphDatabaseType.NEO4J,
214
- queryLanguage: graph_types_1.GraphQueryLanguage.CYPHER,
215
- version: (_a = serverInfo.protocolVersion) === null || _a === void 0 ? void 0 : _a.toString(),
216
- responseTime: Date.now() - startTime,
95
+ type: enums_1.GraphType.NEO4J,
96
+ version: (_a = serverInfo === null || serverInfo === void 0 ? void 0 : serverInfo.protocolVersion) === null || _a === void 0 ? void 0 : _a.toString(),
97
+ latency: Date.now() - startTime,
217
98
  };
218
99
  }
219
100
  catch (error) {
220
101
  return {
221
102
  connected: false,
222
- message: 'Connection failed',
223
- databaseType: graph_types_1.GraphDatabaseType.NEO4J,
224
- queryLanguage: graph_types_1.GraphQueryLanguage.CYPHER,
225
- responseTime: Date.now() - startTime,
103
+ type: enums_1.GraphType.NEO4J,
226
104
  error: error.message,
227
105
  };
228
106
  }
229
107
  }
230
- async getDatabaseInfo(connection) {
231
- const session = connection.getSession();
232
- try {
233
- const result = await session.run('CALL dbms.components()');
234
- const record = result.records[0];
235
- return {
236
- version: record.get('versions')[0],
237
- edition: record.get('edition'),
238
- features: [],
239
- };
240
- }
241
- finally {
242
- await session.close();
243
- }
244
- }
245
- // ==================== TRANSACTION METHODS ====================
246
- async beginTransaction(connection, options) {
247
- const session = connection.getSession();
248
- const txConfig = {};
249
- if (options === null || options === void 0 ? void 0 : options.timeout) {
250
- txConfig.timeout = (0, neo4j_driver_1.int)(options.timeout);
108
+ async disconnect() {
109
+ if (this.session) {
110
+ await this.session.close();
111
+ this.session = null;
251
112
  }
252
- if (options === null || options === void 0 ? void 0 : options.metadata) {
253
- txConfig.metadata = options.metadata;
113
+ if (this.driver) {
114
+ await this.driver.close();
115
+ this.driver = null;
254
116
  }
255
- const accessMode = (options === null || options === void 0 ? void 0 : options.accessMode) === 'READ'
256
- ? neo4j_driver_1.default.session.READ
257
- : neo4j_driver_1.default.session.WRITE;
258
- const transaction = session.beginTransaction(txConfig);
259
- return new Neo4jTransaction(connection, session, transaction);
117
+ this.connected = false;
260
118
  }
261
- async commitTransaction(connection, transaction) {
262
- await transaction.commit();
263
- }
264
- async rollbackTransaction(connection, transaction) {
265
- await transaction.rollback();
266
- }
267
- // ==================== RAW QUERY METHODS ====================
268
- async executeRaw(connection, options, transaction) {
269
- const startTime = Date.now();
270
- try {
271
- let result;
272
- if (transaction && transaction.isActive()) {
273
- result = await transaction.native.run(options.query, options.params || {});
274
- }
275
- else {
276
- const session = connection.getSession();
277
- try {
278
- result = await session.run(options.query, options.params || {});
279
- }
280
- finally {
281
- await session.close();
282
- }
283
- }
284
- const records = result.records.map((record) => {
285
- const obj = {};
286
- record.keys.forEach((key) => {
287
- obj[key] = this.convertNeo4jValue(record.get(key));
288
- });
289
- return obj;
290
- });
291
- return {
292
- success: true,
293
- executionTime: Date.now() - startTime,
294
- data: records,
295
- columns: result.records.length > 0 ? result.records[0].keys.map(k => String(k)) : [],
296
- count: records.length,
297
- statistics: this.parseStatistics(result.summary.counters),
298
- };
119
+ getSession(transaction) {
120
+ if (transaction === null || transaction === void 0 ? void 0 : transaction.client) {
121
+ return transaction.client;
299
122
  }
300
- catch (error) {
301
- throw this.wrapError(error, graph_types_1.GraphErrorType.QUERY_ERROR, `Query execution failed: ${error.message}`, options.query, options.params);
123
+ if (!this.session) {
124
+ this.session = this.driver.session();
302
125
  }
126
+ return this.session;
303
127
  }
304
128
  // ==================== NODE OPERATIONS ====================
305
- async createNode(connection, options, transaction) {
306
- const startTime = Date.now();
307
- const labels = this.normalizeLabels(options.labels);
308
- const labelStr = labels.map(l => this.escapeIdentifier(l)).join(':');
309
- const { clause: propsClause, params } = this.buildPropertiesClause(options.properties);
310
- const query = `CREATE (n:${labelStr} ${propsClause}) RETURN n`;
311
- try {
312
- const result = await this.executeRaw(connection, { query, params }, transaction);
313
- const node = result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined;
314
- return {
315
- success: true,
316
- executionTime: Date.now() - startTime,
317
- node,
318
- created: true,
319
- statistics: result.statistics,
320
- };
321
- }
322
- catch (error) {
323
- if (options.onConflict === 'ignore') {
324
- return {
325
- success: true,
326
- executionTime: Date.now() - startTime,
327
- created: false,
328
- };
329
- }
330
- throw error;
331
- }
129
+ async createNode(options, transaction) {
130
+ const labels = options.labels.join(':');
131
+ const query = `CREATE (n:${labels} $props) RETURN n`;
132
+ const session = this.getSession(transaction);
133
+ const result = await session.run(query, { props: options.properties });
134
+ const record = result.records[0];
135
+ const node = record.get('n');
136
+ return {
137
+ node: this.mapNeo4jNode(node),
138
+ created: true,
139
+ };
332
140
  }
333
- async findNodes(connection, options, transaction) {
334
- const startTime = Date.now();
335
- const labels = options.labels ? this.normalizeLabels(options.labels) : [];
336
- const labelStr = labels.length > 0 ? ':' + labels.map(l => this.escapeIdentifier(l)).join(':') : '';
337
- let query = `MATCH (n${labelStr})`;
141
+ async findNodes(options, transaction) {
142
+ var _a, _b;
143
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
144
+ const labelClause = labels ? `:${labels}` : '';
145
+ let query = `MATCH (n${labelClause})`;
338
146
  const params = {};
339
- // Build WHERE clause
340
- if (options.where || options.properties) {
341
- const whereParts = [];
342
- if (options.where) {
343
- const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
344
- whereParts.push(clause);
345
- Object.assign(params, whereParams);
346
- }
347
- if (options.properties) {
348
- Object.entries(options.properties).forEach(([key, value], index) => {
349
- const paramName = `prop_${index}`;
350
- whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
351
- params[paramName] = value;
352
- });
353
- }
354
- if (whereParts.length > 0) {
355
- query += ` WHERE ${whereParts.join(' AND ')}`;
356
- }
357
- }
358
- // Return specific properties or entire node
359
- if (options.returnProperties && options.returnProperties.length > 0) {
360
- const props = options.returnProperties.map(p => `n.${this.escapeIdentifier(p)} AS ${p}`).join(', ');
361
- query += ` RETURN ${props}`;
362
- }
363
- else {
364
- query += ` RETURN n`;
147
+ if (options.where) {
148
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
149
+ query += ` WHERE ${clause}`;
150
+ Object.assign(params, whereParams);
365
151
  }
366
- // ORDER BY
367
- if (options.orderBy && options.orderBy.length > 0) {
368
- const orderParts = options.orderBy.map(o => `n.${this.escapeIdentifier(o.property)} ${o.direction}`);
369
- query += ` ORDER BY ${orderParts.join(', ')}`;
152
+ query += ' RETURN n';
153
+ if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
154
+ const orderClauses = options.orderBy.map(o => `n.${o.property} ${o.direction.toUpperCase()}`);
155
+ query += ` ORDER BY ${orderClauses.join(', ')}`;
370
156
  }
371
- // SKIP and LIMIT
372
- if (options.skip !== undefined) {
373
- query += ` SKIP ${options.skip}`;
157
+ if (options.offset) {
158
+ query += ` SKIP ${options.offset}`;
374
159
  }
375
- if (options.limit !== undefined) {
160
+ if (options.limit) {
376
161
  query += ` LIMIT ${options.limit}`;
377
162
  }
378
- const result = await this.executeRaw(connection, { query, params }, transaction);
379
- const nodes = result.data.map(row => {
380
- if (options.returnProperties) {
381
- // Reconstruct node from properties
382
- return {
383
- id: '',
384
- labels: [],
385
- properties: row,
386
- };
387
- }
388
- return this.parseNode(row.n);
389
- });
163
+ const session = this.getSession(transaction);
164
+ const result = await session.run(query, params);
165
+ const nodes = result.records.map((record) => this.mapNeo4jNode(record.get('n')));
390
166
  return {
391
- success: true,
392
- executionTime: Date.now() - startTime,
393
167
  nodes,
394
168
  count: nodes.length,
395
- hasMore: options.limit !== undefined && nodes.length === options.limit,
396
169
  };
397
170
  }
398
- async findNodeById(connection, id, transaction) {
399
- const query = typeof id === 'string'
400
- ? `MATCH (n) WHERE elementId(n) = $id RETURN n`
401
- : `MATCH (n) WHERE id(n) = $id RETURN n`;
402
- const result = await this.executeRaw(connection, { query, params: { id } }, transaction);
403
- if (result.data.length === 0) {
171
+ async findNodeById(id, transaction) {
172
+ const query = `MATCH (n) WHERE elementId(n) = $id OR id(n) = $idNum RETURN n`;
173
+ const session = this.getSession(transaction);
174
+ const result = await session.run(query, {
175
+ id: String(id),
176
+ idNum: typeof id === 'number' ? id : parseInt(id, 10) || -1
177
+ });
178
+ if (result.records.length === 0) {
404
179
  return null;
405
180
  }
406
- return this.parseNode(result.data[0].n);
181
+ return this.mapNeo4jNode(result.records[0].get('n'));
407
182
  }
408
- async updateNode(connection, options, transaction) {
183
+ async updateNode(options, transaction) {
409
184
  var _a;
410
- const startTime = Date.now();
411
- const params = {};
412
- let matchClause = 'MATCH (n)';
413
- // Build match by ID or labels
414
- if (options.id !== undefined) {
415
- if (typeof options.id === 'string') {
416
- matchClause = 'MATCH (n) WHERE elementId(n) = $nodeId';
417
- }
418
- else {
419
- matchClause = 'MATCH (n) WHERE id(n) = $nodeId';
420
- }
421
- params.nodeId = options.id;
422
- }
423
- else if (options.labels) {
424
- const labels = this.normalizeLabels(options.labels);
425
- matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
426
- }
427
- // Add WHERE clause
428
- if (options.where) {
429
- const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
430
- matchClause += options.id === undefined && !options.labels ? ` WHERE ${clause}` : ` AND ${clause}`;
431
- Object.assign(params, whereParams);
432
- }
433
- const setParts = [];
434
- const removeParts = [];
435
- // SET properties
436
- if (options.set) {
437
- Object.entries(options.set).forEach(([key, value], index) => {
438
- const paramName = `set_${index}`;
439
- setParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
440
- params[paramName] = value;
441
- });
442
- }
443
- // Add labels
444
- if (options.addLabels && options.addLabels.length > 0) {
445
- setParts.push(`n:${options.addLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
446
- }
447
- // REMOVE properties
448
- if (options.remove && options.remove.length > 0) {
449
- options.remove.forEach(prop => {
450
- removeParts.push(`n.${this.escapeIdentifier(prop)}`);
451
- });
452
- }
453
- // Remove labels
454
- if (options.removeLabels && options.removeLabels.length > 0) {
455
- removeParts.push(`n:${options.removeLabels.map(l => this.escapeIdentifier(l)).join(':')}`);
456
- }
457
- let query = matchClause;
458
- if (setParts.length > 0) {
459
- query += ` SET ${setParts.join(', ')}`;
185
+ let query;
186
+ const params = { props: options.properties };
187
+ if (options.id) {
188
+ query = `MATCH (n) WHERE elementId(n) = $id OR id(n) = $idNum SET n += $props RETURN n`;
189
+ params.id = String(options.id);
190
+ params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
460
191
  }
461
- if (removeParts.length > 0) {
462
- query += ` REMOVE ${removeParts.join(', ')}`;
192
+ else {
193
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
194
+ const labelClause = labels ? `:${labels}` : '';
195
+ query = `MATCH (n${labelClause})`;
196
+ if (options.where) {
197
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
198
+ query += ` WHERE ${clause}`;
199
+ Object.assign(params, whereParams);
200
+ }
201
+ query += ' SET n += $props RETURN n';
463
202
  }
464
- query += ' RETURN n';
465
- const result = await this.executeRaw(connection, { query, params }, transaction);
203
+ const session = this.getSession(transaction);
204
+ const result = await session.run(query, params);
205
+ const nodes = result.records.map((record) => this.mapNeo4jNode(record.get('n')));
466
206
  return {
467
- success: true,
468
- executionTime: Date.now() - startTime,
469
- node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
470
- updated: result.data.length > 0,
471
- matchedCount: result.data.length,
472
- modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
473
- statistics: result.statistics,
207
+ node: nodes.length === 1 ? nodes[0] : undefined,
208
+ nodes: nodes.length > 1 ? nodes : undefined,
209
+ updatedCount: nodes.length,
474
210
  };
475
211
  }
476
- async deleteNode(connection, options, transaction) {
477
- var _a, _b;
478
- const startTime = Date.now();
212
+ async deleteNode(options, transaction) {
213
+ var _a, _b, _c;
214
+ let query;
479
215
  const params = {};
480
- let matchClause = 'MATCH (n)';
481
- if (options.id !== undefined) {
482
- if (typeof options.id === 'string') {
483
- matchClause = 'MATCH (n) WHERE elementId(n) = $nodeId';
484
- }
485
- else {
486
- matchClause = 'MATCH (n) WHERE id(n) = $nodeId';
487
- }
488
- params.nodeId = options.id;
216
+ const detach = options.detach ? 'DETACH ' : '';
217
+ if (options.id) {
218
+ query = `MATCH (n) WHERE elementId(n) = $id OR id(n) = $idNum ${detach}DELETE n RETURN count(n) as count`;
219
+ params.id = String(options.id);
220
+ params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
489
221
  }
490
- else if (options.labels) {
491
- const labels = this.normalizeLabels(options.labels);
492
- matchClause = `MATCH (n:${labels.map(l => this.escapeIdentifier(l)).join(':')})`;
493
- }
494
- if (options.where) {
495
- const { clause, params: whereParams } = this.buildWhereFromClause(options.where, 'n');
496
- matchClause += options.id === undefined && !options.labels ? ` WHERE ${clause}` : ` AND ${clause}`;
497
- Object.assign(params, whereParams);
222
+ else {
223
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
224
+ const labelClause = labels ? `:${labels}` : '';
225
+ query = `MATCH (n${labelClause})`;
226
+ if (options.where) {
227
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'n');
228
+ query += ` WHERE ${clause}`;
229
+ Object.assign(params, whereParams);
230
+ }
231
+ query += ` ${detach}DELETE n RETURN count(n) as count`;
498
232
  }
499
- const deleteCmd = options.detach ? 'DETACH DELETE' : 'DELETE';
500
- const query = `${matchClause} ${deleteCmd} n`;
501
- const result = await this.executeRaw(connection, { query, params }, transaction);
233
+ const session = this.getSession(transaction);
234
+ const result = await session.run(query, params);
235
+ const count = ((_c = (_b = result.records[0]) === null || _b === void 0 ? void 0 : _b.get('count')) === null || _c === void 0 ? void 0 : _c.toNumber()) || 0;
502
236
  return {
503
- success: true,
504
- executionTime: Date.now() - startTime,
505
- deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesDeleted) || 0,
506
- deletedRelationshipsCount: ((_b = result.statistics) === null || _b === void 0 ? void 0 : _b.relationshipsDeleted) || 0,
507
- statistics: result.statistics,
237
+ deleted: count > 0,
238
+ deletedCount: count,
508
239
  };
509
240
  }
510
- async mergeNode(connection, options, transaction) {
511
- var _a;
512
- const startTime = Date.now();
513
- const labels = this.normalizeLabels(options.labels);
514
- const labelStr = labels.map(l => this.escapeIdentifier(l)).join(':');
241
+ async mergeNode(options, transaction) {
242
+ const labels = options.labels.join(':');
243
+ const matchProps = Object.entries(options.matchProperties)
244
+ .map(([key]) => `${key}: $match_${key}`)
245
+ .join(', ');
246
+ let query = `MERGE (n:${labels} {${matchProps}})`;
515
247
  const params = {};
516
- const matchProps = [];
517
- Object.entries(options.matchProperties).forEach(([key, value], index) => {
518
- const paramName = `match_${index}`;
519
- matchProps.push(`${this.escapeIdentifier(key)}: $${paramName}`);
520
- params[paramName] = value;
248
+ // Add match properties to params
249
+ Object.entries(options.matchProperties).forEach(([key, value]) => {
250
+ params[`match_${key}`] = value;
521
251
  });
522
- let query = `MERGE (n:${labelStr} {${matchProps.join(', ')}})`;
523
- if (options.onCreate && Object.keys(options.onCreate).length > 0) {
524
- const createProps = [];
525
- Object.entries(options.onCreate).forEach(([key, value], index) => {
526
- const paramName = `create_${index}`;
527
- createProps.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
528
- params[paramName] = value;
529
- });
530
- query += ` ON CREATE SET ${createProps.join(', ')}`;
531
- }
532
- if (options.onMatch && Object.keys(options.onMatch).length > 0) {
533
- const matchSetProps = [];
534
- Object.entries(options.onMatch).forEach(([key, value], index) => {
535
- const paramName = `match_set_${index}`;
536
- matchSetProps.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
537
- params[paramName] = value;
538
- });
539
- query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
540
- }
541
- query += ' RETURN n';
542
- const result = await this.executeRaw(connection, { query, params }, transaction);
543
- const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.nodesCreated) || 0) > 0;
252
+ if (options.onCreate) {
253
+ query += ' ON CREATE SET n += $onCreateProps';
254
+ params.onCreateProps = options.onCreate;
255
+ }
256
+ if (options.onMatch) {
257
+ query += ' ON MATCH SET n += $onMatchProps';
258
+ params.onMatchProps = options.onMatch;
259
+ }
260
+ query += ' RETURN n, EXISTS((n)--()) as existed';
261
+ const session = this.getSession(transaction);
262
+ const result = await session.run(query, params);
263
+ const record = result.records[0];
264
+ const node = this.mapNeo4jNode(record.get('n'));
544
265
  return {
545
- success: true,
546
- executionTime: Date.now() - startTime,
547
- node: result.data.length > 0 ? this.parseNode(result.data[0].n) : undefined,
548
- created,
549
- matched: !created,
550
- statistics: result.statistics,
266
+ node,
267
+ created: !record.get('existed'),
551
268
  };
552
269
  }
553
- // ==================== RELATIONSHIP OPERATIONS ====================
554
- async createRelationship(connection, options, transaction) {
555
- var _a;
556
- const startTime = Date.now();
557
- const params = {};
558
- const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
559
- const toMatch = this.buildNodeReference(options.toNode, 'to', params);
560
- let propsClause = '';
561
- if (options.properties && Object.keys(options.properties).length > 0) {
562
- const { clause, params: propParams } = this.buildPropertiesClause(options.properties, 'rel_');
563
- propsClause = ` ${clause}`;
564
- Object.assign(params, propParams);
565
- }
270
+ // ==================== LABEL MANAGEMENT ====================
271
+ async addLabels(options, transaction) {
272
+ const labels = options.labels.map(l => `:\`${l}\``).join('');
566
273
  const query = `
567
- MATCH ${fromMatch}, ${toMatch}
568
- CREATE (from)-[r:${this.escapeIdentifier(options.type)}${propsClause}]->(to)
569
- RETURN r, from, to
274
+ MATCH (n)
275
+ WHERE elementId(n) = $id OR id(n) = $idNum
276
+ SET n${labels}
277
+ RETURN n, labels(n) as newLabels
570
278
  `;
571
- const result = await this.executeRaw(connection, { query, params }, transaction);
572
- return {
573
- success: true,
574
- executionTime: Date.now() - startTime,
575
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
576
- created: (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0,
577
- statistics: result.statistics,
279
+ const params = {
280
+ id: String(options.id),
281
+ idNum: typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1,
578
282
  };
579
- }
580
- async findRelationships(connection, options, transaction) {
581
- const startTime = Date.now();
582
- const params = {};
583
- // Build relationship type pattern
584
- let typePattern = '';
585
- if (options.type) {
586
- const types = Array.isArray(options.type) ? options.type : [options.type];
587
- typePattern = ':' + types.map(t => this.escapeIdentifier(t)).join('|');
588
- }
589
- // Build direction pattern
590
- const directionStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
591
- const directionEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
592
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
593
- let query = `MATCH (from)${directionStart}[r${typePattern}]${directionEnd}(to)`;
594
- const whereParts = [];
595
- // From node filter
596
- if (options.fromNode) {
597
- const fromWhere = this.buildNodeReferenceWhere(options.fromNode, 'from', params, 'from_');
598
- if (fromWhere)
599
- whereParts.push(fromWhere);
600
- }
601
- // To node filter
602
- if (options.toNode) {
603
- const toWhere = this.buildNodeReferenceWhere(options.toNode, 'to', params, 'to_');
604
- if (toWhere)
605
- whereParts.push(toWhere);
606
- }
607
- // Relationship properties filter
608
- if (options.where) {
609
- const { clause, params: whereParams } = this.buildRelationshipWhereClause(options.where, 'r');
610
- whereParts.push(clause);
611
- Object.assign(params, whereParams);
612
- }
613
- if (options.properties) {
614
- Object.entries(options.properties).forEach(([key, value], index) => {
615
- const paramName = `rel_prop_${index}`;
616
- whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
617
- params[paramName] = value;
618
- });
619
- }
620
- if (whereParts.length > 0) {
621
- query += ` WHERE ${whereParts.join(' AND ')}`;
622
- }
623
- // Return clause
624
- if (options.includeNodes) {
625
- query += ' RETURN r, from, to';
283
+ const session = this.getSession(transaction);
284
+ const result = await session.run(query, params);
285
+ if (result.records.length === 0) {
286
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
626
287
  }
627
- else {
628
- query += ' RETURN r';
629
- }
630
- // ORDER BY
631
- if (options.orderBy && options.orderBy.length > 0) {
632
- const orderParts = options.orderBy.map(o => `r.${this.escapeIdentifier(o.property)} ${o.direction}`);
633
- query += ` ORDER BY ${orderParts.join(', ')}`;
634
- }
635
- // SKIP and LIMIT
636
- if (options.skip !== undefined) {
637
- query += ` SKIP ${options.skip}`;
638
- }
639
- if (options.limit !== undefined) {
640
- query += ` LIMIT ${options.limit}`;
641
- }
642
- const result = await this.executeRaw(connection, { query, params }, transaction);
643
- const relationships = result.data.map(row => this.parseRelationship(row.r));
288
+ const record = result.records[0];
289
+ const node = this.mapNeo4jNode(record.get('n'));
644
290
  return {
645
- success: true,
646
- executionTime: Date.now() - startTime,
647
- relationships,
648
- count: relationships.length,
649
- hasMore: options.limit !== undefined && relationships.length === options.limit,
291
+ node,
292
+ addedLabels: options.labels,
650
293
  };
651
294
  }
652
- async findRelationshipById(connection, id, transaction) {
653
- const query = typeof id === 'string'
654
- ? `MATCH ()-[r]->() WHERE elementId(r) = $id RETURN r`
655
- : `MATCH ()-[r]->() WHERE id(r) = $id RETURN r`;
656
- const result = await this.executeRaw(connection, { query, params: { id } }, transaction);
657
- if (result.data.length === 0) {
658
- return null;
659
- }
660
- return this.parseRelationship(result.data[0].r);
661
- }
662
- async updateRelationship(connection, options, transaction) {
663
- var _a;
664
- const startTime = Date.now();
665
- const params = {};
666
- let matchClause = 'MATCH ()-[r]->()';
667
- if (options.id !== undefined) {
668
- if (typeof options.id === 'string') {
669
- matchClause = 'MATCH ()-[r]->() WHERE elementId(r) = $relId';
670
- }
671
- else {
672
- matchClause = 'MATCH ()-[r]->() WHERE id(r) = $relId';
673
- }
674
- params.relId = options.id;
675
- }
676
- else if (options.type) {
677
- matchClause = `MATCH ()-[r:${this.escapeIdentifier(options.type)}]->()`;
678
- }
679
- if (options.where) {
680
- const { clause, params: whereParams } = this.buildRelationshipWhereClause(options.where, 'r');
681
- matchClause += options.id === undefined && !options.type ? ` WHERE ${clause}` : ` AND ${clause}`;
682
- Object.assign(params, whereParams);
683
- }
684
- const setParts = [];
685
- const removeParts = [];
686
- if (options.set) {
687
- Object.entries(options.set).forEach(([key, value], index) => {
688
- const paramName = `set_${index}`;
689
- setParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
690
- params[paramName] = value;
691
- });
692
- }
693
- if (options.remove && options.remove.length > 0) {
694
- options.remove.forEach(prop => {
695
- removeParts.push(`r.${this.escapeIdentifier(prop)}`);
696
- });
697
- }
698
- let query = matchClause;
699
- if (setParts.length > 0) {
700
- query += ` SET ${setParts.join(', ')}`;
701
- }
702
- if (removeParts.length > 0) {
703
- query += ` REMOVE ${removeParts.join(', ')}`;
295
+ async removeLabels(options, transaction) {
296
+ const labels = options.labels.map(l => `:\`${l}\``).join('');
297
+ const query = `
298
+ MATCH (n)
299
+ WHERE elementId(n) = $id OR id(n) = $idNum
300
+ REMOVE n${labels}
301
+ RETURN n, labels(n) as newLabels
302
+ `;
303
+ const params = {
304
+ id: String(options.id),
305
+ idNum: typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1,
306
+ };
307
+ const session = this.getSession(transaction);
308
+ const result = await session.run(query, params);
309
+ if (result.records.length === 0) {
310
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
704
311
  }
705
- query += ' RETURN r';
706
- const result = await this.executeRaw(connection, { query, params }, transaction);
312
+ const record = result.records[0];
313
+ const node = this.mapNeo4jNode(record.get('n'));
707
314
  return {
708
- success: true,
709
- executionTime: Date.now() - startTime,
710
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
711
- updated: result.data.length > 0,
712
- matchedCount: result.data.length,
713
- modifiedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.propertiesSet) || 0,
714
- statistics: result.statistics,
315
+ node,
316
+ removedLabels: options.labels,
715
317
  };
716
318
  }
717
- async deleteRelationship(connection, options, transaction) {
718
- var _a;
719
- const startTime = Date.now();
720
- const params = {};
721
- let matchClause = 'MATCH ()-[r]->()';
722
- if (options.id !== undefined) {
723
- if (typeof options.id === 'string') {
724
- matchClause = 'MATCH ()-[r]->() WHERE elementId(r) = $relId';
725
- }
726
- else {
727
- matchClause = 'MATCH ()-[r]->() WHERE id(r) = $relId';
728
- }
729
- params.relId = options.id;
730
- }
731
- else if (options.type) {
732
- const types = Array.isArray(options.type) ? options.type : [options.type];
733
- matchClause = `MATCH ()-[r:${types.map(t => this.escapeIdentifier(t)).join('|')}]->()`;
734
- }
735
- if (options.where) {
736
- const { clause, params: whereParams } = this.buildRelationshipWhereClause(options.where, 'r');
737
- matchClause += options.id === undefined && !options.type ? ` WHERE ${clause}` : ` AND ${clause}`;
738
- Object.assign(params, whereParams);
739
- }
740
- const query = `${matchClause} DELETE r`;
741
- const result = await this.executeRaw(connection, { query, params }, transaction);
319
+ async setLabels(options, transaction) {
320
+ // First get current labels
321
+ const getQuery = `
322
+ MATCH (n)
323
+ WHERE elementId(n) = $id OR id(n) = $idNum
324
+ RETURN labels(n) as currentLabels
325
+ `;
326
+ const params = {
327
+ id: String(options.id),
328
+ idNum: typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1,
329
+ };
330
+ const session = this.getSession(transaction);
331
+ const getResult = await session.run(getQuery, params);
332
+ if (getResult.records.length === 0) {
333
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
334
+ }
335
+ const previousLabels = getResult.records[0].get('currentLabels');
336
+ // Remove all existing labels and add new ones
337
+ const removeLabels = previousLabels.map(l => `:\`${l}\``).join('');
338
+ const addLabels = options.labels.map(l => `:\`${l}\``).join('');
339
+ const setQuery = `
340
+ MATCH (n)
341
+ WHERE elementId(n) = $id OR id(n) = $idNum
342
+ REMOVE n${removeLabels}
343
+ SET n${addLabels}
344
+ RETURN n
345
+ `;
346
+ const result = await session.run(setQuery, params);
347
+ const node = this.mapNeo4jNode(result.records[0].get('n'));
742
348
  return {
743
- success: true,
744
- executionTime: Date.now() - startTime,
745
- deletedCount: ((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsDeleted) || 0,
746
- statistics: result.statistics,
349
+ node,
350
+ previousLabels,
351
+ newLabels: options.labels,
747
352
  };
748
353
  }
749
- async mergeRelationship(connection, options, transaction) {
750
- var _a;
751
- const startTime = Date.now();
752
- const params = {};
753
- const fromMatch = this.buildNodeReference(options.fromNode, 'from', params);
754
- const toMatch = this.buildNodeReference(options.toNode, 'to', params);
755
- let matchPropsClause = '';
756
- if (options.matchProperties && Object.keys(options.matchProperties).length > 0) {
757
- const { clause, params: matchParams } = this.buildPropertiesClause(options.matchProperties, 'match_');
758
- matchPropsClause = ` ${clause}`;
759
- Object.assign(params, matchParams);
760
- }
761
- let query = `
762
- MATCH ${fromMatch}, ${toMatch}
763
- MERGE (from)-[r:${this.escapeIdentifier(options.type)}${matchPropsClause}]->(to)
354
+ // ==================== RELATIONSHIP OPERATIONS ====================
355
+ async createRelationship(options, transaction) {
356
+ const query = `
357
+ MATCH (a), (b)
358
+ WHERE (elementId(a) = $startId OR id(a) = $startIdNum)
359
+ AND (elementId(b) = $endId OR id(b) = $endIdNum)
360
+ CREATE (a)-[r:${options.type} $props]->(b)
361
+ RETURN r, elementId(a) as startId, elementId(b) as endId
764
362
  `;
765
- if (options.onCreate && Object.keys(options.onCreate).length > 0) {
766
- const createProps = [];
767
- Object.entries(options.onCreate).forEach(([key, value], index) => {
768
- const paramName = `create_${index}`;
769
- createProps.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
770
- params[paramName] = value;
771
- });
772
- query += ` ON CREATE SET ${createProps.join(', ')}`;
773
- }
774
- if (options.onMatch && Object.keys(options.onMatch).length > 0) {
775
- const matchSetProps = [];
776
- Object.entries(options.onMatch).forEach(([key, value], index) => {
777
- const paramName = `match_set_${index}`;
778
- matchSetProps.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
779
- params[paramName] = value;
780
- });
781
- query += ` ON MATCH SET ${matchSetProps.join(', ')}`;
782
- }
783
- query += ' RETURN r';
784
- const result = await this.executeRaw(connection, { query, params }, transaction);
785
- const created = (((_a = result.statistics) === null || _a === void 0 ? void 0 : _a.relationshipsCreated) || 0) > 0;
363
+ const params = {
364
+ startId: String(options.startNodeId),
365
+ startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
366
+ endId: String(options.endNodeId),
367
+ endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
368
+ props: options.properties || {},
369
+ };
370
+ const session = this.getSession(transaction);
371
+ const result = await session.run(query, params);
372
+ const record = result.records[0];
373
+ const rel = record.get('r');
786
374
  return {
787
- success: true,
788
- executionTime: Date.now() - startTime,
789
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].r) : undefined,
790
- created,
791
- matched: !created,
792
- statistics: result.statistics,
375
+ relationship: this.mapNeo4jRelationship(rel, record.get('startId'), record.get('endId')),
376
+ created: true,
793
377
  };
794
378
  }
795
- // ==================== PATH & TRAVERSAL OPERATIONS ====================
796
- async traverse(connection, options, transaction) {
797
- const startTime = Date.now();
379
+ async findRelationships(options, transaction) {
380
+ const types = options.type
381
+ ? (Array.isArray(options.type) ? options.type.join('|') : options.type)
382
+ : '';
383
+ const typeClause = types ? `:${types}` : '';
384
+ let query = `MATCH (a)-[r${typeClause}]->(b)`;
798
385
  const params = {};
799
- const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
800
- // Build relationship pattern
801
- const minDepth = options.minDepth || 1;
802
- const maxDepth = options.maxDepth || 10;
803
- const relPattern = this.buildTraversalRelPattern(options);
804
- const depthPattern = minDepth === maxDepth ? `*${minDepth}` : `*${minDepth}..${maxDepth}`;
805
- // Build direction
806
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
807
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
808
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
809
- let query = `
810
- MATCH ${startNodeMatch}
811
- MATCH path = (start)${dirStart}[${relPattern}${depthPattern}]${dirEnd}(end)
812
- `;
813
- // Add filters
814
- if (options.filters) {
815
- const filterParts = [];
816
- if (options.filters.nodeLabels && options.filters.nodeLabels.length > 0) {
817
- const labelConditions = options.filters.nodeLabels
818
- .map(l => `'${l}' IN labels(end)`)
819
- .join(' OR ');
820
- filterParts.push(`(${labelConditions})`);
821
- }
822
- if (options.filters.stopAtLabels && options.filters.stopAtLabels.length > 0) {
823
- const stopConditions = options.filters.stopAtLabels
824
- .map(l => `NOT '${l}' IN labels(end)`)
825
- .join(' AND ');
826
- filterParts.push(`(${stopConditions})`);
827
- }
828
- if (filterParts.length > 0) {
829
- query += ` WHERE ${filterParts.join(' AND ')}`;
830
- }
386
+ const conditions = [];
387
+ if (options.startNodeId) {
388
+ conditions.push('(elementId(a) = $startId OR id(a) = $startIdNum)');
389
+ params.startId = String(options.startNodeId);
390
+ params.startIdNum = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1;
831
391
  }
832
- // Return clause
833
- const returnParts = [];
834
- if (options.returnPaths) {
835
- returnParts.push('path');
392
+ if (options.endNodeId) {
393
+ conditions.push('(elementId(b) = $endId OR id(b) = $endIdNum)');
394
+ params.endId = String(options.endNodeId);
395
+ params.endIdNum = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1;
836
396
  }
837
- if (options.returnNodes) {
838
- returnParts.push('COLLECT(DISTINCT end) AS nodes');
397
+ if (options.where) {
398
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
399
+ conditions.push(clause);
400
+ Object.assign(params, whereParams);
401
+ }
402
+ if (conditions.length > 0) {
403
+ query += ` WHERE ${conditions.join(' AND ')}`;
839
404
  }
840
- if (returnParts.length === 0) {
841
- returnParts.push('path');
405
+ query += ' RETURN r, elementId(a) as startId, elementId(b) as endId';
406
+ if (options.offset) {
407
+ query += ` SKIP ${options.offset}`;
842
408
  }
843
- query += ` RETURN ${returnParts.join(', ')}`;
844
409
  if (options.limit) {
845
410
  query += ` LIMIT ${options.limit}`;
846
411
  }
847
- const result = await this.executeRaw(connection, { query, params }, transaction);
848
- const paths = [];
849
- const nodesSet = new Map();
850
- const relsSet = new Map();
851
- result.data.forEach(row => {
852
- if (row.path) {
853
- const parsedPath = this.parsePath(row.path);
854
- paths.push(parsedPath);
855
- parsedPath.nodes.forEach(n => nodesSet.set(String(n.id), n));
856
- parsedPath.relationships.forEach(r => relsSet.set(String(r.id), r));
857
- }
858
- if (row.nodes) {
859
- row.nodes.forEach((n) => {
860
- const parsed = this.parseNode(n);
861
- nodesSet.set(String(parsed.id), parsed);
862
- });
863
- }
864
- });
412
+ const session = this.getSession(transaction);
413
+ const result = await session.run(query, params);
414
+ const relationships = result.records.map((record) => this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId')));
865
415
  return {
866
- success: true,
867
- executionTime: Date.now() - startTime,
868
- paths: options.returnPaths ? paths : undefined,
869
- nodes: options.returnNodes ? Array.from(nodesSet.values()) : undefined,
870
- relationships: Array.from(relsSet.values()),
871
- count: paths.length,
416
+ relationships,
417
+ count: relationships.length,
872
418
  };
873
419
  }
874
- async shortestPath(connection, options, transaction) {
875
- const startTime = Date.now();
876
- const params = {};
877
- const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
878
- const endNodeMatch = this.buildNodeSelectorMatch(options.endNode, 'end', params, 'end_');
879
- const relPattern = this.buildTraversalRelPattern(options);
880
- const maxDepth = options.maxDepth || '';
881
- const depthPattern = maxDepth ? `*..${maxDepth}` : '*';
882
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
883
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
884
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
885
- let query;
886
- if (options.weightProperty && options.algorithm === path_types_1.PathAlgorithm.DIJKSTRA) {
887
- // Use APOC for weighted shortest path
888
- query = `
889
- MATCH ${startNodeMatch}, ${endNodeMatch}
890
- CALL apoc.algo.dijkstra(start, end, '${relPattern}', '${options.weightProperty}')
891
- YIELD path, weight
892
- RETURN path, weight
893
- `;
420
+ async findRelationshipById(id, transaction) {
421
+ const query = `
422
+ MATCH (a)-[r]->(b)
423
+ WHERE elementId(r) = $id OR id(r) = $idNum
424
+ RETURN r, elementId(a) as startId, elementId(b) as endId
425
+ `;
426
+ const session = this.getSession(transaction);
427
+ const result = await session.run(query, {
428
+ id: String(id),
429
+ idNum: typeof id === 'number' ? id : parseInt(id, 10) || -1,
430
+ });
431
+ if (result.records.length === 0) {
432
+ return null;
894
433
  }
895
- else if (options.returnAllShortest) {
434
+ const record = result.records[0];
435
+ return this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId'));
436
+ }
437
+ async updateRelationship(options, transaction) {
438
+ let query;
439
+ const params = { props: options.properties };
440
+ if (options.id) {
896
441
  query = `
897
- MATCH ${startNodeMatch}, ${endNodeMatch}
898
- MATCH path = allShortestPaths((start)${dirStart}[${relPattern}${depthPattern}]${dirEnd}(end))
899
- RETURN path
442
+ MATCH (a)-[r]->(b)
443
+ WHERE elementId(r) = $id OR id(r) = $idNum
444
+ SET r += $props
445
+ RETURN r, elementId(a) as startId, elementId(b) as endId
900
446
  `;
447
+ params.id = String(options.id);
448
+ params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
901
449
  }
902
450
  else {
903
- query = `
904
- MATCH ${startNodeMatch}, ${endNodeMatch}
905
- MATCH path = shortestPath((start)${dirStart}[${relPattern}${depthPattern}]${dirEnd}(end))
906
- RETURN path
907
- `;
451
+ const typeClause = options.type ? `:${options.type}` : '';
452
+ query = `MATCH (a)-[r${typeClause}]->(b)`;
453
+ if (options.where) {
454
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
455
+ query += ` WHERE ${clause}`;
456
+ Object.assign(params, whereParams);
457
+ }
458
+ query += ' SET r += $props RETURN r, elementId(a) as startId, elementId(b) as endId';
908
459
  }
909
- const result = await this.executeRaw(connection, { query, params }, transaction);
910
- if (result.data.length === 0) {
911
- return {
912
- success: true,
913
- executionTime: Date.now() - startTime,
914
- found: false,
915
- };
460
+ const session = this.getSession(transaction);
461
+ const result = await session.run(query, params);
462
+ const relationships = result.records.map((record) => this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId')));
463
+ return {
464
+ relationship: relationships.length === 1 ? relationships[0] : undefined,
465
+ relationships: relationships.length > 1 ? relationships : undefined,
466
+ updatedCount: relationships.length,
467
+ };
468
+ }
469
+ async deleteRelationship(options, transaction) {
470
+ var _a, _b;
471
+ let query;
472
+ const params = {};
473
+ if (options.id) {
474
+ query = `MATCH ()-[r]->() WHERE elementId(r) = $id OR id(r) = $idNum DELETE r RETURN count(r) as count`;
475
+ params.id = String(options.id);
476
+ params.idNum = typeof options.id === 'number' ? options.id : parseInt(options.id, 10) || -1;
916
477
  }
917
- const paths = result.data.map(row => {
918
- const parsedPath = this.parsePath(row.path);
919
- if (row.weight !== undefined) {
920
- return Object.assign(Object.assign({}, parsedPath), { totalWeight: row.weight, weights: [] });
478
+ else {
479
+ const typeClause = options.type ? `:${options.type}` : '';
480
+ query = `MATCH (a)-[r${typeClause}]->(b)`;
481
+ const conditions = [];
482
+ if (options.startNodeId) {
483
+ conditions.push('(elementId(a) = $startId OR id(a) = $startIdNum)');
484
+ params.startId = String(options.startNodeId);
485
+ params.startIdNum = typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1;
486
+ }
487
+ if (options.endNodeId) {
488
+ conditions.push('(elementId(b) = $endId OR id(b) = $endIdNum)');
489
+ params.endId = String(options.endNodeId);
490
+ params.endIdNum = typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1;
921
491
  }
922
- return parsedPath;
923
- });
492
+ if (options.where) {
493
+ const { clause, params: whereParams } = this.buildWhereClause(options.where, 'r');
494
+ conditions.push(clause);
495
+ Object.assign(params, whereParams);
496
+ }
497
+ if (conditions.length > 0) {
498
+ query += ` WHERE ${conditions.join(' AND ')}`;
499
+ }
500
+ query += ' DELETE r RETURN count(r) as count';
501
+ }
502
+ const session = this.getSession(transaction);
503
+ const result = await session.run(query, params);
504
+ const count = ((_b = (_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0;
924
505
  return {
925
- success: true,
926
- executionTime: Date.now() - startTime,
927
- path: options.returnAllShortest ? undefined : paths[0],
928
- paths: options.returnAllShortest ? paths : undefined,
929
- found: true,
930
- length: paths[0].length,
931
- totalWeight: paths[0].totalWeight,
506
+ deleted: count > 0,
507
+ deletedCount: count,
932
508
  };
933
509
  }
934
- async allPaths(connection, options, transaction) {
935
- const startTime = Date.now();
936
- const params = {};
937
- const startNodeMatch = this.buildNodeSelectorMatch(options.startNode, 'start', params);
938
- const endNodeMatch = this.buildNodeSelectorMatch(options.endNode, 'end', params, 'end_');
939
- const relPattern = this.buildTraversalRelPattern(options);
940
- const minDepth = options.minDepth || 1;
941
- const maxDepth = options.maxDepth || 10;
942
- const depthPattern = `*${minDepth}..${maxDepth}`;
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 ? '->' : '-';
510
+ async mergeRelationship(options, transaction) {
946
511
  let query = `
947
- MATCH ${startNodeMatch}, ${endNodeMatch}
948
- MATCH path = (start)${dirStart}[${relPattern}${depthPattern}]${dirEnd}(end)
512
+ MATCH (a), (b)
513
+ WHERE (elementId(a) = $startId OR id(a) = $startIdNum)
514
+ AND (elementId(b) = $endId OR id(b) = $endIdNum)
515
+ MERGE (a)-[r:${options.type}]->(b)
516
+ `;
517
+ const params = {
518
+ startId: String(options.startNodeId),
519
+ startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
520
+ endId: String(options.endNodeId),
521
+ endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
522
+ };
523
+ if (options.onCreate) {
524
+ query += ' ON CREATE SET r += $onCreateProps';
525
+ params.onCreateProps = options.onCreate;
526
+ }
527
+ if (options.onMatch) {
528
+ query += ' ON MATCH SET r += $onMatchProps';
529
+ params.onMatchProps = options.onMatch;
530
+ }
531
+ query += ' RETURN r, elementId(a) as startId, elementId(b) as endId';
532
+ const session = this.getSession(transaction);
533
+ const result = await session.run(query, params);
534
+ const record = result.records[0];
535
+ const relationship = this.mapNeo4jRelationship(record.get('r'), record.get('startId'), record.get('endId'));
536
+ // Check if relationship was created (no properties existed before)
537
+ const created = Object.keys(record.get('r').properties || {}).length === 0;
538
+ return {
539
+ relationship,
540
+ created,
541
+ };
542
+ }
543
+ // ==================== TRAVERSAL OPERATIONS ====================
544
+ async traverse(options, transaction) {
545
+ var _a;
546
+ const direction = this.getDirectionArrow(options.direction);
547
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
548
+ const relClause = relTypes ? `:${relTypes}` : '';
549
+ const depthClause = `*1..${options.maxDepth || 3}`;
550
+ const query = `
551
+ MATCH path = (start)${direction.left}[${relClause}${depthClause}]${direction.right}(end)
552
+ WHERE elementId(start) = $startId OR id(start) = $startIdNum
949
553
  RETURN path
554
+ ${options.limit ? `LIMIT ${options.limit}` : ''}
950
555
  `;
951
- if (options.limit) {
952
- query += ` LIMIT ${options.limit}`;
953
- }
954
- const result = await this.executeRaw(connection, { query, params }, transaction);
955
- const paths = result.data.map(row => this.parsePath(row.path));
556
+ const params = {
557
+ startId: String(options.startNodeId),
558
+ startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
559
+ };
560
+ const session = this.getSession(transaction);
561
+ const result = await session.run(query, params);
562
+ const paths = result.records.map((record) => this.mapNeo4jPath(record.get('path')));
956
563
  return {
957
- success: true,
958
- executionTime: Date.now() - startTime,
959
564
  paths,
960
565
  count: paths.length,
961
566
  };
962
567
  }
963
- async matchPattern(connection, options, transaction) {
964
- const startTime = Date.now();
965
- const params = {};
966
- const { pattern } = options;
967
- // Build node patterns
968
- const nodePatterns = [];
969
- pattern.nodes.forEach(node => {
970
- const labels = node.labels
971
- ? ':' + (Array.isArray(node.labels) ? node.labels : [node.labels])
972
- .map(l => this.escapeIdentifier(l)).join(':')
973
- : '';
974
- let props = '';
975
- if (node.properties && Object.keys(node.properties).length > 0) {
976
- const { clause, params: nodeParams } = this.buildPropertiesClause(node.properties, `${node.variable}_`);
977
- props = ` ${clause}`;
978
- Object.assign(params, nodeParams);
979
- }
980
- nodePatterns.push(`(${node.variable}${labels}${props})`);
981
- });
982
- // Build relationship patterns
983
- const matchClauses = [];
984
- if (pattern.relationships.length === 0) {
985
- // Just match nodes
986
- matchClauses.push(`MATCH ${nodePatterns.join(', ')}`);
987
- }
988
- else {
989
- pattern.relationships.forEach(rel => {
990
- const startVar = rel.startNode;
991
- const endVar = rel.endNode;
992
- const relVar = rel.variable || '';
993
- const types = rel.type
994
- ? ':' + (Array.isArray(rel.type) ? rel.type : [rel.type])
995
- .map(t => this.escapeIdentifier(t)).join('|')
996
- : '';
997
- const dirStart = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
998
- const dirEnd = rel.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
999
- rel.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
1000
- let hops = '';
1001
- if (rel.minHops !== undefined || rel.maxHops !== undefined) {
1002
- const min = rel.minHops || '';
1003
- const max = rel.maxHops || '';
1004
- hops = `*${min}..${max}`;
1005
- }
1006
- matchClauses.push(`MATCH (${startVar})${dirStart}[${relVar}${types}${hops}]${dirEnd}(${endVar})`);
1007
- });
1008
- }
1009
- let query = matchClauses.join(' ');
1010
- // WHERE clause
1011
- if (pattern.where) {
1012
- const conditions = pattern.where.conditions
1013
- .map(c => c.expression)
1014
- .join(pattern.where.operator === 'OR' ? ' OR ' : ' AND ');
1015
- query += ` WHERE ${conditions}`;
1016
- }
1017
- // RETURN clause
1018
- const returnVars = options.return || pattern.nodes.map(n => n.variable);
1019
- query += ` RETURN ${returnVars.join(', ')}`;
1020
- // ORDER BY
1021
- if (options.orderBy && options.orderBy.length > 0) {
1022
- const orderParts = options.orderBy.map(o => `${o.expression} ${o.direction}`);
1023
- query += ` ORDER BY ${orderParts.join(', ')}`;
1024
- }
1025
- // SKIP and LIMIT
1026
- if (options.skip !== undefined) {
1027
- query += ` SKIP ${options.skip}`;
1028
- }
1029
- if (options.limit !== undefined) {
1030
- query += ` LIMIT ${options.limit}`;
568
+ async shortestPath(options, transaction) {
569
+ var _a;
570
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
571
+ const relClause = relTypes ? `:${relTypes}` : '';
572
+ const maxDepth = options.maxDepth || 15;
573
+ const query = `
574
+ MATCH (start), (end)
575
+ WHERE (elementId(start) = $startId OR id(start) = $startIdNum)
576
+ AND (elementId(end) = $endId OR id(end) = $endIdNum)
577
+ MATCH path = shortestPath((start)-[${relClause}*..${maxDepth}]-(end))
578
+ RETURN path
579
+ `;
580
+ const params = {
581
+ startId: String(options.startNodeId),
582
+ startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
583
+ endId: String(options.endNodeId),
584
+ endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
585
+ };
586
+ const session = this.getSession(transaction);
587
+ const result = await session.run(query, params);
588
+ if (result.records.length === 0) {
589
+ return { path: null };
1031
590
  }
1032
- const result = await this.executeRaw(connection, { query, params }, transaction);
591
+ const path = this.mapNeo4jPath(result.records[0].get('path'));
1033
592
  return {
1034
- success: true,
1035
- executionTime: Date.now() - startTime,
1036
- matches: result.data,
1037
- count: result.data.length,
1038
- hasMore: options.limit !== undefined && result.data.length === options.limit,
593
+ path,
594
+ totalWeight: options.weightProperty
595
+ ? path.relationships.reduce((sum, r) => sum + (r.properties[options.weightProperty] || 0), 0)
596
+ : undefined,
1039
597
  };
1040
598
  }
1041
- async extractSubgraph(connection, options, transaction) {
1042
- const startTime = Date.now();
1043
- const params = {};
1044
- const startNodes = Array.isArray(options.startNodes) ? options.startNodes : [options.startNodes];
1045
- const startMatches = startNodes.map((node, idx) => this.buildNodeSelectorMatch(node, `start${idx}`, params, `start${idx}_`));
1046
- const maxDepth = options.maxDepth || 3;
1047
- const relPattern = this.buildTraversalRelPattern(options);
1048
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
1049
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
1050
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
1051
- const startVars = startNodes.map((_, idx) => `start${idx}`).join(', ');
1052
- const matchPaths = startNodes.map((_, idx) => `(start${idx})${dirStart}[${relPattern}*0..${maxDepth}]${dirEnd}(n)`).join(' OR ');
1053
- let query = `
1054
- MATCH ${startMatches.join(', ')}
1055
- WITH ${startVars}
1056
- MATCH path = ${matchPaths.length > 0 ? matchPaths.replace(' OR ', '), (') : `(start0)${dirStart}[${relPattern}*0..${maxDepth}]${dirEnd}(n)`}
1057
- WITH COLLECT(DISTINCT n) AS nodes, COLLECT(DISTINCT relationships(path)) AS rels
1058
- UNWIND rels AS relList
1059
- UNWIND relList AS r
1060
- RETURN nodes, COLLECT(DISTINCT r) AS relationships
599
+ async allPaths(options, transaction) {
600
+ var _a;
601
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
602
+ const relClause = relTypes ? `:${relTypes}` : '';
603
+ const minDepth = options.minDepth || 1;
604
+ const maxDepth = options.maxDepth || 5;
605
+ const query = `
606
+ MATCH (start), (end)
607
+ WHERE (elementId(start) = $startId OR id(start) = $startIdNum)
608
+ AND (elementId(end) = $endId OR id(end) = $endIdNum)
609
+ MATCH path = (start)-[${relClause}*${minDepth}..${maxDepth}]-(end)
610
+ RETURN path
611
+ ${options.limit ? `LIMIT ${options.limit}` : ''}
1061
612
  `;
1062
- const result = await this.executeRaw(connection, { query, params }, transaction);
1063
- const nodes = [];
1064
- const relationships = [];
1065
- if (result.data.length > 0) {
1066
- const row = result.data[0];
1067
- if (row.nodes) {
1068
- row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
1069
- }
1070
- if (row.relationships) {
1071
- row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
1072
- }
1073
- }
613
+ const params = {
614
+ startId: String(options.startNodeId),
615
+ startIdNum: typeof options.startNodeId === 'number' ? options.startNodeId : parseInt(options.startNodeId, 10) || -1,
616
+ endId: String(options.endNodeId),
617
+ endIdNum: typeof options.endNodeId === 'number' ? options.endNodeId : parseInt(options.endNodeId, 10) || -1,
618
+ };
619
+ const session = this.getSession(transaction);
620
+ const result = await session.run(query, params);
621
+ const paths = result.records.map((record) => this.mapNeo4jPath(record.get('path')));
1074
622
  return {
1075
- success: true,
1076
- executionTime: Date.now() - startTime,
1077
- subgraph: {
1078
- nodes,
1079
- relationships,
1080
- nodeCount: nodes.length,
1081
- relationshipCount: relationships.length,
1082
- },
623
+ paths,
624
+ count: paths.length,
1083
625
  };
1084
626
  }
1085
- async getNeighborhood(connection, options, transaction) {
1086
- const startTime = Date.now();
1087
- const params = {};
1088
- const centerMatch = this.buildNodeSelectorMatch(options.node, 'center', params);
627
+ async getNeighborhood(options, transaction) {
628
+ var _a;
629
+ const direction = this.getDirectionArrow(options.direction);
630
+ const relTypes = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.join('|')) || '';
631
+ const relClause = relTypes ? `:${relTypes}` : '';
1089
632
  const depth = options.depth || 1;
1090
- let relTypes = '';
1091
- if (options.relationshipTypes && options.relationshipTypes.length > 0) {
1092
- relTypes = ':' + options.relationshipTypes.map(t => this.escapeIdentifier(t)).join('|');
1093
- }
1094
- const dirStart = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '<-' : '-';
1095
- const dirEnd = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? '-' :
1096
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? '->' : '-';
1097
633
  const query = `
1098
- MATCH ${centerMatch}
1099
- CALL apoc.path.subgraphAll(center, {
1100
- relationshipFilter: '${relTypes.replace(':', '')}',
1101
- minLevel: ${options.includeCenter ? 0 : 1},
1102
- maxLevel: ${depth}
1103
- })
1104
- YIELD nodes, relationships
1105
- RETURN nodes, relationships
634
+ MATCH (start)
635
+ WHERE elementId(start) = $nodeId OR id(start) = $nodeIdNum
636
+ MATCH path = (start)${direction.left}[r${relClause}*1..${depth}]${direction.right}(neighbor)
637
+ RETURN DISTINCT neighbor, r
1106
638
  `;
1107
- // Fallback query without APOC
1108
- const fallbackQuery = `
1109
- MATCH ${centerMatch}
1110
- MATCH path = (center)${dirStart}[${relTypes}*0..${depth}]${dirEnd}(n)
1111
- WITH COLLECT(DISTINCT n) AS nodes, COLLECT(DISTINCT relationships(path)) AS rels
1112
- UNWIND rels AS relList
1113
- UNWIND relList AS r
1114
- RETURN nodes, COLLECT(DISTINCT r) AS relationships
1115
- `;
1116
- let result;
1117
- try {
1118
- result = await this.executeRaw(connection, { query, params }, transaction);
1119
- }
1120
- catch (_a) {
1121
- // Fall back to non-APOC query
1122
- result = await this.executeRaw(connection, { query: fallbackQuery, params }, transaction);
1123
- }
1124
- const nodes = [];
1125
- const relationships = [];
1126
- const levels = new Map();
1127
- if (result.data.length > 0) {
1128
- const row = result.data[0];
1129
- if (row.nodes) {
1130
- row.nodes.forEach((n) => {
1131
- const parsed = this.parseNode(n);
1132
- nodes.push(parsed);
1133
- });
639
+ const params = {
640
+ nodeId: String(options.nodeId),
641
+ nodeIdNum: typeof options.nodeId === 'number' ? options.nodeId : parseInt(options.nodeId, 10) || -1,
642
+ };
643
+ const session = this.getSession(transaction);
644
+ const result = await session.run(query, params);
645
+ const nodesMap = new Map();
646
+ const relationshipsSet = [];
647
+ result.records.forEach((record) => {
648
+ const neighbor = record.get('neighbor');
649
+ const nodeId = neighbor.elementId || neighbor.identity.toString();
650
+ if (!nodesMap.has(nodeId)) {
651
+ nodesMap.set(nodeId, this.mapNeo4jNode(neighbor));
1134
652
  }
1135
- if (row.relationships) {
1136
- row.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
653
+ const rels = record.get('r');
654
+ if (Array.isArray(rels)) {
655
+ rels.forEach((rel) => {
656
+ relationshipsSet.push(this.mapNeo4jRelationship(rel, rel.startNodeElementId || rel.start.toString(), rel.endNodeElementId || rel.end.toString()));
657
+ });
1137
658
  }
1138
- }
659
+ });
1139
660
  return {
1140
- success: true,
1141
- executionTime: Date.now() - startTime,
1142
- nodes,
1143
- relationships,
1144
- levels,
661
+ nodes: Array.from(nodesMap.values()),
662
+ relationships: relationshipsSet,
1145
663
  };
1146
664
  }
1147
- async findConnectedComponents(connection, options, transaction) {
1148
- const startTime = Date.now();
1149
- // Build label filter
1150
- let labelFilter = '';
1151
- if (options.labels && options.labels.length > 0) {
1152
- labelFilter = ':' + options.labels.map(l => this.escapeIdentifier(l)).join(':');
1153
- }
1154
- // Build relationship type filter
1155
- let relFilter = '';
1156
- if (options.relationshipTypes && options.relationshipTypes.length > 0) {
1157
- relFilter = ':' + options.relationshipTypes.map(t => this.escapeIdentifier(t)).join('|');
1158
- }
1159
- // Use GDS (Graph Data Science) library for connected components
665
+ async findConnectedComponents(options, transaction) {
666
+ var _a, _b;
667
+ // Note: This requires APOC or GDS library for efficient implementation
668
+ // Basic implementation using Cypher
669
+ const labels = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a.join(':')) || '';
670
+ const labelClause = labels ? `:${labels}` : '';
671
+ const relTypes = ((_b = options.relationshipTypes) === null || _b === void 0 ? void 0 : _b.join('|')) || '';
672
+ const relClause = relTypes ? `:${relTypes}` : '';
1160
673
  const query = `
1161
- CALL gds.wcc.stream({
1162
- nodeQuery: 'MATCH (n${labelFilter}) RETURN id(n) AS id',
1163
- relationshipQuery: 'MATCH (n${labelFilter})-[r${relFilter}]-(m${labelFilter}) RETURN id(n) AS source, id(m) AS target'
1164
- })
1165
- YIELD nodeId, componentId
1166
- WITH componentId, COLLECT(nodeId) AS nodeIds
1167
- ${options.minSize ? `WHERE size(nodeIds) >= ${options.minSize}` : ''}
1168
- RETURN componentId, nodeIds
1169
- ORDER BY size(nodeIds) DESC
1170
- `;
1171
- // Fallback query without GDS
1172
- const fallbackQuery = `
1173
- MATCH (n${labelFilter})
1174
- WITH COLLECT(n) AS allNodes
1175
- UNWIND allNodes AS node
1176
- MATCH path = (node)-[${relFilter}*]-(connected)
1177
- WITH node, COLLECT(DISTINCT connected) + node AS component
1178
- WITH COLLECT(DISTINCT component) AS allComponents
1179
- UNWIND range(0, size(allComponents)-1) AS idx
1180
- WITH idx AS componentId, allComponents[idx] AS component
1181
- ${options.minSize ? `WHERE size(component) >= ${options.minSize}` : ''}
1182
- RETURN componentId, component AS nodes
674
+ MATCH (n${labelClause})
675
+ WITH collect(n) as nodes
676
+ UNWIND nodes as node
677
+ MATCH path = (node)-[${relClause}*]-(connected)
678
+ WITH node, collect(DISTINCT connected) as component
679
+ RETURN component
1183
680
  `;
1184
- let result;
1185
- try {
1186
- result = await this.executeRaw(connection, { query }, transaction);
1187
- }
1188
- catch (_a) {
1189
- result = await this.executeRaw(connection, { query: fallbackQuery }, transaction);
1190
- }
1191
- const components = result.data.map((row, idx) => ({
1192
- id: row.componentId || idx,
1193
- nodes: (row.nodes || []).map((n) => this.parseNode(n)),
1194
- size: row.nodeIds ? row.nodeIds.length : (row.nodes || []).length,
681
+ const session = this.getSession(transaction);
682
+ const result = await session.run(query, {});
683
+ const components = result.records.map((record) => ({
684
+ nodes: record.get('component').map((n) => this.mapNeo4jNode(n)),
685
+ size: record.get('component').length,
1195
686
  }));
1196
687
  return {
1197
- success: true,
1198
- executionTime: Date.now() - startTime,
1199
688
  components,
1200
689
  count: components.length,
1201
690
  };
1202
691
  }
1203
692
  // ==================== AGGREGATION OPERATIONS ====================
1204
- async countNodes(connection, labels, where, transaction) {
1205
- var _a;
1206
- const startTime = Date.now();
693
+ async countNodes(labels, where, transaction) {
694
+ var _a, _b;
695
+ const labelClause = (labels === null || labels === void 0 ? void 0 : labels.length) ? `:${labels.join(':')}` : '';
696
+ let query = `MATCH (n${labelClause})`;
1207
697
  const params = {};
1208
- let labelStr = '';
1209
- if (labels) {
1210
- const labelArr = Array.isArray(labels) ? labels : [labels];
1211
- labelStr = ':' + labelArr.map(l => this.escapeIdentifier(l)).join(':');
1212
- }
1213
- let query = `MATCH (n${labelStr})`;
1214
- if (where && Object.keys(where).length > 0) {
1215
- const whereParts = [];
1216
- Object.entries(where).forEach(([key, value], index) => {
1217
- const paramName = `where_${index}`;
1218
- whereParts.push(`n.${this.escapeIdentifier(key)} = $${paramName}`);
1219
- params[paramName] = value;
1220
- });
1221
- query += ` WHERE ${whereParts.join(' AND ')}`;
698
+ if (where) {
699
+ const { clause, params: whereParams } = this.buildWhereClause(where, 'n');
700
+ query += ` WHERE ${clause}`;
701
+ Object.assign(params, whereParams);
1222
702
  }
1223
- query += ' RETURN count(n) AS count';
1224
- const result = await this.executeRaw(connection, { query, params }, transaction);
703
+ query += ' RETURN count(n) as count';
704
+ const session = this.getSession(transaction);
705
+ const result = await session.run(query, params);
1225
706
  return {
1226
- success: true,
1227
- executionTime: Date.now() - startTime,
1228
- count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
707
+ count: ((_b = (_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0,
1229
708
  };
1230
709
  }
1231
- async countRelationships(connection, type, where, transaction) {
1232
- var _a;
1233
- const startTime = Date.now();
710
+ async countRelationships(types, where, transaction) {
711
+ var _a, _b;
712
+ const typeClause = (types === null || types === void 0 ? void 0 : types.length) ? `:${types.join('|')}` : '';
713
+ let query = `MATCH ()-[r${typeClause}]->()`;
1234
714
  const params = {};
1235
- let typeStr = '';
1236
- if (type) {
1237
- const typeArr = Array.isArray(type) ? type : [type];
1238
- typeStr = ':' + typeArr.map(t => this.escapeIdentifier(t)).join('|');
1239
- }
1240
- let query = `MATCH ()-[r${typeStr}]->()`;
1241
- if (where && Object.keys(where).length > 0) {
1242
- const whereParts = [];
1243
- Object.entries(where).forEach(([key, value], index) => {
1244
- const paramName = `where_${index}`;
1245
- whereParts.push(`r.${this.escapeIdentifier(key)} = $${paramName}`);
1246
- params[paramName] = value;
1247
- });
1248
- query += ` WHERE ${whereParts.join(' AND ')}`;
715
+ if (where) {
716
+ const { clause, params: whereParams } = this.buildWhereClause(where, 'r');
717
+ query += ` WHERE ${clause}`;
718
+ Object.assign(params, whereParams);
1249
719
  }
1250
- query += ' RETURN count(r) AS count';
1251
- const result = await this.executeRaw(connection, { query, params }, transaction);
720
+ query += ' RETURN count(r) as count';
721
+ const session = this.getSession(transaction);
722
+ const result = await session.run(query, params);
1252
723
  return {
1253
- success: true,
1254
- executionTime: Date.now() - startTime,
1255
- count: this.toNumber(((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.count) || 0),
724
+ count: ((_b = (_a = result.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0,
1256
725
  };
1257
726
  }
1258
- async getStatistics(connection, transaction) {
1259
- const startTime = Date.now();
1260
- const query = `
1261
- CALL apoc.meta.stats() YIELD labels, relTypesCount, nodeCount, relCount
1262
- RETURN labels, relTypesCount, nodeCount, relCount
1263
- `;
1264
- // Fallback without APOC
1265
- const fallbackQuery = `
1266
- MATCH (n)
1267
- WITH count(n) AS nodeCount
1268
- MATCH ()-[r]->()
1269
- WITH nodeCount, count(r) AS relCount
1270
- RETURN nodeCount, relCount
1271
- `;
1272
- let result;
1273
- try {
1274
- result = await this.executeRaw(connection, { query }, transaction);
1275
- }
1276
- catch (_a) {
1277
- result = await this.executeRaw(connection, { query: fallbackQuery }, transaction);
1278
- }
1279
- const row = result.data[0] || {};
727
+ async getStatistics(transaction) {
728
+ var _a, _b, _c, _d;
729
+ const session = this.getSession(transaction);
730
+ const nodeCountResult = await session.run('MATCH (n) RETURN count(n) as count');
731
+ const relCountResult = await session.run('MATCH ()-[r]->() RETURN count(r) as count');
1280
732
  return {
1281
- success: true,
1282
- executionTime: Date.now() - startTime,
1283
- nodeCount: this.toNumber(row.nodeCount || 0),
1284
- relationshipCount: this.toNumber(row.relCount || 0),
1285
- labelCounts: row.labels || {},
1286
- relationshipTypeCounts: row.relTypesCount || {},
733
+ nodeCount: ((_b = (_a = nodeCountResult.records[0]) === null || _a === void 0 ? void 0 : _a.get('count')) === null || _b === void 0 ? void 0 : _b.toNumber()) || 0,
734
+ relationshipCount: ((_d = (_c = relCountResult.records[0]) === null || _c === void 0 ? void 0 : _c.get('count')) === null || _d === void 0 ? void 0 : _d.toNumber()) || 0,
1287
735
  };
1288
736
  }
1289
737
  // ==================== SEARCH OPERATIONS ====================
1290
- async fullTextSearch(connection, options, transaction) {
1291
- const startTime = Date.now();
1292
- let query = `
738
+ async fullTextSearch(options, transaction) {
739
+ const query = `
1293
740
  CALL db.index.fulltext.queryNodes($indexName, $searchQuery)
1294
741
  YIELD node, score
742
+ RETURN node, score
743
+ ${options.limit ? `LIMIT ${options.limit}` : ''}
1295
744
  `;
1296
- if (options.labels && options.labels.length > 0) {
1297
- const labelConditions = options.labels.map(l => `'${l}' IN labels(node)`).join(' OR ');
1298
- query += ` WHERE ${labelConditions}`;
1299
- }
1300
- query += ' RETURN node';
1301
- if (options.score) {
1302
- query += ', score';
1303
- }
1304
- if (options.limit) {
1305
- query += ` LIMIT ${options.limit}`;
1306
- }
1307
- const params = {
1308
- indexName: options.index,
745
+ const session = this.getSession(transaction);
746
+ const result = await session.run(query, {
747
+ indexName: options.indexName,
1309
748
  searchQuery: options.query,
1310
- };
1311
- const result = await this.executeRaw(connection, { query, params }, transaction);
1312
- const nodes = result.data.map(row => {
1313
- const node = this.parseNode(row.node);
1314
- if (options.score && row.score !== undefined) {
1315
- return Object.assign(Object.assign({}, node), { score: row.score });
1316
- }
1317
- return node;
1318
749
  });
1319
- return {
1320
- success: true,
1321
- executionTime: Date.now() - startTime,
1322
- nodes,
1323
- count: nodes.length,
1324
- };
750
+ const nodes = result.records.map((r) => this.mapNeo4jNode(r.get('node')));
751
+ const scores = result.records.map((r) => r.get('score'));
752
+ return { nodes, scores };
1325
753
  }
1326
- async vectorSearch(connection, options, transaction) {
1327
- const startTime = Date.now();
754
+ async vectorSearch(options, transaction) {
755
+ // Vector search requires Neo4j 5.13+ with vector index
1328
756
  const query = `
1329
- CALL db.index.vector.queryNodes($indexName, $k, $vector)
757
+ CALL db.index.vector.queryNodes($indexName, $topK, $vector)
1330
758
  YIELD node, score
1331
- ${options.minScore ? `WHERE score >= ${options.minScore}` : ''}
1332
759
  RETURN node, score
1333
760
  `;
1334
- const params = {
1335
- indexName: options.index,
1336
- k: options.topK,
761
+ const session = this.getSession(transaction);
762
+ const result = await session.run(query, {
763
+ indexName: options.indexName,
764
+ topK: options.topK || 10,
1337
765
  vector: options.vector,
1338
- };
1339
- const result = await this.executeRaw(connection, { query, params }, transaction);
1340
- const nodes = result.data.map(row => (Object.assign(Object.assign({}, this.parseNode(row.node)), { similarity: row.score })));
766
+ });
767
+ const nodes = result.records.map((r) => this.mapNeo4jNode(r.get('node')));
768
+ const scores = result.records.map((r) => r.get('score'));
769
+ return { nodes, scores };
770
+ }
771
+ // ==================== RAW QUERY ====================
772
+ async query(options, transaction) {
773
+ var _a, _b, _c, _d, _e, _f;
774
+ const session = this.getSession(transaction);
775
+ const result = await session.run(options.query, options.params || {});
1341
776
  return {
1342
- success: true,
1343
- executionTime: Date.now() - startTime,
1344
- nodes,
1345
- count: nodes.length,
777
+ records: result.records.map((r) => r.toObject()),
778
+ summary: {
779
+ resultAvailableAfter: (_b = (_a = result.summary) === null || _a === void 0 ? void 0 : _a.resultAvailableAfter) === null || _b === void 0 ? void 0 : _b.toNumber(),
780
+ resultConsumedAfter: (_d = (_c = result.summary) === null || _c === void 0 ? void 0 : _c.resultConsumedAfter) === null || _d === void 0 ? void 0 : _d.toNumber(),
781
+ database: (_f = (_e = result.summary) === null || _e === void 0 ? void 0 : _e.database) === null || _f === void 0 ? void 0 : _f.name,
782
+ },
1346
783
  };
1347
784
  }
1348
785
  // ==================== SCHEMA OPERATIONS ====================
1349
- async createNodeConstraint(connection, constraint, transaction) {
1350
- const startTime = Date.now();
786
+ async createNodeIndex(options) {
787
+ const properties = options.properties.map(p => `n.${p}`).join(', ');
788
+ const unique = options.unique ? 'UNIQUE' : '';
789
+ const query = `CREATE ${unique} INDEX ${options.name} IF NOT EXISTS FOR (n:${options.label}) ON (${properties})`;
790
+ const session = this.getSession();
791
+ await session.run(query);
792
+ return { created: true, name: options.name };
793
+ }
794
+ async createNodeConstraint(options) {
1351
795
  let query;
1352
- const props = constraint.properties.map(p => `n.${this.escapeIdentifier(p)}`).join(', ');
1353
- switch (constraint.type) {
1354
- case node_types_1.NodeConstraintType.UNIQUE:
1355
- query = `CREATE CONSTRAINT ${this.escapeIdentifier(constraint.name)} FOR (n:${this.escapeIdentifier(constraint.label)}) REQUIRE (${props}) IS UNIQUE`;
1356
- break;
1357
- case node_types_1.NodeConstraintType.EXISTS:
1358
- query = `CREATE CONSTRAINT ${this.escapeIdentifier(constraint.name)} FOR (n:${this.escapeIdentifier(constraint.label)}) REQUIRE ${props} IS NOT NULL`;
796
+ switch (options.type) {
797
+ case 'UNIQUE':
798
+ query = `CREATE CONSTRAINT ${options.name} IF NOT EXISTS FOR (n:${options.label}) REQUIRE n.${options.property} IS UNIQUE`;
1359
799
  break;
1360
- case node_types_1.NodeConstraintType.NODE_KEY:
1361
- query = `CREATE CONSTRAINT ${this.escapeIdentifier(constraint.name)} FOR (n:${this.escapeIdentifier(constraint.label)}) REQUIRE (${props}) IS NODE KEY`;
800
+ case 'EXISTS':
801
+ query = `CREATE CONSTRAINT ${options.name} IF NOT EXISTS FOR (n:${options.label}) REQUIRE n.${options.property} IS NOT NULL`;
1362
802
  break;
1363
803
  default:
1364
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Unknown constraint type: ${constraint.type}`);
804
+ throw graph_error_1.GraphError.validationError(`Unsupported constraint type: ${options.type}`);
1365
805
  }
1366
- await this.executeRaw(connection, { query }, transaction);
1367
- return {
1368
- success: true,
1369
- executionTime: Date.now() - startTime,
1370
- name: constraint.name,
1371
- created: true,
1372
- };
806
+ const session = this.getSession();
807
+ await session.run(query);
808
+ return { created: true, name: options.name };
1373
809
  }
1374
- async createRelationshipConstraint(connection, constraint, transaction) {
1375
- const startTime = Date.now();
1376
- const props = constraint.properties.map(p => `r.${this.escapeIdentifier(p)}`).join(', ');
1377
- const query = `CREATE CONSTRAINT ${this.escapeIdentifier(constraint.name)} FOR ()-[r:${this.escapeIdentifier(constraint.relationshipType)}]-() REQUIRE ${props} IS NOT NULL`;
1378
- await this.executeRaw(connection, { query }, transaction);
1379
- return {
1380
- success: true,
1381
- executionTime: Date.now() - startTime,
1382
- name: constraint.name,
1383
- created: true,
1384
- };
810
+ async createRelationshipIndex(options) {
811
+ const properties = options.properties.map(p => `r.${p}`).join(', ');
812
+ const query = `CREATE INDEX ${options.name} IF NOT EXISTS FOR ()-[r:${options.type}]-() ON (${properties})`;
813
+ const session = this.getSession();
814
+ await session.run(query);
815
+ return { created: true, name: options.name };
1385
816
  }
1386
- async dropConstraint(connection, name, transaction) {
1387
- const startTime = Date.now();
1388
- const query = `DROP CONSTRAINT ${this.escapeIdentifier(name)}`;
1389
- await this.executeRaw(connection, { query }, transaction);
1390
- return {
1391
- success: true,
1392
- executionTime: Date.now() - startTime,
1393
- name,
1394
- dropped: true,
1395
- };
817
+ async listIndexes() {
818
+ const query = 'SHOW INDEXES';
819
+ const session = this.getSession();
820
+ const result = await session.run(query);
821
+ const indexes = result.records.map((r) => {
822
+ var _a;
823
+ return ({
824
+ name: r.get('name'),
825
+ labelOrType: ((_a = r.get('labelsOrTypes')) === null || _a === void 0 ? void 0 : _a[0]) || '',
826
+ properties: r.get('properties') || [],
827
+ unique: r.get('uniqueness') === 'UNIQUE',
828
+ type: r.get('type'),
829
+ state: r.get('state'),
830
+ });
831
+ });
832
+ return { indexes };
1396
833
  }
1397
- async listConstraints(connection, transaction) {
1398
- const startTime = Date.now();
834
+ async listConstraints() {
1399
835
  const query = 'SHOW CONSTRAINTS';
1400
- const result = await this.executeRaw(connection, { query }, transaction);
1401
- const constraints = result.data.map(row => ({
1402
- name: row.name,
1403
- type: row.type,
1404
- entityType: row.entityType,
1405
- labelsOrTypes: row.labelsOrTypes || [],
1406
- properties: row.properties || [],
1407
- ownedIndex: row.ownedIndex,
1408
- }));
1409
- return {
1410
- success: true,
1411
- executionTime: Date.now() - startTime,
1412
- constraints,
1413
- };
1414
- }
1415
- async createNodeIndex(connection, index, transaction) {
1416
- const startTime = Date.now();
1417
- const props = index.properties.map(p => `n.${this.escapeIdentifier(p)}`).join(', ');
1418
- let query;
1419
- switch (index.type) {
1420
- case node_types_1.NodeIndexType.BTREE:
1421
- case node_types_1.NodeIndexType.RANGE:
1422
- query = `CREATE INDEX ${this.escapeIdentifier(index.name)} FOR (n:${this.escapeIdentifier(index.label)}) ON (${props})`;
1423
- break;
1424
- case node_types_1.NodeIndexType.FULLTEXT:
1425
- query = `CREATE FULLTEXT INDEX ${this.escapeIdentifier(index.name)} FOR (n:${this.escapeIdentifier(index.label)}) ON EACH [${props}]`;
1426
- break;
1427
- case node_types_1.NodeIndexType.POINT:
1428
- query = `CREATE POINT INDEX ${this.escapeIdentifier(index.name)} FOR (n:${this.escapeIdentifier(index.label)}) ON (${props})`;
1429
- break;
1430
- case node_types_1.NodeIndexType.TEXT:
1431
- query = `CREATE TEXT INDEX ${this.escapeIdentifier(index.name)} FOR (n:${this.escapeIdentifier(index.label)}) ON (${props})`;
1432
- break;
1433
- case node_types_1.NodeIndexType.VECTOR:
1434
- const vectorOptions = index.options || {};
1435
- query = `CREATE VECTOR INDEX ${this.escapeIdentifier(index.name)} FOR (n:${this.escapeIdentifier(index.label)}) ON (${props}) OPTIONS {indexConfig: {vector.dimensions: ${vectorOptions.dimensions || 256}, vector.similarity_function: '${vectorOptions.similarityFunction || 'cosine'}'}}`;
1436
- break;
836
+ const session = this.getSession();
837
+ const result = await session.run(query);
838
+ const constraints = result.records.map((r) => {
839
+ var _a, _b;
840
+ return ({
841
+ name: r.get('name'),
842
+ label: ((_a = r.get('labelsOrTypes')) === null || _a === void 0 ? void 0 : _a[0]) || '',
843
+ property: ((_b = r.get('properties')) === null || _b === void 0 ? void 0 : _b[0]) || '',
844
+ type: r.get('type'),
845
+ });
846
+ });
847
+ return { constraints };
848
+ }
849
+ async dropIndex(name) {
850
+ const query = `DROP INDEX ${name} IF EXISTS`;
851
+ const session = this.getSession();
852
+ await session.run(query);
853
+ return { dropped: true };
854
+ }
855
+ async dropConstraint(name) {
856
+ const query = `DROP CONSTRAINT ${name} IF EXISTS`;
857
+ const session = this.getSession();
858
+ await session.run(query);
859
+ return { dropped: true };
860
+ }
861
+ // ==================== SCHEMA INTROSPECTION ====================
862
+ async listLabels() {
863
+ var _a, _b, _c, _d;
864
+ const session = this.getSession();
865
+ // Get all labels
866
+ const labelsResult = await session.run('CALL db.labels()');
867
+ const labelNames = labelsResult.records.map((r) => r.get('label'));
868
+ const labels = [];
869
+ for (const labelName of labelNames) {
870
+ // Get count for each label
871
+ const countResult = await session.run(`MATCH (n:\`${labelName}\`) RETURN count(n) as count`);
872
+ 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)) ||
873
+ ((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
874
+ // Get properties for a sample of nodes with this label
875
+ const propsResult = await session.run(`MATCH (n:\`${labelName}\`) WITH n LIMIT 100
876
+ UNWIND keys(n) as key
877
+ WITH key, n[key] as value
878
+ RETURN DISTINCT key,
879
+ CASE
880
+ WHEN value IS NULL THEN 'unknown'
881
+ WHEN toInteger(value) IS NOT NULL THEN 'number'
882
+ WHEN toFloat(value) IS NOT NULL THEN 'number'
883
+ WHEN value =~ '.*' THEN 'string'
884
+ WHEN value = true OR value = false THEN 'boolean'
885
+ WHEN date(value) IS NOT NULL THEN 'date'
886
+ WHEN datetime(value) IS NOT NULL THEN 'datetime'
887
+ WHEN point(value) IS NOT NULL THEN 'point'
888
+ WHEN value IS :: LIST THEN 'array'
889
+ ELSE 'unknown'
890
+ END as type`);
891
+ const properties = propsResult.records.map((r) => ({
892
+ name: r.get('key'),
893
+ type: this.mapNeo4jTypeToPropertyType(r.get('type')),
894
+ }));
895
+ labels.push({
896
+ name: labelName,
897
+ count: typeof count === 'number' ? count : Number(count),
898
+ properties,
899
+ });
900
+ }
901
+ return { labels };
902
+ }
903
+ async listRelationshipTypes() {
904
+ var _a, _b, _c, _d;
905
+ const session = this.getSession();
906
+ // Get all relationship types
907
+ const typesResult = await session.run('CALL db.relationshipTypes()');
908
+ const typeNames = typesResult.records.map((r) => r.get('relationshipType'));
909
+ const types = [];
910
+ for (const typeName of typeNames) {
911
+ // Get count for each type
912
+ const countResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() RETURN count(r) as count`);
913
+ 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)) ||
914
+ ((_d = countResult.records[0]) === null || _d === void 0 ? void 0 : _d.get('count')) || 0;
915
+ // Get source and target label information
916
+ const endpointsResult = await session.run(`MATCH (a)-[r:\`${typeName}\`]->(b)
917
+ WITH labels(a) as fromLabels, labels(b) as toLabels
918
+ RETURN DISTINCT fromLabels[0] as fromLabel, toLabels[0] as toLabel
919
+ LIMIT 10`);
920
+ const fromLabelsArray = endpointsResult.records
921
+ .map((r) => r.get('fromLabel'))
922
+ .filter((l) => Boolean(l));
923
+ const fromLabels = [...new Set(fromLabelsArray)];
924
+ const toLabelsArray = endpointsResult.records
925
+ .map((r) => r.get('toLabel'))
926
+ .filter((l) => Boolean(l));
927
+ const toLabels = [...new Set(toLabelsArray)];
928
+ // Get properties for relationships of this type
929
+ const propsResult = await session.run(`MATCH ()-[r:\`${typeName}\`]->() WITH r LIMIT 100
930
+ UNWIND keys(r) as key
931
+ RETURN DISTINCT key`);
932
+ const properties = propsResult.records.map((r) => ({
933
+ name: r.get('key'),
934
+ type: 'unknown',
935
+ }));
936
+ types.push({
937
+ type: typeName,
938
+ count: typeof count === 'number' ? count : Number(count),
939
+ fromLabels,
940
+ toLabels,
941
+ properties: properties.length > 0 ? properties : undefined,
942
+ });
943
+ }
944
+ return { types };
945
+ }
946
+ /**
947
+ * Map Neo4j type string to GraphPropertyType
948
+ */
949
+ mapNeo4jTypeToPropertyType(typeStr) {
950
+ switch (typeStr === null || typeStr === void 0 ? void 0 : typeStr.toLowerCase()) {
951
+ case 'number':
952
+ case 'integer':
953
+ case 'float':
954
+ return 'number';
955
+ case 'string':
956
+ return 'string';
957
+ case 'boolean':
958
+ return 'boolean';
959
+ case 'date':
960
+ return 'date';
961
+ case 'datetime':
962
+ return 'datetime';
963
+ case 'point':
964
+ return 'point';
965
+ case 'array':
966
+ case 'list':
967
+ return 'array';
1437
968
  default:
1438
- query = `CREATE INDEX ${this.escapeIdentifier(index.name)} FOR (n:${this.escapeIdentifier(index.label)}) ON (${props})`;
969
+ return 'unknown';
1439
970
  }
1440
- await this.executeRaw(connection, { query }, transaction);
1441
- return {
1442
- success: true,
1443
- executionTime: Date.now() - startTime,
1444
- name: index.name,
1445
- created: true,
1446
- };
1447
971
  }
1448
- async createRelationshipIndex(connection, index, transaction) {
1449
- const startTime = Date.now();
1450
- const props = index.properties.map(p => `r.${this.escapeIdentifier(p)}`).join(', ');
1451
- const query = `CREATE INDEX ${this.escapeIdentifier(index.name)} FOR ()-[r:${this.escapeIdentifier(index.relationshipType)}]-() ON (${props})`;
1452
- await this.executeRaw(connection, { query }, transaction);
972
+ // ==================== TRANSACTION OPERATIONS ====================
973
+ async beginTransaction(options) {
974
+ const session = this.driver.session();
975
+ const tx = session.beginTransaction();
1453
976
  return {
1454
- success: true,
1455
- executionTime: Date.now() - startTime,
1456
- name: index.name,
1457
- created: true,
977
+ id: `tx_${Date.now()}`,
978
+ status: enums_1.GraphTransactionStatus.ACTIVE,
979
+ client: tx,
980
+ commit: async () => {
981
+ await tx.commit();
982
+ await session.close();
983
+ },
984
+ rollback: async () => {
985
+ await tx.rollback();
986
+ await session.close();
987
+ },
1458
988
  };
1459
989
  }
1460
- async dropIndex(connection, name, transaction) {
1461
- const startTime = Date.now();
1462
- const query = `DROP INDEX ${this.escapeIdentifier(name)}`;
1463
- await this.executeRaw(connection, { query }, transaction);
1464
- return {
1465
- success: true,
1466
- executionTime: Date.now() - startTime,
1467
- name,
1468
- dropped: true,
1469
- };
990
+ async commitTransaction(transaction) {
991
+ await transaction.commit();
1470
992
  }
1471
- async listIndexes(connection, transaction) {
1472
- const startTime = Date.now();
1473
- const query = 'SHOW INDEXES';
1474
- const result = await this.executeRaw(connection, { query }, transaction);
1475
- const indexes = result.data.map(row => ({
1476
- name: row.name,
1477
- type: row.type,
1478
- entityType: row.entityType,
1479
- labelsOrTypes: row.labelsOrTypes || [],
1480
- properties: row.properties || [],
1481
- state: row.state,
1482
- uniqueness: row.uniqueness,
1483
- provider: row.provider,
1484
- }));
1485
- return {
1486
- success: true,
1487
- executionTime: Date.now() - startTime,
1488
- indexes,
1489
- };
993
+ async rollbackTransaction(transaction) {
994
+ await transaction.rollback();
1490
995
  }
1491
996
  // ==================== UTILITY METHODS ====================
1492
- escapeIdentifier(identifier) {
1493
- // Neo4j identifiers can be backtick-escaped
1494
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(identifier)) {
1495
- return identifier;
1496
- }
1497
- return `\`${identifier.replace(/`/g, '``')}\``;
1498
- }
1499
- escapeValue(value) {
1500
- if (value === null)
1501
- return 'null';
1502
- if (typeof value === 'string')
1503
- return `'${value.replace(/'/g, "\\'")}'`;
1504
- if (typeof value === 'number')
1505
- return String(value);
1506
- if (typeof value === 'boolean')
1507
- return value ? 'true' : 'false';
1508
- if (value instanceof Date)
1509
- return `datetime('${value.toISOString()}')`;
1510
- if (Array.isArray(value))
1511
- return `[${value.map(v => this.escapeValue(v)).join(', ')}]`;
1512
- if (typeof value === 'object')
1513
- return `{${Object.entries(value).map(([k, v]) => `${k}: ${this.escapeValue(v)}`).join(', ')}}`;
1514
- return String(value);
1515
- }
1516
- buildWhereClause(where, variableName = 'n') {
997
+ buildWhereClause(where, alias = 'n') {
998
+ const conditions = [];
1517
999
  const params = {};
1518
- const parts = [];
1519
- Object.entries(where).forEach(([key, value], index) => {
1520
- const paramName = `where_${index}`;
1521
- parts.push(`${variableName}.${this.escapeIdentifier(key)} = $${paramName}`);
1522
- params[paramName] = value;
1000
+ let paramIndex = 0;
1001
+ const processCondition = (key, value, prefix = '') => {
1002
+ const fullKey = prefix ? `${prefix}_${key}` : key;
1003
+ const paramName = `param_${paramIndex++}`;
1004
+ if (key === '$AND') {
1005
+ const subConditions = Object.entries(value).map(([k, v]) => {
1006
+ processCondition(k, v, fullKey);
1007
+ return conditions.pop();
1008
+ });
1009
+ conditions.push(`(${subConditions.join(' AND ')})`);
1010
+ return;
1011
+ }
1012
+ if (key === '$OR') {
1013
+ const subConditions = Object.entries(value).map(([k, v]) => {
1014
+ processCondition(k, v, fullKey);
1015
+ return conditions.pop();
1016
+ });
1017
+ conditions.push(`(${subConditions.join(' OR ')})`);
1018
+ return;
1019
+ }
1020
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
1021
+ Object.entries(value).forEach(([op, opValue]) => {
1022
+ const opParamName = `${paramName}_${op.toLowerCase()}`;
1023
+ switch (op) {
1024
+ case '$GT':
1025
+ conditions.push(`${alias}.${key} > $${opParamName}`);
1026
+ params[opParamName] = opValue;
1027
+ break;
1028
+ case '$GTE':
1029
+ conditions.push(`${alias}.${key} >= $${opParamName}`);
1030
+ params[opParamName] = opValue;
1031
+ break;
1032
+ case '$LT':
1033
+ conditions.push(`${alias}.${key} < $${opParamName}`);
1034
+ params[opParamName] = opValue;
1035
+ break;
1036
+ case '$LTE':
1037
+ conditions.push(`${alias}.${key} <= $${opParamName}`);
1038
+ params[opParamName] = opValue;
1039
+ break;
1040
+ case '$NE':
1041
+ conditions.push(`${alias}.${key} <> $${opParamName}`);
1042
+ params[opParamName] = opValue;
1043
+ break;
1044
+ case '$IN':
1045
+ conditions.push(`${alias}.${key} IN $${opParamName}`);
1046
+ params[opParamName] = opValue;
1047
+ break;
1048
+ case '$NOT_IN':
1049
+ conditions.push(`NOT ${alias}.${key} IN $${opParamName}`);
1050
+ params[opParamName] = opValue;
1051
+ break;
1052
+ case '$CONTAINS':
1053
+ conditions.push(`${alias}.${key} CONTAINS $${opParamName}`);
1054
+ params[opParamName] = opValue;
1055
+ break;
1056
+ case '$STARTS_WITH':
1057
+ conditions.push(`${alias}.${key} STARTS WITH $${opParamName}`);
1058
+ params[opParamName] = opValue;
1059
+ break;
1060
+ case '$ENDS_WITH':
1061
+ conditions.push(`${alias}.${key} ENDS WITH $${opParamName}`);
1062
+ params[opParamName] = opValue;
1063
+ break;
1064
+ case '$EXISTS':
1065
+ if (opValue) {
1066
+ conditions.push(`${alias}.${key} IS NOT NULL`);
1067
+ }
1068
+ else {
1069
+ conditions.push(`${alias}.${key} IS NULL`);
1070
+ }
1071
+ break;
1072
+ }
1073
+ });
1074
+ }
1075
+ else {
1076
+ conditions.push(`${alias}.${key} = $${paramName}`);
1077
+ params[paramName] = value;
1078
+ }
1079
+ };
1080
+ Object.entries(where).forEach(([key, value]) => {
1081
+ processCondition(key, value);
1523
1082
  });
1524
1083
  return {
1525
- clause: parts.join(' AND '),
1084
+ clause: conditions.join(' AND ') || 'true',
1526
1085
  params,
1527
1086
  };
1528
1087
  }
1529
- // ==================== PROTECTED PARSER METHODS ====================
1530
- parseNode(nativeNode) {
1531
- if (!nativeNode) {
1532
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.NODE_ERROR, 'Cannot parse null node');
1533
- }
1534
- // Handle Neo4j Node object
1535
- if (nativeNode.identity !== undefined) {
1536
- return {
1537
- id: this.toNumber(nativeNode.identity),
1538
- labels: nativeNode.labels || [],
1539
- properties: this.convertProperties(nativeNode.properties),
1540
- elementId: nativeNode.elementId,
1541
- };
1542
- }
1543
- // Handle plain object (from raw query results)
1088
+ parseError(error) {
1089
+ return graph_error_1.GraphError.wrap(error);
1090
+ }
1091
+ // ==================== PRIVATE HELPER METHODS ====================
1092
+ mapNeo4jNode(node) {
1093
+ var _a;
1544
1094
  return {
1545
- id: nativeNode.id || nativeNode.identity || '',
1546
- labels: nativeNode.labels || [],
1547
- properties: (nativeNode.properties || nativeNode),
1548
- elementId: nativeNode.elementId,
1095
+ id: node.elementId || ((_a = node.identity) === null || _a === void 0 ? void 0 : _a.toString()) || '',
1096
+ labels: node.labels || [],
1097
+ properties: this.convertNeo4jProperties(node.properties || {}),
1098
+ elementId: node.elementId,
1549
1099
  };
1550
1100
  }
1551
- parseRelationship(nativeRelationship) {
1552
- if (!nativeRelationship) {
1553
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.RELATIONSHIP_ERROR, 'Cannot parse null relationship');
1554
- }
1555
- // Handle Neo4j Relationship object
1556
- if (nativeRelationship.identity !== undefined) {
1557
- return {
1558
- id: this.toNumber(nativeRelationship.identity),
1559
- type: nativeRelationship.type,
1560
- startNodeId: this.toNumber(nativeRelationship.start),
1561
- endNodeId: this.toNumber(nativeRelationship.end),
1562
- properties: this.convertProperties(nativeRelationship.properties),
1563
- elementId: nativeRelationship.elementId,
1564
- startNodeElementId: nativeRelationship.startNodeElementId,
1565
- endNodeElementId: nativeRelationship.endNodeElementId,
1566
- };
1567
- }
1101
+ mapNeo4jRelationship(rel, startId, endId) {
1102
+ var _a;
1568
1103
  return {
1569
- id: nativeRelationship.id || nativeRelationship.identity || '',
1570
- type: nativeRelationship.type || '',
1571
- startNodeId: nativeRelationship.startNodeId || nativeRelationship.start || '',
1572
- endNodeId: nativeRelationship.endNodeId || nativeRelationship.end || '',
1573
- properties: (nativeRelationship.properties || nativeRelationship),
1574
- elementId: nativeRelationship.elementId,
1104
+ id: rel.elementId || ((_a = rel.identity) === null || _a === void 0 ? void 0 : _a.toString()) || '',
1105
+ type: rel.type,
1106
+ startNodeId: startId,
1107
+ endNodeId: endId,
1108
+ properties: this.convertNeo4jProperties(rel.properties || {}),
1109
+ elementId: rel.elementId,
1575
1110
  };
1576
1111
  }
1577
- parsePath(nativePath) {
1578
- if (!nativePath) {
1579
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.PATH_ERROR, 'Cannot parse null path');
1580
- }
1581
- // Handle Neo4j Path object
1582
- const nodes = [];
1583
- const relationships = [];
1584
- if (nativePath.segments) {
1585
- nativePath.segments.forEach((segment) => {
1586
- if (nodes.length === 0) {
1587
- nodes.push(this.parseNode(segment.start));
1588
- }
1589
- relationships.push(this.parseRelationship(segment.relationship));
1590
- nodes.push(this.parseNode(segment.end));
1591
- });
1592
- }
1593
- else if (nativePath.nodes && nativePath.relationships) {
1594
- nativePath.nodes.forEach((n) => nodes.push(this.parseNode(n)));
1595
- nativePath.relationships.forEach((r) => relationships.push(this.parseRelationship(r)));
1596
- }
1112
+ mapNeo4jPath(path) {
1113
+ const nodes = path.segments.reduce((acc, segment, index) => {
1114
+ if (index === 0) {
1115
+ acc.push(this.mapNeo4jNode(segment.start));
1116
+ }
1117
+ acc.push(this.mapNeo4jNode(segment.end));
1118
+ return acc;
1119
+ }, []);
1120
+ const relationships = path.segments.map((segment) => this.mapNeo4jRelationship(segment.relationship, segment.start.elementId || segment.start.identity.toString(), segment.end.elementId || segment.end.identity.toString()));
1597
1121
  return {
1598
1122
  nodes,
1599
1123
  relationships,
1600
1124
  length: relationships.length,
1601
- start: nodes[0],
1602
- end: nodes[nodes.length - 1],
1603
1125
  };
1604
1126
  }
1605
- // ==================== PRIVATE HELPER METHODS ====================
1127
+ convertNeo4jProperties(props) {
1128
+ const result = {};
1129
+ for (const [key, value] of Object.entries(props)) {
1130
+ result[key] = this.convertNeo4jValue(value);
1131
+ }
1132
+ return result;
1133
+ }
1606
1134
  convertNeo4jValue(value) {
1607
- if (value === null || value === undefined)
1135
+ var _a, _b;
1136
+ if (value === null || value === undefined) {
1608
1137
  return value;
1609
- // Handle Neo4j Integer
1610
- if (neo4j_driver_1.default.isInt(value)) {
1611
- return this.toNumber(value);
1612
1138
  }
1613
- // Handle Neo4j Node
1614
- if (value.labels !== undefined && value.properties !== undefined) {
1615
- return this.parseNode(value);
1616
- }
1617
- // Handle Neo4j Relationship
1618
- if (value.type !== undefined && value.start !== undefined && value.end !== undefined) {
1619
- return this.parseRelationship(value);
1139
+ // Handle Neo4j Integer type
1140
+ if (typeof value === 'object' && ((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Integer') {
1141
+ return value.toNumber();
1620
1142
  }
1621
- // Handle Neo4j Path
1622
- if (value.segments !== undefined) {
1623
- return this.parsePath(value);
1143
+ // Handle Neo4j Date types
1144
+ if (typeof value === 'object' && ((_b = value.constructor) === null || _b === void 0 ? void 0 : _b.name) === 'Date') {
1145
+ return new Date(value.toString());
1624
1146
  }
1625
- // Handle arrays
1626
1147
  if (Array.isArray(value)) {
1627
1148
  return value.map(v => this.convertNeo4jValue(v));
1628
1149
  }
1629
- // Handle objects
1630
- if (typeof value === 'object') {
1631
- const converted = {};
1632
- Object.entries(value).forEach(([key, val]) => {
1633
- converted[key] = this.convertNeo4jValue(val);
1634
- });
1635
- return converted;
1636
- }
1637
1150
  return value;
1638
1151
  }
1639
- convertProperties(properties) {
1640
- if (!properties)
1641
- return {};
1642
- const converted = {};
1643
- Object.entries(properties).forEach(([key, value]) => {
1644
- converted[key] = this.convertNeo4jValue(value);
1645
- });
1646
- return converted;
1647
- }
1648
- toNumber(value) {
1649
- if (neo4j_driver_1.default.isInt(value)) {
1650
- return value.toNumber();
1651
- }
1652
- if (typeof value === 'number') {
1653
- return value;
1654
- }
1655
- return parseInt(value, 10) || 0;
1656
- }
1657
- normalizeLabels(labels) {
1658
- return Array.isArray(labels) ? labels : [labels];
1659
- }
1660
- buildPropertiesClause(properties, prefix = '') {
1661
- const params = {};
1662
- const propParts = [];
1663
- Object.entries(properties).forEach(([key, value], index) => {
1664
- const paramName = `${prefix}prop_${index}`;
1665
- propParts.push(`${this.escapeIdentifier(key)}: $${paramName}`);
1666
- params[paramName] = value;
1667
- });
1668
- return {
1669
- clause: `{${propParts.join(', ')}}`,
1670
- params,
1671
- };
1672
- }
1673
- buildNodeReference(ref, alias, params, prefix = '') {
1674
- let pattern = `(${alias}`;
1675
- if (ref.labels) {
1676
- const labels = this.normalizeLabels(ref.labels);
1677
- pattern += ':' + labels.map(l => this.escapeIdentifier(l)).join(':');
1678
- }
1679
- if (ref.id !== undefined) {
1680
- const paramName = `${prefix}id`;
1681
- params[paramName] = ref.id;
1682
- pattern += ` {id: $${paramName}}`;
1683
- }
1684
- else if (ref.properties && Object.keys(ref.properties).length > 0) {
1685
- const { clause, params: propParams } = this.buildPropertiesClause(ref.properties, prefix);
1686
- pattern += ` ${clause}`;
1687
- Object.assign(params, propParams);
1688
- }
1689
- pattern += ')';
1690
- return pattern;
1691
- }
1692
- buildNodeReferenceWhere(ref, alias, params, prefix = '') {
1693
- const parts = [];
1694
- if (ref.id !== undefined) {
1695
- const paramName = `${prefix}id`;
1696
- params[paramName] = ref.id;
1697
- if (typeof ref.id === 'string') {
1698
- parts.push(`elementId(${alias}) = $${paramName}`);
1699
- }
1700
- else {
1701
- parts.push(`id(${alias}) = $${paramName}`);
1702
- }
1703
- }
1704
- if (ref.labels) {
1705
- const labels = this.normalizeLabels(ref.labels);
1706
- labels.forEach(label => {
1707
- parts.push(`'${label}' IN labels(${alias})`);
1708
- });
1709
- }
1710
- if (ref.properties) {
1711
- Object.entries(ref.properties).forEach(([key, value], index) => {
1712
- const paramName = `${prefix}prop_${index}`;
1713
- parts.push(`${alias}.${this.escapeIdentifier(key)} = $${paramName}`);
1714
- params[paramName] = value;
1715
- });
1716
- }
1717
- return parts.join(' AND ');
1718
- }
1719
- buildWhereFromClause(where, alias, prefix = '') {
1720
- const params = {};
1721
- const clause = this.buildWhereCondition(where, alias, params, prefix);
1722
- return { clause, params };
1723
- }
1724
- buildWhereCondition(where, alias, params, prefix, index = 0) {
1725
- const paramName = `${prefix}where_${index}`;
1726
- let condition;
1727
- switch (where.operator) {
1728
- case node_types_1.NodeComparisonOperator.IS_NULL:
1729
- condition = `${alias}.${this.escapeIdentifier(where.property)} IS NULL`;
1730
- break;
1731
- case node_types_1.NodeComparisonOperator.IS_NOT_NULL:
1732
- condition = `${alias}.${this.escapeIdentifier(where.property)} IS NOT NULL`;
1733
- break;
1734
- case node_types_1.NodeComparisonOperator.IN:
1735
- case node_types_1.NodeComparisonOperator.NOT_IN:
1736
- params[paramName] = where.value;
1737
- condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
1738
- break;
1739
- case node_types_1.NodeComparisonOperator.CONTAINS:
1740
- params[paramName] = where.value;
1741
- condition = `${alias}.${this.escapeIdentifier(where.property)} CONTAINS $${paramName}`;
1742
- break;
1743
- case node_types_1.NodeComparisonOperator.STARTS_WITH:
1744
- params[paramName] = where.value;
1745
- condition = `${alias}.${this.escapeIdentifier(where.property)} STARTS WITH $${paramName}`;
1746
- break;
1747
- case node_types_1.NodeComparisonOperator.ENDS_WITH:
1748
- params[paramName] = where.value;
1749
- condition = `${alias}.${this.escapeIdentifier(where.property)} ENDS WITH $${paramName}`;
1750
- break;
1751
- case node_types_1.NodeComparisonOperator.REGEX:
1752
- params[paramName] = where.value;
1753
- condition = `${alias}.${this.escapeIdentifier(where.property)} =~ $${paramName}`;
1754
- break;
1152
+ getDirectionArrow(direction) {
1153
+ switch (direction) {
1154
+ case enums_1.TraversalDirection.OUTGOING:
1155
+ case 'OUTGOING':
1156
+ return { left: '-', right: '->' };
1157
+ case enums_1.TraversalDirection.INCOMING:
1158
+ case 'INCOMING':
1159
+ return { left: '<-', right: '-' };
1160
+ case enums_1.TraversalDirection.BOTH:
1161
+ case 'BOTH':
1755
1162
  default:
1756
- params[paramName] = where.value;
1757
- condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
1758
- }
1759
- // Handle AND conditions
1760
- if (where.and && where.and.length > 0) {
1761
- const andClauses = where.and.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 1));
1762
- condition = `(${condition} AND ${andClauses.join(' AND ')})`;
1763
- }
1764
- // Handle OR conditions
1765
- if (where.or && where.or.length > 0) {
1766
- const orClauses = where.or.map((w, i) => this.buildWhereCondition(w, alias, params, prefix, index + i + 100));
1767
- condition = `(${condition} OR ${orClauses.join(' OR ')})`;
1768
- }
1769
- return condition;
1770
- }
1771
- buildRelationshipWhereClause(where, alias, prefix = '') {
1772
- const params = {};
1773
- const clause = this.buildRelationshipWhereCondition(where, alias, params, prefix);
1774
- return { clause, params };
1775
- }
1776
- buildRelationshipWhereCondition(where, alias, params, prefix, index = 0) {
1777
- const paramName = `${prefix}relwhere_${index}`;
1778
- params[paramName] = where.value;
1779
- let condition = `${alias}.${this.escapeIdentifier(where.property)} ${where.operator} $${paramName}`;
1780
- if (where.and && where.and.length > 0) {
1781
- const andClauses = where.and.map((w, i) => this.buildRelationshipWhereCondition(w, alias, params, prefix, index + i + 1));
1782
- condition = `(${condition} AND ${andClauses.join(' AND ')})`;
1783
- }
1784
- if (where.or && where.or.length > 0) {
1785
- const orClauses = where.or.map((w, i) => this.buildRelationshipWhereCondition(w, alias, params, prefix, index + i + 100));
1786
- condition = `(${condition} OR ${orClauses.join(' OR ')})`;
1163
+ return { left: '-', right: '-' };
1787
1164
  }
1788
- return condition;
1789
- }
1790
- buildNodeSelectorMatch(selector, alias, params, prefix = '') {
1791
- let pattern = `(${alias}`;
1792
- if (selector.labels) {
1793
- const labels = this.normalizeLabels(selector.labels);
1794
- pattern += ':' + labels.map((l) => this.escapeIdentifier(l)).join(':');
1795
- }
1796
- pattern += ')';
1797
- const whereParts = [];
1798
- if (selector.id !== undefined) {
1799
- const paramName = `${prefix}id`;
1800
- params[paramName] = selector.id;
1801
- if (typeof selector.id === 'string') {
1802
- whereParts.push(`elementId(${alias}) = $${paramName}`);
1803
- }
1804
- else {
1805
- whereParts.push(`id(${alias}) = $${paramName}`);
1806
- }
1807
- }
1808
- if (selector.properties && Object.keys(selector.properties).length > 0) {
1809
- Object.entries(selector.properties).forEach(([key, value], index) => {
1810
- const paramName = `${prefix}prop_${index}`;
1811
- whereParts.push(`${alias}.${this.escapeIdentifier(key)} = $${paramName}`);
1812
- params[paramName] = value;
1813
- });
1814
- }
1815
- if (selector.where) {
1816
- const { clause, params: whereParams } = this.buildWhereFromClause(selector.where, alias, prefix);
1817
- whereParts.push(clause);
1818
- Object.assign(params, whereParams);
1819
- }
1820
- if (whereParts.length > 0) {
1821
- return `${pattern} WHERE ${whereParts.join(' AND ')}`;
1822
- }
1823
- return pattern;
1824
- }
1825
- buildTraversalRelPattern(options) {
1826
- if (!options.relationships)
1827
- return '';
1828
- const patterns = Array.isArray(options.relationships)
1829
- ? options.relationships
1830
- : [options.relationships];
1831
- const types = patterns
1832
- .filter((p) => p.type)
1833
- .map((p) => {
1834
- const types = Array.isArray(p.type) ? p.type : [p.type];
1835
- return types.map((t) => this.escapeIdentifier(t));
1836
- })
1837
- .flat();
1838
- return types.length > 0 ? ':' + types.join('|') : '';
1839
- }
1840
- parseStatistics(counters) {
1841
- if (!counters)
1842
- return undefined;
1843
- return {
1844
- nodesCreated: counters.nodesCreated ? counters.nodesCreated() : 0,
1845
- nodesDeleted: counters.nodesDeleted ? counters.nodesDeleted() : 0,
1846
- relationshipsCreated: counters.relationshipsCreated ? counters.relationshipsCreated() : 0,
1847
- relationshipsDeleted: counters.relationshipsDeleted ? counters.relationshipsDeleted() : 0,
1848
- propertiesSet: counters.propertiesSet ? counters.propertiesSet() : 0,
1849
- labelsAdded: counters.labelsAdded ? counters.labelsAdded() : 0,
1850
- labelsRemoved: counters.labelsRemoved ? counters.labelsRemoved() : 0,
1851
- indexesAdded: counters.indexesAdded ? counters.indexesAdded() : 0,
1852
- indexesRemoved: counters.indexesRemoved ? counters.indexesRemoved() : 0,
1853
- constraintsAdded: counters.constraintsAdded ? counters.constraintsAdded() : 0,
1854
- constraintsRemoved: counters.constraintsRemoved ? counters.constraintsRemoved() : 0,
1855
- containsUpdates: counters.containsUpdates ? counters.containsUpdates() : false,
1856
- };
1857
1165
  }
1858
1166
  }
1859
1167
  exports.Neo4jAdapter = Neo4jAdapter;
1860
- exports.default = Neo4jAdapter;
1861
1168
  //# sourceMappingURL=neo4j.adapter.js.map