@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,10 @@
1
1
  "use strict";
2
2
  /**
3
3
  * ArangoDB Graph Database Adapter
4
- * Implements the BaseGraphAdapter for ArangoDB using AQL (ArangoDB Query Language)
4
+ *
5
+ * Implements the BaseGraphAdapter for ArangoDB.
6
+ * ArangoDB is a multi-model database that supports documents, graphs, and key-value.
7
+ * Uses AQL (ArangoDB Query Language) for graph operations.
5
8
  */
6
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
10
  if (k2 === undefined) k2 = k;
@@ -36,1358 +39,1445 @@ var __importStar = (this && this.__importStar) || (function () {
36
39
  return result;
37
40
  };
38
41
  })();
39
- var __rest = (this && this.__rest) || function (s, e) {
40
- var t = {};
41
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
42
- t[p] = s[p];
43
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
44
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
45
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
46
- t[p[i]] = s[p[i]];
47
- }
48
- return t;
49
- };
50
42
  Object.defineProperty(exports, "__esModule", { value: true });
51
43
  exports.ArangoDBAdapter = void 0;
52
44
  const base_adapter_1 = require("./base.adapter");
53
- const graph_types_1 = require("../types/graph.types");
54
- const node_types_1 = require("../types/node.types");
55
- const relationship_types_1 = require("../types/relationship.types");
45
+ const enums_1 = require("../types/enums");
46
+ const graph_error_1 = require("../utils/graph-error");
56
47
  /**
57
- * ArangoDB connection implementation
48
+ * ArangoDB adapter using arangojs
58
49
  */
