@ductape/sdk 0.0.4-v9 → 0.0.4-v91

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 (998) hide show
  1. package/dist/agents/agent-context.d.ts +98 -0
  2. package/dist/agents/agent-context.js +588 -0
  3. package/dist/agents/agent-context.js.map +1 -0
  4. package/dist/agents/agent-executor.d.ts +180 -0
  5. package/dist/agents/agent-executor.js +715 -0
  6. package/dist/agents/agent-executor.js.map +1 -0
  7. package/dist/agents/agents.service.d.ts +310 -0
  8. package/dist/agents/agents.service.js +1249 -0
  9. package/dist/agents/agents.service.js.map +1 -0
  10. package/dist/agents/index.d.ts +55 -0
  11. package/dist/agents/index.js +110 -0
  12. package/dist/agents/index.js.map +1 -0
  13. package/dist/agents/memory-manager.d.ts +182 -0
  14. package/dist/agents/memory-manager.js +383 -0
  15. package/dist/agents/memory-manager.js.map +1 -0
  16. package/dist/agents/tool-registry.d.ts +141 -0
  17. package/dist/agents/tool-registry.js +355 -0
  18. package/dist/agents/tool-registry.js.map +1 -0
  19. package/dist/agents/types/agents.types.d.ts +1227 -0
  20. package/dist/agents/types/agents.types.js +12 -0
  21. package/dist/agents/types/agents.types.js.map +1 -0
  22. package/dist/agents/types/index.d.ts +6 -0
  23. package/dist/agents/types/index.js +23 -0
  24. package/dist/agents/types/index.js.map +1 -0
  25. package/dist/agents/vector-store-adapter.d.ts +108 -0
  26. package/dist/agents/vector-store-adapter.js +213 -0
  27. package/dist/agents/vector-store-adapter.js.map +1 -0
  28. package/dist/api/services/appApi.service.d.ts +51 -5
  29. package/dist/api/services/appApi.service.js +101 -3
  30. package/dist/api/services/appApi.service.js.map +1 -1
  31. package/dist/api/services/pricingApi.service.d.ts +10 -0
  32. package/dist/api/services/pricingApi.service.js +34 -0
  33. package/dist/api/services/pricingApi.service.js.map +1 -0
  34. package/dist/api/services/processorApi.service.d.ts +322 -0
  35. package/dist/api/services/processorApi.service.js +252 -0
  36. package/dist/api/services/processorApi.service.js.map +1 -1
  37. package/dist/api/services/productsApi.service.d.ts +105 -0
  38. package/dist/api/services/productsApi.service.js +139 -3
  39. package/dist/api/services/productsApi.service.js.map +1 -1
  40. package/dist/api/services/resilienceApi.service.d.ts +106 -0
  41. package/dist/api/services/resilienceApi.service.js +224 -0
  42. package/dist/api/services/resilienceApi.service.js.map +1 -0
  43. package/dist/api/services/secretsApi.service.d.ts +50 -0
  44. package/dist/api/services/secretsApi.service.js +124 -0
  45. package/dist/api/services/secretsApi.service.js.map +1 -0
  46. package/dist/api/services/workflowApi.service.d.ts +199 -0
  47. package/dist/api/services/workflowApi.service.js +183 -0
  48. package/dist/api/services/workflowApi.service.js.map +1 -0
  49. package/dist/api/services/workspaceApi.service.d.ts +8 -0
  50. package/dist/api/services/workspaceApi.service.js +20 -0
  51. package/dist/api/services/workspaceApi.service.js.map +1 -1
  52. package/dist/api/urls.d.ts +62 -0
  53. package/dist/api/urls.js +87 -17
  54. package/dist/api/urls.js.map +1 -1
  55. package/dist/api/utils/auth.utils.d.ts +1 -3
  56. package/dist/api/utils/auth.utils.js.map +1 -1
  57. package/dist/api/utils/cache.utils.d.ts +1 -1
  58. package/dist/api/utils/cache.utils.js +2 -2
  59. package/dist/api/utils/cache.utils.js.map +1 -1
  60. package/dist/api/utils/strings.utils.d.ts +2 -0
  61. package/dist/api/utils/strings.utils.js +14 -0
  62. package/dist/api/utils/strings.utils.js.map +1 -1
  63. package/dist/apps/services/app.service.d.ts +41 -33
  64. package/dist/apps/services/app.service.js +472 -184
  65. package/dist/apps/services/app.service.js.map +1 -1
  66. package/dist/apps/utils/auth-context-manager.d.ts +137 -0
  67. package/dist/apps/utils/auth-context-manager.js +248 -0
  68. package/dist/apps/utils/auth-context-manager.js.map +1 -0
  69. package/dist/apps/utils/credential-manager.d.ts +128 -0
  70. package/dist/apps/utils/credential-manager.js +199 -0
  71. package/dist/apps/utils/credential-manager.js.map +1 -0
  72. package/dist/apps/utils/index.d.ts +10 -0
  73. package/dist/apps/utils/index.js +54 -0
  74. package/dist/apps/utils/index.js.map +1 -0
  75. package/dist/apps/utils/input-helpers.d.ts +67 -0
  76. package/dist/apps/utils/input-helpers.js +185 -0
  77. package/dist/apps/utils/input-helpers.js.map +1 -0
  78. package/dist/apps/utils/input-resolver.d.ts +165 -0
  79. package/dist/apps/utils/input-resolver.js +477 -0
  80. package/dist/apps/utils/input-resolver.js.map +1 -0
  81. package/dist/apps/utils/oauth-manager.d.ts +196 -0
  82. package/dist/apps/utils/oauth-manager.js +429 -0
  83. package/dist/apps/utils/oauth-manager.js.map +1 -0
  84. package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
  85. package/dist/apps/validators/joi-validators/create.appAction.validator.js +21 -2
  86. package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
  87. package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -1
  88. package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
  89. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
  90. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
  91. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
  92. package/dist/bin.d.ts +26 -0
  93. package/dist/bin.js +28 -0
  94. package/dist/bin.js.map +1 -0
  95. package/dist/brokers/brokers.service.d.ts +297 -0
  96. package/dist/brokers/brokers.service.js +797 -0
  97. package/dist/brokers/brokers.service.js.map +1 -0
  98. package/dist/brokers/index.d.ts +46 -0
  99. package/dist/brokers/index.js +83 -0
  100. package/dist/brokers/index.js.map +1 -0
  101. package/dist/brokers/types/index.d.ts +316 -0
  102. package/dist/brokers/types/index.js +8 -0
  103. package/dist/brokers/types/index.js.map +1 -0
  104. package/dist/brokers/utils/broker.util.d.ts +33 -0
  105. package/dist/brokers/utils/broker.util.js +125 -0
  106. package/dist/brokers/utils/broker.util.js.map +1 -0
  107. package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
  108. package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
  109. package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
  110. package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
  111. package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
  112. package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
  113. package/dist/brokers/utils/providers/index.d.ts +6 -0
  114. package/dist/brokers/utils/providers/index.js +16 -0
  115. package/dist/brokers/utils/providers/index.js.map +1 -0
  116. package/dist/brokers/utils/providers/kafka.service.d.ts +23 -0
  117. package/dist/brokers/utils/providers/kafka.service.js +131 -0
  118. package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
  119. package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
  120. package/dist/brokers/utils/providers/nats.service.js +63 -0
  121. package/dist/brokers/utils/providers/nats.service.js.map +1 -0
  122. package/dist/brokers/utils/providers/rabbitmq.service.d.ts +15 -0
  123. package/dist/brokers/utils/providers/rabbitmq.service.js +151 -0
  124. package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
  125. package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
  126. package/dist/brokers/utils/providers/redis.service.js +93 -0
  127. package/dist/brokers/utils/providers/redis.service.js.map +1 -0
  128. package/dist/cache/cache.manager.d.ts +229 -0
  129. package/dist/cache/cache.manager.js +460 -0
  130. package/dist/cache/cache.manager.js.map +1 -0
  131. package/dist/cache/cache.service.d.ts +186 -0
  132. package/dist/cache/cache.service.js +437 -0
  133. package/dist/cache/cache.service.js.map +1 -0
  134. package/dist/cache/index.d.ts +52 -0
  135. package/dist/cache/index.js +79 -0
  136. package/dist/cache/index.js.map +1 -0
  137. package/dist/cache/types/index.d.ts +106 -0
  138. package/dist/cache/types/index.js +6 -0
  139. package/dist/cache/types/index.js.map +1 -0
  140. package/dist/clients/pricing.client.d.ts +3 -0
  141. package/dist/clients/pricing.client.js +33 -0
  142. package/dist/clients/pricing.client.js.map +1 -0
  143. package/dist/database/actions/action-manager.d.ts +170 -0
  144. package/dist/database/actions/action-manager.js +465 -0
  145. package/dist/database/actions/action-manager.js.map +1 -0
  146. package/dist/database/actions/index.d.ts +6 -0
  147. package/dist/database/actions/index.js +13 -0
  148. package/dist/database/actions/index.js.map +1 -0
  149. package/dist/database/adapters/adapter.factory.d.ts +62 -0
  150. package/dist/database/adapters/adapter.factory.js +97 -0
  151. package/dist/database/adapters/adapter.factory.js.map +1 -0
  152. package/dist/database/adapters/base.adapter.d.ts +423 -0
  153. package/dist/database/adapters/base.adapter.js +260 -0
  154. package/dist/database/adapters/base.adapter.js.map +1 -0
  155. package/dist/database/adapters/cassandra.adapter.d.ts +92 -0
  156. package/dist/database/adapters/cassandra.adapter.js +1091 -0
  157. package/dist/database/adapters/cassandra.adapter.js.map +1 -0
  158. package/dist/database/adapters/dynamodb.adapter.d.ts +110 -0
  159. package/dist/database/adapters/dynamodb.adapter.js +1564 -0
  160. package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
  161. package/dist/database/adapters/index.d.ts +11 -0
  162. package/dist/database/adapters/index.js +27 -0
  163. package/dist/database/adapters/index.js.map +1 -0
  164. package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
  165. package/dist/database/adapters/mariadb.adapter.js +247 -0
  166. package/dist/database/adapters/mariadb.adapter.js.map +1 -0
  167. package/dist/database/adapters/mongodb.adapter.d.ts +121 -0
  168. package/dist/database/adapters/mongodb.adapter.js +1284 -0
  169. package/dist/database/adapters/mongodb.adapter.js.map +1 -0
  170. package/dist/database/adapters/mysql.adapter.d.ts +86 -0
  171. package/dist/database/adapters/mysql.adapter.js +1371 -0
  172. package/dist/database/adapters/mysql.adapter.js.map +1 -0
  173. package/dist/database/adapters/postgresql.adapter.d.ts +90 -0
  174. package/dist/database/adapters/postgresql.adapter.js +1487 -0
  175. package/dist/database/adapters/postgresql.adapter.js.map +1 -0
  176. package/dist/database/databases.service.d.ts +1408 -0
  177. package/dist/database/databases.service.js +2953 -0
  178. package/dist/database/databases.service.js.map +1 -0
  179. package/dist/database/index.d.ts +46 -0
  180. package/dist/database/index.js +109 -0
  181. package/dist/database/index.js.map +1 -0
  182. package/dist/database/migrations/index.d.ts +6 -0
  183. package/dist/database/migrations/index.js +12 -0
  184. package/dist/database/migrations/index.js.map +1 -0
  185. package/dist/database/migrations/migration-engine.d.ts +136 -0
  186. package/dist/database/migrations/migration-engine.js +1421 -0
  187. package/dist/database/migrations/migration-engine.js.map +1 -0
  188. package/dist/database/operators/aggregation-builder.d.ts +67 -0
  189. package/dist/database/operators/aggregation-builder.js +841 -0
  190. package/dist/database/operators/aggregation-builder.js.map +1 -0
  191. package/dist/database/operators/index.d.ts +7 -0
  192. package/dist/database/operators/index.js +15 -0
  193. package/dist/database/operators/index.js.map +1 -0
  194. package/dist/database/operators/query-builder.d.ts +69 -0
  195. package/dist/database/operators/query-builder.js +447 -0
  196. package/dist/database/operators/query-builder.js.map +1 -0
  197. package/dist/database/presave/decrypt.d.ts +25 -0
  198. package/dist/database/presave/decrypt.js +146 -0
  199. package/dist/database/presave/decrypt.js.map +1 -0
  200. package/dist/database/presave/index.d.ts +9 -0
  201. package/dist/database/presave/index.js +18 -0
  202. package/dist/database/presave/index.js.map +1 -0
  203. package/dist/database/presave/presave-processor.d.ts +148 -0
  204. package/dist/database/presave/presave-processor.js +702 -0
  205. package/dist/database/presave/presave-processor.js.map +1 -0
  206. package/dist/database/schema/index.d.ts +7 -0
  207. package/dist/database/schema/index.js +13 -0
  208. package/dist/database/schema/index.js.map +1 -0
  209. package/dist/database/schema/schema-manager.d.ts +258 -0
  210. package/dist/database/schema/schema-manager.js +638 -0
  211. package/dist/database/schema/schema-manager.js.map +1 -0
  212. package/dist/database/transactions/index.d.ts +6 -0
  213. package/dist/database/transactions/index.js +13 -0
  214. package/dist/database/transactions/index.js.map +1 -0
  215. package/dist/database/transactions/transaction-manager.d.ts +113 -0
  216. package/dist/database/transactions/transaction-manager.js +344 -0
  217. package/dist/database/transactions/transaction-manager.js.map +1 -0
  218. package/dist/database/triggers/index.d.ts +7 -0
  219. package/dist/database/triggers/index.js +14 -0
  220. package/dist/database/triggers/index.js.map +1 -0
  221. package/dist/database/triggers/trigger-processor.d.ts +239 -0
  222. package/dist/database/triggers/trigger-processor.js +1034 -0
  223. package/dist/database/triggers/trigger-processor.js.map +1 -0
  224. package/dist/database/types/action.interface.d.ts +148 -0
  225. package/dist/database/types/action.interface.js +6 -0
  226. package/dist/database/types/action.interface.js.map +1 -0
  227. package/dist/database/types/aggregation.interface.d.ts +185 -0
  228. package/dist/database/types/aggregation.interface.js +6 -0
  229. package/dist/database/types/aggregation.interface.js.map +1 -0
  230. package/dist/database/types/connection.interface.d.ts +137 -0
  231. package/dist/database/types/connection.interface.js +6 -0
  232. package/dist/database/types/connection.interface.js.map +1 -0
  233. package/dist/database/types/enums.d.ts +195 -0
  234. package/dist/database/types/enums.js +244 -0
  235. package/dist/database/types/enums.js.map +1 -0
  236. package/dist/database/types/index.d.ts +14 -0
  237. package/dist/database/types/index.js +31 -0
  238. package/dist/database/types/index.js.map +1 -0
  239. package/dist/database/types/migration.interface.d.ts +686 -0
  240. package/dist/database/types/migration.interface.js +9 -0
  241. package/dist/database/types/migration.interface.js.map +1 -0
  242. package/dist/database/types/presave.interface.d.ts +292 -0
  243. package/dist/database/types/presave.interface.js +60 -0
  244. package/dist/database/types/presave.interface.js.map +1 -0
  245. package/dist/database/types/query.interface.d.ts +205 -0
  246. package/dist/database/types/query.interface.js +6 -0
  247. package/dist/database/types/query.interface.js.map +1 -0
  248. package/dist/database/types/schema.interface.d.ts +412 -0
  249. package/dist/database/types/schema.interface.js +6 -0
  250. package/dist/database/types/schema.interface.js.map +1 -0
  251. package/dist/database/types/transaction.interface.d.ts +84 -0
  252. package/dist/database/types/transaction.interface.js +6 -0
  253. package/dist/database/types/transaction.interface.js.map +1 -0
  254. package/dist/database/types/trigger.interface.d.ts +612 -0
  255. package/dist/database/types/trigger.interface.js +121 -0
  256. package/dist/database/types/trigger.interface.js.map +1 -0
  257. package/dist/database/types/write.interface.d.ts +216 -0
  258. package/dist/database/types/write.interface.js +6 -0
  259. package/dist/database/types/write.interface.js.map +1 -0
  260. package/dist/database/utils/database-error.d.ts +96 -0
  261. package/dist/database/utils/database-error.js +221 -0
  262. package/dist/database/utils/database-error.js.map +1 -0
  263. package/dist/database/utils/index.d.ts +6 -0
  264. package/dist/database/utils/index.js +11 -0
  265. package/dist/database/utils/index.js.map +1 -0
  266. package/dist/graph/adapters/adapter.factory.d.ts +47 -0
  267. package/dist/graph/adapters/adapter.factory.js +77 -0
  268. package/dist/graph/adapters/adapter.factory.js.map +1 -0
  269. package/dist/graph/adapters/arangodb.adapter.d.ts +86 -0
  270. package/dist/graph/adapters/arangodb.adapter.js +1588 -0
  271. package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
  272. package/dist/graph/adapters/base.adapter.d.ts +264 -0
  273. package/dist/graph/adapters/base.adapter.js +156 -0
  274. package/dist/graph/adapters/base.adapter.js.map +1 -0
  275. package/dist/graph/adapters/index.d.ts +11 -0
  276. package/dist/graph/adapters/index.js +21 -0
  277. package/dist/graph/adapters/index.js.map +1 -0
  278. package/dist/graph/adapters/memgraph.adapter.d.ts +110 -0
  279. package/dist/graph/adapters/memgraph.adapter.js +1452 -0
  280. package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
  281. package/dist/graph/adapters/neo4j.adapter.d.ts +81 -0
  282. package/dist/graph/adapters/neo4j.adapter.js +1317 -0
  283. package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
  284. package/dist/graph/adapters/neptune.adapter.d.ts +82 -0
  285. package/dist/graph/adapters/neptune.adapter.js +1369 -0
  286. package/dist/graph/adapters/neptune.adapter.js.map +1 -0
  287. package/dist/graph/graphs.service.d.ts +568 -0
  288. package/dist/graph/graphs.service.js +1948 -0
  289. package/dist/graph/graphs.service.js.map +1 -0
  290. package/dist/graph/index.d.ts +57 -0
  291. package/dist/graph/index.js +77 -0
  292. package/dist/graph/index.js.map +1 -0
  293. package/dist/graph/transactions/index.d.ts +4 -0
  294. package/dist/graph/transactions/index.js +9 -0
  295. package/dist/graph/transactions/index.js.map +1 -0
  296. package/dist/graph/transactions/transaction-manager.d.ts +61 -0
  297. package/dist/graph/transactions/transaction-manager.js +126 -0
  298. package/dist/graph/transactions/transaction-manager.js.map +1 -0
  299. package/dist/graph/types/connection.interface.d.ts +149 -0
  300. package/dist/graph/types/connection.interface.js +9 -0
  301. package/dist/graph/types/connection.interface.js.map +1 -0
  302. package/dist/graph/types/enums.d.ts +101 -0
  303. package/dist/graph/types/enums.js +114 -0
  304. package/dist/graph/types/enums.js.map +1 -0
  305. package/dist/graph/types/index.d.ts +13 -0
  306. package/dist/graph/types/index.js +20 -0
  307. package/dist/graph/types/index.js.map +1 -0
  308. package/dist/graph/types/node.interface.d.ts +248 -0
  309. package/dist/graph/types/node.interface.js +9 -0
  310. package/dist/graph/types/node.interface.js.map +1 -0
  311. package/dist/graph/types/query.interface.d.ts +175 -0
  312. package/dist/graph/types/query.interface.js +9 -0
  313. package/dist/graph/types/query.interface.js.map +1 -0
  314. package/dist/graph/types/relationship.interface.d.ts +207 -0
  315. package/dist/graph/types/relationship.interface.js +9 -0
  316. package/dist/graph/types/relationship.interface.js.map +1 -0
  317. package/dist/graph/types/schema.interface.d.ts +295 -0
  318. package/dist/graph/types/schema.interface.js +9 -0
  319. package/dist/graph/types/schema.interface.js.map +1 -0
  320. package/dist/graph/types/transaction.interface.d.ts +55 -0
  321. package/dist/graph/types/transaction.interface.js +9 -0
  322. package/dist/graph/types/transaction.interface.js.map +1 -0
  323. package/dist/graph/types/traversal.interface.d.ts +181 -0
  324. package/dist/graph/types/traversal.interface.js +9 -0
  325. package/dist/graph/types/traversal.interface.js.map +1 -0
  326. package/dist/graph/utils/graph-error.d.ts +71 -0
  327. package/dist/graph/utils/graph-error.js +142 -0
  328. package/dist/graph/utils/graph-error.js.map +1 -0
  329. package/dist/graph/utils/index.d.ts +4 -0
  330. package/dist/graph/utils/index.js +9 -0
  331. package/dist/graph/utils/index.js.map +1 -0
  332. package/dist/imports/imports.service.d.ts +3 -3
  333. package/dist/imports/imports.service.js +8 -7
  334. package/dist/imports/imports.service.js.map +1 -1
  335. package/dist/imports/imports.types.d.ts +8 -0
  336. package/dist/imports/repos/openApi.repo.d.ts +1 -1
  337. package/dist/imports/repos/openApi.repo.js +414 -47
  338. package/dist/imports/repos/openApi.repo.js.map +1 -1
  339. package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
  340. package/dist/imports/repos/postmanV21.repo.js +126 -83
  341. package/dist/imports/repos/postmanV21.repo.js.map +1 -1
  342. package/dist/index.d.ts +3654 -289
  343. package/dist/index.js +5066 -669
  344. package/dist/index.js.map +1 -1
  345. package/dist/init.interface.d.ts +407 -0
  346. package/dist/init.interface.js +3 -0
  347. package/dist/init.interface.js.map +1 -0
  348. package/dist/inputs/inputs.service.d.ts +1 -1
  349. package/dist/inputs/utils/inputs.utils.create.js +1 -1
  350. package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
  351. package/dist/jobs/index.d.ts +38 -0
  352. package/dist/jobs/index.js +50 -0
  353. package/dist/jobs/index.js.map +1 -0
  354. package/dist/jobs/jobs.service.d.ts +154 -0
  355. package/dist/jobs/jobs.service.js +491 -0
  356. package/dist/jobs/jobs.service.js.map +1 -0
  357. package/dist/jobs/jobs.state.d.ts +113 -0
  358. package/dist/jobs/jobs.state.js +447 -0
  359. package/dist/jobs/jobs.state.js.map +1 -0
  360. package/dist/jobs/types.d.ts +449 -0
  361. package/dist/jobs/types.js +74 -0
  362. package/dist/jobs/types.js.map +1 -0
  363. package/dist/logs/logs.service.js +6 -2
  364. package/dist/logs/logs.service.js.map +1 -1
  365. package/dist/logs/logs.types.d.ts +19 -1
  366. package/dist/logs/logs.types.js +6 -0
  367. package/dist/logs/logs.types.js.map +1 -1
  368. package/dist/models/index.d.ts +6 -0
  369. package/dist/models/index.js +11 -0
  370. package/dist/models/index.js.map +1 -0
  371. package/dist/models/models.service.d.ts +137 -0
  372. package/dist/models/models.service.js +195 -0
  373. package/dist/models/models.service.js.map +1 -0
  374. package/dist/notifications/index.d.ts +13 -0
  375. package/dist/notifications/index.js +26 -0
  376. package/dist/notifications/index.js.map +1 -0
  377. package/dist/notifications/notifications.service.d.ts +265 -0
  378. package/dist/notifications/notifications.service.js +862 -0
  379. package/dist/notifications/notifications.service.js.map +1 -0
  380. package/dist/notifications/types/index.d.ts +4 -0
  381. package/dist/notifications/types/index.js +21 -0
  382. package/dist/notifications/types/index.js.map +1 -0
  383. package/dist/notifications/types/notifications.types.d.ts +402 -0
  384. package/dist/notifications/types/notifications.types.js +49 -0
  385. package/dist/notifications/types/notifications.types.js.map +1 -0
  386. package/dist/parsers/index.d.ts +3 -0
  387. package/dist/parsers/index.js +27 -0
  388. package/dist/parsers/index.js.map +1 -0
  389. package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
  390. package/dist/parsers/pipelines/postman.pipelines.js +103 -0
  391. package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
  392. package/dist/parsers/types/postman.types.d.ts +200 -0
  393. package/dist/parsers/types/postman.types.js +3 -0
  394. package/dist/parsers/types/postman.types.js.map +1 -0
  395. package/dist/parsers/utils/postman.utils.d.ts +12 -0
  396. package/dist/parsers/utils/postman.utils.js +116 -0
  397. package/dist/parsers/utils/postman.utils.js.map +1 -0
  398. package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
  399. package/dist/parsers/validators/postman-auth.validators.js +127 -0
  400. package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
  401. package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
  402. package/dist/parsers/validators/postman-request.validators.js +139 -0
  403. package/dist/parsers/validators/postman-request.validators.js.map +1 -0
  404. package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
  405. package/dist/parsers/validators/postman-response.validators.js +150 -0
  406. package/dist/parsers/validators/postman-response.validators.js.map +1 -0
  407. package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
  408. package/dist/parsers/validators/postman-variable.validators.js +163 -0
  409. package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
  410. package/dist/pricing/pricing.repo.js +1 -0
  411. package/dist/pricing/pricing.repo.js.map +1 -0
  412. package/dist/pricing/pricing.service.d.ts +24 -0
  413. package/dist/pricing/pricing.service.js +51 -0
  414. package/dist/pricing/pricing.service.js.map +1 -0
  415. package/dist/pricing/pricing.types.d.ts +76 -0
  416. package/dist/pricing/pricing.types.js +21 -0
  417. package/dist/pricing/pricing.types.js.map +1 -0
  418. package/dist/pricing/utils/string.utils.d.ts +1 -0
  419. package/dist/pricing/utils/string.utils.js +9 -0
  420. package/dist/pricing/utils/string.utils.js.map +1 -0
  421. package/dist/processor/services/processor.service.d.ts +117 -73
  422. package/dist/processor/services/processor.service.js +1557 -1276
  423. package/dist/processor/services/processor.service.js.map +1 -1
  424. package/dist/processor/services/request.service.d.ts +36 -0
  425. package/dist/processor/services/request.service.js +304 -0
  426. package/dist/processor/services/request.service.js.map +1 -0
  427. package/dist/processor/types/request.types.d.ts +14 -0
  428. package/dist/processor/types/request.types.js +3 -0
  429. package/dist/processor/types/request.types.js.map +1 -0
  430. package/dist/processor/utils/processor.utils.js +32 -20
  431. package/dist/processor/utils/processor.utils.js.map +1 -1
  432. package/dist/processor/utils/request.utils.d.ts +20 -0
  433. package/dist/processor/utils/request.utils.js +113 -0
  434. package/dist/processor/utils/request.utils.js.map +1 -0
  435. package/dist/products/services/products.service.d.ts +365 -75
  436. package/dist/products/services/products.service.js +2809 -414
  437. package/dist/products/services/products.service.js.map +1 -1
  438. package/dist/products/utils/string.utils.d.ts +1 -1
  439. package/dist/products/utils/string.utils.js +14 -2
  440. package/dist/products/utils/string.utils.js.map +1 -1
  441. package/dist/products/validators/index.d.ts +7 -1
  442. package/dist/products/validators/index.js +16 -1
  443. package/dist/products/validators/index.js.map +1 -1
  444. package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
  445. package/dist/products/validators/joi-validators/create.productAgent.validator.js +266 -0
  446. package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
  447. package/dist/products/validators/joi-validators/create.productDatabase.validator.js +5 -0
  448. package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
  449. package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
  450. package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
  451. package/dist/products/validators/joi-validators/create.productGraph.validator.js +89 -0
  452. package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
  453. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
  454. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
  455. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
  456. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +81 -25
  457. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
  458. package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
  459. package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
  460. package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
  461. package/dist/products/validators/joi-validators/create.productNotification.validator.js +133 -45
  462. package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
  463. package/dist/products/validators/joi-validators/create.productStorage.validator.js +77 -18
  464. package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -1
  465. package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
  466. package/dist/products/validators/joi-validators/create.productVector.validator.js +135 -0
  467. package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
  468. package/dist/products/validators/joi-validators/update.dataValue.validator.js +1 -0
  469. package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
  470. package/dist/products/validators/joi-validators/update.productDatabase.validator.js +5 -0
  471. package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
  472. package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
  473. package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
  474. package/dist/products/validators/joi-validators/update.productGraph.validator.js +88 -0
  475. package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
  476. package/dist/resilience/fallback.service.d.ts +140 -0
  477. package/dist/resilience/fallback.service.js +764 -0
  478. package/dist/resilience/fallback.service.js.map +1 -0
  479. package/dist/resilience/healthcheck.service.d.ts +159 -0
  480. package/dist/resilience/healthcheck.service.js +943 -0
  481. package/dist/resilience/healthcheck.service.js.map +1 -0
  482. package/dist/resilience/index.d.ts +104 -0
  483. package/dist/resilience/index.js +140 -0
  484. package/dist/resilience/index.js.map +1 -0
  485. package/dist/resilience/quota.service.d.ts +82 -0
  486. package/dist/resilience/quota.service.js +516 -0
  487. package/dist/resilience/quota.service.js.map +1 -0
  488. package/dist/resilience/resilience.service.d.ts +98 -0
  489. package/dist/resilience/resilience.service.js +560 -0
  490. package/dist/resilience/resilience.service.js.map +1 -0
  491. package/dist/resilience/types/index.d.ts +513 -0
  492. package/dist/resilience/types/index.js +29 -0
  493. package/dist/resilience/types/index.js.map +1 -0
  494. package/dist/secrets/index.d.ts +10 -0
  495. package/dist/secrets/index.js +33 -0
  496. package/dist/secrets/index.js.map +1 -0
  497. package/dist/secrets/secrets.resolver.d.ts +52 -0
  498. package/dist/secrets/secrets.resolver.js +233 -0
  499. package/dist/secrets/secrets.resolver.js.map +1 -0
  500. package/dist/secrets/secrets.service.d.ts +93 -0
  501. package/dist/secrets/secrets.service.js +258 -0
  502. package/dist/secrets/secrets.service.js.map +1 -0
  503. package/dist/secrets/secrets.types.d.ts +188 -0
  504. package/dist/secrets/secrets.types.js +87 -0
  505. package/dist/secrets/secrets.types.js.map +1 -0
  506. package/dist/sessions/index.d.ts +50 -0
  507. package/dist/sessions/index.js +93 -0
  508. package/dist/sessions/index.js.map +1 -0
  509. package/dist/sessions/sessions.helper.d.ts +68 -0
  510. package/dist/sessions/sessions.helper.js +116 -0
  511. package/dist/sessions/sessions.helper.js.map +1 -0
  512. package/dist/sessions/sessions.resolver.d.ts +157 -0
  513. package/dist/sessions/sessions.resolver.js +374 -0
  514. package/dist/sessions/sessions.resolver.js.map +1 -0
  515. package/dist/sessions/sessions.service.d.ts +178 -0
  516. package/dist/sessions/sessions.service.js +923 -0
  517. package/dist/sessions/sessions.service.js.map +1 -0
  518. package/dist/sessions/types/index.d.ts +298 -0
  519. package/dist/sessions/types/index.js +6 -0
  520. package/dist/sessions/types/index.js.map +1 -0
  521. package/dist/storage/index.d.ts +66 -0
  522. package/dist/storage/index.js +99 -0
  523. package/dist/storage/index.js.map +1 -0
  524. package/dist/storage/storage.service.d.ts +174 -0
  525. package/dist/storage/storage.service.js +757 -0
  526. package/dist/storage/storage.service.js.map +1 -0
  527. package/dist/storage/types/index.d.ts +267 -0
  528. package/dist/storage/types/index.js +6 -0
  529. package/dist/storage/types/index.js.map +1 -0
  530. package/dist/storage/utils/storage.util.d.ts +62 -0
  531. package/dist/storage/utils/storage.util.js +593 -0
  532. package/dist/storage/utils/storage.util.js.map +1 -0
  533. package/dist/test/index.d.ts +3 -0
  534. package/dist/test/index.js +11 -0
  535. package/dist/test/index.js.map +1 -0
  536. package/dist/test/test.appBuilder.d.ts +0 -1
  537. package/dist/test/test.appBuilder.js +0 -15
  538. package/dist/test/test.appBuilder.js.map +1 -1
  539. package/dist/test/test.broker.kafka.js +172 -0
  540. package/dist/test/test.broker.kafka.js.map +1 -0
  541. package/dist/test/test.broker.nats.js +193 -0
  542. package/dist/test/test.broker.nats.js.map +1 -0
  543. package/dist/test/test.broker.pubsub.js +171 -0
  544. package/dist/test/test.broker.pubsub.js.map +1 -0
  545. package/dist/test/test.broker.rabbitmq.js +164 -0
  546. package/dist/test/test.broker.rabbitmq.js.map +1 -0
  547. package/dist/test/test.broker.redis.js +168 -0
  548. package/dist/test/test.broker.redis.js.map +1 -0
  549. package/dist/test/test.broker.sqs.d.ts +1 -0
  550. package/dist/test/test.broker.sqs.js +158 -0
  551. package/dist/test/test.broker.sqs.js.map +1 -0
  552. package/dist/test/test.caches.d.ts +1 -0
  553. package/dist/test/test.caches.js +231 -0
  554. package/dist/test/test.caches.js.map +1 -0
  555. package/dist/test/test.database.d.ts +1 -0
  556. package/dist/test/test.database.dynamo.d.ts +1 -0
  557. package/dist/test/test.database.dynamo.js +265 -0
  558. package/dist/test/test.database.dynamo.js.map +1 -0
  559. package/dist/test/test.database.js +140 -0
  560. package/dist/test/test.database.js.map +1 -0
  561. package/dist/test/test.database.mongo.d.ts +1 -0
  562. package/dist/test/test.database.mongo.js +371 -0
  563. package/dist/test/test.database.mongo.js.map +1 -0
  564. package/dist/test/test.database.mysql.d.ts +1 -0
  565. package/dist/test/test.database.mysql.js +415 -0
  566. package/dist/test/test.database.mysql.js.map +1 -0
  567. package/dist/test/test.database.postgres.d.ts +1 -0
  568. package/dist/test/test.database.postgres.js +412 -0
  569. package/dist/test/test.database.postgres.js.map +1 -0
  570. package/dist/test/test.email.brevo.d.ts +1 -0
  571. package/dist/test/test.email.brevo.js +326 -0
  572. package/dist/test/test.email.brevo.js.map +1 -0
  573. package/dist/test/test.email.mailgun.d.ts +1 -0
  574. package/dist/test/test.email.mailgun.js +352 -0
  575. package/dist/test/test.email.mailgun.js.map +1 -0
  576. package/dist/test/test.email.postmark.d.ts +1 -0
  577. package/dist/test/test.email.postmark.js +316 -0
  578. package/dist/test/test.email.postmark.js.map +1 -0
  579. package/dist/test/test.email.sendgrid.d.ts +1 -0
  580. package/dist/test/test.email.sendgrid.js +365 -0
  581. package/dist/test/test.email.sendgrid.js.map +1 -0
  582. package/dist/test/test.email.smtp.d.ts +1 -0
  583. package/dist/test/test.email.smtp.js +323 -0
  584. package/dist/test/test.email.smtp.js.map +1 -0
  585. package/dist/test/test.graph.arangodb.d.ts +1 -0
  586. package/dist/test/test.graph.arangodb.js +358 -0
  587. package/dist/test/test.graph.arangodb.js.map +1 -0
  588. package/dist/test/test.graph.memgraph.d.ts +1 -0
  589. package/dist/test/test.graph.memgraph.js +320 -0
  590. package/dist/test/test.graph.memgraph.js.map +1 -0
  591. package/dist/test/test.graph.neo4j.d.ts +1 -0
  592. package/dist/test/test.graph.neo4j.js +218 -0
  593. package/dist/test/test.graph.neo4j.js.map +1 -0
  594. package/dist/test/test.graph.neptune.d.ts +1 -0
  595. package/dist/test/test.graph.neptune.js +331 -0
  596. package/dist/test/test.graph.neptune.js.map +1 -0
  597. package/dist/test/test.health.js +1 -0
  598. package/dist/test/test.health.js.map +1 -0
  599. package/dist/test/test.import.d.ts +0 -1
  600. package/dist/test/test.import.js +0 -1459
  601. package/dist/test/test.import.js.map +1 -1
  602. package/dist/test/test.import.openapi.d.ts +0 -1
  603. package/dist/test/test.import.openapi.js +0 -75
  604. package/dist/test/test.import.openapi.js.map +1 -1
  605. package/dist/test/test.imports.js +14 -55
  606. package/dist/test/test.imports.js.map +1 -1
  607. package/dist/test/test.logs.d.ts +0 -1
  608. package/dist/test/test.logs.js +0 -17
  609. package/dist/test/test.logs.js.map +1 -1
  610. package/dist/test/test.notifications.d.ts +1 -0
  611. package/dist/test/test.notifications.js +198 -0
  612. package/dist/test/test.notifications.js.map +1 -0
  613. package/dist/test/test.notifiers.js +1 -0
  614. package/dist/test/test.notifiers.js.map +1 -0
  615. package/dist/test/test.processor.d.ts +0 -1
  616. package/dist/test/test.processor.js +0 -122
  617. package/dist/test/test.processor.js.map +1 -1
  618. package/dist/test/test.productBuilder.d.ts +0 -1
  619. package/dist/test/test.productBuilder.js +0 -660
  620. package/dist/test/test.productBuilder.js.map +1 -1
  621. package/dist/test/test.products.js +1 -0
  622. package/dist/test/test.products.js.map +1 -0
  623. package/dist/test/test.push.expo.d.ts +1 -0
  624. package/dist/test/test.push.expo.js +442 -0
  625. package/dist/test/test.push.expo.js.map +1 -0
  626. package/dist/test/test.push.firebase.d.ts +1 -0
  627. package/dist/test/test.push.firebase.js +409 -0
  628. package/dist/test/test.push.firebase.js.map +1 -0
  629. package/dist/test/test.session.d.ts +1 -0
  630. package/dist/test/test.session.js +299 -0
  631. package/dist/test/test.session.js.map +1 -0
  632. package/dist/test/test.sms.nexmo.d.ts +1 -0
  633. package/dist/test/test.sms.nexmo.js +278 -0
  634. package/dist/test/test.sms.nexmo.js.map +1 -0
  635. package/dist/test/test.sms.twilio.d.ts +1 -0
  636. package/dist/test/test.sms.twilio.js +275 -0
  637. package/dist/test/test.sms.twilio.js.map +1 -0
  638. package/dist/test/test.storage.d.ts +1 -0
  639. package/dist/test/test.storage.js +202 -0
  640. package/dist/test/test.storage.js.map +1 -0
  641. package/dist/test/test.triggers.d.ts +1 -0
  642. package/dist/test/test.triggers.js +314 -0
  643. package/dist/test/test.triggers.js.map +1 -0
  644. package/dist/test/test.vector.pinecone.d.ts +1 -0
  645. package/dist/test/test.vector.pinecone.js +238 -0
  646. package/dist/test/test.vector.pinecone.js.map +1 -0
  647. package/dist/test/test.vector.qdrant.d.ts +1 -0
  648. package/dist/test/test.vector.qdrant.js +307 -0
  649. package/dist/test/test.vector.qdrant.js.map +1 -0
  650. package/dist/test/test.vector.weaviate.d.ts +1 -0
  651. package/dist/test/test.vector.weaviate.js +325 -0
  652. package/dist/test/test.vector.weaviate.js.map +1 -0
  653. package/dist/types/appBuilder.types.d.ts +9 -2
  654. package/dist/types/enums.d.ts +11 -1
  655. package/dist/types/enums.js +10 -0
  656. package/dist/types/enums.js.map +1 -1
  657. package/dist/types/index.types.d.ts +4 -7
  658. package/dist/types/index.types.js +0 -1
  659. package/dist/types/index.types.js.map +1 -1
  660. package/dist/types/inputs.types.js +1 -1
  661. package/dist/types/inputs.types.js.map +1 -1
  662. package/dist/types/pricing.types.d.ts +4 -0
  663. package/dist/types/pricing.types.js +3 -0
  664. package/dist/types/pricing.types.js.map +1 -0
  665. package/dist/types/processor.types.d.ts +214 -33
  666. package/dist/types/processor.types.js +9 -1
  667. package/dist/types/processor.types.js.map +1 -1
  668. package/dist/types/productsBuilder.types.d.ts +978 -23
  669. package/dist/types/productsBuilder.types.js +210 -3
  670. package/dist/types/productsBuilder.types.js.map +1 -1
  671. package/dist/types/request-tracker.interface.js +1 -0
  672. package/dist/types/request-tracker.interface.js.map +1 -0
  673. package/dist/types/requests.types.d.ts +2 -0
  674. package/dist/utils/constants.d.ts +1 -0
  675. package/dist/utils/constants.js +5 -0
  676. package/dist/utils/constants.js.map +1 -0
  677. package/dist/utils/index.d.ts +0 -2
  678. package/dist/utils/index.js +24 -52
  679. package/dist/utils/index.js.map +1 -1
  680. package/dist/vector/actions/action-manager.d.ts +140 -0
  681. package/dist/vector/actions/action-manager.js +356 -0
  682. package/dist/vector/actions/action-manager.js.map +1 -0
  683. package/dist/vector/adapters/base.adapter.d.ts +169 -0
  684. package/dist/vector/adapters/base.adapter.js +218 -0
  685. package/dist/vector/adapters/base.adapter.js.map +1 -0
  686. package/dist/vector/adapters/index.d.ts +10 -0
  687. package/dist/vector/adapters/index.js +19 -0
  688. package/dist/vector/adapters/index.js.map +1 -0
  689. package/dist/vector/adapters/memory.adapter.d.ts +85 -0
  690. package/dist/vector/adapters/memory.adapter.js +505 -0
  691. package/dist/vector/adapters/memory.adapter.js.map +1 -0
  692. package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
  693. package/dist/vector/adapters/pinecone.adapter.js +433 -0
  694. package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
  695. package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
  696. package/dist/vector/adapters/qdrant.adapter.js +442 -0
  697. package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
  698. package/dist/vector/adapters/weaviate.adapter.d.ts +68 -0
  699. package/dist/vector/adapters/weaviate.adapter.js +645 -0
  700. package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
  701. package/dist/vector/index.d.ts +36 -0
  702. package/dist/vector/index.js +70 -0
  703. package/dist/vector/index.js.map +1 -0
  704. package/dist/vector/types/action.interface.d.ts +195 -0
  705. package/dist/vector/types/action.interface.js +100 -0
  706. package/dist/vector/types/action.interface.js.map +1 -0
  707. package/dist/vector/types/connection.interface.d.ts +151 -0
  708. package/dist/vector/types/connection.interface.js +8 -0
  709. package/dist/vector/types/connection.interface.js.map +1 -0
  710. package/dist/vector/types/embedding.interface.d.ts +144 -0
  711. package/dist/vector/types/embedding.interface.js +8 -0
  712. package/dist/vector/types/embedding.interface.js.map +1 -0
  713. package/dist/vector/types/enums.d.ts +104 -0
  714. package/dist/vector/types/enums.js +113 -0
  715. package/dist/vector/types/enums.js.map +1 -0
  716. package/dist/vector/types/index.d.ts +11 -0
  717. package/dist/vector/types/index.js +23 -0
  718. package/dist/vector/types/index.js.map +1 -0
  719. package/dist/vector/types/vector.interface.d.ts +315 -0
  720. package/dist/vector/types/vector.interface.js +8 -0
  721. package/dist/vector/types/vector.interface.js.map +1 -0
  722. package/dist/vector/utils/index.d.ts +6 -0
  723. package/dist/vector/utils/index.js +11 -0
  724. package/dist/vector/utils/index.js.map +1 -0
  725. package/dist/vector/utils/vector-error.d.ts +69 -0
  726. package/dist/vector/utils/vector-error.js +116 -0
  727. package/dist/vector/utils/vector-error.js.map +1 -0
  728. package/dist/vector/vector-database.service.d.ts +474 -0
  729. package/dist/vector/vector-database.service.js +850 -0
  730. package/dist/vector/vector-database.service.js.map +1 -0
  731. package/dist/vector/vector.service.d.ts +283 -0
  732. package/dist/vector/vector.service.js +544 -0
  733. package/dist/vector/vector.service.js.map +1 -0
  734. package/dist/warehouse/executor/index.d.ts +5 -0
  735. package/dist/warehouse/executor/index.js +12 -0
  736. package/dist/warehouse/executor/index.js.map +1 -0
  737. package/dist/warehouse/executor/joins/index.d.ts +5 -0
  738. package/dist/warehouse/executor/joins/index.js +11 -0
  739. package/dist/warehouse/executor/joins/index.js.map +1 -0
  740. package/dist/warehouse/executor/joins/join-executor.d.ts +101 -0
  741. package/dist/warehouse/executor/joins/join-executor.js +493 -0
  742. package/dist/warehouse/executor/joins/join-executor.js.map +1 -0
  743. package/dist/warehouse/executor/joins/semantic-join.d.ts +64 -0
  744. package/dist/warehouse/executor/joins/semantic-join.js +241 -0
  745. package/dist/warehouse/executor/joins/semantic-join.js.map +1 -0
  746. package/dist/warehouse/executor/single-source-executor.d.ts +155 -0
  747. package/dist/warehouse/executor/single-source-executor.js +573 -0
  748. package/dist/warehouse/executor/single-source-executor.js.map +1 -0
  749. package/dist/warehouse/index.d.ts +79 -0
  750. package/dist/warehouse/index.js +111 -0
  751. package/dist/warehouse/index.js.map +1 -0
  752. package/dist/warehouse/parser/index.d.ts +4 -0
  753. package/dist/warehouse/parser/index.js +10 -0
  754. package/dist/warehouse/parser/index.js.map +1 -0
  755. package/dist/warehouse/parser/query-parser.d.ts +181 -0
  756. package/dist/warehouse/parser/query-parser.js +415 -0
  757. package/dist/warehouse/parser/query-parser.js.map +1 -0
  758. package/dist/warehouse/registry/data-source-registry.d.ts +207 -0
  759. package/dist/warehouse/registry/data-source-registry.js +396 -0
  760. package/dist/warehouse/registry/data-source-registry.js.map +1 -0
  761. package/dist/warehouse/registry/index.d.ts +4 -0
  762. package/dist/warehouse/registry/index.js +9 -0
  763. package/dist/warehouse/registry/index.js.map +1 -0
  764. package/dist/warehouse/transactions/index.d.ts +4 -0
  765. package/dist/warehouse/transactions/index.js +9 -0
  766. package/dist/warehouse/transactions/index.js.map +1 -0
  767. package/dist/warehouse/transactions/saga-orchestrator.d.ts +92 -0
  768. package/dist/warehouse/transactions/saga-orchestrator.js +383 -0
  769. package/dist/warehouse/transactions/saga-orchestrator.js.map +1 -0
  770. package/dist/warehouse/types/index.d.ts +9 -0
  771. package/dist/warehouse/types/index.js +33 -0
  772. package/dist/warehouse/types/index.js.map +1 -0
  773. package/dist/warehouse/types/join.interface.d.ts +225 -0
  774. package/dist/warehouse/types/join.interface.js +87 -0
  775. package/dist/warehouse/types/join.interface.js.map +1 -0
  776. package/dist/warehouse/types/query.interface.d.ts +232 -0
  777. package/dist/warehouse/types/query.interface.js +9 -0
  778. package/dist/warehouse/types/query.interface.js.map +1 -0
  779. package/dist/warehouse/types/transaction.interface.d.ts +236 -0
  780. package/dist/warehouse/types/transaction.interface.js +74 -0
  781. package/dist/warehouse/types/transaction.interface.js.map +1 -0
  782. package/dist/warehouse/types/where.interface.d.ts +208 -0
  783. package/dist/warehouse/types/where.interface.js +89 -0
  784. package/dist/warehouse/types/where.interface.js.map +1 -0
  785. package/dist/warehouse/warehouse.service.d.ts +200 -0
  786. package/dist/warehouse/warehouse.service.js +470 -0
  787. package/dist/warehouse/warehouse.service.js.map +1 -0
  788. package/dist/workflows/index.d.ts +30 -0
  789. package/dist/workflows/index.js +64 -0
  790. package/dist/workflows/index.js.map +1 -0
  791. package/dist/workflows/types/index.d.ts +6 -0
  792. package/dist/workflows/types/index.js +23 -0
  793. package/dist/workflows/types/index.js.map +1 -0
  794. package/dist/workflows/types/workflows.types.d.ts +1037 -0
  795. package/dist/workflows/types/workflows.types.js +13 -0
  796. package/dist/workflows/types/workflows.types.js.map +1 -0
  797. package/dist/workflows/workflow-builder.d.ts +70 -0
  798. package/dist/workflows/workflow-builder.js +338 -0
  799. package/dist/workflows/workflow-builder.js.map +1 -0
  800. package/dist/workflows/workflow-executor.d.ts +208 -0
  801. package/dist/workflows/workflow-executor.js +1194 -0
  802. package/dist/workflows/workflow-executor.js.map +1 -0
  803. package/dist/workflows/workflows.service.d.ts +410 -0
  804. package/dist/workflows/workflows.service.js +1724 -0
  805. package/dist/workflows/workflows.service.js.map +1 -0
  806. package/package.json +65 -12
  807. package/dist/actions/actions.repo.js +0 -13
  808. package/dist/actions/actions.repo.js.map +0 -1
  809. package/dist/actions/actions.service.js +0 -24
  810. package/dist/actions/actions.service.js.map +0 -1
  811. package/dist/actions/utils/actions.util.read.js +0 -427
  812. package/dist/actions/utils/actions.util.read.js.map +0 -1
  813. package/dist/api/services/integrationsApi.service.d.ts +0 -18
  814. package/dist/api/services/integrationsApi.service.js +0 -80
  815. package/dist/api/services/integrationsApi.service.js.map +0 -1
  816. package/dist/appBuilder/services/app.service.d.ts +0 -111
  817. package/dist/appBuilder/services/app.service.js +0 -737
  818. package/dist/appBuilder/services/app.service.js.map +0 -1
  819. package/dist/appBuilder/services/appBuilder.service.d.ts +0 -111
  820. package/dist/appBuilder/services/appBuilder.service.js +0 -662
  821. package/dist/appBuilder/services/appBuilder.service.js.map +0 -1
  822. package/dist/appBuilder/utils/objects.utils.d.ts +0 -3
  823. package/dist/appBuilder/utils/objects.utils.js +0 -9
  824. package/dist/appBuilder/utils/objects.utils.js.map +0 -1
  825. package/dist/appBuilder/utils/string.utils.d.ts +0 -2
  826. package/dist/appBuilder/utils/string.utils.js +0 -57
  827. package/dist/appBuilder/utils/string.utils.js.map +0 -1
  828. package/dist/appBuilder/validators/index.d.ts +0 -19
  829. package/dist/appBuilder/validators/index.js +0 -40
  830. package/dist/appBuilder/validators/index.js.map +0 -1
  831. package/dist/appBuilder/validators/joi-validators/create.app.validator.js +0 -10
  832. package/dist/appBuilder/validators/joi-validators/create.app.validator.js.map +0 -1
  833. package/dist/appBuilder/validators/joi-validators/create.appAction.validator.d.ts +0 -4
  834. package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js +0 -20
  835. package/dist/appBuilder/validators/joi-validators/create.appAction.validator.js.map +0 -1
  836. package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.d.ts +0 -7
  837. package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js +0 -44
  838. package/dist/appBuilder/validators/joi-validators/create.appActionResponse.validator.js.map +0 -1
  839. package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.d.ts +0 -3
  840. package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js +0 -31
  841. package/dist/appBuilder/validators/joi-validators/create.appAuth.validator.js.map +0 -1
  842. package/dist/appBuilder/validators/joi-validators/create.appBody.validators.d.ts +0 -4
  843. package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js +0 -11
  844. package/dist/appBuilder/validators/joi-validators/create.appBody.validators.js.map +0 -1
  845. package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.d.ts +0 -4
  846. package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js +0 -12
  847. package/dist/appBuilder/validators/joi-validators/create.appConstants.validator.js.map +0 -1
  848. package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.d.ts +0 -4
  849. package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js +0 -17
  850. package/dist/appBuilder/validators/joi-validators/create.appEnv.validator.js.map +0 -1
  851. package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
  852. package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js +0 -30
  853. package/dist/appBuilder/validators/joi-validators/create.appEvent.validator.js.map +0 -1
  854. package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.d.ts +0 -4
  855. package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js +0 -14
  856. package/dist/appBuilder/validators/joi-validators/create.appVariable.validator.js.map +0 -1
  857. package/dist/appBuilder/validators/joi-validators/sample.validator.d.ts +0 -5
  858. package/dist/appBuilder/validators/joi-validators/sample.validator.js +0 -26
  859. package/dist/appBuilder/validators/joi-validators/sample.validator.js.map +0 -1
  860. package/dist/appBuilder/validators/joi-validators/update.app.validator.d.ts +0 -4
  861. package/dist/appBuilder/validators/joi-validators/update.app.validator.js +0 -34
  862. package/dist/appBuilder/validators/joi-validators/update.app.validator.js.map +0 -1
  863. package/dist/appBuilder/validators/joi-validators/update.appAction.validator.d.ts +0 -4
  864. package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js +0 -23
  865. package/dist/appBuilder/validators/joi-validators/update.appAction.validator.js.map +0 -1
  866. package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.d.ts +0 -3
  867. package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js +0 -21
  868. package/dist/appBuilder/validators/joi-validators/update.appActionResponse.validator.js.map +0 -1
  869. package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.d.ts +0 -4
  870. package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js +0 -19
  871. package/dist/appBuilder/validators/joi-validators/update.appAuth.validator.js.map +0 -1
  872. package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.d.ts +0 -4
  873. package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js +0 -12
  874. package/dist/appBuilder/validators/joi-validators/update.appConstants.validator.js.map +0 -1
  875. package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.d.ts +0 -4
  876. package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js +0 -17
  877. package/dist/appBuilder/validators/joi-validators/update.appEnv.validator.js.map +0 -1
  878. package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
  879. package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js +0 -16
  880. package/dist/appBuilder/validators/joi-validators/update.appEvent.validator.js.map +0 -1
  881. package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.d.ts +0 -4
  882. package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js +0 -14
  883. package/dist/appBuilder/validators/joi-validators/update.appVariables.validator.js.map +0 -1
  884. package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js +0 -27
  885. package/dist/appBuilder/validators/joi-validators/update.validation.entityData.validator.js.map +0 -1
  886. package/dist/apps/validators/joi-validators/create.appEvent.validator.d.ts +0 -5
  887. package/dist/apps/validators/joi-validators/create.appEvent.validator.js +0 -30
  888. package/dist/apps/validators/joi-validators/create.appEvent.validator.js.map +0 -1
  889. package/dist/apps/validators/joi-validators/update.appEvent.validator.d.ts +0 -4
  890. package/dist/apps/validators/joi-validators/update.appEvent.validator.js +0 -16
  891. package/dist/apps/validators/joi-validators/update.appEvent.validator.js.map +0 -1
  892. package/dist/clients/integrations.client.d.ts +0 -2
  893. package/dist/clients/integrations.client.js +0 -26
  894. package/dist/clients/integrations.client.js.map +0 -1
  895. package/dist/integrationsBuilder/services/integration.service.d.ts +0 -138
  896. package/dist/integrationsBuilder/services/integration.service.js +0 -1148
  897. package/dist/integrationsBuilder/services/integration.service.js.map +0 -1
  898. package/dist/integrationsBuilder/services/integrationBuilder.service.d.ts +0 -130
  899. package/dist/integrationsBuilder/services/integrationBuilder.service.js +0 -1017
  900. package/dist/integrationsBuilder/services/integrationBuilder.service.js.map +0 -1
  901. package/dist/integrationsBuilder/utils/objects.utils.d.ts +0 -2
  902. package/dist/integrationsBuilder/utils/objects.utils.js +0 -48
  903. package/dist/integrationsBuilder/utils/objects.utils.js.map +0 -1
  904. package/dist/integrationsBuilder/utils/string.utils.d.ts +0 -1
  905. package/dist/integrationsBuilder/utils/string.utils.js +0 -9
  906. package/dist/integrationsBuilder/utils/string.utils.js.map +0 -1
  907. package/dist/integrationsBuilder/validators/index.d.ts +0 -18
  908. package/dist/integrationsBuilder/validators/index.js +0 -38
  909. package/dist/integrationsBuilder/validators/index.js.map +0 -1
  910. package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.d.ts +0 -3
  911. package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js +0 -10
  912. package/dist/integrationsBuilder/validators/joi-validators/create.integration.validator.js.map +0 -1
  913. package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.d.ts +0 -4
  914. package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js +0 -26
  915. package/dist/integrationsBuilder/validators/joi-validators/create.integrationApp.validator.js.map +0 -1
  916. package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.d.ts +0 -3
  917. package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js +0 -8
  918. package/dist/integrationsBuilder/validators/joi-validators/create.integrationCache.validator.js.map +0 -1
  919. package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.d.ts +0 -3
  920. package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js +0 -8
  921. package/dist/integrationsBuilder/validators/joi-validators/create.integrationDatabase.validator.js.map +0 -1
  922. package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.d.ts +0 -3
  923. package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js +0 -10
  924. package/dist/integrationsBuilder/validators/joi-validators/create.integrationEnv.validator.js.map +0 -1
  925. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.d.ts +0 -3
  926. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js +0 -60
  927. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFeature.validator.js.map +0 -1
  928. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.d.ts +0 -3
  929. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js +0 -8
  930. package/dist/integrationsBuilder/validators/joi-validators/create.integrationFunction.validator.js.map +0 -1
  931. package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.d.ts +0 -3
  932. package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js +0 -8
  933. package/dist/integrationsBuilder/validators/joi-validators/create.integrationJob.validator.js.map +0 -1
  934. package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.d.ts +0 -3
  935. package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js +0 -8
  936. package/dist/integrationsBuilder/validators/joi-validators/create.integrationNotification.validator.js.map +0 -1
  937. package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.d.ts +0 -3
  938. package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js +0 -9
  939. package/dist/integrationsBuilder/validators/joi-validators/update.integrationApp.validator.js.map +0 -1
  940. package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.d.ts +0 -3
  941. package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js +0 -8
  942. package/dist/integrationsBuilder/validators/joi-validators/update.integrationCache.validator.js.map +0 -1
  943. package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.d.ts +0 -3
  944. package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js +0 -8
  945. package/dist/integrationsBuilder/validators/joi-validators/update.integrationDatabase.validator.js.map +0 -1
  946. package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.d.ts +0 -3
  947. package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js +0 -8
  948. package/dist/integrationsBuilder/validators/joi-validators/update.integrationEnv.validator.js.map +0 -1
  949. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.d.ts +0 -3
  950. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js +0 -8
  951. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFeature.validator.js.map +0 -1
  952. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.d.ts +0 -3
  953. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js +0 -8
  954. package/dist/integrationsBuilder/validators/joi-validators/update.integrationFunction.validator copy.js.map +0 -1
  955. package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.d.ts +0 -3
  956. package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js +0 -8
  957. package/dist/integrationsBuilder/validators/joi-validators/update.integrationJob.validator.js.map +0 -1
  958. package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.d.ts +0 -3
  959. package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js +0 -8
  960. package/dist/integrationsBuilder/validators/joi-validators/update.integrationNotification.validator.js.map +0 -1
  961. package/dist/postman.d.ts +0 -1
  962. package/dist/postman.js +0 -21674
  963. package/dist/postman.js.map +0 -1
  964. package/dist/processor/utils/mongo.util.js +0 -152
  965. package/dist/processor/utils/mongo.util.js.map +0 -1
  966. package/dist/processor/utils/postgres.util.d.ts +0 -14
  967. package/dist/processor/utils/postgres.util.js +0 -83
  968. package/dist/processor/utils/postgres.util.js.map +0 -1
  969. package/dist/products/validators/joi-validators/create.product.validator.d.ts +0 -3
  970. package/dist/products/validators/joi-validators/create.product.validator.js +0 -10
  971. package/dist/products/validators/joi-validators/create.product.validator.js.map +0 -1
  972. package/dist/test.appBuilder.js +0 -14
  973. package/dist/test.appBuilder.js.map +0 -1
  974. package/dist/test.import.js +0 -24
  975. package/dist/test.import.js.map +0 -1
  976. package/dist/test.imports.js +0 -28
  977. package/dist/test.imports.js.map +0 -1
  978. package/dist/test.integrationBuilder.js +0 -276
  979. package/dist/test.integrationBuilder.js.map +0 -1
  980. package/dist/test.processor.js +0 -23
  981. package/dist/test.processor.js.map +0 -1
  982. package/dist/test.utils.js +0 -25
  983. package/dist/test.utils.js.map +0 -1
  984. package/dist/types/integrationsBuilder.types.d.ts +0 -276
  985. package/dist/types/integrationsBuilder.types.js +0 -51
  986. package/dist/types/integrationsBuilder.types.js.map +0 -1
  987. /package/dist/{actions/actions.repo.d.ts → pricing/pricing.repo.d.ts} +0 -0
  988. /package/dist/{appBuilder/validators/joi-validators/create.app.validator.d.ts → products/validators/joi-validators/create.productGraph.validator.d.ts} +0 -0
  989. /package/dist/{appBuilder/validators/joi-validators/update.validation.entityData.validator.d.ts → products/validators/joi-validators/update.productGraph.validator.d.ts} +0 -0
  990. /package/dist/{test.appBuilder.d.ts → test/test.broker.kafka.d.ts} +0 -0
  991. /package/dist/{test.imports.d.ts → test/test.broker.nats.d.ts} +0 -0
  992. /package/dist/{test.integrationBuilder.d.ts → test/test.broker.pubsub.d.ts} +0 -0
  993. /package/dist/{test.processor.d.ts → test/test.broker.rabbitmq.d.ts} +0 -0
  994. /package/dist/{test.utils.d.ts → test/test.broker.redis.d.ts} +0 -0
  995. /package/dist/{actions/actions.service.d.ts → test/test.health.d.ts} +0 -0
  996. /package/dist/{actions/utils/actions.util.read.d.ts → test/test.notifiers.d.ts} +0 -0
  997. /package/dist/{processor/utils/mongo.util.d.ts → test/test.products.d.ts} +0 -0
  998. /package/dist/{test.import.d.ts → types/request-tracker.interface.d.ts} +0 -0
