@tsed/formio 7.0.0-alpha.1 → 7.0.0-beta.10

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 (276) hide show
  1. package/.mocharc.js +2 -2
  2. package/.nycrc +6 -5
  3. package/lib/{FormioModule.js → cjs/FormioModule.js} +17 -30
  4. package/lib/cjs/FormioModule.js.map +1 -0
  5. package/lib/{builder → cjs/builder}/FormioMapper.js +11 -3
  6. package/lib/cjs/builder/FormioMapper.js.map +1 -0
  7. package/lib/cjs/components/AlterActions.js +111 -0
  8. package/lib/cjs/components/AlterActions.js.map +1 -0
  9. package/lib/{components → cjs/components}/AlterAudit.js +1 -1
  10. package/lib/cjs/components/AlterAudit.js.map +1 -0
  11. package/lib/{components → cjs/components}/AlterHost.js +1 -1
  12. package/lib/cjs/components/AlterHost.js.map +1 -0
  13. package/lib/{components → cjs/components}/AlterLog.js +1 -1
  14. package/lib/cjs/components/AlterLog.js.map +1 -0
  15. package/lib/{components → cjs/components}/AlterSkip.js +4 -4
  16. package/lib/cjs/components/AlterSkip.js.map +1 -0
  17. package/lib/{components → cjs/components}/AlterTemplateExportSteps.js +5 -5
  18. package/lib/cjs/components/AlterTemplateExportSteps.js.map +1 -0
  19. package/lib/{components → cjs/components}/AlterTemplateImportSteps.js +4 -4
  20. package/lib/cjs/components/AlterTemplateImportSteps.js.map +1 -0
  21. package/lib/{decorators → cjs/decorators}/action.js +3 -3
  22. package/lib/cjs/decorators/action.js.map +1 -0
  23. package/lib/{decorators → cjs/decorators}/actionCtx.js +1 -1
  24. package/lib/cjs/decorators/actionCtx.js.map +1 -0
  25. package/lib/{decorators → cjs/decorators}/alter.js +3 -3
  26. package/lib/cjs/decorators/alter.js.map +1 -0
  27. package/lib/{decorators → cjs/decorators}/on.js +3 -3
  28. package/lib/cjs/decorators/on.js.map +1 -0
  29. package/lib/{decorators → cjs/decorators}/useFormioAuth.js +1 -1
  30. package/lib/cjs/decorators/useFormioAuth.js.map +1 -0
  31. package/lib/{domain → cjs/domain}/AlterHook.js +0 -0
  32. package/lib/cjs/domain/AlterHook.js.map +1 -0
  33. package/lib/{domain → cjs/domain}/Formio.js +0 -0
  34. package/lib/cjs/domain/Formio.js.map +1 -0
  35. package/lib/{domain → cjs/domain}/FormioAction.js +0 -0
  36. package/lib/cjs/domain/FormioAction.js.map +1 -0
  37. package/lib/{domain → cjs/domain}/FormioActionsIndex.js +0 -0
  38. package/lib/cjs/domain/FormioActionsIndex.js.map +1 -0
  39. package/lib/{domain → cjs/domain}/FormioAuth.js +0 -0
  40. package/lib/cjs/domain/FormioAuth.js.map +1 -0
  41. package/lib/{domain → cjs/domain}/FormioBaseModel.js +0 -0
  42. package/lib/cjs/domain/FormioBaseModel.js.map +1 -0
  43. package/lib/{domain → cjs/domain}/FormioConfig.js +0 -0
  44. package/lib/cjs/domain/FormioConfig.js.map +1 -0
  45. package/lib/{domain → cjs/domain}/FormioCtxMapper.js +0 -0
  46. package/lib/cjs/domain/FormioCtxMapper.js.map +1 -0
  47. package/lib/{domain → cjs/domain}/FormioDecodedToken.js +0 -0
  48. package/lib/cjs/domain/FormioDecodedToken.js.map +1 -0
  49. package/lib/{domain → cjs/domain}/FormioErrors.js +0 -0
  50. package/lib/cjs/domain/FormioErrors.js.map +1 -0
  51. package/lib/{domain → cjs/domain}/FormioHooks.js +0 -0
  52. package/lib/cjs/domain/FormioHooks.js.map +1 -0
  53. package/lib/{domain → cjs/domain}/FormioJs.js +0 -0
  54. package/lib/cjs/domain/FormioJs.js.map +1 -0
  55. package/lib/cjs/domain/FormioModels.js +5 -0
  56. package/lib/cjs/domain/FormioModels.js.map +1 -0
  57. package/lib/{domain → cjs/domain}/FormioRouter.js +0 -0
  58. package/lib/cjs/domain/FormioRouter.js.map +1 -0
  59. package/lib/{domain → cjs/domain}/FormioSettings.js +0 -0
  60. package/lib/cjs/domain/FormioSettings.js.map +1 -0
  61. package/lib/{domain → cjs/domain}/FormioTemplate.js +0 -0
  62. package/lib/cjs/domain/FormioTemplate.js.map +1 -0
  63. package/lib/{domain → cjs/domain}/FormioTemplateUtil.js +0 -0
  64. package/lib/cjs/domain/FormioTemplateUtil.js.map +1 -0
  65. package/lib/{domain → cjs/domain}/FormioUpdate.js +0 -0
  66. package/lib/cjs/domain/FormioUpdate.js.map +1 -0
  67. package/lib/{domain → cjs/domain}/FormioUtils.js +0 -0
  68. package/lib/cjs/domain/FormioUtils.js.map +1 -0
  69. package/lib/{domain → cjs/domain}/OnHook.js +0 -0
  70. package/lib/cjs/domain/OnHook.js.map +1 -0
  71. package/lib/{domain → cjs/domain}/Resource.js +0 -0
  72. package/lib/cjs/domain/Resource.js.map +1 -0
  73. package/lib/{index.js → cjs/index.js} +22 -18
  74. package/lib/cjs/index.js.map +1 -0
  75. package/lib/{middlewares → cjs/middlewares}/FormioAuthMiddleware.js +5 -5
  76. package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +1 -0
  77. package/lib/cjs/package.json +3 -0
  78. package/lib/{services → cjs/services}/FormioAuthService.js +6 -6
  79. package/lib/cjs/services/FormioAuthService.js.map +1 -0
  80. package/lib/{services → cjs/services}/FormioDatabase.js +50 -13
  81. package/lib/cjs/services/FormioDatabase.js.map +1 -0
  82. package/lib/{services → cjs/services}/FormioHooksService.js +4 -4
  83. package/lib/cjs/services/FormioHooksService.js.map +1 -0
  84. package/lib/{services → cjs/services}/FormioInstaller.js +3 -3
  85. package/lib/cjs/services/FormioInstaller.js.map +1 -0
  86. package/lib/cjs/services/FormioRepository.js +42 -0
  87. package/lib/cjs/services/FormioRepository.js.map +1 -0
  88. package/lib/cjs/services/FormioService.js +103 -0
  89. package/lib/cjs/services/FormioService.js.map +1 -0
  90. package/lib/{utils → cjs/utils}/isMongoId.js +0 -0
  91. package/lib/cjs/utils/isMongoId.js.map +1 -0
  92. package/lib/esm/FormioModule.js +134 -0
  93. package/lib/esm/FormioModule.js.map +1 -0
  94. package/lib/esm/builder/FormioMapper.js +57 -0
  95. package/lib/esm/builder/FormioMapper.js.map +1 -0
  96. package/lib/esm/components/AlterActions.js +108 -0
  97. package/lib/esm/components/AlterActions.js.map +1 -0
  98. package/lib/esm/components/AlterAudit.js +13 -0
  99. package/lib/esm/components/AlterAudit.js.map +1 -0
  100. package/lib/esm/components/AlterHost.js +12 -0
  101. package/lib/esm/components/AlterHost.js.map +1 -0
  102. package/lib/esm/components/AlterLog.js +13 -0
  103. package/lib/esm/components/AlterLog.js.map +1 -0
  104. package/lib/esm/components/AlterSkip.js +29 -0
  105. package/lib/esm/components/AlterSkip.js.map +1 -0
  106. package/lib/esm/components/AlterTemplateExportSteps.js +49 -0
  107. package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -0
  108. package/lib/esm/components/AlterTemplateImportSteps.js +42 -0
  109. package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -0
  110. package/lib/esm/decorators/action.js +16 -0
  111. package/lib/esm/decorators/action.js.map +1 -0
  112. package/lib/esm/decorators/actionCtx.js +19 -0
  113. package/lib/esm/decorators/actionCtx.js.map +1 -0
  114. package/lib/esm/decorators/alter.js +16 -0
  115. package/lib/esm/decorators/alter.js.map +1 -0
  116. package/lib/esm/decorators/on.js +16 -0
  117. package/lib/esm/decorators/on.js.map +1 -0
  118. package/lib/esm/decorators/useFormioAuth.js +11 -0
  119. package/lib/esm/decorators/useFormioAuth.js.map +1 -0
  120. package/lib/esm/domain/AlterHook.js +2 -0
  121. package/lib/esm/domain/AlterHook.js.map +1 -0
  122. package/lib/esm/domain/Formio.js +2 -0
  123. package/lib/esm/domain/Formio.js.map +1 -0
  124. package/lib/esm/domain/FormioAction.js +2 -0
  125. package/lib/esm/domain/FormioAction.js.map +1 -0
  126. package/lib/esm/domain/FormioActionsIndex.js +2 -0
  127. package/lib/esm/domain/FormioActionsIndex.js.map +1 -0
  128. package/lib/esm/domain/FormioAuth.js +2 -0
  129. package/lib/esm/domain/FormioAuth.js.map +1 -0
  130. package/lib/esm/domain/FormioBaseModel.js +2 -0
  131. package/lib/esm/domain/FormioBaseModel.js.map +1 -0
  132. package/lib/esm/domain/FormioConfig.js +2 -0
  133. package/lib/esm/domain/FormioConfig.js.map +1 -0
  134. package/lib/esm/domain/FormioCtxMapper.js +2 -0
  135. package/lib/esm/domain/FormioCtxMapper.js.map +1 -0
  136. package/lib/esm/domain/FormioDecodedToken.js +2 -0
  137. package/lib/esm/domain/FormioDecodedToken.js.map +1 -0
  138. package/lib/esm/domain/FormioErrors.js +2 -0
  139. package/lib/esm/domain/FormioErrors.js.map +1 -0
  140. package/lib/esm/domain/FormioHooks.js +2 -0
  141. package/lib/esm/domain/FormioHooks.js.map +1 -0
  142. package/lib/esm/domain/FormioJs.js +2 -0
  143. package/lib/esm/domain/FormioJs.js.map +1 -0
  144. package/lib/esm/domain/FormioModels.js +2 -0
  145. package/lib/esm/domain/FormioModels.js.map +1 -0
  146. package/lib/esm/domain/FormioRouter.js +2 -0
  147. package/lib/esm/domain/FormioRouter.js.map +1 -0
  148. package/lib/esm/domain/FormioSettings.js +2 -0
  149. package/lib/esm/domain/FormioSettings.js.map +1 -0
  150. package/lib/esm/domain/FormioTemplate.js +2 -0
  151. package/lib/esm/domain/FormioTemplate.js.map +1 -0
  152. package/lib/esm/domain/FormioTemplateUtil.js +2 -0
  153. package/lib/esm/domain/FormioTemplateUtil.js.map +1 -0
  154. package/lib/esm/domain/FormioUpdate.js +2 -0
  155. package/lib/esm/domain/FormioUpdate.js.map +1 -0
  156. package/lib/esm/domain/FormioUtils.js +2 -0
  157. package/lib/esm/domain/FormioUtils.js.map +1 -0
  158. package/lib/esm/domain/OnHook.js +2 -0
  159. package/lib/esm/domain/OnHook.js.map +1 -0
  160. package/lib/esm/domain/Resource.js +2 -0
  161. package/lib/esm/domain/Resource.js.map +1 -0
  162. package/lib/esm/index.js +47 -0
  163. package/lib/esm/index.js.map +1 -0
  164. package/lib/esm/middlewares/FormioAuthMiddleware.js +38 -0
  165. package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -0
  166. package/lib/esm/package.json +3 -0
  167. package/lib/esm/services/FormioAuthService.js +179 -0
  168. package/lib/esm/services/FormioAuthService.js.map +1 -0
  169. package/lib/esm/services/FormioDatabase.js +137 -0
  170. package/lib/esm/services/FormioDatabase.js.map +1 -0
  171. package/lib/esm/services/FormioHooksService.js +78 -0
  172. package/lib/esm/services/FormioHooksService.js.map +1 -0
  173. package/lib/esm/services/FormioInstaller.js +47 -0
  174. package/lib/esm/services/FormioInstaller.js.map +1 -0
  175. package/lib/esm/services/FormioRepository.js +38 -0
  176. package/lib/esm/services/FormioRepository.js.map +1 -0
  177. package/lib/{services → esm/services}/FormioService.js +18 -18
  178. package/lib/esm/services/FormioService.js.map +1 -0
  179. package/lib/esm/utils/isMongoId.js +4 -0
  180. package/lib/esm/utils/isMongoId.js.map +1 -0
  181. package/lib/{FormioModule.d.ts → types/FormioModule.d.ts} +0 -0
  182. package/lib/{builder → types/builder}/FormioMapper.d.ts +0 -0
  183. package/lib/{components → types/components}/AlterActions.d.ts +8 -3
  184. package/lib/types/components/AlterAudit.d.ts +5 -0
  185. package/lib/{components → types/components}/AlterHost.d.ts +0 -0
  186. package/lib/{components → types/components}/AlterLog.d.ts +0 -0
  187. package/lib/{components → types/components}/AlterSkip.d.ts +0 -0
  188. package/lib/{components → types/components}/AlterTemplateExportSteps.d.ts +0 -0
  189. package/lib/{components → types/components}/AlterTemplateImportSteps.d.ts +0 -0
  190. package/lib/{decorators → types/decorators}/action.d.ts +1 -1
  191. package/lib/{decorators → types/decorators}/actionCtx.d.ts +2 -1
  192. package/lib/{decorators → types/decorators}/alter.d.ts +0 -0
  193. package/lib/{decorators → types/decorators}/on.d.ts +0 -0
  194. package/lib/{decorators → types/decorators}/useFormioAuth.d.ts +0 -0
  195. package/lib/{domain → types/domain}/AlterHook.d.ts +0 -0
  196. package/lib/{domain → types/domain}/Formio.d.ts +0 -0
  197. package/lib/{domain → types/domain}/FormioAction.d.ts +1 -26
  198. package/lib/{domain → types/domain}/FormioActionsIndex.d.ts +0 -0
  199. package/lib/{domain → types/domain}/FormioAuth.d.ts +0 -0
  200. package/lib/{domain → types/domain}/FormioBaseModel.d.ts +0 -0
  201. package/lib/{domain → types/domain}/FormioConfig.d.ts +0 -0
  202. package/lib/{domain → types/domain}/FormioCtxMapper.d.ts +1 -2
  203. package/lib/{domain → types/domain}/FormioDecodedToken.d.ts +0 -0
  204. package/lib/{domain → types/domain}/FormioErrors.d.ts +0 -0
  205. package/lib/{domain → types/domain}/FormioHooks.d.ts +1 -1
  206. package/lib/{domain → types/domain}/FormioJs.d.ts +0 -0
  207. package/lib/types/domain/FormioModels.d.ts +42 -0
  208. package/lib/{domain → types/domain}/FormioRouter.d.ts +0 -0
  209. package/lib/{domain → types/domain}/FormioSettings.d.ts +0 -0
  210. package/lib/{domain → types/domain}/FormioTemplate.d.ts +0 -0
  211. package/lib/{domain → types/domain}/FormioTemplateUtil.d.ts +0 -0
  212. package/lib/{domain → types/domain}/FormioUpdate.d.ts +0 -0
  213. package/lib/{domain → types/domain}/FormioUtils.d.ts +0 -0
  214. package/lib/{domain → types/domain}/OnHook.d.ts +0 -0
  215. package/lib/{domain → types/domain}/Resource.d.ts +2 -2
  216. package/lib/{index.d.ts → types/index.d.ts} +22 -14
  217. package/lib/types/middlewares/FormioAuthMiddleware.d.ts +11 -0
  218. package/lib/{services → types/services}/FormioAuthService.d.ts +14 -3
  219. package/lib/types/services/FormioDatabase.d.ts +63 -0
  220. package/lib/{services → types/services}/FormioHooksService.d.ts +2 -3
  221. package/lib/{services → types/services}/FormioInstaller.d.ts +0 -0
  222. package/lib/types/services/FormioRepository.d.ts +24 -0
  223. package/lib/{services → types/services}/FormioService.d.ts +0 -0
  224. package/lib/{utils → types/utils}/isMongoId.d.ts +0 -0
  225. package/package.json +32 -17
  226. package/readme.md +5 -9
  227. package/tsconfig.compile.esm.json +12 -0
  228. package/lib/FormioModule.js.map +0 -1
  229. package/lib/builder/FormioMapper.js.map +0 -1
  230. package/lib/components/AlterActions.js +0 -66
  231. package/lib/components/AlterActions.js.map +0 -1
  232. package/lib/components/AlterAudit.d.ts +0 -5
  233. package/lib/components/AlterAudit.js.map +0 -1
  234. package/lib/components/AlterHost.js.map +0 -1
  235. package/lib/components/AlterLog.js.map +0 -1
  236. package/lib/components/AlterSkip.js.map +0 -1
  237. package/lib/components/AlterTemplateExportSteps.js.map +0 -1
  238. package/lib/components/AlterTemplateImportSteps.js.map +0 -1
  239. package/lib/decorators/action.js.map +0 -1
  240. package/lib/decorators/actionCtx.js.map +0 -1
  241. package/lib/decorators/alter.js.map +0 -1
  242. package/lib/decorators/on.js.map +0 -1
  243. package/lib/decorators/useFormioAuth.js.map +0 -1
  244. package/lib/domain/AlterHook.js.map +0 -1
  245. package/lib/domain/Formio.js.map +0 -1
  246. package/lib/domain/FormioAction.js.map +0 -1
  247. package/lib/domain/FormioActionsIndex.js.map +0 -1
  248. package/lib/domain/FormioAuth.js.map +0 -1
  249. package/lib/domain/FormioBaseModel.js.map +0 -1
  250. package/lib/domain/FormioConfig.js.map +0 -1
  251. package/lib/domain/FormioCtxMapper.js.map +0 -1
  252. package/lib/domain/FormioDecodedToken.js.map +0 -1
  253. package/lib/domain/FormioErrors.js.map +0 -1
  254. package/lib/domain/FormioHooks.js.map +0 -1
  255. package/lib/domain/FormioJs.js.map +0 -1
  256. package/lib/domain/FormioModels.d.ts +0 -183
  257. package/lib/domain/FormioModels.js +0 -3
  258. package/lib/domain/FormioModels.js.map +0 -1
  259. package/lib/domain/FormioRouter.js.map +0 -1
  260. package/lib/domain/FormioSettings.js.map +0 -1
  261. package/lib/domain/FormioTemplate.js.map +0 -1
  262. package/lib/domain/FormioTemplateUtil.js.map +0 -1
  263. package/lib/domain/FormioUpdate.js.map +0 -1
  264. package/lib/domain/FormioUtils.js.map +0 -1
  265. package/lib/domain/OnHook.js.map +0 -1
  266. package/lib/domain/Resource.js.map +0 -1
  267. package/lib/index.js.map +0 -1
  268. package/lib/middlewares/FormioAuthMiddleware.d.ts +0 -13
  269. package/lib/middlewares/FormioAuthMiddleware.js.map +0 -1
  270. package/lib/services/FormioAuthService.js.map +0 -1
  271. package/lib/services/FormioDatabase.d.ts +0 -25
  272. package/lib/services/FormioDatabase.js.map +0 -1
  273. package/lib/services/FormioHooksService.js.map +0 -1
  274. package/lib/services/FormioInstaller.js.map +0 -1
  275. package/lib/services/FormioService.js.map +0 -1
  276. package/lib/utils/isMongoId.js.map +0 -1
