@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioAction.js","sourceRoot":"","sources":["../../../src/domain/FormioAction.ts"],"names":[],"mappings":"","sourcesContent":["import {Request, Response} from \"express\";\nimport {FormioMongooseSchema} from \"./FormioBaseModel\";\nimport {FormioComponent} from \"./FormioModels\";\nimport {FormioAction, FormioActionInfo} from \"@tsed/formio-types\";\n\nexport interface FormioActionModel extends FormioAction {\n resolve(handler: string, method: string, req: Request, res: Response, next: Function, setActionItemMessage: SetActionItemMessage): void;\n}\n\nexport type FormioActionMongooseSchema = FormioMongooseSchema<FormioAction>;\nexport type SetActionItemMessage = (message: string, data?: any, state?: any) => void;\n\nexport interface FormioActionModelCtor {\n schema?: FormioActionMongooseSchema;\n\n info(req: Request, response: Response, next: (err: any, info: FormioActionInfo) => void): void;\n\n settingsForm(req: Request, response: Response, next: (err: any, info: FormioComponent[]) => void): void;\n\n new (data: FormioAction, req: Request, res: Response): FormioActionModel;\n}\n\nexport interface ActionMethods {\n info?(req: Request, response: Response): Promise<FormioAction>;\n\n settingsForm(req: Request, response: Response): Promise<FormioComponent[]>;\n\n resolve(...args: any[]): Promise<any>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioActionsIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioActionsIndex.js","sourceRoot":"","sources":["../../../src/domain/FormioActionsIndex.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {FormioActionModelCtor} from \"./FormioAction\";\n\nexport interface FormioActions {\n email: FormioActionModelCtor;\n login: FormioActionModelCtor;\n resetpass: FormioActionModelCtor;\n role: FormioActionModelCtor;\n save: FormioActionModelCtor;\n sql: FormioActionModelCtor;\n webhook: FormioActionModelCtor;\n\n [key: string]: FormioActionModelCtor;\n}\n\nexport interface FormioActionsIndex {\n actions: FormioActions & Record<string, Type<FormioActionModelCtor>>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioAuth.js","sourceRoot":"","sources":["../../../src/domain/FormioAuth.ts"],"names":[],"mappings":"","sourcesContent":["import {Next, Req, Res} from \"@tsed/common\";\nimport {FormioDecodedToken, FormioPayloadToken} from \"./FormioDecodedToken\";\nimport {FormioForm} from \"./FormioModels\";\n\nexport interface FormioAuth {\n /**\n * Send the current user.\n *\n * @param req\n * @param res\n * @param next\n */\n currentUser(req: Req, res: Res, next: Function): void;\n\n /**\n * Checks to see if a decoded token is allowed to access this path.\n * @param req\n * @param decoded\n * @return {boolean}\n */\n isTokenAllowed(req: Req, decoded: FormioDecodedToken): boolean;\n\n /**\n * Generate our JWT with the given payload, and pass it to the given callback function.\n *\n * @param payload {Object}\n * The decoded JWT.\n *\n * @return {String|Boolean}\n * The JWT from the given payload, or false if the jwt payload is still valid.\n */\n getToken(payload: FormioPayloadToken): string | boolean;\n\n /**\n * Generate a temporary token for a specific path and expiration.\n *\n * @param req\n * @param res\n * @param allow\n * @param expire\n * @param admin\n * @param cb\n */\n getTempToken(req: Req, res: Res, allow: boolean, expire: number, admin: boolean, cb: Function): void;\n\n tempToken(req: Req, res: Res): void;\n\n /**\n * Authenticate a user.\n *\n * @param req\n * @param forms {Mixed}\n * A single form or an array of forms to authenticate against.\n * @param userField {String}\n * The user submission field that contains the username.\n * @param passField {String}\n * The user submission field that contains the password.\n * @param username {String}\n * The user submission username to login with.\n * @param password {String}\n * The user submission password to login with.\n * @param next {Function}\n * The callback function to call after authentication.\n */\n authenticate(\n req: Req,\n forms: FormioForm | FormioForm[],\n userField: string,\n passField: string,\n username: string,\n password: string,\n next: Function\n ): void;\n\n /**\n * Interception logout request.\n * @param req\n * @param res\n * @param next\n */\n logout(req: Req, res: Res, next: Next): void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioBaseModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioBaseModel.js","sourceRoot":"","sources":["../../../src/domain/FormioBaseModel.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Schema, Document} from \"mongoose\";\n\nexport type FormioMongooseSchema<T> = Schema<Document<T>> & {\n machineName(document: MongooseDocument<T>, done: Function): void;\n};\n\nexport interface FormioBaseModel<T = any> {\n schema: Schema<Document<T>>;\n}\n\nexport interface FormioModel<T = any> extends FormioBaseModel<T> {\n schema: FormioMongooseSchema<T>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioConfig.js","sourceRoot":"","sources":["../../../src/domain/FormioConfig.ts"],"names":[],"mappings":"","sourcesContent":["import {FormioSettings} from \"./FormioSettings\";\nimport {FormioTemplate} from \"./FormioTemplate\";\n\nexport interface FormioJwtConfig {\n secret: string;\n expireTime?: number;\n}\n\nexport interface FormioEmailConfig {\n type: string;\n username: string;\n password: string;\n}\n\nexport interface FormioConfig {\n /**\n * Base url to mount the formio endpoints with Ts.ED server. Default: '/'\n */\n baseUrl: string;\n /**\n * Skip installation process\n */\n skipInstall?: boolean;\n\n template?: FormioTemplate;\n /**\n * Cors allowed origin configuration. Default: `[\"*\"]`.\n */\n allowedOrigins?: string[];\n /**\n *\n */\n mongoCA?: any;\n mongo?: string;\n mongoConfig?: string;\n /**\n * Reserved keywords form name list\n */\n reservedForms?: string[];\n /**\n * Jwt configuration\n */\n jwt: FormioJwtConfig;\n /**\n * Email sendgrid settings\n */\n email?: FormioEmailConfig;\n /**\n * Settings of external formio services\n */\n settings?: FormioSettings;\n /**\n * Enable audit log. Default: false\n */\n audit?: boolean;\n /**\n * User root credentials\n */\n root: {\n email: string;\n password: string;\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioCtxMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioCtxMapper.js","sourceRoot":"","sources":["../../../src/domain/FormioCtxMapper.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {FormioAction, FormioForm, FormioRole} from \"@tsed/formio-types\";\n\nexport interface FormioCtxMapper {\n forms: Map<string, MongooseDocument<FormioForm>>;\n actions: Map<string, MongooseDocument<FormioAction>>;\n roles: Map<string, MongooseDocument<FormioRole>>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioDecodedToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioDecodedToken.js","sourceRoot":"","sources":["../../../src/domain/FormioDecodedToken.ts"],"names":[],"mappings":"","sourcesContent":["export interface FormioDecodedToken extends Record<string, unknown> {\n user: {\n _id: string;\n };\n form: {\n _id: string;\n };\n}\n\nexport interface FormioPayloadToken {\n token: string;\n decoded: FormioDecodedToken;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioErrors.js","sourceRoot":"","sources":["../../../src/domain/FormioErrors.ts"],"names":[],"mappings":"","sourcesContent":["export interface FormioErrors {\n app: {\n ESETTINGSLOAD: \"Cannot load app settings.\";\n EDBCONFIG: \"Database settings is missing.\";\n EDBHOST: \"Invalid SQL Host.\";\n };\n db: {\n EINVQUERY: \"Invalid query.\";\n EDBCONN: \"Connection error.\";\n EQUERY: \"Query request error.\";\n };\n emailer: {\n ENOTRANSP: \"Cannot get emailer transports.\";\n ESENDMAIL: \"Email sending failed.\";\n ESUBPARAMS: \"Failed to get substitution parameters.\";\n };\n cache: {\n EFORMLOAD: \"Cannot load form.\";\n };\n form: {\n ENOFORM: \"Form not found.\";\n };\n auth: {\n EAUTH: \"Authentication failed.\";\n EPASSFIELD: \"Invalid password field.\";\n EPASSRESET: \"Unable to change password.\";\n ERESETTOKEN: \"Invalid reset password token.\";\n ENOPASSP: \"No password provided.\";\n ELOGINCOUNT: \"Unable to update login count.\";\n };\n submission: {\n ENOSUB: \"Submission not found.\";\n ESUBLOAD: \"Cannot load submission.\";\n ESUBSAVE: \"Cannot save submission.\";\n };\n user: {\n ENOUSER: \"User not found.\";\n ENONAMEP: \"No user name provided.\";\n };\n role: {\n EROLESLOAD: \"Cannot load the Roles.\";\n ENOROLE: \"Role not found.\";\n EROLELOAD: \"Cannot load role.\";\n EROLEEXIST: \"Provided role already exists.\";\n };\n request: {\n EREQRECUR: \"Too many recursive requests.\";\n };\n resource: {\n ENOIDP: \"Resource id is missing.\";\n ENOHANDLER: \"Resource handler not found.\";\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioHooks.js","sourceRoot":"","sources":["../../../src/domain/FormioHooks.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Request} from \"express\";\nimport {FilterQuery, Schema, SchemaDefinition} from \"mongoose\";\nimport {Formio} from \"./Formio\";\nimport {FormioActions} from \"./FormioActionsIndex\";\nimport {FormioConfig} from \"./FormioConfig\";\nimport {FormioDecodedToken} from \"./FormioDecodedToken\";\nimport {FormioJs} from \"./FormioJs\";\nimport {FormioActionItem, FormioForm, FormioModelsModels, FormioSubmission} from \"./FormioModels\";\nimport {FormioSettings} from \"./FormioSettings\";\nimport {ResourceRestOptions} from \"./Resource\";\n\nexport type FormioInitEvent = \"alias\" | \"params\" | \"token\" | \"getTempToken\" | \"logout\" | \"current\" | \"access\" | \"perms\";\n\nexport interface FormioHooks {\n settings?: (settings: FormioSettings, req: Request, cb: Function) => FormioSettings;\n alter?: {\n alias?: (alias: string, req: Request, res: Response) => string;\n /**\n * Alter FormioJs configuration\n * @param formIo\n */\n configFormio?: (formIo: {Formio: FormioJs}) => void;\n /**\n * Alter formio server configuration.\n * @param config\n */\n updateConfig?: (config: FormioConfig) => FormioConfig;\n /**\n * Alter audit log.\n * @param info\n * @param event\n * @param req\n */\n audit?: (info: any[], event: string, req: Request) => void;\n /**\n * Alter log.\n * @param info\n * @param event\n * @param req\n */\n log?: (event: string, req: Request, ...info: string[]) => void;\n /**\n * Alter available actions\n * @param info\n * @param event\n * @param req\n */\n actions?: (actions: FormioActions) => FormioActions;\n /**\n * Skip auth for the current request.\n * @param info\n * @param event\n * @param req\n */\n skip?: (value: boolean, req: Request) => boolean;\n /**\n * Resolve host.\n * @param baseUrl\n * @param req\n */\n host?: (baseUrl: string, req: Request) => string;\n /**\n * `/form/${req.params.formId}/action`\n * @param action\n * @param req\n */\n path?: (path: string, req: Request) => any;\n /**\n * Restrict request types\n * @param methods\n */\n methods?: (methods: string[]) => string[];\n /**\n * Return the cors configuration.\n */\n cors?: () => Record<string, any>;\n /**\n * Return the current user submission.\n */\n currentUser?: (user: any) => any;\n /**\n * Alter current form.\n * @param form\n */\n currentForm?: (form: FormioForm) => FormioForm;\n /**\n * Alter formio\n * @param formio\n */\n formio?: (formio: Formio) => Formio;\n /**\n * Alter models\n * @param models\n */\n models?: (models: FormioModelsModels) => FormioModelsModels;\n /**\n * Alter resources\n * @param resources\n */\n resources?: (resources: {form: any; submission: any; role: any}) => any;\n\n resourceAccessFilter?: (search: any, req: Request, done: (err: unknown, newSearch: any) => void) => void;\n\n // machineName\n actionMachineName?: (name: string, document: MongooseDocument<any>, done: Function) => void;\n formMachineName?: (name: string, document: MongooseDocument<any>, done: Function) => void;\n roleMachineName?: (name: string, document: MongooseDocument<any>, done: Function) => void;\n\n // schemas\n actionSchema?: (schema: Schema) => Schema;\n actionItemSchema?: (schema: Schema) => Schema;\n formSchema?: (schema: Schema) => Schema;\n roleSchema?: (schema: Schema) => Schema;\n schemaSchema?: (schema: Schema) => Schema;\n submissionSchema?: (schema: Schema | SchemaDefinition) => Schema;\n tokenSchema?: (schema: Schema) => Schema;\n permissionSchema?: (schema: SchemaDefinition) => SchemaDefinition;\n fieldMatchAccessPermissionSchema?: (schemaOptions: SchemaDefinition) => SchemaDefinition;\n\n // query\n actionsQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n submissionQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n roleQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n formQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n\n // Data\n actionItem?: (actionItem: FormioActionItem, req: Request) => FormioActionItem;\n actionContext?: (actionContext: any, req: Request) => any;\n actionInfo?: (action: any, req: Request) => any;\n\n // submission\n submission?: (req: Request, res: Response, done: Function) => void;\n submissionRequest?: (submission: FormioSubmission) => FormioSubmission;\n validateSubmissionForm?: (form: FormioForm, submission: FormioSubmission, done: Function) => void;\n postSubmissionUpdate?: (req: Request, res: Response, submissionUpdate: FormioSubmission) => void;\n\n // response\n /**\n * Allow modules to hook into the form loader middleware.\n * @param item\n * @param req\n * @param done\n */\n formResponse?: (item: any, req: Request, done: Function) => void;\n\n // params\n requestParams?: (req: Request & {formId: string; subId: string; roleId: string}, params: Record<string, any>) => void;\n /**\n * Alter submitted params\n * @param params\n */\n submissionParams?: (params: string[]) => string[];\n\n // Routes\n /**\n * Alter actions routes.\n */\n actionRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n /**\n * Alter roles routes.\n */\n rolesRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n /**\n * Alter forms routes.\n */\n formRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n /**\n * Alter submission routes.\n */\n submissionRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n\n // Auth\n user?: (user: any, done: (err: any, user: any) => void) => void;\n login?: (user: any, req: Request, done: (err: any) => void) => void;\n token?: (token: FormioDecodedToken, form: FormioForm, req: Request) => FormioDecodedToken;\n tokenDecode?: (token: FormioDecodedToken, req: Request, done: (err: any, decoded: FormioDecodedToken) => void) => void;\n submissionRequestTokenQuery?: (query: {formId: string; submissionId: string}, token: string) => any;\n\n [key: string]: any;\n };\n on?: {\n init?: (type: FormioInitEvent) => boolean;\n [key: string]: any;\n };\n}\n\nexport interface FormioHook {\n /**\n * Run settings function.\n */\n settings(req: Request, cb: Function): void;\n\n /**\n * Emit an event.\n * @param args\n */\n invoke<T = any>(...args: any[]): T | boolean;\n\n /**\n * Alter the given value by calling all listener.\n * @param event\n * @param args\n */\n alter(event: string, ...args: any[]): any;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioJs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioJs.js","sourceRoot":"","sources":["../../../src/domain/FormioJs.ts"],"names":[],"mappings":"","sourcesContent":["export interface FormioJs {\n forms: Record<string, any>;\n cache: Record<string, any>;\n Components: {\n components: {\n component: {\n Validator: {\n db: any | null;\n token: any | null;\n form: any | null;\n submission: any | null;\n };\n };\n };\n };\n\n getToken(): string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from "@tsed/formio-types";
2
+ //# sourceMappingURL=FormioModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioModels.js","sourceRoot":"","sources":["../../../src/domain/FormioModels.ts"],"names":[],"mappings":"AAMA,cAAc,oBAAoB,CAAC","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Schema} from \"mongoose\";\nimport {FormioActionModelCtor, FormioActionMongooseSchema} from \"./FormioAction\";\nimport {FormioBaseModel, FormioModel, FormioMongooseSchema} from \"./FormioBaseModel\";\nimport {FormioActionItem, FormioForm, FormioRole, FormioSchema, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\n\nexport * from \"@tsed/formio-types\";\n\nexport type WithID<T> = T & {_id: string};\n\nexport interface FormioSchemas {\n action: FormioActionMongooseSchema;\n actionItem: Schema<MongooseDocument<FormioActionItem>>;\n form: FormioMongooseSchema<FormioForm>;\n role: FormioMongooseSchema<FormioRole>;\n schema: Schema<MongooseDocument<FormioSchema>>;\n submission: Schema<MongooseDocument<FormioSubmission>>;\n token: Schema<MongooseDocument<FormioToken>>;\n\n [key: string]: Schema<MongooseDocument<any>>;\n}\n\nexport type FormioModelsModels = {\n action: FormioActionModelCtor;\n actionItem: FormioBaseModel<FormioActionItem>;\n form: FormioModel<FormioForm>;\n role: FormioModel<FormioRole>;\n schema: FormioBaseModel<FormioSchema>;\n submission: FormioBaseModel<FormioSubmission>;\n token: FormioBaseModel<FormioToken>;\n} & Record<string, FormioBaseModel>;\n\nexport interface FormioModels {\n schemas: FormioSchemas;\n models: FormioModelsModels;\n specs: {\n action: any;\n actionItem: any;\n form: any;\n role: any;\n schema: any;\n submission: any;\n token: any;\n\n [key: string]: any;\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioRouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioRouter.js","sourceRoot":"","sources":["../../../src/domain/FormioRouter.ts"],"names":[],"mappings":"","sourcesContent":["import {Router} from \"express\";\nimport {Formio, FormioBase} from \"./Formio\";\nimport {FormioHooks} from \"./FormioHooks\";\n\nexport interface FormioRouter extends Router {\n formio: FormioBase;\n\n init(hooks: FormioHooks): Promise<Formio>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioSettings.js","sourceRoot":"","sources":["../../../src/domain/FormioSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface FormioSettings extends Record<string, any> {\n office365: {\n tenant: string;\n clientId: string;\n email: string;\n cert: string;\n thumbprint: string;\n\n [key: string]: any;\n };\n\n databases: {\n mysql: {\n host: string;\n port: string;\n database: string;\n user: string;\n password: string;\n\n [key: string]: any;\n };\n mssql: {\n host: string;\n port: string;\n database: string;\n user: string;\n password: string;\n\n [key: string]: any;\n };\n };\n email: {\n gmail: {\n auth: {\n user: string;\n pass: string;\n [key: string]: any;\n };\n\n [key: string]: any;\n };\n sendgrid: {\n auth: {\n api_user: string;\n api_key: string;\n\n [key: string]: any;\n };\n\n [key: string]: any;\n };\n mandrill: {\n auth: {\n apiKey: string;\n\n [key: string]: any;\n };\n [key: string]: any;\n };\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioTemplate.js","sourceRoot":"","sources":["../../../src/domain/FormioTemplate.ts"],"names":[],"mappings":"","sourcesContent":["import {FormioActionItem, FormioForm, FormioRole, FormioSubmission} from \"./FormioModels\";\n\nexport interface FormioTemplate {\n roles?: Record<string, FormioRole>;\n forms: Record<string, FormioForm>;\n resources: Record<string, FormioForm>;\n actions: Record<string, FormioActionItem>;\n submissions?: Record<string, FormioSubmission[]>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioTemplateUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioTemplateUtil.js","sourceRoot":"","sources":["../../../src/domain/FormioTemplateUtil.ts"],"names":[],"mappings":"","sourcesContent":["import {FormioTemplate} from \"./FormioTemplate\";\n\nexport interface FormioExportOptions {\n title: string;\n version: string;\n description: string;\n name: string;\n}\n\nexport interface FormioTemplateUtil {\n import: {\n template(template: FormioTemplate, cb: (er: unknown, data: FormioTemplate) => void): void;\n };\n export(options: Partial<FormioExportOptions>, cb: (er: unknown, data: FormioTemplate) => void): void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioUpdate.js","sourceRoot":"","sources":["../../../src/domain/FormioUpdate.ts"],"names":[],"mappings":"","sourcesContent":["import {NextFunction, Request, Response} from \"express\";\nimport {Db} from \"mongodb\";\nimport {Formio} from \"./Formio\";\n\nexport interface FormioUpdate {\n db: Db;\n version: string;\n\n /**\n *\n * @param cb\n */\n initialize(cb: (err: unknown, db: any) => void): Promise<Formio>;\n\n /**\n *\n * @param req\n * @param res\n * @param next\n */\n sanityCheck(req: Request, res: Response, next: NextFunction): void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FormioUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioUtils.js","sourceRoot":"","sources":["../../../src/domain/FormioUtils.ts"],"names":[],"mappings":"","sourcesContent":["import {Request, Response} from \"express\";\nimport {FormioErrors} from \"./FormioErrors\";\nimport {FormioJs} from \"./FormioJs\";\n\nexport interface FormioUtil {\n Formio: FormioJs;\n /**\n * Iterate through each component within a form.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Function} fn\n * The iteration function to invoke for each component.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n * @param {String} path\n */\n eachComponent: Function;\n /**\n * Get a component by its key\n *\n * @param {Object} components\n * The components to iterate.\n * @param {String} key\n * The key of the component to get.\n *\n * @returns {Object}\n * The component that matches the given key, or undefined if not found.\n */\n getComponent: Function;\n /**\n * Define if component should be considered input component\n *\n * @param {Object} componentJson\n * JSON of component to check\n *\n * @returns {Boolean}\n * If component is input or not\n */\n isInputComponent: Function;\n /**\n * Flatten the form components for data manipulation.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n *\n * @returns {Object}\n * The flattened components map.\n */\n flattenComponents: Function;\n /**\n * Get the value for a component key, in the given submission.\n *\n * @param {Object} submission\n * A submission object to search.\n * @param {String} key\n * A for components API key to search for.\n */\n getValue: Function;\n /**\n * Determine if a component is a layout component or not.\n *\n * @param {Object} component\n * The component to check.\n *\n * @returns {Boolean}\n * Whether or not the component is a layout component.\n */\n isLayoutComponent: Function;\n /**\n * Apply JSON logic functionality.\n *\n * @param component\n * @param row\n * @param data\n */\n jsonLogic: Function;\n /**\n * Check if the condition for a component is true or not.\n *\n * @param component\n * @param row\n * @param data\n */\n checkCondition: Function;\n flattenComponentsForRender: Function;\n renderFormSubmission: Function;\n renderComponentValue: Function;\n /**\n * A node-fetch shim adding support for http(s) proxy and allowing\n * invalid tls certificates (to be used with self signed certificates).\n *\n * @param {any} url The request url string or url like object.\n * @param {any} options The request options object.\n * @returns {Promise<Response>} The promise with the node-fetch response object.\n */\n fetch: any;\n /* eslint-disable new-cap */\n base64: {\n /**\n * Base64 encode the given data.\n *\n * @param {String} decoded\n * The decoded data to encode.\n *\n * @return {String}\n * The base64 representation of the given data.\n */\n encode(decoded: string): string;\n /**\n * Base64 decode the given data.\n *\n * @param {String} encoded\n * The encoded data to decode.\n *\n * @return {String}\n * The ascii representation of the given encoded data.\n */\n decode(encoded: string): string;\n };\n /**\n * Application error codes.\n */\n errorCodes: FormioErrors;\n\n layoutComponents: (\"panel\" | \"table\" | \"well\" | \"columns\" | \"fieldset\" | \"tabs\" | string)[];\n\n deleteProp(target: any, propertyKey: any): any;\n\n /**\n * A wrapper around console.log that gets ignored by eslint.\n *\n * @param {*} content\n * The content to pass to console.log.\n */\n log(content: string): void;\n\n /**\n * Determine if a value is a boolean representation.\n * @param value\n * @return {boolean}\n */\n isBoolean(value: any): boolean;\n\n /**\n * Quick boolean coercer.\n * @param value\n * @return {boolean}\n */\n boolean(value: any): boolean;\n\n /**\n * A wrapper around console.error that gets ignored by eslint.\n *\n * @param {*} content\n * The content to pass to console.error.\n */\n error(content: any): void;\n\n /**\n * Returns the URL alias for a form provided the url.\n */\n getAlias(req: Request, reservedForms: string[]): {alias: string; additional: string};\n\n /**\n * Escape a string for use in regex.\n *\n * @param str\n * @returns {*}\n */\n escapeRegExp(str: string): string;\n\n /**\n * Create a sub response object that only handles errors.\n *\n * @param res\n * @return {{send: function(), sendStatus: function(*=), status: function(*=)}}\n */\n createSubResponse(res: Response): Response;\n\n /**\n * Create a sub-request object from the original request.\n *\n * @param req\n */\n createSubRequest(req: Request): Request;\n\n /**\n * Return the objectId.\n *\n * @param id\n * @returns {*}\n * @constructor\n */\n ObjectId(id: string): any;\n\n /**\n * Search the request headers for the given key.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for in the headers.\n *\n * @return\n * The header value if found or false.\n */\n getHeader(req: Request, key: string): string | false;\n\n /**\n * Search the request query for the given key.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for in the query.\n *\n * @return\n * The query value if found or false.\n */\n getQuery(req: Request, key: string): any | false;\n\n /**\n * Search the request parameters for the given key.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for in the parameters.\n *\n * @return\n * The parameter value if found or false.\n */\n getParameter(req: Request, key: string): any | false;\n\n /**\n * Determine if the request has the given key set as a header or url parameter.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for.\n *\n * @return\n * Return the value of the key or false if not found.\n */\n getRequestValue(req: Request, key: string): any | false;\n\n /**\n * Split the given URL into its key/value pairs.\n *\n * @param url\n * The request url to split, typically req.url.\n *\n * @returns {{}}\n * The key/value pairs of the request url.\n */\n getUrlParams(url: string): Record<string, any>;\n\n /**\n * Converts a form component key into a submission key\n * by putting .data. between each nested component\n * (ex: `user.name` becomes `user.data.name` in a submission)\n * @param key\n * The key to convert\n * @return\n * The submission key\n */\n getSubmissionKey(key: string): string;\n\n /**\n * Converts a submission key into a form component key\n * by replacing .data. with .\n * (ex: `user.data.name` becomes `user.name` in a submission)\n * @param key\n * The key to convert\n * @return\n * The form component key\n */\n getFormComponentKey(key: string): string;\n\n /**\n * Utility function to ensure the given id is always a BSON object.\n *\n * @param _id {String|Object}\n * A mongo id as a string or object.\n *\n * @returns {Object}\n * The mongo BSON id.\n */\n idToBson(_id: string | any): any;\n\n /**\n * Utility function to ensure the given id is always a string object.\n *\n * @param _id {String|Object}\n * A mongo id as a string or object.\n *\n * @returns {String}\n * The mongo string id.\n */\n idToString(_id: string | any): string;\n\n /* eslint-enable new-cap */\n\n /**\n * Ensures that a submission data has MongoDB ObjectID's for all \"id\" fields.\n * @param data\n * @return {boolean}\n */\n ensureIds(data: any[]): any;\n\n removeProtectedFields(form: string, action: string, submissions: any): void;\n\n /**\n * Retrieve a unique machine name\n *\n * @param document\n * @param model\n * @param next\n * @return {*}\n */\n uniqueMachineName(document: {machineName: string}, model: any, next: (err?: Error) => void): void;\n\n castValue<T = any>(valueType: \"string\" | \"number\" | \"boolean\" | \"[number]\" | \"[string]\", value: any): T;\n\n valuePath(prefix: string, key: string): string;\n\n eachValue(components: any, data: any, fn: Function, context: any, path?: string): void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OnHook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnHook.js","sourceRoot":"","sources":["../../../src/domain/OnHook.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnHook<T = any> {\n on(...args: any[]): boolean | void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Resource.js","sourceRoot":"","sources":["../../../src/domain/Resource.ts"],"names":[],"mappings":"","sourcesContent":["import Express from \"express\";\n\nexport type ResourceHttpHandler = (req: Request, res: Response, next: Express.NextFunction) => void;\n\nexport interface ResourceHttpMethodOptions {\n before?: ResourceHttpHandler;\n after?: ResourceHttpHandler;\n}\n\nexport interface ResourceRestOptions extends ResourceHttpMethodOptions {\n beforePut?: ResourceHttpHandler;\n beforePatch?: ResourceHttpHandler;\n beforePost?: ResourceHttpHandler;\n beforeIndex?: ResourceHttpHandler;\n beforeGet?: ResourceHttpHandler;\n afterPut?: ResourceHttpHandler;\n afterPatch?: ResourceHttpHandler;\n afterPost?: ResourceHttpHandler;\n afterIndex?: ResourceHttpHandler;\n afterGet?: ResourceHttpHandler;\n}\n"]}
@@ -0,0 +1,43 @@
1
+ // decorators
2
+ export * from "./decorators/action";
3
+ export * from "./decorators/actionCtx";
4
+ export * from "./decorators/alter";
5
+ export * from "./decorators/on";
6
+ export * from "./decorators/useFormioAuth";
7
+ // middlewares
8
+ export * from "./middlewares/FormioAuthMiddleware";
9
+ // domain
10
+ export * from "./domain/AlterHook";
11
+ export * from "./domain/Formio";
12
+ export * from "./domain/FormioDecodedToken";
13
+ export * from "./domain/FormioAction";
14
+ export * from "./domain/FormioActionsIndex";
15
+ export * from "./domain/FormioAuth";
16
+ export * from "./domain/FormioBaseModel";
17
+ export * from "./domain/FormioConfig";
18
+ export * from "./domain/FormioCtxMapper";
19
+ export * from "./domain/FormioErrors";
20
+ export * from "./domain/FormioHooks";
21
+ export * from "./domain/FormioJs";
22
+ export * from "./domain/FormioModels";
23
+ export * from "./domain/FormioRouter";
24
+ export * from "./domain/FormioSettings";
25
+ export * from "./domain/FormioUpdate";
26
+ export * from "./domain/FormioUtils";
27
+ export * from "./domain/FormioTemplate";
28
+ export * from "./domain/FormioTemplateUtil";
29
+ export * from "./domain/OnHook";
30
+ // module
31
+ export * from "./FormioModule";
32
+ export * from "./builder/FormioMapper";
33
+ export * from "./services/FormioService";
34
+ export * from "./services/FormioDatabase";
35
+ export * from "./services/FormioDatabase";
36
+ export * from "./services/FormioAuthService";
37
+ export * from "./services/FormioHooksService";
38
+ export * from "./components/AlterActions";
39
+ export * from "./components/AlterAudit";
40
+ export * from "./components/AlterLog";
41
+ export * from "./components/AlterHost";
42
+ export * from "./components/AlterSkip";
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAE3C,cAAc;AACd,cAAc,oCAAoC,CAAC;AAEnD,SAAS;AACT,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAEhC,SAAS;AACT,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["// decorators\nexport * from \"./decorators/action\";\nexport * from \"./decorators/actionCtx\";\nexport * from \"./decorators/alter\";\nexport * from \"./decorators/on\";\nexport * from \"./decorators/useFormioAuth\";\n\n// middlewares\nexport * from \"./middlewares/FormioAuthMiddleware\";\n\n// domain\nexport * from \"./domain/AlterHook\";\nexport * from \"./domain/Formio\";\nexport * from \"./domain/FormioDecodedToken\";\nexport * from \"./domain/FormioAction\";\nexport * from \"./domain/FormioActionsIndex\";\nexport * from \"./domain/FormioAuth\";\nexport * from \"./domain/FormioBaseModel\";\nexport * from \"./domain/FormioConfig\";\nexport * from \"./domain/FormioCtxMapper\";\nexport * from \"./domain/FormioErrors\";\nexport * from \"./domain/FormioHooks\";\nexport * from \"./domain/FormioJs\";\nexport * from \"./domain/FormioModels\";\nexport * from \"./domain/FormioRouter\";\nexport * from \"./domain/FormioSettings\";\nexport * from \"./domain/FormioUpdate\";\nexport * from \"./domain/FormioUtils\";\nexport * from \"./domain/FormioTemplate\";\nexport * from \"./domain/FormioTemplateUtil\";\nexport * from \"./domain/OnHook\";\n\n// module\nexport * from \"./FormioModule\";\nexport * from \"./builder/FormioMapper\";\nexport * from \"./services/FormioService\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioAuthService\";\nexport * from \"./services/FormioHooksService\";\nexport * from \"./components/AlterActions\";\nexport * from \"./components/AlterAudit\";\nexport * from \"./components/AlterLog\";\nexport * from \"./components/AlterHost\";\nexport * from \"./components/AlterSkip\";\n"]}
@@ -0,0 +1,38 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Context, Inject, Middleware } from "@tsed/common";
3
+ import { getValue } from "@tsed/core";
4
+ import { Unauthorized } from "@tsed/exceptions";
5
+ import { promisify } from "util";
6
+ import { FormioService } from "../services/FormioService";
7
+ /**
8
+ * @middleware
9
+ * @formio
10
+ */
11
+ let FormioAuthMiddleware = class FormioAuthMiddleware {
12
+ get tokenHandler() {
13
+ return promisify(this.formio.middleware.tokenHandler);
14
+ }
15
+ async use(ctx) {
16
+ const req = ctx.getRequest();
17
+ const res = ctx.getResponse();
18
+ await this.tokenHandler(req, res);
19
+ if (!getValue(req, "token.user._id")) {
20
+ throw new Unauthorized("User unauthorized");
21
+ }
22
+ }
23
+ };
24
+ __decorate([
25
+ Inject(),
26
+ __metadata("design:type", FormioService)
27
+ ], FormioAuthMiddleware.prototype, "formio", void 0);
28
+ __decorate([
29
+ __param(0, Context()),
30
+ __metadata("design:type", Function),
31
+ __metadata("design:paramtypes", [Object]),
32
+ __metadata("design:returntype", Promise)
33
+ ], FormioAuthMiddleware.prototype, "use", null);
34
+ FormioAuthMiddleware = __decorate([
35
+ Middleware()
36
+ ], FormioAuthMiddleware);
37
+ export { FormioAuthMiddleware };
38
+ //# sourceMappingURL=FormioAuthMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioAuthMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/FormioAuthMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAExD;;;GAGG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAI/B,IAAI,YAAY;QACd,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAE9B,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE;YACpC,MAAM,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAAC;SAC7C;IACH,CAAC;CACF,CAAA;AAhBC;IADC,MAAM,EAAE;8BACS,aAAa;oDAAC;AAMhC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;+CASnB;AAjBU,oBAAoB;IADhC,UAAU,EAAE;GACA,oBAAoB,CAkBhC;SAlBY,oBAAoB","sourcesContent":["import {Context, Inject, Middleware} from \"@tsed/common\";\nimport {getValue} from \"@tsed/core\";\nimport {Unauthorized} from \"@tsed/exceptions\";\nimport {promisify} from \"util\";\nimport {FormioService} from \"../services/FormioService\";\n\n/**\n * @middleware\n * @formio\n */\n@Middleware()\nexport class FormioAuthMiddleware {\n @Inject()\n protected formio: FormioService;\n\n get tokenHandler(): any {\n return promisify(this.formio.middleware.tokenHandler);\n }\n\n async use(@Context() ctx: Context) {\n const req = ctx.getRequest();\n const res = ctx.getResponse();\n\n await this.tokenHandler(req, res);\n\n if (!getValue(req, \"token.user._id\")) {\n throw new Unauthorized(\"User unauthorized\");\n }\n }\n}\n"]}
@@ -0,0 +1,179 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { isFunction } from "@tsed/core";
3
+ import { Inject, Injectable } from "@tsed/di";
4
+ import { BadRequest, NotFound, Unauthorized } from "@tsed/exceptions";
5
+ import { promisify } from "util";
6
+ import { FormioDatabase } from "./FormioDatabase";
7
+ import { FormioHooksService } from "./FormioHooksService";
8
+ import { FormioService } from "./FormioService";
9
+ let FormioAuthService = class FormioAuthService {
10
+ get currentUser() {
11
+ return promisify(this.formio.auth.currentUser);
12
+ }
13
+ get getToken() {
14
+ return this.formio.auth.getToken;
15
+ }
16
+ get tempToken() {
17
+ return this.formio.auth.tempToken;
18
+ }
19
+ get logout() {
20
+ return this.formio.auth.logout;
21
+ }
22
+ setCurrentUser(user, token, ctx) {
23
+ const request = ctx.getRequest();
24
+ const response = ctx.getResponse();
25
+ request.submission.data = user.data;
26
+ request.user = user;
27
+ request.token = token.decoded;
28
+ response.token = token.token;
29
+ request["x-jwt-token"] = token.token;
30
+ return this;
31
+ }
32
+ /**
33
+ * Generate the payload token for the session
34
+ * @param user
35
+ * @param ctx
36
+ */
37
+ async generatePayloadToken(user, ctx) {
38
+ const req = ctx.getRequest();
39
+ const audit = this.formio.audit;
40
+ let form;
41
+ try {
42
+ form = (await this.db.getForm(user.form));
43
+ }
44
+ catch (err) {
45
+ audit("EAUTH_USERFORM", {
46
+ ...req,
47
+ userId: user._id
48
+ }, user.form, err);
49
+ throw err;
50
+ }
51
+ if (!form) {
52
+ audit("EAUTH_USERFORM", {
53
+ ...req,
54
+ userId: user._id
55
+ }, user.form, { message: "User form not found" });
56
+ throw new NotFound("User form not found.");
57
+ }
58
+ try {
59
+ user = await this.hooks.alterAsync("user", user);
60
+ }
61
+ catch (err) {
62
+ // istanbul ignore next
63
+ ctx.logger.debug(err);
64
+ }
65
+ await this.hooks.alterAsync("login", user, req);
66
+ // Allow anyone to hook and modify the token.
67
+ const token = this.hooks.alter("token", {
68
+ user: {
69
+ _id: user._id
70
+ },
71
+ form: {
72
+ _id: form === null || form === void 0 ? void 0 : form._id
73
+ }
74
+ }, form, req);
75
+ const decoded = this.hooks.alter("tokenDecode", token, req);
76
+ return {
77
+ user,
78
+ token: {
79
+ token: this.getToken(token),
80
+ decoded
81
+ }
82
+ };
83
+ }
84
+ /**
85
+ * Generate session from the given authenticated user.
86
+ * @param user
87
+ * @param ctx
88
+ */
89
+ async generateSession(user, ctx) {
90
+ try {
91
+ const { user: userSession, token } = await this.generatePayloadToken(user, ctx);
92
+ this.setCurrentUser(userSession, token, ctx);
93
+ await this.currentUser(ctx.getRequest(), ctx.getResponse());
94
+ }
95
+ catch (err) {
96
+ ctx.logger.error({ event: "Error on OAuthActions", error: err });
97
+ throw new Unauthorized(err.message);
98
+ }
99
+ }
100
+ /**
101
+ * Retrieve roles
102
+ * @param req
103
+ */
104
+ async getRoles(req) {
105
+ try {
106
+ const query = this.hooks.alter("roleQuery", { deleted: { $eq: null } }, req);
107
+ return await this.db.roleModel.find(query).sort({ title: 1 }).lean().exec();
108
+ }
109
+ catch (err) {
110
+ throw new BadRequest(this.formio.util.errorCodes.role.EROLESLOAD);
111
+ }
112
+ }
113
+ /**
114
+ * Update the role of the current user submission
115
+ * @param _id
116
+ * @param role
117
+ * @param req
118
+ */
119
+ async updateUserRole(_id, role, req) {
120
+ const query = this.hooks.alter("submissionQuery", {
121
+ _id: this.formio.util.idToBson(_id),
122
+ deleted: { $eq: null }
123
+ }, req);
124
+ const user = await this.db.submissionModel.findOne(query).exec();
125
+ if (!user) {
126
+ throw new BadRequest("No Submission was found with the given setting `submission`.");
127
+ }
128
+ user.roles = [this.formio.util.idToBson(role)];
129
+ if (isFunction(user.save)) {
130
+ await user.save();
131
+ }
132
+ return user;
133
+ }
134
+ /**
135
+ * Create a user submission in formio
136
+ * @param user
137
+ */
138
+ async createUser(user) {
139
+ const submission = new this.db.submissionModel({
140
+ owner: null,
141
+ deleted: null,
142
+ roles: [],
143
+ externalsIds: [],
144
+ ...user,
145
+ created: new Date().toISOString(),
146
+ modified: new Date().toISOString()
147
+ });
148
+ user.form && (submission.form = this.db.idToBson(user.form));
149
+ await submission.save();
150
+ return submission.toObject();
151
+ }
152
+ /**
153
+ * Update user submission in formio
154
+ * @param user
155
+ */
156
+ async updateUser(user) {
157
+ await this.db.submissionModel.updateOne({
158
+ _id: user._id
159
+ }, { $set: user });
160
+ return user;
161
+ }
162
+ };
163
+ __decorate([
164
+ Inject(),
165
+ __metadata("design:type", FormioService)
166
+ ], FormioAuthService.prototype, "formio", void 0);
167
+ __decorate([
168
+ Inject(),
169
+ __metadata("design:type", FormioHooksService)
170
+ ], FormioAuthService.prototype, "hooks", void 0);
171
+ __decorate([
172
+ Inject(),
173
+ __metadata("design:type", FormioDatabase)
174
+ ], FormioAuthService.prototype, "db", void 0);
175
+ FormioAuthService = __decorate([
176
+ Injectable()
177
+ ], FormioAuthService);
178
+ export { FormioAuthService };
179
+ //# sourceMappingURL=FormioAuthService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormioAuthService.js","sourceRoot":"","sources":["../../../src/services/FormioAuthService.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAA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,YAAY,EAAE,EAAE;YAChB,GAAG,IAAI;YACP,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACjC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACnC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE7D,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;QAExB,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAa,IAAoC;QAC/D,MAAM,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,SAAS,CACrC;YACE,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,EACD,EAAC,IAAI,EAAE,IAAI,EAAC,CACb,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AApNC;IADC,MAAM,EAAE;8BACD,aAAa;iDAAC;AAGtB;IADC,MAAM,EAAE;8BACF,kBAAkB;gDAAC;AAG1B;IADC,MAAM,EAAE;8BACL,cAAc;6CAAC;AARR,iBAAiB;IAD7B,UAAU,EAAE;GACA,iBAAiB,CAsN7B;SAtNY,iBAAiB","sourcesContent":["import {PlatformContext, Req} from \"@tsed/common\";\nimport {isFunction} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {BadRequest, NotFound, Unauthorized} from \"@tsed/exceptions\";\nimport {promisify} from \"util\";\nimport {FormioPayloadToken} from \"../domain/FormioDecodedToken\";\nimport {FormioForm, FormioSubmission, WithID} from \"../domain/FormioModels\";\nimport {FormioDatabase} from \"./FormioDatabase\";\nimport {FormioHooksService} from \"./FormioHooksService\";\nimport {FormioService} from \"./FormioService\";\n\n@Injectable()\nexport class FormioAuthService {\n @Inject()\n formio: FormioService;\n\n @Inject()\n hooks: FormioHooksService;\n\n @Inject()\n db: FormioDatabase;\n\n get currentUser() {\n return promisify(this.formio.auth.currentUser);\n }\n\n get getToken() {\n return this.formio.auth.getToken;\n }\n\n get tempToken() {\n return this.formio.auth.tempToken;\n }\n\n get logout() {\n return this.formio.auth.logout;\n }\n\n setCurrentUser<User = any>(user: WithID<FormioSubmission<User>>, token: FormioPayloadToken, ctx: PlatformContext) {\n const request = ctx.getRequest();\n const response = ctx.getResponse();\n\n request.submission.data = user.data;\n request.user = user;\n request.token = token.decoded;\n response.token = token.token;\n request[\"x-jwt-token\"] = token.token;\n\n return this;\n }\n\n /**\n * Generate the payload token for the session\n * @param user\n * @param ctx\n */\n async generatePayloadToken<User = any>(\n user: WithID<FormioSubmission<User>>,\n ctx: PlatformContext\n ): Promise<{user: WithID<FormioSubmission<User>>; token: FormioPayloadToken}> {\n const req = ctx.getRequest();\n const audit = this.formio.audit;\n let form: FormioForm | null;\n\n try {\n form = (await this.db.getForm(user.form)) as any;\n } catch (err) {\n audit(\n \"EAUTH_USERFORM\",\n {\n ...req,\n userId: user._id\n },\n user.form,\n err\n );\n throw err;\n }\n\n if (!form) {\n audit(\n \"EAUTH_USERFORM\",\n {\n ...req,\n userId: user._id\n },\n user.form,\n {message: \"User form not found\"}\n );\n\n throw new NotFound(\"User form not found.\");\n }\n\n try {\n user = await this.hooks.alterAsync(\"user\", user);\n } catch (err) {\n // istanbul ignore next\n ctx.logger.debug(err);\n }\n\n await this.hooks.alterAsync(\"login\", user, req);\n\n // Allow anyone to hook and modify the token.\n const token = this.hooks.alter(\n \"token\",\n {\n user: {\n _id: user._id\n },\n form: {\n _id: form?._id\n }\n },\n form,\n req\n );\n\n const decoded = this.hooks.alter(\"tokenDecode\", token, req);\n\n return {\n user,\n token: {\n token: this.getToken(token) as string,\n decoded\n }\n };\n }\n\n /**\n * Generate session from the given authenticated user.\n * @param user\n * @param ctx\n */\n async generateSession<User = any>(user: WithID<FormioSubmission<User>>, ctx: PlatformContext) {\n try {\n const {user: userSession, token} = await this.generatePayloadToken(user, ctx);\n this.setCurrentUser(userSession, token, ctx);\n\n await this.currentUser(ctx.getRequest(), ctx.getResponse());\n } catch (err) {\n ctx.logger.error({event: \"Error on OAuthActions\", error: err});\n throw new Unauthorized(err.message);\n }\n }\n\n /**\n * Retrieve roles\n * @param req\n */\n async getRoles(req?: Req) {\n try {\n const query = this.hooks.alter(\"roleQuery\", {deleted: {$eq: null}}, req);\n\n return await this.db.roleModel.find(query).sort({title: 1}).lean().exec();\n } catch (err) {\n throw new BadRequest(this.formio.util.errorCodes.role.EROLESLOAD);\n }\n }\n\n /**\n * Update the role of the current user submission\n * @param _id\n * @param role\n * @param req\n */\n async updateUserRole(_id: string | any, role: string, req?: Req) {\n const query = this.hooks.alter(\n \"submissionQuery\",\n {\n _id: this.formio.util.idToBson(_id),\n deleted: {$eq: null}\n },\n req\n );\n\n const user = await this.db.submissionModel.findOne(query).exec();\n\n if (!user) {\n throw new BadRequest(\"No Submission was found with the given setting `submission`.\");\n }\n\n user.roles = [this.formio.util.idToBson(role)];\n\n if (isFunction(user.save)) {\n await user.save();\n }\n\n return user;\n }\n\n /**\n * Create a user submission in formio\n * @param user\n */\n async createUser<User = any>(user: Partial<FormioSubmission<User>>) {\n const submission = new this.db.submissionModel({\n owner: null,\n deleted: null,\n roles: [],\n externalsIds: [],\n ...user,\n created: new Date().toISOString(),\n modified: new Date().toISOString()\n });\n\n user.form && (submission.form = this.db.idToBson(user.form));\n\n await submission.save();\n\n return submission.toObject();\n }\n\n /**\n * Update user submission in formio\n * @param user\n */\n async updateUser<User = any>(user: WithID<FormioSubmission<User>>) {\n await this.db.submissionModel.updateOne(\n {\n _id: user._id\n },\n {$set: user}\n );\n\n return user;\n }\n}\n"]}
@@ -0,0 +1,100 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { isArray, isObject, isString, toMap as tMap } from "@tsed/core";
3
+ import { Inject, Injectable } from "@tsed/di";
4
+ import { FormioMapper } from "../builder/FormioMapper";
5
+ import { isMongoId } from "../utils/isMongoId";
6
+ import { FormioService } from "./FormioService";
7
+ function toMap(list) {
8
+ return tMap(list, (o) => [o._id.toString(), `$machineName:${o.machineName}`]);
9
+ }
10
+ let FormioDatabase = class FormioDatabase {
11
+ get models() {
12
+ return this.formio.mongoose.models;
13
+ }
14
+ get roleModel() {
15
+ return this.models.role;
16
+ }
17
+ get formModel() {
18
+ return this.models.form;
19
+ }
20
+ get actionModel() {
21
+ return this.models.action;
22
+ }
23
+ get submissionModel() {
24
+ return this.models.submission;
25
+ }
26
+ get tokenModel() {
27
+ return this.models.token;
28
+ }
29
+ get actionItemModel() {
30
+ return this.models.actionItem;
31
+ }
32
+ async getFormioMapper() {
33
+ const [roles, forms, actions] = await Promise.all([
34
+ this.roleModel.find({
35
+ deleted: { $eq: null }
36
+ }),
37
+ this.formModel.find({
38
+ deleted: { $eq: null }
39
+ }),
40
+ this.actionModel.find({
41
+ deleted: { $eq: null }
42
+ })
43
+ ]);
44
+ return new FormioMapper({
45
+ forms: toMap(forms),
46
+ actions: toMap(actions),
47
+ roles: toMap(roles)
48
+ });
49
+ }
50
+ async hasForms() {
51
+ return (await this.formModel.countDocuments()) > 0;
52
+ }
53
+ async hasForm(name) {
54
+ return !!(await this.formModel.countDocuments({ machineName: { $eq: name } }));
55
+ }
56
+ async getForm(nameOrId) {
57
+ return this.formModel
58
+ .findOne({
59
+ deleted: { $eq: null },
60
+ ...(isMongoId(nameOrId)
61
+ ? {
62
+ _id: nameOrId
63
+ }
64
+ : { machineName: { $eq: nameOrId } })
65
+ })
66
+ .lean()
67
+ .exec();
68
+ }
69
+ async createFormIfNotExists(form, onCreate) {
70
+ if (!(await this.hasForm(form.name))) {
71
+ const createForm = await this.saveFormDefinition(form);
72
+ onCreate && (await onCreate(createForm));
73
+ }
74
+ return this.getForm(form.name);
75
+ }
76
+ async saveFormDefinition(form) {
77
+ const mapper = await this.getFormioMapper();
78
+ return new this.formModel(mapper.mapToImport(form)).save();
79
+ }
80
+ idToBson(form) {
81
+ if (isArray(form)) {
82
+ return { $in: form.map(this.formio.util.idToBson) };
83
+ }
84
+ else if (isObject(form)) {
85
+ return this.formio.util.idToBson(form._id);
86
+ }
87
+ else if (isString(form)) {
88
+ return this.formio.util.idToBson(form);
89
+ }
90
+ }
91
+ };
92
+ __decorate([
93
+ Inject(),
94
+ __metadata("design:type", FormioService)
95
+ ], FormioDatabase.prototype, "formio", void 0);
96
+ FormioDatabase = __decorate([
97
+ Injectable()
98
+ ], FormioDatabase);
99
+ export { FormioDatabase };
100
+ //# sourceMappingURL=FormioDatabase.js.map