@@ -0,0 +1,1421 @@
1
+ "use strict";
2
+ /**
3
+ * Migration Engine
4
+ *
5
+ * Manages database migrations including running migrations,
6
+ * rolling back, tracking migration history, and status checking.
7
+ *
8
+ * Executes platform-independent migration operations by translating
9
+ * them to database-specific commands via the adapter.
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.MigrationHelpers = exports.MigrationEngine = void 0;
46
+ const crypto = __importStar(require("crypto"));
47
+ const enums_1 = require("../types/enums");
48
+ const database_error_1 = require("../utils/database-error");
49
+ /**
50
+ * Migration tracking table/collection name
51
+ */
52
+ const MIGRATION_COLLECTION = '_ductape_migrations';
53
+ /**
54
+ * Migration Engine for managing database migrations
55
+ */
56
+ class MigrationEngine {
57
+ constructor(adapter) {
58
+ this.adapter = adapter;
59
+ this.databaseType = adapter.getDatabaseType();
60
+ }
61
+ /**
62
+ * Execute a raw query using the adapter's raw() method
63
+ * This is a convenience wrapper that handles different query types
64
+ */
65
+ async rawQuery(query, params) {
66
+ try {
67
+ const result = await this.adapter.raw({
68
+ table: MIGRATION_COLLECTION,
69
+ query: query,
70
+ params: params,
71
+ });
72
+ return result;
73
+ }
74
+ catch (error) {
75
+ throw error;
76
+ }
77
+ }
78
+ // ==================== INITIALIZATION ====================
79
+ /**
80
+ * Initialize migration tracking collection if it doesn't exist
81
+ */
82
+ async initialize() {
83
+ const exists = await this.adapter.tableExists(MIGRATION_COLLECTION);
84
+ if (exists)
85
+ return;
86
+ // Create migration tracking collection using raw operations
87
+ await this.createMigrationTrackingCollection();
88
+ }
89
+ async createMigrationTrackingCollection() {
90
+ switch (this.databaseType) {
91
+ case enums_1.DatabaseType.POSTGRESQL:
92
+ case enums_1.DatabaseType.MYSQL:
93
+ case enums_1.DatabaseType.MARIADB:
94
+ await this.createSQLMigrationTable();
95
+ break;
96
+ case enums_1.DatabaseType.MONGODB:
97
+ await this.createMongoMigrationCollection();
98
+ break;
99
+ case enums_1.DatabaseType.DYNAMODB:
100
+ await this.createDynamoMigrationTable();
101
+ break;
102
+ case enums_1.DatabaseType.CASSANDRA:
103
+ await this.createCassandraMigrationTable();
104
+ break;
105
+ }
106
+ }
107
+ async createSQLMigrationTable() {
108
+ const escapedTable = this.escapeIdentifier(MIGRATION_COLLECTION);
109
+ const sql = `
110
+ CREATE TABLE IF NOT EXISTS ${escapedTable} (
111
+ id ${this.databaseType === enums_1.DatabaseType.POSTGRESQL ? 'SERIAL' : 'INT AUTO_INCREMENT'} PRIMARY KEY,
112
+ tag VARCHAR(255) NOT NULL UNIQUE,
113
+ name VARCHAR(255) NOT NULL,
114
+ applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
115
+ applied_by VARCHAR(255),
116
+ checksum VARCHAR(64),
117
+ execution_time INT
118
+ )
119
+ `;
120
+ await this.rawQuery(sql);
121
+ }
122
+ async createMongoMigrationCollection() {
123
+ // MongoDB will auto-create the collection on first insert
124
+ // But we can create it explicitly with validation
125
+ try {
126
+ await this.rawQuery({
127
+ create: MIGRATION_COLLECTION,
128
+ validator: {
129
+ $jsonSchema: {
130
+ bsonType: 'object',
131
+ required: ['tag', 'name', 'applied_at'],
132
+ properties: {
133
+ tag: { bsonType: 'string' },
134
+ name: { bsonType: 'string' },
135
+ applied_at: { bsonType: 'date' },
136
+ applied_by: { bsonType: 'string' },
137
+ checksum: { bsonType: 'string' },
138
+ execution_time: { bsonType: 'int' },
139
+ },
140
+ },
141
+ },
142
+ });
143
+ // Create unique index on tag
144
+ await this.rawQuery({
145
+ createIndexes: MIGRATION_COLLECTION,
146
+ indexes: [{ key: { tag: 1 }, unique: true, name: 'tag_unique' }],
147
+ });
148
+ }
149
+ catch (error) {
150
+ // Collection might already exist
151
+ }
152
+ }
153
+ async createDynamoMigrationTable() {
154
+ await this.rawQuery({
155
+ operation: 'CreateTable',
156
+ params: {
157
+ TableName: MIGRATION_COLLECTION,
158
+ KeySchema: [{ AttributeName: 'tag', KeyType: 'HASH' }],
159
+ AttributeDefinitions: [{ AttributeName: 'tag', AttributeType: 'S' }],
160
+ BillingMode: 'PAY_PER_REQUEST',
161
+ },
162
+ });
163
+ }
164
+ async createCassandraMigrationTable() {
165
+ const sql = `
166
+ CREATE TABLE IF NOT EXISTS ${MIGRATION_COLLECTION} (
167
+ tag text PRIMARY KEY,
168
+ name text,
169
+ applied_at timestamp,
170
+ applied_by text,
171
+ checksum text,
172
+ execution_time int
173
+ )
174
+ `;
175
+ await this.rawQuery(sql);
176
+ }
177
+ // ==================== MIGRATION EXECUTION ====================
178
+ /**
179
+ * Run all pending migrations
180
+ */
181
+ async migrate(migrations, options) {
182
+ await this.initialize();
183
+ const results = new Map();
184
+ const pending = await this.getPendingMigrations(migrations);
185
+ const sorted = this.sortByDependencies(pending);
186
+ for (const migration of sorted) {
187
+ if (options === null || options === void 0 ? void 0 : options.dryRun) {
188
+ results.set(migration.tag, {
189
+ success: true,
190
+ operations: migration.up.map(op => this.getOperationDescription(op)),
191
+ executionTime: 0,
192
+ });
193
+ continue;
194
+ }
195
+ const result = await this.runMigration(migration, 'up', options === null || options === void 0 ? void 0 : options.appliedBy);
196
+ results.set(migration.tag, result);
197
+ if (!result.success) {
198
+ break;
199
+ }
200
+ }
201
+ return results;
202
+ }
203
+ /**
204
+ * Run a single migration
205
+ */
206
+ async runMigration(migration, direction, appliedBy) {
207
+ const startTime = Date.now();
208
+ const operations = [];
209
+ try {
210
+ const ops = direction === 'up' ? migration.up : migration.down;
211
+ for (const operation of ops) {
212
+ const description = this.getOperationDescription(operation);
213
+ operations.push(description);
214
+ await this.executeOperation(operation);
215
+ }
216
+ const executionTime = Date.now() - startTime;
217
+ if (direction === 'up') {
218
+ await this.recordMigration(migration, appliedBy, executionTime);
219
+ }
220
+ else {
221
+ await this.removeMigrationRecord(migration.tag);
222
+ }
223
+ return { success: true, operations, executionTime };
224
+ }
225
+ catch (error) {
226
+ return {
227
+ success: false,
228
+ operations,
229
+ error: error.message,
230
+ executionTime: Date.now() - startTime,
231
+ };
232
+ }
233
+ }
234
+ /**
235
+ * Rollback the last N migrations
236
+ */
237
+ async rollback(migrations, count = 1) {
238
+ await this.initialize();
239
+ const results = new Map();
240
+ const applied = await this.getAppliedMigrations();
241
+ const toRollback = applied.slice(-count);
242
+ for (const history of toRollback.reverse()) {
243
+ const migration = migrations.find(m => m.tag === history.tag);
244
+ if (!migration) {
245
+ results.set(history.tag, {
246
+ success: false,
247
+ operations: [],
248
+ error: `Migration definition not found for tag: ${history.tag}`,
249
+ });
250
+ continue;
251
+ }
252
+ const result = await this.runMigration(migration, 'down');
253
+ results.set(history.tag, result);
254
+ if (!result.success)
255
+ break;
256
+ }
257
+ return results;
258
+ }
259
+ /**
260
+ * Rollback all migrations
261
+ */
262
+ async rollbackAll(migrations) {
263
+ const applied = await this.getAppliedMigrations();
264
+ return this.rollback(migrations, applied.length);
265
+ }
266
+ /**
267
+ * Reset database (rollback all and re-run all migrations)
268
+ */
269
+ async reset(migrations) {
270
+ const rollbackResults = await this.rollbackAll(migrations);
271
+ const migrateResults = await this.migrate(migrations);
272
+ return { rollback: rollbackResults, migrate: migrateResults };
273
+ }
274
+ // ==================== STATUS & HISTORY ====================
275
+ async getStatus(migrations) {
276
+ await this.initialize();
277
+ const applied = await this.getAppliedMigrations();
278
+ const appliedTags = new Set(applied.map(m => m.tag));
279
+ const pendingMigrations = migrations.filter(m => !appliedTags.has(m.tag)).map(m => m.tag);
280
+ return {
281
+ total: migrations.length,
282
+ completed: applied.length,
283
+ pending: pendingMigrations.length,
284
+ lastApplied: applied[applied.length - 1] || undefined,
285
+ pendingMigrations,
286
+ appliedMigrations: applied.map(m => m.tag),
287
+ };
288
+ }
289
+ async getAppliedMigrations() {
290
+ await this.initialize();
291
+ try {
292
+ const result = await this.adapter.query({
293
+ options: {
294
+ table: MIGRATION_COLLECTION,
295
+ orderBy: { column: 'applied_at', order: 'ASC' },
296
+ },
297
+ });
298
+ return (result.data || []).map((row) => ({
299
+ tag: row.tag,
300
+ name: row.name,
301
+ appliedAt: new Date(row.applied_at || row.appliedAt),
302
+ appliedBy: row.applied_by || row.appliedBy,
303
+ checksum: row.checksum,
304
+ executionTime: row.execution_time || row.executionTime,
305
+ }));
306
+ }
307
+ catch (error) {
308
+ return [];
309
+ }
310
+ }
311
+ async getPendingMigrations(migrations) {
312
+ const applied = await this.getAppliedMigrations();
313
+ const appliedTags = new Set(applied.map(m => m.tag));
314
+ const pendingMigrations = [];
315
+ for (const migration of migrations) {
316
+ // If migration was never applied, it's pending
317
+ if (!appliedTags.has(migration.tag)) {
318
+ pendingMigrations.push(migration);
319
+ continue;
320
+ }
321
+ // For createCollection migrations, verify the table actually exists
322
+ // If it doesn't exist (e.g., was manually dropped), re-apply the migration
323
+ const createOp = migration.up.find(op => op.type === 'createCollection');
324
+ if (createOp) {
325
+ try {
326
+ const tableExists = await this.tableExists(createOp.name);
327
+ if (!tableExists) {
328
+ // Table doesn't exist but migration was marked as applied
329
+ // Remove the stale migration record and mark as pending
330
+ await this.removeMigrationRecord(migration.tag);
331
+ pendingMigrations.push(migration);
332
+ }
333
+ }
334
+ catch (_a) {
335
+ // If we can't check, assume it needs to be re-applied
336
+ await this.removeMigrationRecord(migration.tag);
337
+ pendingMigrations.push(migration);
338
+ }
339
+ }
340
+ }
341
+ return pendingMigrations;
342
+ }
343
+ /**
344
+ * Check if a table exists in the database
345
+ */
346
+ async tableExists(tableName) {
347
+ var _a, _b, _c;
348
+ try {
349
+ switch (this.databaseType) {
350
+ case enums_1.DatabaseType.POSTGRESQL:
351
+ const pgResult = await this.rawQuery(`SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = '${tableName}')`);
352
+ return ((_a = pgResult === null || pgResult === void 0 ? void 0 : pgResult[0]) === null || _a === void 0 ? void 0 : _a.exists) === true;
353
+ case enums_1.DatabaseType.MYSQL:
354
+ case enums_1.DatabaseType.MARIADB:
355
+ const mysqlResult = await this.rawQuery(`SHOW TABLES LIKE '${tableName}'`);
356
+ return Array.isArray(mysqlResult) && mysqlResult.length > 0;
357
+ case enums_1.DatabaseType.MONGODB:
358
+ const collections = await this.rawQuery({ listCollections: 1, nameOnly: true });
359
+ return ((_c = (_b = collections === null || collections === void 0 ? void 0 : collections.cursor) === null || _b === void 0 ? void 0 : _b.firstBatch) === null || _c === void 0 ? void 0 : _c.some((c) => c.name === tableName)) || false;
360
+ default:
361
+ return true; // Assume exists for other databases
362
+ }
363
+ }
364
+ catch (_d) {
365
+ return true; // On error, assume exists to avoid accidental re-creation
366
+ }
367
+ }
368
+ async isMigrationApplied(tag) {
369
+ await this.initialize();
370
+ const applied = await this.getAppliedMigrations();
371
+ return applied.some(m => m.tag === tag);
372
+ }
373
+ // ==================== OPERATION EXECUTION ====================
374
+ async executeOperation(operation) {
375
+ switch (operation.type) {
376
+ // Common operations
377
+ case 'createCollection':
378
+ await this.executeCreateCollection(operation);
379
+ break;
380
+ case 'dropCollection':
381
+ await this.executeDropCollection(operation);
382
+ break;
383
+ case 'createIndex':
384
+ await this.executeCreateIndex(operation);
385
+ break;
386
+ case 'dropIndex':
387
+ await this.executeDropIndex(operation);
388
+ break;
389
+ case 'addField':
390
+ await this.executeAddField(operation);
391
+ break;
392
+ case 'dropField':
393
+ await this.executeDropField(operation);
394
+ break;
395
+ case 'renameField':
396
+ await this.executeRenameField(operation);
397
+ break;
398
+ case 'modifyField':
399
+ await this.executeModifyField(operation);
400
+ break;
401
+ // SQL-specific
402
+ case 'addConstraint':
403
+ await this.executeAddConstraint(operation);
404
+ break;
405
+ case 'dropConstraint':
406
+ await this.executeDropConstraint(operation);
407
+ break;
408
+ // MongoDB-specific
409
+ case 'createMongoValidation':
410
+ await this.executeCreateMongoValidation(operation);
411
+ break;
412
+ case 'dropMongoValidation':
413
+ await this.executeDropMongoValidation(operation);
414
+ break;
415
+ case 'shardCollection':
416
+ await this.executeShardCollection(operation);
417
+ break;
418
+ // DynamoDB-specific
419
+ case 'createDynamoTable':
420
+ await this.executeCreateDynamoTable(operation);
421
+ break;
422
+ case 'updateDynamoThroughput':
423
+ await this.executeUpdateDynamoThroughput(operation);
424
+ break;
425
+ case 'addDynamoGSI':
426
+ await this.executeAddDynamoGSI(operation);
427
+ break;
428
+ case 'removeDynamoGSI':
429
+ await this.executeRemoveDynamoGSI(operation);
430
+ break;
431
+ case 'enableDynamoStream':
432
+ await this.executeEnableDynamoStream(operation);
433
+ break;
434
+ case 'enableDynamoTTL':
435
+ await this.executeEnableDynamoTTL(operation);
436
+ break;
437
+ // Cassandra-specific
438
+ case 'alterCassandraTable':
439
+ await this.executeAlterCassandraTable(operation);
440
+ break;
441
+ case 'createCassandraMaterializedView':
442
+ await this.executeCreateCassandraMaterializedView(operation);
443
+ break;
444
+ case 'dropCassandraMaterializedView':
445
+ await this.executeDropCassandraMaterializedView(operation);
446
+ break;
447
+ // Raw operations
448
+ case 'raw':
449
+ await this.executeRawOperation(operation);
450
+ break;
451
+ default:
452
+ throw database_error_1.DatabaseError.migrationError(`Unknown migration operation type: ${operation.type}`);
453
+ }
454
+ }
455
+ // ==================== COMMON OPERATION EXECUTORS ====================
456
+ async executeCreateCollection(op) {
457
+ switch (this.databaseType) {
458
+ case enums_1.DatabaseType.POSTGRESQL:
459
+ case enums_1.DatabaseType.MYSQL:
460
+ case enums_1.DatabaseType.MARIADB:
461
+ await this.createSQLTable(op);
462
+ break;
463
+ case enums_1.DatabaseType.MONGODB:
464
+ await this.createMongoCollection(op);
465
+ break;
466
+ case enums_1.DatabaseType.DYNAMODB:
467
+ await this.createDynamoTable(op);
468
+ break;
469
+ case enums_1.DatabaseType.CASSANDRA:
470
+ await this.createCassandraTable(op);
471
+ break;
472
+ }
473
+ }
474
+ async executeDropCollection(op) {
475
+ switch (this.databaseType) {
476
+ case enums_1.DatabaseType.POSTGRESQL:
477
+ case enums_1.DatabaseType.MYSQL:
478
+ case enums_1.DatabaseType.MARIADB:
479
+ let sql = 'DROP TABLE';
480
+ if (op.ifExists)
481
+ sql += ' IF EXISTS';
482
+ sql += ` ${this.escapeIdentifier(op.name)}`;
483
+ if (op.cascade)
484
+ sql += ' CASCADE';
485
+ await this.rawQuery(sql);
486
+ break;
487
+ case enums_1.DatabaseType.MONGODB:
488
+ await this.rawQuery({ drop: op.name });
489
+ break;
490
+ case enums_1.DatabaseType.DYNAMODB:
491
+ await this.rawQuery({
492
+ operation: 'DeleteTable',
493
+ params: { TableName: op.name },
494
+ });
495
+ break;
496
+ case enums_1.DatabaseType.CASSANDRA:
497
+ await this.rawQuery(`DROP TABLE ${op.ifExists ? 'IF EXISTS ' : ''}${op.name}`);
498
+ break;
499
+ }
500
+ }
501
+ async executeCreateIndex(op) {
502
+ switch (this.databaseType) {
503
+ case enums_1.DatabaseType.POSTGRESQL:
504
+ case enums_1.DatabaseType.MYSQL:
505
+ case enums_1.DatabaseType.MARIADB:
506
+ await this.createSQLIndex(op);
507
+ break;
508
+ case enums_1.DatabaseType.MONGODB:
509
+ await this.createMongoIndex(op);
510
+ break;
511
+ case enums_1.DatabaseType.CASSANDRA:
512
+ await this.createCassandraIndex(op);
513
+ break;
514
+ case enums_1.DatabaseType.DYNAMODB:
515
+ // DynamoDB indexes are created with the table or via GSI
516
+ break;
517
+ }
518
+ }
519
+ async executeDropIndex(op) {
520
+ switch (this.databaseType) {
521
+ case enums_1.DatabaseType.POSTGRESQL:
522
+ let pgSql = 'DROP INDEX';
523
+ if (op.ifExists)
524
+ pgSql += ' IF EXISTS';
525
+ if (op.concurrent)
526
+ pgSql += ' CONCURRENTLY';
527
+ pgSql += ` ${this.escapeIdentifier(op.name)}`;
528
+ await this.rawQuery(pgSql);
529
+ break;
530
+ case enums_1.DatabaseType.MYSQL:
531
+ case enums_1.DatabaseType.MARIADB:
532
+ await this.rawQuery(`DROP INDEX ${this.escapeIdentifier(op.name)} ON ${this.escapeIdentifier(op.collection)}`);
533
+ break;
534
+ case enums_1.DatabaseType.MONGODB:
535
+ await this.rawQuery({
536
+ dropIndexes: op.collection,
537
+ index: op.name,
538
+ });
539
+ break;
540
+ case enums_1.DatabaseType.CASSANDRA:
541
+ await this.rawQuery(`DROP INDEX ${op.ifExists ? 'IF EXISTS ' : ''}${op.name}`);
542
+ break;
543
+ }
544
+ }
545
+ async executeAddField(op) {
546
+ switch (this.databaseType) {
547
+ case enums_1.DatabaseType.POSTGRESQL:
548
+ case enums_1.DatabaseType.MYSQL:
549
+ case enums_1.DatabaseType.MARIADB:
550
+ const colDef = this.buildColumnDefinition(op.field);
551
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} ADD COLUMN ${colDef}`);
552
+ break;
553
+ case enums_1.DatabaseType.MONGODB:
554
+ // MongoDB is schemaless - fields are added on write
555
+ // Optionally update validator
556
+ break;
557
+ case enums_1.DatabaseType.CASSANDRA:
558
+ const cassDef = this.buildCassandraColumnDefinition(op.field);
559
+ await this.rawQuery(`ALTER TABLE ${op.collection} ADD ${cassDef}`);
560
+ break;
561
+ case enums_1.DatabaseType.DYNAMODB:
562
+ // DynamoDB is schemaless - fields are added on write
563
+ break;
564
+ }
565
+ }
566
+ async executeDropField(op) {
567
+ switch (this.databaseType) {
568
+ case enums_1.DatabaseType.POSTGRESQL:
569
+ case enums_1.DatabaseType.MYSQL:
570
+ case enums_1.DatabaseType.MARIADB:
571
+ let sql = `ALTER TABLE ${this.escapeIdentifier(op.collection)} DROP COLUMN ${this.escapeIdentifier(op.fieldName)}`;
572
+ if (op.cascade)
573
+ sql += ' CASCADE';
574
+ await this.rawQuery(sql);
575
+ break;
576
+ case enums_1.DatabaseType.MONGODB:
577
+ // Use $unset to remove field from all documents
578
+ await this.rawQuery({
579
+ update: op.collection,
580
+ updates: [{ q: {}, u: { $unset: { [op.fieldName]: '' } }, multi: true }],
581
+ });
582
+ break;
583
+ case enums_1.DatabaseType.CASSANDRA:
584
+ await this.rawQuery(`ALTER TABLE ${op.collection} DROP ${op.fieldName}`);
585
+ break;
586
+ }
587
+ }
588
+ async executeRenameField(op) {
589
+ switch (this.databaseType) {
590
+ case enums_1.DatabaseType.POSTGRESQL:
591
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} RENAME COLUMN ${this.escapeIdentifier(op.oldName)} TO ${this.escapeIdentifier(op.newName)}`);
592
+ break;
593
+ case enums_1.DatabaseType.MYSQL:
594
+ case enums_1.DatabaseType.MARIADB:
595
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} RENAME COLUMN ${this.escapeIdentifier(op.oldName)} TO ${this.escapeIdentifier(op.newName)}`);
596
+ break;
597
+ case enums_1.DatabaseType.MONGODB:
598
+ await this.rawQuery({
599
+ update: op.collection,
600
+ updates: [{ q: {}, u: { $rename: { [op.oldName]: op.newName } }, multi: true }],
601
+ });
602
+ break;
603
+ case enums_1.DatabaseType.CASSANDRA:
604
+ await this.rawQuery(`ALTER TABLE ${op.collection} RENAME ${op.oldName} TO ${op.newName}`);
605
+ break;
606
+ }
607
+ }
608
+ async executeModifyField(op) {
609
+ switch (this.databaseType) {
610
+ case enums_1.DatabaseType.POSTGRESQL:
611
+ if (op.changes.type) {
612
+ const pgType = this.mapFieldTypeToSQL(op.changes.type, op.changes);
613
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} ALTER COLUMN ${this.escapeIdentifier(op.fieldName)} TYPE ${pgType}`);
614
+ }
615
+ if (op.changes.nullable === false) {
616
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} ALTER COLUMN ${this.escapeIdentifier(op.fieldName)} SET NOT NULL`);
617
+ }
618
+ else if (op.changes.nullable === true) {
619
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} ALTER COLUMN ${this.escapeIdentifier(op.fieldName)} DROP NOT NULL`);
620
+ }
621
+ if (op.changes.defaultValue !== undefined) {
622
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} ALTER COLUMN ${this.escapeIdentifier(op.fieldName)} SET DEFAULT ${this.formatValue(op.changes.defaultValue)}`);
623
+ }
624
+ break;
625
+ case enums_1.DatabaseType.MYSQL:
626
+ case enums_1.DatabaseType.MARIADB:
627
+ // MySQL requires full column definition for MODIFY
628
+ const mysqlType = this.mapFieldTypeToSQL(op.changes.type || 'string', op.changes);
629
+ await this.rawQuery(`ALTER TABLE ${this.escapeIdentifier(op.collection)} MODIFY COLUMN ${this.escapeIdentifier(op.fieldName)} ${mysqlType}`);
630
+ break;
631
+ case enums_1.DatabaseType.MONGODB:
632
+ // MongoDB doesn't have schema modification - data is flexible
633
+ break;
634
+ case enums_1.DatabaseType.CASSANDRA:
635
+ if (op.changes.type) {
636
+ const cassType = this.mapFieldTypeToCassandra(op.changes.type);
637
+ await this.rawQuery(`ALTER TABLE ${op.collection} ALTER ${op.fieldName} TYPE ${cassType}`);
638
+ }
639
+ break;
640
+ }
641
+ }
642
+ // ==================== SQL-SPECIFIC EXECUTORS ====================
643
+ async executeAddConstraint(op) {
644
+ if (!this.isSQLDatabase()) {
645
+ throw database_error_1.DatabaseError.migrationError('addConstraint is only supported for SQL databases');
646
+ }
647
+ const constraint = op.constraint;
648
+ let sql = `ALTER TABLE ${this.escapeIdentifier(op.collection)} ADD CONSTRAINT ${this.escapeIdentifier(constraint.name)}`;
649
+ switch (constraint.type) {
650
+ case 'primaryKey':
651
+ sql += ` PRIMARY KEY (${constraint.columns.map(c => this.escapeIdentifier(c)).join(', ')})`;
652
+ break;
653
+ case 'foreignKey':
654
+ sql += ` FOREIGN KEY (${constraint.columns.map(c => this.escapeIdentifier(c)).join(', ')})`;
655
+ if (constraint.references) {
656
+ sql += ` REFERENCES ${this.escapeIdentifier(constraint.references.table)} (${constraint.references.columns.map(c => this.escapeIdentifier(c)).join(', ')})`;
657
+ if (constraint.references.onDelete)
658
+ sql += ` ON DELETE ${constraint.references.onDelete}`;
659
+ if (constraint.references.onUpdate)
660
+ sql += ` ON UPDATE ${constraint.references.onUpdate}`;
661
+ }
662
+ break;
663
+ case 'unique':
664
+ sql += ` UNIQUE (${constraint.columns.map(c => this.escapeIdentifier(c)).join(', ')})`;
665
+ break;
666
+ case 'check':
667
+ sql += ` CHECK (${constraint.expression})`;
668
+ break;
669
+ }
670
+ await this.rawQuery(sql);
671
+ }
672
+ async executeDropConstraint(op) {
673
+ if (!this.isSQLDatabase()) {
674
+ throw database_error_1.DatabaseError.migrationError('dropConstraint is only supported for SQL databases');
675
+ }
676
+ let sql = `ALTER TABLE ${this.escapeIdentifier(op.collection)} DROP CONSTRAINT ${this.escapeIdentifier(op.constraintName)}`;
677
+ if (op.cascade)
678
+ sql += ' CASCADE';
679
+ await this.rawQuery(sql);
680
+ }
681
+ // ==================== MONGODB-SPECIFIC EXECUTORS ====================
682
+ async executeCreateMongoValidation(op) {
683
+ if (this.databaseType !== enums_1.DatabaseType.MONGODB) {
684
+ throw database_error_1.DatabaseError.migrationError('createMongoValidation is only supported for MongoDB');
685
+ }
686
+ await this.rawQuery({
687
+ collMod: op.collection,
688
+ validator: op.validator,
689
+ validationLevel: op.validationLevel || 'strict',
690
+ validationAction: op.validationAction || 'error',
691
+ });
692
+ }
693
+ async executeDropMongoValidation(op) {
694
+ if (this.databaseType !== enums_1.DatabaseType.MONGODB) {
695
+ throw database_error_1.DatabaseError.migrationError('dropMongoValidation is only supported for MongoDB');
696
+ }
697
+ await this.rawQuery({
698
+ collMod: op.collection,
699
+ validator: {},
700
+ validationLevel: 'off',
701
+ });
702
+ }
703
+ async executeShardCollection(op) {
704
+ if (this.databaseType !== enums_1.DatabaseType.MONGODB) {
705
+ throw database_error_1.DatabaseError.migrationError('shardCollection is only supported for MongoDB');
706
+ }
707
+ await this.rawQuery({
708
+ shardCollection: op.collection,
709
+ key: op.shardKey,
710
+ unique: op.unique,
711
+ });
712
+ }
713
+ // ==================== DYNAMODB-SPECIFIC EXECUTORS ====================
714
+ async executeCreateDynamoTable(op) {
715
+ if (this.databaseType !== enums_1.DatabaseType.DYNAMODB) {
716
+ throw database_error_1.DatabaseError.migrationError('createDynamoTable is only supported for DynamoDB');
717
+ }
718
+ const params = {
719
+ TableName: op.name,
720
+ KeySchema: [{ AttributeName: op.partitionKey.name, KeyType: 'HASH' }],
721
+ AttributeDefinitions: [{ AttributeName: op.partitionKey.name, AttributeType: op.partitionKey.type }],
722
+ BillingMode: op.billingMode || 'PAY_PER_REQUEST',
723
+ };
724
+ if (op.sortKey) {
725
+ params.KeySchema.push({ AttributeName: op.sortKey.name, KeyType: 'RANGE' });
726
+ params.AttributeDefinitions.push({ AttributeName: op.sortKey.name, AttributeType: op.sortKey.type });
727
+ }
728
+ if (op.billingMode === 'PROVISIONED') {
729
+ params.ProvisionedThroughput = {
730
+ ReadCapacityUnits: op.readCapacity || 5,
731
+ WriteCapacityUnits: op.writeCapacity || 5,
732
+ };
733
+ }
734
+ if (op.globalSecondaryIndexes) {
735
+ params.GlobalSecondaryIndexes = op.globalSecondaryIndexes.map(gsi => this.buildDynamoGSI(gsi, op.billingMode));
736
+ // Add attribute definitions for GSI keys
737
+ for (const gsi of op.globalSecondaryIndexes) {
738
+ if (!params.AttributeDefinitions.find((a) => a.AttributeName === gsi.partitionKey.name)) {
739
+ params.AttributeDefinitions.push({ AttributeName: gsi.partitionKey.name, AttributeType: gsi.partitionKey.type });
740
+ }
741
+ if (gsi.sortKey && !params.AttributeDefinitions.find((a) => a.AttributeName === gsi.sortKey.name)) {
742
+ params.AttributeDefinitions.push({ AttributeName: gsi.sortKey.name, AttributeType: gsi.sortKey.type });
743
+ }
744
+ }
745
+ }
746
+ if (op.localSecondaryIndexes) {
747
+ params.LocalSecondaryIndexes = op.localSecondaryIndexes.map(lsi => ({
748
+ IndexName: lsi.name,
749
+ KeySchema: [
750
+ { AttributeName: op.partitionKey.name, KeyType: 'HASH' },
751
+ { AttributeName: lsi.sortKey.name, KeyType: 'RANGE' },
752
+ ],
753
+ Projection: this.buildDynamoProjection(lsi.projection),
754
+ }));
755
+ // Add attribute definitions for LSI sort keys
756
+ for (const lsi of op.localSecondaryIndexes) {
757
+ if (!params.AttributeDefinitions.find((a) => a.AttributeName === lsi.sortKey.name)) {
758
+ params.AttributeDefinitions.push({ AttributeName: lsi.sortKey.name, AttributeType: lsi.sortKey.type });
759
+ }
760
+ }
761
+ }
762
+ if (op.streamEnabled) {
763
+ params.StreamSpecification = {
764
+ StreamEnabled: true,
765
+ StreamViewType: op.streamViewType || 'NEW_AND_OLD_IMAGES',
766
+ };
767
+ }
768
+ await this.rawQuery({ operation: 'CreateTable', params });
769
+ }
770
+ async executeUpdateDynamoThroughput(op) {
771
+ if (this.databaseType !== enums_1.DatabaseType.DYNAMODB) {
772
+ throw database_error_1.DatabaseError.migrationError('updateDynamoThroughput is only supported for DynamoDB');
773
+ }
774
+ const params = { TableName: op.name };
775
+ if (op.billingMode) {
776
+ params.BillingMode = op.billingMode;
777
+ }
778
+ if (op.billingMode === 'PROVISIONED' && (op.readCapacity || op.writeCapacity)) {
779
+ params.ProvisionedThroughput = {
780
+ ReadCapacityUnits: op.readCapacity || 5,
781
+ WriteCapacityUnits: op.writeCapacity || 5,
782
+ };
783
+ }
784
+ await this.rawQuery({ operation: 'UpdateTable', params });
785
+ }
786
+ async executeAddDynamoGSI(op) {
787
+ if (this.databaseType !== enums_1.DatabaseType.DYNAMODB) {
788
+ throw database_error_1.DatabaseError.migrationError('addDynamoGSI is only supported for DynamoDB');
789
+ }
790
+ const params = {
791
+ TableName: op.tableName,
792
+ AttributeDefinitions: [
793
+ { AttributeName: op.gsi.partitionKey.name, AttributeType: op.gsi.partitionKey.type },
794
+ ],
795
+ GlobalSecondaryIndexUpdates: [{
796
+ Create: this.buildDynamoGSI(op.gsi),
797
+ }],
798
+ };
799
+ if (op.gsi.sortKey) {
800
+ params.AttributeDefinitions.push({ AttributeName: op.gsi.sortKey.name, AttributeType: op.gsi.sortKey.type });
801
+ }
802
+ await this.rawQuery({ operation: 'UpdateTable', params });
803
+ }
804
+ async executeRemoveDynamoGSI(op) {
805
+ if (this.databaseType !== enums_1.DatabaseType.DYNAMODB) {
806
+ throw database_error_1.DatabaseError.migrationError('removeDynamoGSI is only supported for DynamoDB');
807
+ }
808
+ await this.rawQuery({
809
+ operation: 'UpdateTable',
810
+ params: {
811
+ TableName: op.tableName,
812
+ GlobalSecondaryIndexUpdates: [{ Delete: { IndexName: op.gsiName } }],
813
+ },
814
+ });
815
+ }
816
+ async executeEnableDynamoStream(op) {
817
+ if (this.databaseType !== enums_1.DatabaseType.DYNAMODB) {
818
+ throw database_error_1.DatabaseError.migrationError('enableDynamoStream is only supported for DynamoDB');
819
+ }
820
+ await this.rawQuery({
821
+ operation: 'UpdateTable',
822
+ params: {
823
+ TableName: op.tableName,
824
+ StreamSpecification: {
825
+ StreamEnabled: true,
826
+ StreamViewType: op.streamViewType,
827
+ },
828
+ },
829
+ });
830
+ }
831
+ async executeEnableDynamoTTL(op) {
832
+ if (this.databaseType !== enums_1.DatabaseType.DYNAMODB) {
833
+ throw database_error_1.DatabaseError.migrationError('enableDynamoTTL is only supported for DynamoDB');
834
+ }
835
+ await this.rawQuery({
836
+ operation: 'UpdateTimeToLive',
837
+ params: {
838
+ TableName: op.tableName,
839
+ TimeToLiveSpecification: {
840
+ AttributeName: op.attributeName,
841
+ Enabled: op.enabled,
842
+ },
843
+ },
844
+ });
845
+ }
846
+ // ==================== CASSANDRA-SPECIFIC EXECUTORS ====================
847
+ async executeAlterCassandraTable(op) {
848
+ if (this.databaseType !== enums_1.DatabaseType.CASSANDRA) {
849
+ throw database_error_1.DatabaseError.migrationError('alterCassandraTable is only supported for Cassandra');
850
+ }
851
+ const options = [];
852
+ if (op.options.defaultTTL !== undefined)
853
+ options.push(`default_time_to_live = ${op.options.defaultTTL}`);
854
+ if (op.options.gcGraceSeconds !== undefined)
855
+ options.push(`gc_grace_seconds = ${op.options.gcGraceSeconds}`);
856
+ if (op.options.compaction)
857
+ options.push(`compaction = ${JSON.stringify(op.options.compaction)}`);
858
+ if (op.options.compression)
859
+ options.push(`compression = ${JSON.stringify(op.options.compression)}`);
860
+ if (op.options.caching)
861
+ options.push(`caching = ${JSON.stringify(op.options.caching)}`);
862
+ if (options.length > 0) {
863
+ await this.rawQuery(`ALTER TABLE ${op.name} WITH ${options.join(' AND ')}`);
864
+ }
865
+ }
866
+ async executeCreateCassandraMaterializedView(op) {
867
+ if (this.databaseType !== enums_1.DatabaseType.CASSANDRA) {
868
+ throw database_error_1.DatabaseError.migrationError('createCassandraMaterializedView is only supported for Cassandra');
869
+ }
870
+ const pk = op.partitionKey.join(', ');
871
+ const clustering = op.clusteringColumns ? `, ${op.clusteringColumns.join(', ')}` : '';
872
+ await this.rawQuery(`
873
+ CREATE MATERIALIZED VIEW ${op.name} AS
874
+ SELECT ${op.columns.join(', ')}
875
+ FROM ${op.baseTable}
876
+ WHERE ${op.where}
877
+ PRIMARY KEY ((${pk})${clustering})
878
+ `);
879
+ }
880
+ async executeDropCassandraMaterializedView(op) {
881
+ if (this.databaseType !== enums_1.DatabaseType.CASSANDRA) {
882
+ throw database_error_1.DatabaseError.migrationError('dropCassandraMaterializedView is only supported for Cassandra');
883
+ }
884
+ await this.rawQuery(`DROP MATERIALIZED VIEW ${op.ifExists ? 'IF EXISTS ' : ''}${op.name}`);
885
+ }
886
+ // ==================== RAW OPERATION EXECUTOR ====================
887
+ async executeRawOperation(op) {
888
+ const dbType = this.databaseType.toLowerCase();
889
+ const dbOp = op.operations[dbType];
890
+ if (!dbOp) {
891
+ if (op.databases && !op.databases.includes(dbType)) {
892
+ // Skip if database not in target list
893
+ return;
894
+ }
895
+ throw database_error_1.DatabaseError.migrationError(`No raw operation defined for database type: ${dbType}`);
896
+ }
897
+ if ('sql' in dbOp) {
898
+ await this.rawQuery(dbOp.sql, dbOp.params);
899
+ }
900
+ else if ('cql' in dbOp) {
901
+ await this.rawQuery(dbOp.cql, dbOp.params);
902
+ }
903
+ else if ('command' in dbOp) {
904
+ await this.rawQuery(dbOp.command);
905
+ }
906
+ else if ('operation' in dbOp) {
907
+ await this.rawQuery(dbOp);
908
+ }
909
+ }
910
+ // ==================== HELPER METHODS ====================
911
+ async createSQLTable(op) {
912
+ var _a, _b, _c, _d;
913
+ const columns = op.fields.map(f => this.buildColumnDefinition(f));
914
+ const constraints = [];
915
+ // Handle composite primary key
916
+ const pkFields = op.fields.filter(f => f.primaryKey);
917
+ if (pkFields.length > 1) {
918
+ const pkNames = pkFields.map(f => this.escapeIdentifier(f.name)).join(', ');
919
+ constraints.push(`PRIMARY KEY (${pkNames})`);
920
+ }
921
+ else if ((_a = op.sqlOptions) === null || _a === void 0 ? void 0 : _a.primaryKey) {
922
+ constraints.push(`PRIMARY KEY (${op.sqlOptions.primaryKey.map(c => this.escapeIdentifier(c)).join(', ')})`);
923
+ }
924
+ // Add constraints from options
925
+ if ((_b = op.sqlOptions) === null || _b === void 0 ? void 0 : _b.constraints) {
926
+ for (const c of op.sqlOptions.constraints) {
927
+ const constraintSQL = this.buildConstraintSQL(c);
928
+ constraints.push(constraintSQL);
929
+ }
930
+ }
931
+ let sql = 'CREATE';
932
+ if ((_c = op.sqlOptions) === null || _c === void 0 ? void 0 : _c.temporary)
933
+ sql += ' TEMPORARY';
934
+ if (((_d = op.sqlOptions) === null || _d === void 0 ? void 0 : _d.unlogged) && this.databaseType === enums_1.DatabaseType.POSTGRESQL)
935
+ sql += ' UNLOGGED';
936
+ sql += ' TABLE';
937
+ if (op.ifNotExists)
938
+ sql += ' IF NOT EXISTS';
939
+ sql += ` ${this.escapeIdentifier(op.name)} (${[...columns, ...constraints].join(', ')})`;
940
+ await this.rawQuery(sql);
941
+ }
942
+ async createMongoCollection(op) {
943
+ var _a, _b;
944
+ const createCmd = { create: op.name };
945
+ if ((_a = op.mongoOptions) === null || _a === void 0 ? void 0 : _a.capped) {
946
+ createCmd.capped = true;
947
+ if (op.mongoOptions.size)
948
+ createCmd.size = op.mongoOptions.size;
949
+ if (op.mongoOptions.max)
950
+ createCmd.max = op.mongoOptions.max;
951
+ }
952
+ if ((_b = op.mongoOptions) === null || _b === void 0 ? void 0 : _b.validator) {
953
+ createCmd.validator = op.mongoOptions.validator;
954
+ if (op.mongoOptions.validationLevel)
955
+ createCmd.validationLevel = op.mongoOptions.validationLevel;
956
+ }
957
+ try {
958
+ await this.rawQuery(createCmd);
959
+ }
960
+ catch (error) {
961
+ // Collection might already exist
962
+ if (!error.message.includes('already exists'))
963
+ throw error;
964
+ }
965
+ // Process fields: create unique indexes and register auto-increment fields
966
+ if (op.fields) {
967
+ for (const field of op.fields) {
968
+ // Create unique index for fields marked as unique (excluding _id which is already unique)
969
+ if (field.unique && field.name !== '_id') {
970
+ await this.createMongoUniqueIndex(op.name, field.name);
971
+ }
972
+ // Register auto-increment fields in the _ductape_counters collection
973
+ if (field.autoGenerate) {
974
+ await this.registerMongoAutoIncrementField(op.name, field.name);
975
+ }
976
+ }
977
+ }
978
+ // Store schema metadata for default values and other app-level features
979
+ if (op.fields && op.fields.length > 0) {
980
+ await this.storeMongoSchemaMetadata(op.name, op.fields);
981
+ }
982
+ }
983
+ /**
984
+ * Create a unique index on a MongoDB collection field.
985
+ */
986
+ async createMongoUniqueIndex(collectionName, fieldName) {
987
+ try {
988
+ await this.rawQuery({
989
+ createIndexes: collectionName,
990
+ indexes: [{
991
+ key: { [fieldName]: 1 },
992
+ name: `${collectionName}_${fieldName}_unique`,
993
+ unique: true
994
+ }]
995
+ });
996
+ }
997
+ catch (error) {
998
+ // Index might already exist - ignore this error
999
+ const errMsg = error.message || '';
1000
+ if (!errMsg.includes('already exists') && !errMsg.includes('duplicate key')) {
1001
+ throw error;
1002
+ }
1003
+ }
1004
+ }
1005
+ /**
1006
+ * Register an auto-increment field in the MongoDB counters collection.
1007
+ * Uses atomic operations to ensure thread safety.
1008
+ */
1009
+ async registerMongoAutoIncrementField(collectionName, fieldName) {
1010
+ await this.rawQuery({
1011
+ findAndModify: '_ductape_counters',
1012
+ query: { _id: `${collectionName}.${fieldName}` },
1013
+ update: {
1014
+ $setOnInsert: {
1015
+ collection: collectionName,
1016
+ field: fieldName,
1017
+ currentValue: 0
1018
+ }
1019
+ },
1020
+ upsert: true
1021
+ });
1022
+ }
1023
+ /**
1024
+ * Store schema metadata for MongoDB collections.
1025
+ * This enables application-level features like default values.
1026
+ */
1027
+ async storeMongoSchemaMetadata(collectionName, fields) {
1028
+ await this.rawQuery({
1029
+ findAndModify: '_ductape_schema',
1030
+ query: { _id: collectionName },
1031
+ update: {
1032
+ $set: {
1033
+ collection: collectionName,
1034
+ columns: fields.map(f => ({
1035
+ name: f.name,
1036
+ type: f.type,
1037
+ defaultValue: f.defaultValue,
1038
+ nullable: f.nullable,
1039
+ unique: f.unique,
1040
+ primaryKey: f.primaryKey,
1041
+ autoIncrement: f.autoGenerate,
1042
+ })),
1043
+ updatedAt: new Date()
1044
+ }
1045
+ },
1046
+ upsert: true
1047
+ });
1048
+ }
1049
+ async createDynamoTable(op) {
1050
+ if (!op.dynamoOptions) {
1051
+ throw database_error_1.DatabaseError.migrationError('DynamoDB requires dynamoOptions with partitionKey');
1052
+ }
1053
+ // Convert to ICreateDynamoTableMigration format
1054
+ await this.executeCreateDynamoTable(Object.assign({ type: 'createDynamoTable', name: op.name }, op.dynamoOptions));
1055
+ }
1056
+ async createCassandraTable(op) {
1057
+ if (!op.cassandraOptions) {
1058
+ throw database_error_1.DatabaseError.migrationError('Cassandra requires cassandraOptions with partitionKey');
1059
+ }
1060
+ const columns = op.fields.map(f => this.buildCassandraColumnDefinition(f));
1061
+ const pk = op.cassandraOptions.partitionKey.join(', ');
1062
+ const clustering = op.cassandraOptions.clusteringColumns
1063
+ ? `, ${op.cassandraOptions.clusteringColumns.join(', ')}`
1064
+ : '';
1065
+ let sql = `CREATE TABLE ${op.ifNotExists ? 'IF NOT EXISTS ' : ''}${op.name} (${columns.join(', ')}, PRIMARY KEY ((${pk})${clustering}))`;
1066
+ const withClauses = [];
1067
+ if (op.cassandraOptions.clusteringOrder) {
1068
+ const order = op.cassandraOptions.clusteringOrder.map(o => `${o.column} ${o.order}`).join(', ');
1069
+ withClauses.push(`CLUSTERING ORDER BY (${order})`);
1070
+ }
1071
+ if (op.cassandraOptions.defaultTTL) {
1072
+ withClauses.push(`default_time_to_live = ${op.cassandraOptions.defaultTTL}`);
1073
+ }
1074
+ if (withClauses.length > 0) {
1075
+ sql += ` WITH ${withClauses.join(' AND ')}`;
1076
+ }
1077
+ await this.rawQuery(sql);
1078
+ }
1079
+ async createSQLIndex(op) {
1080
+ var _a, _b, _c, _d;
1081
+ let sql = 'CREATE';
1082
+ if (op.unique)
1083
+ sql += ' UNIQUE';
1084
+ sql += ' INDEX';
1085
+ if (op.ifNotExists && this.databaseType === enums_1.DatabaseType.POSTGRESQL)
1086
+ sql += ' IF NOT EXISTS';
1087
+ if (((_a = op.sqlOptions) === null || _a === void 0 ? void 0 : _a.concurrent) && this.databaseType === enums_1.DatabaseType.POSTGRESQL)
1088
+ sql += ' CONCURRENTLY';
1089
+ sql += ` ${this.escapeIdentifier(op.name)} ON ${this.escapeIdentifier(op.collection)}`;
1090
+ if (((_b = op.sqlOptions) === null || _b === void 0 ? void 0 : _b.method) && this.databaseType === enums_1.DatabaseType.POSTGRESQL) {
1091
+ sql += ` USING ${op.sqlOptions.method}`;
1092
+ }
1093
+ sql += ` (${op.fields.map(f => `${this.escapeIdentifier(f.name)}${f.order ? ' ' + f.order.toUpperCase() : ''}`).join(', ')})`;
1094
+ if (((_c = op.sqlOptions) === null || _c === void 0 ? void 0 : _c.include) && this.databaseType === enums_1.DatabaseType.POSTGRESQL) {
1095
+ sql += ` INCLUDE (${op.sqlOptions.include.map(c => this.escapeIdentifier(c)).join(', ')})`;
1096
+ }
1097
+ if (((_d = op.sqlOptions) === null || _d === void 0 ? void 0 : _d.where) && this.databaseType === enums_1.DatabaseType.POSTGRESQL) {
1098
+ sql += ` WHERE ${op.sqlOptions.where}`;
1099
+ }
1100
+ await this.rawQuery(sql);
1101
+ }
1102
+ async createMongoIndex(op) {
1103
+ var _a, _b, _c;
1104
+ const keys = {};
1105
+ for (const f of op.fields) {
1106
+ keys[f.name] = f.type === 'text' ? 'text' : (f.order === 'desc' ? -1 : 1);
1107
+ }
1108
+ const indexOptions = { name: op.name };
1109
+ if (op.unique)
1110
+ indexOptions.unique = true;
1111
+ if (op.sparse)
1112
+ indexOptions.sparse = true;
1113
+ if ((_a = op.mongoOptions) === null || _a === void 0 ? void 0 : _a.background)
1114
+ indexOptions.background = true;
1115
+ if (((_b = op.mongoOptions) === null || _b === void 0 ? void 0 : _b.expireAfterSeconds) !== undefined) {
1116
+ indexOptions.expireAfterSeconds = op.mongoOptions.expireAfterSeconds;
1117
+ }
1118
+ if ((_c = op.mongoOptions) === null || _c === void 0 ? void 0 : _c.weights)
1119
+ indexOptions.weights = op.mongoOptions.weights;
1120
+ await this.rawQuery({
1121
+ createIndexes: op.collection,
1122
+ indexes: [Object.assign({ key: keys }, indexOptions)],
1123
+ });
1124
+ }
1125
+ async createCassandraIndex(op) {
1126
+ var _a;
1127
+ const field = op.fields[0]; // Cassandra secondary indexes are single-column
1128
+ let sql = `CREATE INDEX ${op.ifNotExists ? 'IF NOT EXISTS ' : ''}${op.name} ON ${op.collection} (${field.name})`;
1129
+ if ((_a = op.cassandraOptions) === null || _a === void 0 ? void 0 : _a.sasiOptions) {
1130
+ const opts = op.cassandraOptions.sasiOptions;
1131
+ const using = [];
1132
+ if (opts.mode)
1133
+ using.push(`'mode': '${opts.mode}'`);
1134
+ if (opts.analyzerClass)
1135
+ using.push(`'analyzer_class': '${opts.analyzerClass}'`);
1136
+ if (opts.caseSensitive !== undefined)
1137
+ using.push(`'case_sensitive': '${opts.caseSensitive}'`);
1138
+ sql += ` USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {${using.join(', ')}}`;
1139
+ }
1140
+ await this.rawQuery(sql);
1141
+ }
1142
+ buildColumnDefinition(field) {
1143
+ const parts = [this.escapeIdentifier(field.name)];
1144
+ parts.push(this.mapFieldTypeToSQL(field.type, field));
1145
+ if (field.primaryKey && !field.autoGenerate)
1146
+ parts.push('PRIMARY KEY');
1147
+ if (field.autoGenerate) {
1148
+ if (this.databaseType === enums_1.DatabaseType.POSTGRESQL) {
1149
+ // Already handled in type mapping (SERIAL)
1150
+ }
1151
+ else {
1152
+ parts.push('AUTO_INCREMENT');
1153
+ if (field.primaryKey)
1154
+ parts.push('PRIMARY KEY');
1155
+ }
1156
+ }
1157
+ if (field.nullable === false && !field.primaryKey)
1158
+ parts.push('NOT NULL');
1159
+ if (field.unique && !field.primaryKey)
1160
+ parts.push('UNIQUE');
1161
+ if (field.defaultValue !== undefined)
1162
+ parts.push(`DEFAULT ${this.formatValue(field.defaultValue)}`);
1163
+ return parts.join(' ');
1164
+ }
1165
+ buildCassandraColumnDefinition(field) {
1166
+ return `${field.name} ${this.mapFieldTypeToCassandra(field.type)}`;
1167
+ }
1168
+ buildConstraintSQL(constraint) {
1169
+ let sql = `CONSTRAINT ${this.escapeIdentifier(constraint.name)}`;
1170
+ switch (constraint.type) {
1171
+ case 'primaryKey':
1172
+ sql += ` PRIMARY KEY (${constraint.columns.map((c) => this.escapeIdentifier(c)).join(', ')})`;
1173
+ break;
1174
+ case 'unique':
1175
+ sql += ` UNIQUE (${constraint.columns.map((c) => this.escapeIdentifier(c)).join(', ')})`;
1176
+ break;
1177
+ case 'foreignKey':
1178
+ sql += ` FOREIGN KEY (${constraint.columns.map((c) => this.escapeIdentifier(c)).join(', ')})`;
1179
+ if (constraint.references) {
1180
+ sql += ` REFERENCES ${this.escapeIdentifier(constraint.references.table)} (${constraint.references.columns.map((c) => this.escapeIdentifier(c)).join(', ')})`;
1181
+ }
1182
+ break;
1183
+ case 'check':
1184
+ sql += ` CHECK (${constraint.expression})`;
1185
+ break;
1186
+ }
1187
+ return sql;
1188
+ }
1189
+ buildDynamoGSI(gsi, billingMode) {
1190
+ const result = {
1191
+ IndexName: gsi.name,
1192
+ KeySchema: [{ AttributeName: gsi.partitionKey.name, KeyType: 'HASH' }],
1193
+ Projection: this.buildDynamoProjection(gsi.projection),
1194
+ };
1195
+ if (gsi.sortKey) {
1196
+ result.KeySchema.push({ AttributeName: gsi.sortKey.name, KeyType: 'RANGE' });
1197
+ }
1198
+ if (billingMode === 'PROVISIONED') {
1199
+ result.ProvisionedThroughput = {
1200
+ ReadCapacityUnits: gsi.readCapacity || 5,
1201
+ WriteCapacityUnits: gsi.writeCapacity || 5,
1202
+ };
1203
+ }
1204
+ return result;
1205
+ }
1206
+ buildDynamoProjection(projection) {
1207
+ if (projection === 'ALL')
1208
+ return { ProjectionType: 'ALL' };
1209
+ if (projection === 'KEYS_ONLY')
1210
+ return { ProjectionType: 'KEYS_ONLY' };
1211
+ if (typeof projection === 'object' && projection.type === 'INCLUDE') {
1212
+ return { ProjectionType: 'INCLUDE', NonKeyAttributes: projection.attributes };
1213
+ }
1214
+ return { ProjectionType: 'ALL' };
1215
+ }
1216
+ mapFieldTypeToSQL(type, options) {
1217
+ const isPG = this.databaseType === enums_1.DatabaseType.POSTGRESQL;
1218
+ switch (type) {
1219
+ case 'integer':
1220
+ if ((options === null || options === void 0 ? void 0 : options.autoGenerate) && isPG)
1221
+ return 'SERIAL';
1222
+ return 'INTEGER';
1223
+ case 'bigint':
1224
+ if ((options === null || options === void 0 ? void 0 : options.autoGenerate) && isPG)
1225
+ return 'BIGSERIAL';
1226
+ return 'BIGINT';
1227
+ case 'smallint': return 'SMALLINT';
1228
+ case 'decimal': return `DECIMAL(${(options === null || options === void 0 ? void 0 : options.precision) || 10}, ${(options === null || options === void 0 ? void 0 : options.scale) || 2})`;
1229
+ case 'float': return 'REAL';
1230
+ case 'double': return 'DOUBLE PRECISION';
1231
+ case 'string': return `VARCHAR(${(options === null || options === void 0 ? void 0 : options.maxLength) || 255})`;
1232
+ case 'text': return 'TEXT';
1233
+ case 'uuid': return isPG ? 'UUID' : 'CHAR(36)';
1234
+ case 'boolean': return 'BOOLEAN';
1235
+ case 'date': return 'DATE';
1236
+ case 'time': return 'TIME';
1237
+ case 'datetime': return isPG ? 'TIMESTAMP' : 'DATETIME';
1238
+ case 'timestamp': return isPG ? 'TIMESTAMPTZ' : 'TIMESTAMP';
1239
+ case 'binary': return 'BYTEA';
1240
+ case 'blob': return isPG ? 'BYTEA' : 'BLOB';
1241
+ case 'json': return isPG ? 'JSONB' : 'JSON';
1242
+ case 'object': return isPG ? 'JSONB' : 'JSON';
1243
+ case 'array': return isPG ? `${this.mapFieldTypeToSQL((options === null || options === void 0 ? void 0 : options.arrayElementType) || 'string', {})}[]` : 'JSON';
1244
+ case 'enum': return (options === null || options === void 0 ? void 0 : options.enumValues) ? `ENUM(${options.enumValues.map(v => `'${v}'`).join(', ')})` : 'VARCHAR(255)';
1245
+ default: return 'VARCHAR(255)';
1246
+ }
1247
+ }
1248
+ mapFieldTypeToCassandra(type) {
1249
+ switch (type) {
1250
+ case 'integer': return 'int';
1251
+ case 'bigint': return 'bigint';
1252
+ case 'smallint': return 'smallint';
1253
+ case 'decimal': return 'decimal';
1254
+ case 'float': return 'float';
1255
+ case 'double': return 'double';
1256
+ case 'string': return 'text';
1257
+ case 'text': return 'text';
1258
+ case 'uuid': return 'uuid';
1259
+ case 'boolean': return 'boolean';
1260
+ case 'date': return 'date';
1261
+ case 'time': return 'time';
1262
+ case 'datetime': return 'timestamp';
1263
+ case 'timestamp': return 'timestamp';
1264
+ case 'binary': return 'blob';
1265
+ case 'blob': return 'blob';
1266
+ case 'json': return 'text';
1267
+ case 'object': return 'text';
1268
+ default: return 'text';
1269
+ }
1270
+ }
1271
+ isSQLDatabase() {
1272
+ return [enums_1.DatabaseType.POSTGRESQL, enums_1.DatabaseType.MYSQL, enums_1.DatabaseType.MARIADB].includes(this.databaseType);
1273
+ }
1274
+ async recordMigration(migration, appliedBy, executionTime) {
1275
+ const checksum = this.calculateChecksum(migration);
1276
+ await this.adapter.insert({
1277
+ table: MIGRATION_COLLECTION,
1278
+ data: {
1279
+ tag: migration.tag,
1280
+ name: migration.name,
1281
+ applied_at: new Date(),
1282
+ applied_by: appliedBy || null,
1283
+ checksum,
1284
+ execution_time: executionTime || null,
1285
+ },
1286
+ });
1287
+ }
1288
+ async removeMigrationRecord(tag) {
1289
+ await this.adapter.delete({
1290
+ table: MIGRATION_COLLECTION,
1291
+ where: { tag },
1292
+ });
1293
+ }
1294
+ calculateChecksum(migration) {
1295
+ const content = JSON.stringify({ tag: migration.tag, name: migration.name, up: migration.up, down: migration.down });
1296
+ return crypto.createHash('sha256').update(content).digest('hex').substring(0, 64);
1297
+ }
1298
+ sortByDependencies(migrations) {
1299
+ const sorted = [];
1300
+ const visited = new Set();
1301
+ const visiting = new Set();
1302
+ const visit = (migration) => {
1303
+ if (visited.has(migration.tag))
1304
+ return;
1305
+ if (visiting.has(migration.tag)) {
1306
+ throw database_error_1.DatabaseError.migrationError(`Circular dependency detected in migration: ${migration.tag}`);
1307
+ }
1308
+ visiting.add(migration.tag);
1309
+ if (migration.dependencies) {
1310
+ for (const depTag of migration.dependencies) {
1311
+ const dep = migrations.find(m => m.tag === depTag);
1312
+ if (dep)
1313
+ visit(dep);
1314
+ }
1315
+ }
1316
+ visiting.delete(migration.tag);
1317
+ visited.add(migration.tag);
1318
+ sorted.push(migration);
1319
+ };
1320
+ for (const migration of migrations)
1321
+ visit(migration);
1322
+ return sorted;
1323
+ }
1324
+ getOperationDescription(operation) {
1325
+ switch (operation.type) {
1326
+ case 'createCollection': return `Create collection: ${operation.name}`;
1327
+ case 'dropCollection': return `Drop collection: ${operation.name}`;
1328
+ case 'createIndex': return `Create index: ${operation.name} on ${operation.collection}`;
1329
+ case 'dropIndex': return `Drop index: ${operation.name} from ${operation.collection}`;
1330
+ case 'addField': return `Add field: ${operation.field.name} to ${operation.collection}`;
1331
+ case 'dropField': return `Drop field: ${operation.fieldName} from ${operation.collection}`;
1332
+ case 'renameField': return `Rename field: ${operation.oldName} to ${operation.newName} in ${operation.collection}`;
1333
+ case 'modifyField': return `Modify field: ${operation.fieldName} in ${operation.collection}`;
1334
+ case 'addConstraint': return `Add constraint: ${operation.constraint.name} to ${operation.collection}`;
1335
+ case 'dropConstraint': return `Drop constraint: ${operation.constraintName} from ${operation.collection}`;
1336
+ case 'createMongoValidation': return `Create validation on: ${operation.collection}`;
1337
+ case 'dropMongoValidation': return `Drop validation from: ${operation.collection}`;
1338
+ case 'shardCollection': return `Shard collection: ${operation.collection}`;
1339
+ case 'createDynamoTable': return `Create DynamoDB table: ${operation.name}`;
1340
+ case 'updateDynamoThroughput': return `Update DynamoDB throughput: ${operation.name}`;
1341
+ case 'addDynamoGSI': return `Add GSI to: ${operation.tableName}`;
1342
+ case 'removeDynamoGSI': return `Remove GSI from: ${operation.tableName}`;
1343
+ case 'enableDynamoStream': return `Enable stream on: ${operation.tableName}`;
1344
+ case 'enableDynamoTTL': return `Enable TTL on: ${operation.tableName}`;
1345
+ case 'alterCassandraTable': return `Alter Cassandra table: ${operation.name}`;
1346
+ case 'createCassandraMaterializedView': return `Create materialized view: ${operation.name}`;
1347
+ case 'dropCassandraMaterializedView': return `Drop materialized view: ${operation.name}`;
1348
+ case 'raw': return 'Execute raw operation';
1349
+ default: return 'Unknown operation';
1350
+ }
1351
+ }
1352
+ escapeIdentifier(identifier) {
1353
+ switch (this.databaseType) {
1354
+ case enums_1.DatabaseType.POSTGRESQL: return `"${identifier.replace(/"/g, '""')}"`;
1355
+ case enums_1.DatabaseType.MYSQL:
1356
+ case enums_1.DatabaseType.MARIADB: return `\`${identifier.replace(/`/g, '``')}\``;
1357
+ case enums_1.DatabaseType.CASSANDRA:
1358
+ if (/[^a-zA-Z0-9_]/.test(identifier))
1359
+ return `"${identifier.replace(/"/g, '""')}"`;
1360
+ return identifier;
1361
+ default: return identifier;
1362
+ }
1363
+ }
1364
+ formatValue(value) {
1365
+ if (value === null)
1366
+ return 'NULL';
1367
+ if (typeof value === 'boolean')
1368
+ return value ? 'TRUE' : 'FALSE';
1369
+ if (typeof value === 'number')
1370
+ return String(value);
1371
+ if (typeof value === 'string') {
1372
+ const upperValue = value.toUpperCase();
1373
+ // Handle special datetime functions
1374
+ if (upperValue.startsWith('CURRENT_') || upperValue === 'NOW()')
1375
+ return value;
1376
+ // Handle 'now' as CURRENT_TIMESTAMP for datetime defaults
1377
+ if (upperValue === 'NOW')
1378
+ return 'CURRENT_TIMESTAMP';
1379
+ return `'${value.replace(/'/g, "''")}'`;
1380
+ }
1381
+ if (value instanceof Date)
1382
+ return `'${value.toISOString()}'`;
1383
+ return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
1384
+ }
1385
+ }
1386
+ exports.MigrationEngine = MigrationEngine;
1387
+ /**
1388
+ * Migration Helpers for creating common migrations
1389
+ */
1390
+ exports.MigrationHelpers = {
1391
+ generateMigrationTag(name) {
1392
+ const timestamp = new Date().toISOString().replace(/[-:T.Z]/g, '').substring(0, 14);
1393
+ const sanitizedName = name.toLowerCase().replace(/[^a-z0-9]/g, '_');
1394
+ return `${timestamp}_${sanitizedName}`;
1395
+ },
1396
+ createCollectionMigration(tag, name, fields) {
1397
+ return {
1398
+ tag,
1399
+ name: `Create collection ${name}`,
1400
+ up: [{ type: 'createCollection', name, fields }],
1401
+ down: [{ type: 'dropCollection', name, ifExists: true }],
1402
+ };
1403
+ },
1404
+ addFieldMigration(tag, collection, field) {
1405
+ return {
1406
+ tag,
1407
+ name: `Add field ${field.name} to ${collection}`,
1408
+ up: [{ type: 'addField', collection, field }],
1409
+ down: [{ type: 'dropField', collection, fieldName: field.name }],
1410
+ };
1411
+ },
1412
+ addIndexMigration(tag, collection, indexName, fields, unique) {
1413
+ return {
1414
+ tag,
1415
+ name: `Add index ${indexName} on ${collection}`,
1416
+ up: [{ type: 'createIndex', collection, name: indexName, fields: fields.map(f => ({ name: f })), unique }],
1417
+ down: [{ type: 'dropIndex', collection, name: indexName, ifExists: true }],
1418
+ };
1419
+ },
1420
+ };
1421
+ //# sourceMappingURL=migration-engine.js.map