@@ -1,5 +1,7 @@
1
- import { PlatformContext } from "@tsed/common";
2
1
  import { InjectorService, Provider } from "@tsed/di";
2
+ import { PlatformParams } from "@tsed/platform-params";
3
+ import { PlatformResponseFilter } from "@tsed/platform-response-filter";
4
+ import { PlatformContext } from "@tsed/common";
3
5
  import { AlterHook } from "../domain/AlterHook";
4
6
  import { SetActionItemMessage } from "../domain/FormioAction";
5
7
  import { FormioActions } from "../domain/FormioActionsIndex";
@@ -7,9 +9,12 @@ import { FormioService } from "../services/FormioService";
7
9
  export declare class AlterActions implements AlterHook {
8
10
  protected injector: InjectorService;
9
11
  protected formio: FormioService;
12
+ protected params: PlatformParams;
13
+ protected responseFilter: PlatformResponseFilter;
10
14
  transform(actions: FormioActions): FormioActions;
11
15
  protected getActions(): Provider<any>[];
12
- protected createResolveHandler(provider: Provider<any>): (action: any, handler: string, method: string, req: {
16
+ protected createHandler(provider: Provider, propertyKey: string | symbol): (action: any, handler: string, method: string, req: {
13
17
  $ctx: PlatformContext;
14
- }, res: Response, next: any, setActionItemMessage: SetActionItemMessage) => void;
18
+ }, res: any, next: any, setActionItemMessage: SetActionItemMessage) => Promise<void>;
19
+ private flush;
15
20
  }
