@dynamatix/gb-schemas 2.17.12 → 2.17.13

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 (385) hide show
  1. package/dist/applicants/applicant-additional-income.model.d.ts +378 -0
  2. package/dist/applicants/applicant-additional-income.model.d.ts.map +1 -0
  3. package/dist/applicants/applicant-additional-income.model.js +35 -0
  4. package/dist/applicants/applicant-additional-income.type.d.ts +40 -0
  5. package/dist/applicants/applicant-additional-income.type.d.ts.map +1 -0
  6. package/dist/applicants/applicant-additional-income.type.js +1 -0
  7. package/dist/applicants/applicant-commitment-creditCard.model.d.ts +545 -0
  8. package/dist/applicants/applicant-commitment-creditCard.model.d.ts.map +1 -0
  9. package/dist/applicants/applicant-commitment-creditCard.model.js +40 -0
  10. package/dist/applicants/applicant-commitment-loan.model.d.ts +434 -0
  11. package/dist/applicants/applicant-commitment-loan.model.d.ts.map +1 -0
  12. package/dist/applicants/applicant-commitment-loan.model.js +51 -0
  13. package/dist/applicants/applicant-commitment-mortgage.model.d.ts +506 -0
  14. package/dist/applicants/applicant-commitment-mortgage.model.d.ts.map +1 -0
  15. package/dist/applicants/applicant-commitment-mortgage.model.js +69 -0
  16. package/dist/applicants/applicant-commitment-residence.model.d.ts +768 -0
  17. package/dist/applicants/applicant-commitment-residence.model.d.ts.map +1 -0
  18. package/dist/applicants/applicant-commitment-residence.model.js +57 -0
  19. package/dist/applicants/applicant-commitment-secureLoan.model.d.ts +426 -0
  20. package/dist/applicants/applicant-commitment-secureLoan.model.d.ts.map +1 -0
  21. package/dist/applicants/applicant-commitment-secureLoan.model.js +43 -0
  22. package/dist/applicants/applicant-commitment-unsecuredLoan.model.d.ts +426 -0
  23. package/dist/applicants/applicant-commitment-unsecuredLoan.model.d.ts.map +1 -0
  24. package/dist/applicants/applicant-commitment-unsecuredLoan.model.js +43 -0
  25. package/dist/applicants/applicant-credit-data.model.d.ts +60 -0
  26. package/dist/applicants/applicant-credit-data.model.d.ts.map +1 -0
  27. package/dist/applicants/applicant-credit-data.model.js +11 -0
  28. package/dist/applicants/applicant-credit-profile.model.d.ts +51 -0
  29. package/dist/applicants/applicant-credit-profile.model.d.ts.map +1 -0
  30. package/dist/applicants/applicant-credit-profile.model.js +20 -0
  31. package/dist/applicants/applicant-credit-report.model.d.ts +3816 -0
  32. package/dist/applicants/applicant-credit-report.model.d.ts.map +1 -0
  33. package/dist/applicants/applicant-credit-report.model.js +126 -0
  34. package/dist/applicants/applicant-credit-report.type.d.ts +145 -0
  35. package/dist/applicants/applicant-credit-report.type.d.ts.map +1 -0
  36. package/dist/applicants/applicant-credit-report.type.js +1 -0
  37. package/dist/applicants/applicant-direct-debit.model.d.ts +86 -0
  38. package/dist/applicants/applicant-direct-debit.model.d.ts.map +1 -0
  39. package/dist/applicants/applicant-direct-debit.model.js +16 -0
  40. package/dist/applicants/applicant-employment-income.model.d.ts +206 -0
  41. package/dist/applicants/applicant-employment-income.model.d.ts.map +1 -0
  42. package/dist/applicants/applicant-employment-income.model.js +20 -0
  43. package/dist/applicants/applicant-employment-income.type.d.ts +37 -0
  44. package/dist/applicants/applicant-employment-income.type.d.ts.map +1 -0
  45. package/dist/applicants/applicant-employment-income.type.js +1 -0
  46. package/dist/applicants/applicant-employment.model.d.ts +828 -0
  47. package/dist/applicants/applicant-employment.model.d.ts.map +1 -0
  48. package/dist/applicants/applicant-employment.model.js +46 -0
  49. package/dist/applicants/applicant-expenditure.model.d.ts +127 -0
  50. package/dist/applicants/applicant-expenditure.model.d.ts.map +1 -0
  51. package/dist/applicants/applicant-expenditure.model.js +146 -0
  52. package/dist/applicants/applicant-expenditure.type.d.ts +42 -0
  53. package/dist/applicants/applicant-expenditure.type.d.ts.map +1 -0
  54. package/dist/applicants/applicant-expenditure.type.js +1 -0
  55. package/dist/applicants/applicant-income-settings.model.d.ts +82 -0
  56. package/dist/applicants/applicant-income-settings.model.d.ts.map +1 -0
  57. package/dist/applicants/applicant-income-settings.model.js +22 -0
  58. package/dist/applicants/applicant-income-settings.type.d.ts +40 -0
  59. package/dist/applicants/applicant-income-settings.type.d.ts.map +1 -0
  60. package/dist/applicants/applicant-income-settings.type.js +1 -0
  61. package/dist/applicants/applicant-income-summary.model.d.ts +2964 -0
  62. package/dist/applicants/applicant-income-summary.model.d.ts.map +1 -0
  63. package/dist/applicants/applicant-income-summary.model.js +59 -0
  64. package/dist/applicants/applicant-income-summary.type.d.ts +72 -0
  65. package/dist/applicants/applicant-income-summary.type.d.ts.map +1 -0
  66. package/dist/applicants/applicant-income-summary.type.js +1 -0
  67. package/dist/applicants/applicant-large-exposure.model.d.ts +667 -0
  68. package/dist/applicants/applicant-large-exposure.model.d.ts.map +1 -0
  69. package/dist/applicants/applicant-large-exposure.model.js +16 -0
  70. package/dist/applicants/applicant-large-exposure.type.d.ts +39 -0
  71. package/dist/applicants/applicant-large-exposure.type.d.ts.map +1 -0
  72. package/dist/applicants/applicant-large-exposure.type.js +1 -0
  73. package/dist/applicants/applicant-pension-income.model.d.ts +494 -0
  74. package/dist/applicants/applicant-pension-income.model.d.ts.map +1 -0
  75. package/dist/applicants/applicant-pension-income.model.js +35 -0
  76. package/dist/applicants/applicant-pension-income.type.d.ts +40 -0
  77. package/dist/applicants/applicant-pension-income.type.d.ts.map +1 -0
  78. package/dist/applicants/applicant-pension-income.type.js +1 -0
  79. package/dist/applicants/applicant-property-income.model.d.ts +953 -0
  80. package/dist/applicants/applicant-property-income.model.d.ts.map +1 -0
  81. package/dist/applicants/applicant-property-income.model.js +34 -0
  82. package/dist/applicants/applicant-property-income.type.d.ts +44 -0
  83. package/dist/applicants/applicant-property-income.type.d.ts.map +1 -0
  84. package/dist/applicants/applicant-property-income.type.js +1 -0
  85. package/dist/applicants/applicant-risk-narrative.model.d.ts +66 -0
  86. package/dist/applicants/applicant-risk-narrative.model.d.ts.map +1 -0
  87. package/dist/applicants/applicant-risk-narrative.model.js +13 -0
  88. package/dist/applicants/applicant-self-employed-income.model.d.ts +213 -0
  89. package/dist/applicants/applicant-self-employed-income.model.d.ts.map +1 -0
  90. package/dist/applicants/applicant-self-employed-income.model.js +23 -0
  91. package/dist/applicants/applicant-self-employed-income.type.d.ts +37 -0
  92. package/dist/applicants/applicant-self-employed-income.type.d.ts.map +1 -0
  93. package/dist/applicants/applicant-self-employed-income.type.js +1 -0
  94. package/dist/applicants/applicant-self-employment.model.d.ts +269 -0
  95. package/dist/applicants/applicant-self-employment.model.d.ts.map +1 -0
  96. package/dist/applicants/applicant-self-employment.model.js +55 -0
  97. package/dist/applicants/applicant-sole-trader-income.model.d.ts +213 -0
  98. package/dist/applicants/applicant-sole-trader-income.model.d.ts.map +1 -0
  99. package/dist/applicants/applicant-sole-trader-income.model.js +21 -0
  100. package/dist/applicants/applicant-sole-trader-income.type.d.ts +37 -0
  101. package/dist/applicants/applicant-sole-trader-income.type.d.ts.map +1 -0
  102. package/dist/applicants/applicant-sole-trader-income.type.js +1 -0
  103. package/dist/applicants/applicant-uk-tax-credits.model.d.ts +500 -0
  104. package/dist/applicants/applicant-uk-tax-credits.model.d.ts.map +1 -0
  105. package/dist/applicants/applicant-uk-tax-credits.model.js +21 -0
  106. package/dist/applicants/applicant-uk-tax-credits.type.d.ts +39 -0
  107. package/dist/applicants/applicant-uk-tax-credits.type.d.ts.map +1 -0
  108. package/dist/applicants/applicant-uk-tax-credits.type.js +1 -0
  109. package/dist/applicants/applicant-welcome-call.model.d.ts +384 -0
  110. package/dist/applicants/applicant-welcome-call.model.d.ts.map +1 -0
  111. package/dist/applicants/applicant-welcome-call.model.js +709 -0
  112. package/dist/applicants/applicant-welcome-call.type.d.ts +66 -0
  113. package/dist/applicants/applicant-welcome-call.type.d.ts.map +1 -0
  114. package/dist/applicants/applicant-welcome-call.type.js +1 -0
  115. package/dist/applicants/applicant.model.d.ts +1569 -0
  116. package/dist/applicants/applicant.model.d.ts.map +1 -0
  117. package/dist/applicants/applicant.model.js +262 -0
  118. package/dist/applicants/applicant.type.d.ts +161 -0
  119. package/dist/applicants/applicant.type.d.ts.map +1 -0
  120. package/dist/applicants/applicant.type.js +1 -0
  121. package/dist/applicants/index.d.ts +37 -0
  122. package/dist/applicants/index.d.ts.map +1 -0
  123. package/dist/applicants/index.js +22 -0
  124. package/dist/applications/application-audit.model.d.ts +120 -0
  125. package/dist/applications/application-audit.model.d.ts.map +1 -0
  126. package/dist/applications/application-audit.model.js +45 -0
  127. package/dist/applications/application-checklist-Item.model.d.ts +292 -0
  128. package/dist/applications/application-checklist-Item.model.d.ts.map +1 -0
  129. package/dist/applications/application-checklist-Item.model.js +49 -0
  130. package/dist/applications/application-company-model.d.ts +1548 -0
  131. package/dist/applications/application-company-model.d.ts.map +1 -0
  132. package/dist/applications/application-company-model.js +134 -0
  133. package/dist/applications/application-credit-profile.model.d.ts +63 -0
  134. package/dist/applications/application-credit-profile.model.d.ts.map +1 -0
  135. package/dist/applications/application-credit-profile.model.js +12 -0
  136. package/dist/applications/application-direct-debit.model.d.ts +697 -0
  137. package/dist/applications/application-direct-debit.model.d.ts.map +1 -0
  138. package/dist/applications/application-direct-debit.model.js +173 -0
  139. package/dist/applications/application-direct-debit.type.d.ts +63 -0
  140. package/dist/applications/application-direct-debit.type.d.ts.map +1 -0
  141. package/dist/applications/application-direct-debit.type.js +1 -0
  142. package/dist/applications/application-euc.model.d.ts +196 -0
  143. package/dist/applications/application-euc.model.d.ts.map +1 -0
  144. package/dist/applications/application-euc.model.js +39 -0
  145. package/dist/applications/application-euc.type.d.ts +58 -0
  146. package/dist/applications/application-euc.type.d.ts.map +1 -0
  147. package/dist/applications/application-euc.type.js +1 -0
  148. package/dist/applications/application-fieldconfig.model.d.ts +58 -0
  149. package/dist/applications/application-fieldconfig.model.d.ts.map +1 -0
  150. package/dist/applications/application-fieldconfig.model.js +10 -0
  151. package/dist/applications/application-illustration-model.d.ts +52 -0
  152. package/dist/applications/application-illustration-model.d.ts.map +1 -0
  153. package/dist/applications/application-illustration-model.js +6 -0
  154. package/dist/applications/application-legal.model.d.ts +58 -0
  155. package/dist/applications/application-legal.model.d.ts.map +1 -0
  156. package/dist/applications/application-legal.model.js +10 -0
  157. package/dist/applications/application-mortgage.model.d.ts +307 -0
  158. package/dist/applications/application-mortgage.model.d.ts.map +1 -0
  159. package/dist/applications/application-mortgage.model.js +274 -0
  160. package/dist/applications/application-mortgage.type.d.ts +76 -0
  161. package/dist/applications/application-mortgage.type.d.ts.map +1 -0
  162. package/dist/applications/application-mortgage.type.js +1 -0
  163. package/dist/applications/application-note.model.d.ts +184 -0
  164. package/dist/applications/application-note.model.d.ts.map +1 -0
  165. package/dist/applications/application-note.model.js +105 -0
  166. package/dist/applications/application-note.type.d.ts +55 -0
  167. package/dist/applications/application-note.type.d.ts.map +1 -0
  168. package/dist/applications/application-note.type.js +1 -0
  169. package/dist/applications/application-offer.model.d.ts +196 -0
  170. package/dist/applications/application-offer.model.d.ts.map +1 -0
  171. package/dist/applications/application-offer.model.js +56 -0
  172. package/dist/applications/application-offer.type.d.ts +54 -0
  173. package/dist/applications/application-offer.type.d.ts.map +1 -0
  174. package/dist/applications/application-offer.type.js +1 -0
  175. package/dist/applications/application-onboarding.model.d.ts +70 -0
  176. package/dist/applications/application-onboarding.model.d.ts.map +1 -0
  177. package/dist/applications/application-onboarding.model.js +12 -0
  178. package/dist/applications/application-product.model.d.ts +290 -0
  179. package/dist/applications/application-product.model.d.ts.map +1 -0
  180. package/dist/applications/application-product.model.js +90 -0
  181. package/dist/applications/application-product.type.d.ts +58 -0
  182. package/dist/applications/application-product.type.d.ts.map +1 -0
  183. package/dist/applications/application-product.type.js +1 -0
  184. package/dist/applications/application-productfeatures.model.d.ts +772 -0
  185. package/dist/applications/application-productfeatures.model.d.ts.map +1 -0
  186. package/dist/applications/application-productfeatures.model.js +100 -0
  187. package/dist/applications/application-productfeatures.type.d.ts +125 -0
  188. package/dist/applications/application-productfeatures.type.d.ts.map +1 -0
  189. package/dist/applications/application-productfeatures.type.js +1 -0
  190. package/dist/applications/application-rationale.model.d.ts +126 -0
  191. package/dist/applications/application-rationale.model.d.ts.map +1 -0
  192. package/dist/applications/application-rationale.model.js +23 -0
  193. package/dist/applications/application-rationale.type.d.ts +44 -0
  194. package/dist/applications/application-rationale.type.d.ts.map +1 -0
  195. package/dist/applications/application-rationale.type.js +1 -0
  196. package/dist/applications/application-risk-narrative.model.d.ts +100 -0
  197. package/dist/applications/application-risk-narrative.model.d.ts.map +1 -0
  198. package/dist/applications/application-risk-narrative.model.js +17 -0
  199. package/dist/applications/application-valuation-report.model.d.ts +1438 -0
  200. package/dist/applications/application-valuation-report.model.d.ts.map +1 -0
  201. package/dist/applications/application-valuation-report.model.js +799 -0
  202. package/dist/applications/application-valuation-report.type.d.ts +256 -0
  203. package/dist/applications/application-valuation-report.type.d.ts.map +1 -0
  204. package/dist/applications/application-valuation-report.type.js +1 -0
  205. package/dist/applications/application-valuation.model.d.ts +1358 -0
  206. package/dist/applications/application-valuation.model.d.ts.map +1 -0
  207. package/dist/applications/application-valuation.model.js +72 -0
  208. package/dist/applications/application-valuation.type.d.ts +55 -0
  209. package/dist/applications/application-valuation.type.d.ts.map +1 -0
  210. package/dist/applications/application-valuation.type.js +1 -0
  211. package/dist/applications/application.model.d.ts +642 -0
  212. package/dist/applications/application.model.d.ts.map +1 -0
  213. package/dist/applications/application.model.js +254 -0
  214. package/dist/applications/applications-task.model.d.ts +312 -0
  215. package/dist/applications/applications-task.model.d.ts.map +1 -0
  216. package/dist/applications/applications-task.model.js +58 -0
  217. package/dist/applications/applications-task.type.d.ts +59 -0
  218. package/dist/applications/applications-task.type.d.ts.map +1 -0
  219. package/dist/applications/applications-task.type.js +1 -0
  220. package/dist/applications/broker.model.d.ts +162 -0
  221. package/dist/applications/broker.model.d.ts.map +1 -0
  222. package/dist/applications/broker.model.js +24 -0
  223. package/dist/applications/broker.type.d.ts +51 -0
  224. package/dist/applications/broker.type.d.ts.map +1 -0
  225. package/dist/applications/broker.type.js +1 -0
  226. package/dist/applications/index.d.ts +36 -0
  227. package/dist/applications/index.d.ts.map +1 -0
  228. package/dist/applications/index.js +23 -0
  229. package/dist/applications/solicitor.model.d.ts +206 -0
  230. package/dist/applications/solicitor.model.d.ts.map +1 -0
  231. package/dist/applications/solicitor.model.js +121 -0
  232. package/dist/applications/solicitor.type.d.ts +56 -0
  233. package/dist/applications/solicitor.type.d.ts.map +1 -0
  234. package/dist/applications/solicitor.type.js +1 -0
  235. package/dist/index.d.ts +9 -0
  236. package/dist/index.d.ts.map +1 -0
  237. package/dist/index.js +9 -0
  238. package/dist/product-catalogues/index.d.ts +7 -0
  239. package/dist/product-catalogues/index.d.ts.map +1 -0
  240. package/dist/product-catalogues/index.js +3 -0
  241. package/dist/product-catalogues/product-catalogue.model.d.ts +132 -0
  242. package/dist/product-catalogues/product-catalogue.model.d.ts.map +1 -0
  243. package/dist/product-catalogues/product-catalogue.model.js +22 -0
  244. package/dist/product-catalogues/product-catalogue.type.d.ts +15 -0
  245. package/dist/product-catalogues/product-catalogue.type.d.ts.map +1 -0
  246. package/dist/product-catalogues/product-catalogue.type.js +1 -0
  247. package/dist/product-catalogues/product-definitions.model.d.ts +318 -0
  248. package/dist/product-catalogues/product-definitions.model.d.ts.map +1 -0
  249. package/dist/product-catalogues/product-definitions.model.js +29 -0
  250. package/dist/product-catalogues/product-definitions.type.d.ts +53 -0
  251. package/dist/product-catalogues/product-definitions.type.d.ts.map +1 -0
  252. package/dist/product-catalogues/product-definitions.type.js +1 -0
  253. package/dist/product-catalogues/product-variant.model.d.ts +96 -0
  254. package/dist/product-catalogues/product-variant.model.d.ts.map +1 -0
  255. package/dist/product-catalogues/product-variant.model.js +16 -0
  256. package/dist/product-catalogues/product-variant.type.d.ts +38 -0
  257. package/dist/product-catalogues/product-variant.type.d.ts.map +1 -0
  258. package/dist/product-catalogues/product-variant.type.js +1 -0
  259. package/dist/properties/index.d.ts +3 -0
  260. package/dist/properties/index.d.ts.map +1 -0
  261. package/dist/properties/index.js +2 -0
  262. package/dist/properties/property.model.d.ts +1174 -0
  263. package/dist/properties/property.model.d.ts.map +1 -0
  264. package/dist/properties/property.model.js +152 -0
  265. package/dist/properties/security.model.d.ts +331 -0
  266. package/dist/properties/security.model.d.ts.map +1 -0
  267. package/dist/properties/security.model.js +159 -0
  268. package/dist/shared/alert.model.d.ts +102 -0
  269. package/dist/shared/alert.model.d.ts.map +1 -0
  270. package/dist/shared/alert.model.js +24 -0
  271. package/dist/shared/api-log.model.d.ts +124 -0
  272. package/dist/shared/api-log.model.d.ts.map +1 -0
  273. package/dist/shared/api-log.model.js +25 -0
  274. package/dist/shared/api-performance.model.d.ts +37 -0
  275. package/dist/shared/api-performance.model.d.ts.map +1 -0
  276. package/dist/shared/api-performance.model.js +22 -0
  277. package/dist/shared/api-performance.type.d.ts +178 -0
  278. package/dist/shared/api-performance.type.d.ts.map +1 -0
  279. package/dist/shared/api-performance.type.js +1 -0
  280. package/dist/shared/apprivo-sync-journey.model.d.ts +114 -0
  281. package/dist/shared/apprivo-sync-journey.model.d.ts.map +1 -0
  282. package/dist/shared/apprivo-sync-journey.model.js +19 -0
  283. package/dist/shared/checklist.model.d.ts +102 -0
  284. package/dist/shared/checklist.model.d.ts.map +1 -0
  285. package/dist/shared/checklist.model.js +35 -0
  286. package/dist/shared/index.d.ts +19 -0
  287. package/dist/shared/index.d.ts.map +1 -0
  288. package/dist/shared/index.js +16 -0
  289. package/dist/shared/job-run.model.d.ts +76 -0
  290. package/dist/shared/job-run.model.d.ts.map +1 -0
  291. package/dist/shared/job-run.model.js +14 -0
  292. package/dist/shared/job-setting.model.d.ts +70 -0
  293. package/dist/shared/job-setting.model.d.ts.map +1 -0
  294. package/dist/shared/job-setting.model.js +11 -0
  295. package/dist/shared/lookup-group.model.d.ts +78 -0
  296. package/dist/shared/lookup-group.model.d.ts.map +1 -0
  297. package/dist/shared/lookup-group.model.js +22 -0
  298. package/dist/shared/lookup.model.d.ts +96 -0
  299. package/dist/shared/lookup.model.d.ts.map +1 -0
  300. package/dist/shared/lookup.model.js +32 -0
  301. package/dist/shared/schema-doc.model.d.ts +76 -0
  302. package/dist/shared/schema-doc.model.d.ts.map +1 -0
  303. package/dist/shared/schema-doc.model.js +11 -0
  304. package/dist/shared/system-parameter.model.d.ts +88 -0
  305. package/dist/shared/system-parameter.model.d.ts.map +1 -0
  306. package/dist/shared/system-parameter.model.js +32 -0
  307. package/dist/shared/task-document.model.d.ts +70 -0
  308. package/dist/shared/task-document.model.d.ts.map +1 -0
  309. package/dist/shared/task-document.model.js +23 -0
  310. package/dist/shared/task.model.d.ts +234 -0
  311. package/dist/shared/task.model.d.ts.map +1 -0
  312. package/dist/shared/task.model.js +15 -0
  313. package/dist/shared/webhook-event.model.d.ts +37 -0
  314. package/dist/shared/webhook-event.model.d.ts.map +1 -0
  315. package/dist/shared/webhook-event.model.js +57 -0
  316. package/dist/shared/webhook-event.type.d.ts +15 -0
  317. package/dist/shared/webhook-event.type.d.ts.map +1 -0
  318. package/dist/shared/webhook-event.type.js +1 -0
  319. package/dist/shared/workflow-trigger.model.d.ts +32 -0
  320. package/dist/shared/workflow-trigger.model.d.ts.map +1 -0
  321. package/dist/shared/workflow-trigger.model.js +49 -0
  322. package/dist/shared/workflow-trigger.type.d.ts +60 -0
  323. package/dist/shared/workflow-trigger.type.d.ts.map +1 -0
  324. package/dist/shared/workflow-trigger.type.js +1 -0
  325. package/dist/shared/workflow.init.d.ts +21 -0
  326. package/dist/shared/workflow.init.d.ts.map +1 -0
  327. package/dist/shared/workflow.init.js +42 -0
  328. package/dist/shared/workflow.logger.d.ts +18 -0
  329. package/dist/shared/workflow.logger.d.ts.map +1 -0
  330. package/dist/shared/workflow.logger.js +41 -0
  331. package/dist/shared/workflow.middleware.d.ts +108 -0
  332. package/dist/shared/workflow.middleware.d.ts.map +1 -0
  333. package/dist/shared/workflow.middleware.js +246 -0
  334. package/dist/shared/workflow.plugin.d.ts +46 -0
  335. package/dist/shared/workflow.plugin.d.ts.map +1 -0
  336. package/dist/shared/workflow.plugin.js +151 -0
  337. package/dist/shared/workflow.service.d.ts +42 -0
  338. package/dist/shared/workflow.service.d.ts.map +1 -0
  339. package/dist/shared/workflow.service.js +134 -0
  340. package/dist/types/base.types.d.ts +35 -0
  341. package/dist/types/base.types.d.ts.map +1 -0
  342. package/dist/types/base.types.js +1 -0
  343. package/dist/types/index.d.ts +2 -0
  344. package/dist/types/index.d.ts.map +1 -0
  345. package/dist/types/index.js +1 -0
  346. package/dist/underwriter/index.d.ts +2 -0
  347. package/dist/underwriter/index.d.ts.map +1 -0
  348. package/dist/underwriter/index.js +1 -0
  349. package/dist/underwriter/underwriter.model.d.ts +126 -0
  350. package/dist/underwriter/underwriter.model.d.ts.map +1 -0
  351. package/dist/underwriter/underwriter.model.js +17 -0
  352. package/dist/users/auth-log.model.d.ts +70 -0
  353. package/dist/users/auth-log.model.d.ts.map +1 -0
  354. package/dist/users/auth-log.model.js +24 -0
  355. package/dist/users/index.d.ts +7 -0
  356. package/dist/users/index.d.ts.map +1 -0
  357. package/dist/users/index.js +6 -0
  358. package/dist/users/permission.model.d.ts +84 -0
  359. package/dist/users/permission.model.d.ts.map +1 -0
  360. package/dist/users/permission.model.js +12 -0
  361. package/dist/users/role-group.model.d.ts +90 -0
  362. package/dist/users/role-group.model.d.ts.map +1 -0
  363. package/dist/users/role-group.model.js +17 -0
  364. package/dist/users/role.model.d.ts +90 -0
  365. package/dist/users/role.model.d.ts.map +1 -0
  366. package/dist/users/role.model.js +16 -0
  367. package/dist/users/tasks.model.d.ts +114 -0
  368. package/dist/users/tasks.model.d.ts.map +1 -0
  369. package/dist/users/tasks.model.js +18 -0
  370. package/dist/users/user.model.d.ts +222 -0
  371. package/dist/users/user.model.d.ts.map +1 -0
  372. package/dist/users/user.model.js +41 -0
  373. package/dist/users/user.type.d.ts +55 -0
  374. package/dist/users/user.type.d.ts.map +1 -0
  375. package/dist/users/user.type.js +1 -0
  376. package/dist/value-objects/account-number.d.ts +42 -0
  377. package/dist/value-objects/account-number.d.ts.map +1 -0
  378. package/dist/value-objects/account-number.js +24 -0
  379. package/dist/value-objects/pound.d.ts +43 -0
  380. package/dist/value-objects/pound.d.ts.map +1 -0
  381. package/dist/value-objects/pound.js +50 -0
  382. package/dist/value-objects/sort-code.d.ts +42 -0
  383. package/dist/value-objects/sort-code.d.ts.map +1 -0
  384. package/dist/value-objects/sort-code.js +34 -0
  385. package/package.json +1 -1
