@tsed/formio 6.88.1 → 6.92.0

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 (303) hide show
  1. package/lib/{FormioModule.d.ts → cjs/FormioModule.d.ts} +0 -0
  2. package/lib/{FormioModule.js → cjs/FormioModule.js} +38 -51
  3. package/lib/cjs/FormioModule.js.map +1 -0
  4. package/lib/{builder → cjs/builder}/FormioMapper.d.ts +0 -0
  5. package/lib/{builder → cjs/builder}/FormioMapper.js +0 -0
  6. package/lib/cjs/builder/FormioMapper.js.map +1 -0
  7. package/lib/{components → cjs/components}/AlterActions.d.ts +0 -0
  8. package/lib/{components → cjs/components}/AlterActions.js +8 -8
  9. package/lib/cjs/components/AlterActions.js.map +1 -0
  10. package/lib/{components → cjs/components}/AlterAudit.d.ts +0 -0
  11. package/lib/{components → cjs/components}/AlterAudit.js +2 -2
  12. package/lib/cjs/components/AlterAudit.js.map +1 -0
  13. package/lib/{components → cjs/components}/AlterHost.d.ts +0 -0
  14. package/lib/{components → cjs/components}/AlterHost.js +2 -2
  15. package/lib/cjs/components/AlterHost.js.map +1 -0
  16. package/lib/{components → cjs/components}/AlterLog.d.ts +0 -0
  17. package/lib/{components → cjs/components}/AlterLog.js +2 -2
  18. package/lib/cjs/components/AlterLog.js.map +1 -0
  19. package/lib/{components → cjs/components}/AlterSkip.d.ts +0 -0
  20. package/lib/{components → cjs/components}/AlterSkip.js +9 -9
  21. package/lib/cjs/components/AlterSkip.js.map +1 -0
  22. package/lib/{components → cjs/components}/AlterTemplateExportSteps.d.ts +0 -0
  23. package/lib/{components → cjs/components}/AlterTemplateExportSteps.js +6 -6
  24. package/lib/cjs/components/AlterTemplateExportSteps.js.map +1 -0
  25. package/lib/{components → cjs/components}/AlterTemplateImportSteps.d.ts +0 -0
  26. package/lib/{components → cjs/components}/AlterTemplateImportSteps.js +5 -5
  27. package/lib/cjs/components/AlterTemplateImportSteps.js.map +1 -0
  28. package/lib/{decorators → cjs/decorators}/action.d.ts +0 -0
  29. package/lib/{decorators → cjs/decorators}/action.js +3 -3
  30. package/lib/cjs/decorators/action.js.map +1 -0
  31. package/lib/{decorators → cjs/decorators}/actionCtx.d.ts +0 -0
  32. package/lib/{decorators → cjs/decorators}/actionCtx.js +1 -1
  33. package/lib/cjs/decorators/actionCtx.js.map +1 -0
  34. package/lib/{decorators → cjs/decorators}/alter.d.ts +0 -0
  35. package/lib/{decorators → cjs/decorators}/alter.js +3 -3
  36. package/lib/cjs/decorators/alter.js.map +1 -0
  37. package/lib/{decorators → cjs/decorators}/on.d.ts +0 -0
  38. package/lib/{decorators → cjs/decorators}/on.js +3 -3
  39. package/lib/cjs/decorators/on.js.map +1 -0
  40. package/lib/{decorators → cjs/decorators}/useFormioAuth.d.ts +0 -0
  41. package/lib/{decorators → cjs/decorators}/useFormioAuth.js +1 -1
  42. package/lib/cjs/decorators/useFormioAuth.js.map +1 -0
  43. package/lib/{domain → cjs/domain}/AlterHook.d.ts +0 -0
  44. package/lib/{domain → cjs/domain}/AlterHook.js +0 -0
  45. package/lib/cjs/domain/AlterHook.js.map +1 -0
  46. package/lib/{domain → cjs/domain}/Formio.d.ts +0 -0
  47. package/lib/{domain → cjs/domain}/Formio.js +0 -0
  48. package/lib/cjs/domain/Formio.js.map +1 -0
  49. package/lib/{domain → cjs/domain}/FormioAction.d.ts +0 -0
  50. package/lib/{domain → cjs/domain}/FormioAction.js +0 -0
  51. package/lib/cjs/domain/FormioAction.js.map +1 -0
  52. package/lib/{domain → cjs/domain}/FormioActionsIndex.d.ts +0 -0
  53. package/lib/{domain → cjs/domain}/FormioActionsIndex.js +0 -0
  54. package/lib/cjs/domain/FormioActionsIndex.js.map +1 -0
  55. package/lib/{domain → cjs/domain}/FormioAuth.d.ts +0 -0
  56. package/lib/{domain → cjs/domain}/FormioAuth.js +0 -0
  57. package/lib/cjs/domain/FormioAuth.js.map +1 -0
  58. package/lib/{domain → cjs/domain}/FormioBaseModel.d.ts +0 -0
  59. package/lib/{domain → cjs/domain}/FormioBaseModel.js +0 -0
  60. package/lib/cjs/domain/FormioBaseModel.js.map +1 -0
  61. package/lib/{domain → cjs/domain}/FormioConfig.d.ts +0 -0
  62. package/lib/{domain → cjs/domain}/FormioConfig.js +0 -0
  63. package/lib/cjs/domain/FormioConfig.js.map +1 -0
  64. package/lib/{domain → cjs/domain}/FormioCtxMapper.d.ts +0 -0
  65. package/lib/{domain → cjs/domain}/FormioCtxMapper.js +0 -0
  66. package/lib/cjs/domain/FormioCtxMapper.js.map +1 -0
  67. package/lib/{domain → cjs/domain}/FormioDecodedToken.d.ts +0 -0
  68. package/lib/{domain → cjs/domain}/FormioDecodedToken.js +0 -0
  69. package/lib/cjs/domain/FormioDecodedToken.js.map +1 -0
  70. package/lib/{domain → cjs/domain}/FormioErrors.d.ts +0 -0
  71. package/lib/{domain → cjs/domain}/FormioErrors.js +0 -0
  72. package/lib/cjs/domain/FormioErrors.js.map +1 -0
  73. package/lib/{domain → cjs/domain}/FormioHooks.d.ts +0 -0
  74. package/lib/{domain → cjs/domain}/FormioHooks.js +0 -0
  75. package/lib/cjs/domain/FormioHooks.js.map +1 -0
  76. package/lib/{domain → cjs/domain}/FormioJs.d.ts +0 -0
  77. package/lib/{domain → cjs/domain}/FormioJs.js +0 -0
  78. package/lib/cjs/domain/FormioJs.js.map +1 -0
  79. package/lib/{domain → cjs/domain}/FormioModels.d.ts +0 -0
  80. package/lib/{domain → cjs/domain}/FormioModels.js +1 -1
  81. package/lib/cjs/domain/FormioModels.js.map +1 -0
  82. package/lib/{domain → cjs/domain}/FormioRouter.d.ts +0 -0
  83. package/lib/{domain → cjs/domain}/FormioRouter.js +0 -0
  84. package/lib/cjs/domain/FormioRouter.js.map +1 -0
  85. package/lib/{domain → cjs/domain}/FormioSettings.d.ts +0 -0
  86. package/lib/{domain → cjs/domain}/FormioSettings.js +0 -0
  87. package/lib/cjs/domain/FormioSettings.js.map +1 -0
  88. package/lib/{domain → cjs/domain}/FormioTemplate.d.ts +0 -0
  89. package/lib/{domain → cjs/domain}/FormioTemplate.js +0 -0
  90. package/lib/cjs/domain/FormioTemplate.js.map +1 -0
  91. package/lib/{domain → cjs/domain}/FormioTemplateUtil.d.ts +0 -0
  92. package/lib/{domain → cjs/domain}/FormioTemplateUtil.js +0 -0
  93. package/lib/cjs/domain/FormioTemplateUtil.js.map +1 -0
  94. package/lib/{domain → cjs/domain}/FormioUpdate.d.ts +0 -0
  95. package/lib/{domain → cjs/domain}/FormioUpdate.js +0 -0
  96. package/lib/cjs/domain/FormioUpdate.js.map +1 -0
  97. package/lib/{domain → cjs/domain}/FormioUtils.d.ts +0 -0
  98. package/lib/{domain → cjs/domain}/FormioUtils.js +0 -0
  99. package/lib/cjs/domain/FormioUtils.js.map +1 -0
  100. package/lib/{domain → cjs/domain}/OnHook.d.ts +0 -0
  101. package/lib/{domain → cjs/domain}/OnHook.js +0 -0
  102. package/lib/cjs/domain/OnHook.js.map +1 -0
  103. package/lib/{domain → cjs/domain}/Resource.d.ts +0 -0
  104. package/lib/{domain → cjs/domain}/Resource.js +0 -0
  105. package/lib/cjs/domain/Resource.js.map +1 -0
  106. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  107. package/lib/cjs/index.js +46 -0
  108. package/lib/cjs/index.js.map +1 -0
  109. package/lib/{middlewares → cjs/middlewares}/FormioAuthMiddleware.d.ts +0 -0
  110. package/lib/{middlewares → cjs/middlewares}/FormioAuthMiddleware.js +12 -12
  111. package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +1 -0
  112. package/lib/{services → cjs/services}/FormioAuthService.d.ts +1 -1
  113. package/lib/{services → cjs/services}/FormioAuthService.js +13 -13
  114. package/lib/cjs/services/FormioAuthService.js.map +1 -0
  115. package/lib/{services → cjs/services}/FormioDatabase.d.ts +0 -0
  116. package/lib/{services → cjs/services}/FormioDatabase.js +10 -10
  117. package/lib/cjs/services/FormioDatabase.js.map +1 -0
  118. package/lib/{services → cjs/services}/FormioHooksService.d.ts +0 -0
  119. package/lib/{services → cjs/services}/FormioHooksService.js +9 -9
  120. package/lib/cjs/services/FormioHooksService.js.map +1 -0
  121. package/lib/{services → cjs/services}/FormioInstaller.d.ts +0 -0
  122. package/lib/{services → cjs/services}/FormioInstaller.js +8 -8
  123. package/lib/cjs/services/FormioInstaller.js.map +1 -0
  124. package/lib/{services → cjs/services}/FormioService.d.ts +0 -0
  125. package/lib/{services → cjs/services}/FormioService.js +8 -8
  126. package/lib/cjs/services/FormioService.js.map +1 -0
  127. package/lib/{utils → cjs/utils}/isMongoId.d.ts +0 -0
  128. package/lib/{utils → cjs/utils}/isMongoId.js +0 -0
  129. package/lib/cjs/utils/isMongoId.js.map +1 -0
  130. package/lib/esm/FormioModule.js +134 -0
  131. package/lib/esm/FormioModule.js.map +1 -0
  132. package/lib/esm/builder/FormioMapper.js +49 -0
  133. package/lib/esm/builder/FormioMapper.js.map +1 -0
  134. package/lib/esm/components/AlterActions.js +63 -0
  135. package/lib/esm/components/AlterActions.js.map +1 -0
  136. package/lib/esm/components/AlterAudit.js +13 -0
  137. package/lib/esm/components/AlterAudit.js.map +1 -0
  138. package/lib/esm/components/AlterHost.js +12 -0
  139. package/lib/esm/components/AlterHost.js.map +1 -0
  140. package/lib/esm/components/AlterLog.js +13 -0
  141. package/lib/esm/components/AlterLog.js.map +1 -0
  142. package/lib/esm/components/AlterSkip.js +29 -0
  143. package/lib/esm/components/AlterSkip.js.map +1 -0
  144. package/lib/esm/components/AlterTemplateExportSteps.js +49 -0
  145. package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -0
  146. package/lib/esm/components/AlterTemplateImportSteps.js +42 -0
  147. package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -0
  148. package/lib/esm/decorators/action.js +16 -0
  149. package/lib/esm/decorators/action.js.map +1 -0
  150. package/lib/esm/decorators/actionCtx.js +19 -0
  151. package/lib/esm/decorators/actionCtx.js.map +1 -0
  152. package/lib/esm/decorators/alter.js +16 -0
  153. package/lib/esm/decorators/alter.js.map +1 -0
  154. package/lib/esm/decorators/on.js +16 -0
  155. package/lib/esm/decorators/on.js.map +1 -0
  156. package/lib/esm/decorators/useFormioAuth.js +11 -0
  157. package/lib/esm/decorators/useFormioAuth.js.map +1 -0
  158. package/lib/esm/domain/AlterHook.js +2 -0
  159. package/lib/esm/domain/AlterHook.js.map +1 -0
  160. package/lib/esm/domain/Formio.js +2 -0
  161. package/lib/esm/domain/Formio.js.map +1 -0
  162. package/lib/esm/domain/FormioAction.js +2 -0
  163. package/lib/esm/domain/FormioAction.js.map +1 -0
  164. package/lib/esm/domain/FormioActionsIndex.js +2 -0
  165. package/lib/esm/domain/FormioActionsIndex.js.map +1 -0
  166. package/lib/esm/domain/FormioAuth.js +2 -0
  167. package/lib/esm/domain/FormioAuth.js.map +1 -0
  168. package/lib/esm/domain/FormioBaseModel.js +2 -0
  169. package/lib/esm/domain/FormioBaseModel.js.map +1 -0
  170. package/lib/esm/domain/FormioConfig.js +2 -0
  171. package/lib/esm/domain/FormioConfig.js.map +1 -0
  172. package/lib/esm/domain/FormioCtxMapper.js +2 -0
  173. package/lib/esm/domain/FormioCtxMapper.js.map +1 -0
  174. package/lib/esm/domain/FormioDecodedToken.js +2 -0
  175. package/lib/esm/domain/FormioDecodedToken.js.map +1 -0
  176. package/lib/esm/domain/FormioErrors.js +2 -0
  177. package/lib/esm/domain/FormioErrors.js.map +1 -0
  178. package/lib/esm/domain/FormioHooks.js +2 -0
  179. package/lib/esm/domain/FormioHooks.js.map +1 -0
  180. package/lib/esm/domain/FormioJs.js +2 -0
  181. package/lib/esm/domain/FormioJs.js.map +1 -0
  182. package/lib/esm/domain/FormioModels.js +2 -0
  183. package/lib/esm/domain/FormioModels.js.map +1 -0
  184. package/lib/esm/domain/FormioRouter.js +2 -0
  185. package/lib/esm/domain/FormioRouter.js.map +1 -0
  186. package/lib/esm/domain/FormioSettings.js +2 -0
  187. package/lib/esm/domain/FormioSettings.js.map +1 -0
  188. package/lib/esm/domain/FormioTemplate.js +2 -0
  189. package/lib/esm/domain/FormioTemplate.js.map +1 -0
  190. package/lib/esm/domain/FormioTemplateUtil.js +2 -0
  191. package/lib/esm/domain/FormioTemplateUtil.js.map +1 -0
  192. package/lib/esm/domain/FormioUpdate.js +2 -0
  193. package/lib/esm/domain/FormioUpdate.js.map +1 -0
  194. package/lib/esm/domain/FormioUtils.js +2 -0
  195. package/lib/esm/domain/FormioUtils.js.map +1 -0
  196. package/lib/esm/domain/OnHook.js +2 -0
  197. package/lib/esm/domain/OnHook.js.map +1 -0
  198. package/lib/esm/domain/Resource.js +2 -0
  199. package/lib/esm/domain/Resource.js.map +1 -0
  200. package/lib/esm/index.js +43 -0
  201. package/lib/esm/index.js.map +1 -0
  202. package/lib/esm/middlewares/FormioAuthMiddleware.js +38 -0
  203. package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -0
  204. package/lib/esm/services/FormioAuthService.js +179 -0
  205. package/lib/esm/services/FormioAuthService.js.map +1 -0
  206. package/lib/esm/services/FormioDatabase.js +100 -0
  207. package/lib/{services → esm/services}/FormioDatabase.js.map +1 -1
  208. package/lib/esm/services/FormioHooksService.js +78 -0
  209. package/lib/esm/services/FormioHooksService.js.map +1 -0
  210. package/lib/esm/services/FormioInstaller.js +47 -0
  211. package/lib/esm/services/FormioInstaller.js.map +1 -0
  212. package/lib/esm/services/FormioService.js +97 -0
  213. package/lib/esm/services/FormioService.js.map +1 -0
  214. package/lib/esm/utils/isMongoId.js +4 -0
  215. package/lib/esm/utils/isMongoId.js.map +1 -0
  216. package/lib/types/FormioModule.d.ts +24 -0
  217. package/lib/types/builder/FormioMapper.d.ts +11 -0
  218. package/lib/types/components/AlterActions.d.ts +15 -0
  219. package/lib/types/components/AlterAudit.d.ts +5 -0
  220. package/lib/types/components/AlterHost.d.ts +5 -0
  221. package/lib/types/components/AlterLog.d.ts +5 -0
  222. package/lib/types/components/AlterSkip.d.ts +7 -0
  223. package/lib/types/components/AlterTemplateExportSteps.d.ts +12 -0
  224. package/lib/types/components/AlterTemplateImportSteps.d.ts +11 -0
  225. package/lib/types/decorators/action.d.ts +7 -0
  226. package/lib/types/decorators/actionCtx.d.ts +23 -0
  227. package/lib/types/decorators/alter.d.ts +6 -0
  228. package/lib/types/decorators/on.d.ts +6 -0
  229. package/lib/types/decorators/useFormioAuth.d.ts +6 -0
  230. package/lib/types/domain/AlterHook.d.ts +3 -0
  231. package/lib/types/domain/Formio.d.ts +112 -0
  232. package/lib/types/domain/FormioAction.d.ts +20 -0
  233. package/lib/types/domain/FormioActionsIndex.d.ts +15 -0
  234. package/lib/types/domain/FormioAuth.d.ts +67 -0
  235. package/lib/types/domain/FormioBaseModel.d.ts +11 -0
  236. package/lib/types/domain/FormioConfig.d.ts +59 -0
  237. package/lib/types/domain/FormioCtxMapper.d.ts +7 -0
  238. package/lib/types/domain/FormioDecodedToken.d.ts +12 -0
  239. package/lib/types/domain/FormioErrors.d.ts +53 -0
  240. package/lib/types/domain/FormioHooks.d.ts +194 -0
  241. package/lib/types/domain/FormioJs.d.ts +17 -0
  242. package/lib/types/domain/FormioModels.d.ts +42 -0
  243. package/lib/types/domain/FormioRouter.d.ts +7 -0
  244. package/lib/types/domain/FormioSettings.d.ts +53 -0
  245. package/lib/types/domain/FormioTemplate.d.ts +8 -0
  246. package/lib/types/domain/FormioTemplateUtil.d.ts +13 -0
  247. package/lib/types/domain/FormioUpdate.d.ts +19 -0
  248. package/lib/types/domain/FormioUtils.d.ts +307 -0
  249. package/lib/types/domain/OnHook.d.ts +3 -0
  250. package/lib/types/domain/Resource.d.ts +18 -0
  251. package/lib/types/index.d.ts +38 -0
  252. package/lib/types/middlewares/FormioAuthMiddleware.d.ts +11 -0
  253. package/lib/types/services/FormioAuthService.d.ts +54 -0
  254. package/lib/types/services/FormioDatabase.d.ts +24 -0
  255. package/lib/types/services/FormioHooksService.d.ts +17 -0
  256. package/lib/types/services/FormioInstaller.d.ts +14 -0
  257. package/lib/types/services/FormioService.d.ts +36 -0
  258. package/lib/types/utils/isMongoId.d.ts +1 -0
  259. package/package.json +22 -14
  260. package/tsconfig.compile.esm.json +23 -0
  261. package/lib/FormioModule.js.map +0 -1
  262. package/lib/builder/FormioMapper.js.map +0 -1
  263. package/lib/components/AlterActions.js.map +0 -1
  264. package/lib/components/AlterAudit.js.map +0 -1
  265. package/lib/components/AlterHost.js.map +0 -1
  266. package/lib/components/AlterLog.js.map +0 -1
  267. package/lib/components/AlterSkip.js.map +0 -1
  268. package/lib/components/AlterTemplateExportSteps.js.map +0 -1
  269. package/lib/components/AlterTemplateImportSteps.js.map +0 -1
  270. package/lib/decorators/action.js.map +0 -1
  271. package/lib/decorators/actionCtx.js.map +0 -1
  272. package/lib/decorators/alter.js.map +0 -1
  273. package/lib/decorators/on.js.map +0 -1
  274. package/lib/decorators/useFormioAuth.js.map +0 -1
  275. package/lib/domain/AlterHook.js.map +0 -1
  276. package/lib/domain/Formio.js.map +0 -1
  277. package/lib/domain/FormioAction.js.map +0 -1
  278. package/lib/domain/FormioActionsIndex.js.map +0 -1
  279. package/lib/domain/FormioAuth.js.map +0 -1
  280. package/lib/domain/FormioBaseModel.js.map +0 -1
  281. package/lib/domain/FormioConfig.js.map +0 -1
  282. package/lib/domain/FormioCtxMapper.js.map +0 -1
  283. package/lib/domain/FormioDecodedToken.js.map +0 -1
  284. package/lib/domain/FormioErrors.js.map +0 -1
  285. package/lib/domain/FormioHooks.js.map +0 -1
  286. package/lib/domain/FormioJs.js.map +0 -1
  287. package/lib/domain/FormioModels.js.map +0 -1
  288. package/lib/domain/FormioRouter.js.map +0 -1
  289. package/lib/domain/FormioSettings.js.map +0 -1
  290. package/lib/domain/FormioTemplate.js.map +0 -1
  291. package/lib/domain/FormioTemplateUtil.js.map +0 -1
  292. package/lib/domain/FormioUpdate.js.map +0 -1
  293. package/lib/domain/FormioUtils.js.map +0 -1
  294. package/lib/domain/OnHook.js.map +0 -1
  295. package/lib/domain/Resource.js.map +0 -1
  296. package/lib/index.js +0 -46
  297. package/lib/index.js.map +0 -1
  298. package/lib/middlewares/FormioAuthMiddleware.js.map +0 -1
  299. package/lib/services/FormioAuthService.js.map +0 -1
  300. package/lib/services/FormioHooksService.js.map +0 -1
  301. package/lib/services/FormioInstaller.js.map +0 -1
  302. package/lib/services/FormioService.js.map +0 -1
  303. package/lib/utils/isMongoId.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../src/services/FormioDatabase.ts"],"names":[],"mappings":";;;;AAAA,qCAAsE;AACtE,iCAA4C;AAG5C,0DAAqD;AACrD,kDAA6C;AAC7C,mDAA8C;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,YAAI,CAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAClH,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,CAAC,KAAK,E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isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({machineName: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {machineName: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n async createFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.saveFormDefinition(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n async saveFormDefinition(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return new this.formModel(mapper.mapToImport(form)).save();\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAI,CAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAClH,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,I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AAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAjGC;IADC,MAAM,EAAE;8BACS,aAAa;8CAAC;AAFrB,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAmG1B;SAnGY,cAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({machineName: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {machineName: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n async createFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.saveFormDefinition(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n async saveFormDefinition(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return new this.formModel(mapper.mapToImport(form)).save();\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
@@ -0,0 +1,78 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject, Injectable, InjectorService } from "@tsed/common";
3
+ import { promisify } from "util";
4
+ import { FormioService } from "./FormioService";
5
+ let FormioHooksService = class FormioHooksService {
6
+ get settings() {
7
+ return this.formio.hook.settings;
8
+ }
9
+ get invoke() {
10
+ return this.formio.hook.invoke;
11
+ }
12
+ get alter() {
13
+ return this.formio.hook.alter;
14
+ }
15
+ get alterAsync() {
16
+ return promisify(this.alter);
17
+ }
18
+ getHooks() {
19
+ return {
20
+ alter: this.getHooksProvider("alter"),
21
+ on: this.getHooksProvider("on")
22
+ };
23
+ }
24
+ getProviders(type) {
25
+ return this.injector.getProviders(`formio:${type}`);
26
+ }
27
+ getHooksProvider(type) {
28
+ return this.bindHooks(type, this.createHooks(type));
29
+ }
30
+ bindHooks(type, hooks) {
31
+ return Object.entries(hooks).reduce((newHooks, [key, pool]) => {
32
+ const wrap = (input, ...args) => {
33
+ let last;
34
+ for (const fn of pool) {
35
+ const result = fn(input, ...args);
36
+ if (type === "alter") {
37
+ input = result;
38
+ }
39
+ else {
40
+ last = result;
41
+ }
42
+ }
43
+ return type === "alter" ? input : last;
44
+ };
45
+ return {
46
+ ...newHooks,
47
+ [key]: wrap
48
+ };
49
+ }, {});
50
+ }
51
+ createHooks(type) {
52
+ return this.getProviders(type).reduce((hooks, provider) => {
53
+ const instance = this.injector.invoke(provider.token);
54
+ const name = provider.store.get(`formio:${type}:name`);
55
+ const pool = hooks[name] || [];
56
+ const hook = (...args) => instance[type === "alter" ? "transform" : "on"](...args.map((input) => {
57
+ return input && input.$ctx ? input.$ctx : input;
58
+ }));
59
+ return {
60
+ ...hooks,
61
+ [name]: [].concat(pool, hook)
62
+ };
63
+ }, {});
64
+ }
65
+ };
66
+ __decorate([
67
+ Inject(),
68
+ __metadata("design:type", InjectorService)
69
+ ], FormioHooksService.prototype, "injector", void 0);
70
+ __decorate([
71
+ Inject(FormioService),
72
+ __metadata("design:type", FormioService)
73
+ ], FormioHooksService.prototype, "formio", void 0);
74
+ FormioHooksService = __decorate([
75
+ Injectable()
76
+ ], FormioHooksService);
77
+ export { FormioHooksService };
78
+ //# sourceMappingURL=FormioHooksService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioHooksService.js","sourceRoot":"","sources":["../../../src/services/FormioHooksService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAI9C,IAAa,kBAAkB,GAA/B,MA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C;IADC,MAAM,CAAC,aAAa,CAAC;8BACJ,aAAa;kDAAC;AALrB,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CAkF9B;SAlFY,kBAAkB","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {promisify} from \"util\";\nimport {FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioService} from \"./FormioService\";\nimport {Request} from \"express\";\n\n@Injectable()\nexport class FormioHooksService {\n @Inject()\n protected injector: InjectorService;\n\n @Inject(FormioService)\n protected formio: FormioService;\n\n get settings(): (req: Request, cb: Function) => void {\n return this.formio.hook.settings;\n }\n\n get invoke() {\n return this.formio.hook.invoke;\n }\n\n get alter(): (event: string, ...args: any[]) => any {\n return this.formio.hook.alter;\n }\n\n get alterAsync(): (event: string, ...args: any[]) => Promise<any> {\n return promisify(this.alter);\n }\n\n getHooks(): FormioHooks {\n return {\n alter: this.getHooksProvider(\"alter\"),\n on: this.getHooksProvider(\"on\")\n };\n }\n\n protected getProviders(type: \"alter\" | \"on\") {\n return this.injector.getProviders(`formio:${type}`);\n }\n\n protected getHooksProvider(type: \"alter\" | \"on\") {\n return this.bindHooks(type, this.createHooks(type));\n }\n\n protected bindHooks(type: \"alter\" | \"on\", hooks: Record<string, Function[]>) {\n return Object.entries(hooks).reduce((newHooks, [key, pool]) => {\n const wrap = (input: any, ...args: any[]): any => {\n let last: any;\n\n for (const fn of pool) {\n const result = fn(input, ...args);\n\n if (type === \"alter\") {\n input = result;\n } else {\n last = result;\n }\n }\n\n return type === \"alter\" ? input : last;\n };\n\n return {\n ...newHooks,\n [key]: wrap\n };\n }, {});\n }\n\n private createHooks(type: \"alter\" | \"on\") {\n return this.getProviders(type).reduce<Record<string, Function[]>>((hooks, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const name = provider.store.get(`formio:${type}:name`);\n const pool: Function[] = hooks[name] || [];\n\n const hook = (...args: any[]) =>\n instance[type === \"alter\" ? \"transform\" : \"on\"](\n ...args.map((input: any) => {\n return input && input.$ctx ? input.$ctx : input;\n })\n );\n\n return {\n ...hooks,\n [name]: ([] as Function[]).concat(pool, hook)\n };\n }, {});\n }\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject, Injectable } from "@tsed/di";
3
+ import { Logger } from "@tsed/logger";
4
+ import { FormioDatabase } from "./FormioDatabase";
5
+ import { FormioService } from "./FormioService";
6
+ let FormioInstaller = class FormioInstaller extends FormioDatabase {
7
+ async install(template, root) {
8
+ this.logger.info("Install formio template...");
9
+ template = await this.formio.importTemplate(template);
10
+ if (root) {
11
+ this.logger.info("Create root user...");
12
+ await this.createRootUser(root, template);
13
+ }
14
+ }
15
+ async createRootUser(user, template) {
16
+ const hash = await this.formio.encrypt(user.password);
17
+ return new Promise((resolve, reject) => {
18
+ var _a;
19
+ this.formio.resources.submission.model.create({
20
+ form: template.resources.admin._id,
21
+ data: {
22
+ email: user.email,
23
+ password: hash
24
+ },
25
+ roles: [(_a = template.roles) === null || _a === void 0 ? void 0 : _a.administrator._id].filter(Boolean)
26
+ }, (err, item) => {
27
+ if (err) {
28
+ return reject(err);
29
+ }
30
+ resolve(item);
31
+ });
32
+ });
33
+ }
34
+ };
35
+ __decorate([
36
+ Inject(),
37
+ __metadata("design:type", FormioService)
38
+ ], FormioInstaller.prototype, "formio", void 0);
39
+ __decorate([
40
+ Inject(),
41
+ __metadata("design:type", Logger)
42
+ ], FormioInstaller.prototype, "logger", void 0);
43
+ FormioInstaller = __decorate([
44
+ Injectable()
45
+ ], FormioInstaller);
46
+ export { FormioInstaller };
47
+ //# sourceMappingURL=FormioInstaller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioInstaller.js","sourceRoot":"","sources":["../../../src/services/FormioInstaller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;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C,CAAC;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAtCC;IADC,MAAM,EAAE;8BACS,aAAa;+CAAC;AAGhC;IADC,MAAM,EAAE;8BACS,MAAM;+CAAC;AALd,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAwC3B;SAxCY,eAAe","sourcesContent":["import {Inject, Injectable} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"./FormioDatabase\";\nimport {FormioService} from \"./FormioService\";\n\n@Injectable()\nexport class FormioInstaller extends FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected logger: Logger;\n\n async install(template: FormioTemplate, root: any) {\n this.logger.info(\"Install formio template...\");\n template = await this.formio.importTemplate(template);\n\n if (root) {\n this.logger.info(\"Create root user...\");\n await this.createRootUser(root, template);\n }\n }\n\n async createRootUser<User = unknown>(user: {email: string; password: string}, template: FormioTemplate): Promise<FormioSubmission<User>> {\n const hash = await this.formio.encrypt(user.password);\n\n return new Promise((resolve, reject) => {\n this.formio.resources.submission.model.create(\n {\n form: template.resources.admin._id,\n data: {\n email: user.email,\n password: hash\n },\n roles: [template.roles?.administrator._id].filter(Boolean)\n },\n (err: unknown, item: any) => {\n if (err) {\n return reject(err);\n }\n\n resolve(item);\n }\n );\n });\n }\n}\n"]}
@@ -0,0 +1,97 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject, Injectable, InjectorService } from "@tsed/common";
3
+ import { promisify } from "util";
4
+ const createRouter = require("formio");
5
+ const swagger = require("formio/src/util/swagger.js");
6
+ const util = require("formio/src/util/util.js");
7
+ let FormioService = class FormioService {
8
+ get audit() {
9
+ return this.formio.audit || (() => { });
10
+ }
11
+ get auth() {
12
+ return this.formio.auth;
13
+ }
14
+ // istanbul ignore next
15
+ get swagger() {
16
+ return (...args) => new Promise((resolve) => swagger(...args, resolve));
17
+ }
18
+ get config() {
19
+ return this.formio.config;
20
+ }
21
+ get db() {
22
+ return this.formio.db;
23
+ }
24
+ get resources() {
25
+ return this.formio.resources;
26
+ }
27
+ get mongoose() {
28
+ return this.formio.mongoose;
29
+ }
30
+ get middleware() {
31
+ return this.formio.middleware;
32
+ }
33
+ get schemas() {
34
+ return this.formio.schemas;
35
+ }
36
+ get formio() {
37
+ return this.router.formio;
38
+ }
39
+ get hook() {
40
+ return this.formio.hook;
41
+ }
42
+ get util() {
43
+ return this.formio.util;
44
+ }
45
+ get template() {
46
+ return this.formio.template;
47
+ }
48
+ get Action() {
49
+ return this.formio.Action;
50
+ }
51
+ async exportTemplate(options = {}) {
52
+ return promisify(this.formio.template.export)(options);
53
+ }
54
+ async importTemplate(template) {
55
+ return promisify(this.formio.template.import.template)(template);
56
+ }
57
+ encrypt(text) {
58
+ return promisify(this.formio.encrypt)(text);
59
+ }
60
+ isInit() {
61
+ return !!this.router;
62
+ }
63
+ // istanbul ignore next
64
+ createRouter(options) {
65
+ return createRouter(options);
66
+ }
67
+ init(options, hooks = {}) {
68
+ if (options && Object.keys(options).length) {
69
+ this.router = this.createRouter(this.mapConfiguration(options));
70
+ this.bindLogger();
71
+ return this.router.init(hooks);
72
+ }
73
+ }
74
+ mapConfiguration(options) {
75
+ const { injector } = this;
76
+ const mongooseSettings = injector.settings.get("mongoose.0");
77
+ if (mongooseSettings) {
78
+ options.mongo = options.mongo || mongooseSettings.url;
79
+ options.mongoConfig = options.mongoConfig || JSON.stringify(mongooseSettings.connectionOptions);
80
+ }
81
+ return options;
82
+ }
83
+ bindLogger() {
84
+ const { injector } = this;
85
+ util.log = injector.logger.info.bind(injector.logger);
86
+ util.error = injector.logger.error.bind(injector.logger);
87
+ }
88
+ };
89
+ __decorate([
90
+ Inject(),
91
+ __metadata("design:type", InjectorService)
92
+ ], FormioService.prototype, "injector", void 0);
93
+ FormioService = __decorate([
94
+ Injectable()
95
+ ], FormioService);
96
+ export { FormioService };
97
+ //# sourceMappingURL=FormioService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/FormioService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAIjE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAS/B,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACtD,MAAM,IAAI,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAGhD,IAAa,aAAa,GAA1B,MAAa,aAAa;IAMxB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,uBAAuB;IACvB,IAAI,OAAO;QACT,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,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AG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,EAAE,CAAC;YAElB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChC;IACH,CAAC;IAES,gBAAgB,CAAC,OAAqB;QAC9C,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QACxB,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAA4B,YAAY,CAAC,CAAC;QAExF,IAAI,gBAAgB,EAAE;YACpB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAAC,GAAG,CAAC;YACtD,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;SACjG;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,UAAU;QAClB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA3GC;IADC,MAAM,EAAE;8BACW,eAAe;+CAAC;AAJzB,aAAa;IADzB,UAAU,EAAE;GACA,aAAa,CA+GzB;SA/GY,aAAa","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {MongooseConnectionOptions} from \"@tsed/mongoose\";\nimport {Db} from \"mongodb\";\nimport {Mongoose} from \"mongoose\";\nimport {promisify} from \"util\";\nimport {Formio} from \"../domain/Formio\";\nimport {FormioConfig} from \"../domain/FormioConfig\";\nimport {FormioHook, FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioSchemas} from \"../domain/FormioModels\";\nimport {FormioRouter} from \"../domain/FormioRouter\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioExportOptions} from \"../domain/FormioTemplateUtil\";\n\nconst createRouter = require(\"formio\");\nconst swagger = require(\"formio/src/util/swagger.js\");\nconst util = require(\"formio/src/util/util.js\");\n\n@Injectable()\nexport class FormioService {\n router: FormioRouter;\n\n @Inject()\n protected injector: InjectorService;\n\n get audit(): Function {\n return this.formio.audit || (() => {});\n }\n\n get auth() {\n return this.formio.auth;\n }\n\n // istanbul ignore next\n get swagger() {\n return (...args: any[]) => new Promise((resolve) => swagger(...args, resolve));\n }\n\n get config(): FormioConfig {\n return this.formio.config;\n }\n\n get db(): Db {\n return this.formio.db;\n }\n\n get resources() {\n return this.formio.resources;\n }\n\n get mongoose(): Mongoose {\n return this.formio.mongoose;\n }\n\n get middleware() {\n return this.formio.middleware;\n }\n\n get schemas(): FormioSchemas {\n return this.formio.schemas;\n }\n\n get formio(): Formio {\n return this.router.formio as Formio;\n }\n\n get hook(): FormioHook {\n return this.formio.hook;\n }\n\n get util() {\n return this.formio.util;\n }\n\n get template() {\n return this.formio.template;\n }\n\n get Action() {\n return this.formio.Action;\n }\n\n async exportTemplate(options: Partial<FormioExportOptions> = {}): Promise<FormioTemplate> {\n return promisify(this.formio.template.export)(options);\n }\n\n async importTemplate(template: FormioTemplate): Promise<FormioTemplate> {\n return promisify(this.formio.template.import.template)(template);\n }\n\n encrypt(text: string) {\n return promisify(this.formio.encrypt)(text);\n }\n\n isInit() {\n return !!this.router;\n }\n\n // istanbul ignore next\n public createRouter(options: FormioConfig) {\n return createRouter(options);\n }\n\n public init(options: FormioConfig, hooks: FormioHooks = {}) {\n if (options && Object.keys(options).length) {\n this.router = this.createRouter(this.mapConfiguration(options));\n this.bindLogger();\n\n return this.router.init(hooks);\n }\n }\n\n protected mapConfiguration(options: FormioConfig) {\n const {injector} = this;\n const mongooseSettings = injector.settings.get<MongooseConnectionOptions>(\"mongoose.0\");\n\n if (mongooseSettings) {\n options.mongo = options.mongo || mongooseSettings.url;\n options.mongoConfig = options.mongoConfig || JSON.stringify(mongooseSettings.connectionOptions);\n }\n\n return options;\n }\n\n protected bindLogger() {\n const {injector} = this;\n\n util.log = injector.logger.info.bind(injector.logger);\n util.error = injector.logger.error.bind(injector.logger);\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export function isMongoId(text) {
2
+ return text.toString().match(/^[0-9a-fA-F]{24}$/);
3
+ }
4
+ //# sourceMappingURL=isMongoId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMongoId.js","sourceRoot":"","sources":["../../../src/utils/isMongoId.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACpD,CAAC","sourcesContent":["export function isMongoId(text: string) {\n return text.toString().match(/^[0-9a-fA-F]{24}$/);\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { InjectorService, OnReady, OnRoutesInit, PlatformApplication, PlatformRouteDetails } from "@tsed/common";
2
+ import { FormioConfig } from "./domain/FormioConfig";
3
+ import { FormioTemplate } from "./domain/FormioTemplate";
4
+ import { FormioHooksService } from "./services/FormioHooksService";
5
+ import { FormioInstaller } from "./services/FormioInstaller";
6
+ import { FormioService } from "./services/FormioService";
7
+ export declare class FormioModule implements OnRoutesInit, OnReady {
8
+ protected formio: FormioService;
9
+ protected hooks: FormioHooksService;
10
+ protected installer: FormioInstaller;
11
+ protected app: PlatformApplication;
12
+ protected injector: InjectorService;
13
+ protected settings: FormioConfig;
14
+ protected baseUrl: string;
15
+ protected skipInstall: boolean;
16
+ protected template?: FormioTemplate;
17
+ protected root?: any;
18
+ $onInit(): Promise<import(".").Formio | undefined>;
19
+ init(options: FormioConfig): Promise<import(".").Formio | undefined>;
20
+ $onRoutesInit(): Promise<void>;
21
+ $logRoutes(routes: PlatformRouteDetails[]): Promise<PlatformRouteDetails[]>;
22
+ $onReady(): Promise<void>;
23
+ protected shouldInstall(): Promise<boolean | undefined>;
24
+ }
@@ -0,0 +1,11 @@
1
+ import { FormioCtxMapper } from "../domain/FormioCtxMapper";
2
+ export declare class FormioMapper {
3
+ readonly ctxData: FormioCtxMapper;
4
+ constructor(ctxData: FormioCtxMapper);
5
+ find(key: string): any;
6
+ findId(data: string): any;
7
+ findMachineName(data: any): string | undefined;
8
+ mapToExport(data: any): any;
9
+ mapToImport(data: any): any;
10
+ mapData(data: any, resolver: any): any;
11
+ }
@@ -0,0 +1,15 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { InjectorService, Provider } from "@tsed/di";
3
+ import { AlterHook } from "../domain/AlterHook";
4
+ import { SetActionItemMessage } from "../domain/FormioAction";
5
+ import { FormioActions } from "../domain/FormioActionsIndex";
6
+ import { FormioService } from "../services/FormioService";
7
+ export declare class AlterActions implements AlterHook {
8
+ protected injector: InjectorService;
9
+ protected formio: FormioService;
10
+ transform(actions: FormioActions): FormioActions;
11
+ protected getActions(): Provider<any>[];
12
+ protected createResolveHandler(provider: Provider<any>): (action: any, handler: string, method: string, req: {
13
+ $ctx: PlatformContext;
14
+ }, res: Response, next: any, setActionItemMessage: SetActionItemMessage) => void;
15
+ }
@@ -0,0 +1,5 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { AlterHook } from "../domain/AlterHook";
3
+ export declare class AlterAudit implements AlterHook {
4
+ transform(info: any[], event: string, ctx: PlatformContext): boolean;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { AlterHook } from "../domain/AlterHook";
3
+ export declare class AlterHost implements AlterHook<string> {
4
+ transform(baseUrl: string, ctx: PlatformContext): string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { AlterHook } from "../domain/AlterHook";
3
+ export declare class AlterLog implements AlterHook {
4
+ transform(event: string, ctx: PlatformContext, ...info: any[]): boolean;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { AlterHook } from "../domain/AlterHook";
3
+ export declare class AlterSkip implements AlterHook {
4
+ baseUrl: string;
5
+ whiteList: string[];
6
+ transform(value: any, ctx: PlatformContext): any;
7
+ }
@@ -0,0 +1,12 @@
1
+ import { MongooseDocument } from "@tsed/mongoose";
2
+ import { FormioMapper } from "../builder/FormioMapper";
3
+ import { AlterHook } from "../domain/AlterHook";
4
+ import { FormioSubmission } from "../domain/FormioModels";
5
+ import { FormioTemplate } from "../domain/FormioTemplate";
6
+ import { FormioDatabase } from "../services/FormioDatabase";
7
+ export declare class AlterTemplateExportSteps implements AlterHook {
8
+ protected database: FormioDatabase;
9
+ transform(queue: any[], template: FormioTemplate, map: any, options: any): any;
10
+ protected exportSubmissions(template: FormioTemplate, map: any, options: any, next: any): Promise<void>;
11
+ protected mapSubmissions(submissions: MongooseDocument<FormioSubmission>[], mapper: FormioMapper): any;
12
+ }
@@ -0,0 +1,11 @@
1
+ import { FormioMapper } from "../builder/FormioMapper";
2
+ import { AlterHook } from "../domain/AlterHook";
3
+ import { FormioSubmission } from "../domain/FormioModels";
4
+ import { FormioTemplate } from "../domain/FormioTemplate";
5
+ import { FormioDatabase } from "../services/FormioDatabase";
6
+ export declare class AlterTemplateImportSteps implements AlterHook {
7
+ protected database: FormioDatabase;
8
+ transform(queue: any[], install: Function, template: Partial<FormioTemplate>): any;
9
+ protected importSubmissions(template: Partial<FormioTemplate>, done: any): Promise<void>;
10
+ protected importSubmission(submission: Partial<FormioSubmission>, mapper: FormioMapper): Promise<any>;
11
+ }
@@ -0,0 +1,7 @@
1
+ import { FormioActionInfo } from "@tsed/formio-types";
2
+ /**
3
+ * Create a new FormIO Action.
4
+ * @param options
5
+ * @decorator
6
+ */
7
+ export declare function Action(options: FormioActionInfo): ClassDecorator;
@@ -0,0 +1,23 @@
1
+ import { SetActionItemMessage } from "../domain/FormioAction";
2
+ import { FormioAction } from "@tsed/formio-types";
3
+ /**
4
+ * Return the current action context with the following data:
5
+ *
6
+ * ```typescript
7
+ * export type ActionCtx = {
8
+ * handler: string;
9
+ * method: string;
10
+ * setActionItemMessage: SetActionItemMessage;
11
+ * action: FormioAction;
12
+ * };
13
+ * ```
14
+ * @param expression
15
+ * @constructor
16
+ */
17
+ export declare function ActionCtx(expression?: string): ParameterDecorator;
18
+ export declare type ActionCtx = {
19
+ handler: string;
20
+ method: string;
21
+ setActionItemMessage: SetActionItemMessage;
22
+ action: FormioAction;
23
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * @param name
4
+ * @constructor
5
+ */
6
+ export declare function Alter(name: string): ClassDecorator;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Create a Form io hook event listener
3
+ * @param name
4
+ * @constructor
5
+ */
6
+ export declare function On(name: string): ClassDecorator;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Check if a user is connected by using the Formio Auth middleware
3
+ * @decorator
4
+ * @formio
5
+ */
6
+ export declare function UseFormioAuth(): Function;
@@ -0,0 +1,3 @@
1
+ export interface AlterHook<T = any> {
2
+ transform(...args: any[]): T;
3
+ }
@@ -0,0 +1,112 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "events";
3
+ import { NextFunction, Request, Response } from "express";
4
+ import { Db } from "mongodb";
5
+ import { Mongoose, Schema } from "mongoose";
6
+ import { FormioActionModelCtor } from "./FormioAction";
7
+ import { FormioActionsIndex } from "./FormioActionsIndex";
8
+ import { FormioAuth } from "./FormioAuth";
9
+ import { FormioBaseModel } from "./FormioBaseModel";
10
+ import { FormioConfig } from "./FormioConfig";
11
+ import { FormioHook, FormioHooks } from "./FormioHooks";
12
+ import { FormioModels, FormioSchemas } from "./FormioModels";
13
+ import { FormioTemplateUtil } from "./FormioTemplateUtil";
14
+ import { FormioUpdate } from "./FormioUpdate";
15
+ import { FormioUtil } from "./FormioUtils";
16
+ export interface FormioBase {
17
+ /**
18
+ * Auth
19
+ */
20
+ auth: FormioAuth;
21
+ /**
22
+ * Event emitter
23
+ */
24
+ events: EventEmitter;
25
+ /**
26
+ * Formio configuration
27
+ */
28
+ config: FormioConfig & {
29
+ schema: string;
30
+ };
31
+ /**
32
+ * Emit alter `log` event. Return false to disable event logging.
33
+ * @param event
34
+ * @param req
35
+ * @param info
36
+ */
37
+ log(event: string, req: Request, ...info: any[]): void;
38
+ /**
39
+ * Emit alter `audit` event if `config.audit` is enabled. Return false to disable event logging.
40
+ * Use `console.log`.
41
+ * @param event
42
+ * @param req
43
+ * @param info
44
+ */
45
+ audit(event: string, req: Request, ...info: any[]): void;
46
+ }
47
+ export interface FormioMiddlewares {
48
+ alias(req: Request, res: Response, next: NextFunction): void;
49
+ params(req: Request, res: Response, next: NextFunction): void;
50
+ accessHandler(req: Request, res: Response, next: NextFunction): void;
51
+ /**
52
+ * Authorize all urls based on roles and permissions.
53
+ * @param req
54
+ * @param res
55
+ * @param next
56
+ */
57
+ permissionHandler(req: Request, res: Response, next: NextFunction): void;
58
+ restrictRequestTypes(req: Request, res: Response, next: NextFunction): void;
59
+ tokenHandler(req: Request, res: Response, next: NextFunction): void;
60
+ }
61
+ export interface Formio extends FormioBase {
62
+ Action: FormioActionModelCtor;
63
+ BaseModel: FormioBaseModel;
64
+ actions: FormioActionsIndex;
65
+ resources: any;
66
+ /**
67
+ * Database connection
68
+ */
69
+ db: Db;
70
+ schemas: FormioSchemas & {
71
+ AccessSchema: Schema;
72
+ PermissionSchema: Schema;
73
+ FieldMatchAccessPermissionSchema: Schema;
74
+ };
75
+ models: FormioModels;
76
+ /**
77
+ * Mongoose lib.
78
+ */
79
+ mongoose: Mongoose;
80
+ /**
81
+ * Exported formio middlewares
82
+ */
83
+ readonly middleware: FormioMiddlewares;
84
+ /**
85
+ * Hooks.
86
+ */
87
+ hooks: FormioHooks;
88
+ /**
89
+ * Plugins.
90
+ */
91
+ plugins: any;
92
+ /**
93
+ * Formio hook util.
94
+ */
95
+ readonly hook: FormioHook;
96
+ /**
97
+ * The formio utils.
98
+ */
99
+ readonly util: FormioUtil;
100
+ /**
101
+ * Update system.
102
+ */
103
+ readonly update: FormioUpdate;
104
+ /**
105
+ * Template export/import
106
+ */
107
+ readonly template: FormioTemplateUtil;
108
+ /**
109
+ * Encryption system.
110
+ */
111
+ encrypt(text: string, next: (err: null | Error, hash: string) => void): void;
112
+ }
@@ -0,0 +1,20 @@
1
+ import { Request, Response } from "express";
2
+ import { FormioMongooseSchema } from "./FormioBaseModel";
3
+ import { FormioComponent } from "./FormioModels";
4
+ import { FormioAction, FormioActionInfo } from "@tsed/formio-types";
5
+ export interface FormioActionModel extends FormioAction {
6
+ resolve(handler: string, method: string, req: Request, res: Response, next: Function, setActionItemMessage: SetActionItemMessage): void;
7
+ }
8
+ export declare type FormioActionMongooseSchema = FormioMongooseSchema<FormioAction>;
9
+ export declare type SetActionItemMessage = (message: string, data?: any, state?: any) => void;
10
+ export interface FormioActionModelCtor {
11
+ schema?: FormioActionMongooseSchema;
12
+ info(req: Request, response: Response, next: (err: any, info: FormioActionInfo) => void): void;
13
+ settingsForm(req: Request, response: Response, next: (err: any, info: FormioComponent[]) => void): void;
14
+ new (data: FormioAction, req: Request, res: Response): FormioActionModel;
15
+ }
16
+ export interface ActionMethods {
17
+ info?(req: Request, response: Response): Promise<FormioAction>;
18
+ settingsForm(req: Request, response: Response): Promise<FormioComponent[]>;
19
+ resolve(...args: any[]): Promise<any>;
20
+ }
@@ -0,0 +1,15 @@
1
+ import { Type } from "@tsed/core";
2
+ import { FormioActionModelCtor } from "./FormioAction";
3
+ export interface FormioActions {
4
+ email: FormioActionModelCtor;
5
+ login: FormioActionModelCtor;
6
+ resetpass: FormioActionModelCtor;
7
+ role: FormioActionModelCtor;
8
+ save: FormioActionModelCtor;
9
+ sql: FormioActionModelCtor;
10
+ webhook: FormioActionModelCtor;
11
+ [key: string]: FormioActionModelCtor;
12
+ }
13
+ export interface FormioActionsIndex {
14
+ actions: FormioActions & Record<string, Type<FormioActionModelCtor>>;
15
+ }