@@ -0,0 +1,5 @@
1
+ import { DIContext } from "@tsed/di";
2
+ import { AlterHook } from "../domain/AlterHook";
3
+ export declare class AlterAudit implements AlterHook {
4
+ transform(info: any[], event: string, ctx: DIContext): boolean;
5
+ }
@@ -1,4 +1,4 @@
1
- import { FormioActionInfo } from "../domain/FormioAction";
1
+ import { FormioActionInfo } from "@tsed/formio-types";
2
2
  /**
3
3
  * Create a new FormIO Action.
4
4
  * @param options
@@ -1,4 +1,5 @@
1
- import { FormioAction, SetActionItemMessage } from "../domain/FormioAction";
1
+ import { SetActionItemMessage } from "../domain/FormioAction";
2
+ import { FormioAction } from "@tsed/formio-types";
2
3
  /**
3
4
  * Return the current action context with the following data:
4
5
  *
File without changes
File without changes
File without changes
File without changes
@@ -1,32 +1,7 @@
1
1
  import { Request, Response } from "express";
2
2
  import { FormioMongooseSchema } from "./FormioBaseModel";
3
3
  import { FormioComponent } from "./FormioModels";
4
- export interface FormioActionInfo {
5
- name: string;
6
- title: string;
7
- description: string;
8
- priority: number;
9
- defaults: {
10
- handler: string[];
11
- method: string[];
12
- };
13
- access?: {
14
- handler: boolean;
15
- method: boolean;
16
- };
17
- }
18
- export interface FormioAction<Settings = any> {
19
- name: string;
20
- title: string;
21
- action: string;
22
- handler: string[];
23
- method: string[];
24
- priority: number;
25
- form: any;
26
- settings: Settings;
27
- condition?: any;
28
- deleted?: number | null;
29
- }
4
+ import { FormioAction, FormioActionInfo } from "@tsed/formio-types";
30
5
  export interface FormioActionModel extends FormioAction {
31
6
  resolve(handler: string, method: string, req: Request, res: Response, next: Function, setActionItemMessage: SetActionItemMessage): void;
32
7
  }
File without changes
File without changes
@@ -1,6 +1,5 @@
1
1
  import { MongooseDocument } from "@tsed/mongoose";
2
- import { FormioAction } from "./FormioAction";
3
- import { FormioForm, FormioRole } from "./FormioModels";
2
+ import { FormioAction, FormioForm, FormioRole } from "@tsed/formio-types";
4
3
  export interface FormioCtxMapper {
5
4
  forms: Map<string, MongooseDocument<FormioForm>>;
6
5
  actions: Map<string, MongooseDocument<FormioAction>>;
File without changes
@@ -1,5 +1,5 @@
1
1
  import { MongooseDocument } from "@tsed/mongoose";
2
- import { Request } from "express";
2
+ import { Request, Response } from "express";
3
3
  import { FilterQuery, Schema, SchemaDefinition } from "mongoose";
4
4
  import { Formio } from "./Formio";
5
5
  import { FormioActions } from "./FormioActionsIndex";
File without changes
@@ -0,0 +1,42 @@
1
+ import { MongooseDocument } from "@tsed/mongoose";
2
+ import { Schema } from "mongoose";
3
+ import { FormioActionModelCtor, FormioActionMongooseSchema } from "./FormioAction";
4
+ import { FormioBaseModel, FormioModel, FormioMongooseSchema } from "./FormioBaseModel";
5
+ import { FormioActionItem, FormioForm, FormioRole, FormioSchema, FormioSubmission, FormioToken } from "@tsed/formio-types";
6
+ export * from "@tsed/formio-types";
7
+ export declare type WithID<T> = T & {
8
+ _id: string;
9
+ };
10
+ export interface FormioSchemas {
11
+ action: FormioActionMongooseSchema;
12
+ actionItem: Schema<MongooseDocument<FormioActionItem>>;
13
+ form: FormioMongooseSchema<FormioForm>;
14
+ role: FormioMongooseSchema<FormioRole>;
15
+ schema: Schema<MongooseDocument<FormioSchema>>;
16
+ submission: Schema<MongooseDocument<FormioSubmission>>;
17
+ token: Schema<MongooseDocument<FormioToken>>;
18
+ [key: string]: Schema<MongooseDocument<any>>;
19
+ }
20
+ export declare type FormioModelsModels = {
21
+ action: FormioActionModelCtor;
22
+ actionItem: FormioBaseModel<FormioActionItem>;
23
+ form: FormioModel<FormioForm>;
24
+ role: FormioModel<FormioRole>;
25
+ schema: FormioBaseModel<FormioSchema>;
26
+ submission: FormioBaseModel<FormioSubmission>;
27
+ token: FormioBaseModel<FormioToken>;
28
+ } & Record<string, FormioBaseModel>;
29
+ export interface FormioModels {
30
+ schemas: FormioSchemas;
31
+ models: FormioModelsModels;
32
+ specs: {
33
+ action: any;
34
+ actionItem: any;
35
+ form: any;
36
+ role: any;
37
+ schema: any;
38
+ submission: any;
39
+ token: any;
40
+ [key: string]: any;
41
+ };
42
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import Express from "express";
2
- export declare type ResourceHttpHandler = (req: Request, res: Response, next: Express.NextFunction) => void;
1
+ import { Request, Response, NextFunction } from "express";
2
+ export declare type ResourceHttpHandler = (req: Request, res: Response, next: NextFunction) => void;
3
3
  export interface ResourceHttpMethodOptions {
4
4
  before?: ResourceHttpHandler;
5
5
  after?: ResourceHttpHandler;
@@ -1,38 +1,46 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./FormioModule";
5
+ export * from "./builder/FormioMapper";
6
+ export * from "./components/AlterActions";
7
+ export * from "./components/AlterAudit";
8
+ export * from "./components/AlterHost";
9
+ export * from "./components/AlterLog";
10
+ export * from "./components/AlterSkip";
11
+ export * from "./components/AlterTemplateExportSteps";
12
+ export * from "./components/AlterTemplateImportSteps";
1
13
  export * from "./decorators/action";
2
14
  export * from "./decorators/actionCtx";
3
15
  export * from "./decorators/alter";
4
16
  export * from "./decorators/on";
5
17
  export * from "./decorators/useFormioAuth";
6
- export * from "./middlewares/FormioAuthMiddleware";
7
18
  export * from "./domain/AlterHook";
8
19
  export * from "./domain/Formio";
9
- export * from "./domain/FormioDecodedToken";
10
20
  export * from "./domain/FormioAction";
11
21
  export * from "./domain/FormioActionsIndex";
12
22
  export * from "./domain/FormioAuth";
13
23
  export * from "./domain/FormioBaseModel";
14
24
  export * from "./domain/FormioConfig";
15
25
  export * from "./domain/FormioCtxMapper";
26
+ export * from "./domain/FormioDecodedToken";
16
27
  export * from "./domain/FormioErrors";
17
28
  export * from "./domain/FormioHooks";
18
29
  export * from "./domain/FormioJs";
19
30
  export * from "./domain/FormioModels";
20
31
  export * from "./domain/FormioRouter";
21
32
  export * from "./domain/FormioSettings";
22
- export * from "./domain/FormioUpdate";
23
- export * from "./domain/FormioUtils";
24
33
  export * from "./domain/FormioTemplate";
25
34
  export * from "./domain/FormioTemplateUtil";
35
+ export * from "./domain/FormioUpdate";
36
+ export * from "./domain/FormioUtils";
26
37
  export * from "./domain/OnHook";
27
- export * from "./FormioModule";
28
- export * from "./builder/FormioMapper";
29
- export * from "./services/FormioService";
30
- export * from "./services/FormioDatabase";
31
- export * from "./services/FormioDatabase";
38
+ export * from "./domain/Resource";
39
+ export * from "./middlewares/FormioAuthMiddleware";
32
40
  export * from "./services/FormioAuthService";
41
+ export * from "./services/FormioDatabase";
33
42
  export * from "./services/FormioHooksService";
34
- export * from "./components/AlterActions";
35
- export * from "./components/AlterAudit";
36
- export * from "./components/AlterLog";
37
- export * from "./components/AlterHost";
38
- export * from "./components/AlterSkip";
43
+ export * from "./services/FormioInstaller";
44
+ export * from "./services/FormioRepository";
45
+ export * from "./services/FormioService";
46
+ export * from "./utils/isMongoId";
@@ -0,0 +1,11 @@
1
+ import { Context } from "@tsed/common";
2
+ import { FormioService } from "../services/FormioService";
3
+ /**
4
+ * @middleware
5
+ * @formio
6
+ */
7
+ export declare class FormioAuthMiddleware {
8
+ protected formio: FormioService;
9
+ get tokenHandler(): any;
10
+ use(ctx: Context): Promise<void>;
11
+ }
@@ -1,3 +1,10 @@
1
+ /// <reference types="mongoose/types/pipelinestage" />
2
+ /// <reference types="mongoose/types/connection" />
3
+ /// <reference types="mongoose/types/cursor" />
4
+ /// <reference types="mongoose/types/document" />
5
+ /// <reference types="mongoose/types/error" />
6
+ /// <reference types="mongoose/types/mongooseoptions" />
7
+ /// <reference types="mongoose/types/schemaoptions" />
1
8
  /// <reference types="mongoose" />
