@tsed/formio 7.0.0-beta.12 → 7.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/FormioModule.js +12 -1
  3. package/lib/cjs/FormioModule.js.map +1 -1
  4. package/lib/cjs/builder/FormioMapper.js +2 -1
  5. package/lib/cjs/builder/FormioMapper.js.map +1 -1
  6. package/lib/cjs/components/AlterActions.js +19 -17
  7. package/lib/cjs/components/AlterActions.js.map +1 -1
  8. package/lib/cjs/components/AlterSkip.js +2 -0
  9. package/lib/cjs/components/AlterSkip.js.map +1 -1
  10. package/lib/cjs/components/AlterTemplateExportSteps.js +1 -0
  11. package/lib/cjs/components/AlterTemplateExportSteps.js.map +1 -1
  12. package/lib/cjs/components/AlterTemplateImportSteps.js +1 -0
  13. package/lib/cjs/components/AlterTemplateImportSteps.js.map +1 -1
  14. package/lib/cjs/middlewares/FormioAuthMiddleware.js +1 -0
  15. package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +1 -1
  16. package/lib/cjs/services/FormioAuthService.js +4 -1
  17. package/lib/cjs/services/FormioAuthService.js.map +1 -1
  18. package/lib/cjs/services/FormioDatabase.js +1 -0
  19. package/lib/cjs/services/FormioDatabase.js.map +1 -1
  20. package/lib/cjs/services/FormioHooksService.js +2 -0
  21. package/lib/cjs/services/FormioHooksService.js.map +1 -1
  22. package/lib/cjs/services/FormioInstaller.js +2 -7
  23. package/lib/cjs/services/FormioInstaller.js.map +1 -1
  24. package/lib/cjs/services/FormioRepository.js +2 -0
  25. package/lib/cjs/services/FormioRepository.js.map +1 -1
  26. package/lib/cjs/services/FormioService.js +2 -0
  27. package/lib/cjs/services/FormioService.js.map +1 -1
  28. package/lib/esm/FormioModule.js +12 -1
  29. package/lib/esm/FormioModule.js.map +1 -1
  30. package/lib/esm/builder/FormioMapper.js +2 -1
  31. package/lib/esm/builder/FormioMapper.js.map +1 -1
  32. package/lib/esm/components/AlterActions.js +19 -17
  33. package/lib/esm/components/AlterActions.js.map +1 -1
  34. package/lib/esm/components/AlterSkip.js +2 -0
  35. package/lib/esm/components/AlterSkip.js.map +1 -1
  36. package/lib/esm/components/AlterTemplateExportSteps.js +1 -0
  37. package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -1
  38. package/lib/esm/components/AlterTemplateImportSteps.js +1 -0
  39. package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -1
  40. package/lib/esm/middlewares/FormioAuthMiddleware.js +1 -0
  41. package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -1
  42. package/lib/esm/services/FormioAuthService.js +4 -1
  43. package/lib/esm/services/FormioAuthService.js.map +1 -1
  44. package/lib/esm/services/FormioDatabase.js +1 -0
  45. package/lib/esm/services/FormioDatabase.js.map +1 -1
  46. package/lib/esm/services/FormioHooksService.js +2 -0
  47. package/lib/esm/services/FormioHooksService.js.map +1 -1
  48. package/lib/esm/services/FormioInstaller.js +2 -7
  49. package/lib/esm/services/FormioInstaller.js.map +1 -1
  50. package/lib/esm/services/FormioRepository.js +2 -0
  51. package/lib/esm/services/FormioRepository.js.map +1 -1
  52. package/lib/esm/services/FormioService.js +2 -0
  53. package/lib/esm/services/FormioService.js.map +1 -1
  54. package/lib/types/services/FormioInstaller.d.ts +0 -2
  55. package/package.json +9 -9
  56. package/.mocharc.js +0 -5
  57. package/.nycrc +0 -27