@@ -0,0 +1,246 @@
1
+ import WorkflowTriggerModel from './workflow-trigger.model.js';
2
+ import { WorkflowService } from './workflow.service.js';
3
+ // @ts-ignore - No type declarations available for @dynamatix/cat-shared/services
4
+ import { getContext as getSharedContext } from '@dynamatix/cat-shared/services';
5
+ import { workflowLog, workflowWarn, workflowError } from './workflow.logger.js';
6
+ export class WorkflowMiddleware {
7
+ constructor(options) {
8
+ // Read configuration from environment variables with fallbacks
9
+ this.options = {
10
+ workflowApiUrl: process.env.WORKFLOW_API_URL || 'https://your-workflow-api.com/api/v1/workflows/execute',
11
+ timeout: parseInt(process.env.WORKFLOW_TIMEOUT || '30000'),
12
+ retryAttempts: parseInt(process.env.WORKFLOW_RETRY_ATTEMPTS || '3'),
13
+ retryDelay: parseInt(process.env.WORKFLOW_RETRY_DELAY || '1000'),
14
+ ...options // Allow override of specific options
15
+ };
16
+ this.workflowService = new WorkflowService(this.options);
17
+ }
18
+ /**
19
+ * Safely gets the WorkflowTrigger model, handling potential registration issues
20
+ */
21
+ getWorkflowTriggerModel() {
22
+ try {
23
+ return WorkflowTriggerModel;
24
+ }
25
+ catch (error) {
26
+ workflowError('Error accessing WorkflowTrigger model:', error);
27
+ throw new Error('WorkflowTrigger model is not properly registered');
28
+ }
29
+ }
30
+ /**
31
+ * Gets the current request context including application_id and token
32
+ * @returns The current context object or null if not available
33
+ */
34
+ getContext() {
35
+ const context = getSharedContext();
36
+ if (context) {
37
+ return {
38
+ contextId: context.contextId,
39
+ token: context.token
40
+ };
41
+ }
42
+ return null;
43
+ }
44
+ /**
45
+ * Creates a Mongoose middleware function for a specific model
46
+ * @param recordType - The type of record (e.g., 'applications', 'products', 'tasks')
47
+ * @returns Mongoose middleware function
48
+ */
49
+ createMiddleware(recordType) {
50
+ return {
51
+ // Post-save middleware for create and update operations
52
+ postSave: async function (doc, next) {
53
+ try {
54
+ workflowLog('Post-save middleware for create and update operations');
55
+ const middleware = new WorkflowMiddleware(this.options || {});
56
+ await middleware.handleEvent({
57
+ recordType,
58
+ action: doc.isNew ? 'created' : 'updated',
59
+ triggerKey: `${recordType}.${doc.isNew ? 'created' : 'updated'}`
60
+ }, doc);
61
+ }
62
+ catch (error) {
63
+ workflowError('Workflow middleware error:', error);
64
+ // Don't throw error to avoid breaking the main operation
65
+ }
66
+ next();
67
+ }.bind(this),
68
+ // Post-remove middleware for delete operations
69
+ postRemove: async function (doc, next) {
70
+ try {
71
+ workflowLog('Post-remove middleware for delete operations');
72
+ const middleware = new WorkflowMiddleware(this.options || {});
73
+ await middleware.handleEvent({
74
+ recordType,
75
+ action: 'deleted',
76
+ triggerKey: `${recordType}.deleted`
77
+ }, doc);
78
+ }
79
+ catch (error) {
80
+ workflowError('Workflow middleware error:', error);
81
+ // Don't throw error to avoid breaking the main operation
82
+ }
83
+ next();
84
+ }.bind(this)
85
+ };
86
+ }
87
+ /**
88
+ * Handles a workflow trigger event
89
+ * @param event - The workflow trigger event
90
+ * @param document - The document that triggered the event
91
+ */
92
+ async handleEvent(event, document) {
93
+ try {
94
+ // Find active triggers for this event
95
+ workflowLog('Finding active triggers for this event');
96
+ const WorkflowTrigger = this.getWorkflowTriggerModel();
97
+ const triggers = await WorkflowTrigger.find({
98
+ triggerKey: event.triggerKey,
99
+ isActive: true
100
+ });
101
+ if (triggers.length === 0) {
102
+ workflowLog(`No active triggers found for ${event.triggerKey}`);
103
+ return;
104
+ }
105
+ // Process each trigger
106
+ workflowLog('Processing each trigger');
107
+ for (const trigger of triggers) {
108
+ await this.processTrigger(trigger, document, event);
109
+ }
110
+ }
111
+ catch (error) {
112
+ workflowError(`Error handling workflow event ${event.triggerKey}:`, error);
113
+ }
114
+ }
115
+ /**
116
+ * Processes a single workflow trigger
117
+ * @param trigger - The workflow trigger configuration
118
+ * @param document - The document that triggered the event
119
+ * @param event - The workflow trigger event
120
+ */
121
+ async processTrigger(trigger, document, event) {
122
+ try {
123
+ workflowLog('Processing trigger');
124
+ // Check if condition is met (if specified)
125
+ if (trigger.condition && !this.evaluateCondition(trigger.condition, document)) {
126
+ workflowLog(`Condition not met for trigger ${trigger.triggerKey}`);
127
+ return;
128
+ }
129
+ // Extract variables from document
130
+ workflowLog('Extracting variables from document');
131
+ workflowLog(` Required variables: ${JSON.stringify(trigger.requiredVariables)}`);
132
+ workflowLog(` Optional variables: ${JSON.stringify(trigger.optionalVariables || [])}`);
133
+ const variables = this.workflowService.extractVariables(trigger.requiredVariables, trigger.optionalVariables || [], document);
134
+ workflowLog(` Extracted variables: ${JSON.stringify(variables, null, 2)}`);
135
+ // Validate required variables
136
+ if (!this.workflowService.validateRequiredVariables(trigger.requiredVariables, variables)) {
137
+ workflowWarn(`❌ Required variables missing for trigger ${trigger.triggerKey}`);
138
+ workflowWarn(` Required: ${JSON.stringify(trigger.requiredVariables)}`);
139
+ workflowWarn(` Got: ${JSON.stringify(variables)}`);
140
+ return;
141
+ }
142
+ // Add metadata
143
+ const metadata = this.extractMetadata(document, event, trigger.parentKey);
144
+ workflowLog(` Metadata: ${JSON.stringify(metadata, null, 2)}`);
145
+ const enrichedVariables = {
146
+ ...variables,
147
+ ...metadata
148
+ };
149
+ // Create workflow payload
150
+ const payload = {
151
+ workflowKey: trigger.workflowKey,
152
+ version: 1, // Default version, could be made configurable
153
+ variables: enrichedVariables
154
+ };
155
+ workflowLog('📦 Workflow payload:', JSON.stringify(payload, null, 2));
156
+ // Get token from context
157
+ const context = this.getContext();
158
+ const token = context?.token;
159
+ // Trigger workflow in background
160
+ await this.workflowService.triggerWorkflow(payload, token);
161
+ workflowLog(`Workflow ${trigger.workflowKey} triggered for ${event.triggerKey}`);
162
+ }
163
+ catch (error) {
164
+ workflowError(`Error processing trigger ${trigger.triggerKey}:`, error);
165
+ }
166
+ }
167
+ /**
168
+ * Evaluates a condition against a document
169
+ * @param condition - The condition string to evaluate
170
+ * @param document - The document to evaluate against
171
+ * @returns true if condition is met
172
+ */
173
+ evaluateCondition(condition, document) {
174
+ try {
175
+ // Simple condition evaluation - could be enhanced with a proper expression parser
176
+ // For now, supporting basic field checks like "status === 'active'"
177
+ if (condition.includes('===')) {
178
+ const [field, value] = condition.split('===').map(s => s.trim());
179
+ const fieldValue = this.workflowService['getNestedValue'](document, field);
180
+ return fieldValue === value.replace(/['"]/g, '');
181
+ }
182
+ // Default to true if condition format is not recognized
183
+ return true;
184
+ }
185
+ catch (error) {
186
+ workflowError('Error evaluating condition:', error);
187
+ return false;
188
+ }
189
+ }
190
+ /**
191
+ * Extracts metadata from document and event
192
+ * @param document - The document
193
+ * @param event - The event
194
+ * @returns Metadata object
195
+ */
196
+ extractMetadata(document, event, parentKey) {
197
+ const context = this.getContext();
198
+ return {
199
+ source: event.recordType,
200
+ action: event.action,
201
+ triggerKey: event.triggerKey,
202
+ sourceId: document._id?.toString(),
203
+ parentSourceId: parentKey ? document[parentKey] : null,
204
+ timestamp: new Date().toISOString(),
205
+ contextId: context?.contextId,
206
+ };
207
+ }
208
+ /**
209
+ * Manually trigger a workflow for a specific document
210
+ * @param triggerKey - The trigger key to use
211
+ * @param document - The document to process
212
+ * @param recordType - The record type
213
+ */
214
+ async manualTrigger(triggerKey, document, recordType) {
215
+ const event = {
216
+ recordType,
217
+ action: 'manual',
218
+ triggerKey
219
+ };
220
+ await this.handleEvent(event, document);
221
+ }
222
+ }
223
+ /**
224
+ * Factory function to create workflow middleware for a model
225
+ * @param recordType - The type of record (e.g., 'applications', 'products', 'tasks')
226
+ * @param options - Optional workflow middleware options (overrides env vars)
227
+ * @returns Mongoose middleware functions
228
+ */
229
+ export function createWorkflowMiddleware(recordType, options) {
230
+ const middleware = new WorkflowMiddleware(options);
231
+ return middleware.createMiddleware(recordType);
232
+ }
233
+ /**
234
+ * Utility function to apply workflow middleware to a Mongoose schema
235
+ * @param schema - The Mongoose schema
236
+ * @param recordType - The type of record
237
+ * @param options - Optional workflow middleware options (overrides env vars)
238
+ */
239
+ export function applyWorkflowMiddleware(schema, recordType, options) {
240
+ const middleware = createWorkflowMiddleware(recordType, options);
241
+ // Apply post-save middleware
242
+ schema.post('save', middleware.postSave);
243
+ // Apply post-remove middleware
244
+ schema.post(/^delete/, middleware.postRemove);
245
+ schema.post('findOneAndDelete', middleware.postRemove);
246
+ }
@@ -0,0 +1,46 @@
1
+ /// <reference path="../value-objects/pound.d.ts" />
2
+ /// <reference path="../value-objects/account-number.d.ts" />
3
+ /// <reference path="../value-objects/sort-code.d.ts" />
4
+ /// <reference types="mongoose/types/aggregate.js" />
5
+ /// <reference types="mongoose/types/callback.js" />
6
+ /// <reference types="mongoose/types/collection.js" />
7
+ /// <reference types="mongoose/types/connection.js" />
8
+ /// <reference types="mongoose/types/cursor.js" />
9
+ /// <reference types="mongoose/types/document.js" />
10
+ /// <reference types="mongoose/types/error.js" />
11
+ /// <reference types="mongoose/types/expressions.js" />
12
+ /// <reference types="mongoose/types/helpers.js" />
13
+ /// <reference types="mongoose/types/middlewares.js" />
14
+ /// <reference types="mongoose/types/indexes.js" />
15
+ /// <reference types="mongoose/types/models.js" />
16
+ /// <reference types="mongoose/types/mongooseoptions.js" />
17
+ /// <reference types="mongoose/types/pipelinestage.js" />
18
+ /// <reference types="mongoose/types/populate.js" />
19
+ /// <reference types="mongoose/types/query.js" />
20
+ /// <reference types="mongoose/types/schemaoptions.js" />
21
+ /// <reference types="mongoose/types/session.js" />
22
+ /// <reference types="mongoose/types/types.js" />
23
+ /// <reference types="mongoose/types/utility.js" />
24
+ /// <reference types="mongoose/types/validation.js" />
25
+ /// <reference types="mongoose/types/virtuals.js" />
26
+ /// <reference types="mongoose/types/schematypes.js" />
27
+ /// <reference types="mongoose/types/inferschematype.js" />
28
+ /// <reference types="mongoose/types/inferrawdoctype.js" />
29
+ import mongoose from 'mongoose';
30
+ /**
31
+ * Workflow plugin that automatically applies workflow middleware to schemas
32
+ * This plugin reads the record type from schema options and applies the appropriate middleware
33
+ */
34
+ export declare function workflowPlugin(schema: mongoose.Schema, options: any): void;
35
+ /**
36
+ * Utility function to register the workflow plugin globally
37
+ * This will apply workflow middleware to all schemas automatically
38
+ */
39
+ export declare function registerWorkflowPlugin(): void;
40
+ /**
41
+ * Utility function to apply workflow plugin to a specific schema with custom record type
42
+ * @param schema - The Mongoose schema
43
+ * @param recordType - The record type (e.g., 'applications', 'applicants')
44
+ */
45
+ export declare function applyWorkflowPlugin(schema: mongoose.Schema, recordType: string): void;
46
+ //# sourceMappingURL=workflow.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.plugin.d.ts","sourceRoot":"","sources":["../../shared/workflow.plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAIhC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,QAyInE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,SAGrC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,QAE9E"}
@@ -0,0 +1,151 @@
1
+ import mongoose from 'mongoose';
2
+ import { WorkflowMiddleware } from './workflow.middleware.js';
3
+ import { workflowLog, workflowError } from './workflow.logger.js';
4
+ /**
5
+ * Workflow plugin that automatically applies workflow middleware to schemas
6
+ * This plugin reads the record type from schema options and applies the appropriate middleware
7
+ */
8
+ export function workflowPlugin(schema, options) {
9
+ // For global plugins, we'll determine the record type when the middleware is triggered
10
+ // by looking at the document's constructor name
11
+ workflowLog(`🔌 Workflow plugin applied to schema`);
12
+ // Create workflow middleware instance
13
+ const middleware = new WorkflowMiddleware();
14
+ // Apply post-save middleware
15
+ schema.post('save', async function (doc, next) {
16
+ // Determine record type from document constructor name
17
+ const recordType = doc.constructor.modelName?.toLowerCase() || 'unknown';
18
+ workflowLog(`💾 Post-save middleware triggered for ${recordType}`);
19
+ workflowLog(` Document ID: ${doc._id}`);
20
+ workflowLog(` Is new: ${doc.isNew}`);
21
+ workflowLog(` Trigger key: ${recordType}.${doc.isNew ? 'created' : 'updated'}`);
22
+ try {
23
+ await middleware.handleEvent({
24
+ recordType,
25
+ action: doc.isNew ? 'created' : 'updated',
26
+ triggerKey: `${recordType}.${doc.isNew ? 'created' : 'updated'}`
27
+ }, doc);
28
+ }
29
+ catch (error) {
30
+ workflowError('Workflow middleware error:', error);
31
+ // Don't throw error to avoid breaking the main operation
32
+ }
33
+ next();
34
+ });
35
+ // Apply post-findOneAndUpdate middleware
36
+ schema.post('findOneAndUpdate', async function (doc, next) {
37
+ const recordType = doc.constructor.modelName?.toLowerCase() || 'unknown';
38
+ workflowLog(`🔄 Post-findOneAndUpdate middleware triggered for ${recordType}`);
39
+ workflowLog(` Document ID: ${doc._id}`);
40
+ workflowLog(` Trigger key: ${recordType}.updated`);
41
+ try {
42
+ await middleware.handleEvent({
43
+ recordType,
44
+ action: 'updated',
45
+ triggerKey: `${recordType}.updated`
46
+ }, doc);
47
+ }
48
+ catch (error) {
49
+ workflowError('Workflow middleware error:', error);
50
+ // Don't throw error to avoid breaking the main operation
51
+ }
52
+ next();
53
+ });
54
+ // Apply post-remove middleware
55
+ schema.post(/^delete/, async function (result, next) {
56
+ // Try multiple methods to get model name since context differs in delete hooks
57
+ // For query hooks (model.deleteOne or doc.deleteOne), 'this' is the query
58
+ let recordType = 'unknown';
59
+ // Try from query context first (most reliable for deleteOne hooks)
60
+ // When doc.deleteOne() is called, 'this' refers to the query object
61
+ if (this?.model?.modelName) {
62
+ recordType = this.model.modelName.toLowerCase();
63
+ }
64
+ // Try from schema modelName
65
+ else if (schema?.modelName) {
66
+ recordType = schema.modelName.toLowerCase();
67
+ }
68
+ // Try from collection name as fallback
69
+ else if (this?.model?.collection?.name) {
70
+ recordType = this.model.collection.name.toLowerCase();
71
+ }
72
+ // Try from result if it's a document
73
+ else if (result?.constructor?.modelName) {
74
+ recordType = result.constructor.modelName.toLowerCase();
75
+ }
76
+ workflowLog(`🗑️ Post-delete middleware triggered for ${recordType}`);
77
+ try {
78
+ await middleware.handleEvent({
79
+ recordType,
80
+ action: 'deleted',
81
+ triggerKey: `${recordType}.deleted`
82
+ }, result);
83
+ }
84
+ catch (error) {
85
+ workflowError('Workflow middleware error:', error);
86
+ // Don't throw error to avoid breaking the main operation
87
+ }
88
+ next();
89
+ });
90
+ schema.post('findOneAndDelete', async function (doc, next) {
91
+ const recordType = doc.constructor.modelName?.toLowerCase() || 'unknown';
92
+ workflowLog(`🗑️ Post-findOneAndDelete middleware triggered for ${recordType}`);
93
+ try {
94
+ await middleware.handleEvent({
95
+ recordType,
96
+ action: 'deleted',
97
+ triggerKey: `${recordType}.deleted`
98
+ }, doc);
99
+ }
100
+ catch (error) {
101
+ workflowError('Workflow middleware error:', error);
102
+ // Don't throw error to avoid breaking the main operation
103
+ }
104
+ next();
105
+ });
106
+ // Apply post-find middleware (for findAll queries)
107
+ schema.post('find', async function (docs, next) {
108
+ const recordType = docs && docs.length > 0
109
+ ? docs[0]?.constructor?.modelName?.toLowerCase() || 'unknown'
110
+ : 'unknown';
111
+ // Only process for applicantcreditreport model
112
+ if (recordType === 'applicantcreditreport') {
113
+ workflowLog(`📚 Post-find (findAll) middleware triggered for ${recordType}`);
114
+ workflowLog(` Documents found: ${docs?.length || 0}`);
115
+ workflowLog(` Trigger key: ${recordType}.get`);
116
+ // Process each document in the results
117
+ if (docs && docs.length > 0) {
118
+ for (const doc of docs) {
119
+ try {
120
+ await middleware.handleEvent({
121
+ recordType,
122
+ action: 'get',
123
+ triggerKey: `${recordType}.get`
124
+ }, doc);
125
+ }
126
+ catch (error) {
127
+ workflowError('Workflow middleware error:', error);
128
+ // Don't throw error to avoid breaking the main operation
129
+ }
130
+ }
131
+ }
132
+ }
133
+ next();
134
+ });
135
+ }
136
+ /**
137
+ * Utility function to register the workflow plugin globally
138
+ * This will apply workflow middleware to all schemas automatically
139
+ */
140
+ export function registerWorkflowPlugin() {
141
+ // Register the plugin globally
142
+ mongoose.plugin(workflowPlugin);
143
+ }
144
+ /**
145
+ * Utility function to apply workflow plugin to a specific schema with custom record type
146
+ * @param schema - The Mongoose schema
147
+ * @param recordType - The record type (e.g., 'applications', 'applicants')
148
+ */
149
+ export function applyWorkflowPlugin(schema, recordType) {
150
+ schema.plugin(workflowPlugin, { recordType });
151
+ }
@@ -0,0 +1,42 @@
1
+ import { WorkflowApiPayload, WorkflowMiddlewareOptions } from './workflow-trigger.type';
2
+ export declare class WorkflowService {
3
+ private options;
4
+ private token?;
5
+ constructor(options: WorkflowMiddlewareOptions, token?: string);
6
+ /**
7
+ * Triggers a workflow execution in the background
8
+ * @param payload - The workflow payload to send
9
+ * @param token - Optional token to use for this specific call (overrides instance token)
10
+ * @returns Promise that resolves when the request is initiated (not when it completes)
11
+ */
12
+ triggerWorkflow(payload: WorkflowApiPayload, token?: string): Promise<void>;
13
+ /**
14
+ * Executes the actual workflow API call with retry logic
15
+ * @param payload - The workflow payload to send
16
+ * @param token - Optional token from context (takes priority over env var)
17
+ */
18
+ private executeWorkflowCall;
19
+ /**
20
+ * Validates that required variables are present in the data
21
+ * @param requiredVariables - Array of required variable names
22
+ * @param data - The data object to validate
23
+ * @returns true if all required variables are present
24
+ */
25
+ validateRequiredVariables(requiredVariables: string[], data: Record<string, any>): boolean;
26
+ /**
27
+ * Extracts variables from document data based on required and optional variables
28
+ * @param requiredVariables - Array of required variable names
29
+ * @param optionalVariables - Array of optional variable names
30
+ * @param document - The document to extract variables from
31
+ * @returns Object containing extracted variables
32
+ */
33
+ extractVariables(requiredVariables: string[], optionalVariables: string[], document: any): Record<string, any>;
34
+ /**
35
+ * Gets a nested value from an object using dot notation
36
+ * @param obj - The object to extract from
37
+ * @param path - The dot notation path (e.g., 'user.id')
38
+ * @returns The value at the path or undefined
39
+ */
40
+ private getNestedValue;
41
+ }
42
+ //# sourceMappingURL=workflow.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.service.d.ts","sourceRoot":"","sources":["../../shared/workflow.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGxF,qBAAa,eAAe;IACxB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,KAAK,CAAC,CAAS;gBAEX,OAAO,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE,MAAM;IAU9D;;;;;OAKG;IACG,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAajF;;;;OAIG;YACW,mBAAmB;IA6DjC;;;;;OAKG;IACH,yBAAyB,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;IAO1F;;;;;;OAMG;IACH,gBAAgB,CACZ,iBAAiB,EAAE,MAAM,EAAE,EAC3B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,QAAQ,EAAE,GAAG,GACd,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAmBtB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAKzB"}
@@ -0,0 +1,134 @@
1
+ import { workflowLog, workflowWarn, workflowError } from './workflow.logger.js';
2
+ export class WorkflowService {
3
+ constructor(options, token) {
4
+ this.options = {
5
+ timeout: 30000,
6
+ retryAttempts: 3,
7
+ retryDelay: 1000,
8
+ ...options
9
+ };
10
+ this.token = token;
11
+ }
12
+ /**
13
+ * Triggers a workflow execution in the background
14
+ * @param payload - The workflow payload to send
15
+ * @param token - Optional token to use for this specific call (overrides instance token)
16
+ * @returns Promise that resolves when the request is initiated (not when it completes)
17
+ */
18
+ async triggerWorkflow(payload, token) {
19
+ // Execute in background without waiting for completion
20
+ const tokenToUse = token || this.token;
21
+ setTimeout(async () => {
22
+ try {
23
+ await this.executeWorkflowCall(payload, tokenToUse);
24
+ }
25
+ catch (error) {
26
+ workflowError('Workflow execution failed:', error);
27
+ // Could implement retry logic or error reporting here
28
+ }
29
+ }, 1000);
30
+ }
31
+ /**
32
+ * Executes the actual workflow API call with retry logic
33
+ * @param payload - The workflow payload to send
34
+ * @param token - Optional token from context (takes priority over env var)
35
+ */
36
+ async executeWorkflowCall(payload, token) {
37
+ const headers = {
38
+ 'Content-Type': 'application/json',
39
+ 'X-Solution-Key': process.env.SOLUTION_KEY || 'default'
40
+ };
41
+ // Priority: Context token > Environment variable
42
+ const workflowApiKey = token || process.env.WORKFLOW_API_KEY;
43
+ if (workflowApiKey) {
44
+ headers['Authorization'] = `Bearer ${workflowApiKey}`;
45
+ }
46
+ const requestOptions = {
47
+ method: 'POST',
48
+ headers,
49
+ body: JSON.stringify(payload),
50
+ signal: AbortSignal.timeout(this.options.timeout)
51
+ };
52
+ let lastError = null;
53
+ for (let attempt = 1; attempt <= this.options.retryAttempts; attempt++) {
54
+ try {
55
+ workflowLog(`🚀 Workflow API call attempt ${attempt}:`);
56
+ workflowLog(` URL: ${this.options.workflowApiUrl}`);
57
+ workflowLog(` Payload: ${JSON.stringify(payload, null, 2)}`);
58
+ const response = await fetch(this.options.workflowApiUrl, requestOptions);
59
+ if (!response.ok) {
60
+ // Try to get error details from response body
61
+ let errorDetails = response.statusText;
62
+ try {
63
+ const errorBody = await response.text();
64
+ if (errorBody) {
65
+ errorDetails = errorBody;
66
+ }
67
+ }
68
+ catch (e) {
69
+ // Ignore if we can't read the body
70
+ }
71
+ throw new Error(`HTTP ${response.status}: ${errorDetails}`);
72
+ }
73
+ const result = await response.json();
74
+ workflowLog(`✅ Workflow ${payload.workflowKey} triggered successfully: ${JSON.stringify(result, null, 2)}`);
75
+ return;
76
+ }
77
+ catch (error) {
78
+ lastError = error;
79
+ workflowWarn(`Workflow API call attempt ${attempt} failed:`, error);
80
+ if (attempt < this.options.retryAttempts) {
81
+ // Wait before retrying
82
+ await new Promise(resolve => setTimeout(resolve, this.options.retryDelay * attempt));
83
+ }
84
+ }
85
+ }
86
+ // All retry attempts failed
87
+ throw new Error(`Workflow API call failed after ${this.options.retryAttempts} attempts: ${lastError?.message}`);
88
+ }
89
+ /**
90
+ * Validates that required variables are present in the data
91
+ * @param requiredVariables - Array of required variable names
92
+ * @param data - The data object to validate
93
+ * @returns true if all required variables are present
94
+ */
95
+ validateRequiredVariables(requiredVariables, data) {
96
+ return requiredVariables.every(variable => {
97
+ const value = data[variable];
98
+ return value !== undefined && value !== null && value !== '';
99
+ });
100
+ }
101
+ /**
102
+ * Extracts variables from document data based on required and optional variables
103
+ * @param requiredVariables - Array of required variable names
104
+ * @param optionalVariables - Array of optional variable names
105
+ * @param document - The document to extract variables from
106
+ * @returns Object containing extracted variables
107
+ */
108
+ extractVariables(requiredVariables, optionalVariables, document) {
109
+ const variables = {};
110
+ // Extract required variables
111
+ requiredVariables.forEach(variable => {
112
+ variables[variable] = this.getNestedValue(document, variable);
113
+ });
114
+ // Extract optional variables
115
+ optionalVariables?.forEach(variable => {
116
+ const value = this.getNestedValue(document, variable);
117
+ if (value !== undefined && value !== null) {
118
+ variables[variable] = value;
119
+ }
120
+ });
121
+ return variables;
122
+ }
123
+ /**
124
+ * Gets a nested value from an object using dot notation
125
+ * @param obj - The object to extract from
126
+ * @param path - The dot notation path (e.g., 'user.id')
127
+ * @returns The value at the path or undefined
128
+ */
129
+ getNestedValue(obj, path) {
130
+ return path.split('.').reduce((current, key) => {
131
+ return current && current[key] !== undefined ? current[key] : undefined;
132
+ }, obj);
133
+ }
134
+ }
@@ -0,0 +1,35 @@
1
+ /// <reference path="../value-objects/pound.d.ts" />
2
+ /// <reference path="../value-objects/account-number.d.ts" />
3
+ /// <reference path="../value-objects/sort-code.d.ts" />
4
+ /// <reference types="mongoose/types/aggregate" />
5
+ /// <reference types="mongoose/types/callback" />
6
+ /// <reference types="mongoose/types/collection" />
7
+ /// <reference types="mongoose/types/connection" />
8
+ /// <reference types="mongoose/types/cursor" />
9
+ /// <reference types="mongoose/types/document" />
10
+ /// <reference types="mongoose/types/error" />
11
+ /// <reference types="mongoose/types/expressions" />
12
+ /// <reference types="mongoose/types/helpers" />
13
+ /// <reference types="mongoose/types/middlewares" />
14
+ /// <reference types="mongoose/types/indexes" />
15
+ /// <reference types="mongoose/types/models" />
16
+ /// <reference types="mongoose/types/mongooseoptions" />
17
+ /// <reference types="mongoose/types/pipelinestage" />
18
+ /// <reference types="mongoose/types/populate" />
19
+ /// <reference types="mongoose/types/query" />
20
+ /// <reference types="mongoose/types/schemaoptions" />
21
+ /// <reference types="mongoose/types/session" />
22
+ /// <reference types="mongoose/types/types" />
23
+ /// <reference types="mongoose/types/utility" />
24
+ /// <reference types="mongoose/types/validation" />
25
+ /// <reference types="mongoose/types/virtuals" />
26
+ /// <reference types="mongoose/types/schematypes" />
27
+ /// <reference types="mongoose/types/inferschematype" />
28
+ /// <reference types="mongoose/types/inferrawdoctype" />
29
+ import { Types } from "mongoose";
30
+ export interface IBaseType {
31
+ _id: Types.ObjectId;
32
+ createdAt?: Date;
33
+ updatedAt?: Date;
34
+ }
35
+ //# sourceMappingURL=base.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.types.d.ts","sourceRoot":"","sources":["../../types/base.types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,WAAW,SAAS;IACtB,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB"}
@@ -0,0 +1 @@
1
+ export {};