2
9
  import { PlatformContext, Req } from "@tsed/common";
3
10
  import { FormioPayloadToken } from "../domain/FormioDecodedToken";
@@ -33,19 +40,23 @@ export declare class FormioAuthService {
33
40
  * Retrieve roles
34
41
  * @param req
35
42
  */
36
- getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & import("../domain/FormioModels").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("../domain/FormioModels").FormioRole>>>[]>;
43
+ getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole>> & {
44
+ _id: any;
45
+ }>[]>;
37
46
  /**
38
47
  * Update the role of the current user submission
39
48
  * @param _id
40
49
  * @param role
41
50
  * @param req
42
51
  */
43
- updateUserRole(_id: string | any, role: string, req?: Req): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
52
+ updateUserRole(_id: string | any, role: string, req?: Req): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
53
+ _id: any;
54
+ }>;
44
55
  /**
45
56
  * Create a user submission in formio
46
57
  * @param user
47
58
  */
48
- createUser<User = any>(user: Partial<FormioSubmission<User>>): Promise<import("mongoose").LeanDocument<import("mongoose").Document<any, {}> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
59
+ createUser<User = any>(user: Partial<FormioSubmission<User>>): Promise<import("mongoose").LeanDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>>>;
49
60
  /**
50
61
  * Update user submission in formio
51
62
  * @param user
@@ -0,0 +1,63 @@
1
+ /// <reference types="mongoose/types/pipelinestage" />
2
+ /// <reference types="mongoose/types/connection" />
3
+ /// <reference types="mongoose/types/cursor" />
4
+ /// <reference types="mongoose/types/document" />
5
+ /// <reference types="mongoose/types/error" />
6
+ /// <reference types="mongoose/types/mongooseoptions" />
7
+ /// <reference types="mongoose/types/schemaoptions" />
8
+ import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
9
+ import type { FilterQuery } from "mongoose";
10
+ import { FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken } from "@tsed/formio-types";
11
+ import { FormioMapper } from "../builder/FormioMapper";
12
+ import { FormioService } from "./FormioService";
13
+ export declare class FormioDatabase {
14
+ protected formio: FormioService;
15
+ get models(): import("mongoose").Models;
16
+ get roleModel(): MongooseModel<FormioRole>;
17
+ get formModel(): MongooseModel<FormioForm>;
18
+ get actionModel(): MongooseModel<FormioAction>;
19
+ get submissionModel(): MongooseModel<FormioSubmission>;
20
+ get tokenModel(): MongooseModel<FormioToken>;
21
+ get actionItemModel(): MongooseModel<FormioActionItem>;
22
+ getFormioMapper(): Promise<FormioMapper>;
23
+ hasForms(): Promise<boolean>;
24
+ hasForm(name: string): Promise<boolean>;
25
+ getForm(nameOrId: string): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
26
+ _id: any;
27
+ }> | null>;
28
+ /**
29
+ * Import form previously exported by export tool.
30
+ * This method transform alias to a real mongoose _id
31
+ * @param form
32
+ * @param onCreate
33
+ */
34
+ importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
35
+ _id: any;
36
+ }> | null>;
37
+ /**
38
+ * Import form previously exported by export tool.
39
+ * This method transform alias to a real mongoose _id
40
+ * @param form
41
+ */
42
+ importForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
43
+ _id: any;
44
+ }>;
45
+ saveForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
46
+ _id: any;
47
+ }>;
48
+ getSubmissions<Data>(query?: FilterQuery<MongooseModel<FormioSubmission<Data>>>): Promise<MongooseDocument<FormioSubmission<Data>>[]>;
49
+ /**
50
+ * Import submission previously exported by export tool.
51
+ * This method transform alias to a real mongoose _id
52
+ * @param submission
53
+ */
54
+ importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, "form"> & {
55
+ form?: any;
56
+ }): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
57
+ _id: any;
58
+ }>;
59
+ saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
60
+ _id: any;
61
+ }>;
62
+ idToBson(form?: any): any;
63
+ }
@@ -1,12 +1,11 @@
1
- /// <reference types="qs" />
2
- /// <reference types="express" />
3
1
  import { InjectorService } from "@tsed/common";