@@ -1 +1 @@
1
- {"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/FormioService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AAIjE,+BAA+B;AAQ/B,aAAa;AACb,4DAAkC;AAClC,aAAa;AACb,oFAAiD;AACjD,aAAa;AACb,8EAA2C;AAG3C,IAAa,aAAa,GAA1B,MAAa,aAAa;IAMxB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,C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AC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;SACjG;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,UAAU;QAClB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,iBAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,iBAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA3GC;IADC,IAAA,eAAM,GAAE;sCACW,wBAAe;+CAAC;AAJzB,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CA+GzB;AA/GY,sCAAa","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {MongooseConnectionOptions} from \"@tsed/mongoose\";\nimport {Db} from \"mongodb\";\nimport {Mongoose} from \"mongoose\";\nimport {promisify} from \"util\";\nimport {Formio} from \"../domain/Formio\";\nimport {FormioConfig} from \"../domain/FormioConfig\";\nimport {FormioHook, FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioSchemas} from \"../domain/FormioModels\";\nimport {FormioRouter} from \"../domain/FormioRouter\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioExportOptions} from \"../domain/FormioTemplateUtil\";\n// @ts-ignore\nimport createRouter from \"formio\";\n// @ts-ignore\nimport swagger from \"formio/src/util/swagger.js\";\n// @ts-ignore\nimport util from \"formio/src/util/util.js\";\n\n@Injectable()\nexport class FormioService {\n router: FormioRouter;\n\n @Inject()\n protected injector: InjectorService;\n\n get audit(): Function {\n return this.formio.audit || (() => {});\n }\n\n get auth() {\n return this.formio.auth;\n }\n\n // istanbul ignore next\n get swagger() {\n return (...args: any[]) => new Promise((resolve) => swagger(...args, resolve));\n }\n\n get config(): FormioConfig {\n return this.formio.config;\n }\n\n get db(): Db {\n return this.formio.db;\n }\n\n get resources() {\n return this.formio.resources;\n }\n\n get mongoose(): Mongoose {\n return this.formio.mongoose;\n }\n\n get middleware() {\n return this.formio.middleware;\n }\n\n get schemas(): FormioSchemas {\n return this.formio.schemas;\n }\n\n get formio(): Formio {\n return this.router.formio as Formio;\n }\n\n get hook(): FormioHook {\n return this.formio.hook;\n }\n\n get util() {\n return this.formio.util;\n }\n\n get template() {\n return this.formio.template;\n }\n\n get Action() {\n return this.formio.Action;\n }\n\n async exportTemplate(options: Partial<FormioExportOptions> = {}): Promise<FormioTemplate> {\n return promisify(this.formio.template.export)(options);\n }\n\n async importTemplate(template: FormioTemplate): Promise<FormioTemplate> {\n return promisify(this.formio.template.import.template)(template);\n }\n\n encrypt(text: string) {\n return promisify(this.formio.encrypt)(text);\n }\n\n isInit() {\n return !!this.router;\n }\n\n // istanbul ignore next\n public createRouter(options: FormioConfig) {\n return createRouter(options);\n }\n\n public init(options: FormioConfig, hooks: FormioHooks = {}) {\n if (options && Object.keys(options).length) {\n this.router = this.createRouter(this.mapConfiguration(options));\n this.bindLogger();\n\n return this.router.init(hooks);\n }\n }\n\n protected mapConfiguration(options: FormioConfig) {\n const {injector} = this;\n const mongooseSettings = injector.settings.get<MongooseConnectionOptions>(\"mongoose.0\");\n\n if (mongooseSettings) {\n options.mongo = options.mongo || mongooseSettings.url;\n options.mongoConfig = options.mongoConfig || JSON.stringify(mongooseSettings.connectionOptions);\n }\n\n return options;\n }\n\n protected bindLogger() {\n const {injector} = this;\n\n util.log = injector.logger.info.bind(injector.logger);\n util.error = injector.logger.error.bind(injector.logger);\n }\n}\n"]}
1
+ {"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/FormioService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AAIjE,+BAA+B;AAQ/B,aAAa;AACb,4DAAkC;AAClC,aAAa;AACb,oFAAiD;AACjD,aAAa;AACb,8EAA2C;AAG3C,IAAa,aAAa,GAA1B,MAAa,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AAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAAC,GAAG,CAAC;YACtD,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;SACjG;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,UAAU;QAClB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,iBAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,iBAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA3GC;IADC,IAAA,eAAM,GAAE;sCACW,wBAAe;+CAAC;AAJzB,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CA+GzB;AA/GY,sCAAa","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {MongooseConnectionOptions} from \"@tsed/mongoose\";\nimport {Db} from \"mongodb\";\nimport {Mongoose} from \"mongoose\";\nimport {promisify} from \"util\";\nimport {Formio} from \"../domain/Formio\";\nimport {FormioConfig} from \"../domain/FormioConfig\";\nimport {FormioHook, FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioSchemas} from \"../domain/FormioModels\";\nimport {FormioRouter} from \"../domain/FormioRouter\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioExportOptions} from \"../domain/FormioTemplateUtil\";\n// @ts-ignore\nimport createRouter from \"formio\";\n// @ts-ignore\nimport swagger from \"formio/src/util/swagger.js\";\n// @ts-ignore\nimport util from \"formio/src/util/util.js\";\n\n@Injectable()\nexport class FormioService {\n router: FormioRouter;\n\n @Inject()\n protected injector: InjectorService;\n\n get audit(): Function {\n return this.formio.audit || (() => {});\n }\n\n get auth() {\n return this.formio.auth;\n }\n\n // istanbul ignore next\n get swagger() {\n return (...args: any[]) => new Promise((resolve) => swagger(...args, resolve));\n }\n\n get config(): FormioConfig {\n return this.formio.config;\n }\n\n get db(): Db {\n return this.formio.db;\n }\n\n get resources() {\n return this.formio.resources;\n }\n\n get mongoose(): Mongoose {\n return this.formio.mongoose;\n }\n\n get middleware() {\n return this.formio.middleware;\n }\n\n get schemas(): FormioSchemas {\n return this.formio.schemas;\n }\n\n get formio(): Formio {\n return this.router.formio as Formio;\n }\n\n get hook(): FormioHook {\n return this.formio.hook;\n }\n\n get util() {\n return this.formio.util;\n }\n\n get template() {\n return this.formio.template;\n }\n\n get Action() {\n return this.formio.Action;\n }\n\n async exportTemplate(options: Partial<FormioExportOptions> = {}): Promise<FormioTemplate> {\n return promisify(this.formio.template.export)(options);\n }\n\n async importTemplate(template: FormioTemplate): Promise<FormioTemplate> {\n return promisify(this.formio.template.import.template)(template);\n }\n\n encrypt(text: string) {\n return promisify(this.formio.encrypt)(text);\n }\n\n isInit() {\n return !!this.router;\n }\n\n // istanbul ignore next\n public createRouter(options: FormioConfig) {\n return createRouter(options);\n }\n\n public init(options: FormioConfig, hooks: FormioHooks = {}) {\n if (options && Object.keys(options).length) {\n this.router = this.createRouter(this.mapConfiguration(options));\n this.bindLogger();\n\n return this.router.init(hooks);\n }\n }\n\n protected mapConfiguration(options: FormioConfig) {\n const {injector} = this;\n const mongooseSettings = injector.settings.get<MongooseConnectionOptions>(\"mongoose.0\");\n\n if (mongooseSettings) {\n options.mongo = options.mongo || mongooseSettings.url;\n options.mongoConfig = options.mongoConfig || JSON.stringify(mongooseSettings.connectionOptions);\n }\n\n return options;\n }\n\n protected bindLogger() {\n const {injector} = this;\n\n util.log = injector.logger.info.bind(injector.logger);\n util.error = injector.logger.error.bind(injector.logger);\n }\n}\n"]}
@@ -14,6 +14,16 @@ import { FormioHooksService } from "./services/FormioHooksService.js";
14
14
  import { FormioInstaller } from "./services/FormioInstaller.js";
15
15
  import { FormioService } from "./services/FormioService.js";
