@ductape/sdk 0.0.4-v51 → 0.0.4-v52

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