@tsed/formio 6.87.1 → 6.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{FormioModule.d.ts → cjs/FormioModule.d.ts} +0 -0
- package/lib/{FormioModule.js → cjs/FormioModule.js} +34 -34
- package/lib/cjs/FormioModule.js.map +1 -0
- package/lib/{builder → cjs/builder}/FormioMapper.d.ts +0 -0
- package/lib/{builder → cjs/builder}/FormioMapper.js +0 -0
- package/lib/cjs/builder/FormioMapper.js.map +1 -0
- package/lib/{components → cjs/components}/AlterActions.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterActions.js +8 -8
- package/lib/cjs/components/AlterActions.js.map +1 -0
- package/lib/{components → cjs/components}/AlterAudit.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterAudit.js +2 -2
- package/lib/cjs/components/AlterAudit.js.map +1 -0
- package/lib/{components → cjs/components}/AlterHost.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterHost.js +2 -2
- package/lib/cjs/components/AlterHost.js.map +1 -0
- package/lib/{components → cjs/components}/AlterLog.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterLog.js +2 -2
- package/lib/cjs/components/AlterLog.js.map +1 -0
- package/lib/{components → cjs/components}/AlterSkip.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterSkip.js +9 -9
- package/lib/cjs/components/AlterSkip.js.map +1 -0
- package/lib/{components → cjs/components}/AlterTemplateExportSteps.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterTemplateExportSteps.js +6 -6
- package/lib/cjs/components/AlterTemplateExportSteps.js.map +1 -0
- package/lib/{components → cjs/components}/AlterTemplateImportSteps.d.ts +0 -0
- package/lib/{components → cjs/components}/AlterTemplateImportSteps.js +5 -5
- package/lib/cjs/components/AlterTemplateImportSteps.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/action.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/action.js +3 -3
- package/lib/cjs/decorators/action.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/actionCtx.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/actionCtx.js +1 -1
- package/lib/cjs/decorators/actionCtx.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/alter.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/alter.js +3 -3
- package/lib/cjs/decorators/alter.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/on.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/on.js +3 -3
- package/lib/cjs/decorators/on.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useFormioAuth.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/useFormioAuth.js +1 -1
- package/lib/cjs/decorators/useFormioAuth.js.map +1 -0
- package/lib/{domain → cjs/domain}/AlterHook.d.ts +0 -0
- package/lib/{domain → cjs/domain}/AlterHook.js +0 -0
- package/lib/cjs/domain/AlterHook.js.map +1 -0
- package/lib/{domain → cjs/domain}/Formio.d.ts +0 -0
- package/lib/{domain → cjs/domain}/Formio.js +0 -0
- package/lib/cjs/domain/Formio.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioAction.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioAction.js +0 -0
- package/lib/cjs/domain/FormioAction.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioActionsIndex.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioActionsIndex.js +0 -0
- package/lib/cjs/domain/FormioActionsIndex.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioAuth.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioAuth.js +0 -0
- package/lib/cjs/domain/FormioAuth.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioBaseModel.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioBaseModel.js +0 -0
- package/lib/cjs/domain/FormioBaseModel.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioConfig.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioConfig.js +0 -0
- package/lib/cjs/domain/FormioConfig.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioCtxMapper.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioCtxMapper.js +0 -0
- package/lib/cjs/domain/FormioCtxMapper.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioDecodedToken.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioDecodedToken.js +0 -0
- package/lib/cjs/domain/FormioDecodedToken.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioErrors.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioErrors.js +0 -0
- package/lib/cjs/domain/FormioErrors.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioHooks.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioHooks.js +0 -0
- package/lib/cjs/domain/FormioHooks.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioJs.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioJs.js +0 -0
- package/lib/cjs/domain/FormioJs.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioModels.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioModels.js +1 -1
- package/lib/cjs/domain/FormioModels.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioRouter.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioRouter.js +0 -0
- package/lib/cjs/domain/FormioRouter.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioSettings.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioSettings.js +0 -0
- package/lib/cjs/domain/FormioSettings.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioTemplate.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioTemplate.js +0 -0
- package/lib/cjs/domain/FormioTemplate.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioTemplateUtil.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioTemplateUtil.js +0 -0
- package/lib/cjs/domain/FormioTemplateUtil.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioUpdate.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioUpdate.js +0 -0
- package/lib/cjs/domain/FormioUpdate.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioUtils.d.ts +0 -0
- package/lib/{domain → cjs/domain}/FormioUtils.js +0 -0
- package/lib/cjs/domain/FormioUtils.js.map +1 -0
- package/lib/{domain → cjs/domain}/OnHook.d.ts +0 -0
- package/lib/{domain → cjs/domain}/OnHook.js +0 -0
- package/lib/cjs/domain/OnHook.js.map +1 -0
- package/lib/{domain → cjs/domain}/Resource.d.ts +0 -0
- package/lib/{domain → cjs/domain}/Resource.js +0 -0
- package/lib/cjs/domain/Resource.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +46 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/FormioAuthMiddleware.d.ts +0 -0
- package/lib/{middlewares → cjs/middlewares}/FormioAuthMiddleware.js +12 -12
- package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +1 -0
- package/lib/{services → cjs/services}/FormioAuthService.d.ts +1 -1
- package/lib/{services → cjs/services}/FormioAuthService.js +13 -13
- package/lib/cjs/services/FormioAuthService.js.map +1 -0
- package/lib/{services → cjs/services}/FormioDatabase.d.ts +0 -0
- package/lib/{services → cjs/services}/FormioDatabase.js +10 -10
- package/lib/cjs/services/FormioDatabase.js.map +1 -0
- package/lib/{services → cjs/services}/FormioHooksService.d.ts +0 -0
- package/lib/{services → cjs/services}/FormioHooksService.js +9 -9
- package/lib/cjs/services/FormioHooksService.js.map +1 -0
- package/lib/{services → cjs/services}/FormioInstaller.d.ts +0 -0
- package/lib/{services → cjs/services}/FormioInstaller.js +8 -8
- package/lib/cjs/services/FormioInstaller.js.map +1 -0
- package/lib/{services → cjs/services}/FormioService.d.ts +0 -0
- package/lib/{services → cjs/services}/FormioService.js +8 -8
- package/lib/cjs/services/FormioService.js.map +1 -0
- package/lib/{utils → cjs/utils}/isMongoId.d.ts +0 -0
- package/lib/{utils → cjs/utils}/isMongoId.js +0 -0
- package/lib/cjs/utils/isMongoId.js.map +1 -0
- package/lib/esm/FormioModule.js +147 -0
- package/lib/{FormioModule.js.map → esm/FormioModule.js.map} +1 -1
- package/lib/esm/builder/FormioMapper.js +49 -0
- package/lib/esm/builder/FormioMapper.js.map +1 -0
- package/lib/esm/components/AlterActions.js +63 -0
- package/lib/esm/components/AlterActions.js.map +1 -0
- package/lib/esm/components/AlterAudit.js +13 -0
- package/lib/esm/components/AlterAudit.js.map +1 -0
- package/lib/esm/components/AlterHost.js +12 -0
- package/lib/esm/components/AlterHost.js.map +1 -0
- package/lib/esm/components/AlterLog.js +13 -0
- package/lib/esm/components/AlterLog.js.map +1 -0
- package/lib/esm/components/AlterSkip.js +29 -0
- package/lib/esm/components/AlterSkip.js.map +1 -0
- package/lib/esm/components/AlterTemplateExportSteps.js +49 -0
- package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -0
- package/lib/esm/components/AlterTemplateImportSteps.js +42 -0
- package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -0
- package/lib/esm/decorators/action.js +16 -0
- package/lib/esm/decorators/action.js.map +1 -0
- package/lib/esm/decorators/actionCtx.js +19 -0
- package/lib/esm/decorators/actionCtx.js.map +1 -0
- package/lib/esm/decorators/alter.js +16 -0
- package/lib/esm/decorators/alter.js.map +1 -0
- package/lib/esm/decorators/on.js +16 -0
- package/lib/esm/decorators/on.js.map +1 -0
- package/lib/esm/decorators/useFormioAuth.js +11 -0
- package/lib/esm/decorators/useFormioAuth.js.map +1 -0
- package/lib/esm/domain/AlterHook.js +2 -0
- package/lib/esm/domain/AlterHook.js.map +1 -0
- package/lib/esm/domain/Formio.js +2 -0
- package/lib/esm/domain/Formio.js.map +1 -0
- package/lib/esm/domain/FormioAction.js +2 -0
- package/lib/esm/domain/FormioAction.js.map +1 -0
- package/lib/esm/domain/FormioActionsIndex.js +2 -0
- package/lib/esm/domain/FormioActionsIndex.js.map +1 -0
- package/lib/esm/domain/FormioAuth.js +2 -0
- package/lib/esm/domain/FormioAuth.js.map +1 -0
- package/lib/esm/domain/FormioBaseModel.js +2 -0
- package/lib/esm/domain/FormioBaseModel.js.map +1 -0
- package/lib/esm/domain/FormioConfig.js +2 -0
- package/lib/esm/domain/FormioConfig.js.map +1 -0
- package/lib/esm/domain/FormioCtxMapper.js +2 -0
- package/lib/esm/domain/FormioCtxMapper.js.map +1 -0
- package/lib/esm/domain/FormioDecodedToken.js +2 -0
- package/lib/esm/domain/FormioDecodedToken.js.map +1 -0
- package/lib/esm/domain/FormioErrors.js +2 -0
- package/lib/esm/domain/FormioErrors.js.map +1 -0
- package/lib/esm/domain/FormioHooks.js +2 -0
- package/lib/esm/domain/FormioHooks.js.map +1 -0
- package/lib/esm/domain/FormioJs.js +2 -0
- package/lib/esm/domain/FormioJs.js.map +1 -0
- package/lib/esm/domain/FormioModels.js +2 -0
- package/lib/esm/domain/FormioModels.js.map +1 -0
- package/lib/esm/domain/FormioRouter.js +2 -0
- package/lib/esm/domain/FormioRouter.js.map +1 -0
- package/lib/esm/domain/FormioSettings.js +2 -0
- package/lib/esm/domain/FormioSettings.js.map +1 -0
- package/lib/esm/domain/FormioTemplate.js +2 -0
- package/lib/esm/domain/FormioTemplate.js.map +1 -0
- package/lib/esm/domain/FormioTemplateUtil.js +2 -0
- package/lib/esm/domain/FormioTemplateUtil.js.map +1 -0
- package/lib/esm/domain/FormioUpdate.js +2 -0
- package/lib/esm/domain/FormioUpdate.js.map +1 -0
- package/lib/esm/domain/FormioUtils.js +2 -0
- package/lib/esm/domain/FormioUtils.js.map +1 -0
- package/lib/esm/domain/OnHook.js +2 -0
- package/lib/esm/domain/OnHook.js.map +1 -0
- package/lib/esm/domain/Resource.js +2 -0
- package/lib/esm/domain/Resource.js.map +1 -0
- package/lib/esm/index.js +43 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/middlewares/FormioAuthMiddleware.js +38 -0
- package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -0
- package/lib/esm/services/FormioAuthService.js +179 -0
- package/lib/esm/services/FormioAuthService.js.map +1 -0
- package/lib/esm/services/FormioDatabase.js +100 -0
- package/lib/{services → esm/services}/FormioDatabase.js.map +1 -1
- package/lib/esm/services/FormioHooksService.js +78 -0
- package/lib/esm/services/FormioHooksService.js.map +1 -0
- package/lib/esm/services/FormioInstaller.js +47 -0
- package/lib/esm/services/FormioInstaller.js.map +1 -0
- package/lib/esm/services/FormioService.js +97 -0
- package/lib/esm/services/FormioService.js.map +1 -0
- package/lib/esm/utils/isMongoId.js +4 -0
- package/lib/esm/utils/isMongoId.js.map +1 -0
- package/lib/types/FormioModule.d.ts +24 -0
- package/lib/types/builder/FormioMapper.d.ts +11 -0
- package/lib/types/components/AlterActions.d.ts +15 -0
- package/lib/types/components/AlterAudit.d.ts +5 -0
- package/lib/types/components/AlterHost.d.ts +5 -0
- package/lib/types/components/AlterLog.d.ts +5 -0
- package/lib/types/components/AlterSkip.d.ts +7 -0
- package/lib/types/components/AlterTemplateExportSteps.d.ts +12 -0
- package/lib/types/components/AlterTemplateImportSteps.d.ts +11 -0
- package/lib/types/decorators/action.d.ts +7 -0
- package/lib/types/decorators/actionCtx.d.ts +23 -0
- package/lib/types/decorators/alter.d.ts +6 -0
- package/lib/types/decorators/on.d.ts +6 -0
- package/lib/types/decorators/useFormioAuth.d.ts +6 -0
- package/lib/types/domain/AlterHook.d.ts +3 -0
- package/lib/types/domain/Formio.d.ts +112 -0
- package/lib/types/domain/FormioAction.d.ts +20 -0
- package/lib/types/domain/FormioActionsIndex.d.ts +15 -0
- package/lib/types/domain/FormioAuth.d.ts +67 -0
- package/lib/types/domain/FormioBaseModel.d.ts +11 -0
- package/lib/types/domain/FormioConfig.d.ts +59 -0
- package/lib/types/domain/FormioCtxMapper.d.ts +7 -0
- package/lib/types/domain/FormioDecodedToken.d.ts +12 -0
- package/lib/types/domain/FormioErrors.d.ts +53 -0
- package/lib/types/domain/FormioHooks.d.ts +194 -0
- package/lib/types/domain/FormioJs.d.ts +17 -0
- package/lib/types/domain/FormioModels.d.ts +42 -0
- package/lib/types/domain/FormioRouter.d.ts +7 -0
- package/lib/types/domain/FormioSettings.d.ts +53 -0
- package/lib/types/domain/FormioTemplate.d.ts +8 -0
- package/lib/types/domain/FormioTemplateUtil.d.ts +13 -0
- package/lib/types/domain/FormioUpdate.d.ts +19 -0
- package/lib/types/domain/FormioUtils.d.ts +307 -0
- package/lib/types/domain/OnHook.d.ts +3 -0
- package/lib/types/domain/Resource.d.ts +18 -0
- package/lib/types/index.d.ts +38 -0
- package/lib/types/middlewares/FormioAuthMiddleware.d.ts +11 -0
- package/lib/types/services/FormioAuthService.d.ts +54 -0
- package/lib/types/services/FormioDatabase.d.ts +24 -0
- package/lib/types/services/FormioHooksService.d.ts +17 -0
- package/lib/types/services/FormioInstaller.d.ts +14 -0
- package/lib/types/services/FormioService.d.ts +36 -0
- package/lib/types/utils/isMongoId.d.ts +1 -0
- package/package.json +22 -14
- package/tsconfig.compile.esm.json +23 -0
- package/lib/builder/FormioMapper.js.map +0 -1
- package/lib/components/AlterActions.js.map +0 -1
- package/lib/components/AlterAudit.js.map +0 -1
- package/lib/components/AlterHost.js.map +0 -1
- package/lib/components/AlterLog.js.map +0 -1
- package/lib/components/AlterSkip.js.map +0 -1
- package/lib/components/AlterTemplateExportSteps.js.map +0 -1
- package/lib/components/AlterTemplateImportSteps.js.map +0 -1
- package/lib/decorators/action.js.map +0 -1
- package/lib/decorators/actionCtx.js.map +0 -1
- package/lib/decorators/alter.js.map +0 -1
- package/lib/decorators/on.js.map +0 -1
- package/lib/decorators/useFormioAuth.js.map +0 -1
- package/lib/domain/AlterHook.js.map +0 -1
- package/lib/domain/Formio.js.map +0 -1
- package/lib/domain/FormioAction.js.map +0 -1
- package/lib/domain/FormioActionsIndex.js.map +0 -1
- package/lib/domain/FormioAuth.js.map +0 -1
- package/lib/domain/FormioBaseModel.js.map +0 -1
- package/lib/domain/FormioConfig.js.map +0 -1
- package/lib/domain/FormioCtxMapper.js.map +0 -1
- package/lib/domain/FormioDecodedToken.js.map +0 -1
- package/lib/domain/FormioErrors.js.map +0 -1
- package/lib/domain/FormioHooks.js.map +0 -1
- package/lib/domain/FormioJs.js.map +0 -1
- package/lib/domain/FormioModels.js.map +0 -1
- package/lib/domain/FormioRouter.js.map +0 -1
- package/lib/domain/FormioSettings.js.map +0 -1
- package/lib/domain/FormioTemplate.js.map +0 -1
- package/lib/domain/FormioTemplateUtil.js.map +0 -1
- package/lib/domain/FormioUpdate.js.map +0 -1
- package/lib/domain/FormioUtils.js.map +0 -1
- package/lib/domain/OnHook.js.map +0 -1
- package/lib/domain/Resource.js.map +0 -1
- package/lib/index.js +0 -46
- package/lib/index.js.map +0 -1
- package/lib/middlewares/FormioAuthMiddleware.js.map +0 -1
- package/lib/services/FormioAuthService.js.map +0 -1
- package/lib/services/FormioHooksService.js.map +0 -1
- package/lib/services/FormioInstaller.js.map +0 -1
- package/lib/services/FormioService.js.map +0 -1
- package/lib/utils/isMongoId.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioHooks.js","sourceRoot":"","sources":["../../../src/domain/FormioHooks.ts"],"names":[],"mappings":"","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Request} from \"express\";\nimport {FilterQuery, Schema, SchemaDefinition} from \"mongoose\";\nimport {Formio} from \"./Formio\";\nimport {FormioActions} from \"./FormioActionsIndex\";\nimport {FormioConfig} from \"./FormioConfig\";\nimport {FormioDecodedToken} from \"./FormioDecodedToken\";\nimport {FormioJs} from \"./FormioJs\";\nimport {FormioActionItem, FormioForm, FormioModelsModels, FormioSubmission} from \"./FormioModels\";\nimport {FormioSettings} from \"./FormioSettings\";\nimport {ResourceRestOptions} from \"./Resource\";\n\nexport type FormioInitEvent = \"alias\" | \"params\" | \"token\" | \"getTempToken\" | \"logout\" | \"current\" | \"access\" | \"perms\";\n\nexport interface FormioHooks {\n settings?: (settings: FormioSettings, req: Request, cb: Function) => FormioSettings;\n alter?: {\n alias?: (alias: string, req: Request, res: Response) => string;\n /**\n * Alter FormioJs configuration\n * @param formIo\n */\n configFormio?: (formIo: {Formio: FormioJs}) => void;\n /**\n * Alter formio server configuration.\n * @param config\n */\n updateConfig?: (config: FormioConfig) => FormioConfig;\n /**\n * Alter audit log.\n * @param info\n * @param event\n * @param req\n */\n audit?: (info: any[], event: string, req: Request) => void;\n /**\n * Alter log.\n * @param info\n * @param event\n * @param req\n */\n log?: (event: string, req: Request, ...info: string[]) => void;\n /**\n * Alter available actions\n * @param info\n * @param event\n * @param req\n */\n actions?: (actions: FormioActions) => FormioActions;\n /**\n * Skip auth for the current request.\n * @param info\n * @param event\n * @param req\n */\n skip?: (value: boolean, req: Request) => boolean;\n /**\n * Resolve host.\n * @param baseUrl\n * @param req\n */\n host?: (baseUrl: string, req: Request) => string;\n /**\n * `/form/${req.params.formId}/action`\n * @param action\n * @param req\n */\n path?: (path: string, req: Request) => any;\n /**\n * Restrict request types\n * @param methods\n */\n methods?: (methods: string[]) => string[];\n /**\n * Return the cors configuration.\n */\n cors?: () => Record<string, any>;\n /**\n * Return the current user submission.\n */\n currentUser?: (user: any) => any;\n /**\n * Alter current form.\n * @param form\n */\n currentForm?: (form: FormioForm) => FormioForm;\n /**\n * Alter formio\n * @param formio\n */\n formio?: (formio: Formio) => Formio;\n /**\n * Alter models\n * @param models\n */\n models?: (models: FormioModelsModels) => FormioModelsModels;\n /**\n * Alter resources\n * @param resources\n */\n resources?: (resources: {form: any; submission: any; role: any}) => any;\n\n resourceAccessFilter?: (search: any, req: Request, done: (err: unknown, newSearch: any) => void) => void;\n\n // machineName\n actionMachineName?: (name: string, document: MongooseDocument<any>, done: Function) => void;\n formMachineName?: (name: string, document: MongooseDocument<any>, done: Function) => void;\n roleMachineName?: (name: string, document: MongooseDocument<any>, done: Function) => void;\n\n // schemas\n actionSchema?: (schema: Schema) => Schema;\n actionItemSchema?: (schema: Schema) => Schema;\n formSchema?: (schema: Schema) => Schema;\n roleSchema?: (schema: Schema) => Schema;\n schemaSchema?: (schema: Schema) => Schema;\n submissionSchema?: (schema: Schema | SchemaDefinition) => Schema;\n tokenSchema?: (schema: Schema) => Schema;\n permissionSchema?: (schema: SchemaDefinition) => SchemaDefinition;\n fieldMatchAccessPermissionSchema?: (schemaOptions: SchemaDefinition) => SchemaDefinition;\n\n // query\n actionsQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n submissionQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n roleQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n formQuery?: <DocType = any>(query: FilterQuery<DocType>, req: Request) => FilterQuery<DocType>;\n\n // Data\n actionItem?: (actionItem: FormioActionItem, req: Request) => FormioActionItem;\n actionContext?: (actionContext: any, req: Request) => any;\n actionInfo?: (action: any, req: Request) => any;\n\n // submission\n submission?: (req: Request, res: Response, done: Function) => void;\n submissionRequest?: (submission: FormioSubmission) => FormioSubmission;\n validateSubmissionForm?: (form: FormioForm, submission: FormioSubmission, done: Function) => void;\n postSubmissionUpdate?: (req: Request, res: Response, submissionUpdate: FormioSubmission) => void;\n\n // response\n /**\n * Allow modules to hook into the form loader middleware.\n * @param item\n * @param req\n * @param done\n */\n formResponse?: (item: any, req: Request, done: Function) => void;\n\n // params\n requestParams?: (req: Request & {formId: string; subId: string; roleId: string}, params: Record<string, any>) => void;\n /**\n * Alter submitted params\n * @param params\n */\n submissionParams?: (params: string[]) => string[];\n\n // Routes\n /**\n * Alter actions routes.\n */\n actionRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n /**\n * Alter roles routes.\n */\n rolesRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n /**\n * Alter forms routes.\n */\n formRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n /**\n * Alter submission routes.\n */\n submissionRoutes?: (options: ResourceRestOptions) => ResourceRestOptions;\n\n // Auth\n user?: (user: any, done: (err: any, user: any) => void) => void;\n login?: (user: any, req: Request, done: (err: any) => void) => void;\n token?: (token: FormioDecodedToken, form: FormioForm, req: Request) => FormioDecodedToken;\n tokenDecode?: (token: FormioDecodedToken, req: Request, done: (err: any, decoded: FormioDecodedToken) => void) => void;\n submissionRequestTokenQuery?: (query: {formId: string; submissionId: string}, token: string) => any;\n\n [key: string]: any;\n };\n on?: {\n init?: (type: FormioInitEvent) => boolean;\n [key: string]: any;\n };\n}\n\nexport interface FormioHook {\n /**\n * Run settings function.\n */\n settings(req: Request, cb: Function): void;\n\n /**\n * Emit an event.\n * @param args\n */\n invoke<T = any>(...args: any[]): T | boolean;\n\n /**\n * Alter the given value by calling all listener.\n * @param event\n * @param args\n */\n alter(event: string, ...args: any[]): any;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioJs.js","sourceRoot":"","sources":["../../../src/domain/FormioJs.ts"],"names":[],"mappings":"","sourcesContent":["export interface FormioJs {\n forms: Record<string, any>;\n cache: Record<string, any>;\n Components: {\n components: {\n component: {\n Validator: {\n db: any | null;\n token: any | null;\n form: any | null;\n submission: any | null;\n };\n };\n };\n };\n\n getToken(): string;\n}\n"]}
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("@tsed/formio-types"), exports);
|
|
4
|
+
(0, tslib_1.__exportStar)(require("@tsed/formio-types"), exports);
|
|
5
5
|
//# sourceMappingURL=FormioModels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioModels.js","sourceRoot":"","sources":["../../../src/domain/FormioModels.ts"],"names":[],"mappings":";;;AAMA,kEAAmC","sourcesContent":["import {MongooseDocument} from \"@tsed/mongoose\";\nimport {Schema} from \"mongoose\";\nimport {FormioActionModelCtor, FormioActionMongooseSchema} from \"./FormioAction\";\nimport {FormioBaseModel, FormioModel, FormioMongooseSchema} from \"./FormioBaseModel\";\nimport {FormioActionItem, FormioForm, FormioRole, FormioSchema, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\n\nexport * from \"@tsed/formio-types\";\n\nexport type WithID<T> = T & {_id: string};\n\nexport interface FormioSchemas {\n action: FormioActionMongooseSchema;\n actionItem: Schema<MongooseDocument<FormioActionItem>>;\n form: FormioMongooseSchema<FormioForm>;\n role: FormioMongooseSchema<FormioRole>;\n schema: Schema<MongooseDocument<FormioSchema>>;\n submission: Schema<MongooseDocument<FormioSubmission>>;\n token: Schema<MongooseDocument<FormioToken>>;\n\n [key: string]: Schema<MongooseDocument<any>>;\n}\n\nexport type FormioModelsModels = {\n action: FormioActionModelCtor;\n actionItem: FormioBaseModel<FormioActionItem>;\n form: FormioModel<FormioForm>;\n role: FormioModel<FormioRole>;\n schema: FormioBaseModel<FormioSchema>;\n submission: FormioBaseModel<FormioSubmission>;\n token: FormioBaseModel<FormioToken>;\n} & Record<string, FormioBaseModel>;\n\nexport interface FormioModels {\n schemas: FormioSchemas;\n models: FormioModelsModels;\n specs: {\n action: any;\n actionItem: any;\n form: any;\n role: any;\n schema: any;\n submission: any;\n token: any;\n\n [key: string]: any;\n };\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioRouter.js","sourceRoot":"","sources":["../../../src/domain/FormioRouter.ts"],"names":[],"mappings":"","sourcesContent":["import {Router} from \"express\";\nimport {Formio, FormioBase} from \"./Formio\";\nimport {FormioHooks} from \"./FormioHooks\";\n\nexport interface FormioRouter extends Router {\n formio: FormioBase;\n\n init(hooks: FormioHooks): Promise<Formio>;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioSettings.js","sourceRoot":"","sources":["../../../src/domain/FormioSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface FormioSettings extends Record<string, any> {\n office365: {\n tenant: string;\n clientId: string;\n email: string;\n cert: string;\n thumbprint: string;\n\n [key: string]: any;\n };\n\n databases: {\n mysql: {\n host: string;\n port: string;\n database: string;\n user: string;\n password: string;\n\n [key: string]: any;\n };\n mssql: {\n host: string;\n port: string;\n database: string;\n user: string;\n password: string;\n\n [key: string]: any;\n };\n };\n email: {\n gmail: {\n auth: {\n user: string;\n pass: string;\n [key: string]: any;\n };\n\n [key: string]: any;\n };\n sendgrid: {\n auth: {\n api_user: string;\n api_key: string;\n\n [key: string]: any;\n };\n\n [key: string]: any;\n };\n mandrill: {\n auth: {\n apiKey: string;\n\n [key: string]: any;\n };\n [key: string]: any;\n };\n };\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioTemplate.js","sourceRoot":"","sources":["../../../src/domain/FormioTemplate.ts"],"names":[],"mappings":"","sourcesContent":["import {FormioActionItem, FormioForm, FormioRole, FormioSubmission} from \"./FormioModels\";\n\nexport interface FormioTemplate {\n roles?: Record<string, FormioRole>;\n forms: Record<string, FormioForm>;\n resources: Record<string, FormioForm>;\n actions: Record<string, FormioActionItem>;\n submissions?: Record<string, FormioSubmission[]>;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioTemplateUtil.js","sourceRoot":"","sources":["../../../src/domain/FormioTemplateUtil.ts"],"names":[],"mappings":"","sourcesContent":["import {FormioTemplate} from \"./FormioTemplate\";\n\nexport interface FormioExportOptions {\n title: string;\n version: string;\n description: string;\n name: string;\n}\n\nexport interface FormioTemplateUtil {\n import: {\n template(template: FormioTemplate, cb: (er: unknown, data: FormioTemplate) => void): void;\n };\n export(options: Partial<FormioExportOptions>, cb: (er: unknown, data: FormioTemplate) => void): void;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioUpdate.js","sourceRoot":"","sources":["../../../src/domain/FormioUpdate.ts"],"names":[],"mappings":"","sourcesContent":["import {NextFunction, Request, Response} from \"express\";\nimport {Db} from \"mongodb\";\nimport {Formio} from \"./Formio\";\n\nexport interface FormioUpdate {\n db: Db;\n version: string;\n\n /**\n *\n * @param cb\n */\n initialize(cb: (err: unknown, db: any) => void): Promise<Formio>;\n\n /**\n *\n * @param req\n * @param res\n * @param next\n */\n sanityCheck(req: Request, res: Response, next: NextFunction): void;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioUtils.js","sourceRoot":"","sources":["../../../src/domain/FormioUtils.ts"],"names":[],"mappings":"","sourcesContent":["import {Request, Response} from \"express\";\nimport {FormioErrors} from \"./FormioErrors\";\nimport {FormioJs} from \"./FormioJs\";\n\nexport interface FormioUtil {\n Formio: FormioJs;\n /**\n * Iterate through each component within a form.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Function} fn\n * The iteration function to invoke for each component.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n * @param {String} path\n */\n eachComponent: Function;\n /**\n * Get a component by its key\n *\n * @param {Object} components\n * The components to iterate.\n * @param {String} key\n * The key of the component to get.\n *\n * @returns {Object}\n * The component that matches the given key, or undefined if not found.\n */\n getComponent: Function;\n /**\n * Define if component should be considered input component\n *\n * @param {Object} componentJson\n * JSON of component to check\n *\n * @returns {Boolean}\n * If component is input or not\n */\n isInputComponent: Function;\n /**\n * Flatten the form components for data manipulation.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n *\n * @returns {Object}\n * The flattened components map.\n */\n flattenComponents: Function;\n /**\n * Get the value for a component key, in the given submission.\n *\n * @param {Object} submission\n * A submission object to search.\n * @param {String} key\n * A for components API key to search for.\n */\n getValue: Function;\n /**\n * Determine if a component is a layout component or not.\n *\n * @param {Object} component\n * The component to check.\n *\n * @returns {Boolean}\n * Whether or not the component is a layout component.\n */\n isLayoutComponent: Function;\n /**\n * Apply JSON logic functionality.\n *\n * @param component\n * @param row\n * @param data\n */\n jsonLogic: Function;\n /**\n * Check if the condition for a component is true or not.\n *\n * @param component\n * @param row\n * @param data\n */\n checkCondition: Function;\n flattenComponentsForRender: Function;\n renderFormSubmission: Function;\n renderComponentValue: Function;\n /**\n * A node-fetch shim adding support for http(s) proxy and allowing\n * invalid tls certificates (to be used with self signed certificates).\n *\n * @param {any} url The request url string or url like object.\n * @param {any} options The request options object.\n * @returns {Promise<Response>} The promise with the node-fetch response object.\n */\n fetch: any;\n /* eslint-disable new-cap */\n base64: {\n /**\n * Base64 encode the given data.\n *\n * @param {String} decoded\n * The decoded data to encode.\n *\n * @return {String}\n * The base64 representation of the given data.\n */\n encode(decoded: string): string;\n /**\n * Base64 decode the given data.\n *\n * @param {String} encoded\n * The encoded data to decode.\n *\n * @return {String}\n * The ascii representation of the given encoded data.\n */\n decode(encoded: string): string;\n };\n /**\n * Application error codes.\n */\n errorCodes: FormioErrors;\n\n layoutComponents: (\"panel\" | \"table\" | \"well\" | \"columns\" | \"fieldset\" | \"tabs\" | string)[];\n\n deleteProp(target: any, propertyKey: any): any;\n\n /**\n * A wrapper around console.log that gets ignored by eslint.\n *\n * @param {*} content\n * The content to pass to console.log.\n */\n log(content: string): void;\n\n /**\n * Determine if a value is a boolean representation.\n * @param value\n * @return {boolean}\n */\n isBoolean(value: any): boolean;\n\n /**\n * Quick boolean coercer.\n * @param value\n * @return {boolean}\n */\n boolean(value: any): boolean;\n\n /**\n * A wrapper around console.error that gets ignored by eslint.\n *\n * @param {*} content\n * The content to pass to console.error.\n */\n error(content: any): void;\n\n /**\n * Returns the URL alias for a form provided the url.\n */\n getAlias(req: Request, reservedForms: string[]): {alias: string; additional: string};\n\n /**\n * Escape a string for use in regex.\n *\n * @param str\n * @returns {*}\n */\n escapeRegExp(str: string): string;\n\n /**\n * Create a sub response object that only handles errors.\n *\n * @param res\n * @return {{send: function(), sendStatus: function(*=), status: function(*=)}}\n */\n createSubResponse(res: Response): Response;\n\n /**\n * Create a sub-request object from the original request.\n *\n * @param req\n */\n createSubRequest(req: Request): Request;\n\n /**\n * Return the objectId.\n *\n * @param id\n * @returns {*}\n * @constructor\n */\n ObjectId(id: string): any;\n\n /**\n * Search the request headers for the given key.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for in the headers.\n *\n * @return\n * The header value if found or false.\n */\n getHeader(req: Request, key: string): string | false;\n\n /**\n * Search the request query for the given key.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for in the query.\n *\n * @return\n * The query value if found or false.\n */\n getQuery(req: Request, key: string): any | false;\n\n /**\n * Search the request parameters for the given key.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for in the parameters.\n *\n * @return\n * The parameter value if found or false.\n */\n getParameter(req: Request, key: string): any | false;\n\n /**\n * Determine if the request has the given key set as a header or url parameter.\n *\n * @param req\n * The Express request object.\n * @param key\n * The key to search for.\n *\n * @return\n * Return the value of the key or false if not found.\n */\n getRequestValue(req: Request, key: string): any | false;\n\n /**\n * Split the given URL into its key/value pairs.\n *\n * @param url\n * The request url to split, typically req.url.\n *\n * @returns {{}}\n * The key/value pairs of the request url.\n */\n getUrlParams(url: string): Record<string, any>;\n\n /**\n * Converts a form component key into a submission key\n * by putting .data. between each nested component\n * (ex: `user.name` becomes `user.data.name` in a submission)\n * @param key\n * The key to convert\n * @return\n * The submission key\n */\n getSubmissionKey(key: string): string;\n\n /**\n * Converts a submission key into a form component key\n * by replacing .data. with .\n * (ex: `user.data.name` becomes `user.name` in a submission)\n * @param key\n * The key to convert\n * @return\n * The form component key\n */\n getFormComponentKey(key: string): string;\n\n /**\n * Utility function to ensure the given id is always a BSON object.\n *\n * @param _id {String|Object}\n * A mongo id as a string or object.\n *\n * @returns {Object}\n * The mongo BSON id.\n */\n idToBson(_id: string | any): any;\n\n /**\n * Utility function to ensure the given id is always a string object.\n *\n * @param _id {String|Object}\n * A mongo id as a string or object.\n *\n * @returns {String}\n * The mongo string id.\n */\n idToString(_id: string | any): string;\n\n /* eslint-enable new-cap */\n\n /**\n * Ensures that a submission data has MongoDB ObjectID's for all \"id\" fields.\n * @param data\n * @return {boolean}\n */\n ensureIds(data: any[]): any;\n\n removeProtectedFields(form: string, action: string, submissions: any): void;\n\n /**\n * Retrieve a unique machine name\n *\n * @param document\n * @param model\n * @param next\n * @return {*}\n */\n uniqueMachineName(document: {machineName: string}, model: any, next: (err?: Error) => void): void;\n\n castValue<T = any>(valueType: \"string\" | \"number\" | \"boolean\" | \"[number]\" | \"[string]\", value: any): T;\n\n valuePath(prefix: string, key: string): string;\n\n eachValue(components: any, data: any, fn: Function, context: any, path?: string): void;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnHook.js","sourceRoot":"","sources":["../../../src/domain/OnHook.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnHook<T = any> {\n on(...args: any[]): boolean | void;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../../../src/domain/Resource.ts"],"names":[],"mappings":"","sourcesContent":["import Express from \"express\";\n\nexport type ResourceHttpHandler = (req: Request, res: Response, next: Express.NextFunction) => void;\n\nexport interface ResourceHttpMethodOptions {\n before?: ResourceHttpHandler;\n after?: ResourceHttpHandler;\n}\n\nexport interface ResourceRestOptions extends ResourceHttpMethodOptions {\n beforePut?: ResourceHttpHandler;\n beforePatch?: ResourceHttpHandler;\n beforePost?: ResourceHttpHandler;\n beforeIndex?: ResourceHttpHandler;\n beforeGet?: ResourceHttpHandler;\n afterPut?: ResourceHttpHandler;\n afterPatch?: ResourceHttpHandler;\n afterPost?: ResourceHttpHandler;\n afterIndex?: ResourceHttpHandler;\n afterGet?: ResourceHttpHandler;\n}\n"]}
|
|
File without changes
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// decorators
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./decorators/action"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./decorators/actionCtx"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./decorators/alter"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./decorators/on"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./decorators/useFormioAuth"), exports);
|
|
10
|
+
// middlewares
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./middlewares/FormioAuthMiddleware"), exports);
|
|
12
|
+
// domain
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./domain/AlterHook"), exports);
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./domain/Formio"), exports);
|
|
15
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioDecodedToken"), exports);
|
|
16
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioAction"), exports);
|
|
17
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioActionsIndex"), exports);
|
|
18
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioAuth"), exports);
|
|
19
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioBaseModel"), exports);
|
|
20
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioConfig"), exports);
|
|
21
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioCtxMapper"), exports);
|
|
22
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioErrors"), exports);
|
|
23
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioHooks"), exports);
|
|
24
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioJs"), exports);
|
|
25
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioModels"), exports);
|
|
26
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioRouter"), exports);
|
|
27
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioSettings"), exports);
|
|
28
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioUpdate"), exports);
|
|
29
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioUtils"), exports);
|
|
30
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioTemplate"), exports);
|
|
31
|
+
(0, tslib_1.__exportStar)(require("./domain/FormioTemplateUtil"), exports);
|
|
32
|
+
(0, tslib_1.__exportStar)(require("./domain/OnHook"), exports);
|
|
33
|
+
// module
|
|
34
|
+
(0, tslib_1.__exportStar)(require("./FormioModule"), exports);
|
|
35
|
+
(0, tslib_1.__exportStar)(require("./builder/FormioMapper"), exports);
|
|
36
|
+
(0, tslib_1.__exportStar)(require("./services/FormioService"), exports);
|
|
37
|
+
(0, tslib_1.__exportStar)(require("./services/FormioDatabase"), exports);
|
|
38
|
+
(0, tslib_1.__exportStar)(require("./services/FormioDatabase"), exports);
|
|
39
|
+
(0, tslib_1.__exportStar)(require("./services/FormioAuthService"), exports);
|
|
40
|
+
(0, tslib_1.__exportStar)(require("./services/FormioHooksService"), exports);
|
|
41
|
+
(0, tslib_1.__exportStar)(require("./components/AlterActions"), exports);
|
|
42
|
+
(0, tslib_1.__exportStar)(require("./components/AlterAudit"), exports);
|
|
43
|
+
(0, tslib_1.__exportStar)(require("./components/AlterLog"), exports);
|
|
44
|
+
(0, tslib_1.__exportStar)(require("./components/AlterHost"), exports);
|
|
45
|
+
(0, tslib_1.__exportStar)(require("./components/AlterSkip"), exports);
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,mEAAoC;AACpC,sEAAuC;AACvC,kEAAmC;AACnC,+DAAgC;AAChC,0EAA2C;AAE3C,cAAc;AACd,kFAAmD;AAEnD,SAAS;AACT,kEAAmC;AACnC,+DAAgC;AAChC,2EAA4C;AAC5C,qEAAsC;AACtC,2EAA4C;AAC5C,mEAAoC;AACpC,wEAAyC;AACzC,qEAAsC;AACtC,wEAAyC;AACzC,qEAAsC;AACtC,oEAAqC;AACrC,iEAAkC;AAClC,qEAAsC;AACtC,qEAAsC;AACtC,uEAAwC;AACxC,qEAAsC;AACtC,oEAAqC;AACrC,uEAAwC;AACxC,2EAA4C;AAC5C,+DAAgC;AAEhC,SAAS;AACT,8DAA+B;AAC/B,sEAAuC;AACvC,wEAAyC;AACzC,yEAA0C;AAC1C,yEAA0C;AAC1C,4EAA6C;AAC7C,6EAA8C;AAC9C,yEAA0C;AAC1C,uEAAwC;AACxC,qEAAsC;AACtC,sEAAuC;AACvC,sEAAuC","sourcesContent":["// decorators\nexport * from \"./decorators/action\";\nexport * from \"./decorators/actionCtx\";\nexport * from \"./decorators/alter\";\nexport * from \"./decorators/on\";\nexport * from \"./decorators/useFormioAuth\";\n\n// middlewares\nexport * from \"./middlewares/FormioAuthMiddleware\";\n\n// domain\nexport * from \"./domain/AlterHook\";\nexport * from \"./domain/Formio\";\nexport * from \"./domain/FormioDecodedToken\";\nexport * from \"./domain/FormioAction\";\nexport * from \"./domain/FormioActionsIndex\";\nexport * from \"./domain/FormioAuth\";\nexport * from \"./domain/FormioBaseModel\";\nexport * from \"./domain/FormioConfig\";\nexport * from \"./domain/FormioCtxMapper\";\nexport * from \"./domain/FormioErrors\";\nexport * from \"./domain/FormioHooks\";\nexport * from \"./domain/FormioJs\";\nexport * from \"./domain/FormioModels\";\nexport * from \"./domain/FormioRouter\";\nexport * from \"./domain/FormioSettings\";\nexport * from \"./domain/FormioUpdate\";\nexport * from \"./domain/FormioUtils\";\nexport * from \"./domain/FormioTemplate\";\nexport * from \"./domain/FormioTemplateUtil\";\nexport * from \"./domain/OnHook\";\n\n// module\nexport * from \"./FormioModule\";\nexport * from \"./builder/FormioMapper\";\nexport * from \"./services/FormioService\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioDatabase\";\nexport * from \"./services/FormioAuthService\";\nexport * from \"./services/FormioHooksService\";\nexport * from \"./components/AlterActions\";\nexport * from \"./components/AlterAudit\";\nexport * from \"./components/AlterLog\";\nexport * from \"./components/AlterHost\";\nexport * from \"./components/AlterSkip\";\n"]}
|
|
File without changes
|
|
@@ -13,29 +13,29 @@ const FormioService_1 = require("../services/FormioService");
|
|
|
13
13
|
*/
|
|
14
14
|
let FormioAuthMiddleware = class FormioAuthMiddleware {
|
|
15
15
|
get tokenHandler() {
|
|
16
|
-
return util_1.promisify(this.formio.middleware.tokenHandler);
|
|
16
|
+
return (0, util_1.promisify)(this.formio.middleware.tokenHandler);
|
|
17
17
|
}
|
|
18
18
|
async use(ctx) {
|
|
19
19
|
const req = ctx.getRequest();
|
|
20
20
|
const res = ctx.getResponse();
|
|
21
21
|
await this.tokenHandler(req, res);
|
|
22
|
-
if (!core_1.getValue(req, "token.user._id")) {
|
|
22
|
+
if (!(0, core_1.getValue)(req, "token.user._id")) {
|
|
23
23
|
throw new exceptions_1.Unauthorized("User unauthorized");
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
tslib_1.__decorate([
|
|
28
|
-
common_1.Inject(),
|
|
29
|
-
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
27
|
+
(0, tslib_1.__decorate)([
|
|
28
|
+
(0, common_1.Inject)(),
|
|
29
|
+
(0, tslib_1.__metadata)("design:type", FormioService_1.FormioService)
|
|
30
30
|
], FormioAuthMiddleware.prototype, "formio", void 0);
|
|
31
|
-
tslib_1.__decorate([
|
|
32
|
-
tslib_1.__param(0, common_1.Context()),
|
|
33
|
-
tslib_1.__metadata("design:type", Function),
|
|
34
|
-
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
35
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
31
|
+
(0, tslib_1.__decorate)([
|
|
32
|
+
(0, tslib_1.__param)(0, (0, common_1.Context)()),
|
|
33
|
+
(0, tslib_1.__metadata)("design:type", Function),
|
|
34
|
+
(0, tslib_1.__metadata)("design:paramtypes", [Object]),
|
|
35
|
+
(0, tslib_1.__metadata)("design:returntype", Promise)
|
|
36
36
|
], FormioAuthMiddleware.prototype, "use", null);
|
|
37
|
-
FormioAuthMiddleware = tslib_1.__decorate([
|
|
38
|
-
common_1.Middleware()
|
|
37
|
+
FormioAuthMiddleware = (0, tslib_1.__decorate)([
|
|
38
|
+
(0, common_1.Middleware)()
|
|
39
39
|
], FormioAuthMiddleware);
|
|
40
40
|
exports.FormioAuthMiddleware = FormioAuthMiddleware;
|
|
41
41
|
//# sourceMappingURL=FormioAuthMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioAuthMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/FormioAuthMiddleware.ts"],"names":[],"mappings":";;;;AAAA,yCAAyD;AACzD,qCAAoC;AACpC,iDAA8C;AAC9C,+BAA+B;AAC/B,6DAAwD;AAExD;;;GAGG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAI/B,IAAI,YAAY;QACd,OAAO,IAAA,gBAAS,EAAC,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,IAAA,eAAQ,EAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE;YACpC,MAAM,IAAI,yBAAY,CAAC,mBAAmB,CAAC,CAAC;SAC7C;IACH,CAAC;CACF,CAAA;AAhBC;IADC,IAAA,eAAM,GAAE;2CACS,6BAAa;oDAAC;AAMhC;IAAW,wBAAA,IAAA,gBAAO,GAAE,CAAA;;;;+CASnB;AAjBU,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CAkBhC;AAlBY,oDAAoB","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"]}
|
|
@@ -33,7 +33,7 @@ export declare class FormioAuthService {
|
|
|
33
33
|
* Retrieve roles
|
|
34
34
|
* @param req
|
|
35
35
|
*/
|
|
36
|
-
getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & import("@tsed/formio-types/lib/domain/FormioRole").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("@tsed/formio-types/lib/domain/FormioRole").FormioRole>>>[]>;
|
|
36
|
+
getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, {}> & import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole>>>[]>;
|
|
37
37
|
/**
|
|
38
38
|
* Update the role of the current user submission
|
|
39
39
|
* @param _id
|
|
@@ -11,7 +11,7 @@ const FormioHooksService_1 = require("./FormioHooksService");
|
|
|
11
11
|
const FormioService_1 = require("./FormioService");
|
|
12
12
|
let FormioAuthService = class FormioAuthService {
|
|
13
13
|
get currentUser() {
|
|
14
|
-
return util_1.promisify(this.formio.auth.currentUser);
|
|
14
|
+
return (0, util_1.promisify)(this.formio.auth.currentUser);
|
|
15
15
|
}
|
|
16
16
|
get getToken() {
|
|
17
17
|
return this.formio.auth.getToken;
|
|
@@ -129,7 +129,7 @@ let FormioAuthService = class FormioAuthService {
|
|
|
129
129
|
throw new exceptions_1.BadRequest("No Submission was found with the given setting `submission`.");
|
|
130
130
|
}
|
|
131
131
|
user.roles = [this.formio.util.idToBson(role)];
|
|
132
|
-
if (core_1.isFunction(user.save)) {
|
|
132
|
+
if ((0, core_1.isFunction)(user.save)) {
|
|
133
133
|
await user.save();
|
|
134
134
|
}
|
|
135
135
|
return user;
|
|
@@ -163,20 +163,20 @@ let FormioAuthService = class FormioAuthService {
|
|
|
163
163
|
return user;
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
tslib_1.__decorate([
|
|
167
|
-
di_1.Inject(),
|
|
168
|
-
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
166
|
+
(0, tslib_1.__decorate)([
|
|
167
|
+
(0, di_1.Inject)(),
|
|
168
|
+
(0, tslib_1.__metadata)("design:type", FormioService_1.FormioService)
|
|
169
169
|
], FormioAuthService.prototype, "formio", void 0);
|
|
170
|
-
tslib_1.__decorate([
|
|
171
|
-
di_1.Inject(),
|
|
172
|
-
tslib_1.__metadata("design:type", FormioHooksService_1.FormioHooksService)
|
|
170
|
+
(0, tslib_1.__decorate)([
|
|
171
|
+
(0, di_1.Inject)(),
|
|
172
|
+
(0, tslib_1.__metadata)("design:type", FormioHooksService_1.FormioHooksService)
|
|
173
173
|
], FormioAuthService.prototype, "hooks", void 0);
|
|
174
|
-
tslib_1.__decorate([
|
|
175
|
-
di_1.Inject(),
|
|
176
|
-
tslib_1.__metadata("design:type", FormioDatabase_1.FormioDatabase)
|
|
174
|
+
(0, tslib_1.__decorate)([
|
|
175
|
+
(0, di_1.Inject)(),
|
|
176
|
+
(0, tslib_1.__metadata)("design:type", FormioDatabase_1.FormioDatabase)
|
|
177
177
|
], FormioAuthService.prototype, "db", void 0);
|
|
178
|
-
FormioAuthService = tslib_1.__decorate([
|
|
179
|
-
di_1.Injectable()
|
|
178
|
+
FormioAuthService = (0, tslib_1.__decorate)([
|
|
179
|
+
(0, di_1.Injectable)()
|
|
180
180
|
], FormioAuthService);
|
|
181
181
|
exports.FormioAuthService = FormioAuthService;
|
|
182
182
|
//# sourceMappingURL=FormioAuthService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioAuthService.js","sourceRoot":"","sources":["../../../src/services/FormioAuthService.ts"],"names":[],"mappings":";;;;AACA,qCAAsC;AACtC,iCAA4C;AAC5C,iDAAoE;AACpE,+BAA+B;AAG/B,qDAAgD;AAChD,6DAAwD;AACxD,mDAA8C;AAG9C,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAU5B,IAAI,WAAW;QACb,OAAO,IAAA,gBAAS,EAAC,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,CAAC,WAAW,EAAE,CAAC;QAEnC,OAAO,CAAC,UAAU,CAAC,IAAI,GA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AAI,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;AApNC;IADC,IAAA,WAAM,GAAE;2CACD,6BAAa;iDAAC;AAGtB;IADC,IAAA,WAAM,GAAE;2CACF,uCAAkB;gDAAC;AAG1B;IADC,IAAA,WAAM,GAAE;2CACL,+BAAc;6CAAC;AARR,iBAAiB;IAD7B,IAAA,eAAU,GAAE;GACA,iBAAiB,CAsN7B;AAtNY,8CAAiB","sourcesContent":["import {PlatformContext, Req} from \"@tsed/common\";\nimport {isFunction} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {BadRequest, NotFound, Unauthorized} from \"@tsed/exceptions\";\nimport {promisify} from \"util\";\nimport {FormioPayloadToken} from \"../domain/FormioDecodedToken\";\nimport {FormioForm, FormioSubmission, WithID} from \"../domain/FormioModels\";\nimport {FormioDatabase} from \"./FormioDatabase\";\nimport {FormioHooksService} from \"./FormioHooksService\";\nimport {FormioService} from \"./FormioService\";\n\n@Injectable()\nexport class FormioAuthService {\n @Inject()\n formio: FormioService;\n\n @Inject()\n hooks: FormioHooksService;\n\n @Inject()\n db: FormioDatabase;\n\n get currentUser() {\n return promisify(this.formio.auth.currentUser);\n }\n\n get getToken() {\n return this.formio.auth.getToken;\n }\n\n get tempToken() {\n return this.formio.auth.tempToken;\n }\n\n get logout() {\n return this.formio.auth.logout;\n }\n\n setCurrentUser<User = any>(user: WithID<FormioSubmission<User>>, token: FormioPayloadToken, ctx: PlatformContext) {\n const request = ctx.getRequest();\n const response = ctx.getResponse();\n\n request.submission.data = user.data;\n request.user = user;\n request.token = token.decoded;\n response.token = token.token;\n request[\"x-jwt-token\"] = token.token;\n\n return this;\n }\n\n /**\n * Generate the payload token for the session\n * @param user\n * @param ctx\n */\n async generatePayloadToken<User = any>(\n user: WithID<FormioSubmission<User>>,\n ctx: PlatformContext\n ): Promise<{user: WithID<FormioSubmission<User>>; token: FormioPayloadToken}> {\n const req = ctx.getRequest();\n const audit = this.formio.audit;\n let form: FormioForm | null;\n\n try {\n form = (await this.db.getForm(user.form)) as any;\n } catch (err) {\n audit(\n \"EAUTH_USERFORM\",\n {\n ...req,\n userId: user._id\n },\n user.form,\n err\n );\n throw err;\n }\n\n if (!form) {\n audit(\n \"EAUTH_USERFORM\",\n {\n ...req,\n userId: user._id\n },\n user.form,\n {message: \"User form not found\"}\n );\n\n throw new NotFound(\"User form not found.\");\n }\n\n try {\n user = await this.hooks.alterAsync(\"user\", user);\n } catch (err) {\n // istanbul ignore next\n ctx.logger.debug(err);\n }\n\n await this.hooks.alterAsync(\"login\", user, req);\n\n // Allow anyone to hook and modify the token.\n const token = this.hooks.alter(\n \"token\",\n {\n user: {\n _id: user._id\n },\n form: {\n _id: form?._id\n }\n },\n form,\n req\n );\n\n const decoded = this.hooks.alter(\"tokenDecode\", token, req);\n\n return {\n user,\n token: {\n token: this.getToken(token) as string,\n decoded\n }\n };\n }\n\n /**\n * Generate session from the given authenticated user.\n * @param user\n * @param ctx\n */\n async generateSession<User = any>(user: WithID<FormioSubmission<User>>, ctx: PlatformContext) {\n try {\n const {user: userSession, token} = await this.generatePayloadToken(user, ctx);\n this.setCurrentUser(userSession, token, ctx);\n\n await this.currentUser(ctx.getRequest(), ctx.getResponse());\n } catch (err) {\n ctx.logger.error({event: \"Error on OAuthActions\", error: err});\n throw new Unauthorized(err.message);\n }\n }\n\n /**\n * Retrieve roles\n * @param req\n */\n async getRoles(req?: Req) {\n try {\n const query = this.hooks.alter(\"roleQuery\", {deleted: {$eq: null}}, req);\n\n return await this.db.roleModel.find(query).sort({title: 1}).lean().exec();\n } catch (err) {\n throw new BadRequest(this.formio.util.errorCodes.role.EROLESLOAD);\n }\n }\n\n /**\n * Update the role of the current user submission\n * @param _id\n * @param role\n * @param req\n */\n async updateUserRole(_id: string | any, role: string, req?: Req) {\n const query = this.hooks.alter(\n \"submissionQuery\",\n {\n _id: this.formio.util.idToBson(_id),\n deleted: {$eq: null}\n },\n req\n );\n\n const user = await this.db.submissionModel.findOne(query).exec();\n\n if (!user) {\n throw new BadRequest(\"No Submission was found with the given setting `submission`.\");\n }\n\n user.roles = [this.formio.util.idToBson(role)];\n\n if (isFunction(user.save)) {\n await user.save();\n }\n\n return user;\n }\n\n /**\n * Create a user submission in formio\n * @param user\n */\n async createUser<User = any>(user: Partial<FormioSubmission<User>>) {\n const submission = new this.db.submissionModel({\n owner: null,\n deleted: null,\n roles: [],\n externalsIds: [],\n ...user,\n created: new Date().toISOString(),\n modified: new Date().toISOString()\n });\n\n user.form && (submission.form = this.db.idToBson(user.form));\n\n await submission.save();\n\n return submission.toObject();\n }\n\n /**\n * Update user submission in formio\n * @param user\n */\n async updateUser<User = any>(user: WithID<FormioSubmission<User>>) {\n await this.db.submissionModel.updateOne(\n {\n _id: user._id\n },\n {$set: user}\n );\n\n return user;\n }\n}\n"]}
|
|
File without changes
|
|
@@ -8,7 +8,7 @@ const FormioMapper_1 = require("../builder/FormioMapper");
|
|
|
8
8
|
const isMongoId_1 = require("../utils/isMongoId");
|
|
9
9
|
const FormioService_1 = require("./FormioService");
|
|
10
10
|
function toMap(list) {
|
|
11
|
-
return core_1.toMap(list, (o) => [o._id.toString(), `$machineName:${o.machineName}`]);
|
|
11
|
+
return (0, core_1.toMap)(list, (o) => [o._id.toString(), `$machineName:${o.machineName}`]);
|
|
12
12
|
}
|
|
13
13
|
let FormioDatabase = class FormioDatabase {
|
|
14
14
|
get models() {
|
|
@@ -60,7 +60,7 @@ let FormioDatabase = class FormioDatabase {
|
|
|
60
60
|
return this.formModel
|
|
61
61
|
.findOne({
|
|
62
62
|
deleted: { $eq: null },
|
|
63
|
-
...(isMongoId_1.isMongoId(nameOrId)
|
|
63
|
+
...((0, isMongoId_1.isMongoId)(nameOrId)
|
|
64
64
|
? {
|
|
65
65
|
_id: nameOrId
|
|
66
66
|
}
|
|
@@ -81,23 +81,23 @@ let FormioDatabase = class FormioDatabase {
|
|
|
81
81
|
return new this.formModel(mapper.mapToImport(form)).save();
|
|
82
82
|
}
|
|
83
83
|
idToBson(form) {
|
|
84
|
-
if (core_1.isArray(form)) {
|
|
84
|
+
if ((0, core_1.isArray)(form)) {
|
|
85
85
|
return { $in: form.map(this.formio.util.idToBson) };
|
|
86
86
|
}
|
|
87
|
-
else if (core_1.isObject(form)) {
|
|
87
|
+
else if ((0, core_1.isObject)(form)) {
|
|
88
88
|
return this.formio.util.idToBson(form._id);
|
|
89
89
|
}
|
|
90
|
-
else if (core_1.isString(form)) {
|
|
90
|
+
else if ((0, core_1.isString)(form)) {
|
|
91
91
|
return this.formio.util.idToBson(form);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
tslib_1.__decorate([
|
|
96
|
-
di_1.Inject(),
|
|
97
|
-
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
95
|
+
(0, tslib_1.__decorate)([
|
|
96
|
+
(0, di_1.Inject)(),
|
|
97
|
+
(0, tslib_1.__metadata)("design:type", FormioService_1.FormioService)
|
|
98
98
|
], FormioDatabase.prototype, "formio", void 0);
|
|
99
|
-
FormioDatabase = tslib_1.__decorate([
|
|
100
|
-
di_1.Injectable()
|
|
99
|
+
FormioDatabase = (0, tslib_1.__decorate)([
|
|
100
|
+
(0, di_1.Injectable)()
|
|
101
101
|
], FormioDatabase);
|
|
102
102
|
exports.FormioDatabase = FormioDatabase;
|
|
103
103
|
//# sourceMappingURL=FormioDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";;;;AAAA,qCAAsE;AACtE,iCAA4C;AAG5C,0DAAqD;AACrD,kDAA6C;AAC7C,mDAA8C;AAE9C,SAAS,KAAK,CAAI,IAAW;IAC3B,OAAO,IAAA,YAAI,EAA8B,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAClH,CAAC;AAGD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,M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AE,IAAY,CAAC,GAAG,CAAC,CAAC;SACrD;aAAM,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF,CAAA;AAjGC;IADC,IAAA,WAAM,GAAE;2CACS,6BAAa;8CAAC;AAFrB,cAAc;IAD1B,IAAA,eAAU,GAAE;GACA,cAAc,CAmG1B;AAnGY,wCAAc","sourcesContent":["import {isArray, isObject, isString, toMap as tMap} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {MongooseDocument, MongooseModel} from \"@tsed/mongoose\";\nimport {FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken} from \"@tsed/formio-types\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {isMongoId} from \"../utils/isMongoId\";\nimport {FormioService} from \"./FormioService\";\n\nfunction toMap<T>(list: any[]) {\n return tMap<string, MongooseDocument<T>>(list, (o: any) => [o._id.toString(), `$machineName:${o.machineName}`]);\n}\n\n@Injectable()\nexport class FormioDatabase {\n @Inject()\n protected formio: FormioService;\n\n get models() {\n return this.formio.mongoose.models;\n }\n\n get roleModel(): MongooseModel<FormioRole> {\n return this.models.role;\n }\n\n get formModel(): MongooseModel<FormioForm> {\n return this.models.form;\n }\n\n get actionModel(): MongooseModel<FormioAction> {\n return this.models.action;\n }\n\n get submissionModel(): MongooseModel<FormioSubmission> {\n return this.models.submission;\n }\n\n get tokenModel(): MongooseModel<FormioToken> {\n return this.models.token;\n }\n\n get actionItemModel(): MongooseModel<FormioActionItem> {\n return this.models.actionItem;\n }\n\n async getFormioMapper(): Promise<FormioMapper> {\n const [roles, forms, actions] = await Promise.all([\n this.roleModel.find({\n deleted: {$eq: null}\n }),\n this.formModel.find({\n deleted: {$eq: null}\n }),\n this.actionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n return new FormioMapper({\n forms: toMap<FormioForm>(forms),\n actions: toMap<FormioAction>(actions),\n roles: toMap<FormioRole>(roles)\n });\n }\n\n async hasForms(): Promise<boolean> {\n return (await this.formModel.countDocuments()) > 0;\n }\n\n async hasForm(name: string): Promise<boolean> {\n return !!(await this.formModel.countDocuments({machineName: {$eq: name}}));\n }\n\n async getForm(nameOrId: string) {\n return this.formModel\n .findOne({\n deleted: {$eq: null},\n ...(isMongoId(nameOrId)\n ? {\n _id: nameOrId\n }\n : {machineName: {$eq: nameOrId}})\n })\n .lean()\n .exec();\n }\n\n async createFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any) {\n if (!(await this.hasForm(form.name))) {\n const createForm = await this.saveFormDefinition(form);\n\n onCreate && (await onCreate(createForm));\n }\n\n return this.getForm(form.name);\n }\n\n async saveFormDefinition(form: FormioForm) {\n const mapper = await this.getFormioMapper();\n\n return new this.formModel(mapper.mapToImport(form)).save();\n }\n\n idToBson(form?: any) {\n if (isArray(form)) {\n return {$in: form.map(this.formio.util.idToBson)};\n } else if (isObject(form)) {\n return this.formio.util.idToBson((form as any)._id);\n } else if (isString(form)) {\n return this.formio.util.idToBson(form);\n }\n }\n}\n"]}
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ let FormioHooksService = class FormioHooksService {
|
|
|
16
16
|
return this.formio.hook.alter;
|
|
17
17
|
}
|
|
18
18
|
get alterAsync() {
|
|
19
|
-
return util_1.promisify(this.alter);
|
|
19
|
+
return (0, util_1.promisify)(this.alter);
|
|
20
20
|
}
|
|
21
21
|
getHooks() {
|
|
22
22
|
return {
|
|
@@ -66,16 +66,16 @@ let FormioHooksService = class FormioHooksService {
|
|
|
66
66
|
}, {});
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
tslib_1.__decorate([
|
|
70
|
-
common_1.Inject(),
|
|
71
|
-
tslib_1.__metadata("design:type", common_1.InjectorService)
|
|
69
|
+
(0, tslib_1.__decorate)([
|
|
70
|
+
(0, common_1.Inject)(),
|
|
71
|
+
(0, tslib_1.__metadata)("design:type", common_1.InjectorService)
|
|
72
72
|
], FormioHooksService.prototype, "injector", void 0);
|
|
73
|
-
tslib_1.__decorate([
|
|
74
|
-
common_1.Inject(FormioService_1.FormioService),
|
|
75
|
-
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
73
|
+
(0, tslib_1.__decorate)([
|
|
74
|
+
(0, common_1.Inject)(FormioService_1.FormioService),
|
|
75
|
+
(0, tslib_1.__metadata)("design:type", FormioService_1.FormioService)
|
|
76
76
|
], FormioHooksService.prototype, "formio", void 0);
|
|
77
|
-
FormioHooksService = tslib_1.__decorate([
|
|
78
|
-
common_1.Injectable()
|
|
77
|
+
FormioHooksService = (0, tslib_1.__decorate)([
|
|
78
|
+
(0, common_1.Injectable)()
|
|
79
79
|
], FormioHooksService);
|
|
80
80
|
exports.FormioHooksService = FormioHooksService;
|
|
81
81
|
//# sourceMappingURL=FormioHooksService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioHooksService.js","sourceRoot":"","sources":["../../../src/services/FormioHooksService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AACjE,+BAA+B;AAE/B,mDAA8C;AAI9C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAO7B,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,IAAA,gBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YACrC,EAAE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AAM,CAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3D,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,IAAA,eAAM,GAAE;2CACW,wBAAe;oDAAC;AAGpC;IADC,IAAA,eAAM,EAAC,6BAAa,CAAC;2CACJ,6BAAa;kDAAC;AALrB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAkF9B;AAlFY,gDAAkB","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"]}
|
|
File without changes
|
|
@@ -35,16 +35,16 @@ let FormioInstaller = class FormioInstaller extends FormioDatabase_1.FormioDatab
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
tslib_1.__decorate([
|
|
39
|
-
di_1.Inject(),
|
|
40
|
-
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
38
|
+
(0, tslib_1.__decorate)([
|
|
39
|
+
(0, di_1.Inject)(),
|
|
40
|
+
(0, tslib_1.__metadata)("design:type", FormioService_1.FormioService)
|
|
41
41
|
], FormioInstaller.prototype, "formio", void 0);
|
|
42
|
-
tslib_1.__decorate([
|
|
43
|
-
di_1.Inject(),
|
|
44
|
-
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
42
|
+
(0, tslib_1.__decorate)([
|
|
43
|
+
(0, di_1.Inject)(),
|
|
44
|
+
(0, tslib_1.__metadata)("design:type", logger_1.Logger)
|
|
45
45
|
], FormioInstaller.prototype, "logger", void 0);
|
|
46
|
-
FormioInstaller = tslib_1.__decorate([
|
|
47
|
-
di_1.Injectable()
|
|
46
|
+
FormioInstaller = (0, tslib_1.__decorate)([
|
|
47
|
+
(0, di_1.Injectable)()
|
|
48
48
|
], FormioInstaller);
|
|
49
49
|
exports.FormioInstaller = FormioInstaller;
|
|
50
50
|
//# sourceMappingURL=FormioInstaller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioInstaller.js","sourceRoot":"","sources":["../../../src/services/FormioInstaller.ts"],"names":[],"mappings":";;;;AAAA,iCAA4C;AAC5C,yCAAoC;AAGpC,qDAAgD;AAChD,mDAA8C;AAG9C,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,+BAAc;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,IAAA,WAAM,GAAE;2CACS,6BAAa;+CAAC;AAGhC;IADC,IAAA,WAAM,GAAE;2CACS,eAAM;+CAAC;AALd,eAAe;IAD3B,IAAA,eAAU,GAAE;GACA,eAAe,CAwC3B;AAxCY,0CAAe","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"]}
|
|
File without changes
|
|
@@ -52,13 +52,13 @@ let FormioService = class FormioService {
|
|
|
52
52
|
return this.formio.Action;
|
|
53
53
|
}
|
|
54
54
|
async exportTemplate(options = {}) {
|
|
55
|
-
return util_1.promisify(this.formio.template.export)(options);
|
|
55
|
+
return (0, util_1.promisify)(this.formio.template.export)(options);
|
|
56
56
|
}
|
|
57
57
|
async importTemplate(template) {
|
|
58
|
-
return util_1.promisify(this.formio.template.import.template)(template);
|
|
58
|
+
return (0, util_1.promisify)(this.formio.template.import.template)(template);
|
|
59
59
|
}
|
|
60
60
|
encrypt(text) {
|
|
61
|
-
return util_1.promisify(this.formio.encrypt)(text);
|
|
61
|
+
return (0, util_1.promisify)(this.formio.encrypt)(text);
|
|
62
62
|
}
|
|
63
63
|
isInit() {
|
|
64
64
|
return !!this.router;
|
|
@@ -89,12 +89,12 @@ let FormioService = class FormioService {
|
|
|
89
89
|
util.error = injector.logger.error.bind(injector.logger);
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
tslib_1.__decorate([
|
|
93
|
-
common_1.Inject(),
|
|
94
|
-
tslib_1.__metadata("design:type", common_1.InjectorService)
|
|
92
|
+
(0, tslib_1.__decorate)([
|
|
93
|
+
(0, common_1.Inject)(),
|
|
94
|
+
(0, tslib_1.__metadata)("design:type", common_1.InjectorService)
|
|
95
95
|
], FormioService.prototype, "injector", void 0);
|
|
96
|
-
FormioService = tslib_1.__decorate([
|
|
97
|
-
common_1.Injectable()
|
|
96
|
+
FormioService = (0, tslib_1.__decorate)([
|
|
97
|
+
(0, common_1.Injectable)()
|
|
98
98
|
], FormioService);
|
|
99
99
|
exports.FormioService = FormioService;
|
|
100
100
|
//# sourceMappingURL=FormioService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/FormioService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AAIjE,+BAA+B;AAS/B,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACtD,MAAM,IAAI,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAGhD,IAAa,aAAa,GAA1B,MAAa,aAAa;IAMxB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,uBAAuB;IACvB,IAAI,OAAO;QACT,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,UA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C1C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,EAAE,CAAC;YAElB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChC;IACH,CAAC;IAES,gBAAgB,CAAC,OAAqB;QAC9C,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QACxB,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAA4B,YAAY,CAAC,CAAC;QAExF,IAAI,gBAAgB,EAAE;YACpB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAAC,GAAG,CAAC;YACtD,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;SACjG;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,UAAU;QAClB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA3GC;IADC,IAAA,eAAM,GAAE;2CACW,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\nconst createRouter = require(\"formio\");\nconst swagger = require(\"formio/src/util/swagger.js\");\nconst util = require(\"formio/src/util/util.js\");\n\n@Injectable()\nexport class FormioService {\n router: FormioRouter;\n\n @Inject()\n protected injector: InjectorService;\n\n get audit(): Function {\n return this.formio.audit || (() => {});\n }\n\n get auth() {\n return this.formio.auth;\n }\n\n // istanbul ignore next\n get swagger() {\n return (...args: any[]) => new Promise((resolve) => swagger(...args, resolve));\n }\n\n get config(): FormioConfig {\n return this.formio.config;\n }\n\n get db(): Db {\n return this.formio.db;\n }\n\n get resources() {\n return this.formio.resources;\n }\n\n get mongoose(): Mongoose {\n return this.formio.mongoose;\n }\n\n get middleware() {\n return this.formio.middleware;\n }\n\n get schemas(): FormioSchemas {\n return this.formio.schemas;\n }\n\n get formio(): Formio {\n return this.router.formio as Formio;\n }\n\n get hook(): FormioHook {\n return this.formio.hook;\n }\n\n get util() {\n return this.formio.util;\n }\n\n get template() {\n return this.formio.template;\n }\n\n get Action() {\n return this.formio.Action;\n }\n\n async exportTemplate(options: Partial<FormioExportOptions> = {}): Promise<FormioTemplate> {\n return promisify(this.formio.template.export)(options);\n }\n\n async importTemplate(template: FormioTemplate): Promise<FormioTemplate> {\n return promisify(this.formio.template.import.template)(template);\n }\n\n encrypt(text: string) {\n return promisify(this.formio.encrypt)(text);\n }\n\n isInit() {\n return !!this.router;\n }\n\n // istanbul ignore next\n public createRouter(options: FormioConfig) {\n return createRouter(options);\n }\n\n public init(options: FormioConfig, hooks: FormioHooks = {}) {\n if (options && Object.keys(options).length) {\n this.router = this.createRouter(this.mapConfiguration(options));\n this.bindLogger();\n\n return this.router.init(hooks);\n }\n }\n\n protected mapConfiguration(options: FormioConfig) {\n const {injector} = this;\n const mongooseSettings = injector.settings.get<MongooseConnectionOptions>(\"mongoose.0\");\n\n if (mongooseSettings) {\n options.mongo = options.mongo || mongooseSettings.url;\n options.mongoConfig = options.mongoConfig || JSON.stringify(mongooseSettings.connectionOptions);\n }\n\n return options;\n }\n\n protected bindLogger() {\n const {injector} = this;\n\n util.log = injector.logger.info.bind(injector.logger);\n util.error = injector.logger.error.bind(injector.logger);\n }\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isMongoId.js","sourceRoot":"","sources":["../../../src/utils/isMongoId.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACpD,CAAC;AAFD,8BAEC","sourcesContent":["export function isMongoId(text: string) {\n return text.toString().match(/^[0-9a-fA-F]{24}$/);\n}\n"]}
|