4
2
  import { FormioHooks } from "../domain/FormioHooks";
5
3
  import { FormioService } from "./FormioService";
4
+ import { Request } from "express";
6
5
  export declare class FormioHooksService {
7
6
  protected injector: InjectorService;
8
7
  protected formio: FormioService;
9
- get settings(): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs>, cb: Function) => void;
8
+ get settings(): (req: Request, cb: Function) => void;
10
9
  get invoke(): <T = any>(...args: any[]) => boolean | T;
11
10
  get alter(): (event: string, ...args: any[]) => any;
12
11
  get alterAsync(): (event: string, ...args: any[]) => Promise<any>;
@@ -0,0 +1,24 @@
1
+ /// <reference types="mongoose/types/pipelinestage" />
2
+ /// <reference types="mongoose/types/connection" />
3
+ /// <reference types="mongoose/types/cursor" />
4
+ /// <reference types="mongoose/types/document" />
5
+ /// <reference types="mongoose/types/error" />
6
+ /// <reference types="mongoose/types/mongooseoptions" />
7
+ /// <reference types="mongoose/types/schemaoptions" />
8
+ import type { FilterQuery } from "mongoose";
9
+ import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
10
+ import { FormioSubmission } from "../domain/FormioModels";
11
+ import { FormioDatabase } from "./FormioDatabase";
12
+ export declare abstract class FormioRepository<SubmissionData = any> {
13
+ protected formioDatabase: FormioDatabase;
14
+ protected abstract formName: string;
15
+ private formId;
16
+ getFormId(): Promise<string>;
17
+ saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, "form"> & {
18
+ form?: any;
19
+ }): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
20
+ _id: any;
21
+ }>;
22
+ getSubmissions(query?: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>>): Promise<MongooseDocument<FormioSubmission<SubmissionData>>[]>;
23
+ findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined>;
24
+ }
File without changes
package/package.json CHANGED
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "name": "@tsed/formio",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-beta.10",
4
4
  "description": "Formio package for Ts.ED framework",