59
- class ArangoDBConnection {
60
- constructor(config, id) {
61
- this.config = config;
62
- this.type = graph_types_1.GraphDatabaseType.ARANGODB;
63
- this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
64
- this.queryLanguage = graph_types_1.GraphQueryLanguage.AQL;
50
+ class ArangoDBAdapter extends base_adapter_1.BaseGraphAdapter {
51
+ constructor() {
52
+ super(...arguments);
53
+ this.graphType = enums_1.GraphType.ARANGODB;
54
+ this.supportedFeatures = new Set([
55
+ enums_1.GraphFeature.TRANSACTIONS,
56
+ enums_1.GraphFeature.SCHEMA_INDEXES,
57
+ enums_1.GraphFeature.FULL_TEXT_SEARCH,
58
+ enums_1.GraphFeature.MULTI_TENANCY,
59
+ ]);
65
60
  this.db = null;
66
- this.graphName = null;
67
- this.id = id || `arangodb-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
68
- this.createdAt = new Date();
69
- }
70
- async connect() {
71
- if (this.status === graph_types_1.GraphConnectionStatus.CONNECTED) {
72
- return;
73
- }
74
- this.status = graph_types_1.GraphConnectionStatus.CONNECTING;
61
+ this.graph = null;
62
+ this.graphName = '';
63
+ this.vertexCollections = [];
64
+ this.edgeCollections = [];
65
+ }
66
+ /**
67
+ * Connect to ArangoDB
68
+ */
69
+ async connect(options) {
70
+ var _a;
75
71
  try {
76
- // Dynamic import for arangojs
72
+ // Dynamically import arangojs
77
73
  const arangojs = await Promise.resolve().then(() => __importStar(require('arangojs')));
78
74
  const { Database } = arangojs;
79
- const dbConfig = {
80
- url: this.config.url,
81
- databaseName: this.config.database,
82
- };
83
- if (this.config.token) {
84
- dbConfig.auth = { bearer: this.config.token };
85
- }
86
- else if (this.config.username) {
87
- dbConfig.auth = {
88
- username: this.config.username,
89
- password: this.config.password || '',
90
- };
91
- }
92
- if (this.config.agentOptions) {
93
- dbConfig.agentOptions = this.config.agentOptions;
94
- }
95
- if (this.config.headers) {
96
- dbConfig.headers = this.config.headers;
97
- }
98
- const db = new Database(dbConfig);
99
- // Verify connectivity
100
- const exists = await db.exists();
101
- if (!exists) {
102
- throw new Error(`Database '${this.config.database}' does not exist`);
75
+ this.db = new Database({
76
+ url: options.connectionUrl,
77
+ databaseName: options.database || '_system',
78
+ });
79
+ // If graph name is provided, get the graph
80
+ if (options.graphName) {
81
+ this.graphName = options.graphName;
82
+ this.graph = this.db.graph(options.graphName);
83
+ // Get graph info
84
+ const graphInfo = await this.graph.get();
85
+ this.vertexCollections = graphInfo.orphanCollections || [];
86
+ this.edgeCollections = ((_a = graphInfo.edgeDefinitions) === null || _a === void 0 ? void 0 : _a.map((ed) => ed.collection)) || [];
87
+ // Add vertex collections from edge definitions
88
+ for (const ed of graphInfo.edgeDefinitions || []) {
89
+ this.vertexCollections.push(...ed.from, ...ed.to);
90
+ }
91
+ this.vertexCollections = [...new Set(this.vertexCollections)];
103
92
  }
104
- this.db = db;
105
- this.status = graph_types_1.GraphConnectionStatus.CONNECTED;
106
- this.lastUsedAt = new Date();
93
+ this.client = this.db;
94
+ this.connected = true;
95
+ return {
96
+ connected: true,
97
+ type: this.graphType,
98
+ version: await this.getVersion(),
99
+ };
107
100
  }
108
101
  catch (error) {
109
- this.status = graph_types_1.GraphConnectionStatus.ERROR;
110
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, `Failed to connect to ArangoDB: ${error.message}`, error);
102
+ this.connected = false;
103
+ throw graph_error_1.GraphError.connectionError(`Failed to connect to ArangoDB: ${error.message}`);
111
104
  }
112
105
  }
113
- async disconnect() {
114
- this.db = null;
115
- this.status = graph_types_1.GraphConnectionStatus.DISCONNECTED;
116
- }
117
- isConnected() {
118
- return this.status === graph_types_1.GraphConnectionStatus.CONNECTED && this.db !== null;
119
- }
120
- getClient() {
121
- if (!this.db) {
122
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.CONNECTION_ERROR, 'ArangoDB client not initialized. Call connect() first.');
106
+ async getVersion() {
107
+ try {
108
+ const info = await this.db.version();
109
+ return info.version;
110
+ }
111
+ catch (_a) {
112
+ return 'unknown';
123
113
  }
124
- return this.db;
125
- }
126
- getSession() {
127
- return this.getClient();
128
- }
129
- getConfig() {
130
- return this.config;
131
- }
132
- setGraphName(name) {
133
- this.graphName = name;
134
114
  }
135
- getGraphName() {
136
- return this.graphName;
115
+ /**
116
+ * Disconnect from ArangoDB
117
+ */
118
+ async disconnect() {
119
+ if (this.db) {
120
+ this.db = null;
121
+ this.graph = null;
122
+ this.client = null;
123
+ this.connected = false;
124
+ }
137
125
  }
138
- }
139
- /**
140
- * ArangoDB transaction implementation
141
- */
142
- class ArangoDBTransaction {
143
- constructor(connection, transaction) {
144
- this.connection = connection;
145
- this.status = graph_types_1.GraphTransactionStatus.PENDING;
146
- this.id = `tx-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
147
- this.createdAt = new Date();
148
- this.native = transaction;
149
- this.status = graph_types_1.GraphTransactionStatus.ACTIVE;
126
+ /**
127
+ * Test ArangoDB connection
128
+ */
129
+ async testConnection(options) {
130
+ try {
131
+ await this.connect(options);
132
+ const startTime = Date.now();
133
+ const version = await this.getVersion();
134
+ const latency = Date.now() - startTime;
135
+ await this.disconnect();
136
+ return {
137
+ connected: true,
138
+ type: this.graphType,
139
+ version,
140
+ latency,
141
+ features: ['aql', 'multi-model', 'transactions'],
142
+ };
143
+ }
144
+ catch (error) {
145
+ return {
146
+ connected: false,
147
+ type: this.graphType,
148
+ error: error.message,
149
+ };
150
+ }
150
151
  }
151
- async commit() {
152
- if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
153
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Cannot commit transaction in ${this.status} state`);
152
+ // ==================== NODE OPERATIONS ====================
153
+ async createNode(options, transaction) {
154
+ this.ensureConnected();
155
+ try {
156
+ const collectionName = options.labels[0];
157
+ const collection = this.db.collection(collectionName);
158
+ const doc = Object.assign(Object.assign({}, options.properties), { _labels: options.labels });
159
+ const result = await collection.save(doc, { returnNew: true });
160
+ const node = {
161
+ id: result._key,
162
+ labels: options.labels,
163
+ properties: result.new,
164
+ elementId: result._id,
165
+ };
166
+ return { node, created: true };
154
167
  }
168
+ catch (error) {
169
+ throw graph_error_1.GraphError.queryError(`Failed to create node: ${error.message}`);
170
+ }
171
+ }
172
+ async findNodes(options, transaction) {
173
+ var _a, _b, _c, _d, _e;
174
+ this.ensureConnected();
155
175
  try {
156
- if (this.native && this.native.commit) {
157
- await this.native.commit();
176
+ let aql = 'FOR doc IN @@collection';
177
+ const bindVars = {};
178
+ const collectionName = ((_a = options.labels) === null || _a === void 0 ? void 0 : _a[0]) || this.vertexCollections[0];
179
+ bindVars['@collection'] = collectionName;
180
+ if (options.where) {
181
+ const { filterStr, filterVars } = this.buildArangoWhereClause(options.where, 'doc');
182
+ if (filterStr) {
183
+ aql += ` FILTER ${filterStr}`;
184
+ Object.assign(bindVars, filterVars);
185
+ }
186
+ }
187
+ if ((_b = options.orderBy) === null || _b === void 0 ? void 0 : _b.length) {
188
+ const sortParts = options.orderBy.map((o) => `doc.${o.property} ${o.direction || 'ASC'}`);
189
+ aql += ` SORT ${sortParts.join(', ')}`;
158
190
  }
159
- this.status = graph_types_1.GraphTransactionStatus.COMMITTED;
191
+ const skipValue = (_d = (_c = options.skip) !== null && _c !== void 0 ? _c : options.offset) !== null && _d !== void 0 ? _d : 0;
192
+ const limitValue = (_e = options.limit) !== null && _e !== void 0 ? _e : 100;
193
+ aql += ` LIMIT ${skipValue}, ${limitValue}`;
194
+ aql += ' RETURN doc';
195
+ const cursor = await this.db.query(aql, bindVars);
196
+ const docs = await cursor.all();
197
+ const nodes = docs.map((doc) => ({
198
+ id: doc._key,
199
+ labels: doc._labels || [collectionName],
200
+ properties: this.cleanArangoProps(doc),
201
+ elementId: doc._id,
202
+ }));
203
+ const countAql = `RETURN LENGTH(FOR doc IN @@collection ${options.where ? `FILTER ${this.buildArangoWhereClause(options.where, 'doc').filterStr}` : ''} RETURN 1)`;
204
+ const countCursor = await this.db.query(countAql, { '@collection': collectionName });
205
+ const [total] = await countCursor.all();
206
+ return { nodes, total };
160
207
  }
161
208
  catch (error) {
162
- this.status = graph_types_1.GraphTransactionStatus.FAILED;
163
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to commit transaction: ${error.message}`, error);
209
+ throw graph_error_1.GraphError.queryError(`Failed to find nodes: ${error.message}`);
164
210
  }
165
211
  }
166
- async rollback() {
167
- if (this.status !== graph_types_1.GraphTransactionStatus.ACTIVE) {
168
- return;
169
- }
212
+ async findNodeById(id, transaction) {
213
+ this.ensureConnected();
170
214
  try {
171
- if (this.native && this.native.abort) {
172
- await this.native.abort();
215
+ const docId = String(id).includes('/') ? id : null;
216
+ if (!docId) {
217
+ for (const collName of this.vertexCollections) {
218
+ try {
219
+ const collection = this.db.collection(collName);
220
+ const doc = await collection.document(id);
221
+ return {
222
+ id: doc._key,
223
+ labels: doc._labels || [collName],
224
+ properties: this.cleanArangoProps(doc),
225
+ elementId: doc._id,
226
+ };
227
+ }
228
+ catch (_a) {
229
+ continue;
230
+ }
231
+ }
232
+ return null;
173
233
  }
174
- this.status = graph_types_1.GraphTransactionStatus.ROLLED_BACK;
234
+ const [collName] = String(docId).split('/');
235
+ const collection = this.db.collection(collName);
236
+ const doc = await collection.document(docId);
237
+ return {
238
+ id: doc._key,
239
+ labels: doc._labels || [collName],
240
+ properties: this.cleanArangoProps(doc),
241
+ elementId: doc._id,
242
+ };
175
243
  }
176
244
  catch (error) {
177
- this.status = graph_types_1.GraphTransactionStatus.FAILED;
178
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.TRANSACTION_ERROR, `Failed to rollback transaction: ${error.message}`, error);
245
+ if (error.code === 404) {
246
+ return null;
247
+ }
248
+ throw graph_error_1.GraphError.queryError(`Failed to find node by ID: ${error.message}`);
179
249
  }
180
250
  }
181
- isActive() {
182
- return this.status === graph_types_1.GraphTransactionStatus.ACTIVE;
183
- }
184
- }
185
- /**
186
- * ArangoDB Graph Database Adapter
187
- */
188
- class ArangoDBAdapter extends base_adapter_1.BaseGraphAdapter {
189
- constructor() {
190
- super(...arguments);
191
- this.type = graph_types_1.GraphDatabaseType.ARANGODB;
192
- this.supportedLanguages = [graph_types_1.GraphQueryLanguage.AQL];
193
- this.defaultLanguage = graph_types_1.GraphQueryLanguage.AQL;
194
- // Default collection names
195
- this.defaultVertexCollection = 'vertices';
196
- this.defaultEdgeCollection = 'edges';
251
+ async updateNode(options, transaction) {
252
+ this.ensureConnected();
253
+ try {
254
+ const docId = String(options.id);
255
+ const [collName] = docId.includes('/') ? docId.split('/') : [this.vertexCollections[0]];
256
+ const collection = this.db.collection(collName);
257
+ const key = docId.includes('/') ? docId.split('/')[1] : docId;
258
+ let updateData = {};
259
+ if (options.properties) {
260
+ if ('$SET' in options.properties) {
261
+ updateData = Object.assign(Object.assign({}, updateData), options.properties.$SET);
262
+ }
263
+ if ('$UNSET' in options.properties) {
264
+ for (const prop of options.properties.$UNSET || []) {
265
+ updateData[prop] = null;
266
+ }
267
+ }
268
+ if ('$INCREMENT' in options.properties) {
269
+ for (const [prop, value] of Object.entries(options.properties.$INCREMENT || {})) {
270
+ const current = await collection.document(key);
271
+ updateData[prop] = (current[prop] || 0) + value;
272
+ }
273
+ }
274
+ if ('$APPEND' in options.properties) {
275
+ for (const [prop, value] of Object.entries(options.properties.$APPEND || {})) {
276
+ const current = await collection.document(key);
277
+ updateData[prop] = [...(current[prop] || []), value];
278
+ }
279
+ }
280
+ }
281
+ const result = await collection.update(key, updateData, { returnNew: true });
282
+ const node = {
283
+ id: result._key,
284
+ labels: result.new._labels || [collName],
285
+ properties: this.cleanArangoProps(result.new),
286
+ elementId: result._id,
287
+ };
288
+ return { node, updated: true };
289
+ }
290
+ catch (error) {
291
+ throw graph_error_1.GraphError.queryError(`Failed to update node: ${error.message}`);
292
+ }
197
293
  }
198
- // ==================== CONNECTION METHODS ====================
199
- async connect(config) {
200
- if (config.type !== graph_types_1.GraphDatabaseType.ARANGODB) {
201
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, `Invalid config type ${config.type}. Expected ${graph_types_1.GraphDatabaseType.ARANGODB}`);
202
- }
203
- const connection = new ArangoDBConnection(config);
204
- await connection.connect();
205
- return connection;
294
+ async deleteNode(options, transaction) {
295
+ this.ensureConnected();
296
+ try {
297
+ const docId = String(options.id);
298
+ const [collName] = docId.includes('/') ? docId.split('/') : [this.vertexCollections[0]];
299
+ const collection = this.db.collection(collName);
300
+ const key = docId.includes('/') ? docId.split('/')[1] : docId;
301
+ if (options.detach) {
302
+ const fullId = docId.includes('/') ? docId : `${collName}/${key}`;
303
+ for (const edgeCollName of this.edgeCollections) {
304
+ await this.db.query(`FOR e IN @@collection FILTER e._from == @id OR e._to == @id REMOVE e IN @@collection`, { '@collection': edgeCollName, id: fullId });
305
+ }
306
+ }
307
+ await collection.remove(key);
308
+ return { deleted: true, id: options.id };
309
+ }
310
+ catch (error) {
311
+ throw graph_error_1.GraphError.queryError(`Failed to delete node: ${error.message}`);
312
+ }
206
313
  }
207
- async disconnect(connection) {
208
- await connection.disconnect();
314
+ async mergeNode(options, transaction) {
315
+ this.ensureConnected();
316
+ try {
317
+ const collectionName = options.labels[0];
318
+ const collection = this.db.collection(collectionName);
319
+ const { filterStr, filterVars } = this.buildArangoWhereClause(options.matchProperties, 'doc');
320
+ const findAql = `FOR doc IN @@collection FILTER ${filterStr} LIMIT 1 RETURN doc`;
321
+ const cursor = await this.db.query(findAql, Object.assign({ '@collection': collectionName }, filterVars));
322
+ const existing = await cursor.all();
323
+ if (existing.length > 0) {
324
+ const doc = existing[0];
325
+ const updateData = options.onMatch || {};
326
+ const result = await collection.update(doc._key, updateData, { returnNew: true });
327
+ return {
328
+ node: {
329
+ id: result._key,
330
+ labels: options.labels,
331
+ properties: this.cleanArangoProps(result.new),
332
+ elementId: result._id,
333
+ },
334
+ created: false,
335
+ merged: true,
336
+ };
337
+ }
338
+ else {
339
+ const createData = Object.assign(Object.assign(Object.assign({}, options.matchProperties), (options.onCreate || {})), { _labels: options.labels });
340
+ const result = await collection.save(createData, { returnNew: true });
341
+ return {
342
+ node: {
343
+ id: result._key,
344
+ labels: options.labels,
345
+ properties: this.cleanArangoProps(result.new),
346
+ elementId: result._id,
347
+ },
348
+ created: true,
349
+ merged: true,
350
+ };
351
+ }
352
+ }
353
+ catch (error) {
354
+ throw graph_error_1.GraphError.queryError(`Failed to merge node: ${error.message}`);
355
+ }
209
356
  }
210
- async testConnection(connection) {
211
- const startTime = Date.now();
357
+ // ==================== LABEL MANAGEMENT ====================
358
+ async addLabels(options, _transaction) {
359
+ this.ensureConnected();
212
360
  try {
213
- const db = connection.getClient();
214
- const versionInfo = await db.version();
361
+ // In ArangoDB, we store labels in a _labels array property
362
+ // First, find the document
363
+ const docId = String(options.id);
364
+ const isFullId = docId.includes('/');
365
+ let doc;
366
+ if (isFullId) {
367
+ const [collectionName, key] = docId.split('/');
368
+ const collection = this.db.collection(collectionName);
369
+ doc = await collection.document(key);
370
+ }
371
+ else {
372
+ // Search across vertex collections
373
+ for (const collectionName of this.vertexCollections) {
374
+ try {
375
+ const collection = this.db.collection(collectionName);
376
+ doc = await collection.document(docId);
377
+ break;
378
+ }
379
+ catch (_a) {
380
+ continue;
381
+ }
382
+ }
383
+ }
384
+ if (!doc) {
385
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
386
+ }
387
+ const existingLabels = doc._labels || [];
388
+ const newLabels = [...new Set([...existingLabels, ...options.labels])];
389
+ const [collectionName] = doc._id.split('/');
390
+ const collection = this.db.collection(collectionName);
391
+ const result = await collection.update(doc._key, { _labels: newLabels }, { returnNew: true });
215
392
  return {
216
- connected: true,
217
- message: 'Connection successful',
218
- databaseType: graph_types_1.GraphDatabaseType.ARANGODB,
219
- queryLanguage: graph_types_1.GraphQueryLanguage.AQL,
220
- version: versionInfo.version,
221
- responseTime: Date.now() - startTime,
393
+ node: {
394
+ id: result._key,
395
+ labels: newLabels,
396
+ properties: this.cleanArangoProps(result.new),
397
+ elementId: result._id,
398
+ },
399
+ addedLabels: options.labels,
222
400
  };
223
401
  }
224
402
  catch (error) {
403
+ if (error instanceof graph_error_1.GraphError)
404
+ throw error;
405
+ throw graph_error_1.GraphError.queryError(`Failed to add labels: ${error.message}`);
406
+ }
407
+ }
408
+ async removeLabels(options, _transaction) {
409
+ this.ensureConnected();
410
+ try {
411
+ const docId = String(options.id);
412
+ const isFullId = docId.includes('/');
413
+ let doc;
414
+ if (isFullId) {
415
+ const [collectionName, key] = docId.split('/');
416
+ const collection = this.db.collection(collectionName);
417
+ doc = await collection.document(key);
418
+ }
419
+ else {
420
+ for (const collectionName of this.vertexCollections) {
421
+ try {
422
+ const collection = this.db.collection(collectionName);
423
+ doc = await collection.document(docId);
424
+ break;
425
+ }
426
+ catch (_a) {
427
+ continue;
428
+ }
429
+ }
430
+ }
431
+ if (!doc) {
432
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
433
+ }
434
+ const existingLabels = doc._labels || [];
435
+ const newLabels = existingLabels.filter(l => !options.labels.includes(l));
436
+ const [collectionName] = doc._id.split('/');
437
+ const collection = this.db.collection(collectionName);
438
+ const result = await collection.update(doc._key, { _labels: newLabels }, { returnNew: true });
225
439
  return {
226
- connected: false,
227
- message: 'Connection failed',
228
- databaseType: graph_types_1.GraphDatabaseType.ARANGODB,
229
- queryLanguage: graph_types_1.GraphQueryLanguage.AQL,
230
- responseTime: Date.now() - startTime,
231
- error: error.message,
440
+ node: {
441
+ id: result._key,
442
+ labels: newLabels,
443
+ properties: this.cleanArangoProps(result.new),
444
+ elementId: result._id,
445
+ },
446
+ removedLabels: options.labels,
232
447
  };
233
448
  }
449
+ catch (error) {
450
+ if (error instanceof graph_error_1.GraphError)
451
+ throw error;
452
+ throw graph_error_1.GraphError.queryError(`Failed to remove labels: ${error.message}`);
453
+ }
234
454
  }
235
- async getDatabaseInfo(connection) {
236
- const db = connection.getClient();
237
- const versionInfo = await db.version();
238
- return {
239
- version: versionInfo.version,
240
- edition: versionInfo.server,
241
- features: ['graphs', 'full-text-search', 'geo-spatial'],
242
- };
243
- }
244
- // ==================== TRANSACTION METHODS ====================
245
- async beginTransaction(connection, options) {
246
- const db = connection.getClient();
247
- const collections = {
248
- read: [this.defaultVertexCollection, this.defaultEdgeCollection],
249
- write: [this.defaultVertexCollection, this.defaultEdgeCollection],
250
- };
251
- const trx = await db.beginTransaction(collections);
252
- return new ArangoDBTransaction(connection, trx);
253
- }
254
- async commitTransaction(connection, transaction) {
255
- await transaction.commit();
256
- }
257
- async rollbackTransaction(connection, transaction) {
258
- await transaction.rollback();
259
- }
260
- // ==================== RAW QUERY METHODS ====================
261
- async executeRaw(connection, options, transaction) {
262
- const startTime = Date.now();
263
- const db = connection.getClient();
455
+ async setLabels(options, _transaction) {
456
+ this.ensureConnected();
264
457
  try {
265
- const cursor = await db.query(options.query, options.params || {});
266
- const data = await cursor.all();
458
+ const docId = String(options.id);
459
+ const isFullId = docId.includes('/');
460
+ let doc;
461
+ if (isFullId) {
462
+ const [collectionName, key] = docId.split('/');
463
+ const collection = this.db.collection(collectionName);
464
+ doc = await collection.document(key);
465
+ }
466
+ else {
467
+ for (const collectionName of this.vertexCollections) {
468
+ try {
469
+ const collection = this.db.collection(collectionName);
470
+ doc = await collection.document(docId);
471
+ break;
472
+ }
473
+ catch (_a) {
474
+ continue;
475
+ }
476
+ }
477
+ }
478
+ if (!doc) {
479
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${options.id} not found`);
480
+ }
481
+ const previousLabels = doc._labels || [];
482
+ const [collectionName] = doc._id.split('/');
483
+ const collection = this.db.collection(collectionName);
484
+ const result = await collection.update(doc._key, { _labels: options.labels }, { returnNew: true });
267
485
  return {
268
- success: true,
269
- executionTime: Date.now() - startTime,
270
- data: data,
271
- count: data.length,
486
+ node: {
487
+ id: result._key,
488
+ labels: options.labels,
489
+ properties: this.cleanArangoProps(result.new),
490
+ elementId: result._id,
491
+ },
492
+ previousLabels,
493
+ newLabels: options.labels,
272
494
  };
273
495
  }
274
496
  catch (error) {
275
- throw this.wrapError(error, graph_types_1.GraphErrorType.QUERY_ERROR, `Query execution failed: ${error.message}`, options.query, options.params);
497
+ if (error instanceof graph_error_1.GraphError)
498
+ throw error;
499
+ throw graph_error_1.GraphError.queryError(`Failed to set labels: ${error.message}`);
276
500
  }
277
501
  }
278
- // ==================== NODE OPERATIONS ====================
279
- async createNode(connection, options, transaction) {
280
- const startTime = Date.now();
281
- const labels = this.normalizeLabels(options.labels);
282
- const collection = this.getVertexCollection(labels[0]);
283
- // Add labels to properties for ArangoDB
284
- const doc = Object.assign(Object.assign({}, options.properties), { _labels: labels });
285
- const query = `
286
- INSERT @doc INTO @@collection
287
- RETURN NEW
288
- `;
289
- const result = await this.executeRaw(connection, {
290
- query,
291
- params: {
292
- doc,
293
- '@collection': collection,
294
- },
295
- }, transaction);
296
- return {
297
- success: true,
298
- executionTime: Date.now() - startTime,
299
- node: result.data.length > 0 ? this.parseNode(result.data[0]) : undefined,
300
- created: true,
301
- };
502
+ // ==================== RELATIONSHIP OPERATIONS ====================
503
+ async createRelationship(options, transaction) {
504
+ this.ensureConnected();
505
+ try {
506
+ const edgeCollectionName = options.type;
507
+ const edgeCollection = this.db.collection(edgeCollectionName);
508
+ const fromId = String(options.startNodeId).includes('/')
509
+ ? options.startNodeId
510
+ : await this.resolveNodeId(options.startNodeId);
511
+ const toId = String(options.endNodeId).includes('/')
512
+ ? options.endNodeId
513
+ : await this.resolveNodeId(options.endNodeId);
514
+ const edgeDoc = Object.assign({ _from: fromId, _to: toId }, options.properties);
515
+ const result = await edgeCollection.save(edgeDoc, { returnNew: true });
516
+ const relationship = {
517
+ id: result._key,
518
+ type: options.type,
519
+ startNodeId: fromId,
520
+ endNodeId: toId,
521
+ properties: this.cleanArangoProps(result.new),
522
+ elementId: result._id,
523
+ };
524
+ return { relationship, created: true };
525
+ }
526
+ catch (error) {
527
+ throw graph_error_1.GraphError.queryError(`Failed to create relationship: ${error.message}`);
528
+ }
302
529
  }
303
- async findNodes(connection, options, transaction) {
304
- const startTime = Date.now();
305
- const labels = options.labels ? this.normalizeLabels(options.labels) : [];
306
- const collection = labels.length > 0 ? this.getVertexCollection(labels[0]) : this.defaultVertexCollection;
307
- let query = `FOR doc IN @@collection`;
308
- const params = { '@collection': collection };
309
- // Build filter conditions
310
- const filters = [];
311
- if (labels.length > 0) {
312
- filters.push(`@labels ALL IN doc._labels`);
313
- params.labels = labels;
314
- }
315
- if (options.properties) {
316
- Object.entries(options.properties).forEach(([key, value], index) => {
317
- const paramName = `prop_${index}`;
318
- filters.push(`doc.${key} == @${paramName}`);
319
- params[paramName] = value;
320
- });
530
+ async findRelationships(options, transaction) {
531
+ var _a, _b, _c, _d;
532
+ this.ensureConnected();
533
+ try {
534
+ const edgeCollectionName = ((_a = options.types) === null || _a === void 0 ? void 0 : _a[0]) || (Array.isArray(options.type) ? options.type[0] : options.type) || this.edgeCollections[0];
535
+ let aql = 'FOR edge IN @@collection';
536
+ const bindVars = { '@collection': edgeCollectionName };
537
+ if (options.where) {
538
+ const { filterStr, filterVars } = this.buildArangoWhereClause(options.where, 'edge');
539
+ if (filterStr) {
540
+ aql += ` FILTER ${filterStr}`;
541
+ Object.assign(bindVars, filterVars);
542
+ }
543
+ }
544
+ const skipValue = (_c = (_b = options.skip) !== null && _b !== void 0 ? _b : options.offset) !== null && _c !== void 0 ? _c : 0;
545
+ const limitValue = (_d = options.limit) !== null && _d !== void 0 ? _d : 100;
546
+ aql += ` LIMIT ${skipValue}, ${limitValue}`;
547
+ aql += ' RETURN edge';
548
+ const cursor = await this.db.query(aql, bindVars);
549
+ const edges = await cursor.all();
550
+ const relationships = edges.map((edge) => ({
551
+ id: edge._key,
552
+ type: edgeCollectionName,
553
+ startNodeId: edge._from,
554
+ endNodeId: edge._to,
555
+ properties: this.cleanArangoProps(edge),
556
+ elementId: edge._id,
557
+ }));
558
+ return { relationships, total: relationships.length };
321
559
  }
322
- if (options.where) {
323
- const filterClause = this.buildAQLFilter(options.where, 'doc', params);
324
- filters.push(filterClause);
560
+ catch (error) {
561
+ throw graph_error_1.GraphError.queryError(`Failed to find relationships: ${error.message}`);
325
562
  }
326
- if (filters.length > 0) {
327
- query += ` FILTER ${filters.join(' AND ')}`;
563
+ }
564
+ async findRelationshipById(id, transaction) {
565
+ this.ensureConnected();
566
+ try {
567
+ const docId = String(id);
568
+ if (!docId.includes('/')) {
569
+ for (const collName of this.edgeCollections) {
570
+ try {
571
+ const collection = this.db.collection(collName);
572
+ const edge = await collection.document(id);
573
+ return {
574
+ id: edge._key,
575
+ type: collName,
576
+ startNodeId: edge._from,
577
+ endNodeId: edge._to,
578
+ properties: this.cleanArangoProps(edge),
579
+ elementId: edge._id,
580
+ };
581
+ }
582
+ catch (_a) {
583
+ continue;
584
+ }
585
+ }
586
+ return null;
587
+ }
588
+ const [collName] = docId.split('/');
589
+ const collection = this.db.collection(collName);
590
+ const edge = await collection.document(docId);
591
+ return {
592
+ id: edge._key,
593
+ type: collName,
594
+ startNodeId: edge._from,
595
+ endNodeId: edge._to,
596
+ properties: this.cleanArangoProps(edge),
597
+ elementId: edge._id,
598
+ };
328
599
  }
329
- // ORDER BY
330
- if (options.orderBy && options.orderBy.length > 0) {
331
- const sortParts = options.orderBy.map(o => `doc.${o.property} ${o.direction}`);
332
- query += ` SORT ${sortParts.join(', ')}`;
600
+ catch (error) {
601
+ if (error.code === 404) {
602
+ return null;
603
+ }
604
+ throw graph_error_1.GraphError.queryError(`Failed to find relationship by ID: ${error.message}`);
333
605
  }
334
- // LIMIT with offset
335
- if (options.skip !== undefined || options.limit !== undefined) {
336
- const skip = options.skip || 0;
337
- const limit = options.limit || 100;
338
- query += ` LIMIT ${skip}, ${limit}`;
606
+ }
607
+ async updateRelationship(options, transaction) {
608
+ this.ensureConnected();
609
+ try {
610
+ const docId = String(options.id);
611
+ const [collName] = docId.includes('/') ? docId.split('/') : [this.edgeCollections[0]];
612
+ const collection = this.db.collection(collName);
613
+ const key = docId.includes('/') ? docId.split('/')[1] : docId;
614
+ let updateData = {};
615
+ if (options.properties) {
616
+ if ('$SET' in options.properties) {
617
+ updateData = Object.assign(Object.assign({}, updateData), options.properties.$SET);
618
+ }
619
+ }
620
+ const result = await collection.update(key, updateData, { returnNew: true });
621
+ const relationship = {
622
+ id: result._key,
623
+ type: collName,
624
+ startNodeId: result.new._from,
625
+ endNodeId: result.new._to,
626
+ properties: this.cleanArangoProps(result.new),
627
+ elementId: result._id,
628
+ };
629
+ return { relationship, updated: true };
630
+ }
631
+ catch (error) {
632
+ throw graph_error_1.GraphError.queryError(`Failed to update relationship: ${error.message}`);
339
633
  }
340
- query += ` RETURN doc`;
341
- const result = await this.executeRaw(connection, { query, params }, transaction);
342
- const nodes = result.data.map(doc => this.parseNode(doc));
343
- return {
344
- success: true,
345
- executionTime: Date.now() - startTime,
346
- nodes,
347
- count: nodes.length,
348
- hasMore: options.limit !== undefined && nodes.length === options.limit,
349
- };
350
634
  }
351
- async findNodeById(connection, id, transaction) {
352
- const query = `
353
- FOR doc IN @@collection
354
- FILTER doc._key == @id OR doc._id == @id
355
- RETURN doc
356
- `;
357
- const result = await this.executeRaw(connection, {
358
- query,
359
- params: { id: String(id), '@collection': this.defaultVertexCollection },
360
- }, transaction);
361
- if (result.data.length === 0) {
362
- return null;
363
- }
364
- return this.parseNode(result.data[0]);
635
+ async deleteRelationship(options, transaction) {
636
+ this.ensureConnected();
637
+ try {
638
+ const docId = String(options.id);
639
+ const [collName] = docId.includes('/') ? docId.split('/') : [this.edgeCollections[0]];
640
+ const collection = this.db.collection(collName);
641
+ const key = docId.includes('/') ? docId.split('/')[1] : docId;
642
+ await collection.remove(key);
643
+ return { deleted: true, id: options.id };
644
+ }
645
+ catch (error) {
646
+ throw graph_error_1.GraphError.queryError(`Failed to delete relationship: ${error.message}`);
647
+ }
365
648
  }
366
- async updateNode(connection, options, transaction) {
367
- const startTime = Date.now();
368
- const params = {};
369
- let query;
370
- if (options.id !== undefined) {
371
- // Update by ID
372
- const updates = {};
373
- if (options.set) {
374
- Object.assign(updates, options.set);
375
- }
376
- if (options.addLabels) {
377
- // Will handle label merging in AQL
649
+ async mergeRelationship(options, transaction) {
650
+ this.ensureConnected();
651
+ try {
652
+ const edgeCollectionName = options.type;
653
+ const fromId = String(options.startNodeId).includes('/')
654
+ ? options.startNodeId
655
+ : await this.resolveNodeId(options.startNodeId);
656
+ const toId = String(options.endNodeId).includes('/')
657
+ ? options.endNodeId
658
+ : await this.resolveNodeId(options.endNodeId);
659
+ let filterStr = 'edge._from == @from AND edge._to == @to';
660
+ const bindVars = {
661
+ '@collection': edgeCollectionName,
662
+ from: fromId,
663
+ to: toId,
664
+ };
665
+ if (options.matchProperties) {
666
+ const { filterStr: matchFilter, filterVars } = this.buildArangoWhereClause(options.matchProperties, 'edge');
667
+ if (matchFilter) {
668
+ filterStr += ` AND ${matchFilter}`;
669
+ Object.assign(bindVars, filterVars);
670
+ }
378
671
  }
379
- query = `
380
- UPDATE { _key: @id } WITH @updates IN @@collection
381
- RETURN NEW
382
- `;
383
- params.id = String(options.id);
384
- params.updates = updates;
385
- params['@collection'] = this.defaultVertexCollection;
386
- }
387
- else {
388
- // Update by filter
389
- const filters = [];
390
- if (options.labels) {
391
- const labels = this.normalizeLabels(options.labels);
392
- filters.push(`@labels ALL IN doc._labels`);
393
- params.labels = labels;
672
+ const findAql = `FOR edge IN @@collection FILTER ${filterStr} LIMIT 1 RETURN edge`;
673
+ const cursor = await this.db.query(findAql, bindVars);
674
+ const existing = await cursor.all();
675
+ if (existing.length > 0) {
676
+ const edge = existing[0];
677
+ const collection = this.db.collection(edgeCollectionName);
678
+ const updateData = options.onMatch || {};
679
+ const result = await collection.update(edge._key, updateData, { returnNew: true });
680
+ return {
681
+ relationship: {
682
+ id: result._key,
683
+ type: options.type,
684
+ startNodeId: result.new._from,
685
+ endNodeId: result.new._to,
686
+ properties: this.cleanArangoProps(result.new),
687
+ elementId: result._id,
688
+ },
689
+ created: false,
690
+ merged: true,
691
+ };
394
692
  }
395
- if (options.where) {
396
- const filterClause = this.buildAQLFilter(options.where, 'doc', params);
397
- filters.push(filterClause);
693
+ else {
694
+ const createProps = Object.assign(Object.assign({}, options.matchProperties), (options.onCreate || {}));
695
+ const result = await this.createRelationship({
696
+ type: options.type,
697
+ startNodeId: options.startNodeId,
698
+ endNodeId: options.endNodeId,
699
+ properties: createProps,
700
+ });
701
+ return { relationship: result.relationship, created: true, merged: true };
398
702
  }
399
- query = `
400
- FOR doc IN @@collection
401
- ${filters.length > 0 ? `FILTER ${filters.join(' AND ')}` : ''}
402
- UPDATE doc WITH @updates IN @@collection
403
- RETURN NEW
703
+ }
704
+ catch (error) {
705
+ throw graph_error_1.GraphError.queryError(`Failed to merge relationship: ${error.message}`);
706
+ }
707
+ }
708
+ // ==================== TRAVERSAL OPERATIONS ====================
709
+ async traverse(options, transaction) {
710
+ var _a;
711
+ this.ensureConnected();
712
+ try {
713
+ const startId = String(options.startNodeId).includes('/')
714
+ ? options.startNodeId
715
+ : await this.resolveNodeId(options.startNodeId);
716
+ const direction = this.mapDirection(options.direction);
717
+ const maxDepth = options.maxDepth || 3;
718
+ const minDepth = 1;
719
+ const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
720
+ ? options.relationshipTypes.join(', ')
721
+ : this.edgeCollections.join(', ');
722
+ const aql = `
723
+ FOR v, e, p IN ${minDepth}..${maxDepth} ${direction} @startVertex
724
+ ${edgeCollections}
725
+ OPTIONS { bfs: true, uniqueVertices: 'global' }
726
+ RETURN { vertex: v, edge: e, path: p }
404
727
  `;
405
- params.updates = options.set || {};
406
- params['@collection'] = this.defaultVertexCollection;
728
+ const cursor = await this.db.query(aql, { startVertex: startId });
729
+ const results = await cursor.all();
730
+ const nodesMap = new Map();
731
+ const relationshipsMap = new Map();
732
+ for (const result of results) {
733
+ if (result.vertex) {
734
+ const v = result.vertex;
735
+ nodesMap.set(v._id, {
736
+ id: v._key,
737
+ labels: v._labels || [v._id.split('/')[0]],
738
+ properties: this.cleanArangoProps(v),
739
+ elementId: v._id,
740
+ });
741
+ }
742
+ if (result.edge) {
743
+ const e = result.edge;
744
+ relationshipsMap.set(e._id, {
745
+ id: e._key,
746
+ type: e._id.split('/')[0],
747
+ startNodeId: e._from,
748
+ endNodeId: e._to,
749
+ properties: this.cleanArangoProps(e),
750
+ elementId: e._id,
751
+ });
752
+ }
753
+ }
754
+ return {
755
+ nodes: Array.from(nodesMap.values()),
756
+ relationships: Array.from(relationshipsMap.values()),
757
+ paths: [],
758
+ };
759
+ }
760
+ catch (error) {
761
+ throw graph_error_1.GraphError.queryError(`Failed to traverse: ${error.message}`);
407
762
  }
408
- const result = await this.executeRaw(connection, { query, params }, transaction);
409
- return {
410
- success: true,
411
- executionTime: Date.now() - startTime,
412
- node: result.data.length > 0 ? this.parseNode(result.data[0]) : undefined,
413
- updated: result.data.length > 0,
414
- matchedCount: result.data.length,
415
- modifiedCount: result.data.length,
416
- };
417
763
  }
418
- async deleteNode(connection, options, transaction) {
419
- const startTime = Date.now();
420
- const params = {};
421
- let query;
422
- if (options.id !== undefined) {
423
- if (options.detach) {
424
- // Delete edges first
425
- query = `
426
- LET doc = DOCUMENT(@@collection, @id)
427
- LET edges = (
428
- FOR e IN @@edges
429
- FILTER e._from == doc._id OR e._to == doc._id
430
- REMOVE e IN @@edges
431
- RETURN 1
432
- )
433
- REMOVE doc IN @@collection
434
- RETURN { deleted: 1, edgesDeleted: LENGTH(edges) }
764
+ async shortestPath(options, transaction) {
765
+ var _a;
766
+ this.ensureConnected();
767
+ try {
768
+ const startId = String(options.startNodeId).includes('/')
769
+ ? options.startNodeId
770
+ : await this.resolveNodeId(options.startNodeId);
771
+ const endId = String(options.endNodeId).includes('/')
772
+ ? options.endNodeId
773
+ : await this.resolveNodeId(options.endNodeId);
774
+ const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
775
+ ? options.relationshipTypes.join(', ')
776
+ : this.edgeCollections.join(', ');
777
+ let aql;
778
+ if (options.weightProperty) {
779
+ aql = `
780
+ FOR v, e IN OUTBOUND SHORTEST_PATH @start TO @end
781
+ ${edgeCollections}
782
+ OPTIONS { weightAttribute: @weight }
783
+ RETURN { vertex: v, edge: e }
435
784
  `;
436
785
  }
437
786
  else {
438
- query = `
439
- REMOVE { _key: @id } IN @@collection
440
- RETURN { deleted: 1 }
787
+ aql = `
788
+ FOR v, e IN OUTBOUND SHORTEST_PATH @start TO @end
789
+ ${edgeCollections}
790
+ RETURN { vertex: v, edge: e }
441
791
  `;
442
792
  }
443
- params.id = String(options.id);
444
- params['@collection'] = this.defaultVertexCollection;
445
- params['@edges'] = this.defaultEdgeCollection;
446
- }
447
- else {
448
- const filters = [];
449
- if (options.labels) {
450
- const labels = this.normalizeLabels(options.labels);
451
- filters.push(`@labels ALL IN doc._labels`);
452
- params.labels = labels;
793
+ const cursor = await this.db.query(aql, {
794
+ start: startId,
795
+ end: endId,
796
+ weight: options.weightProperty,
797
+ });
798
+ const results = await cursor.all();
799
+ if (results.length === 0) {
800
+ return { path: null, length: -1, found: false };
453
801
  }
454
- if (options.where) {
455
- const filterClause = this.buildAQLFilter(options.where, 'doc', params);
456
- filters.push(filterClause);
802
+ const nodes = [];
803
+ const relationships = [];
804
+ for (const result of results) {
805
+ if (result.vertex) {
806
+ nodes.push({
807
+ id: result.vertex._key,
808
+ labels: result.vertex._labels || [result.vertex._id.split('/')[0]],
809
+ properties: this.cleanArangoProps(result.vertex),
810
+ elementId: result.vertex._id,
811
+ });
812
+ }
813
+ if (result.edge) {
814
+ relationships.push({
815
+ id: result.edge._key,
816
+ type: result.edge._id.split('/')[0],
817
+ startNodeId: result.edge._from,
818
+ endNodeId: result.edge._to,
819
+ properties: this.cleanArangoProps(result.edge),
820
+ elementId: result.edge._id,
821
+ });
822
+ }
457
823
  }
458
- query = `
459
- FOR doc IN @@collection
460
- ${filters.length > 0 ? `FILTER ${filters.join(' AND ')}` : ''}
461
- ${options.detach ? `
462
- LET edges = (
463
- FOR e IN @@edges
464
- FILTER e._from == doc._id OR e._to == doc._id
465
- REMOVE e IN @@edges
466
- RETURN 1
467
- )
468
- ` : ''}
469
- REMOVE doc IN @@collection
470
- RETURN 1
471
- `;
472
- params['@collection'] = this.defaultVertexCollection;
473
- params['@edges'] = this.defaultEdgeCollection;
824
+ return {
825
+ path: {
826
+ nodes,
827
+ relationships,
828
+ length: relationships.length,
829
+ },
830
+ length: relationships.length,
831
+ found: true,
832
+ };
833
+ }
834
+ catch (error) {
835
+ throw graph_error_1.GraphError.queryError(`Failed to find shortest path: ${error.message}`);
474
836
  }
475
- const result = await this.executeRaw(connection, { query, params }, transaction);
476
- return {
477
- success: true,
478
- executionTime: Date.now() - startTime,
479
- deletedCount: result.data.length,
480
- deletedRelationshipsCount: 0, // Could be calculated from detach query
481
- };
482
- }
483
- async mergeNode(connection, options, transaction) {
484
- var _a, _b;
485
- const startTime = Date.now();
486
- const labels = this.normalizeLabels(options.labels);
487
- const collection = this.getVertexCollection(labels[0]);
488
- // Build match filter
489
- const matchFilters = [];
490
- const params = { '@collection': collection };
491
- matchFilters.push(`@labels ALL IN doc._labels`);
492
- params.labels = labels;
493
- Object.entries(options.matchProperties).forEach(([key, value], index) => {
494
- const paramName = `match_${index}`;
495
- matchFilters.push(`doc.${key} == @${paramName}`);
496
- params[paramName] = value;
497
- });
498
- const onCreate = Object.assign(Object.assign(Object.assign({}, options.matchProperties), options.onCreate), { _labels: labels });
499
- const onMatch = options.onMatch || {};
500
- const query = `
501
- UPSERT { ${Object.keys(options.matchProperties).map(k => `${k}: @match_${Object.keys(options.matchProperties).indexOf(k)}`).join(', ')}, _labels: @labels }
502
- INSERT @onCreate
503
- UPDATE @onMatch
504
- IN @@collection
505
- RETURN { doc: NEW, created: OLD ? false : true }
506
- `;
507
- params.onCreate = onCreate;
508
- params.onMatch = onMatch;
509
- const result = await this.executeRaw(connection, { query, params }, transaction);
510
- return {
511
- success: true,
512
- executionTime: Date.now() - startTime,
513
- node: result.data.length > 0 ? this.parseNode(result.data[0].doc) : undefined,
514
- created: ((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.created) || false,
515
- matched: !((_b = result.data[0]) === null || _b === void 0 ? void 0 : _b.created),
516
- };
517
- }
518
- // ==================== RELATIONSHIP OPERATIONS ====================
519
- async createRelationship(connection, options, transaction) {
520
- const startTime = Date.now();
521
- const fromId = this.resolveNodeId(options.fromNode);
522
- const toId = this.resolveNodeId(options.toNode);
523
- const edge = Object.assign({ _from: fromId, _to: toId, _type: options.type }, options.properties);
524
- const query = `
525
- INSERT @edge INTO @@collection
526
- RETURN NEW
527
- `;
528
- const result = await this.executeRaw(connection, {
529
- query,
530
- params: {
531
- edge,
532
- '@collection': this.defaultEdgeCollection,
533
- },
534
- }, transaction);
535
- return {
536
- success: true,
537
- executionTime: Date.now() - startTime,
538
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0]) : undefined,
539
- created: true,
540
- };
541
837
  }
542
- async findRelationships(connection, options, transaction) {
543
- const startTime = Date.now();
544
- let query = `FOR edge IN @@collection`;
545
- const params = { '@collection': this.defaultEdgeCollection };
546
- const filters = [];
547
- if (options.type) {
548
- const types = Array.isArray(options.type) ? options.type : [options.type];
549
- filters.push(`edge._type IN @types`);
550
- params.types = types;
551
- }
552
- if (options.fromNode && options.fromNode.id) {
553
- filters.push(`edge._from == @fromId`);
554
- params.fromId = this.resolveNodeId(options.fromNode);
555
- }
556
- if (options.toNode && options.toNode.id) {
557
- filters.push(`edge._to == @toId`);
558
- params.toId = this.resolveNodeId(options.toNode);
559
- }
560
- if (options.properties) {
561
- Object.entries(options.properties).forEach(([key, value], index) => {
562
- const paramName = `prop_${index}`;
563
- filters.push(`edge.${key} == @${paramName}`);
564
- params[paramName] = value;
838
+ async allPaths(options, transaction) {
839
+ var _a;
840
+ this.ensureConnected();
841
+ try {
842
+ const startId = String(options.startNodeId).includes('/')
843
+ ? options.startNodeId
844
+ : await this.resolveNodeId(options.startNodeId);
845
+ const endId = String(options.endNodeId).includes('/')
846
+ ? options.endNodeId
847
+ : await this.resolveNodeId(options.endNodeId);
848
+ const maxDepth = options.maxDepth || 5;
849
+ const maxPaths = options.maxPaths || options.limit || 10;
850
+ const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
851
+ ? options.relationshipTypes.join(', ')
852
+ : this.edgeCollections.join(', ');
853
+ const aql = `
854
+ FOR p IN 1..@maxDepth OUTBOUND @start
855
+ ${edgeCollections}
856
+ PRUNE p.vertices[-1]._id == @end
857
+ OPTIONS { bfs: false }
858
+ FILTER p.vertices[-1]._id == @end
859
+ LIMIT @maxPaths
860
+ RETURN p
861
+ `;
862
+ const cursor = await this.db.query(aql, {
863
+ start: startId,
864
+ end: endId,
865
+ maxDepth,
866
+ maxPaths,
565
867
  });
868
+ const pathResults = await cursor.all();
869
+ const paths = pathResults.map((p) => {
870
+ const nodes = p.vertices.map((v) => ({
871
+ id: v._key,
872
+ labels: v._labels || [v._id.split('/')[0]],
873
+ properties: this.cleanArangoProps(v),
874
+ elementId: v._id,
875
+ }));
876
+ const relationships = p.edges.map((e) => ({
877
+ id: e._key,
878
+ type: e._id.split('/')[0],
879
+ startNodeId: e._from,
880
+ endNodeId: e._to,
881
+ properties: this.cleanArangoProps(e),
882
+ elementId: e._id,
883
+ }));
884
+ return { nodes, relationships, length: relationships.length };
885
+ });
886
+ return { paths, total: paths.length };
566
887
  }
567
- if (filters.length > 0) {
568
- query += ` FILTER ${filters.join(' AND ')}`;
569
- }
570
- // ORDER BY
571
- if (options.orderBy && options.orderBy.length > 0) {
572
- const sortParts = options.orderBy.map(o => `edge.${o.property} ${o.direction}`);
573
- query += ` SORT ${sortParts.join(', ')}`;
574
- }
575
- // LIMIT
576
- if (options.skip !== undefined || options.limit !== undefined) {
577
- const skip = options.skip || 0;
578
- const limit = options.limit || 100;
579
- query += ` LIMIT ${skip}, ${limit}`;
888
+ catch (error) {
889
+ throw graph_error_1.GraphError.queryError(`Failed to find all paths: ${error.message}`);
580
890
  }
581
- query += ` RETURN edge`;
582
- const result = await this.executeRaw(connection, { query, params }, transaction);
583
- const relationships = result.data.map(doc => this.parseRelationship(doc));
584
- return {
585
- success: true,
586
- executionTime: Date.now() - startTime,
587
- relationships,
588
- count: relationships.length,
589
- hasMore: options.limit !== undefined && relationships.length === options.limit,
590
- };
591
- }
592
- async findRelationshipById(connection, id, transaction) {
593
- const query = `
594
- FOR edge IN @@collection
595
- FILTER edge._key == @id OR edge._id == @id
596
- RETURN edge
597
- `;
598
- const result = await this.executeRaw(connection, {
599
- query,
600
- params: { id: String(id), '@collection': this.defaultEdgeCollection },
601
- }, transaction);
602
- if (result.data.length === 0) {
603
- return null;
604
- }
605
- return this.parseRelationship(result.data[0]);
606
- }
607
- async updateRelationship(connection, options, transaction) {
608
- const startTime = Date.now();
609
- const query = `
610
- UPDATE { _key: @id } WITH @updates IN @@collection
611
- RETURN NEW
612
- `;
613
- const result = await this.executeRaw(connection, {
614
- query,
615
- params: {
616
- id: String(options.id),
617
- updates: options.set || {},
618
- '@collection': this.defaultEdgeCollection,
619
- },
620
- }, transaction);
621
- return {
622
- success: true,
623
- executionTime: Date.now() - startTime,
624
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0]) : undefined,
625
- updated: result.data.length > 0,
626
- matchedCount: result.data.length,
627
- modifiedCount: result.data.length,
628
- };
629
891
  }
630
- async deleteRelationship(connection, options, transaction) {
631
- const startTime = Date.now();
632
- const params = { '@collection': this.defaultEdgeCollection };
633
- let query;
634
- if (options.id !== undefined) {
635
- query = `
636
- REMOVE { _key: @id } IN @@collection
637
- RETURN 1
892
+ async getNeighborhood(options, transaction) {
893
+ var _a;
894
+ this.ensureConnected();
895
+ try {
896
+ const nodeId = String(options.nodeId).includes('/')
897
+ ? options.nodeId
898
+ : await this.resolveNodeId(options.nodeId);
899
+ const direction = this.mapDirection(options.direction);
900
+ const depth = options.depth || 1;
901
+ const edgeCollections = ((_a = options.relationshipTypes) === null || _a === void 0 ? void 0 : _a.length)
902
+ ? options.relationshipTypes.join(', ')
903
+ : this.edgeCollections.join(', ');
904
+ let aql = `
905
+ FOR v, e IN 1..@depth ${direction} @start
906
+ ${edgeCollections}
907
+ OPTIONS { uniqueVertices: 'global' }
638
908
  `;
639
- params.id = String(options.id);
640
- }
641
- else {
642
- const filters = [];
643
- if (options.type) {
644
- const types = Array.isArray(options.type) ? options.type : [options.type];
645
- filters.push(`edge._type IN @types`);
646
- params.types = types;
909
+ if (options.limit) {
910
+ aql += ` LIMIT @limit`;
647
911
  }
648
- query = `
649
- FOR edge IN @@collection
650
- ${filters.length > 0 ? `FILTER ${filters.join(' AND ')}` : ''}
651
- REMOVE edge IN @@collection
652
- RETURN 1
653
- `;
912
+ aql += ` RETURN { vertex: v, edge: e }`;
913
+ const cursor = await this.db.query(aql, {
914
+ start: nodeId,
915
+ depth,
916
+ limit: options.limit,
917
+ });
918
+ const results = await cursor.all();
919
+ const nodesMap = new Map();
920
+ const relationshipsMap = new Map();
921
+ for (const result of results) {
922
+ if (result.vertex) {
923
+ nodesMap.set(result.vertex._id, {
924
+ id: result.vertex._key,
925
+ labels: result.vertex._labels || [result.vertex._id.split('/')[0]],
926
+ properties: this.cleanArangoProps(result.vertex),
927
+ elementId: result.vertex._id,
928
+ });
929
+ }
930
+ if (result.edge) {
931
+ relationshipsMap.set(result.edge._id, {
932
+ id: result.edge._key,
933
+ type: result.edge._id.split('/')[0],
934
+ startNodeId: result.edge._from,
935
+ endNodeId: result.edge._to,
936
+ properties: this.cleanArangoProps(result.edge),
937
+ elementId: result.edge._id,
938
+ });
939
+ }
940
+ }
941
+ return {
942
+ nodes: Array.from(nodesMap.values()),
943
+ relationships: Array.from(relationshipsMap.values()),
944
+ depth,
945
+ };
946
+ }
947
+ catch (error) {
948
+ throw graph_error_1.GraphError.queryError(`Failed to get neighborhood: ${error.message}`);
654
949
  }
655
- const result = await this.executeRaw(connection, { query, params }, transaction);
656
- return {
657
- success: true,
658
- executionTime: Date.now() - startTime,
659
- deletedCount: result.data.length,
660
- };
661
950
  }
662
- async mergeRelationship(connection, options, transaction) {
663
- var _a, _b;
664
- const startTime = Date.now();
665
- const fromId = this.resolveNodeId(options.fromNode);
666
- const toId = this.resolveNodeId(options.toNode);
667
- const matchDoc = Object.assign({ _from: fromId, _to: toId, _type: options.type }, options.matchProperties);
668
- const insertDoc = Object.assign(Object.assign({}, matchDoc), options.onCreate);
669
- const updateDoc = options.onMatch || {};
670
- const query = `
671
- UPSERT @matchDoc
672
- INSERT @insertDoc
673
- UPDATE @updateDoc
674
- IN @@collection
675
- RETURN { doc: NEW, created: OLD ? false : true }
676
- `;
677
- const result = await this.executeRaw(connection, {
678
- query,
679
- params: {
680
- matchDoc,
681
- insertDoc,
682
- updateDoc,
683
- '@collection': this.defaultEdgeCollection,
684
- },
685
- }, transaction);
686
- return {
687
- success: true,
688
- executionTime: Date.now() - startTime,
689
- relationship: result.data.length > 0 ? this.parseRelationship(result.data[0].doc) : undefined,
690
- created: ((_a = result.data[0]) === null || _a === void 0 ? void 0 : _a.created) || false,
691
- matched: !((_b = result.data[0]) === null || _b === void 0 ? void 0 : _b.created),
692
- };
951
+ async findConnectedComponents(options, transaction) {
952
+ throw graph_error_1.GraphError.unsupportedOperationError('Connected components', 'ArangoDB (requires Pregel or SmartGraphs)');
693
953
  }
694
- // ==================== PATH & TRAVERSAL OPERATIONS ====================
695
- async traverse(connection, options, transaction) {
696
- const startTime = Date.now();
697
- const startId = this.resolveNodeId(options.startNode);
698
- const minDepth = options.minDepth || 1;
699
- const maxDepth = options.maxDepth || 10;
700
- const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'INBOUND' :
701
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'OUTBOUND' : 'ANY';
702
- let edgeCollections = this.defaultEdgeCollection;
703
- if (options.relationships) {
704
- const patterns = Array.isArray(options.relationships) ? options.relationships : [options.relationships];
705
- const types = patterns.filter(p => p.type).map(p => p.type);
706
- if (types.length > 0) {
707
- // In ArangoDB, you'd filter by edge type within the traversal
954
+ // ==================== AGGREGATION ====================
955
+ async countNodes(labels, where, transaction) {
956
+ this.ensureConnected();
957
+ try {
958
+ const collectionName = (labels === null || labels === void 0 ? void 0 : labels[0]) || this.vertexCollections[0];
959
+ let aql = 'RETURN LENGTH(FOR doc IN @@collection';
960
+ const bindVars = { '@collection': collectionName };
961
+ if (where) {
962
+ const { filterStr, filterVars } = this.buildArangoWhereClause(where, 'doc');
963
+ if (filterStr) {
964
+ aql += ` FILTER ${filterStr}`;
965
+ Object.assign(bindVars, filterVars);
966
+ }
708
967
  }
968
+ aql += ' RETURN 1)';
969
+ const cursor = await this.db.query(aql, bindVars);
970
+ const [count] = await cursor.all();
971
+ return { count };
972
+ }
973
+ catch (error) {
974
+ throw graph_error_1.GraphError.queryError(`Failed to count nodes: ${error.message}`);
709
975
  }
710
- const query = `
711
- FOR vertex, edge, path IN ${minDepth}..${maxDepth} ${direction} @startId
712
- GRAPH @graphName
713
- ${options.limit ? `LIMIT ${options.limit}` : ''}
714
- RETURN { vertex, edge, path }
715
- `;
716
- const arangoConn = connection;
717
- const graphName = arangoConn.getGraphName() || 'defaultGraph';
718
- const result = await this.executeRaw(connection, {
719
- query,
720
- params: { startId, graphName },
721
- }, transaction);
722
- const nodesMap = new Map();
723
- const relsMap = new Map();
724
- const paths = [];
725
- result.data.forEach(row => {
726
- if (row.vertex) {
727
- const node = this.parseNode(row.vertex);
728
- nodesMap.set(String(node.id), node);
976
+ }
977
+ async countRelationships(types, where, transaction) {
978
+ this.ensureConnected();
979
+ try {
980
+ const collectionName = (types === null || types === void 0 ? void 0 : types[0]) || this.edgeCollections[0];
981
+ let aql = 'RETURN LENGTH(FOR edge IN @@collection';
982
+ const bindVars = { '@collection': collectionName };
983
+ if (where) {
984
+ const { filterStr, filterVars } = this.buildArangoWhereClause(where, 'edge');
985
+ if (filterStr) {
986
+ aql += ` FILTER ${filterStr}`;
987
+ Object.assign(bindVars, filterVars);
988
+ }
729
989
  }
730
- if (row.edge) {
731
- const rel = this.parseRelationship(row.edge);
732
- relsMap.set(String(rel.id), rel);
990
+ aql += ' RETURN 1)';
991
+ const cursor = await this.db.query(aql, bindVars);
992
+ const [count] = await cursor.all();
993
+ return { count };
994
+ }
995
+ catch (error) {
996
+ throw graph_error_1.GraphError.queryError(`Failed to count relationships: ${error.message}`);
997
+ }
998
+ }
999
+ async getStatistics(transaction) {
1000
+ this.ensureConnected();
1001
+ try {
1002
+ let nodeCount = 0;
1003
+ let relationshipCount = 0;
1004
+ const nodesByLabel = {};
1005
+ const relationshipsByType = {};
1006
+ for (const collName of this.vertexCollections) {
1007
+ const cursor = await this.db.query('RETURN LENGTH(FOR doc IN @@collection RETURN 1)', { '@collection': collName });
1008
+ const [count] = await cursor.all();
1009
+ nodesByLabel[collName] = count;
1010
+ nodeCount += count;
733
1011
  }
734
- if (row.path && options.returnPaths) {
735
- paths.push(this.parsePath(row.path));
1012
+ for (const collName of this.edgeCollections) {
1013
+ const cursor = await this.db.query('RETURN LENGTH(FOR edge IN @@collection RETURN 1)', { '@collection': collName });
1014
+ const [count] = await cursor.all();
1015
+ relationshipsByType[collName] = count;
1016
+ relationshipCount += count;
736
1017
  }
737
- });
738
- return {
739
- success: true,
740
- executionTime: Date.now() - startTime,
741
- paths: options.returnPaths ? paths : undefined,
742
- nodes: options.returnNodes ? Array.from(nodesMap.values()) : undefined,
743
- relationships: Array.from(relsMap.values()),
744
- count: result.data.length,
745
- };
1018
+ return {
1019
+ nodeCount,
1020
+ relationshipCount,
1021
+ nodesByLabel,
1022
+ relationshipsByType,
1023
+ };
1024
+ }
1025
+ catch (error) {
1026
+ throw graph_error_1.GraphError.queryError(`Failed to get statistics: ${error.message}`);
1027
+ }
746
1028
  }
747
- async shortestPath(connection, options, transaction) {
748
- const startTime = Date.now();
749
- const startId = this.resolveNodeId(options.startNode);
750
- const endId = this.resolveNodeId(options.endNode);
751
- const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'INBOUND' :
752
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'OUTBOUND' : 'ANY';
753
- let query;
754
- if (options.weightProperty) {
755
- // Weighted shortest path using SHORTEST_PATH with weight
756
- query = `
757
- FOR path IN ${direction} SHORTEST_PATH @startId TO @endId
758
- GRAPH @graphName
759
- OPTIONS { weightAttribute: @weightProp }
760
- RETURN path
1029
+ // ==================== SEARCH ====================
1030
+ async fullTextSearch(options, transaction) {
1031
+ this.ensureConnected();
1032
+ try {
1033
+ const aql = `
1034
+ FOR doc IN ${options.indexName}
1035
+ SEARCH ANALYZER(doc.content IN TOKENS(@query, 'text_en'), 'text_en')
1036
+ SORT BM25(doc) DESC
1037
+ LIMIT @limit
1038
+ RETURN doc
761
1039
  `;
1040
+ const cursor = await this.db.query(aql, {
1041
+ query: options.query,
1042
+ limit: options.limit || 10,
1043
+ });
1044
+ const results = await cursor.all();
1045
+ return {
1046
+ nodes: results.map((doc) => ({
1047
+ id: doc._key,
1048
+ labels: doc._labels || [doc._id.split('/')[0]],
1049
+ properties: this.cleanArangoProps(doc),
1050
+ elementId: doc._id,
1051
+ })),
1052
+ };
762
1053
  }
763
- else {
764
- query = `
765
- FOR path IN ${direction} SHORTEST_PATH @startId TO @endId
766
- GRAPH @graphName
767
- RETURN path
768
- `;
1054
+ catch (error) {
1055
+ throw graph_error_1.GraphError.queryError(`Failed to perform full-text search: ${error.message}`);
769
1056
  }
770
- const arangoConn = connection;
771
- const graphName = arangoConn.getGraphName() || 'defaultGraph';
772
- const result = await this.executeRaw(connection, {
773
- query,
774
- params: {
775
- startId,
776
- endId,
777
- graphName,
778
- weightProp: options.weightProperty || 'weight',
779
- },
780
- }, transaction);
781
- if (result.data.length === 0 || !result.data[0]) {
1057
+ }
1058
+ async vectorSearch(options, transaction) {
1059
+ throw graph_error_1.GraphError.unsupportedOperationError('Vector search', 'ArangoDB');
1060
+ }
1061
+ // ==================== RAW QUERY ====================
1062
+ async query(options, transaction) {
1063
+ this.ensureConnected();
1064
+ try {
1065
+ const cursor = await this.db.query(options.query, options.params || {});
1066
+ const records = await cursor.all();
782
1067
  return {
783
- success: true,
784
- executionTime: Date.now() - startTime,
785
- found: false,
1068
+ records: records,
1069
+ summary: {
1070
+ database: this.db.name,
1071
+ },
786
1072
  };
787
1073
  }
788
- const path = this.parsePath(result.data[0]);
789
- return {
790
- success: true,
791
- executionTime: Date.now() - startTime,
792
- path,
793
- found: true,
794
- length: path.length,
795
- };
796
- }
797
- async allPaths(connection, options, transaction) {
798
- const startTime = Date.now();
799
- const startId = this.resolveNodeId(options.startNode);
800
- const endId = this.resolveNodeId(options.endNode);
801
- const minDepth = options.minDepth || 1;
802
- const maxDepth = options.maxDepth || 10;
803
- const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'INBOUND' :
804
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'OUTBOUND' : 'ANY';
805
- const query = `
806
- FOR vertex, edge, path IN ${minDepth}..${maxDepth} ${direction} @startId
807
- GRAPH @graphName
808
- FILTER vertex._id == @endId
809
- ${options.limit ? `LIMIT ${options.limit}` : ''}
810
- RETURN path
811
- `;
812
- const arangoConn = connection;
813
- const graphName = arangoConn.getGraphName() || 'defaultGraph';
814
- const result = await this.executeRaw(connection, {
815
- query,
816
- params: { startId, endId, graphName },
817
- }, transaction);
818
- const paths = result.data.map(p => this.parsePath(p));
819
- return {
820
- success: true,
821
- executionTime: Date.now() - startTime,
822
- paths,
823
- count: paths.length,
824
- };
1074
+ catch (error) {
1075
+ throw graph_error_1.GraphError.queryError(`Failed to execute query: ${error.message}`);
1076
+ }
825
1077
  }
826
- async matchPattern(connection, options, transaction) {
827
- const startTime = Date.now();
828
- const { pattern } = options;
829
- // Build AQL query from pattern
830
- const forClauses = [];
831
- const filters = [];
832
- const params = {};
833
- pattern.nodes.forEach((node, index) => {
834
- forClauses.push(`FOR ${node.variable} IN @@vertices_${index}`);
835
- params[`@vertices_${index}`] = this.defaultVertexCollection;
836
- if (node.labels) {
837
- const labels = Array.isArray(node.labels) ? node.labels : [node.labels];
838
- filters.push(`@labels_${index} ALL IN ${node.variable}._labels`);
839
- params[`labels_${index}`] = labels;
1078
+ // ==================== SCHEMA ====================
1079
+ async createNodeIndex(options) {
1080
+ var _a, _b;
1081
+ this.ensureConnected();
1082
+ try {
1083
+ const collection = this.db.collection(options.label);
1084
+ const indexOptions = {
1085
+ type: this.mapIndexType(options.type),
1086
+ fields: options.properties,
1087
+ name: options.name,
1088
+ };
1089
+ if (((_a = options.options) === null || _a === void 0 ? void 0 : _a.sparse) !== undefined) {
1090
+ indexOptions.sparse = options.options.sparse;
840
1091
  }
841
- if (node.properties) {
842
- Object.entries(node.properties).forEach(([key, value], propIndex) => {
843
- const paramName = `node_${index}_prop_${propIndex}`;
844
- filters.push(`${node.variable}.${key} == @${paramName}`);
845
- params[paramName] = value;
846
- });
1092
+ if (((_b = options.options) === null || _b === void 0 ? void 0 : _b.unique) !== undefined) {
1093
+ indexOptions.unique = options.options.unique;
847
1094
  }
848
- });
849
- // Handle relationships
850
- pattern.relationships.forEach((rel, index) => {
851
- forClauses.push(`FOR ${rel.variable || `_edge_${index}`} IN @@edges_${index}`);
852
- params[`@edges_${index}`] = this.defaultEdgeCollection;
853
- const edgeVar = rel.variable || `_edge_${index}`;
854
- filters.push(`${edgeVar}._from == ${rel.startNode}._id`);
855
- filters.push(`${edgeVar}._to == ${rel.endNode}._id`);
856
- if (rel.type) {
857
- const types = Array.isArray(rel.type) ? rel.type : [rel.type];
858
- filters.push(`${edgeVar}._type IN @relTypes_${index}`);
859
- params[`relTypes_${index}`] = types;
860
- }
861
- });
862
- const returnVars = options.return || pattern.nodes.map(n => n.variable);
863
- let query = forClauses.join('\n');
864
- if (filters.length > 0) {
865
- query += `\nFILTER ${filters.join(' AND ')}`;
1095
+ const result = await collection.ensureIndex(indexOptions);
1096
+ return {
1097
+ created: result.isNewlyCreated,
1098
+ name: result.name,
1099
+ };
866
1100
  }
867
- if (options.limit) {
868
- query += `\nLIMIT ${options.skip || 0}, ${options.limit}`;
1101
+ catch (error) {
1102
+ throw graph_error_1.GraphError.queryError(`Failed to create index: ${error.message}`);
869
1103
  }
870
- query += `\nRETURN { ${returnVars.map(v => `${v}: ${v}`).join(', ')} }`;
871
- const result = await this.executeRaw(connection, { query, params }, transaction);
872
- return {
873
- success: true,
874
- executionTime: Date.now() - startTime,
875
- matches: result.data,
876
- count: result.data.length,
877
- hasMore: options.limit !== undefined && result.data.length === options.limit,
878
- };
879
1104
  }
880
- async extractSubgraph(connection, options, transaction) {
881
- const startTime = Date.now();
882
- const startNodes = Array.isArray(options.startNodes) ? options.startNodes : [options.startNodes];
883
- const startIds = startNodes.map(n => this.resolveNodeId(n));
884
- const maxDepth = options.maxDepth || 3;
885
- const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'INBOUND' :
886
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'OUTBOUND' : 'ANY';
887
- const query = `
888
- LET startNodes = @startIds
889
- LET subgraphNodes = (
890
- FOR startId IN startNodes
891
- FOR vertex IN 0..@maxDepth ${direction} startId
892
- GRAPH @graphName
893
- RETURN DISTINCT vertex
894
- )
895
- LET subgraphEdges = (
896
- FOR startId IN startNodes
897
- FOR vertex, edge IN 1..@maxDepth ${direction} startId
898
- GRAPH @graphName
899
- RETURN DISTINCT edge
900
- )
901
- RETURN { nodes: subgraphNodes, edges: subgraphEdges }
902
- `;
903
- const arangoConn = connection;
904
- const graphName = arangoConn.getGraphName() || 'defaultGraph';
905
- const result = await this.executeRaw(connection, {
906
- query,
907
- params: { startIds, maxDepth, graphName },
908
- }, transaction);
909
- const nodes = [];
910
- const relationships = [];
911
- if (result.data.length > 0) {
912
- const row = result.data[0];
913
- if (row.nodes) {
914
- row.nodes.forEach((n) => nodes.push(this.parseNode(n)));
915
- }
916
- if (row.edges) {
917
- row.edges.filter((e) => e).forEach((e) => relationships.push(this.parseRelationship(e)));
918
- }
1105
+ async createNodeConstraint(options) {
1106
+ this.ensureConnected();
1107
+ try {
1108
+ const collection = this.db.collection(options.label);
1109
+ const fields = options.properties || (options.property ? [options.property] : []);
1110
+ const result = await collection.ensureIndex({
1111
+ type: 'persistent',
1112
+ fields,
1113
+ name: options.name,
1114
+ unique: true,
1115
+ });
1116
+ return {
1117
+ created: result.isNewlyCreated,
1118
+ name: result.name,
1119
+ };
1120
+ }
1121
+ catch (error) {
1122
+ throw graph_error_1.GraphError.queryError(`Failed to create constraint: ${error.message}`);
919
1123
  }
920
- return {
921
- success: true,
922
- executionTime: Date.now() - startTime,
923
- subgraph: {
924
- nodes,
925
- relationships,
926
- nodeCount: nodes.length,
927
- relationshipCount: relationships.length,
928
- },
929
- };
930
1124
  }
931
- async getNeighborhood(connection, options, transaction) {
932
- const startTime = Date.now();
933
- const nodeId = this.resolveNodeId(options.node);
934
- const depth = options.depth || 1;
935
- const direction = options.direction === relationship_types_1.RelationshipDirection.INCOMING ? 'INBOUND' :
936
- options.direction === relationship_types_1.RelationshipDirection.OUTGOING ? 'OUTBOUND' : 'ANY';
937
- const query = `
938
- FOR vertex, edge IN 0..@depth ${direction} @nodeId
939
- GRAPH @graphName
940
- RETURN { vertex, edge }
941
- `;
942
- const arangoConn = connection;
943
- const graphName = arangoConn.getGraphName() || 'defaultGraph';
944
- const result = await this.executeRaw(connection, {
945
- query,
946
- params: { nodeId, depth, graphName },
947
- }, transaction);
948
- const nodesMap = new Map();
949
- const relsMap = new Map();
950
- result.data.forEach(row => {
951
- if (row.vertex) {
952
- const node = this.parseNode(row.vertex);
953
- nodesMap.set(String(node.id), node);
954
- }
955
- if (row.edge) {
956
- const rel = this.parseRelationship(row.edge);
957
- relsMap.set(String(rel.id), rel);
958
- }
1125
+ async createRelationshipIndex(options) {
1126
+ return this.createNodeIndex({
1127
+ label: options.type,
1128
+ properties: options.properties,
1129
+ name: options.name,
1130
+ type: options.type,
959
1131
  });
960
- return {
961
- success: true,
962
- executionTime: Date.now() - startTime,
963
- nodes: Array.from(nodesMap.values()),
964
- relationships: Array.from(relsMap.values()),
965
- levels: new Map(),
966
- };
967
1132
  }
968
- async findConnectedComponents(connection, options, transaction) {
969
- const startTime = Date.now();
970
- // ArangoDB doesn't have built-in connected components
971
- // This would require Pregel or custom implementation
972
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Connected components analysis requires ArangoDB Pregel or custom implementation');
973
- }
974
- // ==================== AGGREGATION OPERATIONS ====================
975
- async countNodes(connection, labels, where, transaction) {
976
- const startTime = Date.now();
977
- let query = `RETURN COUNT(FOR doc IN @@collection`;
978
- const params = { '@collection': this.defaultVertexCollection };
979
- const filters = [];
980
- if (labels) {
981
- const labelArr = Array.isArray(labels) ? labels : [labels];
982
- filters.push(`@labels ALL IN doc._labels`);
983
- params.labels = labelArr;
984
- }
985
- if (where) {
986
- Object.entries(where).forEach(([key, value], index) => {
987
- const paramName = `where_${index}`;
988
- filters.push(`doc.${key} == @${paramName}`);
989
- params[paramName] = value;
990
- });
1133
+ async listIndexes() {
1134
+ this.ensureConnected();
1135
+ try {
1136
+ const indexes = [];
1137
+ for (const collName of [...this.vertexCollections, ...this.edgeCollections]) {
1138
+ const collection = this.db.collection(collName);
1139
+ const collIndexes = await collection.indexes();
1140
+ for (const idx of collIndexes) {
1141
+ indexes.push({
1142
+ name: idx.name,
1143
+ labelOrType: collName,
1144
+ properties: idx.fields || [],
1145
+ type: idx.type,
1146
+ unique: idx.unique || false,
1147
+ });
1148
+ }
1149
+ }
1150
+ return { indexes };
991
1151
  }
992
- if (filters.length > 0) {
993
- query += ` FILTER ${filters.join(' AND ')}`;
1152
+ catch (error) {
1153
+ throw graph_error_1.GraphError.queryError(`Failed to list indexes: ${error.message}`);
994
1154
  }
995
- query += ` RETURN 1)`;
996
- const result = await this.executeRaw(connection, { query, params }, transaction);
997
- return {
998
- success: true,
999
- executionTime: Date.now() - startTime,
1000
- count: result.data[0] || 0,
1001
- };
1002
1155
  }
1003
- async countRelationships(connection, type, where, transaction) {
1004
- const startTime = Date.now();
1005
- let query = `RETURN COUNT(FOR edge IN @@collection`;
1006
- const params = { '@collection': this.defaultEdgeCollection };
1007
- const filters = [];
1008
- if (type) {
1009
- const typeArr = Array.isArray(type) ? type : [type];
1010
- filters.push(`edge._type IN @types`);
1011
- params.types = typeArr;
1012
- }
1013
- if (where) {
1014
- Object.entries(where).forEach(([key, value], index) => {
1015
- const paramName = `where_${index}`;
1016
- filters.push(`edge.${key} == @${paramName}`);
1017
- params[paramName] = value;
1018
- });
1156
+ async listConstraints() {
1157
+ this.ensureConnected();
1158
+ try {
1159
+ const constraints = [];
1160
+ for (const collName of this.vertexCollections) {
1161
+ const collection = this.db.collection(collName);
1162
+ const indexes = await collection.indexes();
1163
+ for (const idx of indexes) {
1164
+ if (idx.unique) {
1165
+ constraints.push({
1166
+ name: idx.name,
1167
+ label: collName,
1168
+ property: (idx.fields || [])[0] || '',
1169
+ type: 'UNIQUE',
1170
+ });
1171
+ }
1172
+ }
1173
+ }
1174
+ return { constraints };
1019
1175
  }
1020
- if (filters.length > 0) {
1021
- query += ` FILTER ${filters.join(' AND ')}`;
1176
+ catch (error) {
1177
+ throw graph_error_1.GraphError.queryError(`Failed to list constraints: ${error.message}`);
1022
1178
  }
1023
- query += ` RETURN 1)`;
1024
- const result = await this.executeRaw(connection, { query, params }, transaction);
1025
- return {
1026
- success: true,
1027
- executionTime: Date.now() - startTime,
1028
- count: result.data[0] || 0,
1029
- };
1030
- }
1031
- async getStatistics(connection, transaction) {
1032
- const startTime = Date.now();
1033
- const nodeCountResult = await this.countNodes(connection, undefined, undefined, transaction);
1034
- const relCountResult = await this.countRelationships(connection, undefined, undefined, transaction);
1035
- return {
1036
- success: true,
1037
- executionTime: Date.now() - startTime,
1038
- nodeCount: nodeCountResult.count,
1039
- relationshipCount: relCountResult.count,
1040
- labelCounts: {},
1041
- relationshipTypeCounts: {},
1042
- };
1043
1179
  }
1044
- // ==================== SEARCH OPERATIONS ====================
1045
- async fullTextSearch(connection, options, transaction) {
1046
- const startTime = Date.now();
1047
- // ArangoDB uses ArangoSearch for full-text search
1048
- const query = `
1049
- FOR doc IN @@view
1050
- SEARCH ANALYZER(doc.${options.index} IN TOKENS(@searchQuery, "text_en"), "text_en")
1051
- ${options.labels ? `FILTER @labels ALL IN doc._labels` : ''}
1052
- ${options.limit ? `LIMIT ${options.limit}` : ''}
1053
- ${options.score ? `RETURN MERGE(doc, { score: BM25(doc) })` : `RETURN doc`}
1054
- `;
1055
- const result = await this.executeRaw(connection, {
1056
- query,
1057
- params: {
1058
- '@view': `${this.defaultVertexCollection}_search`,
1059
- searchQuery: options.query,
1060
- labels: options.labels || [],
1061
- },
1062
- }, transaction);
1063
- const nodes = result.data.map(doc => {
1064
- const node = this.parseNode(doc);
1065
- if (options.score && doc.score !== undefined) {
1066
- return Object.assign(Object.assign({}, node), { score: doc.score });
1180
+ async dropIndex(name) {
1181
+ this.ensureConnected();
1182
+ try {
1183
+ for (const collName of [...this.vertexCollections, ...this.edgeCollections]) {
1184
+ const collection = this.db.collection(collName);
1185
+ try {
1186
+ await collection.dropIndex(name);
1187
+ return { dropped: true };
1188
+ }
1189
+ catch (_a) {
1190
+ continue;
1191
+ }
1067
1192
  }
1068
- return node;
1069
- });
1070
- return {
1071
- success: true,
1072
- executionTime: Date.now() - startTime,
1073
- nodes,
1074
- count: nodes.length,
1075
- };
1193
+ return { dropped: false };
1194
+ }
1195
+ catch (error) {
1196
+ throw graph_error_1.GraphError.queryError(`Failed to drop index: ${error.message}`);
1197
+ }
1076
1198
  }
1077
- async vectorSearch(connection, options, transaction) {
1078
- // ArangoDB requires ArangoSearch with custom analyzers for vector similarity
1079
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Vector search requires ArangoDB Enterprise with custom vector analyzer configuration');
1199
+ async dropConstraint(name) {
1200
+ const result = await this.dropIndex(name);
1201
+ return { dropped: result.dropped };
1202
+ }
1203
+ // ==================== SCHEMA INTROSPECTION ====================
1204
+ async listLabels() {
1205
+ this.ensureConnected();
1206
+ const labels = [];
1207
+ // In ArangoDB, vertex collections act as "labels"
1208
+ for (const collectionName of this.vertexCollections) {
1209
+ try {
1210
+ const collection = this.db.collection(collectionName);
1211
+ // Get count
1212
+ const countResult = await collection.count();
1213
+ const count = countResult.count || 0;
1214
+ // Get properties from a sample of documents
1215
+ const cursor = await this.db.query(`
1216
+ FOR doc IN \`${collectionName}\`
1217
+ LIMIT 100
1218
+ RETURN ATTRIBUTES(doc, true)
1219
+ `);
1220
+ const attributeArrays = await cursor.all();
1221
+ // Flatten and dedupe property names
1222
+ const propertyNames = new Set();
1223
+ for (const attrs of attributeArrays) {
1224
+ for (const attr of attrs) {
1225
+ if (attr !== '_key' && attr !== '_id' && attr !== '_rev') {
1226
+ propertyNames.add(attr);
1227
+ }
1228
+ }
1229
+ }
1230
+ const properties = Array.from(propertyNames).map(name => ({
1231
+ name,
1232
+ type: 'unknown',
1233
+ }));
1234
+ labels.push({
1235
+ name: collectionName,
1236
+ count,
1237
+ properties,
1238
+ });
1239
+ }
1240
+ catch (error) {
1241
+ // Skip collections that don't exist or have errors
1242
+ continue;
1243
+ }
1244
+ }
1245
+ return { labels };
1246
+ }
1247
+ async listRelationshipTypes() {
1248
+ this.ensureConnected();
1249
+ const types = [];
1250
+ // In ArangoDB, edge collections act as "relationship types"
1251
+ for (const collectionName of this.edgeCollections) {
1252
+ try {
1253
+ const collection = this.db.collection(collectionName);
1254
+ // Get count
1255
+ const countResult = await collection.count();
1256
+ const count = countResult.count || 0;
1257
+ // Get source and target collection information
1258
+ const endpointsCursor = await this.db.query(`
1259
+ FOR edge IN \`${collectionName}\`
1260
+ LIMIT 100
1261
+ RETURN {
1262
+ fromCollection: PARSE_IDENTIFIER(edge._from).collection,
1263
+ toCollection: PARSE_IDENTIFIER(edge._to).collection
1264
+ }
1265
+ `);
1266
+ const endpoints = await endpointsCursor.all();
1267
+ const fromLabelsSet = new Set();
1268
+ const toLabelsSet = new Set();
1269
+ for (const ep of endpoints) {
1270
+ if (ep.fromCollection)
1271
+ fromLabelsSet.add(ep.fromCollection);
1272
+ if (ep.toCollection)
1273
+ toLabelsSet.add(ep.toCollection);
1274
+ }
1275
+ // Get properties from a sample of edges
1276
+ const propsCursor = await this.db.query(`
1277
+ FOR edge IN \`${collectionName}\`
1278
+ LIMIT 100
1279
+ RETURN ATTRIBUTES(edge, true)
1280
+ `);
1281
+ const attributeArrays = await propsCursor.all();
1282
+ const propertyNames = new Set();
1283
+ for (const attrs of attributeArrays) {
1284
+ for (const attr of attrs) {
1285
+ if (!['_key', '_id', '_rev', '_from', '_to'].includes(attr)) {
1286
+ propertyNames.add(attr);
1287
+ }
1288
+ }
1289
+ }
1290
+ const properties = Array.from(propertyNames).map(name => ({
1291
+ name,
1292
+ type: 'unknown',
1293
+ }));
1294
+ types.push({
1295
+ type: collectionName,
1296
+ count,
1297
+ fromLabels: Array.from(fromLabelsSet),
1298
+ toLabels: Array.from(toLabelsSet),
1299
+ properties: properties.length > 0 ? properties : undefined,
1300
+ });
1301
+ }
1302
+ catch (error) {
1303
+ // Skip collections that don't exist or have errors
1304
+ continue;
1305
+ }
1306
+ }
1307
+ return { types };
1080
1308
  }
1081
- // ==================== SCHEMA OPERATIONS ====================
1082
- async createNodeConstraint(connection, constraint, transaction) {
1083
- const startTime = Date.now();
1084
- const db = connection.getClient();
1085
- const collection = this.getVertexCollection(constraint.label);
1086
- const coll = db.collection(collection);
1087
- // ArangoDB uses unique indexes for constraints
1088
- if (constraint.type === node_types_1.NodeConstraintType.UNIQUE) {
1089
- await coll.ensureIndex({
1090
- type: 'persistent',
1091
- fields: constraint.properties,
1092
- unique: true,
1093
- name: constraint.name,
1309
+ // ==================== TRANSACTIONS ====================
1310
+ async beginTransaction() {
1311
+ this.ensureConnected();
1312
+ try {
1313
+ const trx = await this.db.beginTransaction({
1314
+ write: [...this.vertexCollections, ...this.edgeCollections],
1315
+ read: [...this.vertexCollections, ...this.edgeCollections],
1094
1316
  });
1317
+ return {
1318
+ id: trx.id,
1319
+ status: enums_1.GraphTransactionStatus.ACTIVE,
1320
+ startTime: new Date(),
1321
+ nativeTransaction: trx,
1322
+ };
1323
+ }
1324
+ catch (error) {
1325
+ throw graph_error_1.GraphError.transactionError(`Failed to begin transaction: ${error.message}`);
1095
1326
  }
1096
- return {
1097
- success: true,
1098
- executionTime: Date.now() - startTime,
1099
- name: constraint.name,
1100
- created: true,
1101
- };
1102
- }
1103
- async createRelationshipConstraint(connection, constraint, transaction) {
1104
- const startTime = Date.now();
1105
- const db = connection.getClient();
1106
- const coll = db.collection(this.defaultEdgeCollection);
1107
- await coll.ensureIndex({
1108
- type: 'persistent',
1109
- fields: constraint.properties,
1110
- unique: true,
1111
- name: constraint.name,
1112
- });
1113
- return {
1114
- success: true,
1115
- executionTime: Date.now() - startTime,
1116
- name: constraint.name,
1117
- created: true,
1118
- };
1119
1327
  }
1120
- async dropConstraint(connection, name, transaction) {
1121
- const startTime = Date.now();
1122
- const db = connection.getClient();
1123
- // ArangoDB drops constraints via dropIndex
1124
- const coll = db.collection(this.defaultVertexCollection);
1125
- await coll.dropIndex(name);
1126
- return {
1127
- success: true,
1128
- executionTime: Date.now() - startTime,
1129
- name,
1130
- dropped: true,
1131
- };
1328
+ async commitTransaction(transaction) {
1329
+ try {
1330
+ await transaction.nativeTransaction.commit();
1331
+ transaction.status = enums_1.GraphTransactionStatus.COMMITTED;
1332
+ }
1333
+ catch (error) {
1334
+ throw graph_error_1.GraphError.transactionError(`Failed to commit transaction: ${error.message}`);
1335
+ }
1132
1336
  }
1133
- async listConstraints(connection, transaction) {
1134
- const startTime = Date.now();
1135
- const db = connection.getClient();
1136
- const coll = db.collection(this.defaultVertexCollection);
1137
- const indexes = await coll.indexes();
1138
- const constraints = indexes
1139
- .filter((idx) => idx.unique)
1140
- .map((idx) => ({
1141
- name: idx.name,
1142
- type: 'UNIQUE',
1143
- entityType: 'NODE',
1144
- labelsOrTypes: [],
1145
- properties: idx.fields,
1146
- }));
1147
- return {
1148
- success: true,
1149
- executionTime: Date.now() - startTime,
1150
- constraints,
1151
- };
1337
+ async rollbackTransaction(transaction) {
1338
+ try {
1339
+ await transaction.nativeTransaction.abort();
1340
+ transaction.status = enums_1.GraphTransactionStatus.ROLLED_BACK;
1341
+ }
1342
+ catch (error) {
1343
+ throw graph_error_1.GraphError.transactionError(`Failed to rollback transaction: ${error.message}`);
1344
+ }
1152
1345
  }
1153
- async createNodeIndex(connection, index, transaction) {
1154
- const startTime = Date.now();
1155
- const db = connection.getClient();
1156
- const collection = this.getVertexCollection(index.label);
1157
- const coll = db.collection(collection);
1158
- let indexType = 'persistent';
1159
- const options = {
1160
- fields: index.properties,
1161
- name: index.name,
1162
- };
1163
- switch (index.type) {
1164
- case node_types_1.NodeIndexType.FULLTEXT:
1165
- indexType = 'fulltext';
1166
- break;
1167
- case node_types_1.NodeIndexType.POINT:
1168
- indexType = 'geo';
1169
- break;
1346
+ // ==================== HELPERS ====================
1347
+ mapDirection(direction) {
1348
+ switch (direction) {
1349
+ case enums_1.TraversalDirection.OUTGOING:
1350
+ case 'OUTGOING':
1351
+ return 'OUTBOUND';
1352
+ case enums_1.TraversalDirection.INCOMING:
1353
+ case 'INCOMING':
1354
+ return 'INBOUND';
1355
+ case enums_1.TraversalDirection.BOTH:
1356
+ case 'BOTH':
1170
1357
  default:
1171
- indexType = 'persistent';
1358
+ return 'ANY';
1172
1359
  }
1173
- options.type = indexType;
1174
- await coll.ensureIndex(options);
1175
- return {
1176
- success: true,
1177
- executionTime: Date.now() - startTime,
1178
- name: index.name,
1179
- created: true,
1180
- };
1181
- }
1182
- async createRelationshipIndex(connection, index, transaction) {
1183
- const startTime = Date.now();
1184
- const db = connection.getClient();
1185
- const coll = db.collection(this.defaultEdgeCollection);
1186
- await coll.ensureIndex({
1187
- type: 'persistent',
1188
- fields: index.properties,
1189
- name: index.name,
1190
- });
1191
- return {
1192
- success: true,
1193
- executionTime: Date.now() - startTime,
1194
- name: index.name,
1195
- created: true,
1196
- };
1197
1360
  }
1198
- async dropIndex(connection, name, transaction) {
1199
- const startTime = Date.now();
1200
- const db = connection.getClient();
1201
- const coll = db.collection(this.defaultVertexCollection);
1202
- await coll.dropIndex(name);
1203
- return {
1204
- success: true,
1205
- executionTime: Date.now() - startTime,
1206
- name,
1207
- dropped: true,
1208
- };
1209
- }
1210
- async listIndexes(connection, transaction) {
1211
- const startTime = Date.now();
1212
- const db = connection.getClient();
1213
- const coll = db.collection(this.defaultVertexCollection);
1214
- const indexes = await coll.indexes();
1215
- const indexList = indexes.map((idx) => ({
1216
- name: idx.name,
1217
- type: idx.type,
1218
- entityType: 'NODE',
1219
- labelsOrTypes: [],
1220
- properties: idx.fields,
1221
- state: 'ONLINE',
1222
- uniqueness: idx.unique ? 'UNIQUE' : 'NONUNIQUE',
1223
- }));
1224
- return {
1225
- success: true,
1226
- executionTime: Date.now() - startTime,
1227
- indexes: indexList,
1228
- };
1229
- }
1230
- // ==================== UTILITY METHODS ====================
1231
- escapeIdentifier(identifier) {
1232
- return identifier.replace(/[^a-zA-Z0-9_]/g, '_');
1233
- }
1234
- escapeValue(value) {
1235
- if (value === null)
1236
- return 'null';
1237
- if (typeof value === 'string')
1238
- return `"${value.replace(/"/g, '\\"')}"`;
1239
- if (typeof value === 'number')
1240
- return String(value);
1241
- if (typeof value === 'boolean')
1242
- return value ? 'true' : 'false';
1243
- if (value instanceof Date)
1244
- return `"${value.toISOString()}"`;
1245
- if (Array.isArray(value))
1246
- return `[${value.map(v => this.escapeValue(v)).join(', ')}]`;
1247
- return JSON.stringify(value);
1248
- }
1249
- buildWhereClause(where, variableName = 'doc') {
1250
- const params = {};
1251
- const parts = [];
1252
- Object.entries(where).forEach(([key, value], index) => {
1253
- const paramName = `where_${index}`;
1254
- parts.push(`${variableName}.${key} == @${paramName}`);
1255
- params[paramName] = value;
1256
- });
1257
- return {
1258
- clause: parts.join(' AND '),
1259
- params,
1260
- };
1261
- }
1262
- // ==================== PROTECTED PARSER METHODS ====================
1263
- parseNode(nativeNode) {
1264
- if (!nativeNode) {
1265
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.NODE_ERROR, 'Cannot parse null node');
1361
+ mapIndexType(type) {
1362
+ switch (type) {
1363
+ case 'fulltext':
1364
+ return 'fulltext';
1365
+ case 'geo':
1366
+ case 'point':
1367
+ return 'geo';
1368
+ case 'ttl':
1369
+ return 'ttl';
1370
+ default:
1371
+ return 'persistent';
1266
1372
  }
1267
- const { _key, _id, _rev, _labels } = nativeNode, properties = __rest(nativeNode, ["_key", "_id", "_rev", "_labels"]);
1268
- return {
1269
- id: _key || _id,
1270
- labels: _labels || [],
1271
- properties: properties,
1272
- elementId: _id,
1273
- };
1274
1373
  }
1275
- parseRelationship(nativeRelationship) {
1276
- if (!nativeRelationship) {
1277
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.RELATIONSHIP_ERROR, 'Cannot parse null relationship');
1278
- }
1279
- const { _key, _id, _rev, _from, _to, _type } = nativeRelationship, properties = __rest(nativeRelationship, ["_key", "_id", "_rev", "_from", "_to", "_type"]);
1280
- return {
1281
- id: _key || _id,
1282
- type: _type || '',
1283
- startNodeId: _from,
1284
- endNodeId: _to,
1285
- properties: properties,
1286
- elementId: _id,
1287
- };
1374
+ buildWhereClause(where) {
1375
+ return this.buildArangoWhereClause(where, 'doc');
1288
1376
  }
1289
- parsePath(nativePath) {
1290
- if (!nativePath) {
1291
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.PATH_ERROR, 'Cannot parse null path');
1292
- }
1293
- const nodes = [];
1294
- const relationships = [];
1295
- if (nativePath.vertices) {
1296
- nativePath.vertices.forEach((v) => nodes.push(this.parseNode(v)));
1297
- }
1298
- if (nativePath.edges) {
1299
- nativePath.edges.forEach((e) => {
1300
- if (e)
1301
- relationships.push(this.parseRelationship(e));
1302
- });
1377
+ parseError(error) {
1378
+ if (error instanceof graph_error_1.GraphError) {
1379
+ return error;
1380
+ }
1381
+ return graph_error_1.GraphError.queryError(String(error));
1382
+ }
1383
+ buildArangoWhereClause(where, varName) {
1384
+ const conditions = [];
1385
+ const filterVars = {};
1386
+ let varCounter = 0;
1387
+ for (const [key, value] of Object.entries(where)) {
1388
+ if (key === '$AND') {
1389
+ const { filterStr, filterVars: andVars } = this.buildArangoWhereClause(value, varName);
1390
+ if (filterStr) {
1391
+ conditions.push(`(${filterStr})`);
1392
+ Object.assign(filterVars, andVars);
1393
+ }
1394
+ }
1395
+ else if (key === '$OR') {
1396
+ const { filterStr, filterVars: orVars } = this.buildArangoWhereClause(value, varName);
1397
+ if (filterStr) {
1398
+ conditions.push(`(${filterStr.replace(/ AND /g, ' OR ')})`);
1399
+ Object.assign(filterVars, orVars);
1400
+ }
1401
+ }
1402
+ else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
1403
+ for (const [op, opValue] of Object.entries(value)) {
1404
+ const varKey = `v${varCounter++}`;
1405
+ filterVars[varKey] = opValue;
1406
+ switch (op) {
1407
+ case '$GT':
1408
+ conditions.push(`${varName}.${key} > @${varKey}`);
1409
+ break;
1410
+ case '$GTE':
1411
+ conditions.push(`${varName}.${key} >= @${varKey}`);
1412
+ break;
1413
+ case '$LT':
1414
+ conditions.push(`${varName}.${key} < @${varKey}`);
1415
+ break;
1416
+ case '$LTE':
1417
+ conditions.push(`${varName}.${key} <= @${varKey}`);
1418
+ break;
1419
+ case '$NE':
1420
+ conditions.push(`${varName}.${key} != @${varKey}`);
1421
+ break;
1422
+ case '$IN':
1423
+ conditions.push(`${varName}.${key} IN @${varKey}`);
1424
+ break;
1425
+ case '$NOT_IN':
1426
+ conditions.push(`${varName}.${key} NOT IN @${varKey}`);
1427
+ break;
1428
+ case '$CONTAINS':
1429
+ conditions.push(`CONTAINS(${varName}.${key}, @${varKey})`);
1430
+ break;
1431
+ case '$STARTS_WITH':
1432
+ conditions.push(`STARTS_WITH(${varName}.${key}, @${varKey})`);
1433
+ break;
1434
+ case '$ENDS_WITH':
1435
+ conditions.push(`LIKE(${varName}.${key}, CONCAT('%', @${varKey}))`);
1436
+ break;
1437
+ case '$EXISTS':
1438
+ if (opValue) {
1439
+ conditions.push(`${varName}.${key} != null`);
1440
+ }
1441
+ else {
1442
+ conditions.push(`${varName}.${key} == null`);
1443
+ }
1444
+ break;
1445
+ }
1446
+ }
1447
+ }
1448
+ else {
1449
+ const varKey = `v${varCounter++}`;
1450
+ filterVars[varKey] = value;
1451
+ conditions.push(`${varName}.${key} == @${varKey}`);
1452
+ }
1303
1453
  }
1304
1454
  return {
1305
- nodes,
1306
- relationships,
1307
- length: relationships.length,
1308
- start: nodes[0],
1309
- end: nodes[nodes.length - 1],
1455
+ filterStr: conditions.join(' AND '),
1456
+ filterVars,
1310
1457
  };
1311
1458
  }
1312
- // ==================== PRIVATE HELPER METHODS ====================
1313
- normalizeLabels(labels) {
1314
- return Array.isArray(labels) ? labels : [labels];
1315
- }
1316
- getVertexCollection(label) {
1317
- // In ArangoDB, you might use different collections per label
1318
- // For simplicity, using default collection
1319
- return this.defaultVertexCollection;
1320
- }
1321
- resolveNodeId(ref) {
1322
- if (typeof ref === 'string')
1323
- return ref;
1324
- if (ref.id) {
1325
- const id = String(ref.id);
1326
- // If it's not already a full document ID, prefix it
1327
- if (!id.includes('/')) {
1328
- return `${this.defaultVertexCollection}/${id}`;
1459
+ cleanArangoProps(doc) {
1460
+ const result = {};
1461
+ for (const [key, value] of Object.entries(doc)) {
1462
+ if (!key.startsWith('_')) {
1463
+ result[key] = value;
1329
1464
  }
1330
- return id;
1331
1465
  }
1332
- throw new graph_types_1.GraphError(graph_types_1.GraphErrorType.VALIDATION_ERROR, 'Node reference must have an id');
1466
+ return result;
1333
1467
  }
1334
- buildAQLFilter(where, alias, params, prefix = '') {
1335
- const paramName = `${prefix}filter_${Object.keys(params).length}`;
1336
- let operator;
1337
- switch (where.operator) {
1338
- case node_types_1.NodeComparisonOperator.EQUALS:
1339
- operator = '==';
1340
- break;
1341
- case node_types_1.NodeComparisonOperator.NOT_EQUALS:
1342
- operator = '!=';
1343
- break;
1344
- case node_types_1.NodeComparisonOperator.GREATER_THAN:
1345
- operator = '>';
1346
- break;
1347
- case node_types_1.NodeComparisonOperator.GREATER_THAN_OR_EQUAL:
1348
- operator = '>=';
1349
- break;
1350
- case node_types_1.NodeComparisonOperator.LESS_THAN:
1351
- operator = '<';
1352
- break;
1353
- case node_types_1.NodeComparisonOperator.LESS_THAN_OR_EQUAL:
1354
- operator = '<=';
1355
- break;
1356
- case node_types_1.NodeComparisonOperator.IN:
1357
- operator = 'IN';
1358
- break;
1359
- case node_types_1.NodeComparisonOperator.NOT_IN:
1360
- operator = 'NOT IN';
1361
- break;
1362
- case node_types_1.NodeComparisonOperator.CONTAINS:
1363
- params[paramName] = where.value;
1364
- return `CONTAINS(${alias}.${where.property}, @${paramName})`;
1365
- case node_types_1.NodeComparisonOperator.STARTS_WITH:
1366
- params[paramName] = where.value;
1367
- return `STARTS_WITH(${alias}.${where.property}, @${paramName})`;
1368
- case node_types_1.NodeComparisonOperator.IS_NULL:
1369
- return `${alias}.${where.property} == null`;
1370
- case node_types_1.NodeComparisonOperator.IS_NOT_NULL:
1371
- return `${alias}.${where.property} != null`;
1372
- case node_types_1.NodeComparisonOperator.REGEX:
1373
- params[paramName] = where.value;
1374
- return `REGEX_TEST(${alias}.${where.property}, @${paramName})`;
1375
- default:
1376
- operator = '==';
1377
- }
1378
- params[paramName] = where.value;
1379
- let condition = `${alias}.${where.property} ${operator} @${paramName}`;
1380
- if (where.and && where.and.length > 0) {
1381
- const andClauses = where.and.map((w, i) => this.buildAQLFilter(w, alias, params, `${prefix}and${i}_`));
1382
- condition = `(${condition} AND ${andClauses.join(' AND ')})`;
1383
- }
1384
- if (where.or && where.or.length > 0) {
1385
- const orClauses = where.or.map((w, i) => this.buildAQLFilter(w, alias, params, `${prefix}or${i}_`));
1386
- condition = `(${condition} OR ${orClauses.join(' OR ')})`;
1468
+ async resolveNodeId(id) {
1469
+ for (const collName of this.vertexCollections) {
1470
+ try {
1471
+ const collection = this.db.collection(collName);
1472
+ await collection.document(id);
1473
+ return `${collName}/${id}`;
1474
+ }
1475
+ catch (_a) {
1476
+ continue;
1477
+ }
1387
1478
  }
1388
- return condition;
1479
+ throw graph_error_1.GraphError.notFoundError(`Node with ID ${id} not found`);
1389
1480
  }
1390
1481
  }
1391
1482
  exports.ArangoDBAdapter = ArangoDBAdapter;
1392
- exports.default = ArangoDBAdapter;
1393
1483
  //# sourceMappingURL=arangodb.adapter.js.map