16
16
  let FormioModule = class FormioModule {
17
+ formio;
18
+ hooks;
19
+ installer;
20
+ app;
21
+ injector;
22
+ settings;
23
+ baseUrl;
24
+ skipInstall;
25
+ template;
26
+ root;
17
27
  $onInit() {
18
28
  return this.init(deepClone(this.settings));
19
29
  }
@@ -62,8 +72,9 @@ let FormioModule = class FormioModule {
62
72
  }
63
73
  // istanbul ignore next
64
74
  async $onReady() {
65
- if (this.formio.isInit() && this.injector.settings.getBestHost) {
75
+ if (this.formio.isInit() && "getBestHost" in this.injector.settings) {
66
76
  const { injector } = this;
77
+ // @ts-ignore
67
78
  const host = injector.settings.getBestHost();
68
79
  const url = host.toString();
69
80
  injector.logger.info(`Form.io API is available on ${url}${this.baseUrl || "/"}`);
@@ -1 +1 @@
1
- {"version":3,"file":"FormioModule.js","sourceRoot":"","sources":["../../src/FormioModule.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EACR,MAAM,EACN,eAAe,EACf,aAAa,EAGb,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAG/E,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAC,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I,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAEjD,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AAtGC;IADC,MAAM,EAAE;8BACS,aAAa;4CAAC;AAGhC;IADC,MAAM,EAAE;8BACQ,kBAAkB;2CAAC;AAGpC;IADC,MAAM,EAAE;8BACY,eAAe;+CAAC;AAGrC;IADC,MAAM,EAAE;8BACM,mBAAmB;yCAAC;AAGnC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;;8CACU;AAGjC;IADC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;;6CACN;AAG1B;IADC,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC;;iDACP;AAG/B;IADC,QAAQ,CAAC,iBAAiB,CAAC;;8CACQ;AAGpC;IADC,QAAQ,CAAC,aAAa,CAAC;;0CACH;AA7BV,YAAY;IAdxB,MAAM,CAAC;QACN,OAAO,EAAE;YACP,aAAa;YACb,kBAAkB;YAClB,iBAAiB;YACjB,YAAY;YACZ,SAAS;YACT,UAAU;YACV,QAAQ;YACR,SAAS;YACT,wBAAwB;YACxB,wBAAwB;SACzB;KACF,CAAC;GACW,YAAY,CAwGxB;SAxGY,YAAY","sourcesContent":["import {\n Constant,\n Inject,\n InjectorService,\n normalizePath,\n OnReady,\n OnRoutesInit,\n PlatformApplication,\n PlatformRouteDetails\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() && this.injector.settings.getBestHost) {\n const {injector} = this;\n const host = injector.settings.getBestHost();\n const url = host.toString();\n\n injector.logger.info(`Form.io API is available on ${url}${this.baseUrl || \"/\"}`);\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
+ {"version":3,"file":"FormioModule.js","sourceRoot":"","sources":["../../src/FormioModule.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EACR,MAAM,EACN,eAAe,EACf,aAAa,EAGb,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAG/E,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAC,eAAe,EAAC,MAAM,4B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CAAC,+BAA+B,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;SAClF;IACH,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AAtGC;IADC,MAAM,EAAE;8BACS,aAAa;4CAAC;AAGhC;IADC,MAAM,EAAE;8BACQ,kBAAkB;2CAAC;AAGpC;IADC,MAAM,EAAE;8BACY,eAAe;+CAAC;AAGrC;IADC,MAAM,EAAE;8BACM,mBAAmB;yCAAC;AAGnC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;;8CACU;AAGjC;IADC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;;6CACN;AAG1B;IADC,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC;;iDACP;AAG/B;IADC,QAAQ,CAAC,iBAAiB,CAAC;;8CACQ;AAGpC;IADC,QAAQ,CAAC,aAAa,CAAC;;0CACH;AA7BV,YAAY;IAdxB,MAAM,CAAC;QACN,OAAO,EAAE;YACP,aAAa;YACb,kBAAkB;YAClB,iBAAiB;YACjB,YAAY;YACZ,SAAS;YACT,UAAU;YACV,QAAQ;YACR,SAAS;YACT,wBAAwB;YACxB,wBAAwB;SACzB;KACF,CAAC;GACW,YAAY,CAwGxB;SAxGY,YAAY","sourcesContent":["import {\n Constant,\n Inject,\n InjectorService,\n normalizePath,\n OnReady,\n OnRoutesInit,\n PlatformApplication,\n PlatformRouteDetails\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() && \"getBestHost\" in this.injector.settings) {\n const {injector} = this;\n // @ts-ignore\n const host = injector.settings.getBestHost();\n const url = host.toString();\n\n injector.logger.info(`Form.io API is available on ${url}${this.baseUrl || \"/\"}`);\n }\n }\n\n protected async shouldInstall() {\n const hasForms = await this.installer.hasForms();\n return this.template && !(hasForms || this.skipInstall);\n }\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  export class FormioMapper {
2
+ ctxData;
2
3
  constructor(ctxData) {
3
4
  this.ctxData = ctxData;
4
5
  }
5
6
  find(key) {
6
7
  const store = Object.values(this.ctxData).find((store) => store.get(key));
7
- return store === null || store === void 0 ? void 0 : store.get(key);
8
+ return store?.get(key);
8
9
  }
9
10
  findId(data) {
10
11
  const key = String(data).startsWith("$machineName:") ? String(data) : `$machineName:${String(data)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"FormioMapper.js","sourceRoot":"","sources":["../../../src/builder/FormioMapper.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,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,C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AAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACvB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,GAAG,EAAE;YACP,OAAO,GAAG,CAAC;SACZ;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,CAAC,EAAE;YACjF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC/D,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;iBACrC,CAAC;YACJ,CAAC,EAAE,EAAE,CAAC,CAAC;YAEP,OAAO,MAAM;gBACX,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI;iBAC3C;gBACH,CAAC,CAAC,MAAM,CAAC;SACZ;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","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.name || 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\" && !(\"_bsontype\" in data) && !(data instanceof Date)) {\n const isForm = data.path && data.type;\n const mapped = Object.entries(data).reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: this.mapData(value, resolver)\n };\n }, {});\n\n return isForm\n ? {\n ...mapped,\n name: data.name,\n machineName: data.machineName || data.name\n }\n : mapped;\n }\n\n return data;\n }\n}\n"]}
1
+ {"version":3,"file":"FormioMapper.js","sourceRoot":"","sources":["../../../src/builder/FormioMapper.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAY;IACF;IAArB,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,EAAE,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,IAA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,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,CAAC,EAAE;YACjF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC/D,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;iBACrC,CAAC;YACJ,CAAC,EAAE,EAAE,CAAC,CAAC;YAEP,OAAO,MAAM;gBACX,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI;iBAC3C;gBACH,CAAC,CAAC,MAAM,CAAC;SACZ;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","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.name || 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\" && !(\"_bsontype\" in data) && !(data instanceof Date)) {\n const isForm = data.path && data.type;\n const mapped = Object.entries(data).reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: this.mapData(value, resolver)\n };\n }, {});\n\n return isForm\n ? {\n ...mapped,\n name: data.name,\n machineName: data.machineName || data.name\n }\n : mapped;\n }\n\n return data;\n }\n}\n"]}
@@ -8,32 +8,34 @@ import { setResponseHeaders } from "@tsed/common";
8
8
  import { Alter } from "../decorators/alter.js";
9
9
  import { FormioService } from "../services/FormioService.js";
10
10
  let AlterActions = class AlterActions {
11
+ injector;
12
+ formio;
13
+ params;
14
+ responseFilter;
11
15
  transform(actions) {
12
16
  const { Action } = this.formio;
13
17
  return this.getActions().reduce((actions, provider) => {
14
- var _a;
15
18
  const instance = this.injector.invoke(provider.token);
16
19
  const options = provider.store.get("formio:action");
17
20
  const resolveHandler = this.createHandler(provider, "resolve");
18
21
  return {
19
22
  ...actions,
20
- [options.name]: (_a = class extends Action {
21
- static async info(req, res, next) {
22
- let opts = { ...options };
23
- if (instance.info) {
24
- opts = await instance.info(opts, req, res);
25
- }
26
- next(null, opts);
23
+ [options.name]: class extends Action {
24
+ static access = options.access;
25
+ static async info(req, res, next) {
26
+ let opts = { ...options };
27
+ if (instance.info) {
28
+ opts = await instance.info(opts, req, res);
27
29
  }
28
- static async settingsForm(req, res, next) {
29
- next(null, await instance.settingsForm(req, res));
30
- }
31
- resolve(handler, method, req, res, next, setActionItemMessage) {
32
- resolveHandler(this, handler, method, req, res, next, setActionItemMessage);
33
- }
34
- },
35
- _a.access = options.access,
36
- _a)
30
+ next(null, opts);
31
+ }
32
+ static async settingsForm(req, res, next) {
33
+ next(null, await instance.settingsForm(req, res));
34
+ }
35
+ resolve(handler, method, req, res, next, setActionItemMessage) {
36
+ resolveHandler(this, handler, method, req, res, next, setActionItemMessage);
37
+ }
38
+ }
37
39
  };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B,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEvD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAhHC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACS,aAAa;4CAAC;AAGhC;IADC,MAAM,EAAE;8BACS,cAAc;4CAAC;AAGjC;IADC,MAAM,EAAE;8BACiB,sBAAsB;oDAAC;AAXtC,YAAY;IADxB,KAAK,CAAC,SAAS,CAAC;GACJ,YAAY,CAkHxB;SAlHY,YAAY","sourcesContent":["import {Inject, InjectorService, Provider, runInContext} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected params: PlatformParams;\n\n @Inject()\n protected responseFilter: PlatformResponseFilter;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createHandler(provider, \"resolve\");\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createHandler(provider: Provider, propertyKey: string | symbol) {\n const promisedHandler = this.params.compileHandler({\n token: provider.token,\n propertyKey\n });\n\n return async (\n action: any,\n handler: string,\n method: string,\n req: {$ctx: PlatformContext},\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const $ctx = req.$ctx;\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n await runInContext($ctx, async () => {\n try {\n const resolver = new AnyToPromise();\n const handler = await promisedHandler;\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n if (state === AnyToPromiseStatus.RESOLVED) {\n if (status) {\n $ctx.response.status(status);\n }\n\n if (headers) {\n $ctx.response.setHeaders(headers);\n }\n\n if (data !== undefined) {\n $ctx.data = data;\n\n return await this.flush($ctx.data, $ctx);\n }\n\n next();\n }\n } catch (er) {\n next(er);\n }\n });\n };\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!response.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx);\n data = await this.responseFilter.transform(data, $ctx);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
1
+ {"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"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G,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEvD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAhHC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACS,aAAa;4CAAC;AAGhC;IADC,MAAM,EAAE;8BACS,cAAc;4CAAC;AAGjC;IADC,MAAM,EAAE;8BACiB,sBAAsB;oDAAC;AAXtC,YAAY;IADxB,KAAK,CAAC,SAAS,CAAC;GACJ,YAAY,CAkHxB;SAlHY,YAAY","sourcesContent":["import {Inject, InjectorService, Provider, runInContext} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected params: PlatformParams;\n\n @Inject()\n protected responseFilter: PlatformResponseFilter;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createHandler(provider, \"resolve\");\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createHandler(provider: Provider, propertyKey: string | symbol) {\n const promisedHandler = this.params.compileHandler({\n token: provider.token,\n propertyKey\n });\n\n return async (\n action: any,\n handler: string,\n method: string,\n req: {$ctx: PlatformContext},\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const $ctx = req.$ctx;\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n await runInContext($ctx, async () => {\n try {\n const resolver = new AnyToPromise();\n const handler = await promisedHandler;\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n if (state === AnyToPromiseStatus.RESOLVED) {\n if (status) {\n $ctx.response.status(status);\n }\n\n if (headers) {\n $ctx.response.setHeaders(headers);\n }\n\n if (data !== undefined) {\n $ctx.data = data;\n\n return await this.flush($ctx.data, $ctx);\n }\n\n next();\n }\n } catch (er) {\n next(er);\n }\n });\n };\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!response.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx);\n data = await this.responseFilter.transform(data, $ctx);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
@@ -3,6 +3,8 @@ import { Constant } from "@tsed/common";
3
3
  import { normalizePath } from "@tsed/common";
4
4
  import { Alter } from "../decorators/alter.js";
5
5
  let AlterSkip = class AlterSkip {
6
+ baseUrl;
7
+ whiteList;
6
8
  transform(value, ctx) {
7
9
  if (value) {
8
10
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"AlterSkip.js","sourceRoot":"","sources":["../../../src/components/AlterSkip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAkB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,IAAa,SAAS,GAAtB,MAAa,SAAS;IAOpB,SAAS,CAAC,KAAU,EAAE,GAAoB;QACxC,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC;SACb;QAED,MAAM,EAAC,OAAO,EAAC,GAAG,GAAG,CAAC;QACtB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACrC,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBC;IADC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;;0CAChB;AAGhB;IADC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,YAAY,CAAC,CAAC;;4CACzB;AALT,SAAS;IADrB,KAAK,CAAC,MAAM,CAAC;GACD,SAAS,CAmBrB;SAnBY,SAAS","sourcesContent":["import {Constant, PlatformContext} from \"@tsed/common\";\nimport {normalizePath} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"skip\")\nexport class AlterSkip implements AlterHook {\n @Constant(\"formio.baseUrl\", \"/\")\n baseUrl: string;\n\n @Constant(\"formio.whiteList\", [\"/spec.json\"])\n whiteList: string[];\n\n transform(value: any, ctx: PlatformContext): any {\n if (value) {\n return true;\n }\n\n const {request} = ctx;\n const url = request.url.split(\"?\")[0];\n\n return !!this.whiteList.find((entry) => {\n return normalizePath(this.baseUrl, entry) === url;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"AlterSkip.js","sourceRoot":"","sources":["../../../src/components/AlterSkip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAkB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEpB,OAAO,CAAS;IAGhB,SAAS,CAAW;IAEpB,SAAS,CAAC,KAAU,EAAE,GAAoB;QACxC,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC;SACb;QAED,MAAM,EAAC,OAAO,EAAC,GAAG,GAAG,CAAC;QACtB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACrC,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBC;IADC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;;0CAChB;AAGhB;IADC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,YAAY,CAAC,CAAC;;4CACzB;AALT,SAAS;IADrB,KAAK,CAAC,MAAM,CAAC;GACD,SAAS,CAmBrB;SAnBY,SAAS","sourcesContent":["import {Constant, PlatformContext} from \"@tsed/common\";\nimport {normalizePath} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"skip\")\nexport class AlterSkip implements AlterHook {\n @Constant(\"formio.baseUrl\", \"/\")\n baseUrl: string;\n\n @Constant(\"formio.whiteList\", [\"/spec.json\"])\n whiteList: string[];\n\n transform(value: any, ctx: PlatformContext): any {\n if (value) {\n return true;\n }\n\n const {request} = ctx;\n const url = request.url.split(\"?\")[0];\n\n return !!this.whiteList.find((entry) => {\n return normalizePath(this.baseUrl, entry) === url;\n });\n }\n}\n"]}
@@ -5,6 +5,7 @@ import { Alter } from "../decorators/alter.js";
5
5
  import { FormioDatabase } from "../services/FormioDatabase.js";
6
6
  import async from "async";
7
7
  let AlterTemplateExportSteps = class AlterTemplateExportSteps {
8
+ database;
8
9
  transform(queue, template, map, options) {
9
10
  queue.push(async.apply(this.exportSubmissions.bind(this), template, map, options));
10
11
  return queue;
@@ -1 +1 @@
1
- {"version":3,"file":"AlterTemplateExportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateExportSteps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAInC,SAAS,CAAC,KAAY,EAAE,QAAwB,EAAE,GAAQ,EAAE,OAAY;QACtE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QAEnF,OAAO,KAAK,CAAC;IACf,CAAC;IAES,KAAK,CAAC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BACzC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;gBACzC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBAChD,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;aAC/B,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;CACF,CAAA;AA1CC;IADC,MAAM,EAAE;8BACW,cAAc;0DAAC;AAFxB,wBAAwB;IADpC,KAAK,CAAC,qBAAqB,CAAC;GAChB,wBAAwB,CA4CpC;SA5CY,wBAAwB","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseDocument} from \"@tsed/mongoose\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"../services/FormioDatabase\";\nimport async from \"async\";\n\n@Alter(\"templateExportSteps\")\nexport class AlterTemplateExportSteps implements AlterHook {\n @Inject()\n protected database: FormioDatabase;\n\n transform(queue: any[], template: FormioTemplate, map: any, options: any): any {\n queue.push(async.apply(this.exportSubmissions.bind(this), template, map, options));\n\n return queue;\n }\n\n protected async exportSubmissions(template: FormioTemplate, map: any, options: any, next: any) {\n const [mapper, submissions] = await Promise.all([\n this.database.getFormioMapper(),\n this.database.submissionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n template.submissions = await this.mapSubmissions(submissions, mapper);\n\n next(null, template);\n }\n\n protected mapSubmissions(submissions: MongooseDocument<FormioSubmission>[], mapper: FormioMapper) {\n return submissions\n .map((submission) => submission.toObject())\n .reduce((acc: any, {_id, created, updated, modified, __v, owner, roles, form, metadata, ...submission}) => {\n const machineName = mapper.mapToExport(form.toString());\n const key = machineName.replace(\"$machineName:\", \"\");\n\n acc[key] = getValue(acc, key, []);\n\n acc[key].push({\n ...submission,\n created: created && created.toString(),\n modified: modified && modified.toString(),\n data: mapper.mapToExport(submission.data),\n roles: mapper.mapToExport(roles).filter(Boolean),\n form: mapper.mapToExport(form)\n });\n\n return acc;\n }, {});\n }\n}\n"]}
1
+ {"version":3,"file":"AlterTemplateExportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateExportSteps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAiB;IAEnC,SAAS,CAAC,KAAY,EAAE,QAAwB,EAAE,GAAQ,EAAE,OAAY;QACtE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QAEnF,OAAO,KAAK,CAAC;IACf,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,QAAwB,EAAE,GAAQ,EAAE,OAAY,EAAE,IAAS;QAC3F,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE;YAC/B,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC;gBACjC,OAAO,EAAE,EAAC,GAAG,EAAE,IAAI,EAAC;aACrB,CAAC;SACH,CAAC,CAAC;QAEH,QAAQ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8BACW,cAAc;0DAAC;AAFxB,wBAAwB;IADpC,KAAK,CAAC,qBAAqB,CAAC;GAChB,wBAAwB,CA4CpC;SA5CY,wBAAwB","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseDocument} from \"@tsed/mongoose\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"../services/FormioDatabase\";\nimport async from \"async\";\n\n@Alter(\"templateExportSteps\")\nexport class AlterTemplateExportSteps implements AlterHook {\n @Inject()\n protected database: FormioDatabase;\n\n transform(queue: any[], template: FormioTemplate, map: any, options: any): any {\n queue.push(async.apply(this.exportSubmissions.bind(this), template, map, options));\n\n return queue;\n }\n\n protected async exportSubmissions(template: FormioTemplate, map: any, options: any, next: any) {\n const [mapper, submissions] = await Promise.all([\n this.database.getFormioMapper(),\n this.database.submissionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n template.submissions = await this.mapSubmissions(submissions, mapper);\n\n next(null, template);\n }\n\n protected mapSubmissions(submissions: MongooseDocument<FormioSubmission>[], mapper: FormioMapper) {\n return submissions\n .map((submission) => submission.toObject())\n .reduce((acc: any, {_id, created, updated, modified, __v, owner, roles, form, metadata, ...submission}) => {\n const machineName = mapper.mapToExport(form.toString());\n const key = machineName.replace(\"$machineName:\", \"\");\n\n acc[key] = getValue(acc, key, []);\n\n acc[key].push({\n ...submission,\n created: created && created.toString(),\n modified: modified && modified.toString(),\n data: mapper.mapToExport(submission.data),\n roles: mapper.mapToExport(roles).filter(Boolean),\n form: mapper.mapToExport(form)\n });\n\n return acc;\n }, {});\n }\n}\n"]}
@@ -4,6 +4,7 @@ import { Alter } from "../decorators/alter.js";
4
4
  import { FormioDatabase } from "../services/FormioDatabase.js";
5
5
  import async from "async";
6
6
  let AlterTemplateImportSteps = class AlterTemplateImportSteps {
7
+ database;
7
8
  transform(queue, install, template) {
8
9
  queue.push(async.apply(this.importSubmissions.bind(this), template));
9
10
  return queue;
@@ -1 +1 @@
1
- {"version":3,"file":"AlterTemplateImportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateImportSteps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAInC,SAAS,CAAC,KAAY,EAAE,OAAiB,EAAE,QAAiC;QAC1E,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;QAErE,OAAO,KAAK,CAAC;IACf,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,QAAiC,EAAE,IAAS;QAC5E,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE;YACpC,wBAAwB;YACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAErD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;oBACjC,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAC,GAAG,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAC,EAAE,OAAO,CAAC,CAAC;iBAC1F;aACF;SACF;QAED,IAAI,EAAE,CAAC;IACT,CAAC;IAES,KAAK,CAAC,gBAAgB,CAAC,UAAqC,EAAE,MAAoB;QAC1F,MAAM,KAAK,GAAG;YACZ,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;SAChF,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AApCC;IADC,MAAM,EAAE;8BACW,cAAc;0DAAC;AAFxB,wBAAwB;IADpC,KAAK,CAAC,qBAAqB,CAAC;GAChB,wBAAwB,CAsCpC;SAtCY,wBAAwB","sourcesContent":["import {Inject} from \"@tsed/di\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"../services/FormioDatabase\";\nimport async from \"async\";\n\n@Alter(\"templateImportSteps\")\nexport class AlterTemplateImportSteps implements AlterHook {\n @Inject()\n protected database: FormioDatabase;\n\n transform(queue: any[], install: Function, template: Partial<FormioTemplate>): any {\n queue.push(async.apply(this.importSubmissions.bind(this), template));\n\n return queue;\n }\n\n protected async importSubmissions(template: Partial<FormioTemplate>, done: any) {\n if (template && template.submissions) {\n // clean all submissions\n await this.database.submissionModel.deleteMany({});\n\n const ctxData = await this.database.getFormioMapper();\n const entries = Object.entries(template.submissions);\n\n for (const entry of entries) {\n for (const submission of entry[1]) {\n await this.importSubmission({...submission, form: submission.form || entry[0]}, ctxData);\n }\n }\n }\n\n done();\n }\n\n protected async importSubmission(submission: Partial<FormioSubmission>, mapper: FormioMapper) {\n const value = {\n ...mapper.mapToImport(submission),\n roles: [...new Set(mapper.mapToImport(submission.roles || []))].filter(Boolean)\n };\n\n await this.database.submissionModel.create(value);\n\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"AlterTemplateImportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateImportSteps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAI1C,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAiB;IAEnC,SAAS,CAAC,KAAY,EAAE,OAAiB,EAAE,QAAiC;QAC1E,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;QAErE,OAAO,KAAK,CAAC;IACf,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,QAAiC,EAAE,IAAS;QAC5E,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE;YACpC,wBAAwB;YACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAErD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;oBACjC,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAC,GAAG,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAC,EAAE,OAAO,CAAC,CAAC;iBAC1F;aACF;SACF;QAED,IAAI,EAAE,CAAC;IACT,CAAC;IAES,KAAK,CAAC,gBAAgB,CAAC,UAAqC,EAAE,MAAoB;QAC1F,MAAM,KAAK,GAAG;YACZ,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;SAChF,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AApCC;IADC,MAAM,EAAE;8BACW,cAAc;0DAAC;AAFxB,wBAAwB;IADpC,KAAK,CAAC,qBAAqB,CAAC;GAChB,wBAAwB,CAsCpC;SAtCY,wBAAwB","sourcesContent":["import {Inject} from \"@tsed/di\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"../services/FormioDatabase\";\nimport async from \"async\";\n\n@Alter(\"templateImportSteps\")\nexport class AlterTemplateImportSteps implements AlterHook {\n @Inject()\n protected database: FormioDatabase;\n\n transform(queue: any[], install: Function, template: Partial<FormioTemplate>): any {\n queue.push(async.apply(this.importSubmissions.bind(this), template));\n\n return queue;\n }\n\n protected async importSubmissions(template: Partial<FormioTemplate>, done: any) {\n if (template && template.submissions) {\n // clean all submissions\n await this.database.submissionModel.deleteMany({});\n\n const ctxData = await this.database.getFormioMapper();\n const entries = Object.entries(template.submissions);\n\n for (const entry of entries) {\n for (const submission of entry[1]) {\n await this.importSubmission({...submission, form: submission.form || entry[0]}, ctxData);\n }\n }\n }\n\n done();\n }\n\n protected async importSubmission(submission: Partial<FormioSubmission>, mapper: FormioMapper) {\n const value = {\n ...mapper.mapToImport(submission),\n roles: [...new Set(mapper.mapToImport(submission.roles || []))].filter(Boolean)\n };\n\n await this.database.submissionModel.create(value);\n\n return value;\n }\n}\n"]}
@@ -9,6 +9,7 @@ import { FormioService } from "../services/FormioService.js";
9
9
  * @formio
10
10
  */
11
11
  let FormioAuthMiddleware = class FormioAuthMiddleware {
12
+ formio;
12
13
  get tokenHandler() {
13
14
  return promisify(this.formio.middleware.tokenHandler);
14
15
  }
@@ -1 +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"]}
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;IAErB,MAAM,CAAgB;IAEhC,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"]}
@@ -7,6 +7,9 @@ import { FormioDatabase } from "./FormioDatabase.js";
7
7
  import { FormioHooksService } from "./FormioHooksService.js";
8
8
  import { FormioService } from "./FormioService.js";
9
9
  let FormioAuthService = class FormioAuthService {
10
+ formio;
11
+ hooks;
12
+ db;
10
13
  get currentUser() {
11
14
  return promisify(this.formio.auth.currentUser);
12
15
  }
@@ -69,7 +72,7 @@ let FormioAuthService = class FormioAuthService {
69
72
  _id: user._id
70
73
  },
71
74
  form: {
72
- _id: form === null || form === void 0 ? void 0 : form._id
75
+ _id: form?._id
73
76
  }
74
77
  }, form, req);
75
78
  const decoded = this.hooks.alter("tokenDecode", token, req);
@@ -1 +1 @@
1
- {"version":3,"file":"FormioAuthService.js","sourceRoot":"","sources":["../../../src/services/FormioAuthService.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAU5B,IAAI,WAAW;QACb,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;IACpC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,cAAc,CAAa,IAAoC,EAAE,KAAyB,EAAE,GAAoB;QAC9G,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,GAAG,CAA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AC,IAAI,CAAC,IAAI,CAAC,EAAE;YACzB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;SACnB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAa,IAAqC;QAChE,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC;YAC7C,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,EAAE;YACT,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;AAnNC;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,CAqN7B;SArNY,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 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"]}
1
+ {"version":3,"file":"FormioAuthService.js","sourceRoot":"","sources":["../../../src/services/FormioAuthService.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAE5B,MAAM,CAAgB;IAGtB,KAAK,CAAqB;IAG1B,EAAE,CAAiB;IAEnB,IAAI,WAAW;QACb,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;IACpC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,cAAc,CAAa,IAAoC,EAAE,KAAyB,EAAE,GAAoB;QAC9G,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,GA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,CAAC,EAAE;YACzB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;SACnB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAa,IAAqC;QAChE,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC;YAC7C,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,EAAE;YACT,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;AAnNC;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,CAqN7B;SArNY,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 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"]}
@@ -9,6 +9,7 @@ function toMap(list) {
9
9
  return tMap(list, (o) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);
10
10
  }
11
11
  let FormioDatabase = class FormioDatabase {
12
+ formio;
12
13
  get models() {
13
14
  return this.formio.mongoose.models;
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAI,CAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5H,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC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AAC;SACxC;IACH,CAAC;CACF,CAAA;AAlJC;IADC,MAAM,EAAE;8BACS,aAAa;8CAAC;AAFrB,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAoJ1B;SApJY,cAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport type {FilterQuery} from \"mongoose\";\nimport omit from \"lodash/omit\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({name: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {name: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n * @param onCreate\n */\n async importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.importForm(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n */\n async importForm(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return this.saveForm(mapper.mapToImport(form));\n }\n\n async saveForm(form: FormioForm) {\n form = omit(form, [\"__v\"]) as any;\n\n return this.formModel.findOneAndUpdate({_id: form._id}, form, {upsert: true, new: true});\n }\n\n async getSubmissions<Data>(\n query: FilterQuery<MongooseModel<FormioSubmission<Data>>> = {}\n ): Promise<MongooseDocument<FormioSubmission<Data>>[]> {\n return this.submissionModel.find({\n ...query,\n deleted: {$eq: null}\n }) as any;\n }\n\n /**\n * Import submission previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param submission\n */\n async importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, \"form\"> & {form?: any}) {\n const mapper = await this.getFormioMapper();\n\n return this.saveSubmission(mapper.mapToImport(submission));\n }\n\n async saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>) {\n submission = omit(submission, [\"__v\"]);\n\n return this.submissionModel.findOneAndUpdate(\n {\n _id: submission._id\n },\n submission,\n {new: true, upsert: true}\n );\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAI,CAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5H,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEf,MAAM,CAAgB;IAEhC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,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ACrB,CAAQ,CAAC;IACZ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAa,UAAwE;QACzG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAE5C,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,cAAc,CAAa,UAA2C;QAC1E,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAC1C;YACE,GAAG,EAAE,UAAU,CAAC,GAAG;SACpB,EACD,UAAU,EACV,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,CAC1B,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,IAAU;QACjB,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO,EAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;SACnD;aAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAlJC;IADC,MAAM,EAAE;8BACS,aAAa;8CAAC;AAFrB,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAoJ1B;SApJY,cAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport type {FilterQuery} from \"mongoose\";\nimport omit from \"lodash/omit\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({name: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {name: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n * @param onCreate\n */\n async importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.importForm(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n /**\n * Import form previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param form\n */\n async importForm(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return this.saveForm(mapper.mapToImport(form));\n }\n\n async saveForm(form: FormioForm) {\n form = omit(form, [\"__v\"]) as any;\n\n return this.formModel.findOneAndUpdate({_id: form._id}, form, {upsert: true, new: true});\n }\n\n async getSubmissions<Data>(\n query: FilterQuery<MongooseModel<FormioSubmission<Data>>> = {}\n ): Promise<MongooseDocument<FormioSubmission<Data>>[]> {\n return this.submissionModel.find({\n ...query,\n deleted: {$eq: null}\n }) as any;\n }\n\n /**\n * Import submission previously exported by export tool.\n * This method transform alias to a real mongoose _id\n * @param submission\n */\n async importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, \"form\"> & {form?: any}) {\n const mapper = await this.getFormioMapper();\n\n return this.saveSubmission(mapper.mapToImport(submission));\n }\n\n async saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>) {\n submission = omit(submission, [\"__v\"]);\n\n return this.submissionModel.findOneAndUpdate(\n {\n _id: submission._id\n },\n submission,\n {new: true, upsert: true}\n );\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
@@ -3,6 +3,8 @@ import { Inject, Injectable, InjectorService } from "@tsed/common";
3
3
  import { promisify } from "util";
4
4
  import { FormioService } from "./FormioService.js";
5
5
  let FormioHooksService = class FormioHooksService {
6
+ injector;
7
+ formio;
6
8
  get settings() {
7
9
  return this.formio.hook.settings;
8
10
  }
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C,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;YAClD,CAAC,CAAC,CACH,CAAC;YAEJ,OAAO;gBACL,GAAG,KAAK;gBACR,CAAC,IAAI,CAAC,EAAG,EAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AAhFC;IADC,MAAM,EAAE;8BACW,eAAe;oDAAC;AAGpC;IADC,MAAM,CAAC,aAAa,CAAC;8BACJ,aAAa;kDAAC;AALrB,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CAkF9B;SAlFY,kBAAkB","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {promisify} from \"util\";\nimport {FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioService} from \"./FormioService\";\nimport {Request} from \"express\";\n\n@Injectable()\nexport class FormioHooksService {\n @Inject()\n protected injector: InjectorService;\n\n @Inject(FormioService)\n protected formio: FormioService;\n\n get settings(): (req: Request, cb: Function) => void {\n return this.formio.hook.settings;\n }\n\n get invoke() {\n return this.formio.hook.invoke;\n }\n\n get alter(): (event: string, ...args: any[]) => any {\n return this.formio.hook.alter;\n }\n\n get alterAsync(): (event: string, ...args: any[]) => Promise<any> {\n return promisify(this.alter);\n }\n\n getHooks(): FormioHooks {\n return {\n alter: this.getHooksProvider(\"alter\"),\n on: this.getHooksProvider(\"on\")\n };\n }\n\n protected getProviders(type: \"alter\" | \"on\") {\n return this.injector.getProviders(`formio:${type}`);\n }\n\n protected getHooksProvider(type: \"alter\" | \"on\") {\n return this.bindHooks(type, this.createHooks(type));\n }\n\n protected bindHooks(type: \"alter\" | \"on\", hooks: Record<string, Function[]>) {\n return Object.entries(hooks).reduce((newHooks, [key, pool]) => {\n const wrap = (input: any, ...args: any[]): any => {\n let last: any;\n\n for (const fn of pool) {\n const result = fn(input, ...args);\n\n if (type === \"alter\") {\n input = result;\n } else {\n last = result;\n }\n }\n\n return type === \"alter\" ? input : last;\n };\n\n return {\n ...newHooks,\n [key]: wrap\n };\n }, {});\n }\n\n private createHooks(type: \"alter\" | \"on\") {\n return this.getProviders(type).reduce<Record<string, Function[]>>((hooks, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const name = provider.store.get(`formio:${type}:name`);\n const pool: Function[] = hooks[name] || [];\n\n const hook = (...args: any[]) =>\n instance[type === \"alter\" ? \"transform\" : \"on\"](\n ...args.map((input: any) => {\n return input && input.$ctx ? input.$ctx : input;\n })\n );\n\n return {\n ...hooks,\n [name]: ([] as Function[]).concat(pool, hook)\n };\n }, {});\n }\n}\n"]}
1
+ {"version":3,"file":"FormioHooksService.js","sourceRoot":"","sources":["../../../src/services/FormioHooksService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAI9C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAEnB,QAAQ,CAAkB;IAG1B,MAAM,CAAgB;IAEhC,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IAChC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YACrC,EAAE,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAA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AC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC;YACvD,MAAM,IAAI,GAAe,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAE3C,MAAM,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAC9B,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAC7C,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;gBACzB,OAAO,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;YAClD,CAAC,CAAC,CACH,CAAC;YAEJ,OAAO;gBACL,GAAG,KAAK;gBACR,CAAC,IAAI,CAAC,EAAG,EAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AAhFC;IADC,MAAM,EAAE;8BACW,eAAe;oDAAC;AAGpC;IADC,MAAM,CAAC,aAAa,CAAC;8BACJ,aAAa;kDAAC;AALrB,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CAkF9B;SAlFY,kBAAkB","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {promisify} from \"util\";\nimport {FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioService} from \"./FormioService\";\nimport {Request} from \"express\";\n\n@Injectable()\nexport class FormioHooksService {\n @Inject()\n protected injector: InjectorService;\n\n @Inject(FormioService)\n protected formio: FormioService;\n\n get settings(): (req: Request, cb: Function) => void {\n return this.formio.hook.settings;\n }\n\n get invoke() {\n return this.formio.hook.invoke;\n }\n\n get alter(): (event: string, ...args: any[]) => any {\n return this.formio.hook.alter;\n }\n\n get alterAsync(): (event: string, ...args: any[]) => Promise<any> {\n return promisify(this.alter);\n }\n\n getHooks(): FormioHooks {\n return {\n alter: this.getHooksProvider(\"alter\"),\n on: this.getHooksProvider(\"on\")\n };\n }\n\n protected getProviders(type: \"alter\" | \"on\") {\n return this.injector.getProviders(`formio:${type}`);\n }\n\n protected getHooksProvider(type: \"alter\" | \"on\") {\n return this.bindHooks(type, this.createHooks(type));\n }\n\n protected bindHooks(type: \"alter\" | \"on\", hooks: Record<string, Function[]>) {\n return Object.entries(hooks).reduce((newHooks, [key, pool]) => {\n const wrap = (input: any, ...args: any[]): any => {\n let last: any;\n\n for (const fn of pool) {\n const result = fn(input, ...args);\n\n if (type === \"alter\") {\n input = result;\n } else {\n last = result;\n }\n }\n\n return type === \"alter\" ? input : last;\n };\n\n return {\n ...newHooks,\n [key]: wrap\n };\n }, {});\n }\n\n private createHooks(type: \"alter\" | \"on\") {\n return this.getProviders(type).reduce<Record<string, Function[]>>((hooks, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const name = provider.store.get(`formio:${type}:name`);\n const pool: Function[] = hooks[name] || [];\n\n const hook = (...args: any[]) =>\n instance[type === \"alter\" ? \"transform\" : \"on\"](\n ...args.map((input: any) => {\n return input && input.$ctx ? input.$ctx : input;\n })\n );\n\n return {\n ...hooks,\n [name]: ([] as Function[]).concat(pool, hook)\n };\n }, {});\n }\n}\n"]}
@@ -2,8 +2,8 @@ import { __decorate, __metadata } from "tslib";
2
2
  import { Inject, Injectable } from "@tsed/di";
3
3
  import { Logger } from "@tsed/logger";
4
4
  import { FormioDatabase } from "./FormioDatabase.js";
5
- import { FormioService } from "./FormioService.js";
6
5
  let FormioInstaller = class FormioInstaller extends FormioDatabase {
6
+ logger;
7
7
  async install(template, root) {
8
8
  this.logger.info("Install formio template...");
9
9
  template = await this.formio.importTemplate(template);
@@ -15,14 +15,13 @@ let FormioInstaller = class FormioInstaller extends FormioDatabase {
15
15
  async createRootUser(user, template) {
16
16
  const hash = await this.formio.encrypt(user.password);
17
17
  return new Promise((resolve, reject) => {
18
- var _a;
19
18
  this.formio.resources.submission.model.create({
20
19
  form: template.resources.admin._id,
21
20
  data: {
22
21
  email: user.email,
23
22
  password: hash
24
23
  },
25
- roles: [(_a = template.roles) === null || _a === void 0 ? void 0 : _a.administrator._id].filter(Boolean)
24
+ roles: [template.roles?.administrator._id].filter(Boolean)
26
25
  }, (err, item) => {
27
26
  if (err) {
28
27
  return reject(err);
@@ -32,10 +31,6 @@ let FormioInstaller = class FormioInstaller extends FormioDatabase {
32
31
  });
33
32
  }
34
33
  };
35
- __decorate([
36
- Inject(),
37
- __metadata("design:type", FormioService)
38
- ], FormioInstaller.prototype, "formio", void 0);
39
34
  __decorate([
40
35
  Inject(),
41
36
  __metadata("design:type", Logger)
@@ -1 +1 @@
1
- {"version":3,"file":"FormioInstaller.js","sourceRoot":"","sources":["../../../src/services/FormioInstaller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,cAAc;IAOjD,KAAK,CAAC,OAAO,CAAC,QAAwB,EAAE,IAAS;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC/C,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SAC3C;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAiB,IAAuC,EAAE,QAAwB;QACpG,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;;YACrC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAC3C;gBACE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;gBAClC,IAAI,EAAE;oBACJ,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,QAAQ,EAAE,IAAI;iBACf;gBACD,KAAK,EAAE,CAAC,MAAA,QAAQ,CAAC,KAAK,0CAAE,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;aAC3D,EACD,CAAC,GAAY,EAAE,IAAS,EAAE,EAAE;gBAC1B,IAAI,GAAG,EAAE;oBACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACpB;gBAED,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAtCC;IADC,MAAM,EAAE;8BACS,aAAa;+CAAC;AAGhC;IADC,MAAM,EAAE;8BACS,MAAM;+CAAC;AALd,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAwC3B;SAxCY,eAAe","sourcesContent":["import {Inject, Injectable} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"./FormioDatabase\";\nimport {FormioService} from \"./FormioService\";\n\n@Injectable()\nexport class FormioInstaller extends FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected logger: Logger;\n\n async install(template: FormioTemplate, root: any) {\n this.logger.info(\"Install formio template...\");\n template = await this.formio.importTemplate(template);\n\n if (root) {\n this.logger.info(\"Create root user...\");\n await this.createRootUser(root, template);\n }\n }\n\n async createRootUser<User = unknown>(user: {email: string; password: string}, template: FormioTemplate): Promise<FormioSubmission<User>> {\n const hash = await this.formio.encrypt(user.password);\n\n return new Promise((resolve, reject) => {\n this.formio.resources.submission.model.create(\n {\n form: template.resources.admin._id,\n data: {\n email: user.email,\n password: hash\n },\n roles: [template.roles?.administrator._id].filter(Boolean)\n },\n (err: unknown, item: any) => {\n if (err) {\n return reject(err);\n }\n\n resolve(item);\n }\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"FormioInstaller.js","sourceRoot":"","sources":["../../../src/services/FormioInstaller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAGhD,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,cAAc;IAEvC,MAAM,CAAS;IAEzB,KAAK,CAAC,OAAO,CAAC,QAAwB,EAAE,IAAS;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC/C,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SAC3C;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAiB,IAAuC,EAAE,QAAwB;QACpG,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAC3C;gBACE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;gBAClC,IAAI,EAAE;oBACJ,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,QAAQ,EAAE,IAAI;iBACf;gBACD,KAAK,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;aAC3D,EACD,CAAC,GAAY,EAAE,IAAS,EAAE,EAAE;gBAC1B,IAAI,GAAG,EAAE;oBACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACpB;gBAED,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnCC;IADC,MAAM,EAAE;8BACS,MAAM;+CAAC;AAFd,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAqC3B;SArCY,eAAe","sourcesContent":["import {Inject, Injectable} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"./FormioDatabase\";\n\n@Injectable()\nexport class FormioInstaller extends FormioDatabase {\n @Inject()\n protected logger: Logger;\n\n async install(template: FormioTemplate, root: any) {\n this.logger.info(\"Install formio template...\");\n template = await this.formio.importTemplate(template);\n\n if (root) {\n this.logger.info(\"Create root user...\");\n await this.createRootUser(root, template);\n }\n }\n\n async createRootUser<User = unknown>(user: {email: string; password: string}, template: FormioTemplate): Promise<FormioSubmission<User>> {\n const hash = await this.formio.encrypt(user.password);\n\n return new Promise((resolve, reject) => {\n this.formio.resources.submission.model.create(\n {\n form: template.resources.admin._id,\n data: {\n email: user.email,\n password: hash\n },\n roles: [template.roles?.administrator._id].filter(Boolean)\n },\n (err: unknown, item: any) => {\n if (err) {\n return reject(err);\n }\n\n resolve(item);\n }\n );\n });\n }\n}\n"]}
@@ -2,6 +2,8 @@ import { __decorate, __metadata } from "tslib";
2
2
  import { Inject } from "@tsed/di";
3
3
  import { FormioDatabase } from "./FormioDatabase.js";
4
4
  export class FormioRepository {
5
+ formioDatabase;
6
+ formId;
5
7
  async getFormId() {
6
8
  if (!this.formId) {
7
9
  const form = await this.formioDatabase.formModel.findOne({ name: { $eq: this.formName } });
@@ -1 +1 @@
1
- {"version":3,"file":"FormioRepository.js","sourceRoot":"","sources":["../../../src/services/FormioRepository.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,MAAM,OAAgB,gBAAgB;IAQpC,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;YAEvF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;aACxB;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkF;QACrG,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAAsE,EAAE;QAC3F,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,KAAK;YACR,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAU;QAChC,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC;YACjD,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO,EAAE,IAAI;YACb,GAAG,KAAK;SACT,CAAQ,CAAC;IACZ,CAAC;CACF;AAvCC;IADC,MAAM,EAAE;8BACiB,cAAc;wDAAC","sourcesContent":["import type {FilterQuery} from \"mongoose\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioDatabase} from \"./FormioDatabase\";\n\nexport abstract class FormioRepository<SubmissionData = any> {\n @Inject()\n protected formioDatabase: FormioDatabase;\n\n protected abstract formName: string;\n\n private formId: string;\n\n async getFormId() {\n if (!this.formId) {\n const form = await this.formioDatabase.formModel.findOne({name: {$eq: this.formName}});\n\n if (form) {\n this.formId = form._id;\n }\n }\n\n return this.formId;\n }\n\n async saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, \"form\"> & {form?: any}) {\n return this.formioDatabase.saveSubmission<SubmissionData>({\n ...submission,\n form: submission.form || (await this.getFormId())\n });\n }\n\n async getSubmissions(query: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>> = {}) {\n return this.formioDatabase.getSubmissions<SubmissionData>({\n ...query,\n form: await this.getFormId()\n });\n }\n\n async findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined> {\n return this.formioDatabase.submissionModel.findOne({\n form: await this.getFormId(),\n deleted: null,\n ...query\n }) as any;\n }\n}\n"]}
1
+ {"version":3,"file":"FormioRepository.js","sourceRoot":"","sources":["../../../src/services/FormioRepository.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAC,MAAM,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ocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioDatabase} from \"./FormioDatabase\";\n\nexport abstract class FormioRepository<SubmissionData = any> {\n @Inject()\n protected formioDatabase: FormioDatabase;\n\n protected abstract formName: string;\n\n private formId: string;\n\n async getFormId() {\n if (!this.formId) {\n const form = await this.formioDatabase.formModel.findOne({name: {$eq: this.formName}});\n\n if (form) {\n this.formId = form._id;\n }\n }\n\n return this.formId;\n }\n\n async saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, \"form\"> & {form?: any}) {\n return this.formioDatabase.saveSubmission<SubmissionData>({\n ...submission,\n form: submission.form || (await this.getFormId())\n });\n }\n\n async getSubmissions(query: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>> = {}) {\n return this.formioDatabase.getSubmissions<SubmissionData>({\n ...query,\n form: await this.getFormId()\n });\n }\n\n async findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined> {\n return this.formioDatabase.submissionModel.findOne({\n form: await this.getFormId(),\n deleted: null,\n ...query\n }) as any;\n }\n}\n"]}
@@ -8,6 +8,8 @@ import swagger from "formio/src/util/swagger.js";
8
8
  // @ts-ignore
9
9
  import util from "formio/src/util/util.js";
10
10
  let FormioService = class FormioService {
11
+ router;
12
+ injector;
11
13
  get audit() {
12
14
  return this.formio.audit || (() => { });
13
15
  }