5
- "source": "./src/index.ts",
6
- "main": "./lib/index.js",
7
- "typings": "./lib/index.d.ts",
8
5
  "private": false,
9
6
  "keywords": [
10
7
  "Formio",
@@ -14,39 +11,57 @@
14
11
  "decorators",
15
12
  "express"
16
13
  ],
14
+ "source": "./src/index.ts",
15
+ "main": "./lib/cjs/index.js",
16
+ "module": "./lib/esm/index.js",
17
+ "typings": "./lib/types/index.d.ts",
18
+ "exports": {
19
+ "types": "./lib/types/index.d.ts",
20
+ "import": "./lib/esm/index.js",
21
+ "require": "./lib/cjs/index.js",
22
+ "default": "./lib/esm/index.js"
23
+ },
17
24
  "scripts": {
18
- "build": "tsc --build tsconfig.compile.json",
25
+ "build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
26
+ "build:cjs": "tsc --build tsconfig.compile.json",
27
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
28
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
19
29
  "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
20
30
  "test": "cross-env NODE_ENV=test nyc mocha"
21
31
  },
22
32
  "dependencies": {
23
- "tslib": "2.2.0"
33
+ "@tsed/formio-types": "7.0.0-beta.10",
34
+ "tslib": "2.3.1"
24
35
  },
25
36
  "devDependencies": {
26
- "@tsed/common": "7.0.0-alpha.1",
27
- "@tsed/core": "7.0.0-alpha.1",
28
- "@tsed/di": "7.0.0-alpha.1",
29
- "@tsed/mongoose": "7.0.0-alpha.1",
37
+ "@tsed/common": "7.0.0-beta.10",
38
+ "@tsed/core": "7.0.0-beta.10",
39
+ "@tsed/di": "7.0.0-beta.10",
40
+ "@tsed/mongoose": "7.0.0-beta.10",
41
+ "@types/async": "3.2.12",
30
42
  "express": "^4.17.1",
31
43
  "formio": "^2.0.0",
32
44
  "mongodb": "*",
33
- "mongoose": "^5.12.2"
45
+ "mongoose": "^6.1.7"
34
46
  },
35
47
  "peerDependencies": {
36
- "@tsed/common": "^7.0.0-alpha.1",
37
- "@tsed/core": "^7.0.0-alpha.1",
38
- "@tsed/di": "^7.0.0-alpha.1",
39
- "@tsed/mongoose": "^7.0.0-alpha.1",
48
+ "@tsed/common": "^7.0.0-beta.10",
40
49
  "express": "^4.17.1",
41
50
  "formio": "^2.0.0",
51
+ "lodash": "^4.17.21",
42
52
  "mongodb": "*",
43
- "mongoose": "^5.12.2"
53
+ "mongoose": "^6.1.7"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "@tsed/common": {
57
+ "optional": false
58
+ }
44
59
  },
45
60
  "repository": "https://github.com/tsedio/tsed",
46
61
  "bugs": {
47
62
  "url": "https://github.com/tsedio/tsed/issues"
48
63
  },
49
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/third-parties/formio",
64
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/formio",
50
65
  "author": "Romain Lenzotti",
51
66
  "license": "MIT"
52
67
  }
package/readme.md CHANGED
@@ -32,7 +32,7 @@ A package of Ts.ED framework. See website: https://tsed.io/tutorials/formio.html
32
32
  ## Feature
33
33
 
34
34
  Currently, `@tsed/formio` allows you:
35
-
35
+
36
36
  - Configure formio project
37
37
  - Register Hook
38
38
  - Register Actions
@@ -50,30 +50,26 @@ Then import `@tsed/formio` in your Server:
50
50
 
51
51
  ```typescript
52
52
  import {Configuration, PlatformApplication} from "@tsed/common";
53
- import "@tsed/formio";
53
+ import "@tsed/formio";
54
54
 
55
55
  @Configuration({
56
- formio: {
57
- }
56
+ formio: {}
58
57
  })
59
- export class Server {
60
-
61
- }
58
+ export class Server {}
62
59
  ```
63
60
 
64
61
  ## Contributors
62
+
65
63
  Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
66
64
 
67
65
  <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
68
66
 
69
-
70
67
  ## Backers
71
68
 
72
69
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
73
70
 
74
71
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
75
72
 
76
-
77
73
  ## Sponsors
78
74
 
79
75
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
12
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioModule.js","sourceRoot":"","sources":["../src/FormioModule.ts"],"names":[],"m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,EAAE,CAAC;;8CACU;AAGjC;IADC,iBAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;;6CACN;AAG1B;IADC,iBAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC;;iDACP;AAG/B;IADC,iBAAQ,CAAC,iBAAiB,CAAC;;8CACQ;AAGpC;IADC,iBAAQ,CAAC,aAAa,CAAC;;0CACH;AA7BV,YAAY;IAdxB,WAAM,CAAC;QACN,OAAO,EAAE;YACP,6BAAa;YACb,uCAAkB;YAClB,qCAAiB;YACjB,2BAAY;YACZ,qBAAS;YACT,uBAAU;YACV,mBAAQ;YACR,qBAAS;YACT,mDAAwB;YACxB,mDAAwB;SACzB;KACF,CAAC;GACW,YAAY,CAsHxB;AAtHY,oCAAY","sourcesContent":["import {\n Constant,\n Inject,\n InjectorService,\n OnReady,\n OnRoutesInit,\n PlatformApplication,\n PlatformRouteDetails,\n normalizePath\n} from \"@tsed/common\";\nimport {deepClone} from \"@tsed/core\";\nimport {Module} from \"@tsed/di\";\nimport {AlterActions} from \"./components/AlterActions\";\nimport {AlterAudit} from \"./components/AlterAudit\";\nimport {AlterHost} from \"./components/AlterHost\";\nimport {AlterLog} from \"./components/AlterLog\";\nimport {AlterSkip} from \"./components/AlterSkip\";\nimport {AlterTemplateExportSteps} from \"./components/AlterTemplateExportSteps\";\nimport {AlterTemplateImportSteps} from \"./components/AlterTemplateImportSteps\";\nimport {FormioConfig} from \"./domain/FormioConfig\";\nimport {FormioTemplate} from \"./domain/FormioTemplate\";\nimport {FormioAuthService} from \"./services/FormioAuthService\";\nimport {FormioHooksService} from \"./services/FormioHooksService\";\nimport {FormioInstaller} from \"./services/FormioInstaller\";\nimport {FormioService} from \"./services/FormioService\";\n\n@Module({\n imports: [\n FormioService,\n FormioHooksService,\n FormioAuthService,\n AlterActions,\n AlterHost,\n AlterAudit,\n AlterLog,\n AlterSkip,\n AlterTemplateImportSteps,\n AlterTemplateExportSteps\n ]\n})\nexport class FormioModule implements OnRoutesInit, OnReady {\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected hooks: FormioHooksService;\n\n @Inject()\n protected installer: FormioInstaller;\n\n @Inject()\n protected app: PlatformApplication;\n\n @Inject()\n protected injector: InjectorService;\n\n @Constant(\"formio\", {})\n protected settings: FormioConfig;\n\n @Constant(\"formio.baseUrl\", \"/\")\n protected baseUrl: string;\n\n @Constant(\"formio.skipInstall\", false)\n protected skipInstall: boolean;\n\n @Constant(\"formio.template\")\n protected template?: FormioTemplate;\n\n @Constant(\"formio.root\")\n protected root?: any;\n\n $onInit() {\n return this.init(deepClone(this.settings));\n }\n\n async init(options: FormioConfig) {\n return this.formio.init(options, this.hooks.getHooks());\n }\n\n async $onRoutesInit() {\n if (this.formio.isInit()) {\n const router: any = this.app.getRouter();\n\n router.use(this.baseUrl, this.formio.middleware.restrictRequestTypes, this.formio.router);\n\n if (await this.shouldInstall()) {\n await this.installer.install(this.template!, this.root);\n }\n }\n }\n\n async $logRoutes(routes: PlatformRouteDetails[]): Promise<PlatformRouteDetails[]> {\n if (this.formio.isInit()) {\n const spec = (await this.formio.swagger(\n {\n $ctx: {\n request: {\n protocol: \"http\",\n host: \"localhost\"\n }\n }\n },\n this.formio.router\n )) as any;\n const {baseUrl} = this;\n\n Object.entries(spec.paths).forEach(([path, methods]: [string, any]) => {\n Object.entries(methods).forEach(([method, operation]: [string, any]) => {\n routes.push({\n toJSON() {\n return {\n method,\n name: operation.operationId,\n url: normalizePath(baseUrl, path.replace(/\\/{(.*)}/gi, \"/:$1\")),\n className: \"formio\",\n methodClassName: operation.operationId,\n parameters: [],\n rawBody: false\n };\n }\n } as any);\n });\n });\n }\n\n return routes;\n }\n\n // istanbul ignore next\n async $onReady(): Promise<void> {\n if (this.formio.isInit()) {\n const {injector} = this;\n const {httpsPort, httpPort} = injector.settings;\n\n const displayLog = (host: any) => {\n const url = [`${host.protocol}://${host.address}`, typeof host.port === \"number\" && host.port].filter(Boolean).join(\":\");\n\n injector.logger.info(`Form.io API is available on ${url}${this.baseUrl || \"/\"}`);\n };\n\n /* istanbul ignore next */\n if (httpsPort) {\n (this.formio.config as any).protocol = \"https\";\n const host = injector.settings.getHttpsPort();\n displayLog({protocol: \"https\", ...host});\n } else if (httpPort) {\n (this.formio.config as any).protocol = \"http\";\n const host = injector.settings.getHttpPort();\n displayLog({protocol: \"http\", ...host});\n }\n }\n }\n\n protected async shouldInstall() {\n const hasForms = await this.installer.hasForms();\n\n return this.template && !(hasForms || this.skipInstall);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioMapper.js","sourceRoot":"","sources":["../../src/builder/FormioMapper.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IACvB,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAEjD,IAAI,CAAC,GAAW;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAE1E,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACrG,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrC,CAAC;IAED,eAAe,CAAC,IAAS;QACvB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,MAA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ACJ,CAAC,EAAE,EAAE,CAAC,CAAC;SACR;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA3DD,oCA2DC","sourcesContent":["import {FormioCtxMapper} from \"../domain/FormioCtxMapper\";\n\nexport class FormioMapper {\n constructor(readonly ctxData: FormioCtxMapper) {}\n\n find(key: string) {\n const store = Object.values(this.ctxData).find((store) => store.get(key));\n\n return store?.get(key);\n }\n\n findId(data: string) {\n const key = String(data).startsWith(\"$machineName:\") ? String(data) : `$machineName:${String(data)}`;\n const item = this.find(key);\n\n return item ? item._id : undefined;\n }\n\n findMachineName(data: any) {\n const key = String(data);\n const item: any = this.find(key);\n\n return item ? `$machineName:${item.machineName}` : undefined;\n }\n\n mapToExport(data: any) {\n return this.mapData(data, this.findMachineName.bind(this));\n }\n\n mapToImport(data: any) {\n return this.mapData(data, this.findId.bind(this));\n }\n\n mapData(data: any, resolver: any): any {\n if (!data) {\n return data;\n }\n\n if (Array.isArray(data)) {\n return data.map((item) => {\n return this.mapData(item, resolver);\n });\n }\n\n const key = resolver(data, this.ctxData);\n\n if (key) {\n return key;\n }\n\n if (typeof data === \"object\" && !(data instanceof Date)) {\n return Object.entries(data).reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: this.mapData(value, resolver)\n };\n }, {});\n }\n\n return data;\n }\n}\n"]}